[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180515121309.GL12235@hirez.programming.kicks-ass.net>
Date: Tue, 15 May 2018 14:13:09 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
will.deacon@....com, mark.rutland@....com,
torvalds@...ux-foundation.org, paulmck@...ux.vnet.ibm.com,
tglx@...utronix.de, hpa@...or.com,
linux-tip-commits@...r.kernel.org
Subject: Re: [tip:locking/core] locking/atomics: Simplify the op definitions
in atomic.h some more
On Tue, May 15, 2018 at 01:41:44PM +0200, Peter Zijlstra wrote:
> #!/bin/bash
>
> gen_proto() {
> local cnt=0;
>
> proto=$1; shift;
> ret=$1; shift;
> pfx=$1; shift;
> sfx=$1; shift;
>
> echo -n "${ret} ";
>
> name=${proto%(*};
> echo -n "${pfx}${name}${sfx}("
>
> args=${proto#*\(};
> for arg in ${args//[,)]/ };
> do
> if [ $cnt -gt 0 ]
> then
> echo -n ", ";
> fi
> let cnt++;
> echo -n "${TYPES[$arg]} ${arg}"
> done
> echo ");"
> }
>
> gen_proto_order() {
> gen_proto $1 $2 $3 $4
> gen_proto $1 $2 $3 $4_acquire
> gen_proto $1 $2 $3 $4_release
> gen_proto $1 $2 $3 $4_relaxed
> }
>
> gen_void_protos() {
> grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta;
> do
> gen_proto ${proto} "void" ${TYPES[pfx]} ""
> done
> }
>
> gen_return_protos() {
> grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta;
> do
> if [[ $meta =~ "R" ]]; then
> gen_proto_order ${proto} ${TYPES[i]} ${TYPES[pfx]} "_return"
> fi
> done
> }
>
> gen_fetch_protos() {
> grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta;
> do
> if [[ $meta =~ "F" ]]; then
> gen_proto_order ${proto} ${TYPES[i]} "${TYPES[pfx]}fetch_" ""
> fi
> done
> }
>
> gen_exchange_protos() {
> grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta;
> do
> if [[ $meta =~ "X" ]]; then
ret=${TYPES[i]};
if [[ $meta =~ "B" ]]; then
ret="bool"
fi
gen_proto_order ${proto} ${ret} ${TYPES[pfx]} ""
> fi
> done
> }
>
> gen_protos() {
> gen_void_protos
> gen_return_protos
> gen_fetch_protos
> gen_exchange_protos
> }
>
> declare -A TYPES=( [pfx]="atomic_" [v]="atomic_t *" [i]="int" [j]="int" [I]="int *" )
>
> gen_protos
>
> declare -A TYPES=( [pfx]="atomic64_" [v]="atomic64_t *" [i]="s64" [j]="s64" [I]="s64 *" )
>
> gen_protos
>
> declare -A TYPES=( [pfx]="atomic_long_" [v]="atomic_long_t *" [i]="long" [j]="long" [I]="long *" )
>
> gen_protos
>
>
Powered by blists - more mailing lists