You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.2 KiB
C

/* See the end of this file for copyright and license terms. */
#pragma once
#ifndef _ARCH_ATOM_H_
#error "This file is not meant to be included directly, use <arch/atom.h>"
#endif
#include <gay/cdefs.h>
#include <gay/types.h>
/*
* we use ILP32 on i386, long is the same as int
*/
#ifndef __ILP32__
#error "__ILP32__ must be defined on i386"
#endif
static inline void latom_init(latom_t *latom, long val)
{
latom->_value = val;
}
static inline long latom_read(const latom_t *latom)
{
return latom->_value;
}
static __always_inline long latom_xchg(latom_t *latom, long val)
{
return atom_xchg((atom_t *)latom, val);
}
static __always_inline long latom_cmp_xchg(latom_t *latom, long compare, long val)
{
return atom_cmp_xchg((atom_t *)latom, compare, val);
}
static __always_inline long latom_add(latom_t *latom, long val)
{
return atom_add((atom_t *)latom, val);
}
static __always_inline long latom_sub(latom_t *latom, long val)
{
return atom_sub((atom_t *)latom, val);
}
static __always_inline bool latom_inc(latom_t *latom)
{
return atom_inc((atom_t *)latom);
}
static __always_inline bool latom_dec(latom_t *latom)
{
return atom_dec((atom_t *)latom);
}
static __always_inline long latom_and(latom_t *latom, long val)
{
return atom_and((atom_t *)latom, val);
}
static __always_inline long latom_or(latom_t *latom, long val)
{
return atom_or((atom_t *)latom, val);
}
static __always_inline long latom_xor(latom_t *latom, long val)
{
return atom_xor((atom_t *)latom, val);
}
static __always_inline bool latom_set_bit(latom_t *latom, int pos)
{
return atom_set_bit((atom_t *)latom, pos);
}
static __always_inline bool latom_clr_bit(latom_t *latom, int pos)
{
return atom_clr_bit((atom_t *)latom, pos);
}
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/