GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_semaphore_create.c Lines: 5 5 100.0 %
Date: 2024-12-12 17:16:36 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** USBX Component                                                        */
16
/**                                                                       */
17
/**   Utility                                                             */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
23
/* Include necessary system files.  */
24
25
#define UX_SOURCE_CODE
26
27
#include "ux_api.h"
28
29
30
#if !defined(UX_STANDALONE)
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _ux_utility_semaphore_create                        PORTABLE C      */
36
/*                                                           6.1.11       */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function creates a semaphore.                                  */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    semaphore                             Semaphore to create           */
48
/*    semaphore_name                        Semaphore name                */
49
/*    initial_count                         Initial semaphore count       */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    Completion Status                                                   */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    tx_semaphore_create                   ThreadX semaphore create      */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    USBX Components                                                     */
62
/*                                                                        */
63
/*  RELEASE HISTORY                                                       */
64
/*                                                                        */
65
/*    DATE              NAME                      DESCRIPTION             */
66
/*                                                                        */
67
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
68
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
69
/*                                            used UX prefix to refer to  */
70
/*                                            TX symbols instead of using */
71
/*                                            them directly,              */
72
/*                                            resulting in version 6.1    */
73
/*  04-25-2022     Chaoqiong Xiao           Modified comment(s),          */
74
/*                                            off in standalone build,    */
75
/*                                            resulting in version 6.1.11 */
76
/*                                                                        */
77
/**************************************************************************/
78
7889
UINT  _ux_utility_semaphore_create(UX_SEMAPHORE *semaphore, CHAR *semaphore_name, UINT initial_count)
79
{
80
81
UINT    status;
82
83
    /* Call ThreadX to create the semaphore.  */
84
7889
    status =  tx_semaphore_create(semaphore, (CHAR *) semaphore_name, initial_count);
85
86
    /* Check for status.  */
87
7889
    if (status != UX_SUCCESS)
88
    {
89
90
        /* Error trap. */
91
46
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, status);
92
93
        /* If trace is enabled, insert this event into the trace buffer.  */
94
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_SEMAPHORE_ERROR, semaphore, 0, 0, UX_TRACE_ERRORS, 0, 0)
95
96
    }
97
98
    /* Return completion status.  */
99
7889
    return(status);
100
}
101
#endif