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] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.58.0801161934500.17781@gandalf.stny.rr.com>
Date:	Wed, 16 Jan 2008 19:36:30 -0500 (EST)
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
cc:	john stultz <johnstul@...ibm.com>,
	LKML <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...e.hu>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Christoph Hellwig <hch@...radead.org>,
	Gregory Haskins <ghaskins@...ell.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Thomas Gleixner <tglx@...utronix.de>,
	Tim Bird <tim.bird@...sony.com>,
	Sam Ravnborg <sam@...nborg.org>,
	"Frank Ch. Eigler" <fche@...hat.com>,
	Steven Rostedt <srostedt@...hat.com>,
	Paul Mackerras <paulus@...ba.org>,
	Daniel Walker <dwalker@...sta.com>
Subject: Re: [RFC PATCH 16/22 -v2] add get_monotonic_cycles



On Wed, 16 Jan 2008, Steven Rostedt wrote:
> On Wed, 16 Jan 2008, Mathieu Desnoyers wrote:
> >
> > !0 is not necessarily 1. This is why I use cpu_synth->index ? 0 : 1 in
>
> How about simply "cpu_synth->index ^ 1"? Seems the best choice if you ask
> me, if all you are doing is changing it from 1 to zero and back to 1.
>

FYI:

rostedt@...bo:~/c$ cat flipme.c
int flip1 (int x)
{
        return !x;
}

int flip2 (int x)
{
        return x ? 0 : 1;
}

int flip3(int x)
{
        return x ^ 1;
}
rostedt@...bo:~/c$ gcc -O2 -c flipme.c
rostedt@...bo:~/c$ objdump -d flipme.o

flipme.o:     file format elf32-i386

Disassembly of section .text:

00000000 <flip1>:
   0:   55                      push   %ebp
   1:   31 c0                   xor    %eax,%eax
   3:   89 e5                   mov    %esp,%ebp
   5:   83 7d 08 00             cmpl   $0x0,0x8(%ebp)
   9:   5d                      pop    %ebp
   a:   0f 94 c0                sete   %al
   d:   c3                      ret
   e:   66 90                   xchg   %ax,%ax

00000010 <flip2>:
  10:   55                      push   %ebp
  11:   31 c0                   xor    %eax,%eax
  13:   89 e5                   mov    %esp,%ebp
  15:   83 7d 08 00             cmpl   $0x0,0x8(%ebp)
  19:   5d                      pop    %ebp
  1a:   0f 94 c0                sete   %al
  1d:   c3                      ret
  1e:   66 90                   xchg   %ax,%ax

00000020 <flip3>:
  20:   55                      push   %ebp
  21:   89 e5                   mov    %esp,%ebp
  23:   8b 45 08                mov    0x8(%ebp),%eax
  26:   5d                      pop    %ebp
  27:   83 f0 01                xor    $0x1,%eax
  2a:   c3                      ret


So, if you know for sure that x is only 1 or 0, then using x ^ 1 to invert
it, seems the most efficient.

-- Steve

--
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