It would have been easier if gai_strerror could simply follow the same pattern as strerror on line 3990. So I started off down that path trying to make $GAI_ERRNO_MESSAGES follow the pattern of

  $ERRNO_MESSAGES: {
    0: 'Success',
    {{{ cDefine('EPERM') }}}: 'Not super-user',
    {{{ cDefine('ENOENT') }}}: 'No such file or directory',
    {{{ cDefine('ESRCH') }}}: 'No such process',

however as I say in my comment the keys (e.g. {{{ cDefine('EAI_BADFLAGS') }}} etc.) are actually negative numbers and you can't have expressions as keys in JavaScript literals. See http://stackoverflow.com/questions/8182183/javascript-assoc-array-with-negative-int-keys. The actual reason why you can't use negative numbers is because a negative number is an expression (a minus sign followed by a numeric literal) and you cannot use expresions as keys in an object literal.

So I ended up declaring an empty object and populating it on the first call explicitly stringifying the negative values.

If you can think of a more descriptive comment I'll be happy to use it :-)