<commit_before>// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "runtime.h"
#include "arch_GOARCH.h"
#include "../../cmd/ld/textflag.h"

static struct {
	Mutex l;
	byte pad[CacheLineSize-sizeof(Mutex)];
} locktab[57];

#define LOCK(addr) (&locktab[((uintptr)(addr)>>3)%nelem(locktab)].l)

// Atomic add and return new value.
#pragma textflag NOSPLIT
uint32
runtime·xadd(uint32 volatile *val, int32 delta)
{
	uint32 oval, nval;

	for(;;){
		oval = *val;
		nval = oval + delta;
		if(runtime·cas(val, oval, nval))
			return nval;
	}
}

#pragma textflag NOSPLIT
uint32
runtime·xchg(uint32 volatile* addr, uint32 v)
{
	uint32 old;

	for(;;) {
		old = *addr;
		if(runtime·cas(addr, old, v))
			return old;
	}
}

#pragma textflag NOSPLIT
void*
runtime·xchgp(void* volatile* addr, void* v)
{
	void *old;

	for(;;) {
		old = *addr;
		if(runtime·casp(addr, old, v))
			return old;
	}
}

#pragma textflag NOSPLIT
void*
runtime·xchguintptr(void* volatile* addr, void* v)
{
	return runtime·xchg((uint32*)addr, (uint32)v);<commit_msg>runtime: fix arm build<commit_after>// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "runtime.h"
#include "arch_GOARCH.h"
#include "../../cmd/ld/textflag.h"

static struct {
	Mutex l;
	byte pad[CacheLineSize-sizeof(Mutex)];
} locktab[57];

#define LOCK(addr) (&locktab[((uintptr)(addr)>>3)%nelem(locktab)].l)

// Atomic add and return new value.
#pragma textflag NOSPLIT
uint32
runtime·xadd(uint32 volatile *val, int32 delta)
{
	uint32 oval, nval;

	for(;;){
		oval = *val;
		nval = oval + delta;
		if(runtime·cas(val, oval, nval))
			return nval;
	}
}

#pragma textflag NOSPLIT
uint32
runtime·xchg(uint32 volatile* addr, uint32 v)
{
	uint32 old;

	for(;;) {
		old = *addr;
		if(runtime·cas(addr, old, v))
			return old;
	}
}

#pragma textflag NOSPLIT
void*
runtime·xchgp(void* volatile* addr, void* v)
{
	void *old;

	for(;;) {
		old = *addr;
		if(runtime·casp(addr, old, v))
			return old;
	}
}

#pragma textflag NOSPLIT
void*
runtime·xchguintptr(void* volatile* addr, void* v)
{
	return (void*)runtime·xchg((uint32*)addr, (uint32)v);
{'fraction_non_alphanumeric': 0.15331010452961671, 'fraction_numerical': 0.023519163763066203, 'mean_word_length': 4.292626728110599, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5974912', 'n_tokens_mistral': 964, 'n_tokens_neox': 899, 'n_words': 248}