Re: c question: *printf'ing arrays
On Tue, 30 Jun 2009 20:21:03 +0200 (CEST), Alexander Best alexbes...@math.uni-muenster.de wrote: thanks. now the output gets redirected using . i'm quite new to programming under unix. sorry for the inconvenience. so i guess there is no really easy way to output an inhomogeneous struct to stdout without using a loop to output each array contained in the struct. No not really. You have to do the sizeof() dance. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: c question: *printf'ing arrays
On Wed, 01 Jul 2009 00:06:05 +0200 (CEST), Alexander Best alexbes...@math.uni-muenster.de wrote: thanks for all the help. i decided to take the pill and coded all the fprintfs by hand. here's the result. usually i'd stick to a higher level languag, but i need C's inline assembly support: struct Header { u_int8_t rom_entry[4]; u_int8_t nintendo_logo[156]; ... fprintf(stderr, \nNintendo Logo: 0x); for (i=0; i sizeof(hdr-nintendo_logo); i++) fprintf(stderr, %x, hdr-nintendo_logo[i]); Note that %x will only print *one* digit for values smaller than 16, i.e. printf(%x, 10) = a, so it may be useful to use %02x instead. fprintf(stderr, \nFixed Value: 0x); fprintf(stderr, %x, hdr-fixed_val); For multi-byte fields, it makes sense to print 0x first and then iterate. For single-byte values, it's probably a tiny bit faster to go only _once_ through for *printf() family formatter, i.e.: - fprintf(stderr, \nFixed Value: 0x); - fprintf(stderr, %x, hdr-fixed_val); + fprintf(stderr, \nFixed Value: 0x%x, hdr-fixed_val); Another nit that I noticed is that your last line doesn't end with \n: fprintf(stderr, \nJoybus Entry Point: 0x); for (i=0; i sizeof(hdr-joybus_entry); i++) fprintf(stderr, %x, hdr-joybus_entry[i]); Some terminal setups will *not* output the last line if it does not finish properly with a \n, so it may be worth editing the code to avoid the \nXXX format idiom, and go for a format style that puts \n at the _end_ of output lines: fprintf(stderr, Nintendo Logo: 0x); for (i = 0; i sizeof(hdr-nintendo_logo); i++) fprintf(stderr, %02x, hdr-nintendo_logo[i]); fprintf(stderr, \n); fprintf(stderr, Fixed Value: 0x%02x\n, hdr-fixed_val); ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: c question: *printf'ing arrays
2009/7/4 Giorgos Keramidas keram...@ceid.upatras.gr: [snip] s/0x%/%#.2hh/g -- Igor ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: bootstrapping gnat GCC on amd64
Status update: http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00102.html I replied to the last email in the thread but haven't heard back yet. Presumably I'll be maintaining the FreeBSD x86_64 port. I'm about to start work on the FreeBSD port now. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
mmap/munmap with zero length
i'm wondering why mmap and munmap behave differently when it comes to a length argument of zero. allocating memory with mmap for a zero length file returns a valid pointer to the mapped region. munmap however isn't able to remove a mapping with no length. wouldn't it be better to either forbid this in mmap or to allow it in munmap? cheers. alex ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: mmap/munmap with zero length
On 7/4/09, Alexander Best alexbes...@math.uni-muenster.de wrote: i'm wondering why mmap and munmap behave differently when it comes to a length argument of zero. allocating memory with mmap for a zero length file returns a valid pointer to the mapped region. there is V flag for malloc.conf munmap however isn't able to remove a mapping with no length. wouldn't it be better to either forbid this in mmap or to allow it in munmap? It wouldn't improve badly written program. -- Paul ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: mmap/munmap with zero length
On Sun, 5 Jul 2009, Alexander Best wrote: i'm wondering why mmap and munmap behave differently when it comes to a length argument of zero. allocating memory with mmap for a zero length file returns a valid pointer to the mapped region. munmap however isn't able to remove a mapping with no length. wouldn't it be better to either forbid this in mmap or to allow it in munmap? POSIX has an opinion: http://www.opengroup.org/onlinepubs/9699919799/functions/mmap.html If len is zero, mmap() shall fail and no mapping shall be established. http://www.opengroup.org/onlinepubs/9699919799/functions/munmap.html The munmap() function shall fail if: ... [EINVAL] The len argument is 0. -- Nate Eldredge neldre...@math.ucsd.edu ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org