scripts/atomic/atomic-tbl.sh

Source file repositories/reference/linux-study-clean/scripts/atomic/atomic-tbl.sh

File Facts

System
Linux kernel
Corpus path
scripts/atomic/atomic-tbl.sh
Extension
.sh
Size
5739 bytes
Lines
291
Domain
Support Tooling And Documentation
Bucket
scripts
Inferred role
Support Tooling And Documentation: scripts
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# helpers for dealing with atomics.tbl

#meta_in(meta, match)
meta_in()
{
	case "$1" in
	[$2]) return 0;;
	esac

	return 1
}

#meta_has_ret(meta)
meta_has_ret()
{
	meta_in "$1" "bBiIfFlR"
}

#meta_has_acquire(meta)
meta_has_acquire()
{
	meta_in "$1" "BFIlR"
}

#meta_has_release(meta)
meta_has_release()
{
	meta_in "$1" "BFIRs"
}

#meta_has_relaxed(meta)
meta_has_relaxed()
{
	meta_in "$1" "BFIR"
}

#meta_is_implicitly_relaxed(meta)
meta_is_implicitly_relaxed()
{
	meta_in "$1" "vls"
}

#find_template(tmpltype, pfx, name, sfx, order)
find_template()
{
	local tmpltype="$1"; shift
	local pfx="$1"; shift
	local name="$1"; shift
	local sfx="$1"; shift
	local order="$1"; shift

	local base=""
	local file=""

	# We may have fallbacks for a specific case (e.g. read_acquire()), or
	# an entire class, e.g. *inc*().
	#
	# Start at the most specific, and fall back to the most general. Once
	# we find a specific fallback, don't bother looking for more.
	for base in "${pfx}${name}${sfx}${order}" "${pfx}${name}${sfx}" "${name}"; do
		file="${ATOMICDIR}/${tmpltype}/${base}"

		if [ -f "${file}" ]; then
			printf "${file}"
			break
		fi
	done
}

Annotation

Implementation Notes