svn commit: r334320 - in head/sys: cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys i386/include

Cy Schubert Cy.Schubert at cschubert.com
Tue May 29 13:02:46 UTC 2018


In message <201805291159.w4TBx3e5085835 at repo.freebsd.org>, Hans Petter 
Selasky
writes:
> Author: hselasky
> Date: Tue May 29 11:59:02 2018
> New Revision: 334320
> URL: https://svnweb.freebsd.org/changeset/base/334320
>
> Log:
>   Implement atomic_add_64() and atomic_subtract_64() for the i386 target.
>   
>   While at it add missing _acq_ and _rel_ variants for 64-bit atomic
>   operations under i386.
>   
>   Reviewed by:	kib @
>   MFC after:	1 week
>   Sponsored by:	Mellanox Technologies
>
> Modified:
>   head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c
>   head/sys/cddl/compat/opensolaris/sys/atomic.h
>   head/sys/i386/include/atomic.h
>
> Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c
> =============================================================================
> =
> --- head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c	Tue May
>  29 10:29:43 2018	(r334319)
> +++ head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c	Tue May
>  29 11:59:02 2018	(r334320)
> @@ -52,7 +52,8 @@ atomic_init(void)
>  }
>  #endif
>  
> -#if !defined(__LP64__) && !defined(__mips_n32) && !defined(ARM_HAVE_ATOMIC64
> )
> +#if !defined(__LP64__) && !defined(__mips_n32) && \
> +    !defined(ARM_HAVE_ATOMIC64) && !defined(__i386__)
>  void
>  atomic_add_64(volatile uint64_t *target, int64_t delta)
>  {
>
> Modified: head/sys/cddl/compat/opensolaris/sys/atomic.h
> =============================================================================
> =
> --- head/sys/cddl/compat/opensolaris/sys/atomic.h	Tue May 29 10:29:43 201
> 8	(r334319)
> +++ head/sys/cddl/compat/opensolaris/sys/atomic.h	Tue May 29 11:59:02 201
> 8	(r334320)
> @@ -36,7 +36,8 @@
>  	atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr
> _t) (_c))
>  #define cas32	atomic_cmpset_32
>  
> -#if !defined(__LP64__) && !defined(__mips_n32) && !defined(ARM_HAVE_ATOMIC64
> )
> +#if !defined(__LP64__) && !defined(__mips_n32) && \
> +    !defined(ARM_HAVE_ATOMIC64) && !defined(__i386__)
>  extern void atomic_add_64(volatile uint64_t *target, int64_t delta);
>  extern void atomic_dec_64(volatile uint64_t *target);
>  #endif
> @@ -85,7 +86,8 @@ atomic_dec_32_nv(volatile uint32_t *target)
>  	return (atomic_fetchadd_32(target, -1) - 1);
>  }
>  
> -#if defined(__LP64__) || defined(__mips_n32) || defined(ARM_HAVE_ATOMIC64)
> +#if defined(__LP64__) || defined(__mips_n32) || \
> +    defined(ARM_HAVE_ATOMIC64) || defined(__i386__)
>  static __inline void
>  atomic_dec_64(volatile uint64_t *target)
>  {
>
> Modified: head/sys/i386/include/atomic.h
> =============================================================================
> =
> --- head/sys/i386/include/atomic.h	Tue May 29 10:29:43 2018	(r33431
> 9)
> +++ head/sys/i386/include/atomic.h	Tue May 29 11:59:02 2018	(r33432
> 0)
> @@ -134,6 +134,8 @@ uint64_t	atomic_load_acq_64(volatile uint64_t *);
>  void		atomic_store_rel_64(volatile uint64_t *, uint64_t);
>  uint64_t	atomic_swap_64(volatile uint64_t *, uint64_t);
>  uint64_t	atomic_fetchadd_64(volatile uint64_t *, uint64_t);
> +void		atomic_add_64(volatile uint64_t *, uint64_t);
> +void		atomic_subtract_64(volatile uint64_t *, uint64_t);
>  
>  #else /* !KLD_MODULE && __GNUCLIKE_ASM */
>  
> @@ -581,6 +583,30 @@ atomic_fetchadd_64(volatile uint64_t *p, uint64_t v)
>  	}
>  }
>  
> +static __inline void
> +atomic_add_64(volatile uint64_t *p, uint64_t v)
> +{
> +	uint64_t t;
> +
> +	for (;;) {
> +		t = *p;
> +		if (atomic_cmpset_64(p, t, t + v))
> +			break;
> +	}
> +}
> +
> +static __inline void
> +atomic_subtract_64(volatile uint64_t *p, uint64_t v)
> +{
> +	uint64_t t;
> +
> +	for (;;) {
> +		t = *p;
> +		if (atomic_cmpset_64(p, t, t - v))
> +			break;
> +	}
> +}
> +
>  #endif /* _KERNEL */
>  
>  #endif /* KLD_MODULE || !__GNUCLIKE_ASM */
> @@ -804,6 +830,16 @@ u_long	atomic_swap_long(volatile u_long *p, u_long v);
>  #define	atomic_fetchadd_32	atomic_fetchadd_int
>  #define	atomic_testandset_32	atomic_testandset_int
>  #define	atomic_testandclear_32	atomic_testandclear_int
> +
> +/* Operations on 64-bit quad words. */
> +#define	atomic_cmpset_acq_64 atomic_cmpset_64
> +#define	atomic_cmpset_rel_64 atomic_cmpset_64
> +#define	atomic_fetchadd_acq_64	atomic_fetchadd_64
> +#define	atomic_fetchadd_rel_64	atomic_fetchadd_64
> +#define	atomic_add_acq_64 atomic_add_64
> +#define	atomic_add_rel_64 atomic_add_64
> +#define	atomic_subtract_acq_64 atomic_subtract_64
> +#define	atomic_subtract_rel_64 atomic_subtract_64
>  
>  /* Operations on pointers. */
>  #define	atomic_set_ptr(p, v) \
>

Hi Hans,

This broke in lib32 on an amd64 system.

--- cddl/lib/libnvpair__L ---
In file included from /opt/src/svn-current/sys/cddl/contrib/opensolaris/
common/nvpair/opensolaris_fnvpair.c:29:
In file included from /opt/src/svn-current/cddl/contrib/opensolaris/lib/
libzpool/common/sys/zfs_context.h:74:
/opt/src/svn-current/sys/cddl/compat/opensolaris/sys/atomic.h:94:2: 
error: implicit declaration of function 'atomic_subtract_64' is invalid 
in C99 [-Werror,-Wimplicit-function-declaration]
        atomic_subtract_64(target, 1);
        ^


-- 
Cheers,
Cy Schubert <Cy.Schubert at cschubert.com>
FreeBSD UNIX:  <cy at FreeBSD.org>   Web:  http://www.FreeBSD.org

	The need of the many outweighs the greed of the few.




More information about the svn-src-head mailing list