GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_mutex_create.c Lines: 5 5 100.0 %
Date: 2026-03-06 18:57:10 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Utility                                                             */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
30
31
#if !defined(UX_STANDALONE)
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_utility_mutex_create                            PORTABLE C      */
37
/*                                                           6.1.11       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function creates a protection mutex.                           */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    mutex                                 Pointer to mutex              */
49
/*    mutex_name                            Name of mutex                 */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    Completion Status                                                   */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    tx_mutex_create                       ThreadX mutex create          */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    USBX Components                                                     */
62
/*                                                                        */
63
/**************************************************************************/
64
794
UINT  _ux_utility_mutex_create(UX_MUTEX *mutex, CHAR *mutex_name)
65
{
66
67
UINT    status;
68
69
70
    /* Call ThreadX to create the Mutex object.  */
71
794
    status =  tx_mutex_create(mutex, (CHAR *) mutex_name, TX_NO_INHERIT);
72
73
    /* Check for status.  */
74
794
    if (status != UX_SUCCESS)
75
    {
76
77
        /* Error trap. */
78
5
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, status);
79
80
        /* If trace is enabled, insert this event into the trace buffer.  */
81
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MUTEX_ERROR, mutex, 0, 0, UX_TRACE_ERRORS, 0, 0)
82
83
    }
84
    /* Return completion status.  */
85
794
    return(status);
86
}
87
#endif