Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
b6f554d9
Commit
b6f554d9
authored
1 month ago
by
Mathieu Westphal
Browse files
Options
Downloads
Patches
Plain Diff
input_file.c: Use HAVE_PHTREADS compile definitions to support building without pthread
parent
dc1b53ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!133
input_file.c: Use HAVE_PHTREADS compile definitions to support building without pthread
Pipeline
#98477
passed
1 month ago
Stage: basic
Stage: levante
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/input_file.c
+14
-1
14 additions, 1 deletion
src/input_file.c
with
14 additions
and
1 deletion
src/input_file.c
+
14
−
1
View file @
b6f554d9
...
...
@@ -18,10 +18,13 @@
#include
<errno.h>
#include
<fcntl.h>
#include
<pthread.h>
#include
<string.h>
#include
<unistd.h>
#if HAVE_PTHREAD
#include
<pthread.h>
#endif
static
void
cdiInputFile_destruct
(
CdiInputFile
*
me
);
// For an explanation of the condestruct() pattern, see the comment in iterator_grib.c
...
...
@@ -64,7 +67,9 @@ success:
static
CdiInputFile
**
openFileList
=
NULL
;
static
size_t
openFileCount
=
0
,
openFileListSize
=
0
;
#if HAVE_PTHREAD
static
pthread_mutex_t
openFileListLock
=
PTHREAD_MUTEX_INITIALIZER
;
#endif
// This either returns a new object, or retains and returns a preexisting open file.
CdiInputFile
*
...
...
@@ -72,8 +77,10 @@ cdiInputFile_make(const char *path)
{
CdiInputFile
*
result
=
NULL
;
xassert
(
path
);
#if HAVE_PTHREAD
int
error
=
pthread_mutex_lock
(
&
openFileListLock
);
xassert
(
!
error
);
#endif
{
// Check the list of open files for the given path.
for
(
size_t
i
=
openFileCount
;
i
--
&&
!
result
;)
...
...
@@ -108,8 +115,10 @@ cdiInputFile_make(const char *path)
}
}
}
#if HAVE_PTHREAD
error
=
pthread_mutex_unlock
(
&
openFileListLock
);
xassert
(
!
error
);
#endif
return
result
;
}
...
...
@@ -142,8 +151,10 @@ cdiInputFile_getPath(const CdiInputFile *me)
void
cdiInputFile_destruct
(
CdiInputFile
*
me
)
{
#if HAVE_PTHREAD
int
error
=
pthread_mutex_lock
(
&
openFileListLock
);
xassert
(
!
error
);
#endif
{
// Find the position of me in the list of open files.
ssize_t
position
=
(
ssize_t
)
openFileCount
;
...
...
@@ -152,8 +163,10 @@ cdiInputFile_destruct(CdiInputFile *me)
// Remove me from the list
openFileList
[
position
]
=
openFileList
[
--
openFileCount
];
}
#if HAVE_PTHREAD
error
=
pthread_mutex_unlock
(
&
openFileListLock
);
xassert
(
!
error
);
#endif
cdiInputFile_condestruct
(
me
,
NULL
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment