summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c
blob: 42eac7a1d8dfc0b31bdea0a0724c162b5d6eec30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*++

Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials                          
are licensed and made available under the terms and conditions of the BSD License         
which accompanies this distribution.  The full text of the license may be found at        
http://opensource.org/licenses/bsd-license.php                                            
                                                                                          
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             

Module Name:

  VcCheck.c

Abstract:

  We have found problems with the Visual C++ SP4 and the /O1 flag.
  If this tests ask a question you have the wrong version of Visual C++
  on your system

  This test assumes the tools are being compiled with the same complier
  as the Tiano code. 

  Please see $(EFI_SOURCE)\EFI2.0 Developer's Manual.doc to get the
  correct version of Visual C++

--*/

#include <stdio.h>

_int16  gGloba16;

int
CheckLostCode (
  int Value
  )
/*++

Routine Description:
  This routine is used to test for compiler isseus with /O1.
  If the /O1 compiler option, and C2.dll is got from Visual C++ SP5
  (version: 6.00.8168.0), the assember codes after default branch will be
  losted. (Execute "cl Visual Ccheck.c /O1 /FAsc" to get detail information)

Arguments:
  Value - Test case

Returns: 
  Test to see if comiler error is present.

--*/
{
  switch (Value) {
  case 0:
    break;

  default:
    _asm
    {
      mov bx, 1
      mov gGloba16, bx
    }

    return 1;
  }

  _asm
  {
    mov bx, 0
    mov gGloba16, bx
  }

  return 0;
}

int
main (
  void
  )
/*++

Routine Description:
  This utility is checking for a known Visual C++ compiler issues. To remove this 
  question from the build follow the steps in the developers manual.

Arguments:
  NONE

Returns: 
  0 - Compiler version is O.K.
  1 - Compiler version is Bad

--*/
{
  int   result;
  char  select;

  gGloba16  = 0xFF;
  result    = 0;

  CheckLostCode (0);
  result += (gGloba16 == 0) ? 0 : 1;

  CheckLostCode (1);
  result += (gGloba16 == 1) ? 0 : 1;

  if (result != 0) {
    printf ("Warning: C2.dll is incorrect.\n Please see $(EFI_SOURCE)\\EFI2.0 Developer's Manual.doc for corrective action.\n");
    printf ("Would you want to continue?(Y/N)");

    scanf ("%c", &select);
    if ((select == 'Y') || (select == 'y')) {
      return 0;
    } else {
      return 1;
    }
  }

  return 0;
}