Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use *const pointer for NetBSD's pthread_setname_np #1608

Merged
merged 1 commit into from Nov 29, 2019

Conversation

@lzutao
Copy link
Contributor

lzutao commented Nov 28, 2019

No description provided.

@rust-highfive

This comment has been minimized.

Copy link

rust-highfive commented Nov 28, 2019

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gnzlbg (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@gnzlbg

This comment has been minimized.

Copy link
Collaborator

gnzlbg commented Nov 28, 2019

@lzutao did you run the libc-test suite on NetBSD ?

@lzutao

This comment has been minimized.

Copy link
Contributor Author

lzutao commented Nov 28, 2019

@gnzlbg I didn't because I don't have NetBSD machines.
On NetBSD the second argument is a printf-like string, which can refer to the value provided by the third argument.
Here is how pthread_setname_np implemented in NetBSD: https://github.com/NetBSD/src/blob/465ec24dbfce4dd9b06234d657a05da1d9777865/lib/libpthread/pthread.c#L825

int
pthread_setname_np(pthread_t thread, const char *name, void *arg)
{
	char *oldname, *cp, newname[PTHREAD_MAX_NAMELEN_NP];
	int namelen;

	if (pthread__find(thread) != 0)
		return ESRCH;

	if (thread->pt_magic != PT_MAGIC)
		return EINVAL;

	namelen = snprintf(newname, sizeof(newname), name, arg);
	if (namelen >= PTHREAD_MAX_NAMELEN_NP)
		return EINVAL;

	cp = strdup(newname);
	if (cp == NULL)
		return ENOMEM;

	pthread_mutex_lock(&thread->pt_lock);
	oldname = thread->pt_name;
	thread->pt_name = cp;
	(void)_lwp_setname(thread->pt_lid, cp);
	pthread_mutex_unlock(&thread->pt_lock);

	if (oldname != NULL)
		free(oldname);

	return 0;
}
@gnzlbg

This comment has been minimized.

Copy link
Collaborator

gnzlbg commented Nov 28, 2019

Thanks @lzutao , that checks out. I'm generally a bit more wary of API breaking changes like this, but for NetBSD we only guarantee that libc "builds".

@bors: r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 28, 2019

📌 Commit f851312 has been approved by gnzlbg

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 28, 2019

⌛️ Testing commit f851312 with merge f6455d1...

bors added a commit that referenced this pull request Nov 28, 2019
use *const pointer for NetBSD's pthread_setname_np
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 28, 2019

💔 Test failed - status-azure

@gnzlbg

This comment has been minimized.

Copy link
Collaborator

gnzlbg commented Nov 29, 2019

@bors: retry

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 29, 2019

⌛️ Testing commit f851312 with merge ea0a54a...

bors added a commit that referenced this pull request Nov 29, 2019
use *const pointer for NetBSD's pthread_setname_np
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 29, 2019

☀️ Test successful - checks-cirrus-freebsd-10, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, status-azure
Approved by: gnzlbg
Pushing ea0a54a to master...

@bors bors merged commit f851312 into rust-lang:master Nov 29, 2019
5 of 6 checks passed
5 of 6 checks passed
rust-lang.libc #20191128.1 failed
Details
homu Test successful
Details
nightly x86_64-unknown-freebsd-10 Task Summary
Details
nightly x86_64-unknown-freebsd-12 Task Summary
Details
rust-lang.libc (1) #20191128.1 succeeded
Details
stable x86_64-unknown-freebsd-11 Task Summary
Details
@lzutao lzutao deleted the lzutao:netbsd-mut-pthread_setname_np branch Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.