diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index fc9aac203..8518b9906 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,14 @@
+2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
+
+	* autoload.cc (UuidCreate): Remove.
+	(UuidCreateSequential): Remove.
+	* passwd.cc (internal_getpwsid): Avoid a strict-aliasing compiler
+	error with gcc 4.5.1.
+	* fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Ditto.
+	* ntdll.h (NtAllocateUuids): Declare.
+	* syscalls.cc (gethostid): Use NtAllocateUuids function rather than
+	UuidCreateSequential/UuidCreate to get rid of rpcrt4 dependency.
+
 2011-03-29  Corinna Vinschen  <corinna@vinschen.de>
 
 	* cygwin.din (pthread_spin_destroy): Export.
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index c0ab2ed26..587f7eb61 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -403,9 +403,6 @@ LoadDLLfuncEx (GetModuleInformation, 16, psapi, 1)
 LoadDLLfuncEx (GetProcessMemoryInfo, 12, psapi, 1)
 LoadDLLfuncEx (QueryWorkingSet, 12, psapi, 1)
 
-LoadDLLfunc (UuidCreate, 4, rpcrt4)
-LoadDLLfuncEx (UuidCreateSequential, 4, rpcrt4, 1)
-
 LoadDLLfunc (LsaDeregisterLogonProcess, 4, secur32)
 LoadDLLfunc (LsaFreeReturnBuffer, 4, secur32)
 LoadDLLfunc (LsaLogonUser, 56, secur32)
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc
index 5ebcd14cd..a5adcae6e 100644
--- a/winsup/cygwin/fhandler_floppy.cc
+++ b/winsup/cygwin/fhandler_floppy.cc
@@ -41,6 +41,7 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
   char dbuf[256];
   char pbuf[256];
 
+  DISK_GEOMETRY_EX *dix = NULL;
   DISK_GEOMETRY *di = NULL;
   PARTITION_INFORMATION_EX *pix = NULL;
   PARTITION_INFORMATION *pi = NULL;
@@ -57,7 +58,8 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
 	__seterrno ();
       else
 	{
-	  di = &((DISK_GEOMETRY_EX *) dbuf)->Geometry;
+	  dix = (DISK_GEOMETRY_EX *) dbuf;
+	  di = &dix->Geometry;
 	  if (!DeviceIoControl (get_handle (),
 				IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0,
 				pbuf, 256, &bytes_read, NULL))
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index cd8e1f106..5f7f5cff4 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -907,6 +907,7 @@ extern "C"
 {
   NTSTATUS NTAPI NtAdjustPrivilegesToken (HANDLE, BOOLEAN, PTOKEN_PRIVILEGES,
 					  ULONG, PTOKEN_PRIVILEGES, PULONG);
+  NTSTATUS NTAPI NtAllocateUuids (PLARGE_INTEGER, PULONG, PULONG, PUCHAR);
   NTSTATUS NTAPI NtClose (HANDLE);
   NTSTATUS NTAPI NtCommitTransaction (HANDLE, BOOLEAN);
   NTSTATUS NTAPI NtCreateDirectoryObject (PHANDLE, ACCESS_MASK,
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 8c51c22a0..44343af7f 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -98,11 +98,14 @@ internal_getpwsid (cygpsid &sid)
     {
       endptr = strchr (sid_string + 2, 0) - 1;
       for (int i = 0; i < pr.curr_lines; i++)
-	if ((pw = passwd_buf + i)->pw_dir > pw->pw_gecos + 8)
-	  for (ptr1 = endptr, ptr2 = pw->pw_dir - 2;
-	       *ptr1 == *ptr2; ptr2--)
-	    if (!*--ptr1)
-	      return pw;
+	{
+	  pw = passwd_buf + i;
+	  if (pw->pw_dir > pw->pw_gecos + 8)
+	    for (ptr1 = endptr, ptr2 = pw->pw_dir - 2;
+		 *ptr1 == *ptr2; ptr2--)
+	      if (!*--ptr1)
+		return pw;
+	}
     }
   return NULL;
 }
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index e3a8f2df3..350edc3e5 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3760,24 +3760,29 @@ long gethostid (void)
 	}
     }
 
-  UUID Uuid;
-  RPC_STATUS status = UuidCreateSequential (&Uuid);
-  if (GetLastError () == ERROR_PROC_NOT_FOUND)
-    status = UuidCreate (&Uuid);
-  if (status == RPC_S_OK)
+  LARGE_INTEGER u1;
+  ULONG u2, u3;
+  union {
+    UCHAR mac[6];
+    struct {
+      ULONG m1;
+      USHORT m2;
+    };
+  } u4;
+  NTSTATUS status = NtAllocateUuids (&u1, &u2, &u3, u4.mac);
+  if (NT_SUCCESS (status))
     {
-      data[4] = *(unsigned *)&Uuid.Data4[2];
-      data[5] = *(unsigned short *)&Uuid.Data4[6];
+      data[4] = u4.m1;
+      data[5] = u4.m2;
       // Unfortunately Windows will sometimes pick a virtual Ethernet card
       // e.g. VMWare Virtual Ethernet Adaptor
-      debug_printf ("MAC address of first Ethernet card: %02x:%02x:%02x:%02x:%02x:%02x",
-		    Uuid.Data4[2], Uuid.Data4[3], Uuid.Data4[4],
-		    Uuid.Data4[5], Uuid.Data4[6], Uuid.Data4[7]);
+      debug_printf ("MAC address of first Ethernet card: "
+		    "%02x:%02x:%02x:%02x:%02x:%02x",
+		    u4.mac[0], u4.mac[1], u4.mac[2],
+		    u4.mac[3], u4.mac[4], u4.mac[5]);
     }
   else
-    {
-      debug_printf ("no Ethernet card installed");
-    }
+    debug_printf ("no Ethernet card installed");
 
   reg_key key (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE", "Microsoft",
 	       "Windows NT", "CurrentVersion", NULL);