Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/waterbox/libc/functions/stdio/ftrylockfile.c
2 views
1
/* ftrylockfile( FILE * )
2
3
This file is part of the Public Domain C Library (PDCLib).
4
Permission is granted to use, modify, and / or redistribute at will.
5
*/
6
7
#include <stdio.h>
8
#include <stdarg.h>
9
10
#ifndef REGTEST
11
#include "_PDCLIB_io.h"
12
#include <threads.h>
13
#include <stdlib.h>
14
15
int _PDCLIB_ftrylockfile( FILE * file )
16
{
17
int res = mtx_trylock( &file->lock );
18
switch(res) {
19
case thrd_success:
20
return 0;
21
case thrd_busy:
22
return 1;
23
24
default:
25
abort();
26
}
27
}
28
29
#endif
30
31
#ifdef TEST
32
#include "_PDCLIB_test.h"
33
34
int main( void )
35
{
36
// Not tested here - tested by other stdio test drivers
37
return TEST_RESULTS;
38
}
39
40
#endif
41
42