From: lufia <[email protected]>
Signed-off-by: lufia <[email protected]>
---
compat/plan9/openssl/crypto.h | 5 +++++
compat/regex/regex_internal.h | 3 +++
config.c | 3 ++-
git-compat-util.h | 9 ++++++++-
parse-options.h | 18 +++++++++---------
remove-bitfields.sh | 17 +++++++++++++++++
6 files changed, 44 insertions(+), 11 deletions(-)
create mode 100644 compat/plan9/openssl/crypto.h
create mode 100755 remove-bitfields.sh
diff --git a/compat/plan9/openssl/crypto.h b/compat/plan9/openssl/crypto.h
new file mode 100644
index 0000000000..9d1ef43422
--- /dev/null
+++ b/compat/plan9/openssl/crypto.h
@@ -0,0 +1,5 @@
+#ifndef __attribute__
+#define __attribute__(x)
+#endif
+
+#include_next <openssl/crypto.h>
diff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h
index 3ee8aae59d..7313c747a6 100644
--- a/compat/regex/regex_internal.h
+++ b/compat/regex/regex_internal.h
@@ -26,6 +26,9 @@
#include <stdlib.h>
#include <string.h>
+#ifdef NEEDS_SYS_PARAM_H
+#include <sys/param.h>
+#endif
#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
# include <langinfo.h>
#endif
diff --git a/config.c b/config.c
index 14de96ee6d..0024b767e5 100644
--- a/config.c
+++ b/config.c
@@ -2462,7 +2462,8 @@ static int store_aux_event(enum config_event_t type,
return error(_("invalid section name '%s'"),
cf->var.buf);
if (cf->subsection_case_sensitive)
- cmpfn = strncasecmp;
+ /* Plan 9's strncasecmp is typed (char*, char*, int) */
+ cmpfn = (int (*)(const char*, const char*,
size_t))strncasecmp;
else
cmpfn = strncmp;
diff --git a/git-compat-util.h b/git-compat-util.h
index f8fdd79591..1aa7877af4 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -164,7 +164,11 @@
#define GIT_WINDOWS_NATIVE
#endif
+#include <sys/types.h>
#include <unistd.h>
+#ifdef __PLAN9__
+#include <libv.h>
+#endif
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -180,7 +184,6 @@
#ifdef NEEDS_SYS_PARAM_H
#include <sys/param.h>
#endif
-#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h>
#include <time.h>
@@ -282,6 +285,10 @@ char *gitbasename(char *);
char *gitdirname(char *);
#endif
+#ifdef __PLAN9__
+#include <machine/endian.h>
+#endif
+
#ifndef NO_ICONV
#include <iconv.h>
#endif
diff --git a/parse-options.h b/parse-options.h
index a4bd40bb6a..38a33a087e 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -46,6 +46,15 @@ enum parse_opt_option_flags {
PARSE_OPT_COMP_ARG = 1024
};
+enum parse_opt_result {
+ PARSE_OPT_COMPLETE = -3,
+ PARSE_OPT_HELP = -2,
+ PARSE_OPT_ERROR = -1, /* must be the same as error() */
+ PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */
+ PARSE_OPT_NON_OPTION,
+ PARSE_OPT_UNKNOWN
+};
+
struct option;
typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
@@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags);
/*----- incremental advanced APIs -----*/
-enum parse_opt_result {
- PARSE_OPT_COMPLETE = -3,
- PARSE_OPT_HELP = -2,
- PARSE_OPT_ERROR = -1, /* must be the same as error() */
- PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */
- PARSE_OPT_NON_OPTION,
- PARSE_OPT_UNKNOWN
-};
-
/*
* It's okay for the caller to consume argv/argc in the usual way.
* Other fields of that structure are private to parse-options and should not
diff --git a/remove-bitfields.sh b/remove-bitfields.sh
new file mode 100755
index 0000000000..952bd34f12
--- /dev/null
+++ b/remove-bitfields.sh
@@ -0,0 +1,17 @@
+#!/bin/ape/sh
+# Plan 9 C compiler rejects initialization a structure including bit field.
+# usage: remove-bitfields.sh [dir ...]
+
+if ! echo abc | sed 's/(ab)c/\1/' >/dev/null 2>&1
+then
+ alias sed='sed -E'
+fi
+
+trap 'rm -f /tmp/remove-bitfields.$pid; exit 1' 1 2 3 15 EXIT
+
+files=$(du -a $* | awk '/\.[ch]$/ { print $2 }')
+for i in $files
+do
+ sed '/(^[ ]*\*|\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\1\2/g'
$i >/tmp/remove-bitfields.$pid
+ cp /tmp/remove-bitfields.$pid $i
+done
--
gitgitgadget