[PATCH] Remove WindowsCE support.

NIIBE Yutaka via Gcrypt-devel <[email protected]>
Newsgroups gmane.comp.encryption.gpg.libgcrypt.devel
Message-ID <[email protected]>
Hello,

For GnuPG and other libraries for GnuPG, WindowsCE support has been
removed.  This is a patch for libgcrypt.  Tested (make check) on amd64
and Windows.

--

_______________________________________________
Gcrypt-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gcrypt-devel
0001-Remove-WindowsCE-support.patch (text/x-diff, 17.4 KB)
>From 24a2ca672b2198d3f420399bd01cc626d9de99f8 Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <[email protected]>
Date: Thu, 16 Jan 2025 15:18:04 +0900
Subject: [PATCH] Remove WindowsCE support.

* compat/clock.c, compat/getpid.c, random/rndw32ce.c: Remove.
* compat/Makefile.am: Remove comment for clock.c and getpid.c.
* compat/libcompat.h: Remove replacement functions.
* configure.ac (GPG_ERR_ENABLE_ERRNO_MACROS): Remove.
(have_w32ce_system, HAVE_W32CE_SYSTEM): Remove.
(AC_REPLACE_FUNCS): Remove.
(USE_RNDW32CE): Remove.
* random/Makefile.am (EXTRA_librandom_la_SOURCES): Remove rndw32ce.c.
* random/random-csprng.c [USE_RNDW32CE] (getfnc_gather_random):
Remove WindowsCE support.
(getfnc_fast_random_poll): Likewise.
* src/Makefile.am [HAVE_W32CE_SYSTEM]: Remove WindowsCE support.
* src/dumpsexp.c [__MINGW32CE__]: Remove WindowsCE support.
* tests/stopwatch.h [__MINGW32CE__] (start_timer, stop_timer): Remove
WindowsCE support.

--

GnuPG-bug-id: 7486
Signed-off-by: NIIBE Yutaka <[email protected]>
---
 compat/Makefile.am     |   5 --
 compat/clock.c         |  36 --------
 compat/getpid.c        |  29 ------
 compat/libcompat.h     |  12 ---
 configure.ac           |  40 +--------
 random/Makefile.am     |   1 -
 random/random-csprng.c |   8 --
 random/rndw32ce.c      | 199 -----------------------------------------
 src/Makefile.am        |  18 +---
 src/dumpsexp.c         |   5 --
 tests/stopwatch.h      |  12 ---
 11 files changed, 5 insertions(+), 360 deletions(-)
 delete mode 100644 compat/clock.c
 delete mode 100644 compat/getpid.c
 delete mode 100644 random/rndw32ce.c

diff --git a/compat/Makefile.am b/compat/Makefile.am
index f0ddf34d..0b17ea8f 100644
--- a/compat/Makefile.am
+++ b/compat/Makefile.am
@@ -41,8 +41,3 @@ noinst_LTLIBRARIES = libcompat.la
 libcompat_la_SOURCES = compat.c libcompat.h
 libcompat_la_DEPENDENCIES = @LTLIBOBJS@
 libcompat_la_LIBADD =       @LTLIBOBJS@
-
-# AC_LIBOBJ files are:
-#    getpid.c
-#    clock.c
-#
diff --git a/compat/clock.c b/compat/clock.c
deleted file mode 100644
index 2a2c205f..00000000
--- a/compat/clock.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* clock.c - Replacement for WindowsCE
-   Copyright (C) 2010 Free Software Foundation, Inc.
-
-   This file is free software; as a special exception the author gives
-   unlimited permission to copy and/or distribute it, with or without
-   modifications, as long as this notice is preserved.
-
-   This file is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY, to the extent permitted by law; without even
-   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-   PURPOSE.  */
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_W32CE_SYSTEM
-#include <windows.h>
-#include <time.h>
-#include <assert.h>
-
-clock_t
-_gcry_clock (void)
-{
-  assert (CLOCKS_PER_SEC == 1000);
-#warning Replace by a correct implementation.
-  /* It seems that GetProcessTimes is available in the kernel but
-     without a declaration.  If that fails we would need to walk over
-     all threads and tally up the GetThreadTimes.  */
-
-  return GetTickCount ();
-}
-
-#else
-# error No replacement function for clock known
-#endif
diff --git a/compat/getpid.c b/compat/getpid.c
deleted file mode 100644
index 032387c3..00000000
--- a/compat/getpid.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* getpid.c - Replacement for WindowsCE
-   Copyright (C) 2010 Free Software Foundation, Inc.
-
-   This file is free software; as a special exception the author gives
-   unlimited permission to copy and/or distribute it, with or without
-   modifications, as long as this notice is preserved.
-
-   This file is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY, to the extent permitted by law; without even
-   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-   PURPOSE.  */
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_W32CE_SYSTEM
-#include <windows.h>
-#include <sys/types.h>
-
-pid_t
-_gcry_getpid (void)
-{
-  return GetCurrentProcessId ();
-}
-
-#else
-# error No replacement function for getpid known
-#endif
diff --git a/compat/libcompat.h b/compat/libcompat.h
index d3eb81bf..411a27be 100644
--- a/compat/libcompat.h
+++ b/compat/libcompat.h
@@ -22,16 +22,4 @@
 
 const char *_gcry_compat_identification (void);
 
-
-#ifndef HAVE_GETPID
-pid_t _gcry_getpid (void);
-#define getpid() _gcry_getpid ()
-#endif
-
-#ifndef HAVE_CLOCK
-clock_t _gcry_clock (void);
-#define clock() _gcry_clock ()
-#endif
-
-
 #endif /*GCRY_LIBCOMPAT_H*/
diff --git a/configure.ac b/configure.ac
index f38e20c5..c1bba129 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,9 +90,6 @@ AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
 AH_TOP([
 #ifndef _GCRYPT_CONFIG_H_INCLUDED
 #define _GCRYPT_CONFIG_H_INCLUDED
-
-/* Enable gpg-error's strerror macro for W32CE.  */
-#define GPG_ERR_ENABLE_ERRNO_MACROS 1
 ])
 
 AH_BOTTOM([
@@ -238,7 +235,6 @@ LIBGCRYPT_THREAD_MODULES=""
 
 # Other definitions.
 have_w32_system=no
-have_w32ce_system=no
 have_pthread=no
 
 
@@ -247,15 +243,7 @@ case "${host}" in
     *-*-mingw32*)
       ac_cv_have_dev_random=no
       have_w32_system=yes
-      case "${host}" in
-        *-mingw32ce*)
-            have_w32ce_system=yes
-            available_random_modules="w32ce"
-            ;;
-        *)
-            available_random_modules="w32"
-            ;;
-      esac
+      available_random_modules="w32"
       AC_DEFINE(USE_ONLY_8DOT3,1,
                 [set this to limit filenames to the 8.3 format])
       AC_DEFINE(HAVE_DRIVE_LETTERS,1,
@@ -307,21 +295,12 @@ esac
 
 if test "$have_w32_system" = yes; then
    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
-   if test "$have_w32ce_system" = yes; then
-     AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
-   fi
 fi
 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
-AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
-
 
 
 # A printable OS Name is sometimes useful.
 case "${host}" in
-    *-*-mingw32ce*)
-        PRINTABLE_OS_NAME="W32CE"
-        ;;
-
     *-*-mingw32*)
         PRINTABLE_OS_NAME="W32"
         ;;
@@ -2637,12 +2616,6 @@ AC_CHECK_FUNCS(explicit_bzero explicit_memset getentropy sysctlbyname)
 
 GNUPG_CHECK_MLOCK
 
-#
-# Replacement functions.
-#
-AC_REPLACE_FUNCS([getpid clock])
-
-
 #
 # Check whether it is necessary to link against libdl.
 #
@@ -2712,10 +2685,6 @@ if test "$random" = "default"; then
         random_modules="linux"
     else
         case "${host}" in
-        *-*-mingw32ce*)
-          # WindowsCE random device.
-          random_modules="w32ce"
-          ;;
         *-*-mingw32*|*-*-cygwin*)
           # Windows random device.
           random_modules="w32"
@@ -3721,13 +3690,6 @@ if test "$found" = "1" ; then
              [Defined if the Windows specific RNG should be used.])
 fi
 
-LIST_MEMBER(w32ce, $random_modules)
-if test "$found" = "1" ; then
-   GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32ce.lo"
-   AC_DEFINE(USE_RNDW32CE, 1,
-             [Defined if the WindowsCE specific RNG should be used.])
-fi
-
 if test "$try_asm_modules" = yes ; then
   # Build with assembly implementations
   GCRYPT_CIPHERS="$GCRYPT_CIPHERS $GCRYPT_ASM_CIPHERS"
diff --git a/random/Makefile.am b/random/Makefile.am
index a42e4306..41041e8a 100644
--- a/random/Makefile.am
+++ b/random/Makefile.am
@@ -45,7 +45,6 @@ rndoldlinux.c \
 rndegd.c \
 rndunix.c \
 rndw32.c  \
-rndw32ce.c \
 jitterentropy-gcd.c jitterentropy-gcd.h \
 jitterentropy-health.c jitterentropy-health.h \
 jitterentropy-noise.c jitterentropy-noise.h \
diff --git a/random/random-csprng.c b/random/random-csprng.c
index 4f34acc0..7304f180 100644
--- a/random/random-csprng.c
+++ b/random/random-csprng.c
@@ -1179,11 +1179,6 @@ getfnc_gather_random (void))(void (*)(const void*, size_t,
   return fnc;
 #endif
 
-#if USE_RNDW32CE
-  fnc = _gcry_rndw32ce_gather_random;
-  return fnc;
-#endif
-
   log_fatal (_("no entropy gathering module detected\n"));
 
   return NULL; /*NOTREACHED*/
@@ -1198,9 +1193,6 @@ getfnc_fast_random_poll (void))( void (*)(const void*, size_t,
 {
 #if USE_RNDW32
   return _gcry_rndw32_gather_random_fast;
-#endif
-#if USE_RNDW32CE
-  return _gcry_rndw32ce_gather_random_fast;
 #endif
   return NULL;
 }
diff --git a/random/rndw32ce.c b/random/rndw32ce.c
deleted file mode 100644
index 873e8460..00000000
--- a/random/rndw32ce.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* rndw32ce.c  -  W32CE entropy gatherer
- * Copyright (C) 2010 Free Software Foundation, Inc.
- *
- * Libgcrypt is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * Libgcrypt is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <stdint.h>
-
-#include <windows.h>
-#include <wincrypt.h>
-
-#include "types.h"
-#include "g10lib.h"
-#include "rand-internal.h"
-
-
-/* The Microsoft docs say that it is suggested to see the buffer with
-   some extra random.  We do this, despite that it is a questionable
-   suggestion as the OS as better means of collecting entropy than an
-   application.  */
-static size_t filler_used;
-static size_t filler_length;
-static unsigned char *filler_buffer;
-
-static void
-filler (const void *data, size_t datalen, enum random_origins dummy)
-{
-  (void)dummy;
-  if (filler_used + datalen > filler_length)
-    datalen = filler_length - filler_used;
-  memcpy (filler_buffer + filler_used, data, datalen);
-  filler_used += datalen;
-}
-
-
-static void
-fillup_buffer (unsigned char *buffer, size_t length)
-{
-  filler_used = 0;
-  filler_length = length;
-  filler_buffer = buffer;
-
-  while (filler_used < length)
-    _gcry_rndw32ce_gather_random_fast (filler, 0);
-}
-
-
-int
-_gcry_rndw32ce_gather_random (void (*add)(const void*, size_t,
-                                          enum random_origins),
-                              enum random_origins origin,
-                              size_t length, int level )
-{
-  HCRYPTPROV prov;
-  unsigned char buffer [256];
-  DWORD buflen;
-
-  if (!level)
-    return 0;
-
-  /* Note that LENGTH is not really important because the caller
-     checks the returned lengths and calls this function until it
-     feels that enough entropy has been gathered.  */
-
-  buflen = sizeof buffer;
-  if (length+8 < buflen)
-    buflen = length+8;  /* Return a bit more than requested.  */
-
-  if (!CryptAcquireContext (&prov, NULL, NULL, PROV_RSA_FULL,
-                           (CRYPT_VERIFYCONTEXT|CRYPT_SILENT)) )
-    log_debug ("CryptAcquireContext failed: rc=%d\n", (int)GetLastError ());
-  else
-    {
-      fillup_buffer (buffer, buflen);
-      if (!CryptGenRandom (prov, buflen, buffer))
-        log_debug ("CryptGenRandom(%d) failed: rc=%d\n",
-                   (int)buflen, (int)GetLastError ());
-      else
-        (*add) (buffer, buflen, origin);
-      CryptReleaseContext (prov, 0);
-      wipememory (buffer, sizeof buffer);
-    }
-
-  return 0;
-}
-
-
-
-void
-_gcry_rndw32ce_gather_random_fast (void (*add)(const void*, size_t,
-                                             enum random_origins),
-                                   enum random_origins origin)
-{
-
-  /* Add word sized values.  */
-  {
-#   define ADD(t,f)  do {                                          \
-      t along = (f);                                               \
-      memcpy (bufptr, &along, sizeof (along));                     \
-      bufptr += sizeof (along);                                    \
-    } while (0)
-    unsigned char buffer[20*sizeof(unsigned long)], *bufptr;
-
-    bufptr = buffer;
-    ADD (HWND,   GetActiveWindow ());
-    ADD (HWND,   GetCapture ());
-    ADD (HWND,   GetClipboardOwner ());
-    ADD (HANDLE, GetCurrentProcess ());
-    ADD (DWORD,  GetCurrentProcessId ());
-    ADD (HANDLE, GetCurrentThread ());
-    ADD (DWORD,  GetCurrentThreadId ());
-    ADD (HWND,   GetDesktopWindow ());
-    ADD (HWND,   GetFocus ());
-    ADD (DWORD,  GetMessagePos ());
-    ADD (HWND,   GetOpenClipboardWindow ());
-    ADD (HWND,   GetProcessHeap ());
-    ADD (DWORD,  GetQueueStatus (QS_ALLEVENTS));
-    ADD (DWORD,  GetTickCount ());
-
-    gcry_assert ( bufptr-buffer < sizeof (buffer) );
-    (*add) ( buffer, bufptr-buffer, origin );
-#   undef ADD
-  }
-
-  /* Get multiword system information: Current caret position, current
-     mouse cursor position.  */
-  {
-    POINT point;
-
-    GetCaretPos (&point);
-    (*add) ( &point, sizeof (point), origin );
-    GetCursorPos (&point);
-    (*add) ( &point, sizeof (point), origin );
-  }
-
-  /* Get percent of memory in use, bytes of physical memory, bytes of
-     free physical memory, bytes in paging file, free bytes in paging
-     file, user bytes of address space, and free user bytes.  */
-  {
-    MEMORYSTATUS memoryStatus;
-
-    memoryStatus.dwLength = sizeof (MEMORYSTATUS);
-    GlobalMemoryStatus (&memoryStatus);
-    (*add) ( &memoryStatus, sizeof (memoryStatus), origin );
-  }
-
-
-  /* Get thread and process creation time, exit time, time in kernel
-     mode, and time in user mode in 100ns intervals.  */
-  {
-    HANDLE handle;
-    FILETIME creationTime, exitTime, kernelTime, userTime;
-
-    handle = GetCurrentThread ();
-    GetThreadTimes (handle, &creationTime, &exitTime,
-                    &kernelTime, &userTime);
-    (*add) ( &creationTime, sizeof (creationTime), origin );
-    (*add) ( &exitTime, sizeof (exitTime), origin );
-    (*add) ( &kernelTime, sizeof (kernelTime), origin );
-    (*add) ( &userTime, sizeof (userTime), origin );
-
-    handle = GetCurrentThread ();
-    GetThreadTimes (handle, &creationTime, &exitTime,
-                     &kernelTime, &userTime);
-    (*add) ( &creationTime, sizeof (creationTime), origin );
-    (*add) ( &exitTime, sizeof (exitTime), origin );
-    (*add) ( &kernelTime, sizeof (kernelTime), origin );
-    (*add) ( &userTime, sizeof (userTime), origin );
-
-  }
-
-
-  /* In case the OEM provides a high precision timer get this.  If
-     none is available the default implementation returns the
-     GetTickCount.  */
-  {
-    LARGE_INTEGER performanceCount;
-
-    if (QueryPerformanceCounter (&performanceCount))
-      (*add) (&performanceCount, sizeof (performanceCount), origin);
-  }
-
-}
diff --git a/src/Makefile.am b/src/Makefile.am
index f6191bc8..abddab71 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,15 +38,6 @@ nodist_include_HEADERS = gcrypt.h
 lib_LTLIBRARIES = libgcrypt.la
 bin_PROGRAMS = dumpsexp hmac256 mpicalc
 
-# Depending on the architecture some targets require libgpg-error.
-if HAVE_W32CE_SYSTEM
-arch_gpg_error_cflags = $(GPG_ERROR_CFLAGS)
-arch_gpg_error_libs   = $(GPG_ERROR_LIBS)
-else
-arch_gpg_error_cflags =
-arch_gpg_error_libs   =
-endif
-
 AM_CFLAGS = $(GPG_ERROR_CFLAGS)
 AM_CCASFLAGS = $(NOEXECSTACK_FLAGS)
 
@@ -129,8 +120,8 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \
 
 
 dumpsexp_SOURCES = dumpsexp.c
-dumpsexp_CFLAGS = $(arch_gpg_error_cflags)
-dumpsexp_LDADD = $(arch_gpg_error_libs)
+dumpsexp_CFLAGS =
+dumpsexp_LDADD =
 
 mpicalc_SOURCES = mpicalc.c
 mpicalc_CFLAGS = $(GPG_ERROR_CFLAGS)
@@ -138,9 +129,8 @@ mpicalc_LDADD = libgcrypt.la $(GPG_ERROR_LIBS)
 EXTRA_mpicalc_DEPENDENCIES = libgcrypt.la.done
 
 hmac256_SOURCES = hmac256.c hmac256.h
-hmac256_CFLAGS = -DSTANDALONE @DEF_HMAC_BINARY_CHECK@ \
-	$(arch_gpg_error_cflags)
-hmac256_LDADD = $(arch_gpg_error_libs)
+hmac256_CFLAGS = -DSTANDALONE @DEF_HMAC_BINARY_CHECK@
+hmac256_LDADD =
 
 CLEANFILES = libgcrypt.la.done
 if USE_HMAC_BINARY_CHECK
diff --git a/src/dumpsexp.c b/src/dumpsexp.c
index ae656359..15a69d1d 100644
--- a/src/dumpsexp.c
+++ b/src/dumpsexp.c
@@ -23,11 +23,6 @@
 #include <assert.h>
 #include <stdarg.h>
 #include <errno.h>
-/* For a native WindowsCE binary we need to include gpg-error.h to
-   provide a replacement for strerror.  */
-#ifdef __MINGW32CE__
-# include <gpg-error.h>
-#endif
 
 #define PGM "dumpsexp"
 #define MYVERSION_LINE PGM " (Libgcrypt) " VERSION
diff --git a/tests/stopwatch.h b/tests/stopwatch.h
index 696e3005..c0029ae5 100644
--- a/tests/stopwatch.h
+++ b/tests/stopwatch.h
@@ -41,15 +41,9 @@ static void
 start_timer (void)
 {
 #ifdef _WIN32
-#ifdef __MINGW32CE__
-  GetThreadTimes (GetCurrentThread (),
-                   &started_at.creation_time, &started_at.exit_time,
-                   &started_at.kernel_time, &started_at.user_time);
-#else
   GetProcessTimes (GetCurrentProcess (),
                    &started_at.creation_time, &started_at.exit_time,
                    &started_at.kernel_time, &started_at.user_time);
-#endif
   stopped_at = started_at;
 #else
   struct tms tmp;
@@ -63,15 +57,9 @@ static void
 stop_timer (void)
 {
 #ifdef _WIN32
-#ifdef __MINGW32CE__
-  GetThreadTimes (GetCurrentThread (),
-                   &stopped_at.creation_time, &stopped_at.exit_time,
-                   &stopped_at.kernel_time, &stopped_at.user_time);
-#else
   GetProcessTimes (GetCurrentProcess (),
                    &stopped_at.creation_time, &stopped_at.exit_time,
                    &stopped_at.kernel_time, &stopped_at.user_time);
-#endif
 #else
   struct tms tmp;
 
-- 
2.39.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.