summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/aws-c-common/source/arch/intel/asm/cpuid.c
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/restricted/aws/aws-c-common/source/arch/intel/asm/cpuid.c
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/restricted/aws/aws-c-common/source/arch/intel/asm/cpuid.c')
-rw-r--r--contrib/restricted/aws/aws-c-common/source/arch/intel/asm/cpuid.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/contrib/restricted/aws/aws-c-common/source/arch/intel/asm/cpuid.c b/contrib/restricted/aws/aws-c-common/source/arch/intel/asm/cpuid.c
new file mode 100644
index 00000000000..d2ceab01060
--- /dev/null
+++ b/contrib/restricted/aws/aws-c-common/source/arch/intel/asm/cpuid.c
@@ -0,0 +1,29 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include <aws/common/cpuid.h>
+
+void aws_run_cpuid(uint32_t eax, uint32_t ecx, uint32_t *abcd) {
+ uint32_t ebx = 0;
+ uint32_t edx = 0;
+
+#if defined(__i386__) && defined(__PIC__)
+ /* in case of PIC under 32-bit EBX cannot be clobbered */
+ __asm__ __volatile__("movl %%ebx, %%edi \n\t "
+ "cpuid \n\t "
+ "xchgl %%ebx, %%edi"
+ : "=D"(ebx),
+#else
+ __asm__ __volatile__("cpuid"
+ : "+b"(ebx),
+#endif
+ "+a"(eax),
+ "+c"(ecx),
+ "=d"(edx));
+ abcd[0] = eax;
+ abcd[1] = ebx;
+ abcd[2] = ecx;
+ abcd[3] = edx;
+}