From: Nadav Har'El <
n...@scylladb.com>
Committer: Nadav Har'El <
n...@scylladb.com>
Branch: master
libc: fix build on C++11 mode of recent gcc
A recently-added named-semaphore feature used std::make_unique<>().
It's hard to remember now, but std::make_unique() wasn't a part of the
original C++11, and was only added later, in C++14. Recent versions of
gcc (such as 13.2.1) started warning when it is used in C++11 compilation
mode, so the build failed.
Eventually, we should switch OSv to the C++14 (or even later) standards,
but I don't want to do that hastely now just to fix the build. So in
this patch I just do what people used to do before the advent of
std::make_unique (and we do many times in OSv): std::unique_ptr(new ...).
Signed-off-by: Nadav Har'El <
n...@scylladb.com>
---
diff --git a/libc/sem.cc b/libc/sem.cc
--- a/libc/sem.cc
+++ b/libc/sem.cc
@@ -132,7 +132,8 @@ sem_t *sem_open(const char *name, int oflag, mode_t mode, unsigned int value)
return SEM_FAILED;
}
- named_semaphores.emplace(std::string(name), std::make_unique<posix_semaphore>(value, 1, true));
+ named_semaphores.emplace(std::string(name),
+ std::unique_ptr<posix_semaphore>(new posix_semaphore(value, 1, true)));
return reinterpret_cast<sem_t *>(&named_semaphores[std::string(name)]);
}
@@ -168,4 +169,4 @@ int sem_close(sem_t *sem)
sem_destroy(sem);
}
return 0;
-}
\ No newline at end of file
+}