mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-23 10:52:09 +00:00
change(esp_libc): rename newlib component to esp_libc
This commit is contained in:
32
components/esp_libc/src/flockfile.c
Normal file
32
components/esp_libc/src/flockfile.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/lock.h>
|
||||
#include <sys/reent.h>
|
||||
|
||||
void flockfile(FILE *fp)
|
||||
{
|
||||
if (fp && !(fp->_flags & __SSTR)) {
|
||||
__lock_acquire_recursive(fp->_lock);
|
||||
}
|
||||
}
|
||||
|
||||
int ftrylockfile(FILE *fp)
|
||||
{
|
||||
if (fp && !(fp->_flags & __SSTR)) {
|
||||
return __lock_try_acquire_recursive(fp->_lock);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void funlockfile(FILE *fp)
|
||||
{
|
||||
if (fp && !(fp->_flags & __SSTR)) {
|
||||
__lock_release_recursive(fp->_lock);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user