Snap for 9754537 from 55fc576843162fd5d9304804c095c30ee914d810 to udc-release

Change-Id: I865d3c6c3cb1d135012826035cfd660732364d94
diff --git a/Android.bp b/Android.bp
index 355aaaf..7400a27 100644
--- a/Android.bp
+++ b/Android.bp
@@ -76,7 +76,7 @@
     ],
 }
 
-cc_library {
+cc_library_static {
     name: "ms-tpm-20-ref-lib",
     srcs: [
         "TPMCmd/Platform/src/*.c",
@@ -100,6 +100,17 @@
         "TPMCmd/tpm/include/Ossl",
         "TPMCmd/tpm/include/prototypes",
     ],
+    target: {
+        windows: {
+            enabled: true,
+            cflags: [
+                "-Wno-unknown-pragmas",
+            ],
+            host_ldlibs: [
+                "-lws2_32",
+            ],
+        },
+    },
     defaults: [ "ms-tpm-20-ref-defaults" ],
 }
 
@@ -108,7 +119,7 @@
     srcs: [
         "TPMCmd/Simulator/src/TPMCmds.c",
     ],
-    shared_libs: [
+    static_libs: [
         "ms-tpm-20-ref-lib",
     ],
     defaults: [ "ms-tpm-20-ref-defaults" ],
diff --git a/TPMCmd/Simulator/src/TPMCmdp.c b/TPMCmd/Simulator/src/TPMCmdp.c
index b776c59..6e5c22b 100644
--- a/TPMCmd/Simulator/src/TPMCmdp.c
+++ b/TPMCmd/Simulator/src/TPMCmdp.c
@@ -43,7 +43,7 @@
 #include <stdbool.h>

 #include "TpmBuildSwitches.h"

 

-#ifdef _MSC_VER

+#ifdef _WIN32

 #   pragma warning(push, 3)

 #   include <windows.h>

 #   include <winsock.h>

diff --git a/TPMCmd/Simulator/src/TPMCmds.c b/TPMCmd/Simulator/src/TPMCmds.c
index 0aca528..ade1c23 100644
--- a/TPMCmd/Simulator/src/TPMCmds.c
+++ b/TPMCmd/Simulator/src/TPMCmds.c
@@ -45,7 +45,7 @@
 #include <ctype.h>

 #include <string.h>

 

-#ifdef _MSC_VER

+#ifdef _WIN32

 #   pragma warning(push, 3)

 #   include <windows.h>

 #   include <winsock.h>

diff --git a/TPMCmd/Simulator/src/TcpServer.c b/TPMCmd/Simulator/src/TcpServer.c
index c12b6c6..5adb90a 100644
--- a/TPMCmd/Simulator/src/TcpServer.c
+++ b/TPMCmd/Simulator/src/TcpServer.c
@@ -42,7 +42,7 @@
 #include <stdio.h>

 #include <stdbool.h>

 

-#ifdef _MSC_VER

+#ifdef _WIN32

 #   pragma warning(push, 3)

 #   include <windows.h>

 #   include <winsock.h>

@@ -110,7 +110,7 @@
     int res;

 //  

     // Initialize Winsock

-#ifdef _MSC_VER

+#ifdef _WIN32

     WSADATA              wsaData;

     res = WSAStartup(MAKEWORD(2, 2), &wsaData);

     if(res != 0)

@@ -297,7 +297,7 @@
     int              PortNumber

     )

 {

-#if defined(_MSC_VER)

+#if defined(_WIN32)

     HANDLE               hPlatformSvc;

     int                  ThreadId;

     int                  port = PortNumber;

@@ -324,7 +324,7 @@
         printf("pthread_create failed: %s", strerror(ret));

     }

     return ret;

-#endif // _MSC_VER

+#endif // _WIN32

 }

 

 //*** RegularCommandService()

@@ -394,13 +394,13 @@
     {

         uint64_t  curTime;

 

-#if defined(_MSC_VER)

+#if defined(_WIN32)

         Sleep((DWORD)timeout);

 #else

         struct timespec     req = { timeout / 1000, (timeout % 1000) * 1000 };

         struct timespec     rem;

         nanosleep(&req, &rem);

-#endif // _MSC_VER

+#endif // _WIN32

         curTime = _plat__RealTime();

 

         // May need to issue several ticks if the Sleep() took longer than asked,

@@ -435,7 +435,7 @@
     int                  ret = 0;

     if(!running)

     {

-#if defined(_MSC_VER)

+#if defined(_WIN32)

         HANDLE               hThr;

         int                  ThreadId;

     //

@@ -456,7 +456,7 @@
 //

         ret = pthread_create(&thread_id, NULL, (void*)SimulatorTimeServiceRoutine,

             (LPVOID)(INT_PTR)NULL);

-#endif // _MSC_VER

+#endif // _WIN32

 

         if(ret != 0)

             printf("ACT thread Creation failed\n");