[PATCH 1/4] pthreads: add stubs for new *clockwait/*clocklock functions to fix gcc 10 errors

4 views
Skip to first unread message

Waldemar Kozaczuk

unread,
May 5, 2020, 6:13:24 PM5/5/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Nadav writes:
"It appears that the new <mutex> C++ header file (included by include/osv/mutex.h,
I don't remember why) needs pthread_mutex_clocklock() to be defined in our pthread header files.

Let's just implement this function. Seeing that our pthread_mutex_timedlock() is already
a stub (nobody ever complained...), pthread_mutex_clocklock() can also be a stub.
I think this will be easy, and hopefully work."

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
include/api/pthread.h | 2 ++
libc/pthread.cc | 16 ++++++++++++++++
2 files changed, 18 insertions(+)

diff --git a/include/api/pthread.h b/include/api/pthread.h
index 1fca154b..027a4bb1 100644
--- a/include/api/pthread.h
+++ b/include/api/pthread.h
@@ -102,6 +102,7 @@ int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);
int pthread_mutex_trylock(pthread_mutex_t *);
int pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict);
+int pthread_mutex_clocklock(pthread_mutex_t *__restrict, clockid_t clock, const struct timespec *__restrict);
int pthread_mutex_destroy(pthread_mutex_t *);
int pthread_mutex_consistent(pthread_mutex_t *);

@@ -112,6 +113,7 @@ int pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__re
int pthread_cond_destroy(pthread_cond_t *);
int pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict);
int pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict);
+int pthread_cond_clockwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, clockid_t clock, const struct timespec *__restrict);
int pthread_cond_broadcast(pthread_cond_t *);
int pthread_cond_signal(pthread_cond_t *);

diff --git a/libc/pthread.cc b/libc/pthread.cc
index 8c976bf6..2f0afb7f 100644
--- a/libc/pthread.cc
+++ b/libc/pthread.cc
@@ -443,6 +443,13 @@ int pthread_mutex_timedlock(pthread_mutex_t *m,
return EINVAL;
}

+int pthread_mutex_clocklock(pthread_mutex_t *m,
+ clockid_t clock,
+ const struct timespec *abs_timeout)
+{
+ WARN_STUBBED();
+ return EINVAL;
+}

int pthread_mutex_unlock(pthread_mutex_t *m)
{
@@ -616,6 +623,15 @@ int pthread_cond_timedwait(pthread_cond_t *__restrict cond,
return from_libc(cond)->wait(from_libc(mutex), &tmr);
}

+int pthread_cond_clockwait(pthread_cond_t *__restrict cond,
+ pthread_mutex_t *__restrict mutex,
+ clockid_t clock_id,
+ const struct timespec* __restrict ts)
+{
+ WARN_STUBBED();
+ return EINVAL;
+}
+
int pthread_attr_init(pthread_attr_t *attr)
{
new (attr) thread_attr;
--
2.26.2

Waldemar Kozaczuk

unread,
May 5, 2020, 6:13:25 PM5/5/20
to osv...@googlegroups.com, Waldemar Kozaczuk
All of the sudden new gcc 10 complains about some missing types
definitions so we make it happy by including proper headers
in right places.

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
arch/x64/string-ssse3.cc | 1 +
include/osv/index-list.hh | 2 ++
tests/tst-sendfile.cc | 1 +
tests/tst-tcp-cork.cc | 1 +
4 files changed, 5 insertions(+)

diff --git a/arch/x64/string-ssse3.cc b/arch/x64/string-ssse3.cc
index 7a3e0d39..a665b87d 100644
--- a/arch/x64/string-ssse3.cc
+++ b/arch/x64/string-ssse3.cc
@@ -8,6 +8,7 @@
#include "sse.hh"
#include <x86intrin.h>
#include <osv/initialize.hh>
+#include <stdint.h>

// We want to use the PALIGNR SSSE3 instruction to copy relatively
// misaligned data (e.g. 1k from address 0x1000006 to address 0x2000007,
diff --git a/include/osv/index-list.hh b/include/osv/index-list.hh
index 3f8c73f2..36263930 100644
--- a/include/osv/index-list.hh
+++ b/include/osv/index-list.hh
@@ -8,6 +8,8 @@
#ifndef INDEX_LIST_HH_
#define INDEX_LIST_HH_

+#include <stddef.h>
+
// make_index_list<3> evaluates to index_list<0, 1, 2>. This can be used when
// we want to enumerate a template argument pack, for example a tuple's.

diff --git a/tests/tst-sendfile.cc b/tests/tst-sendfile.cc
index 64b63354..1b128ab1 100644
--- a/tests/tst-sendfile.cc
+++ b/tests/tst-sendfile.cc
@@ -15,6 +15,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>

+#include <string>
#include <thread>

/* To compile on Linux: g++ tests/tst-sendfile.cc -Wall -lpthread -std=c++0x */
diff --git a/tests/tst-tcp-cork.cc b/tests/tst-tcp-cork.cc
index 9340969c..bae84ff2 100644
--- a/tests/tst-tcp-cork.cc
+++ b/tests/tst-tcp-cork.cc
@@ -26,6 +26,7 @@
#include <netinet/tcp.h>
#include <assert.h>

+#include <cstdlib>
#include <thread>
#include <chrono>

--
2.26.2

Waldemar Kozaczuk

unread,
May 5, 2020, 6:13:29 PM5/5/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
index e6842b89..7dbaa5ba 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
@@ -698,7 +698,7 @@ zfs_get_parent(const char *datasetname, char *parent, int parentsize)
/*
* Remove the @bla or /bla from the end of the name to get the parent.
*/
- (void) strncpy(parent, datasetname, parentsize);
+ (void) strlcpy(parent, datasetname, parentsize);
cp = strrchr(parent, '@');
if (cp != NULL) {
cp[0] = '\0';
--
2.26.2

Waldemar Kozaczuk

unread,
May 5, 2020, 6:13:31 PM5/5/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
bsd/cddl/contrib/opensolaris/cmd/zfs/zfs_util.h | 2 +-
bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h | 2 +-
.../contrib/opensolaris/lib/libzfs/common/libzfs_util.c | 2 --
.../contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 8 --------
4 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/bsd/cddl/contrib/opensolaris/cmd/zfs/zfs_util.h b/bsd/cddl/contrib/opensolaris/cmd/zfs/zfs_util.h
index 3ddff9e2..a56af59a 100644
--- a/bsd/cddl/contrib/opensolaris/cmd/zfs/zfs_util.h
+++ b/bsd/cddl/contrib/opensolaris/cmd/zfs/zfs_util.h
@@ -33,7 +33,7 @@ extern "C" {

void * safe_malloc(size_t size);
void nomem(void);
-libzfs_handle_t *g_zfs;
+extern libzfs_handle_t *g_zfs;

#ifdef __cplusplus
}
diff --git a/bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h b/bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h
index 134c730f..9fd17b89 100644
--- a/bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h
+++ b/bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h
@@ -63,7 +63,7 @@ void pool_list_free(zpool_list_t *);
int pool_list_count(zpool_list_t *);
void pool_list_remove(zpool_list_t *, zpool_handle_t *);

-libzfs_handle_t *g_zfs;
+extern libzfs_handle_t *g_zfs;

#ifdef __cplusplus
}
diff --git a/bsd/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c b/bsd/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
index c01d8c85..54761500 100644
--- a/bsd/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
+++ b/bsd/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
@@ -55,8 +55,6 @@

#include <bsd/porting/netport.h>

-int aok;
-
int
libzfs_errno(libzfs_handle_t *hdl)
{
diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
index 7dbaa5ba..c2d500ce 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
@@ -5248,14 +5248,6 @@ pool_status_check(const char *name, zfs_ioc_namecheck_t type)
return (error);
}

-#ifdef __OSV__
-
-// really from zvol.c, but we don't build that yet
-void *zfsdev_state;
-
-#endif
-
-
/*
* Find a free minor number.
*/
--
2.26.2

Waldek Kozaczuk

unread,
May 5, 2020, 6:24:04 PM5/5/20
to OSv Development
OK . I believe the 4th one is faulty. At least it makes cpiod crash on Ubuntu 19.10. 

But the first 3 of this series should be good. But should be reviewed.

Waldek 

Commit Bot

unread,
May 5, 2020, 6:48:02 PM5/5/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

pthreads: add stubs for new *clockwait/*clocklock functions to fix gcc 10 errors

Nadav writes:
"It appears that the new <mutex> C++ header file (included by include/osv/mutex.h,
I don't remember why) needs pthread_mutex_clocklock() to be defined in our pthread header files.

Let's just implement this function. Seeing that our pthread_mutex_timedlock() is already
a stub (nobody ever complained...), pthread_mutex_clocklock() can also be a stub.
I think this will be easy, and hopefully work."

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200505221304.4...@gmail.com>

---
diff --git a/include/api/pthread.h b/include/api/pthread.h
--- a/include/api/pthread.h
+++ b/include/api/pthread.h
@@ -102,6 +102,7 @@ int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);
int pthread_mutex_trylock(pthread_mutex_t *);
int pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict);
+int pthread_mutex_clocklock(pthread_mutex_t *__restrict, clockid_t clock, const struct timespec *__restrict);
int pthread_mutex_destroy(pthread_mutex_t *);
int pthread_mutex_consistent(pthread_mutex_t *);

@@ -112,6 +113,7 @@ int pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__re
int pthread_cond_destroy(pthread_cond_t *);
int pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict);
int pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict);
+int pthread_cond_clockwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, clockid_t clock, const struct timespec *__restrict);
int pthread_cond_broadcast(pthread_cond_t *);
int pthread_cond_signal(pthread_cond_t *);

diff --git a/libc/pthread.cc b/libc/pthread.cc

Commit Bot

unread,
May 5, 2020, 7:04:48 PM5/5/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

gcc 10: fix warnings but including various standard headers in couple of files

All of the sudden new gcc 10 complains about some missing types
definitions so we make it happy by including proper headers
in right places.

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200505221304.4...@gmail.com>

---
diff --git a/arch/x64/string-ssse3.cc b/arch/x64/string-ssse3.cc
--- a/arch/x64/string-ssse3.cc
+++ b/arch/x64/string-ssse3.cc
@@ -8,6 +8,7 @@
#include "sse.hh"
#include <x86intrin.h>
#include <osv/initialize.hh>
+#include <stdint.h>

// We want to use the PALIGNR SSSE3 instruction to copy relatively
// misaligned data (e.g. 1k from address 0x1000006 to address 0x2000007,
diff --git a/include/osv/index-list.hh b/include/osv/index-list.hh
--- a/include/osv/index-list.hh
+++ b/include/osv/index-list.hh
@@ -8,6 +8,8 @@
#ifndef INDEX_LIST_HH_
#define INDEX_LIST_HH_

+#include <stddef.h>
+
// make_index_list<3> evaluates to index_list<0, 1, 2>. This can be used when
// we want to enumerate a template argument pack, for example a tuple's.

diff --git a/tests/tst-sendfile.cc b/tests/tst-sendfile.cc
--- a/tests/tst-sendfile.cc
+++ b/tests/tst-sendfile.cc
@@ -15,6 +15,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>

+#include <string>
#include <thread>

/* To compile on Linux: g++ tests/tst-sendfile.cc -Wall -lpthread -std=c++0x */
diff --git a/tests/tst-tcp-cork.cc b/tests/tst-tcp-cork.cc

Commit Bot

unread,
May 5, 2020, 7:08:39 PM5/5/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

zfs: replace strncpy with safer strlcpy which is detected by gcc 10

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200505221304.4...@gmail.com>

---
diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Reply all
Reply to author
Forward
0 new messages