[COMMIT osv master] libc: fix sem_open() signature

1 view
Skip to first unread message

Commit Bot

unread,
Sep 13, 2023, 2:32:51 AM9/13/23
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

libc: fix sem_open() signature

The signature of the sem_open is different in musl header than it is in the
sem.cc (as a matter of fact the last 2 arguments are only required with
O_CREAT), resulting on sem_open() not being "extern C" and not being
exported to applications. The test tests/tst-semaphore.so couldn't run
because of this. This patch fixes this.

---
diff --git a/libc/sem.cc b/libc/sem.cc
--- a/libc/sem.cc
+++ b/libc/sem.cc
@@ -110,7 +110,7 @@ static std::unordered_map<std::string, indirect_semaphore> named_semaphores;
static mutex named_semaphores_mutex;

OSV_LIBC_API
-sem_t *sem_open(const char *name, int oflag, mode_t mode, unsigned int value)
+sem_t *sem_open(const char *name, int oflag, ...)
{
SCOPE_LOCK(named_semaphores_mutex);
auto iter = named_semaphores.find(std::string(name));
@@ -127,6 +127,11 @@ sem_t *sem_open(const char *name, int oflag, mode_t mode, unsigned int value)
}
else if (oflag & O_CREAT) {
//creating new semaphore
+ va_list ap;
+ va_start(ap, oflag);
+ va_arg(ap, mode_t);
+ unsigned value = va_arg(ap, unsigned);
+ va_end(ap);
if (value > SEM_VALUE_MAX) {
errno = EINVAL;
return SEM_FAILED;
Reply all
Reply to author
Forward
0 new messages