Re: Usage of unlikely in RCU code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> C absolutely guarantees that the second will NEVER be evaluated before
> the first. Otherwise, things like this:
>
> if ( ptr && ptr->field )
>
> could fail if ptr was NULL.

In your example yes. But is there a problem if the two conditions are
independent ? for eg..

foo() {
....
  a = 0;
  b = my_complex_function_call();
  if (b && a) {
      /* Do some non-trivial stuff */
  } else {
     printf("I'm an intelligent compiler\n");
  }
.....
}

Does C guarantee that even in this case it won't be reordered and not
optimized ?

-- 
Thanks -
Manish

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux