I didn't check the patch in detail, but it seems to me that both theencode stuff as well as pgrand belong in src/common rather thansrc/port.
-- Álvaro Herrera http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services