Skip to content

Commit

Permalink
Fix comments addressed in PR
Browse files Browse the repository at this point in the history
Signed-off-by: Aidan Ha <qbha@edu.uwaterloo.ca>
  • Loading branch information
AidanHa committed Nov 4, 2019
1 parent 20e526b commit cdde3bb
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 67 deletions.
33 changes: 8 additions & 25 deletions fvtest/porttest/si.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2405,39 +2405,22 @@ TEST(PortSysinfoTest, sysinfo_test_sysinfo_get_processor_description)
OMRProcessorDesc desc;

rc = omrsysinfo_get_processor_description(&desc);
if (rc == -1) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() processor detection failed.\n");
}
ASSERT_TRUE(rc == -1);

#if (defined(J9X86) || defined(J9HAMMER))
if (desc.processor < PROCESSOR_X86_UNKNOWN) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() processor detection failed.\n");
}
if (desc.physicalProcessor < PROCESSOR_X86_UNKNOWN) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() physical processor detection failed.\n");
}
ASSERT_TRUE(desc.processor < PROCESSOR_X86_UNKNOWN);
ASSERT_TRUE(desc.physicalProcessor < PROCESSOR_X86_UNKNOWN);
#elif (defined(AIXPPC) || defined(LINUXPPC))
if ((desc.processor < PROCESSOR_PPC_UNKNOWN) || (desc.processor >= PROCESSOR_X86_UNKNOWN)) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() processor detection failed.\n");
}
if ((desc.physicalProcessor < PROCESSOR_PPC_UNKNOWN) || (desc.physicalProcessor >= PROCESSOR_X86_UNKNOWN)) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() physical processor detection failed.\n");
}
ASSERT_TRUE((desc.processor < PROCESSOR_PPC_UNKNOWN) || (desc.processor >= PROCESSOR_X86_UNKNOWN));
ASSERT_TRUE((desc.physicalProcessor < PROCESSOR_PPC_UNKNOWN) || (desc.physicalProcessor >= PROCESSOR_X86_UNKNOWN));
#elif (defined(S390) || defined(J9ZOS390))
if (desc.processor >= (PROCESSOR_PPC_UNKNOWN)) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() processor detection failed.\n");
}
if (desc.physicalProcessor >= (PROCESSOR_PPC_UNKNOWN)) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() physical processor detection failed.\n");
}
ASSERT_TRUE(desc.processor >= (PROCESSOR_PPC_UNKNOWN));
ASSERT_TRUE(desc.physicalProcessor >= (PROCESSOR_PPC_UNKNOWN));
#endif

for (i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE * 32; i++) {
BOOLEAN feature = omrsysinfo_processor_has_feature(&desc, i);
if ((TRUE != feature)
&& (FALSE != feature)) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "omrsysinfo_test_sysinfo_get_processor_description() feature %d detection failed: %d\n", i, feature);
}
ASSERT_TRUE((TRUE != feature) && (FALSE != feature));
}

reportTestExit(OMRPORTLIB, testName);
Expand Down
11 changes: 9 additions & 2 deletions port/common/omrsysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ omrsysinfo_get_CPU_architecture(struct OMRPortLibrary *portLibrary)
return "unknown";
#endif
}

/**
* Determine CPU type and features.
*
Expand All @@ -101,7 +102,10 @@ omrsysinfo_get_CPU_architecture(struct OMRPortLibrary *portLibrary)
intptr_t
omrsysinfo_get_processor_description(struct OMRPortLibrary *portLibrary, OMRProcessorDesc *desc)
{
return -1;
Trc_PRT_sysinfo_get_processor_description_Entered(desc);
intptr_t rc = OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM;
Trc_PRT_sysinfo_get_processor_description_Exit(rc);
return rc;
}

/**
Expand All @@ -116,7 +120,10 @@ omrsysinfo_get_processor_description(struct OMRPortLibrary *portLibrary, OMRProc
BOOLEAN
omrsysinfo_processor_has_feature(struct OMRPortLibrary *portLibrary, OMRProcessorDesc *desc, uint32_t feature)
{
return FALSE;
Trc_PRT_sysinfo_processor_has_feature_Entered(desc, feature);
BOOLEAN rc = FALSE;
Trc_PRT_sysinfo_processor_has_feature_Exit((uintptr_t)rc);
return rc;
}
/**
* Query the operating system for environment variables.
Expand Down
46 changes: 23 additions & 23 deletions port/common/omrsysinfo_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,36 @@
#endif /* defined(WIN32) */

/* defines for the CPUID instruction */
#define CPUID_VENDOR_INFO 0
#define CPUID_FAMILY_INFO 1
#define CPUID_VENDOR_INFO 0
#define CPUID_FAMILY_INFO 1

#define CPUID_VENDOR_INTEL "GenuineIntel"
#define CPUID_VENDOR_AMD "AuthenticAMD"
#define CPUID_VENDOR_LENGTH 12
#define CPUID_VENDOR_INTEL "GenuineIntel"
#define CPUID_VENDOR_AMD "AuthenticAMD"
#define CPUID_VENDOR_LENGTH 12

#define CPUID_SIGNATURE_FAMILY 0x00000F00
#define CPUID_SIGNATURE_MODEL 0x000000F0
#define CPUID_SIGNATURE_EXTENDEDMODEL 0x000F0000
#define CPUID_SIGNATURE_FAMILY 0x00000F00
#define CPUID_SIGNATURE_MODEL 0x000000F0
#define CPUID_SIGNATURE_EXTENDEDMODEL 0x000F0000

#define CPUID_SIGNATURE_FAMILY_SHIFT 8
#define CPUID_SIGNATURE_MODEL_SHIFT 4
#define CPUID_SIGNATURE_EXTENDEDMODEL_SHIFT 12
#define CPUID_SIGNATURE_FAMILY_SHIFT 8
#define CPUID_SIGNATURE_MODEL_SHIFT 4
#define CPUID_SIGNATURE_EXTENDEDMODEL_SHIFT 12

#define CPUID_FAMILYCODE_INTELPENTIUM 0x05
#define CPUID_FAMILYCODE_INTELCORE 0x06
#define CPUID_FAMILYCODE_INTELPENTIUM4 0x0F
#define CPUID_FAMILYCODE_INTELPENTIUM 0x05
#define CPUID_FAMILYCODE_INTELCORE 0x06
#define CPUID_FAMILYCODE_INTELPENTIUM4 0x0F

#define CPUID_MODELCODE_INTELHASWELL 0x3A
#define CPUID_MODELCODE_SANDYBRIDGE 0x2A
#define CPUID_MODELCODE_INTELWESTMERE 0x25
#define CPUID_MODELCODE_INTELNEHALEM 0x1E
#define CPUID_MODELCODE_INTELCORE2 0x0F
#define CPUID_MODELCODE_INTELHASWELL 0x3A
#define CPUID_MODELCODE_SANDYBRIDGE 0x2A
#define CPUID_MODELCODE_INTELWESTMERE 0x25
#define CPUID_MODELCODE_INTELNEHALEM 0x1E
#define CPUID_MODELCODE_INTELCORE2 0x0F

#define CPUID_FAMILYCODE_AMDKSERIES 0x05
#define CPUID_FAMILYCODE_AMDATHLON 0x06
#define CPUID_FAMILYCODE_AMDOPTERON 0x0F
#define CPUID_FAMILYCODE_AMDKSERIES 0x05
#define CPUID_FAMILYCODE_AMDATHLON 0x06
#define CPUID_FAMILYCODE_AMDOPTERON 0x0F

#define CPUID_MODELCODE_AMDK5 0x04
#define CPUID_MODELCODE_AMDK5 0x04
/**
* @internal
* Populates OMRProcessorDesc *desc on Windows and Linux (x86)
Expand Down
8 changes: 1 addition & 7 deletions port/unix/omrsysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,6 @@ getAIXPPCDescription(struct OMRPortLibrary *portLibrary, OMRProcessorDesc *desc)
setFeature(desc, OMRPORT_PPC_FEATURE_POWER4);
}
#endif /* !defined(J9OS_I5_V6R1) */
#if !defined(J9OS_I5_V7R2) && !defined(J9OS_I5_V6R1)
if (__power_tm()) {
setFeature(desc, OMRPORT_PPC_FEATURE_HTM);
}
#endif /* !defined(J9OS_I5_V7R2) && !defined(J9OS_I5_V6R1) */

return 0;
}

Expand All @@ -877,7 +871,7 @@ testSTFLE(struct OMRPortLibrary *portLibrary, uint64_t stfleBit)
{
BOOLEAN rc = FALSE;

STFLEFacilities *mem = &(PPG_stfleCache.facilities);
OMRSTFLEFacilities *mem = &(PPG_stfleCache.facilities);
uintptr_t *stfleRead = &(PPG_stfleCache.lastDoubleWord);

/* If it is the first time, read stfle and cache it */
Expand Down
6 changes: 3 additions & 3 deletions port/unix_include/omrportpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ typedef struct J9PortNodeMask {
} J9PortNodeMask;
#endif

typedef struct STFLEFacilities {
typedef struct OMRSTFLEFacilities {
uint64_t dw1;
uint64_t dw2;
uint64_t dw3;
} STFLEFacilities;
} OMRSTFLEFacilities;

typedef struct OMRSTFLECache {
uintptr_t lastDoubleWord;
STFLEFacilities facilities;
OMRSTFLEFacilities facilities;
} OMRSTFLECache;

typedef struct OMRPortPlatformGlobals {
Expand Down
5 changes: 2 additions & 3 deletions port/win32/omrsysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ omrsysinfo_processor_has_feature(struct OMRPortLibrary *portLibrary, OMRProcesso
BOOLEAN rc = FALSE;
Trc_PRT_sysinfo_processor_has_feature_Entered(desc, feature);

if ((NULL != desc)
&& (feature < (OMRPORT_SYSINFO_OS_FEATURES_SIZE * 32))
) {
if ((NULL != desc) && (feature < (OMRPORT_SYSINFO_OS_FEATURES_SIZE * 32)))
{
uint32_t featureIndex = feature / 32;
uint32_t featureShift = feature % 32;

Expand Down
12 changes: 8 additions & 4 deletions port/zos390/omrportpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@

#if defined(OMR_ENV_DATA64)
#define TTOKEN_BUF_SZ 16
#endif /* defined(OMR_ENV_DATA64) */

typedef struct STFLEFacilities {

typedef struct OMRSTFLEFacilities {
uint64_t dw1;
uint64_t dw2;
uint64_t dw3;
} STFLEFacilities;
} OMRSTFLEFacilities;


typedef struct OMRSTFLECache {
uintptr_t lastDoubleWord;
STFLEFacilities facilities;
OMRSTFLEFacilities facilities;
} OMRSTFLECache;
#endif /* defined(OMR_ENV_DATA64)*/

typedef struct OMRPortPlatformGlobals {
char *si_osType;
Expand Down Expand Up @@ -105,6 +107,8 @@ typedef struct OMRPortPlatformGlobals {
#define PPG_si_executableName (portLibrary->portGlobals->platformGlobals.si_executableName)
#define PPG_ipt_ttoken (portLibrary->portGlobals->platformGlobals.iptTtoken)

#if defined(OMR_ENV_DATA64)
#define PPG_stfleCache (portLibrary->portGlobals->platformGlobals.stfleCache)
#endif /* defined(OMR_ENV_DATA64)*/

#endif /* omrportpg_h */

0 comments on commit cdde3bb

Please sign in to comment.