Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
6.3 KiB

  1. /*****************************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1987-1999 **/
  4. /*****************************************************************************/
  5. /*****************************************************************************
  6. File : acfattr.cxx
  7. Title : the acf attribute handler
  8. Description : this file handles all the code connected to the acf
  9. : attribute handling
  10. History :
  11. 02-Jan-1990 VibhasC Create - Happy New Year !!
  12. *****************************************************************************/
  13. /*****************************************************************************
  14. * include files
  15. *****************************************************************************/
  16. #pragma warning ( disable : 4514 )
  17. #include "nulldefs.h"
  18. extern "C" {
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. }
  23. #include "allnodes.hxx"
  24. #include "cmdana.hxx"
  25. /*****************************************************************************
  26. * local defines
  27. *****************************************************************************/
  28. /*****************************************************************************
  29. * local data
  30. *****************************************************************************/
  31. /*****************************************************************************
  32. * extern data
  33. *****************************************************************************/
  34. extern ATTR_VECTOR AcfConflicts[ ][ ATTR_VECTOR_SIZE ];
  35. extern CMD_ARG * pCommand;
  36. /*****************************************************************************
  37. * local procs
  38. *****************************************************************************/
  39. /*****************************************************************************
  40. * extern procs
  41. *****************************************************************************/
  42. extern void ParseError( STATUS_T, char * );
  43. node_implicit::node_implicit(
  44. node_skl * pType,
  45. node_id * pID ) : acf_attr( ATTR_IMPLICIT )
  46. {
  47. pHandleID = pID;
  48. pID->SetEdgeType( EDGE_USE );
  49. pID->SetChild( pType );
  50. pHandleType = pType;
  51. }
  52. void
  53. node_implicit::ImplicitHandleDetails(
  54. node_skl ** ppType,
  55. node_id ** ppID )
  56. {
  57. (*ppID) = pHandleID;
  58. (*ppType) = pHandleType;
  59. }
  60. BOOL
  61. node_implicit::IsHandleTypeDefined()
  62. {
  63. return ( pHandleType &&
  64. ( pHandleType->NodeKind() != NODE_FORWARD) );
  65. }
  66. OPT_LEVEL_ENUM
  67. ParseAcfOptimizationAttr(
  68. char * pOptString,
  69. unsigned short * pOptFlags )
  70. /*
  71. Before the /target switch was introduced, we had the following
  72. optimization switches (up to beta2 for NT40):
  73. -Os size from NT 3.5 (always available)
  74. -Oi old interpreter from NT 3.5 (always available)
  75. -Oi1 -Oi w/stubless obj client from NT 3.51
  76. -Oi2 new interpreter from NT 4.0
  77. */
  78. {
  79. unsigned short OptFlags = pCommand->GetOptimizationFlags();
  80. OPT_LEVEL_ENUM OptLevel = pCommand->GetOptimizationLevel();
  81. if ( strcmp( pOptString, "i" ) == 0 )
  82. {
  83. OptLevel = OPT_LEVEL_OI;
  84. }
  85. else if ( strcmp( pOptString, "ic" ) == 0 )
  86. {
  87. OptLevel = OPT_LEVEL_OIC;
  88. }
  89. else if ( strcmp( pOptString, "i1" ) == 0 )
  90. {
  91. ParseError( OI1_PHASED_OUT, "i1");
  92. OptLevel = OPT_LEVEL_OIC;
  93. }
  94. else if ( strcmp( pOptString, "icf" ) == 0 ||
  95. strcmp( pOptString, "if" ) == 0 )
  96. {
  97. OptLevel = OPT_LEVEL_OICF;
  98. }
  99. else if ( strcmp( pOptString, "i2" ) == 0 )
  100. {
  101. ParseError( OI2_OBSOLETE, "i2");
  102. OptLevel = OPT_LEVEL_OICF;
  103. }
  104. else if ( strcmp( pOptString, "s" ) == 0 )
  105. {
  106. if ( pCommand->NeedsNDR64Run() )
  107. ParseError( OS_IN_NDR64, "" );
  108. OptLevel = OPT_LEVEL_OS;
  109. }
  110. else
  111. ParseError( ILLEGAL_ARG_VALUE, pOptString );
  112. switch ( OptLevel )
  113. {
  114. case OPT_LEVEL_OS:
  115. OptFlags = OPTIMIZE_SIZE;
  116. break;
  117. // Force Oi and Oic to mean Oicf for 64b platforms.
  118. case OPT_LEVEL_OI:
  119. if ( pCommand->Is64BitEnv() )
  120. {
  121. ParseError( WIN64_INTERPRETED, "-Oicf for -Oi" );
  122. OptFlags = OPTIMIZE_ALL_I2_FLAGS;
  123. }
  124. else
  125. OptFlags = OPTIMIZE_INTERPRETER;
  126. break;
  127. case OPT_LEVEL_OIC:
  128. if ( pCommand->Is64BitEnv() )
  129. {
  130. ParseError( WIN64_INTERPRETED, "-Oicf for -Oic" );
  131. OptFlags = OPTIMIZE_ALL_I2_FLAGS;
  132. }
  133. else
  134. OptFlags = OPTIMIZE_ALL_I1_FLAGS;
  135. break;
  136. case OPT_LEVEL_OICF:
  137. OptFlags = OPTIMIZE_ALL_I2_FLAGS;
  138. break;
  139. }
  140. *pOptFlags = OptFlags;
  141. return OptLevel;
  142. }
  143. /*****************************************************************************
  144. * utility routines
  145. *****************************************************************************/
  146. short
  147. CheckValidAllocate(
  148. char * pAllocID )
  149. {
  150. static char *ValidAllocates[] = {
  151. "single_node"
  152. ,"all_nodes"
  153. ,"dont_free"
  154. ,"free"
  155. ,"all_nodes_aligned"
  156. ,(char *)0
  157. };
  158. static short AllocateValues[] = {
  159. ALLOCATE_SINGLE_NODE
  160. ,ALLOCATE_ALL_NODES
  161. ,ALLOCATE_DONT_FREE
  162. ,ALLOCATE_FREE
  163. ,ALLOCATE_ALL_NODES_ALIGNED
  164. };
  165. char * pSearch;
  166. int i = 0;
  167. while( ( pSearch = ValidAllocates[i] ) != 0 )
  168. {
  169. if( !strcmp( pSearch, pAllocID ) )
  170. return AllocateValues[ i ];
  171. ++i;
  172. }
  173. ParseError( INVALID_ALLOCATE_MODE, pAllocID );
  174. return 0;
  175. }
  176. /*****************************************************************************
  177. * clone routines
  178. *****************************************************************************/
  179. node_base_attr * node_optimize::Clone()
  180. {
  181. node_optimize * pNew = new node_optimize( this );
  182. return pNew;
  183. }
  184. node_base_attr * node_ptr_size::Clone()
  185. {
  186. node_ptr_size * pNew = new node_ptr_size( this );
  187. return pNew;
  188. }
  189. node_base_attr * node_implicit::Clone()
  190. {
  191. node_implicit * pNew = new node_implicit( this );
  192. return pNew;
  193. }