summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2013-05-27 16:35:42 +0200
committerVladislav Vaintroub <wlad@montyprogram.com>2013-05-27 16:35:42 +0200
commitef1e767ae37d82bf821bda5062989a05917b7211 (patch)
tree8ae561c7742fb76464bee0b9e32371eff85eca00
parent9bc4c4183df327140b5f477993f10f08282d977f (diff)
downloadmariadb-git-ef1e767ae37d82bf821bda5062989a05917b7211.tar.gz
MDEV-4553 - Fixes for compilation under NetBSD.
-rw-r--r--include/my_global.h2
-rw-r--r--include/my_pthread.h6
-rw-r--r--sql/threadpool_unix.cc22
3 files changed, 25 insertions, 5 deletions
diff --git a/include/my_global.h b/include/my_global.h
index fcfc052d191..981425dc1b1 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1436,6 +1436,7 @@ static inline char *dlerror(void)
#endif
/* Provide __func__ macro definition for platforms that miss it. */
+#if !defined (__func__)
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
@@ -1453,6 +1454,7 @@ static inline char *dlerror(void)
#else
# define __func__ "<unknown>"
#endif
+#endif /* !defined(__func__) */
#ifndef HAVE_RINT
/**
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 5a921fe0f26..d9aae5f47c9 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -119,7 +119,6 @@ int pthread_cancel(pthread_t thread);
#define HAVE_LOCALTIME_R 1
#define _REENTRANT 1
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
-#define PTHREAD_STACK_MIN 65536
#undef SAFE_MUTEX /* This will cause conflicts */
#define pthread_key(T,V) DWORD V
@@ -857,6 +856,11 @@ extern uint thd_lib_detected;
#define mysql_mutex_record_order(A,B) do { } while(0)
#endif
+/* At least Windows and NetBSD do not have this definition */
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 65536
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc
index 94251660e37..41fe87e19d3 100644
--- a/sql/threadpool_unix.cc
+++ b/sql/threadpool_unix.cc
@@ -286,6 +286,20 @@ static void *native_event_get_userdata(native_event *event)
}
#elif defined(HAVE_KQUEUE)
+
+/*
+ NetBSD is incompatible with other BSDs , last parameter in EV_SET macro
+ (udata, user data) needs to be intptr_t, whereas it needs to be void*
+ everywhere else.
+*/
+
+#ifdef __NetBSD__
+#define MY_EV_SET(a, b, c, d, e, f, g) EV_SET(a, b, c, d, e, f, (intptr_t)g)
+#else
+#define MY_EV_SET(a, b, c, d, e, f, g) EV_SET(a, b, c, d, e, f, g)
+#endif
+
+
int io_poll_create()
{
return kqueue();
@@ -294,7 +308,7 @@ int io_poll_create()
int io_poll_start_read(int pollfd, int fd, void *data)
{
struct kevent ke;
- EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT,
+ MY_EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT,
0, 0, data);
return kevent(pollfd, &ke, 1, 0, 0, 0);
}
@@ -303,7 +317,7 @@ int io_poll_start_read(int pollfd, int fd, void *data)
int io_poll_associate_fd(int pollfd, int fd, void *data)
{
struct kevent ke;
- EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT,
+ MY_EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT,
0, 0, data);
return io_poll_start_read(pollfd,fd, data);
}
@@ -312,7 +326,7 @@ int io_poll_associate_fd(int pollfd, int fd, void *data)
int io_poll_disassociate_fd(int pollfd, int fd)
{
struct kevent ke;
- EV_SET(&ke,fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
+ MY_EV_SET(&ke,fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
return kevent(pollfd, &ke, 1, 0, 0, 0);
}
@@ -337,7 +351,7 @@ int io_poll_wait(int pollfd, struct kevent *events, int maxevents, int timeout_m
static void* native_event_get_userdata(native_event *event)
{
- return event->udata;
+ return (void *)event->udata;
}
#elif defined (__sun)