check __MINGW32__ instead of __MINGW64__

pull/2467/head
KristofferC 2 years ago committed by nick black
parent d49a0375b7
commit a3c37932d6

@ -7,7 +7,7 @@
extern "C" {
#endif
#ifndef __MINGW64__
#ifndef __MINGW32__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)

@ -10,7 +10,7 @@ extern "C" {
// 32-bit values to little-endian (as used in the nccell gcluster field). This
// ought be defined so that it's a a no-op on little-endian builds.
#ifndef __MINGW64__ // All but Windows
#ifndef __MINGW32__ // All but Windows
#include <netinet/in.h>
#endif
@ -26,7 +26,7 @@ extern "C" {
#define htole(x) (__bswap_32(htonl(x)))
#define wcwidth(w) 1 // FIXME lol, no
#define wcswidth(w, s) (int)(wcslen(w)) // FIXME lol, no
#elif defined(__MINGW64__) // Windows
#elif defined(__MINGW32__) // Windows
#include <string.h>
#define wcwidth(w) 1 // FIXME lol, no
#define wcswidth(w, s) (int)(wcslen(w)) // FIXME lol, no

@ -24,7 +24,7 @@ extern "C" {
#define RESTRICT restrict
#endif
#ifndef __MINGW64__
#ifndef __MINGW32__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)

@ -1,7 +1,7 @@
#include "compat/compat.h"
#include <builddef.h>
#include <pthread.h>
#ifdef __MINGW64__
#ifdef __MINGW32__
#include <string.h>
#include <stdlib.h>
#include <synchapi.h>
@ -178,7 +178,7 @@ int pthread_condmonotonic_init(pthread_cond_t* cond){
}
// FIXME we need a solution for this on macos/windows
#ifndef __APPLE__
#ifndef __MINGW64__
#ifndef __MINGW32__
if(pthread_condattr_setclock(&cat, CLOCK_MONOTONIC)){
pthread_condattr_destroy(&cat);
return -1;

@ -19,7 +19,7 @@ extern "C" {
#define TIMER_ABSTIME 1
#endif
#ifdef __MINGW64__
#ifdef __MINGW32__
static inline char
path_separator(void){
return '\\';
@ -147,7 +147,7 @@ notcurses_data_path(const char* ddir, const char* f){
#ifdef __cplusplus
}
#else
#ifdef __MINGW64__
#ifdef __MINGW32__
char* strndup(const char* str, size_t size);
#endif
#endif

@ -500,7 +500,7 @@ scrub_stdplane(struct notcurses* nc){
}
int main(int argc, char** argv){
#ifndef __MINGW64__
#ifndef __MINGW32__
sigset_t sigmask;
// ensure SIGWINCH is delivered only to a thread doing input
sigemptyset(&sigmask);

@ -151,7 +151,7 @@ int input_dispatcher(struct notcurses* nc){
}
// freebsd doesn't have eventfd :/ and apple doesn't even have pipe2() =[ =[
// omg windows doesn't have pipe() fml FIXME
#ifndef __MINGW64__
#ifndef __MINGW32__
#if defined(__APPLE__)
if(pipe(input_pipefds)){
#else

@ -14,7 +14,7 @@
#include <langinfo.h>
#include <sys/utsname.h>
#include <sys/sysinfo.h>
#elif !defined(__MINGW64__)
#elif !defined(__MINGW32__)
#include <langinfo.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
@ -83,7 +83,7 @@ static int
fetch_env_vars(struct notcurses* nc, fetched_info* fi){
#if defined(__APPLE__)
fi->desktop = "Aqua";
#elif defined(__MINGW64__)
#elif defined(__MINGW32__)
fi->desktop = "Metro";
#else
fi->desktop = getenv("XDG_CURRENT_DESKTOP");
@ -118,7 +118,7 @@ fallback_cpuinfo(void){
static int
fetch_bsd_cpuinfo(fetched_info* fi){
#if defined(__linux__) || defined(__gnu_hurd__) || defined(__MINGW64__)
#if defined(__linux__) || defined(__gnu_hurd__) || defined(__MINGW32__)
(void)fi;
#else
size_t len = sizeof(fi->core_count);
@ -140,7 +140,7 @@ fetch_bsd_cpuinfo(fetched_info* fi){
static int
fetch_windows_cpuinfo(fetched_info* fi){
#ifdef __MINGW64__
#ifdef __MINGW32__
SYSTEM_INFO info = {0};
GetSystemInfo(&info);
switch(info.wProcessorArchitecture){
@ -333,7 +333,7 @@ typedef enum {
static ncneo_kernel_e
get_kernel(fetched_info* fi){
#ifndef __MINGW64__
#ifndef __MINGW32__
struct utsname uts;
if(uname(&uts)){
fprintf(stderr, "Failure invoking uname (%s)\n", strerror(errno));

@ -856,7 +856,7 @@ ncdirect_stop_minimal(void* vnc){
ret |= tcsetattr(nc->tcache.ttyfd, TCSANOW, nc->tcache.tpreserved);
}
ret |= ncdirect_flush(nc);
#ifndef __MINGW64__
#ifndef __MINGW32__
del_curterm(cur_term);
#endif
return ret;

@ -262,7 +262,7 @@ blocking_write(int fd, const char* buf, size_t buflen){
written += w;
}
// FIXME ought probably use WSAPoll() on windows
#ifndef __MINGW64__
#ifndef __MINGW32__
if(written < buflen){
struct pollfd pfd = {
.fd = fd,

@ -6,7 +6,7 @@
#ifdef USING_PIDFD
#error "USING_PIDFD was already defined; it should not be."
#endif
#ifdef __MINGW64__
#ifdef __MINGW32__
#include <winsock2.h>
#else
#include <spawn.h>
@ -46,7 +46,7 @@ fdthread(ncfdplane* ncfp, int pidfd){
pfds[1].events = NCPOLLEVENTS;
}
ssize_t r = 0;
#ifndef __MINGW64__
#ifndef __MINGW32__
while(poll(pfds, fdcount, -1) >= 0 || errno == EINTR){
#else
while(WSAPoll(pfds, fdcount, -1) >= 0){
@ -147,7 +147,7 @@ int ncfdplane_destroy(ncfdplane* n){
return ret;
}
#ifndef __MINGW64__
#ifndef __MINGW32__
// get 2 pipes, and ensure they're both set to close-on-exec
static int
lay_pipes(int pipes[static 2]){
@ -236,7 +236,7 @@ launch_pipe_process(int* pipefd, int* pidfd, unsigned usepath,
}
#endif
#ifndef __MINGW64__
#ifndef __MINGW32__
// nuke the just-spawned process, and reap it. called before the subprocess
// reader thread is launched (which otherwise reaps the subprocess).
static int
@ -349,7 +349,7 @@ ncexecvpe(ncplane* n, const ncsubproc_options* opts, unsigned usepath,
if(opts->flags > 0){
logwarn("Provided unsupported flags %016" PRIx64 "\n", opts->flags);
}
#ifndef __MINGW64__
#ifndef __MINGW32__
int fd = -1;
ncsubproc* ret = malloc(sizeof(*ret));
if(ret == NULL){
@ -404,7 +404,7 @@ int ncsubproc_destroy(ncsubproc* n){
if(n){
void* vret = NULL;
//fprintf(stderr, "pid: %u pidfd: %d waittid: %u\n", n->pid, n->pidfd, n->waittid);
#ifndef __MINGW64__
#ifndef __MINGW32__
#ifdef USING_PIDFD
if(n->pidfd >= 0){
loginfo("Sending SIGKILL to pidfd %d\n", n->pidfd);

@ -42,7 +42,7 @@ typedef struct cursorloc {
int y, x; // 0-indexed cursor location
} cursorloc;
#ifndef __MINGW64__
#ifndef __MINGW32__
typedef int ipipe;
#else
typedef HANDLE ipipe;
@ -59,7 +59,7 @@ typedef struct inputctx {
// own this descriptor, and must not close() it.
int termfd; // terminal fd: -1 with no controlling terminal, or
// if stdin is a terminal, or on MSFT Terminal.
#ifdef __MINGW64__
#ifdef __MINGW32__
HANDLE stdinhandle; // handle to input terminal for MSFT Terminal
#endif
@ -164,7 +164,7 @@ prep_xtmodkeys(inputctx* ictx){
// load all known special keys from terminfo, and build the input sequence trie
static int
prep_special_keys(inputctx* ictx){
#ifndef __MINGW64__
#ifndef __MINGW32__
static const struct {
const char* tinfo;
uint32_t key;
@ -437,7 +437,7 @@ amata_next_string(automaton* amata, const char* prefix){
static inline void
send_synth_signal(int sig){
if(sig){
#ifndef __MINGW64__
#ifndef __MINGW32__
raise(sig);
#endif
}
@ -446,7 +446,7 @@ send_synth_signal(int sig){
static void
mark_pipe_ready(ipipe pipes[static 2]){
char sig = 1;
#ifndef __MINGW64__
#ifndef __MINGW32__
if(write(pipes[1], &sig, sizeof(sig)) != 1){
logwarn("error writing to pipe (%d) (%s)\n", pipes[1], strerror(errno));
#else
@ -1545,7 +1545,7 @@ build_cflow_automaton(inputctx* ictx){
static void
closepipe(ipipe p){
#ifndef __MINGW64__
#ifndef __MINGW32__
if(p >= 0){
close(p);
}
@ -1565,7 +1565,7 @@ endpipes(ipipe pipes[static 2]){
// only linux and freebsd13+ have eventfd(), so we'll fall back to pipes sigh.
static int
getpipes(ipipe pipes[static 2]){
#ifndef __MINGW64__
#ifndef __MINGW32__
#ifndef __APPLE__
if(pipe2(pipes, O_CLOEXEC | O_NONBLOCK)){
logerror("couldn't get pipes (%s)\n", strerror(errno));
@ -1631,7 +1631,7 @@ create_inputctx(tinfo* ti, FILE* infp, int lmargin, int tmargin, int rmargin,
i->stats = stats;
i->ti = ti;
i->stdineof = 0;
#ifdef __MINGW64__
#ifdef __MINGW32__
i->stdinhandle = ti->inhandle;
#endif
i->ibufvalid = 0;
@ -2130,7 +2130,7 @@ block_on_input(inputctx* ictx, unsigned* rtfd, unsigned* rifd){
loginfo("nonblocking read to check for completion\n");
ictx->midescape = 0;
}
#ifdef __MINGW64__
#ifdef __MINGW32__
int timeoutms = nonblock ? 0 : -1;
DWORD ncount = 0;
HANDLE handles[2];
@ -2191,7 +2191,7 @@ block_on_input(inputctx* ictx, unsigned* rtfd, unsigned* rifd){
sigdelset(&smask, SIGTHR);
#endif
int events;
#if defined(__APPLE__) || defined(__MINGW64__)
#if defined(__APPLE__) || defined(__MINGW32__)
int timeoutms = nonblock ? 0 : -1;
while((events = poll(pfds, pfdcount, timeoutms)) < 0){ // FIXME smask?
#else
@ -2283,7 +2283,7 @@ int stop_inputlayer(tinfo* ti){
int ret = 0;
if(ti){
// FIXME cancellation on shutdown does not yet work on windows #2192
#ifndef __MINGW64__
#ifndef __MINGW32__
if(ti->ictx){
loginfo("tearing down input thread\n");
ret |= cancel_and_join("input", ti->ictx->tid, NULL);
@ -2297,7 +2297,7 @@ int stop_inputlayer(tinfo* ti){
}
int inputready_fd(const inputctx* ictx){
#ifndef __MINGW64__
#ifndef __MINGW32__
return ictx->readypipes[0];
#else
(void)ictx;
@ -2363,7 +2363,7 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){
sendsignal = true;
}else{
logtrace("draining event readiness pipe %d\n", ictx->ivalid);
#ifndef __MINGW64__
#ifndef __MINGW32__
char c;
while(read(ictx->readypipes[0], &c, sizeof(c)) == 1){
// FIXME accelerate?
@ -2444,7 +2444,7 @@ linesigs_disable(tinfo* ti){
if(!ti->ictx->linesigs){
logwarn("linedisc signals already disabled\n");
}
#ifndef __MINGW64__
#ifndef __MINGW32__
if(ti->ttyfd < 0){
return 0;
}
@ -2484,7 +2484,7 @@ linesigs_enable(tinfo* ti){
if(ti->ictx->linesigs){
logwarn("linedisc signals already enabled\n");
}
#ifndef __MINGW64__
#ifndef __MINGW32__
if(ti->ttyfd < 0){
return 0;
}

@ -12,7 +12,7 @@ extern "C" {
#include "notcurses/notcurses.h"
#include "notcurses/direct.h"
#ifndef __MINGW64__
#ifndef __MINGW32__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)
@ -37,7 +37,7 @@ extern "C" {
#include <stdbool.h>
#include <inttypes.h>
#include <unictype.h>
#ifndef __MINGW64__
#ifndef __MINGW32__
#include <langinfo.h>
#endif
#include "lib/termdesc.h"
@ -1818,10 +1818,10 @@ prefix_data(const char* base){
// within unix, we can just use isatty(3). on windows, things work
// differently. for a true Windows Terminal, we'll have HANDLE pointers
// rather than file descriptors. in cygwin/msys2, isatty(3) always fails.
// so for __MINGW64__, always return true. otherwise return isatty(fd).
// so for __MINGW32__, always return true. otherwise return isatty(fd).
static inline int
tty_check(int fd){
#ifdef __MINGW64__
#ifdef __MINGW32__
return _isatty(fd);
#endif
return isatty(fd);

@ -325,7 +325,7 @@ int update_term_dimensions(unsigned* rows, unsigned* cols, tinfo* tcache,
cols = &colsafe;
colsafe = tcache->dimx;
}
#ifndef __MINGW64__
#ifndef __MINGW32__
struct winsize ws;
if(tiocgwinsz(tcache->ttyfd, &ws)){
return -1;
@ -1039,7 +1039,7 @@ int ncplane_destroy_family(ncplane *ncp){
// if that flag is set, we take the locale and encoding as we get them.
void init_lang(void){
char* setret;
#ifdef __MINGW64__
#ifdef __MINGW32__
if((setret = setlocale(LC_ALL, ".UTF8")) == NULL){
logwarn("couldn't set LC_ALL to utf8\n");
}
@ -1054,7 +1054,7 @@ void init_lang(void){
loginfo("LANG was explicitly set to %s, not changing locale\n", lang);
return;
}
#ifndef __MINGW64__
#ifndef __MINGW32__
if((setret = setlocale(LC_ALL, "")) == NULL){
logwarn("setting locale based on LANG failed\n");
}
@ -1410,7 +1410,7 @@ int notcurses_stop(notcurses* nc){
if(!(nc->flags & NCOPTION_SUPPRESS_BANNERS)){
summarize_stats(nc);
}
#ifndef __MINGW64__
#ifndef __MINGW32__
del_curterm(cur_term);
#endif
ret |= pthread_mutex_destroy(&nc->stats.lock);

@ -466,7 +466,7 @@ init_terminfo_esc(tinfo* ti, const char* name, escape_e idx,
// which can be identified directly, sans queries.
// we do not send this query on Windows because it is bled through ConHost,
// and echoed onto the standard output.
#ifndef __MINGW64__
#ifndef __MINGW32__
#define KITTYQUERY "\x1b_Gi=1,a=q;\x1b\\"
#else
#define KITTYQUERY
@ -776,7 +776,7 @@ static int
apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm,
size_t* tablelen, size_t* tableused, bool* invertsixel,
unsigned nonewfonts){
#ifdef __MINGW64__
#ifdef __MINGW32__
if(qterm == TERMINAL_UNKNOWN){
qterm = TERMINAL_MSTERMINAL;
}
@ -1006,7 +1006,7 @@ macos_early_matches(void){
#endif
#ifndef __APPLE__
#ifndef __MINGW64__
#ifndef __MINGW32__
// rxvt has a deeply fucked up palette code implementation. its responses are
// terminated with a bare ESC instead of BEL or ST, impossible to encode in
// our automaton alongside the proper flow. its "oc" doesn't reset the palette,
@ -1065,7 +1065,7 @@ int interrogate_terminfo(tinfo* ti, FILE* out, unsigned utf8,
const char* tname = NULL;
#ifdef __APPLE__
ti->qterm = macos_early_matches();
#elif defined(__MINGW64__)
#elif defined(__MINGW32__)
if(termtype){
logwarn("termtype (%s) ignored on windows\n", termtype);
}
@ -1106,7 +1106,7 @@ int interrogate_terminfo(tinfo* ti, FILE* out, unsigned utf8,
goto err;
}
}
#ifndef __MINGW64__
#ifndef __MINGW32__
// windows doesn't really have a concept of terminfo. you might ssh into other
// machines, but they'll use the terminfo installed thereon (putty, etc.).
int termerr;
@ -1425,7 +1425,7 @@ int locate_cursor(tinfo* ti, unsigned* cursor_y, unsigned* cursor_x){
}
int tiocgwinsz(int fd, struct winsize* ws){
#ifndef __MINGW64__
#ifndef __MINGW32__
int i = ioctl(fd, TIOCGWINSZ, ws);
if(i < 0){
logerror("TIOCGWINSZ failed on %d (%s)\n", fd, strerror(errno));
@ -1444,7 +1444,7 @@ int tiocgwinsz(int fd, struct winsize* ws){
}
int cbreak_mode(tinfo* ti){
#ifndef __MINGW64__
#ifndef __MINGW32__
int ttyfd = ti->ttyfd;
if(ttyfd < 0){
return 0;

@ -194,7 +194,7 @@ typedef struct tinfo {
char* linux_fb_dev; // device corresponding to linux_fb_dev
uint8_t* linux_fbuffer; // mmap()ed framebuffer
size_t linux_fb_len; // size of map
#elif defined(__MINGW64__)
#elif defined(__MINGW32__)
HANDLE inhandle;
HANDLE outhandle;
#endif

@ -6,7 +6,7 @@
// primarily drive ownership off an atomic, safely used within a signal handler
static void* _Atomic signal_nc = ATOMIC_VAR_INIT(NULL);
#ifdef __MINGW64__
#ifdef __MINGW32__
int block_signals(sigset_t* old_blocked_signals){
(void)old_blocked_signals;
return 0;

@ -1,10 +1,10 @@
#ifndef __MINGW64__
#ifndef __MINGW32__
#include <pwd.h>
#include <unistd.h>
#if defined(__linux__) || defined(__gnu_hurd__)
#include <sys/utsname.h>
#include <sys/sysinfo.h>
#elif !defined(__MINGW64__)
#elif !defined(__MINGW32__)
#include <sys/sysctl.h>
#include <sys/utsname.h>
#endif
@ -33,7 +33,7 @@ int set_loglevel_from_env(ncloglevel_e* llptr){
}
char* notcurses_accountname(void){
#ifndef __MINGW64__
#ifndef __MINGW32__
const char* un;
if( (un = getenv("LOGNAME")) ){
return strdup(un);
@ -60,7 +60,7 @@ char* notcurses_accountname(void){
}
char* notcurses_hostname(void){
#ifndef __MINGW64__
#ifndef __MINGW32__
char hostname[_POSIX_HOST_NAME_MAX + 1];
if(gethostname(hostname, sizeof(hostname)) == 0){
char* fqdn = strchr(hostname, '.');
@ -80,7 +80,7 @@ char* notcurses_hostname(void){
}
char* notcurses_osversion(void){
#ifdef __MINGW64__
#ifdef __MINGW32__
// FIXME get version
return strdup("Microsoft Windows");
#else

@ -1,7 +1,7 @@
#include "termdesc.h"
#include "internal.h"
#include "windows.h"
#ifdef __MINGW64__
#ifdef __MINGW32__
// ti has been memset to all zeroes. windows configuration is static.
int prepare_windows_terminal(tinfo* ti, size_t* tablelen, size_t* tableused){
const struct wtermdesc {

@ -96,7 +96,7 @@ int handle_dir(int dirfd, const std::string& pdir, const char* p,
return 0;
}
int newdir = -1;
#ifndef __MINGW64__
#ifndef __MINGW32__
newdir = openat(dirfd, p, O_DIRECTORY | O_CLOEXEC);
if(newdir < 0){
std::cerr << "Error opening " << p << ": " << strerror(errno) << std::endl;
@ -141,7 +141,7 @@ int handle_deref(const char* p, const struct stat* st, const lsContext& ctx){
// true iff the path was directly listed on the command line.
int handle_path(int dirfd, const std::string& pdir, const char* p, const lsContext& ctx, bool toplevel){
struct stat st;
#ifndef __MINGW64__
#ifndef __MINGW32__
if(fstatat(dirfd, p, &st, AT_NO_AUTOMOUNT)){
std::cerr << "Error running fstatat(" << p << "): " << strerror(errno) << std::endl;
return -1;

@ -1,4 +1,4 @@
#ifndef __MINGW64__
#ifndef __MINGW32__
#include <poll.h>
#endif
#include <notcurses/notcurses.h>
@ -24,7 +24,7 @@ int main(void){
goto err;
}
// just some pointless testing of notcurses_inputready_fd() here
#ifndef __MINGW64__
#ifndef __MINGW32__
struct pollfd pfd = {
.fd = notcurses_inputready_fd(nc),
.events = POLLIN,

@ -134,7 +134,7 @@ auto lang_and_term() -> void {
}else{
std::cout << "Running with LANG=" << lang << std::endl;
}
#ifndef __MINGW64__
#ifndef __MINGW32__
const char* term = getenv("TERM");
// ubuntu's buildd sets TERM=unknown, fuck it, handle this atrocity
if(term == nullptr || strcmp(term, "unknown") == 0){

Loading…
Cancel
Save