mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Rich Felker (dalias@libc.org)" <dalias@libc.org>
To: Jaydeep Patil <Jaydeep.Patil@imgtec.com>
Cc: Mahesh Bodapati <Mahesh.Bodapati@imgtec.com>,
	"musl@lists.openwall.com" <musl@lists.openwall.com>,
	"nsz@port70.net" <nsz@port70.net>
Subject: Re: MUSL MIPS64 N64 port
Date: Tue, 1 Mar 2016 23:41:43 -0500	[thread overview]
Message-ID: <20160302044143.GM9349@brightrain.aerifal.cx> (raw)
In-Reply-To: <BD7773622145634B952E5B54ACA8E349AA244A43@PUMAIL01.pu.imgtec.org>

On Tue, Mar 01, 2016 at 07:52:33AM +0000, Jaydeep Patil wrote:
> Also got:
> 
> src/thread/pthread_create.c:212:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>    stack = (void *)(attr._a_stackaddr & -16);
> 
> This is because your pthread types are wrong; you're using the 32-bit arch ones:

This does not seem to be fixed; see below in your new patch:

> diff --git a/arch/mips64/bits/alltypes.h.in b/arch/mips64/bits/alltypes.h.in
> new file mode 100644
> index 0000000..64385c9
> --- /dev/null
> +++ b/arch/mips64/bits/alltypes.h.in
> [...]
> +TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned long __s[9]; } __u; } pthread_attr_t;
> +TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
> +TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
> +TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
> +TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
> +TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
> +TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;

These are still the 32-bit definitions not the 64-bit ones.

> diff --git a/arch/mips64/bits/stat.h b/arch/mips64/bits/stat.h
> new file mode 100644
> index 0000000..dfc80b3
> --- /dev/null
> +++ b/arch/mips64/bits/stat.h
> @@ -0,0 +1,23 @@
> +#include <string.h>
> +#include <bits/alltypes.h>
> +
> +struct stat {
> +	dev_t st_dev;
> +	int pad1[3];
> +	ino_t st_ino;
> +	mode_t st_mode;
> +	nlink_t st_nlink;
> +	uid_t st_uid;
> +	gid_t st_gid;
> +	dev_t st_rdev;
> +	unsigned int pad2[2];
> +	off_t st_size;
> +	int pad3;
> +	struct timespec st_atim;
> +	struct timespec st_mtim;
> +	struct timespec st_ctim;
> +	blksize_t st_blksize;
> +	unsigned int pad4;
> +	blkcnt_t st_blocks;
> +	int pad5[14];
> +};

pad1, pad2 etc. are in the application-reserved namespace. These need
to be __pad1, __pad2, etc. or similar. -- something reserved.

> +static void __stat_fix(struct kernel_stat *kst, struct stat *st)
> +{
> +	st->st_dev = kst->st_dev;
> +	st->pad1[0] = 0;
> +	st->pad1[1] = 0;
> +	st->pad1[2] = 0;
> +	st->st_ino = kst->st_ino;
> +	st->st_mode = kst->st_mode;
> +	st->st_nlink = kst->st_nlink;
> +	st->st_uid = kst->st_uid;
> +	st->st_gid = kst->st_gid;
> +	st->st_rdev = kst->st_rdev;
> +	st->pad2[0] = 0;
> +	st->pad2[1] = 0;
> +	st->st_size = kst->st_size;
> +	st->pad3 = 0;
> +	st->st_atim.tv_sec = kst->st_atime_sec;
> +	st->st_atim.tv_nsec = kst->st_atime_nsec;
> +	st->st_mtim.tv_sec = kst->st_mtime_sec;
> +	st->st_mtim.tv_nsec = kst->st_mtime_nsec;
> +	st->st_ctim.tv_sec = kst->st_ctime_sec;
> +	st->st_ctim.tv_nsec = kst->st_ctime_nsec;
> +	st->st_blksize = kst->st_blksize;
> +	st->st_blocks = kst->st_blocks;
> +	return;
> +}

When I said the memset can be removed I didn't mean to replace it with
assignments. Although they're not as bad, I don't see any reason
they're needed at all. The padding does not need to contain meaningful
content. Just leaving it uninitialized is fine.

Also, the return statement is not needed.

> +static inline long __syscall2(long n, long a, long b)
> +{
> +	struct kernel_stat kst = {0,};

I didn't catch this before, but is there a reason you're filling kst
with zeros before passing it to the kernel? I don't think it's useful,
and it generates extra code the compiler cannot optimize out (because
it cannot know the kernel won't read the memory). Same applies for all
the oher __syscallN's.

The rest of your changes all look okay.

Since it looks like it's about ready to commit, I have a couple
general questions about merging. How should the port be credited? To
imgtec.com? Should someone on your team be the commit author in the
commit, or should I just commit it in my name with your team credited
in the commit message and COPYRIGHT file?

Thanks for your work on this and your patience with review. :)

Rich


  reply	other threads:[~2016-03-02  4:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26  7:13 Jaydeep Patil
2016-03-01  0:11 ` Rich Felker (dalias@libc.org)
2016-03-01  2:35 ` Rich Felker (dalias@libc.org)
2016-03-01  7:52   ` Jaydeep Patil
2016-03-02  4:41     ` Rich Felker (dalias@libc.org) [this message]
2016-03-02  5:50       ` Jaydeep Patil
2016-03-06 17:17         ` Rich Felker (dalias@libc.org)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160302044143.GM9349@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=Jaydeep.Patil@imgtec.com \
    --cc=Mahesh.Bodapati@imgtec.com \
    --cc=musl@lists.openwall.com \
    --cc=nsz@port70.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).