niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » BSD » FreeBSD » mail-lists » Architecture
Please review: endian invariant kernel dump headers
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
David O'Brien
*nix forums beginner


Joined: 03 Apr 2002
Posts: 1

PostPosted: Wed Apr 03, 2002 8:38 pm    Post subject: Re: Please review: endian invariant kernel dump headers Reply with quote

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

PostPosted: Wed Apr 03, 2002 4:08 am    Post subject: Re: Please review: endian invariant kernel dump headers Reply with quote

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

PostPosted: Wed Apr 03, 2002 3:21 am    Post subject: Re: Please review: endian invariant kernel dump headers Reply with quote

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 Smile

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

PostPosted: Wed Apr 03, 2002 1:42 am    Post subject: Please review: endian invariant kernel dump headers Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 5:39 am | All times are GMT
navigation Forum index » *nix » BSD » FreeBSD » mail-lists » Architecture
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts squid 2.6STABLE1 strips authentication headers Anton Golubev Squid 0 Thu Jul 20, 2006 9:43 pm
No new posts Flash device can't find in kernel and redboot Kevin embedded 1 Thu Jul 20, 2006 10:04 am
No new posts panic (cpu 0) kernel memory fault - seems to point to NIC Reed, Judith Tru64 managers mail-list 0 Wed Jul 19, 2006 8:15 pm
No new posts process taking long time to dump core techimadhu C 4 Wed Jul 19, 2006 6:52 am
No new posts Iptables and kernel 2.6.17 phelp needed Chavdar Videff Debian 8 Wed Jul 19, 2006 6:30 am

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
[ Time: 0.1453s ][ Queries: 20 (0.0568s) ][ GZIP on - Debug on ]