GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_system_timer_stop.c Lines: 25 25 100.0 %
Date: 2026-03-06 19:21:09 Branches: 16 16 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
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   System Management (System)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_system_timer_stop                               PORTABLE C      */
36
/*                                                           6.1.3        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This service stops the timer for the specified widget.              */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    owner                                 Pointer to widget control     */
48
/*                                            block                       */
49
/*    timer_id                              ID of timer                   */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    status                                Completion status             */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    GX_ENTER_CRITICAL                     lock critical section         */
58
/*    GX_EXIT_CRITICAL                      unlock critical section       */
59
/*    tx_timer_deactivate                   stop the ThreadX timer        */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Application                                                    */
64
/*    GUIX Internal Code                                                  */
65
/*                                                                        */
66
/**************************************************************************/
67
1044
UINT _gx_system_timer_stop(GX_WIDGET *owner, UINT timer_id)
68
{
69
1044
UINT      status = GX_FAILURE;
70
GX_TIMER *next_timer;
71
1044
GX_TIMER *previous_timer = GX_NULL;
72
GX_TIMER *search;
73
74
1044
    GX_ENTER_CRITICAL
75
76
    /* find the timer in our active list */
77
1044
    search = _gx_system_active_timer_list;
78
79
1256
    while (search)
80
    {
81
        /* save point to next active timer */
82
847
        next_timer = search -> gx_timer_next;
83
84
        /* is this timer owned by caller? */
85
847
        if (search -> gx_timer_owner == owner)
86
        {
87
            /* is this the requested timer? */
88

652
            if (timer_id == 0 || search -> gx_timer_id == timer_id)
89
            {
90
                /* save status that we found at least one timer */
91
647
                status = GX_SUCCESS;
92
93
                /* If timer we found is first in active list, update list head */
94
647
                if (previous_timer == GX_NULL)
95
                {
96
474
                    _gx_system_active_timer_list = search -> gx_timer_next;
97
                }
98
                else
99
                {
100
173
                    previous_timer -> gx_timer_next = search -> gx_timer_next;
101
                }
102
103
                /* add this timer to head of free list */
104
647
                search -> gx_timer_next = _gx_system_free_timer_list;
105
647
                _gx_system_free_timer_list = search;
106
107
                /* if just looking for one timer, we are done */
108
647
                if (timer_id != 0)
109
                {
110
635
                    break;
111
                }
112
                else
113
                {
114
12
                    search = previous_timer;
115
                }
116
            }
117
        }
118
119
        /* advance search to next active timer */
120
212
        previous_timer = search;
121
212
        search = next_timer;
122
123
    }
124
1044
    GX_EXIT_CRITICAL
125
126
    /* if our active list is NULL, then stop the tx_timer */
127
128
1044
    if (_gx_system_active_timer_list == GX_NULL &&
129
812
        _gx_system_animation_list == GX_NULL)
130
    {
131
#ifdef GX_THREADX_BINDING
132
#ifndef GX_DISABLE_THREADX_TIMER_SOURCE
133
686
        tx_timer_deactivate(&_gx_system_timer);
134
#endif
135
#else
136
        GX_TIMER_STOP;
137
#endif
138
    }
139
1044
    return status;
140
}
141