From: Andrew Morton <akpm@linux-foundation.org>
To: Helge Deller <deller@gmx.de>
Cc: linux-kernel@vger.kernel.org, Anton Blanchard <anton@samba.org>,
Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH] Implement prctl(PR_GET_ENDIAN) for all architectures
Date: Mon, 9 Nov 2009 12:46:18 -0800 [thread overview]
Message-ID: <20091109124618.2aa98630.akpm@linux-foundation.org> (raw)
In-Reply-To: <20091022193533.GA5827@p100.box>
On Thu, 22 Oct 2009 21:35:33 +0200
Helge Deller <deller@gmx.de> wrote:
> The PR_GET_ENDIAN and PR_SET_ENDIAN prctl() calls have been implemented
> to allow to switch processes at runtime from big-endian to little-endian
> mode (and vice versa) on PowerPC processors. Since the other architectures
> don't support this feature, they currently will just fail and return -EINVAL.
>
> This patch adds just minimal overhead and implements the PR_GET_ENDIAN
> call for all other architectures by returning the native endianess of
> the architecture. Furthermore, calling prctl(PR_SET_ENDIAN) with the
> native endianess of the architecture will succeed, while trying to
> set another (not-supported) endianess, will fail.
>
> The patch can be tested with the following program:
>
> #include <stdio.h>
> #include <linux/prctl.h>
>
> int main(int argc, char **argv)
> {
> int endian, ret;
>
> ret = prctl(PR_GET_ENDIAN, &endian);
> if (ret)
> perror("prctl(PR_GET_ENDIAN) not implemented");
> printf("current process/machine is running in %s endian mode (%d)\n",
> endian == PR_ENDIAN_LITTLE ? "little":"big", endian);
>
> /* setting native endianess should succeed */
> ret = prctl(PR_SET_ENDIAN, endian);
> printf("prctl(PR_SET_ENDIAN,%d) should succeed: %s\n",
> endian, ret == 0 ? "OK":"FAIL");
>
> /* setting foreign endianess should fail */
> endian = (endian == PR_ENDIAN_LITTLE) ?
> PR_ENDIAN_BIG : PR_ENDIAN_LITTLE;
> ret = prctl(PR_SET_ENDIAN, endian);
> printf("prctl(PR_SET_ENDIAN,%d) should fail: %s\n",
> endian, ret == 0 ? "OK":"FAIL");
> }
>
The changelog forgot to provide any reason for making this change to
the kernel.
next prev parent reply other threads:[~2009-11-09 20:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-22 19:35 [PATCH] Implement prctl(PR_GET_ENDIAN) for all architectures Helge Deller
2009-11-09 20:46 ` Andrew Morton [this message]
2009-11-09 21:32 ` Mikael Pettersson
2009-11-10 22:20 ` Helge Deller
2009-11-10 22:04 ` Helge Deller
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=20091109124618.2aa98630.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=anton@samba.org \
--cc=deller@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox