RFR: 8087322: Implement a Semaphore utility class
kim.barrett at oracle.com
Wed Jun 24 22:36:02 UTC 2015
On Jun 24, 2015, at 5:31 PM, Stefan Karlsson <stefan.karlsson at oracle.com> wrote:
>> We already have assert_status in debug.hpp. It might be better to add
>> a corresponding guarantee_status there, and use those here.
> 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?
The comment seems to be wrong, since the status that gets passed to strerror is one of the macro arguments.
So one could write something like:
assert_status(ret == 0, errno, “sem_post”);
Maybe the macro had a different form at some point in the distant past? Or maybe there was some other macro
(now gone) that provided strerror-based error reporting that was always unconditionally based on errno?
More information about the hotspot-dev