Skip to content

Commit

Permalink
Stub pthread_spinlock_t for Cygwin and OpenBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
kev009 committed Apr 22, 2011
1 parent dae53f1 commit bc740cc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
5 changes: 2 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions include/craftd/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

#define CDNull (0)

#include <craftd/lock.h>
#include <craftd/utils.h>
#include <craftd/memory.h>
#include <craftd/extras.h>
Expand Down
34 changes: 34 additions & 0 deletions include/craftd/lock.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bc740cc

Please sign in to comment.