Skip to content

Commit 6629805

Browse files
committed
Add critical_section_enter_cnt_ to posix/pal.c
1 parent 78107e8 commit 6629805

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

libs/pal/posix/pal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,18 @@ static void *thread_entry_wrapper(void *arg) {
121121
}
122122

123123
static pthread_mutex_t critical_section_mutex_ = PTHREAD_MUTEX_INITIALIZER;
124+
static char critical_section_enter_cnt_ = 0;
124125

125126
void am_pal_crit_enter(void) {
126127
int rc = pthread_mutex_lock(&critical_section_mutex_);
128+
AM_ASSERT(0 == critical_section_enter_cnt_);
129+
++critical_section_enter_cnt_;
127130
AM_ASSERT(0 == rc);
128131
}
129132

130133
void am_pal_crit_exit(void) {
134+
AM_ASSERT(1 == critical_section_enter_cnt_);
135+
--critical_section_enter_cnt_;
131136
int rc = pthread_mutex_unlock(&critical_section_mutex_);
132137
AM_ASSERT(0 == rc);
133138
}

0 commit comments

Comments
 (0)