Bug #3811: Support SOL_SOCKET SO_PEERCRED socket option on OpenBSD
http://redmine.ruby-lang.org/issues/show/3811

Author: Jeremy Evans
Status: Open, Priority: Normal
Category: ext
ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-openbsd4.8]

This makes inspect_peercred in ext/socket/option.c work on OpenBSD-curren=
t.  OpenBSD added support for it on 2010-06-30.  OpenBSD uses a struct so=
ckpeercred instead of a struct ucred for storing the information, because=
 it has used struct ucred for something else since before 1995. See http:=
//fxr.watson.org/fxr/source/sys/ucred.h?v=3DOPENBSD;im=3D3 and http://mar=
c.info/?l=3Dopenbsd-cvs&m=3D127792847027664&w=3D2.

I used a macro to do this, but a typedef would work as well.  Tested on O=
penBSD amd64, OpenBSD i386, and Linux i386.


----------------------------------------
http://redmine.ruby-lang.org
LS0tIGV4dC9zb2NrZXQvb3B0aW9uLmMub3JpZwlXZWQgU2VwICA4IDE4OjI0
OjI4IDIwMTAKKysrIGV4dC9zb2NrZXQvb3B0aW9uLmMJV2VkIFNlcCAgOCAx
ODoyNToyNSAyMDEwCkBAIC0zOTcsMTIgKzM5NywxNyBAQCBpbnNwZWN0X3Rp
bWV2YWxfYXNfaW50ZXJ2YWwoaW50IGxldmVsLCBpbnQgb3B0bmFtZSwgVkEK
IH0KIAogI2lmIGRlZmluZWQoU09MX1NPQ0tFVCkgJiYgZGVmaW5lZChTT19Q
RUVSQ1JFRCkgLyogR05VL0xpbnV4ICovCisjaWYgZGVmaW5lZChfX09wZW5C
U0RfXykKKyNkZWZpbmUgUlVCWV9TT0NLX1BFRVJDUkVEIHN0cnVjdCBzb2Nr
cGVlcmNyZWQKKyNlbHNlCisjZGVmaW5lIFJVQllfU09DS19QRUVSQ1JFRCBz
dHJ1Y3QgdWNyZWQKKyNlbmRpZgogc3RhdGljIGludAogaW5zcGVjdF9wZWVy
Y3JlZChpbnQgbGV2ZWwsIGludCBvcHRuYW1lLCBWQUxVRSBkYXRhLCBWQUxV
RSByZXQpCiB7Ci0g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