Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern use be32toh instead of bswap32
details: https://anonhg.NetBSD.org/src/rev/a65a77898237
branches: trunk
changeset: 512695:a65a77898237
user: christos <christos%NetBSD.org@localhost>
date: Sat Jul 14 03:05:31 2001 +0000
description:
use be32toh instead of bswap32
add a macro MACHO_MACHDEP_CASES instead of ifdef'ing cpu types.
thanks jason!
diffstat:
sys/kern/exec_macho.c | 31 ++++++++++++++-----------------
1 files changed, 14 insertions(+), 17 deletions(-)
diffs (82 lines):
diff -r 5685cd212d51 -r a65a77898237 sys/kern/exec_macho.c
--- a/sys/kern/exec_macho.c Sat Jul 14 02:18:02 2001 +0000
+++ b/sys/kern/exec_macho.c Sat Jul 14 03:05:31 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_macho.c,v 1.1 2001/07/14 02:09:41 christos Exp $ */
+/* $NetBSD: exec_macho.c,v 1.2 2001/07/14 03:05:31 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -86,17 +86,17 @@
static void
exec_macho_print_fat_header(struct exec_macho_fat_header *fat) {
- printf("fat.magic 0x%x\n", bswap32(fat->magic));
- printf("fat.nfat_arch %d\n", bswap32(fat->nfat_arch));
+ printf("fat.magic 0x%x\n", be32toh(fat->magic));
+ printf("fat.nfat_arch %d\n", be32toh(fat->nfat_arch));
}
static void
exec_macho_print_fat_arch(struct exec_macho_fat_arch *arch) {
- printf("arch.cputype %x\n", bswap32(arch->cputype));
- printf("arch.cpusubtype %d\n", bswap32(arch->cpusubtype));
- printf("arch.offset 0x%lx\n", bswap32(arch->offset));
- printf("arch.size %ld\n", bswap32(arch->size));
- printf("arch.align 0x%lx\n", bswap32(arch->align));
+ printf("arch.cputype %x\n", be32toh(arch->cputype));
+ printf("arch.cpusubtype %d\n", be32toh(arch->cpusubtype));
+ printf("arch.offset 0x%x\n", be32toh(arch->offset));
+ printf("arch.size %d\n", be32toh(arch->size));
+ printf("arch.align 0x%x\n", be32toh(arch->align));
}
static void
@@ -358,7 +358,7 @@
size_t size;
void *buf = &lc;
- if (bswap32(fat->magic) != MACHO_FAT_MAGIC) {
+ if (be32toh(fat->magic) != MACHO_FAT_MAGIC) {
DPRINTF(("bad exec_macho fat magic %x\n", fat->magic));
goto bad;
}
@@ -367,25 +367,22 @@
exec_macho_print_fat_header(fat);
#endif
- for (i = 0; i < bswap32(fat->nfat_arch); i++, arch) {
+ for (i = 0; i < be32toh(fat->nfat_arch); i++, arch) {
if ((error = exec_read_from(p, vp, sizeof(*fat) +
sizeof(arch) * i, &arch, sizeof(arch))) != 0)
goto bad;
#ifdef DEBUG_MACHO
exec_macho_print_fat_arch(&arch);
#endif
- switch (bswap32(arch.cputype)) {
-#ifdef __i386__
- case MACHO_CPU_TYPE_I386:
- goto done;
+ switch (be32toh(arch.cputype)) {
+ MACHO_MACHDEP_CASES
}
-#endif
}
DPRINTF(("This MACH-O binary does not support your cpu"));
goto bad;
done:
- if ((error = exec_read_from(p, vp, bswap32(arch.offset), &hdr,
+ if ((error = exec_read_from(p, vp, be32toh(arch.offset), &hdr,
sizeof(hdr))) != 0)
goto bad;
@@ -410,7 +407,7 @@
}
- aoffs = bswap32(arch.offset);
+ aoffs = be32toh(arch.offset);
offs = aoffs + sizeof(hdr);
size = sizeof(lc);
for (i = 0; i < hdr.ncmds; i++) {
Home |
Main Index |
Thread Index |
Old Index