* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
+#include "config.h"
+
#include "gbitlock.h"
#include <glib/gmessages.h>
#include <glib/gslice.h>
#include "gthreadprivate.h"
-#include "config.h"
-#undef HAVE_FUTEX
#ifdef G_BIT_LOCK_FORCE_FUTEX_EMULATION
+#undef HAVE_FUTEX
#endif
#ifndef HAVE_FUTEX
{
#ifdef USE_ASM_GOTO
retry:
- asm volatile goto ("lock bts %1, (%0)\n"
- "jc %l[contended]"
- : /* no output */
- : "r" (address), "r" (lock_bit)
- : "cc", "memory"
- : contended);
+ __asm__ volatile goto ("lock bts %1, (%0)\n"
+ "jc %l[contended]"
+ : /* no output */
+ : "r" (address), "r" (lock_bit)
+ : "cc", "memory"
+ : contended);
return;
contended:
* g_bit_trylock:
* @address: a pointer to an integer
* @lock_bit: a bit value between 0 and 31
- * @returns: %TRUE if the lock was acquired
*
* Sets the indicated @lock_bit in @address, returning %TRUE if
* successful. If the bit is already set, returns %FALSE immediately.
* @address must be atomic in order for this function to work
* reliably.
*
+ * Returns: %TRUE if the lock was acquired
+ *
* Since: 2.24
**/
gboolean
#ifdef USE_ASM_GOTO
gboolean result;
- asm volatile ("lock bts %2, (%1)\n"
- "setnc %%al\n"
- "movzx %%al, %0"
- : "=r" (result)
- : "r" (address), "r" (lock_bit)
- : "cc", "memory");
+ __asm__ volatile ("lock bts %2, (%1)\n"
+ "setnc %%al\n"
+ "movzx %%al, %0"
+ : "=r" (result)
+ : "r" (address), "r" (lock_bit)
+ : "cc", "memory");
return result;
#else
{
const volatile gint *int_address = address;
+ /* this implementation makes these (reasonable) assumptions: */
+ G_STATIC_ASSERT (G_BYTE_ORDER == G_LITTLE_ENDIAN ||
+ (G_BYTE_ORDER == G_BIG_ENDIAN &&
+ sizeof (int) == 4 &&
+ (sizeof (gpointer) == 4 || sizeof (gpointer) == 8)));
+
#if G_BYTE_ORDER == G_BIG_ENDIAN && GLIB_SIZEOF_VOID_P == 8
int_address++;
#endif
* g_pointer_bit_trylock:
* @address: a pointer to a #gpointer-sized value
* @lock_bit: a bit value between 0 and 31
- * @returns: %TRUE if the lock was acquired
*
* This is equivalent to g_bit_trylock, but working on pointers (or
* other pointer-sized values).
* For portability reasons, you may only lock on the bottom 32 bits of
* the pointer.
*
+ * Returns: %TRUE if the lock was acquired
+ *
* Since: 2.30
**/
gboolean