Thread: [Sablevm-developer] Errno usage considered harmful?!
Brought to you by:
egagnon
From: Grzegorz B. P. <ga...@de...> - 2004-03-10 08:29:06
|
Hi all, I have strange problems with compiler warnings: 1. If I add: #include <errno.h> extern int errno; I get such warning: java_lang_ProcessImpl.c:24: warning: function declaration isn't a prototype 2. In interrupt() implementation I use a pointer to pthread_cond_t: volatile pthread_cond_t *sleeping_on_cond; I also keep getting this warning: java_lang_VMThread.c:342: warning: passing arg 1 of `pthread_cond_broadcast' discards qualifiers from pointer target type which is such code: pthread_cond_broadcast (env_other->thread.sleeping_on_cond); Not sure how to deal with these two. Suggestions are very welcomed. [*] Cheers, Grzegorz B. Prokopski [*] Like a good RTFM, for ex. -- Grzegorz B. Prokopski <ga...@de...> Debian GNU/Linux http://www.debian.org SableVM - LGPLed JVM http://www.sablevm.org Why SableVM ?!? http://devel.sablevm.org/wiki/WhySableVM |
From: Etienne G. <gag...@uq...> - 2004-03-10 14:05:02
|
Hi Greg, Grzegorz B. Prokopski wrote: > 1. If I add: > #include <errno.h> > extern int errno; > I get such warning: > java_lang_ProcessImpl.c:24: warning: function declaration isn't a > prototype You should NEVER declare errno. #include <errno.h> declares it appropriately. (It can be a macro, of many things, specially when you compile with multi-threading support). > 2. In interrupt() implementation I use a pointer to pthread_cond_t: > volatile pthread_cond_t *sleeping_on_cond; > I also keep getting this warning: > java_lang_VMThread.c:342: warning: passing arg 1 of > `pthread_cond_broadcast' discards qualifiers from pointer target type > which is such code: > pthread_cond_broadcast (env_other->thread.sleeping_on_cond); Why aren't you using SableVM's wrapper for broadcasting? I think that we should discuss your code in my office; it would be quicker than long emails... Etienne -- Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ |
From: Clark V. <cl...@CS...> - 2004-03-10 13:44:29
|
I have some guesses, below. -- ttfn, clark cl...@cs... On Wed, 10 Mar 2004, Grzegorz B. Prokopski wrote: > Hi all, > > I have strange problems with compiler warnings: > > 1. If I add: > #include <errno.h> > extern int errno; > I get such warning: > java_lang_ProcessImpl.c:24: warning: function declaration isn't a > prototype It would help to know which line is line 24, but here's something that may be worth checking: Although the extern declaration should be fine, errno may be declared as a macro rather than a simple variable --- particularly with multithreaded code, where errno's exist for each separate thread. Try just using the include and removing the "extern int errno;" statement. > 2. In interrupt() implementation I use a pointer to pthread_cond_t: > volatile pthread_cond_t *sleeping_on_cond; > I also keep getting this warning: > java_lang_VMThread.c:342: warning: passing arg 1 of > `pthread_cond_broadcast' discards qualifiers from pointer target type > which is such code: > pthread_cond_broadcast (env_other->thread.sleeping_on_cond); The prototype for cond_broadcast doesn't expect a volatile type for the argument, so that qualifier is being discarded when you call the function. An explicit cast may eliminate the warning, but the problem is that the cond_broadcast code was not compiled assuming volatile input arguments. If that's a problem then you'll need to re-examine why you need volatile in sleeping_on_cond. > Not sure how to deal with these two. Suggestions are very welcomed. [*] > > Cheers, > > Grzegorz B. Prokopski > > [*] Like a good RTFM, for ex. > > |
From: Grzegorz B. P. <ga...@de...> - 2004-03-14 06:18:10
|
W li=B6cie z =B6ro, 10-03-2004, godz. 08:26, Clark VERBRUGGE pisze:=20 > I have some guesses, below. > Try just using the include and removing the "extern int errno;" > statement. Works, indeed. > > 2. In interrupt() implementation I use a pointer to pthread_cond_t: > > volatile pthread_cond_t *sleeping_on_cond; > > I also keep getting this warning: > > java_lang_VMThread.c:342: warning: passing arg 1 of > > `pthread_cond_broadcast' discards qualifiers from pointer target > type > > which is such code: > > pthread_cond_broadcast (env_other->thread.sleeping_on_cond); >=20 > The prototype for cond_broadcast doesn't expect a volatile type for > the argument, so that qualifier is being discarded when you call the > function. > An explicit cast may eliminate the warning, but the problem is that > the cond_broadcast code was not compiled assuming volatile input > arguments. =20 >=20 > If that's a problem then you'll need to re-examine why you need > volatile in sleeping_on_cond. Good hint. The problem was, that I wanted volatile _pointer_ to pthread_cond_t, not a pointer to volatile pthread_cond_t. I changed the declaration to sth. like: pthread_cond_t *volatile sleeping_on_cond; and the warnings are all gone. Thanks a lot, Grzegorz B. Prokopski --=20 Grzegorz B. Prokopski <ga...@de...> Debian GNU/Linux http://www.debian.org SableVM - LGPLed JVM http://www.sablevm.org Why SableVM ?!? http://devel.sablevm.org/wiki/WhySableVM |
From: Stephen C. <s1...@me...> - 2004-03-12 20:47:34
|
"Grzegorz B. Prokopski" <ga...@de...> writes: > 1. If I add: > #include <errno.h> > extern int errno; > I get such warning: > java_lang_ProcessImpl.c:24: warning: function declaration isn't a > prototype If you are really concerned about systems whose errno.h doesn't declare errno, wrap the variable declaration in a !defined(errno) check. This is what bash (not to mention GNU errno.h) does. I suppose you'd get a warning if you had -Wredundant-decls on and weren't building with threads, but I don't think you do. On GNU, when you are using threads, errno expands to a function call (__errno_location) that returns a pointer, which is then dereferenced. -- Stephen Compall or s11 or sirian The best thing about growing older is that it takes such a long time. bullion Fortezza class struggle lynch Becker spy bootleg Telex Saddam Hussein wire transfer AMW high security bce Manfurov PGP |