audk/MdePkg
Ard Biesheuvel b331b99fae MdePkg/BaseLib: do not rely on undefined behavior in arithmetic shift
The runtime test whether the compiler supports arithmetic shift of
negative signed numbers currently relies on undefined behavior in C,
which means that all bets are off regarding whether the condition
that follows passes or fails, regardless of whether the compiler in
fact supports arithmetic shift or not.

Relevant quote from ISO C99 (6.5.7/4)

  The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits
  are filled with zeros. If E1 has an unsigned type, the value of the result
  is E1 × 2^E2, reduced modulo one more than the maximum value representable
  in the result type. If E1 has a signed type and nonnegative value, and
  E1 × 2^E2 is representable in the result type, then that is the resulting
  value; otherwise, the behavior is undefined.

For historic purposes, let's keep the test in place (although it is doubtful
we actually need it) but rewrite it in a way that prevents compilers from
this century from doing whacky things with it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19580 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-31 10:47:22 +00:00
..
Include MdePkg: Update Ipmi2.0 definitions header file. 2015-12-23 08:15:14 +00:00
Library MdePkg/BaseLib: do not rely on undefined behavior in arithmetic shift 2015-12-31 10:47:22 +00:00
Contributions.txt */Contributions.txt: Update example email address 2015-02-03 17:29:14 +00:00
License.txt
MdePkg.dec MdePkg: Add more DataBits support to Port80 output 2015-11-11 02:16:35 +00:00
MdePkg.dsc MdePkg/BaseIoLibIntrinsic: Add EBC support 2015-12-14 06:11:17 +00:00
MdePkg.uni MdePkg: Convert all .uni files to utf-8 2015-12-15 04:53:50 +00:00
MdePkgExtra.uni MdePkg: Convert all .uni files to utf-8 2015-12-15 04:53:50 +00:00