aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/secmod_common.c44
-rw-r--r--src/util/secmod_common.h12
-rw-r--r--src/util/taler-exchange-secmod-eddsa.c1
-rw-r--r--src/util/taler-exchange-secmod-rsa.c1
-rw-r--r--src/util/util.c17
5 files changed, 72 insertions, 3 deletions
diff --git a/src/util/secmod_common.c b/src/util/secmod_common.c
index 975bae3f7..87ce17e06 100644
--- a/src/util/secmod_common.c
+++ b/src/util/secmod_common.c
@@ -23,7 +23,9 @@
#include "taler_signatures.h"
#include "secmod_common.h"
#include <poll.h>
+#ifdef __linux__
#include <sys/eventfd.h>
+#endif
/**
@@ -217,7 +219,11 @@ TES_wake_clients (void)
client = client->next)
{
GNUNET_assert (sizeof (num) ==
+#ifdef __linux__
write (client->esock,
+#else
+ write (client->esock_in,
+#endif
&num,
sizeof (num)));
}
@@ -243,7 +249,7 @@ TES_read_work (void *cls,
recv_size = recv (client->csock,
&buf[off],
sizeof (client->iobuf) - off,
- 0);
+ 0);
if (-1 == recv_size)
{
if ( (0 == off) &&
@@ -309,7 +315,11 @@ TES_await_ready (struct TES_Client *client)
.events = POLLIN
},
{
+#ifdef __linux__
.fd = client->esock,
+#else
+ .fd = client->esock_out,
+#endif
.events = POLLIN
},
};
@@ -324,13 +334,21 @@ TES_await_ready (struct TES_Client *client)
"poll");
for (int i = 0; i<2; i++)
{
+#ifdef __linux__
if ( (pfds[i].fd == client->esock) &&
+#else
+ if ( (pfds[i].fd == client->esock_out) &&
+#endif
(POLLIN == pfds[i].revents) )
{
uint64_t num;
GNUNET_assert (sizeof (num) ==
+#ifdef __linux__
read (client->esock,
+#else
+ read (client->esock_out,
+#endif
&num,
sizeof (num)));
return true;
@@ -349,7 +367,12 @@ TES_free_client (struct TES_Client *client)
client);
GNUNET_assert (0 == pthread_mutex_unlock (&TES_clients_lock));
GNUNET_break (0 == close (client->csock));
+#ifdef __linux__
GNUNET_break (0 == close (client->esock));
+#else
+ GNUNET_break (0 == close (client->esock_in));
+ GNUNET_break (0 == close (client->esock_out));
+#endif
pthread_detach (client->worker);
GNUNET_free (client);
}
@@ -401,7 +424,11 @@ listen_job (void *cls)
{
const struct TES_Callbacks *cb = cls;
int s;
+#ifdef __linux__
int e;
+#else
+ int e[2];
+#endif
struct sockaddr_storage sa;
socklen_t sa_len = sizeof (sa);
@@ -418,6 +445,7 @@ listen_job (void *cls)
"accept");
return;
}
+#ifdef __linux__
e = eventfd (0,
EFD_CLOEXEC);
if (-1 == e)
@@ -427,13 +455,27 @@ listen_job (void *cls)
GNUNET_break (0 == close (s));
return;
}
+#else
+ if (0 != pipe (e))
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+ "pipe");
+ GNUNET_break (0 == close (s));
+ return;
+ }
+#endif
{
struct TES_Client *client;
client = GNUNET_new (struct TES_Client);
client->cb = *cb;
client->csock = s;
+#ifdef __linux__
client->esock = e;
+#else
+ client->esock_in = e[1];
+ client->esock_out = e[0];
+#endif
GNUNET_assert (0 == pthread_mutex_lock (&TES_clients_lock));
GNUNET_CONTAINER_DLL_insert (TES_clients_head,
TES_clients_tail,
diff --git a/src/util/secmod_common.h b/src/util/secmod_common.h
index b24e91cb2..304acebdf 100644
--- a/src/util/secmod_common.h
+++ b/src/util/secmod_common.h
@@ -155,10 +155,22 @@ struct TES_Client
*/
int csock;
+#ifdef __linux__
/**
* Event socket.
*/
int esock;
+#else
+ /**
+ * Input end of the event pipe.
+ */
+ int esock_in;
+
+ /**
+ * Output end of the event pipe.
+ */
+ int esock_out;
+#endif
};
diff --git a/src/util/taler-exchange-secmod-eddsa.c b/src/util/taler-exchange-secmod-eddsa.c
index 02b36fb9a..21aedbc2a 100644
--- a/src/util/taler-exchange-secmod-eddsa.c
+++ b/src/util/taler-exchange-secmod-eddsa.c
@@ -37,7 +37,6 @@
#include "taler-exchange-secmod-eddsa.h"
#include <gcrypt.h>
#include <pthread.h>
-#include <sys/eventfd.h>
#include "taler_error_codes.h"
#include "taler_signatures.h"
#include "secmod_common.h"
diff --git a/src/util/taler-exchange-secmod-rsa.c b/src/util/taler-exchange-secmod-rsa.c
index e40c8e39f..433879299 100644
--- a/src/util/taler-exchange-secmod-rsa.c
+++ b/src/util/taler-exchange-secmod-rsa.c
@@ -36,7 +36,6 @@
#include "taler-exchange-secmod-rsa.h"
#include <gcrypt.h>
#include <pthread.h>
-#include <sys/eventfd.h>
#include "taler_error_codes.h"
#include "taler_signatures.h"
#include "secmod_common.h"
diff --git a/src/util/util.c b/src/util/util.c
index 274dad3cd..2ff295b0b 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -46,4 +46,21 @@ TALER_b2s (const void *buf,
}
+#ifdef __APPLE__
+char *
+strchrnul (const char *s,
+ int c)
+{
+ char *value;
+ value = strchr (s,
+ c);
+ if (NULL == value)
+ value = &s[strlen (s)];
+ return value;
+}
+
+
+#endif
+
+
/* end of util.c */