Patch required for app/load_save.c to compile on NetBSD and OpenBSD
Submitted by David H. Gutteridge
fchmod() can't be portably exposed with one particular macro, it's hidden using various macro names depending upon the OS in question. I've just updated packaging of Dia for pkgsrc.org for NetBSD and OpenBSD, my patch is below.
pkgsrc covers a lot of OSes. I've limited my concern to the BSDs. But I'm not even sure the existing code is portable to all Linux distros, e.g. Fedora appears to require __USE_POSIX to expose fchmod(). It looks like DragonFly BSD will work by default (though I haven't tested it), and OpenSolaris-derived OSes will work because of _POSIX_C_SOURCE being used (at least, according to looking at the Illumos sources, again, I haven't tested it). My two cents.
--- app/load_save.c.orig 2014-08-24 11:46:01.000000000 -0400 +++ app/load_save.c @@ -19,7 +19,14 @@
/* so we get fdopen declared even when compiling with -ansi / #define _POSIX_C_SOURCE 200809L -#define _BSD_SOURCE 1 / to get the prototype for fchmod() / +/ to get the prototype for fchmod() */ +#if defined(NetBSD) +#define _NETBSD_SOURCE 1 +#elif defined(OpenBSD) +#define __BSD_VISIBLE 1 +#else +#define _BSD_SOURCE 1 +#endif
#include <sys/stat.h> #ifdef HAVE_UNISTD_H