diff --git a/CHANGELOG.md b/CHANGELOG.md index c455efce4a4f712ac56465273aefd566aa568855..04aafd397701544c5ed132dca958123e3a0d2f94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * The loop over `EPICSVERSION` in `driver.makefile` has been removed; various other cleanup has been performed. * Improved output during IOC startup * e3-sequencer tests added, as well as removing pre-processing of .stt files. +* Remove Win32 and CYGWIN32 support ## [4.0.0] diff --git a/require-ess/src/asprintf.c b/require-ess/src/asprintf.c deleted file mode 100644 index 1b18caaf3784524f34489ebc62bceeb82e949358..0000000000000000000000000000000000000000 --- a/require-ess/src/asprintf.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2020 Dirk Zimoch */ -/* Copyright (C) 2020-2022 European Spallation Source, ERIC */ - -#include "asprintf.h" - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> - -/* some implementations have __va_copy instead of va_copy */ -#if !defined(va_copy) && defined(__va_copy) -#define va_copy __va_copy -#endif - -int vasprintf(char **pbuffer, const char *format, va_list ap) { - int len = -1; - -#ifdef va_copy - va_list ap2; - va_copy(ap2, ap); -#else -/* if we have no va_copy, we probably don't need one */ -#define ap2 ap -#endif // va_copy - -#if defined(_WIN32) - len = _vscprintf(format, ap2); -#else - len = vsnprintf(NULL, 0, format, ap2); -#endif - -#ifdef va_copy - va_end(ap2); -#endif // va_copy - - if (len <= 0) { - fprintf(stderr, "vasprintf: error calculating needed size\n"); - return -1; - } - *pbuffer = malloc(len + 1); - if (*pbuffer == NULL) return -1; - return vsprintf(*pbuffer, format, ap); -} - -int asprintf(char **pbuffer, const char *format, ...) { - va_list ap; - int len; - - va_start(ap, format); - len = vasprintf(pbuffer, format, ap); - va_end(ap); - return len; -} diff --git a/require-ess/src/asprintf.h b/require-ess/src/asprintf.h deleted file mode 100644 index 4d502526eaa1bf5f6bd5c7c65a4b390f93df0765..0000000000000000000000000000000000000000 --- a/require-ess/src/asprintf.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2020 Dirk Zimoch */ -/* Copyright (C) 2020-2022 European Spallation Source, ERIC */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -#include <stdarg.h> - -#ifndef __GNUC__ -#define __attribute__(arg) -#endif // __GNUC__ - -int asprintf(char **pbuffer, const char *format, ...) - __attribute__((__format__(__printf__, 2, 3))); -int vasprintf(char **pbuffer, const char *format, va_list ap) - __attribute__((__format__(__printf__, 2, 0))); - -#ifdef __cplusplus -} -#endif // __cplusplus diff --git a/require-ess/src/dbLoadTemplate.y b/require-ess/src/dbLoadTemplate.y index 0651b7a675e9e9645500640392e404e06d0f56e6..2f6a4d81558c988cc1cc35c60c8efb05b1893829 100644 --- a/require-ess/src/dbLoadTemplate.y +++ b/require-ess/src/dbLoadTemplate.y @@ -17,10 +17,7 @@ #include <stddef.h> #include <string.h> #include <errno.h> - -#if !defined (_WIN32) #include <unistd.h> -#endif #include "macLib.h" #include "dbmf.h" @@ -30,10 +27,6 @@ #include "osiFileName.h" #include "epicsVersion.h" -#if defined(vxWorks) || defined (_WIN32) -#include "asprintf.h" -#endif - #include "iocsh.h" #include "epicsExport.h" diff --git a/require-ess/src/require.c b/require-ess/src/require.c index b0c178bd4211f25c88bd7d42e7e4ce223eeb1f69..11ad6e8917d9068d9c2b58e944330f230058f8c7 100644 --- a/require-ess/src/require.c +++ b/require-ess/src/require.c @@ -61,10 +61,6 @@ int requireDebug; #define OS_CLASS "RTEMS" #endif // __rtems__ -#ifdef CYGWIN32 -#define OS_CLASS "cygwin32" -#endif // CYGWIN32 - #ifdef freebsd #define OS_CLASS "freebsd" #endif // freebsd @@ -78,84 +74,18 @@ int requireDebug; #endif // _AIX32 #endif // OS_CLASS +#else + #error Only support Unix based distros +#endif + #include <dlfcn.h> #define HMODULE void * #define getAddress(module, name) dlsym(module, name) -#ifdef CYGWIN32 -#define PREFIX -#define INFIX -#define EXT ".dll" -#else // CYGWIN32 #define PREFIX "lib" #define INFIX #define EXT ".so" -#endif // CYGWIN32 - -#elif defined(_WIN32) - -#ifndef OS_CLASS -#define OS_CLASS "WIN32" -#endif // OS_CLASS - -#include <Psapi.h> -#include <windows.h> -#pragma comment(lib, "kernel32.lib") -#pragma comment(lib, "psapi.lib") -#include "asprintf.h" -#define snprintf _snprintf -#define setenv(name, value, overwrite) _putenv_s(name, value) -#define PATH_MAX MAX_PATH - -#define PREFIX -#define INFIX -#define EXT ".dll" - -#define getAddress(module, name) GetProcAddress(module, name) - -static char *realpath(const char *path, char *buffer) { - int len = MAX_PATH; - if (buffer == NULL) { - len = GetFullPathName(path, 0, NULL, NULL); - if (len == 0) return NULL; - buffer = malloc(len); - if (buffer == NULL) return NULL; - } - GetFullPathName(path, len, buffer, NULL); - return buffer; -} - -#else // defined(none) - -#warning unknown OS -#define PREFIX -#define INFIX -#define EXT -#define getAddress(module, name) NULL - -#endif // defined - -/* for readdir: Windows or Posix */ -#if defined(_WIN32) -#define DIR_HANDLE HANDLE -#define DIR_ENTRY WIN32_FIND_DATA -#define IF_OPEN_DIR(f) \ - if (snprintf(f + modulediroffs, sizeof(f) - modulediroffs, "\\*.*"), \ - (dir = FindFirstFile(filename, &direntry)) != INVALID_HANDLE_VALUE || \ - (FindClose(dir), 0)) -#define START_DIR_LOOP do -#define END_DIR_LOOP \ - while (FindNextFile(dir, &direntry)) \ - ; \ - FindClose(dir); -#define SKIP_NON_DIR(e) \ - if (!(e.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || \ - (e.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) \ - continue; -#define FILENAME(e) e.cFileName - -#else // defined(_WIN32) #include <dirent.h> #define DIR_HANDLE DIR * #define IF_OPEN_DIR(f) if ((dir = opendir(f))) @@ -174,8 +104,6 @@ static char *realpath(const char *path, char *buffer) { #endif // _DIRENT_HAVE_D_TYPE #define FILENAME(e) e->d_name -#endif // defined(_WIN32) - #define LIBDIR "lib" OSI_PATH_SEPARATOR #define TEMPLATEDIR "db" @@ -221,24 +149,9 @@ static HMODULE loadlib(const char *libname) { return NULL; } -#if defined(__unix) if ((libhandle = dlopen(libname, RTLD_NOW | RTLD_GLOBAL)) == NULL) { fprintf(stderr, "Loading %s library failed: %s\n", libname, dlerror()); } -#elif defined(_WIN32) - if ((libhandle = LoadLibrary(libname)) == NULL) { - LPVOID lpMsgBuf; - - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, - 0, NULL); - fprintf(stderr, "Loading %s library failed: %s\n", libname, lpMsgBuf); - LocalFree(lpMsgBuf); - } -#else - fprintf(stderr, "cannot load libraries on this OS.\n"); -#endif return libhandle; } @@ -624,57 +537,6 @@ static void registerExternalModules() { dl_iterate_phdr(findLibRelease, NULL); } -#elif defined(_WIN32) - -static void registerExternalModules() { - HMODULE hMods[100]; - HANDLE hProcess = GetCurrentProcess(); - DWORD cbNeeded; - char *location = NULL; - char *p; - char *version; - char *symname; - unsigned int i; - /* get space for library path + "LibRelease" */ - char name[MAX_PATH + 11]; - - /* iterate over all loaded libraries */ - if (!EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) return; - for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { - /* Get the full path to the module's file. */ - if (!GetModuleFileName(hMods[i], name, MAX_PATH)) - continue; /* no library name */ - name[sizeof(name) - 1] = 0; /* WinXP may not terminate the string */ - - /* find file name part in "<location>/<module>.dll" */ - p = strrchr(name, '\\'); - if (p) { - location = name; - } else { - /* find end of "<location>\\" (if exists) */ - p = name; - } - symname = p; - p = strchr(symname, '.'); /* find ".dll" */ - if (p == NULL) p = symname + strlen(symname); /* no file extension ? */ - memmove(symname + 2, symname, p - symname); /* make room for 0 and '_' */ - *symname++ = 0; /* terminate "<location>/" */ - *symname = '_'; /* prefix module name with '_' */ - strcpy((p += 2), "LibRelease"); /* append "LibRelease" to module name */ - - version = (char *)GetProcAddress( - hMods[i], symname); /* find symbol "_<module>LibRelease" */ - if (version) { - *p = 0; - symname++; /* get "<module>" from "_<module>LibRelease" */ - if ((p = strstr(name, "\\" LIBDIR)) != NULL) - p[1] = 0; /* cut "<location>" before LIBDIR */ - if (getLibVersion(symname) == NULL) - registerModule(symname, version, location); - } - } -} - #else static void registerExternalModules() { ; } #endif @@ -1107,11 +969,6 @@ static int require_priv( fileNotEmpty(filename)) #endif -#if defined(_WIN32) - /* enable %n in printf */ - _set_printf_count_output(1); -#endif - driverpath = getenv("EPICS_DRIVER_PATH"); if (!globalTemplates) { char *t = getenv("TEMPLATES"); diff --git a/require-ess/src/runScript.c b/require-ess/src/runScript.c index 69e2329749ecbd2103bf5c1289be8652b72915c3..f54cef276a68f0fd435956d20cce86875a5b417e 100644 --- a/require-ess/src/runScript.c +++ b/require-ess/src/runScript.c @@ -19,10 +19,6 @@ #define EPICSVER \ EPICS_VERSION * 10000 + EPICS_REVISION * 100 + EPICS_MODIFICATION -#if defined(_WIN32) -#include "asprintf.h" -#endif - #include <iocsh.h> #include <osiFileName.h> DBCORE_API int epicsStdCall iocshCmd(const char *cmd); diff --git a/require-ess/src/strdup.c b/require-ess/src/strdup.c deleted file mode 100644 index 53111b516ca65e99eb86e7ac88b5e08821cfb08c..0000000000000000000000000000000000000000 --- a/require-ess/src/strdup.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2020 Dirk Zimoch */ -/* Copyright (C) 2020-2022 European Spallation Source, ERIC */ - -#include "strdup.h" - -#include <stdlib.h> -#include <string.h> - -char *strdup(const char *s) { - char *d = malloc(strlen(s) + 1); - if (d) strcpy(d, s); - return d; -} - -char *strndup(const char *s, size_t n) { - size_t l; - char *d; - - l = strlen(s); - if (n > l) n = l; - d = malloc(n + 1); - strncpy(d, s, l); - d[n] = 0; - return d; -} diff --git a/require-ess/src/strdup.h b/require-ess/src/strdup.h deleted file mode 100644 index 2f3ea7024ce9c11b588642ed7bf5b80227b1a1e5..0000000000000000000000000000000000000000 --- a/require-ess/src/strdup.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (C) 2020 Dirk Zimoch */ -/* Copyright (C) 2020-2022 European Spallation Source, ERIC */ - -#pragma once - -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -char *strdup(const char *s); -char *strndup(const char *s, size_t n); - -#ifdef __cplusplus -} -#endif // __cplusplus diff --git a/require.Makefile b/require.Makefile index d07f41179c72fb1fabedb9c6c5ce7d1e1adb0f09..f1fe3ec0b77386c857f18868e837976185d90db0 100644 --- a/require.Makefile +++ b/require.Makefile @@ -45,15 +45,6 @@ SOURCES += $(APPSRC)/expr.c SOURCES += $(APPSRC)/dbLoadTemplate.y DBDS += $(APPSRC)/dbLoadTemplate.dbd -# ESS doesn't have any T2_ppc604 and vxWorks target -# Friday, May 11 22:05:07 CEST 2018, jhlee -# -# SOURCES_T2 += strdup.c -# SOURCES_vxWorks += asprintf.c -# -# HEADERS += strdup.h -# HEADERS += asprintf.h - HEADERS += $(APPSRC)/require.h # HEADERS += require_env.h @@ -70,11 +61,6 @@ USR_CFLAGS += -std=c99 # # USR_CFLAGS += -DT_A='"${T_A}"' -# ESS doesn't support WIN32 -# This should really go into some global WIN32 config file -# -# USR_CFLAGS_WIN32 += /D_WIN32_WINNT=0x501 - TEMPLATES += $(APPDB)/moduleversion.template # TEMPLATES += moduleversion.db