mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jaydeep Patil <Jaydeep.Patil@imgtec.com>
To: "dalias@libc.org" <dalias@libc.org>
Cc: "musl@lists.openwall.com" <musl@lists.openwall.com>,
	"nsz@port70.net" <nsz@port70.net>
Subject: [PATCH] Fix pthread_arch.h for microMIPS
Date: Mon, 21 Mar 2016 10:01:02 +0000	[thread overview]
Message-ID: <BD7773622145634B952E5B54ACA8E349AA24ADD1@PUMAIL01.pu.imgtec.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 2103 bytes --]

Hi Rich,

The patch fixes a link time error when compiled for microMIPS. The pthread_self() function has been modified to use rdhwr instruction instead of .word directive.
The change has been done for both clang and gcc. Functions containing .word are not compiled for microMIPS.

Please refer to https://github.com/JaydeepIMG/musl-1/tree/fix_rdhwr_for_umips for details.



From 09e4e395d9f1538edb548ffaa02db74e8e11701e Mon Sep 17 00:00:00 2001
From: Jaydeep Patil <jaydeep.patil@imgtec.com>
Date: Mon, 21 Mar 2016 09:53:37 +0000
Subject: [PATCH] Use rdhwr insn instead of .word for microMIPS

---
arch/mips/pthread_arch.h   | 10 ++--------
arch/mips64/pthread_arch.h |  9 ++-------
2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/arch/mips/pthread_arch.h b/arch/mips/pthread_arch.h
index 8a49965..30e2394 100644
--- a/arch/mips/pthread_arch.h
+++ b/arch/mips/pthread_arch.h
@@ -1,13 +1,7 @@
static inline struct pthread *__pthread_self()
{
-#ifdef __clang__
-       char *tp;
-       __asm__ __volatile__ (".word 0x7c03e83b ; move %0, $3" : "=r" (tp) : : "$3" );
-#else
-       register char *tp __asm__("$3");
-       /* rdhwr $3,$29 */
-       __asm__ __volatile__ (".word 0x7c03e83b" : "=r" (tp) );
-#endif
+       register char *tp;
+       __asm__ __volatile__ ("rdhwr %0,$29" : "=r" (tp));
        return (pthread_t)(tp - 0x7000 - sizeof(struct pthread));
}

diff --git a/arch/mips64/pthread_arch.h b/arch/mips64/pthread_arch.h
index b42edbe..30e2394 100644
--- a/arch/mips64/pthread_arch.h
+++ b/arch/mips64/pthread_arch.h
@@ -1,12 +1,7 @@
static inline struct pthread *__pthread_self()
{
-#ifdef __clang__
-       char *tp;
-       __asm__ __volatile__ (".word 0x7c03e83b ; move %0, $3" : "=r" (tp) : : "$3" );
-#else
-       register char *tp __asm__("$3");
-       __asm__ __volatile__ (".word 0x7c03e83b" : "=r" (tp) );
-#endif
+       register char *tp;
+       __asm__ __volatile__ ("rdhwr %0,$29" : "=r" (tp));
        return (pthread_t)(tp - 0x7000 - sizeof(struct pthread));
}

--
2.1.4

Thanks,
Jaydeep


[-- Attachment #2: Type: text/html, Size: 6869 bytes --]

             reply	other threads:[~2016-03-21 10:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21 10:01 Jaydeep Patil [this message]
2016-03-21 17:42 ` dalias
2016-03-22  5:09   ` Jaydeep Patil
2016-03-22 21:37     ` dalias
2016-03-23  7:01       ` Jaydeep Patil

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=BD7773622145634B952E5B54ACA8E349AA24ADD1@PUMAIL01.pu.imgtec.org \
    --to=jaydeep.patil@imgtec.com \
    --cc=dalias@libc.org \
    --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).