Is there a reason why you can't use existing function GetFlushRecPtr() in xlog.c?
No, not really. I think I somehow missed that function when writing the initial version of the patch. Will fix in v2 of the patch.
Hmm, so I've been looking at this, and I've realized that I've written it like this because that's pretty much what pg_current_xlog_location() does. It calls GetXLogWriteRecPtr which does this: