On 03.01.2007 [09:32:17 -0600], Adam Litke wrote:
> On Tue, 2007-01-02 at 15:05 -0800, Nishanth Aravamudan wrote:
> > I noticed that we currently put the "done"s from the segment remapping
> > debugging on their own line. But I'm not sure I see the value, sine it
> > seems rather out of place, given that we specifically use DEBUG_CONT().
> > I think it looks cleaner (and saves up to two lines of screen space) to
> > not newline-terminate the previous output.
>
> I think the main reason we always use newlines is to force a flush of
> stderr to make sure we see the output right away. So, we could take
> this patch, but then you'd need to add a call to fflush(stderr) in
> each debug macro.
Fair enough, doing so, though, causes the macros to become multi-line,
and I had to add do { } while(0)s to preserve their statement-ness :)
Seems like overkill, but I definitely prefer the formatting in the
output.
I noticed that we currently put the "done"s from the segment remapping
debugging on their own line. But I'm not sure I see the value, sine it
seems rather out of place, given that we specifically use DEBUG_CONT().
I think it looks cleaner (and saves up to two lines of screen space) to
not newline-terminate the previous output.
Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>
diff --git a/elflink.c b/elflink.c
index b621a3a..60af377 100644
--- a/elflink.c
+++ b/elflink.c
@@ -600,13 +600,13 @@ static int prepare_segment(struct seg_info *seg)
* be contained in the filesz portion of the segment.
*/
- DEBUG("Mapped hugeseg at %p. Copying %#0lx bytes from %p...\n",
+ DEBUG("Mapped hugeseg at %p. Copying %#0lx bytes from %p...",
p, seg->filesz, seg->vaddr);
memcpy(p, seg->vaddr, seg->filesz);
DEBUG_CONT("done\n");
if (extra_end > extra_start) {
- DEBUG("Copying extra %#0lx bytes from %p...\n",
+ DEBUG("Copying extra %#0lx bytes from %p...",
(unsigned long)(extra_end - extra_start), extra_start);
gap = extra_start - (seg->vaddr + seg->filesz);
memcpy((p + seg->filesz + gap), extra_start, (extra_end -
extra_start));
diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
index 10b02fe..40da66a 100644
--- a/libhugetlbfs_internal.h
+++ b/libhugetlbfs_internal.h
@@ -31,20 +31,36 @@
extern int __hugetlbfs_verbose;
#define ERROR(...) \
- if (__hugetlbfs_verbose >= 1) \
- fprintf(stderr, "libhugetlbfs: ERROR: " __VA_ARGS__)
+ do { \
+ if (__hugetlbfs_verbose >= 1) { \
+ fprintf(stderr, "libhugetlbfs: ERROR: " __VA_ARGS__); \
+ fflush(stderr); \
+ } \
+ } while (0)
#define WARNING(...) \
- if (__hugetlbfs_verbose >= 2) \
- fprintf(stderr, "libhugetlbfs: WARNING: " __VA_ARGS__)
+ do { \
+ if (__hugetlbfs_verbose >= 2) { \
+ fprintf(stderr, "libhugetlbfs: WARNING: " __VA_ARGS__);
\
+ fflush(stderr); \
+ } \
+ } while (0)
#define DEBUG(...) \
- if (__hugetlbfs_verbose >= 3) \
- fprintf(stderr, "libhugetlbfs: " __VA_ARGS__)
+ do { \
+ if (__hugetlbfs_verbose >= 3) { \
+ fprintf(stderr, "libhugetlbfs: " __VA_ARGS__); \
+ fflush(stderr); \
+ } \
+ } while (0)
#define DEBUG_CONT(...) \
- if (__hugetlbfs_verbose >= 3) \
- fprintf(stderr, __VA_ARGS__)
+ do { \
+ if (__hugetlbfs_verbose >= 3) { \
+ fprintf(stderr, __VA_ARGS__); \
+ fflush(stderr); \
+ } \
+ } while (0)
#if defined(__powerpc64__) && !defined(__LP64__)
/* Older binutils fail to provide this symbol */
--
Nishanth Aravamudan <[EMAIL PROTECTED]>
IBM Linux Technology Center
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel