- Fix build of ats transport plugin not linking against libgnunetnt
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 5 Feb 2019 06:16:19 +0000 (07:16 +0100)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 5 Feb 2019 06:16:19 +0000 (07:16 +0100)
- Add compat memrchr layer for Win32 and macOS

po/POTFILES.in
src/ats/Makefile.am
src/gns/gnunet-service-gns_resolver.c
src/include/compat.h [new file with mode: 0644]
src/include/platform.h
src/util/Makefile.am
src/util/proc_compat.c [new file with mode: 0644]

index a1d1713f923901fdbfc0453bb007351c1c4fab41..0ee48fcde4ed64a98a75ad4607c71b86244a3c31 100644 (file)
@@ -517,6 +517,7 @@ src/util/os_network.c
 src/util/os_priority.c
 src/util/peer.c
 src/util/plugin.c
+src/util/proc_compat.c
 src/util/program.c
 src/util/regex.c
 src/util/resolver_api.c
@@ -539,6 +540,7 @@ src/vpn/vpn_api.c
 src/zonemaster/gnunet-service-zonemaster-monitor.c
 src/zonemaster/gnunet-service-zonemaster.c
 src/fs/fs_api.h
+src/include/compat.h
 src/include/gnunet_common.h
 src/include/gnunet_mq_lib.h
 src/include/gnunet_time_lib.h
index 4f2a93227327531c107fb75b84e29307331c843b..2a62d71bd2fe5881d1866dd84e80dff9c40afc47 100644 (file)
@@ -74,6 +74,7 @@ libgnunet_plugin_ats_proportional_la_LIBADD = \
   libgnunetats.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/util/libgnunetutil.la \
+       $(top_builddir)/src/nt/libgnunetnt.la \
   $(LTLIBINTL)
 libgnunet_plugin_ats_proportional_la_LDFLAGS = \
   $(GN_PLUGIN_LDFLAGS)
index 68c03edf1bf48da9e3e6ddb5d40a7217946903d5..703a0f6522a3b2ead18df499d8d5fa1c2b128bf6 100644 (file)
@@ -624,25 +624,6 @@ timeout_resolution (void *cls)
 }
 
 
-#if (defined WINDOWS) || (defined DARWIN)
-/* Don't have this on W32, here's a naive implementation
- * Was somehow removed on OS X ...  */
-static void *
-memrchr (const void *s,
-        int c,
-        size_t n)
-{
-  const unsigned char *ucs = s;
-  ssize_t i;
-
-  for (i = n - 1; i >= 0; i--)
-    if (c == (int) ucs[i])
-      return (void *) &ucs[i];
-  return NULL;
-}
-#endif
-
-
 /**
  * Get the next, rightmost label from the name that we are trying to resolve,
  * and update the resolution position accordingly.  Labels usually consist
diff --git a/src/include/compat.h b/src/include/compat.h
new file mode 100644 (file)
index 0000000..31a9760
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2001, 2002, 2003, 2004, 2005 GNUnet e.V.
+
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+*/
+
+/**
+ * @author Martin Schanzenbach
+ *
+ * @file include/compat.h
+ * Definitions for macOS and Win32
+ */
+
+#ifndef _COMPAT_H
+#define _COMPAT_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+  /**
+ * memrchr as defined in glibc
+ *
+ * @param s pointer to memory
+ * @param c character to search for
+ * @param n search character limit
+ */
+void*
+GN_memrchr_ (const void *s,
+             int c,
+             size_t n);
+
+#define memrchr(s,c,n) GN_memrchr_(s,c,n)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index e12c4988878577e9a11d4115b5e590f7b81f8eb6..b0a7c0a474d5bbabb00d87f4d041b431c10cb9a7 100644 (file)
 
 #define VERBOSE_STATS 0
 
+#if (defined WINDOWS) || (defined DARWIN)
+#include "compat.h"
+#endif
+
 #ifdef CYGWIN
 #include <sys/reent.h>
 #endif
index fc5a4648ccf46a34f8e3904c217b357fd944b3e8..625ff87a21a6e5dbc1c0c047af1e8e4ccf6aed5f 100644 (file)
@@ -120,7 +120,8 @@ libgnunetutil_la_SOURCES = \
   strings.c \
   time.c \
   tun.c \
-  speedup.c speedup.h
+  speedup.c speedup.h \
+       proc_compat.c
 
 if HAVE_LIBIDN
   LIBIDN= -lidn
diff --git a/src/util/proc_compat.c b/src/util/proc_compat.c
new file mode 100644 (file)
index 0000000..7abea44
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2001, 2002, 2003, 2004, 2005 GNUnet e.V.
+
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+*/
+#include "platform.h"
+
+/**
+ * @author Martin Schanzenbach
+ *
+ * @file util/proc_compat.c
+ * Definitions for macOS and Win32
+ */
+
+
+/**
+ * memrchr as defined in glibc
+ *
+ * @param s pointer to memory
+ * @param c character to search for
+ * @param n search character limit
+ */
+void*
+GN_memrchr_ (const void *s,
+             int c,
+             size_t n)
+{
+  const unsigned char *ucs = s;
+  ssize_t i;
+
+  for (i = n - 1; i >= 0; i--)
+    if (c == (int) ucs[i])
+      return (void *) &ucs[i];
+  return NULL;
+}
+
+