Did you propose your patch to upstream?
If so, what's the URL in the bugtracker/etc.?
Have not proposed upstream. I thought it wise get to some feedback from
this list about this change first. Not sure I understand all the issues.
Your patch looks okay to me, but only upstream can say that
for sure.
Even if there's a slightly more elegant solution, you'd usually
have a better chance of finding it when discussing with upstream.
At least, that's my experience. Also, every project has its own
methods and "style" to deal with such portability issues.