Remove Windows-specific code (#154)

This commit is contained in:
Peter McEvoy 2023-01-23 16:59:46 -05:00 committed by GitHub
commit 7c890c3350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 14 additions and 176 deletions

View File

@ -5,7 +5,6 @@ filegroup(
srcs = glob(["**"]),
)
# TODO: check windows build.
configure_make(
name = "curl",
args = select({

View File

@ -5,7 +5,6 @@ filegroup(
srcs = glob(["**"]),
)
# TODO: check windows build.
configure_make(
name = "gmp",
args = select({

View File

@ -239,7 +239,6 @@ cc_library(
visibility = ["//visibility:private"],
)
# TODO: check windows build.
cc_library(
name = "h2o",
# The `*.c` files below correspond to the files in `lib/` in

View File

@ -5,7 +5,6 @@ filegroup(
srcs = glob(["**"]),
)
# TODO: use configure_make_variant() to select nmake toolchain on windows?
configure_make(
name = "openssl",
args = select({

View File

@ -5,7 +5,6 @@ filegroup(
srcs = glob(["**"]),
)
# TODO: check windows build.
configure_make(
name = "uv",
args = select({

View File

@ -76,26 +76,6 @@
# include <sys/resource.h>
# include <sys/mman.h>
# elif defined(U3_OS_mingw)
# define signal mingw_has_no_usable_signal
# define raise mingw_has_no_usable_raise
# define _POSIX
# include <ctype.h>
# include <inttypes.h>
# include <stdlib.h>
# include <string.h>
# include <stdarg.h>
# include <unistd.h>
# include <stdint.h>
# include <assert.h>
# include <setjmp.h>
# include <stdio.h>
# include <dirent.h>
# include <signal.h>
# include <sys/time.h>
# include "mman.h"
# include "compat.h"
# else
#error "port: headers"
# endif
@ -118,8 +98,6 @@
# define U3_OS_ARCH "linux-x86_64"
# endif
# endif
# elif defined(U3_OS_mingw)
# define U3_OS_ARCH "windows-x86_64"
# elif defined(U3_OS_osx)
# ifdef __LP64__
# ifdef U3_CPU_aarch64
@ -149,9 +127,6 @@
# define U3_OS_LoomBase 0x36000000
# endif
# define U3_OS_LoomBits 30
# elif defined(U3_OS_mingw)
# define U3_OS_LoomBase 0x28000000000
# define U3_OS_LoomBits 30
# elif defined(U3_OS_osx)
# ifdef __LP64__
# define U3_OS_LoomBase 0x28000000000
@ -192,7 +167,7 @@
/* Byte swapping.
*/
# if defined(U3_OS_linux) || defined(U3_OS_bsd) || defined(U3_OS_mingw)
# if defined(U3_OS_linux) || defined(U3_OS_bsd)
# define c3_bswap_16(x) bswap_16(x)
# define c3_bswap_32(x) bswap_32(x)
# define c3_bswap_64(x) bswap_64(x)
@ -206,7 +181,7 @@
/* Sync.
*/
# if defined(U3_OS_linux) || defined(U3_OS_mingw)
# if defined(U3_OS_linux)
# define c3_sync(fd) (fdatasync(fd))
# elif defined(U3_OS_osx)
# define c3_sync(fd) (fcntl(fd, F_FULLFSYNC, 0))
@ -221,7 +196,7 @@
# if defined(U3_OS_linux)
# include <stdio_ext.h>
# define c3_fpurge __fpurge
# elif defined(U3_OS_bsd) || defined(U3_OS_osx) || defined(U3_OS_mingw)
# elif defined(U3_OS_bsd) || defined(U3_OS_osx)
# define c3_fpurge fpurge
# else
# error "port: fpurge"
@ -229,7 +204,7 @@
/* Stat.
*/
# if defined(U3_OS_linux) || defined(U3_OS_mingw)
# if defined(U3_OS_linux)
# define c3_stat_mtime(dp) (u3_time_t_in_ts((dp)->st_mtime))
# elif defined(U3_OS_osx)
# define c3_stat_mtime(dp) (u3_time_in_ts(&((dp)->st_mtimespec)))
@ -245,8 +220,6 @@
*/
# if defined(U3_OS_linux) || defined(U3_OS_bsd) || defined(U3_OS_osx)
# define c3_dev_null "/dev/null"
# elif defined(U3_OS_mingw)
# define c3_dev_null "nul"
# else
# error "port: /dev/null"
# endif

View File

@ -96,8 +96,7 @@
//
static rsignal_jmpbuf u3_Signal;
#if !defined(U3_OS_mingw)
#include <sigsegv.h>
#include "sigsegv.h"
#ifndef SIGSTKSZ
# define SIGSTKSZ 16384
@ -105,7 +104,6 @@ static rsignal_jmpbuf u3_Signal;
#ifndef NO_OVERFLOW
static uint8_t Sigstk[SIGSTKSZ];
#endif
#endif
#if 0
/* _cm_punt(): crudely print trace.
@ -150,25 +148,19 @@ static void _cm_overflow(void *arg1, void *arg2, void *arg3)
static void
_cm_signal_handle(c3_l sig_l)
{
#ifndef U3_OS_mingw
if ( c3__over == sig_l ) {
#ifndef NO_OVERFLOW
sigsegv_leave_handler(_cm_overflow, NULL, NULL, NULL);
#endif
} else
#endif
{
}
else {
u3m_signal(sig_l);
}
}
#ifndef NO_OVERFLOW
static void
#ifndef U3_OS_mingw
_cm_signal_handle_over(int emergency, stackoverflow_context_t scp)
#else
_cm_signal_handle_over(int x)
#endif
{
_cm_signal_handle(c3__over);
}
@ -359,11 +351,7 @@ _cm_signal_deep(c3_w mil_w)
}
#ifndef NO_OVERFLOW
#ifndef U3_OS_mingw
stackoverflow_install_handler(_cm_signal_handle_over, Sigstk, SIGSTKSZ);
#else
rsignal_install_handler(SIGSTK, _cm_signal_handle_over);
#endif
#endif
rsignal_install_handler(SIGINT, _cm_signal_handle_intr);
rsignal_install_handler(SIGTERM, _cm_signal_handle_term);
@ -405,11 +393,7 @@ _cm_signal_done()
rsignal_deinstall_handler(SIGVTALRM);
#ifndef NO_OVERFLOW
#ifndef U3_OS_mingw
stackoverflow_deinstall_handler();
#else
rsignal_deinstall_handler(SIGSTK);
#endif
#endif
{
struct itimerval itm_u;
@ -1645,10 +1629,6 @@ u3m_wall(u3_noun wol)
static void
_cm_limits(void)
{
# ifdef U3_OS_mingw
// Windows doesn't have rlimits. Default maximum thread
// stack size is set in the executable file header.
# else
struct rlimit rlm;
// Moar stack.
@ -1696,7 +1676,6 @@ _cm_limits(void)
}
}
# endif
# endif
}
/* _cm_signals(): set up interrupts, etc.
@ -1704,21 +1683,10 @@ _cm_limits(void)
static void
_cm_signals(void)
{
# if defined(U3_OS_mingw)
// vere using libsigsegv on MingW is very slow, because libsigsegv
// works by installing a top-level SEH unhandled exception filter.
// The top-level filter runs only after Windows walks the whole stack,
// looking up registered exception filters for every stack frame, and
// finds no filter to handle the exception.
// Instead of libsigsegv, all vere functions register a SEH exception
// filter (see compat/mingw/seh_handler.c) that handles both memory
// access and stack overflow exceptions. It calls u3e_fault directly.
# else
if ( 0 != sigsegv_install_handler(u3e_fault) ) {
u3l_log("boot: sigsegv install failed");
exit(1);
}
# endif
# if defined(U3_OS_PROF)
// Block SIGPROF, so that if/when we reactivate it on the

View File

@ -504,7 +504,6 @@ u3_lmdb_save_meta(MDB_env* env_u,
return c3y;
}
#if !defined(U3_OS_mingw)
/* mdb_logerror(): writes an error message and lmdb error code to f.
*/
void mdb_logerror(FILE* f, int err, const char* fmt, ...)
@ -524,4 +523,3 @@ intmax_t mdb_get_filesize(mdb_filehandle_t han_u)
fstat(han_u, &sat_u);
return (intmax_t)sat_u.st_size;
}
#endif

View File

@ -889,10 +889,8 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
//
{
const size_t siz_i =
#if defined(U3_OS_mingw)
0xf00000000;
// 500 GiB is as large as musl on aarch64 wants to allow
#elif (defined(U3_CPU_aarch64) && defined(U3_OS_linux))
#if (defined(U3_CPU_aarch64) && defined(U3_OS_linux))
0x7d00000000;
#else
0x10000000000;

View File

@ -730,9 +730,6 @@ _king_sign_cb(uv_signal_t* sil_u, c3_i num_i)
u3l_log("\r\ninterrupt");
u3_term_ef_ctlc();
#ifdef U3_OS_mingw
PulseEvent(u3_Host.cev_u);
#endif
break;
}
@ -890,14 +887,12 @@ u3_king_commence()
u3C.sign_move_f = _king_sign_move;
// Ignore SIGPIPE signals.
#ifndef U3_OS_mingw
{
struct sigaction sig_s = {{0}};
sigemptyset(&(sig_s.sa_mask));
sig_s.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sig_s, 0);
}
#endif
// boot the ivory pill
//
@ -905,7 +900,6 @@ u3_king_commence()
// disable core dumps (due to lmdb size)
//
#ifndef U3_OS_mingw
{
struct rlimit rlm;
@ -917,7 +911,6 @@ u3_king_commence()
exit(1);
}
}
#endif
// run the loop
//
@ -1310,25 +1303,10 @@ _king_copy_raw(c3_i src_i, c3_i dst_i, c3_y* buf_y, size_t pag_i)
return 0;
}
#if defined(U3_OS_mingw)
int err_win_to_posix(DWORD winerr);
#endif
static c3_i
_king_copy_file(c3_c* src_c, c3_c* dst_c)
{
#if defined(U3_OS_mingw)
// XX try FSCTL_DUPLICATE_EXTENTS_TO_FILE
//
if ( CopyFileA(src_c, dst_c, TRUE) ) {
return 0;
}
// XX fallback on any?
//
errno = err_win_to_posix(GetLastError());
return -1;
#elif defined(U3_OS_osx)
#if defined(U3_OS_osx)
if ( !clonefile(src_c, dst_c, 0) ) {
return 0;
}

View File

@ -1158,7 +1158,7 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u)
// spawn new process and connect to it
//
{
c3_c* arg_c[10];
c3_c* arg_c[9];
c3_c key_c[256];
c3_c wag_c[11];
c3_c hap_c[11];
@ -1195,14 +1195,7 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u)
arg_c[7] = "0";
}
#ifdef U3_OS_mingw
sprintf(cev_c, "%" PRIu64, u3_Host.cev_u);
arg_c[8] = cev_c;
#else
arg_c[8] = 0;
#endif
arg_c[9] = 0;
arg_c[8] = NULL;
uv_pipe_init(u3L, &god_u->inn_u.pyp_u, 0);
uv_timer_init(u3L, &god_u->out_u.tim_u);

View File

@ -7,9 +7,7 @@
#include "ur.h"
#include "platform/rsignal.h"
#include "vere.h"
#if !defined(U3_OS_mingw)
#include "sigsegv.h"
#endif
#include "openssl/conf.h"
#include "openssl/engine.h"
#include "openssl/err.h"
@ -640,9 +638,6 @@ _cw_usage(c3_c* bin_c)
" %s vere ARGS <output dir> download binary:\n",
"\n run as a 'serf':\n",
" %s serf <pier> <key> <flags> <cache-size> <at-event>"
#ifdef U3_OS_mingw
" <ctrlc-handle>"
#endif
"\n",
0
};
@ -752,11 +747,9 @@ report(void)
{
printf("urbit %s\n", URBIT_VERSION);
printf("gmp: %s\n", gmp_version);
#if !defined(U3_OS_mingw)
printf("sigsegv: %d.%d\n",
(libsigsegv_version >> 8) & 0xff,
libsigsegv_version & 0xff);
#endif
printf("openssl: %s\n", SSLeay_version(SSLEAY_VERSION));
printf("libuv: %s\n", uv_version_string());
printf("libh2o: %d.%d.%d\n",
@ -958,14 +951,12 @@ _cw_init_io(uv_loop_t* lup_u)
// Ignore SIGPIPE signals.
//
#ifndef U3_OS_mingw
{
struct sigaction sig_s = {{0}};
sigemptyset(&(sig_s.sa_mask));
sig_s.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sig_s, 0);
}
#endif
// configure pipe to daemon process
//
@ -984,47 +975,12 @@ _cw_init_io(uv_loop_t* lup_u)
}
}
#ifdef U3_OS_mingw
/* _cw_intr_win_cb(): invoked when urth signals ctrl-c.
*/
static void
_cw_intr_win_cb(PVOID param, BOOLEAN timedOut)
{
rsignal_raise(SIGINT);
}
/* _cw_intr_win(): initialize ctrl-c handling.
*/
static void
_cw_intr_win(c3_c* han_c)
{
HANDLE h;
if ( 1 != sscanf(han_c, "%" PRIu64, &h) ) {
fprintf(stderr, "mars: ctrl-c event: bad handle %s: %s\r\n",
han_c, strerror(errno));
}
else {
if ( !RegisterWaitForSingleObject(&h, h, _cw_intr_win_cb,
NULL, INFINITE, 0) )
{
fprintf(stderr,
"mars: ctrl-c event: RegisterWaitForSingleObject(%u) failed (%d)\r\n",
h, GetLastError());
}
}
}
#endif
/* _cw_serf_commence(): initialize and run serf
*/
static void
_cw_serf_commence(c3_i argc, c3_c* argv[])
{
#ifdef U3_OS_mingw
if ( 9 > argc ) {
#else
if ( 8 > argc ) {
#endif
fprintf(stderr, "serf: missing args\n");
exit(1);
}
@ -1038,10 +994,6 @@ _cw_serf_commence(c3_i argc, c3_c* argv[])
c3_c* lom_c = argv[6];
c3_w lom_w;
c3_c* eve_c = argv[7];
#ifdef U3_OS_mingw
c3_c* han_c = argv[8];
_cw_intr_win(han_c);
#endif
_cw_init_io(lup_u);
@ -2135,13 +2087,11 @@ main(c3_i argc,
}
#endif
#if !defined(U3_OS_mingw)
// Handle SIGTSTP as if it was SIGTERM.
//
// Configured here using signal() so as to be immediately available.
//
signal(SIGTSTP, _stop_exit);
#endif
printf("~\n");
// printf("welcome.\n");
@ -2211,18 +2161,6 @@ main(c3_i argc,
}
}
#ifdef U3_OS_mingw
// Initialize event used to transmit Ctrl-C to worker process
//
{
SECURITY_ATTRIBUTES sa = {sizeof(sa), NULL, TRUE};
if ( NULL == (u3_Host.cev_u = CreateEvent(&sa, FALSE, FALSE, NULL)) ) {
u3l_log("boot: failed to create Ctrl-C event: %d", GetLastError());
exit(1);
}
}
#endif
// starting u3m configures OpenSSL memory functions, so we must do it
// before any OpenSSL allocations
//

View File

@ -97,7 +97,7 @@ u3_time_in_ts(struct timespec* tim_ts)
return u3_time_in_tv(&tim_tv);
}
#if defined(U3_OS_linux) || defined(U3_OS_mingw)
#if defined(U3_OS_linux)
/* u3_time_t_in_ts(): urbit time from time_t.
*/
u3_atom
@ -110,7 +110,7 @@ u3_time_t_in_ts(time_t tim)
return u3_time_in_tv(&tim_tv);
}
#endif // defined(U3_OS_linux) || defined(U3_OS_mingw)
#endif /* defined(U3_OS_linux) */
/* u3_time_out_ts(): struct timespec from urbit time.
*/

View File

@ -313,9 +313,6 @@
c3_d now_d; // event tick
uv_loop_t* lup_u; // libuv event loop
u3_usig* sig_u; // signal list
#if defined(U3_OS_mingw)
HANDLE cev_u; // Ctrl-C event handle
#endif
u3_utty* uty_u; // linked terminal list
c3_o nex_o; // upgrade requested
c3_c* arc_c; // upgrade to arch
@ -736,7 +733,7 @@
*/
u3_atom
u3_time_in_ts(struct timespec* tim_ts);
#if defined(U3_OS_linux) || defined(U3_OS_mingw)
#if defined(U3_OS_linux)
/* u3_time_t_in_ts(): urbit time from time_t.
*/
u3_atom