portability: fix build on Solaris-derived systemd
Current Illumos and older Solaris require _XOPEN_SOURCE for
msg_control. O_DIRECTORY doesn't exist on older systems either,
so fallback to O_RDONLY. It's good enough as a repository will
require both R and X permission anyway.
--- a/contrib/chg/hgclient.c Wed Jul 03 12:32:57 2024 +0200
+++ b/contrib/chg/hgclient.c Mon Jun 24 18:54:59 2024 +0200
@@ -7,6 +7,11 @@
* GNU General Public License version 2 or any later version.
*/
+#if defined(__sun) && !defined(_XOPEN_SOURCE)
+/* msg_control is used */
+#define _XOPEN_SOURCE 600
+#endif
+
#include <arpa/inet.h> /* for ntohl(), htonl() */
#include <assert.h>
#include <ctype.h>
@@ -26,6 +31,10 @@
#include "procutil.h"
#include "util.h"
+#ifndef O_DIRECTORY
+#define O_DIRECTORY O_RDONLY
+#endif
+
enum {
CAP_GETENCODING = 0x0001,
CAP_RUNCOMMAND = 0x0002,