404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.140.188.79: ~ $
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _ASM_IA64_CMPXCHG_H
#define _ASM_IA64_CMPXCHG_H

/*
 * Compare/Exchange, forked from asm/intrinsics.h
 * which was:
 *
 *	Copyright (C) 2002-2003 Hewlett-Packard Co
 *	David Mosberger-Tang <davidm@hpl.hp.com>
 */

#ifndef __ASSEMBLY__

#include <linux/types.h>
/* include compiler specific intrinsics */
#include <asm/ia64regs.h>
#ifdef __INTEL_COMPILER
# include <asm/intel_intrin.h>
#else
# include <asm/gcc_intrin.h>
#endif

/*
 * This function doesn't exist, so you'll get a linker error if
 * something tries to do an invalid xchg().
 */
extern void ia64_xchg_called_with_bad_pointer(void);

#define __xchg(x, ptr, size)						\
({									\
	unsigned long __xchg_result;					\
									\
	switch (size) {							\
	case 1:								\
		__xchg_result = ia64_xchg1((__u8 *)ptr, x);		\
		break;							\
									\
	case 2:								\
		__xchg_result = ia64_xchg2((__u16 *)ptr, x);		\
		break;							\
									\
	case 4:								\
		__xchg_result = ia64_xchg4((__u32 *)ptr, x);		\
		break;							\
									\
	case 8:								\
		__xchg_result = ia64_xchg8((__u64 *)ptr, x);		\
		break;							\
	default:							\
		ia64_xchg_called_with_bad_pointer();			\
	}								\
	__xchg_result;							\
})

#define xchg(ptr, x)							\
((__typeof__(*(ptr))) __xchg((unsigned long) (x), (ptr), sizeof(*(ptr))))

/*
 * Atomic compare and exchange.  Compare OLD with MEM, if identical,
 * store NEW in MEM.  Return the initial value in MEM.  Success is
 * indicated by comparing RETURN with OLD.
 */

/*
 * This function doesn't exist, so you'll get a linker error
 * if something tries to do an invalid cmpxchg().
 */
extern long ia64_cmpxchg_called_with_bad_pointer(void);

#define ia64_cmpxchg(sem, ptr, old, new, size)				\
({									\
	__u64 _o_, _r_;							\
									\
	switch (size) {							\
	case 1:								\
		_o_ = (__u8) (long) (old);				\
		break;							\
	case 2:								\
		_o_ = (__u16) (long) (old);				\
		break;							\
	case 4:								\
		_o_ = (__u32) (long) (old);				\
		break;							\
	case 8:								\
		_o_ = (__u64) (long) (old);				\
		break;							\
	default:							\
		break;							\
	}								\
	switch (size) {							\
	case 1:								\
		_r_ = ia64_cmpxchg1_##sem((__u8 *) ptr, new, _o_);	\
		break;							\
									\
	case 2:								\
		_r_ = ia64_cmpxchg2_##sem((__u16 *) ptr, new, _o_);	\
		break;							\
									\
	case 4:								\
		_r_ = ia64_cmpxchg4_##sem((__u32 *) ptr, new, _o_);	\
		break;							\
									\
	case 8:								\
		_r_ = ia64_cmpxchg8_##sem((__u64 *) ptr, new, _o_);	\
		break;							\
									\
	default:							\
		_r_ = ia64_cmpxchg_called_with_bad_pointer();		\
		break;							\
	}								\
	(__typeof__(old)) _r_;						\
})

#define cmpxchg_acq(ptr, o, n)	\
	ia64_cmpxchg(acq, (ptr), (o), (n), sizeof(*(ptr)))
#define cmpxchg_rel(ptr, o, n)	\
	ia64_cmpxchg(rel, (ptr), (o), (n), sizeof(*(ptr)))

/*
 * Worse still - early processor implementations actually just ignored
 * the acquire/release and did a full fence all the time.  Unfortunately
 * this meant a lot of badly written code that used .acq when they really
 * wanted .rel became legacy out in the wild - so when we made a cpu
 * that strictly did the .acq or .rel ... all that code started breaking - so
 * we had to back-pedal and keep the "legacy" behavior of a full fence :-(
 */

/* for compatibility with other platforms: */
#define cmpxchg(ptr, o, n)	cmpxchg_acq((ptr), (o), (n))
#define cmpxchg64(ptr, o, n)	cmpxchg_acq((ptr), (o), (n))

#define cmpxchg_local		cmpxchg
#define cmpxchg64_local		cmpxchg64

#ifdef CONFIG_IA64_DEBUG_CMPXCHG
# define CMPXCHG_BUGCHECK_DECL	int _cmpxchg_bugcheck_count = 128;
# define CMPXCHG_BUGCHECK(v)						\
do {									\
	if (_cmpxchg_bugcheck_count-- <= 0) {				\
		void *ip;						\
		extern int printk(const char *fmt, ...);		\
		ip = (void *) ia64_getreg(_IA64_REG_IP);		\
		printk("CMPXCHG_BUGCHECK: stuck at %p on word %p\n", ip, (v));\
		break;							\
	}								\
} while (0)
#else /* !CONFIG_IA64_DEBUG_CMPXCHG */
# define CMPXCHG_BUGCHECK_DECL
# define CMPXCHG_BUGCHECK(v)
#endif /* !CONFIG_IA64_DEBUG_CMPXCHG */

#endif /* !__ASSEMBLY__ */

#endif /* _ASM_IA64_CMPXCHG_H */

Filemanager

Name Type Size Permission Actions
Kbuild File 125 B 0644
auxvec.h File 407 B 0644
bitsperlong.h File 234 B 0644
break.h File 538 B 0644
byteorder.h File 203 B 0644
cmpxchg.h File 4.11 KB 0644
errno.h File 94 B 0644
fcntl.h File 388 B 0644
fpu.h File 2.22 KB 0644
gcc_intrin.h File 18.07 KB 0644
ia64regs.h File 2.81 KB 0644
intel_intrin.h File 4.88 KB 0644
intrinsics.h File 4.06 KB 0644
ioctl.h File 94 B 0644
ioctls.h File 183 B 0644
ipcbuf.h File 95 B 0644
mman.h File 388 B 0644
msgbuf.h File 930 B 0644
param.h File 670 B 0644
perfmon.h File 6.2 KB 0644
perfmon_default_smpl.h File 3.47 KB 0644
poll.h File 93 B 0644
posix_types.h File 268 B 0644
ptrace.h File 8.1 KB 0644
ptrace_offsets.h File 6.38 KB 0644
resource.h File 215 B 0644
rse.h File 1.71 KB 0644
sembuf.h File 678 B 0644
setup.h File 924 B 0644
shmbuf.h File 1.09 KB 0644
sigcontext.h File 3.07 KB 0644
siginfo.h File 3.06 KB 0644
signal.h File 3.32 KB 0644
socket.h File 2.33 KB 0644
sockios.h File 559 B 0644
stat.h File 1.1 KB 0644
statfs.h File 555 B 0644
swab.h File 781 B 0644
termbits.h File 4.75 KB 0644
termios.h File 1.21 KB 0644
types.h File 866 B 0644
ucontext.h File 360 B 0644
unistd.h File 9.85 KB 0644
ustack.h File 296 B 0644