lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20140318125256.GJ4420@linux.vnet.ibm.com>
Date:	Tue, 18 Mar 2014 05:52:56 -0700
From:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To:	noman pouigt <variksla@...il.com>
Cc:	rostedt@...dmis.org, rusty@...tcorp.com.au,
	gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org
Subject: Re: atomic read and increment question

On Tue, Mar 18, 2014 at 01:26:12AM -0700, noman pouigt wrote:
> Hello,
> 
> I looked through the documentation for atomic
> operations but couldn't find out the api for following
> operation:
> 
> x = 1;
> temp = atomic_read_increment(x);
> 
> so basically this will read the old value of x in temp
> and then increment x.
> 
> so temp = 1 and x = 2.
> 
> Is this api already available?

You want atomic_inc_return().  It returns the new value rather than the
old value, but you can do the following:

	temp = atomic_inc_return(&x) - 1;

							Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ