va_arg is not well-defined for shorter-than-int arguments

Use int instead of mode_t, as the latter is either int or short
(cherry picked from commit e471bfd58655521fbb5474b49ec85ece174eeee7)
Add missing platform header for HP-UX.

The code compiles without it, but gets the wrong definition of stat
on HP-UX
(cherry picked from commit 6f2025af92da86c70af6e0d67bf6faa187838233)
Merge pull request #1127 from kacfengine/3.5.x

[3.5.x] Fixes for HP-UX.