Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stub pthread_spinlock_t for Cygwin and OpenBSD

  • Loading branch information...
commit bc740ccfeea5d1e1f8e83d7c6a96303c001745bc 1 parent dae53f1
@kev009 authored
Showing with 37 additions and 3 deletions.
  1. +2 −3 configure.ac
  2. +1 −0  include/craftd/common.h
  3. +34 −0 include/craftd/lock.h
View
5 configure.ac
@@ -109,10 +109,9 @@ AC_CHECK_MEMBERS([struct sigaction.sa_handler], [], [],
[#include <signal.h>
])
+AC_CHECK_TYPES([pthread_spinlock_t], [], [], [[#include <pthread.h>]])
+
# Check if we need to reorder float and double types
AX_C_FLOAT_WORDS_BIGENDIAN
-# Checks for library functions.
-AC_CHECK_FUNCS([socket])
-
AC_OUTPUT
View
1  include/craftd/common.h
@@ -70,6 +70,7 @@
#define CDNull (0)
+#include <craftd/lock.h>
#include <craftd/utils.h>
#include <craftd/memory.h>
#include <craftd/extras.h>
View
34 include/craftd/lock.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010-2011 Kevin M. Bowling, <kevin.bowling@kev009.com>, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+
+#ifndef HAVE_PTHREAD_SPIN_T
+#define pthread_spinlock_t pthread_mutex_t
+#define pthread_spin_init(l, a) pthread_mutex_init(l, NULL)
+#define pthread_spin_destroy(l) pthread_mutex_destroy(l)
+#define pthread_spin_lock(l) pthread_mutex_lock(l)
+#define pthread_spin_unlock(l) pthread_mutex_unlock(l)
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.