RFR: 8087322: Implement a Semaphore utility class

David Holmes david.holmes at oracle.com
Wed Jun 24 23:44:04 UTC 2015

On 25/06/2015 8:46 AM, Kim Barrett wrote:
> On Jun 24, 2015, at 6:39 PM, David Holmes <david.holmes at oracle.com> wrote:
>>> 1) The comment above vmassert_status says:
>>> // This version of vmassert is for use with checking return status from
>>> // library calls that return actual error values eg. EINVAL,
>>> // ENOMEM etc, rather than returning -1 and setting errno.
>>> // When the status is not what is expected it is very useful to know
>>> // what status was actually returned, so we pass the status variable as
>>> // an extra arg and use strerror to convert it to a meaningful string
>>> // like "Invalid argument", "out of memory" etc
>>> but called library calls actually do return -1 and sets errno. Maybe the
>>> comment is too specific?
>> No the comment is as I intended when I wrote it :) This was for those POSIX library calls that don't set errno and return -1, but which return an error code directly: eg the pthread_* family of functions for POSIX
>> Where did you see another form of library call using it? It is possible some misuse has crept in.
> Oh, good, we actually have original intent available.
> Would you consider it a misuse to do
>      assert_status(ret == 0, errno, <msg>);

That works, but it wasn't the intended use case :) And of course you 
have to be sure that when the macro expands there are no intervening 
calls that will potentially modify errno - which there aren't in this case.

But if we're going to start using it this way then the comment block 
needs updating to clarify the two different use-cases.


More information about the hotspot-dev mailing list