mirror of
				https://gitlab.com/qemu-project/edk2.git
				synced 2025-10-30 07:56:39 +08:00 
			
		
		
		
	PrmPkg/Include: Fix GCC/CLANG PRM Module DLL Export issues
Use _MSC_EXTENSIONS instead of _MSC_VER when MSC specific extensions are required such as __declspec(dllexport). CLANGPDB builds do not set _MSC_VER but CLANGPDB builds in Windows and Linux do support use of MSC specific extensions. Add PRM_EXPORT_DESCRIPTOR macro that provides attributes required to make sure the PRM Export Descriptor Structure is not optimized away by the compiler/linker. PRM_EXPORT_API can not be used for this because the attributes for code and data may be different with different tool chains. For GCC/CLANGDWARF tool chains, PRM_EXPORT_DESCRIPTOR sets the 'used' and 'section(.prmexportdescriptor)' attributes and depends on the GCC linker script to make sure the `.prmexportdescriptor` section is preserved. Fix incorrect location of ; in PRM_MODULE_EXPORT() macro that was found by CLANG. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
		 Michael D Kinney
					Michael D Kinney
				
			
				
					committed by
					
						![mergify[bot]](/assets/img/avatar_default.png) mergify[bot]
						mergify[bot]
					
				
			
			
				
	
			
			
			![mergify[bot]](/assets/img/avatar_default.png) mergify[bot]
						mergify[bot]
					
				
			
						parent
						
							3980808abf
						
					
				
				
					commit
					c16e88e301
				
			| @ -14,12 +14,15 @@ | ||||
| #include <Uefi.h> | ||||
| #include <PrmContextBuffer.h> | ||||
|  | ||||
| #if defined (_MSC_VER) | ||||
| #define PRM_EXPORT_API  __declspec(dllexport) | ||||
| #elif defined (__GNUC__) | ||||
| #define PRM_EXPORT_API  __attribute__ ((visibility ("default"))) | ||||
| #if defined (_MSC_EXTENSIONS) | ||||
| #define PRM_EXPORT_API         __declspec(dllexport) | ||||
| #define PRM_EXPORT_DESCRIPTOR  __declspec(dllexport) | ||||
| #elif defined (__GNUC__) || defined (__clang__) | ||||
| #define PRM_EXPORT_API | ||||
| #define PRM_EXPORT_DESCRIPTOR  __attribute__((used)) __attribute__((section(".prmexportdescriptor"))) | ||||
| #else | ||||
| #define PRM_EXPORT_API | ||||
| #define PRM_EXPORT_DESCRIPTOR | ||||
| #endif | ||||
|  | ||||
| #define PRM_HANDLER_NAME_MAXIMUM_LENGTH  128 | ||||
|  | ||||
| @ -41,7 +41,7 @@ typedef struct { | ||||
|  | ||||
| #pragma pack(pop) | ||||
|  | ||||
| #if defined (_MSC_VER) | ||||
| #if defined (_MSC_EXTENSIONS) | ||||
| #define PRM_PACKED_STRUCT(definition) \ | ||||
|   __pragma(pack(push, 1)) typedef struct definition __pragma(pack(pop)) | ||||
| #elif defined (__GNUC__) || defined (__clang__) | ||||
| @ -92,10 +92,10 @@ typedef struct { | ||||
|     {                                                                                                     \ | ||||
|       PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER  Header;                                                 \ | ||||
|       PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT        PrmHandlerExportDescriptors[VA_ARG_COUNT(__VA_ARGS__)]; \ | ||||
|     } PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_                                                                \ | ||||
|   );                                                                                                      \ | ||||
|     } PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_;                                                               \ | ||||
|   )                                                                                                       \ | ||||
|                                                                                                           \ | ||||
|   PRM_EXPORT_API PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_ PRM_MODULE_EXPORT_DESCRIPTOR_NAME = {               \ | ||||
|   PRM_EXPORT_DESCRIPTOR PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_ PRM_MODULE_EXPORT_DESCRIPTOR_NAME = {               \ | ||||
|     {                                                                                                     \ | ||||
|       PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE,                                                             \ | ||||
|       PRM_MODULE_EXPORT_REVISION,                                                                         \ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user