|
|
|
|
|
|
| Author |
Message |
David O'Brien *nix forums beginner
Joined: 03 Apr 2002
Posts: 1
|
Posted: Wed Apr 03, 2002 8:38 pm Post subject:
Re: Please review: endian invariant kernel dump headers
|
|
|
On Tue, Apr 02, 2002 at 07:42:08PM -0800, Marcel Moolenaar wrote:
| Quote: | +#include <machine/endian.h
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define dtoh32(x) __bswap32(x)
+#define dtoh64(x) __bswap64(x)
+#define htod32(x) __bswap32(x)
+#define htod64(x) __bswap64(x)
+#else
+#define dtoh32(x) x
+#define dtoh64(x) x
+#define htod32(x) x
+#define htod64(x) x
+#endif
|
Why can't you just use __bswap64 directly, or some other wrappers.
I am seeing this part in more and more source files with the macros
taking on serveral spellings. Lets please standardize this.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Mike Barcroft *nix forums beginner
Joined: 03 Apr 2002
Posts: 25
|
Posted: Wed Apr 03, 2002 4:08 am Post subject:
Re: Please review: endian invariant kernel dump headers
|
|
|
Marcel Moolenaar <marcel@xcllnt.net> writes:
| Quote: | Please review the attached patch. The change achieves the following:
[...]
Index: sys/sys/kerneldump.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/kerneldump.h,v
retrieving revision 1.2
diff -u -r1.2 kerneldump.h
--- sys/sys/kerneldump.h 2 Apr 2002 10:53:59 -0000 1.2
+++ sys/sys/kerneldump.h 3 Apr 2002 03:15:20 -0000
@@ -38,6 +38,25 @@
#ifndef _SYS_KERNELDUMP_H
#define _SYS_KERNELDUMP_H
+#include <machine/endian.h
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define dtoh32(x) __bswap32(x)
+#define dtoh64(x) __bswap64(x)
+#define htod32(x) __bswap32(x)
+#define htod64(x) __bswap64(x)
+#else
+#define dtoh32(x) x
+#define dtoh64(x) x
+#define htod32(x) x
+#define htod64(x) x
+#endif
|
Adding extra parens around `x' in the !LITTLE_ENDIAN case would
prevent bitting future developers that might be expecting this to be
evaluated like a function.
The rest looks okay.
Best regards,
Mike Barcroft
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Poul-Henning Kamp *nix forums Guru
Joined: 21 Mar 2002
Posts: 436
|
Posted: Wed Apr 03, 2002 3:21 am Post subject:
Re: Please review: endian invariant kernel dump headers
|
|
|
In message <20020403034208.GA929@dhcp01.pn.xcllnt.net>, Marcel Moolenaar writes
:
| Quote: | Please review the attached patch. The change achieves the following:
1. Dump the kernel header in dump byte order. This is the same
as network byte order. Parity calculation is endianness
invariant and should not use the macros.
|
good.
| Quote: | 2. The kernel dump header had a size of 520 bytes on 64-bit
architectures due to alignment of the uint64_t following
the uint32_t. Reordering solves that.
|
My fault, I thought I had that right.
| Quote: | 3. No version bump is required, because all existing headers are
in little-endian and thus will not have the same version as
the big-endian dumps. I did not add support in savecore to
read version 0x01000000 headers
|
Cool.
Suggest you add:
CTASSERT(sizeof kerneldumpheader == 512);
while at it.
| Quote: | If there are no blocking objections I like to commit this quickly
due to point 2.
|
By all means.
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Marcel Moolenaar *nix forums Guru Wannabe
Joined: 03 Apr 2002
Posts: 120
|
Posted: Wed Apr 03, 2002 1:42 am Post subject:
Please review: endian invariant kernel dump headers
|
|
|
Gang,
Please review the attached patch. The change achieves the following:
1. Dump the kernel header in dump byte order. This is the same
as network byte order. Parity calculation is endianness
invariant and should not use the macros.
2. The kernel dump header had a size of 520 bytes on 64-bit
architectures due to alignment of the uint64_t following
the uint32_t. Reordering solves that.
3. No version bump is required, because all existing headers are
in little-endian and thus will not have the same version as
the big-endian dumps. I did not add support in savecore to
read version 0x01000000 headers :-)
If there are no blocking objections I like to commit this quickly
due to point 2.
Thanks,
--
Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Jan 08, 2009 5:39 am | All times are GMT
|
|
Send Telegram | Debt Consolidation | Mortgages | Debt Consolidation | Business Credit Cards
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|