Skip to content

Commit 85f44d3

Browse files
committed
gnu.cfg: Added support for semtimedop().
1 parent 63e58b9 commit 85f44d3

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

cfg/gnu.cfg

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,34 @@
9292
<valid>0:</valid>
9393
</arg>
9494
</function>
95+
<!-- https://man7.org/linux/man-pages/man2/semop.2.html -->
96+
<!-- int semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout); -->
97+
<function name="semtimedop">
98+
<noreturn>false</noreturn>
99+
<returnValue type="int"/>
100+
<use-retval/>
101+
<leak-ignore/>
102+
<arg nr="1" direction="in">
103+
<not-uninit/>
104+
<not-bool/>
105+
<valid>0:</valid>
106+
</arg>
107+
<arg nr="2" direction="out">
108+
<not-null/>
109+
<not-uninit/>
110+
<not-bool/>
111+
</arg>
112+
<arg nr="3" direction="in">
113+
<not-uninit/>
114+
<not-bool/>
115+
<valid>0:</valid>
116+
</arg>
117+
<arg nr="4" direction="in">
118+
<!-- If the timeout argument is NULL, then semtimedop() behaves exactly like semop() -->
119+
<not-uninit/>
120+
<not-bool/>
121+
</arg>
122+
</function>
95123
<!-- void * __builtin_assume_aligned (const void *exp, size_t align, ...) -->
96124
<!-- This function can have either two or three arguments, if it has three, the third argument should have integer type. -->
97125
<function name="__builtin_assume_aligned">

test/cfg/gnu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,20 @@
1616
#include <sys/types.h>
1717
#include <pwd.h>
1818
#include <sys/mman.h>
19+
#include <sys/sem.h>
1920
#include <wchar.h>
2021
#ifndef __CYGWIN__
2122
#include <sys/epoll.h>
2223
#endif
2324

25+
int nullPointer_semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout)
26+
{
27+
(void) semtimedop(semid, sops, nsops, NULL); // If the timeout argument is NULL, then semtimedop() behaves exactly like semop().
28+
(void) semtimedop(semid, sops, nsops, timeout);
29+
// cppcheck-suppress nullPointer
30+
return semtimedop(semid, NULL, nsops, timeout);
31+
}
32+
2433
void *nullPointer_mempcpy(void *dest, const void *src, size_t n)
2534
{
2635
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)