This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: is_mp(), sysconf, and atoi. (Statically-linked multithreaded app s broken on X86?)


Is there a stylistic reason to prefer this one?

I would have said that it doesn't matter much which one you choose.  If the index version doesn't generate essentially the same code as the pointer version at -O2, then the optimizer has a problem.  So I think it really is purely a readability issue.  (Also this routine runs either once or twice at startup, and never thereafter.)

Hans

> -----Original Message-----
> From: Mohan Embar [mailto:gnustuff at thisiscool dot com]
> Sent: Friday, March 07, 2003 10:25 PM
> To: GCJ Java
> Subject: Re: is_mp(), sysconf, and atoi. (Statically-linked
> multithreaded app s broken on X86?)
> 
> 
> Hans,
> 
> I don't pretend to even have a clue as to what you're talking 
> about, but I was
> wondering what you thought of the following idiom instead of 
> what you had
> in linux-threads.c. Am I being too anal?
> 
> If you're too busy to waste time on this, I understand.
> 
> -- Mohan
> http://www.thisiscool.com/
> http://www.animalsong.org/
> 
> Index: linux_threads.c
> ===================================================================
> RCS file: /cvsroot/gcc/gcc/boehm-gc/linux_threads.c,v
> retrieving revision 1.20
> diff -u -2 -r1.20 linux_threads.c
> --- linux_threads.c	29 Mar 2002 22:52:12 -0000	1.20
> +++ linux_threads.c	8 Mar 2003 06:18:27 -0000
> @@ -1022,5 +1022,12 @@
>          if (stat_buf[i] == '\n' && stat_buf[i+1] == 'c'
>  	    && stat_buf[i+2] == 'p' && stat_buf[i+3] == 'u') {
> -	    int cpu_no = atoi(stat_buf + i + 4);
> +	    /* int cpu_no = atoi(stat_buf + i + 4); */
> +	    int cpu_no = 0;
> +	    const char* pchCurBufPos = stat_buf + i + 4;
> +	    char c;
> +	    while ((c = *pchCurBufPos++) >= '0' & c <= '9') {
> +		cpu_no *= 10;
> +		cpu_no += (c - '0');
> +	    }
>  	    if (cpu_no >= result) result = cpu_no + 1;
>  	}
> 
> 
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]