Fix func signature and build for darwin platform