James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 1 | From dec4f95751a103f132e9674adf184188ec69176f Mon Sep 17 00:00:00 2001 |
| 2 | From: PJ Reiniger <pj.reiniger@gmail.com> |
| 3 | Date: Tue, 26 Apr 2022 15:19:14 -0400 |
| 4 | Subject: [PATCH 3/9] Preprocessor cleanup |
| 5 | |
| 6 | --- |
| 7 | include/uv.h | 18 +----------------- |
| 8 | include/uv/unix.h | 8 -------- |
| 9 | include/uv/win.h | 6 +----- |
| 10 | src/unix/internal.h | 2 ++ |
| 11 | src/win/fs.c | 1 + |
| 12 | src/win/tty.c | 2 ++ |
| 13 | src/win/util.c | 8 ++++++++ |
| 14 | src/win/winsock.c | 1 + |
| 15 | 8 files changed, 16 insertions(+), 30 deletions(-) |
| 16 | |
| 17 | diff --git a/include/uv.h b/include/uv.h |
| 18 | index ee1c94cc..dbaeb1e9 100644 |
| 19 | --- a/include/uv.h |
| 20 | +++ b/include/uv.h |
| 21 | @@ -23,9 +23,6 @@ |
| 22 | |
| 23 | #ifndef UV_H |
| 24 | #define UV_H |
| 25 | -#ifdef __cplusplus |
| 26 | -extern "C" { |
| 27 | -#endif |
| 28 | |
| 29 | #if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) |
| 30 | #error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." |
| 31 | @@ -56,11 +53,7 @@ extern "C" { |
| 32 | #include <stddef.h> |
| 33 | #include <stdio.h> |
| 34 | |
| 35 | -#if defined(_MSC_VER) && _MSC_VER < 1600 |
| 36 | -# include "uv/stdint-msvc2008.h" |
| 37 | -#else |
| 38 | -# include <stdint.h> |
| 39 | -#endif |
| 40 | +#include <stdint.h> |
| 41 | |
| 42 | #if defined(_WIN32) |
| 43 | # include "uv/win.h" |
| 44 | @@ -767,16 +760,10 @@ UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); |
| 45 | UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); |
| 46 | UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); |
| 47 | |
| 48 | -#ifdef __cplusplus |
| 49 | -extern "C++" { |
| 50 | - |
| 51 | inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { |
| 52 | return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode)); |
| 53 | } |
| 54 | |
| 55 | -} |
| 56 | -#endif |
| 57 | - |
| 58 | UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); |
| 59 | |
| 60 | /* |
| 61 | @@ -1844,7 +1831,4 @@ UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); |
| 62 | #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS |
| 63 | #undef UV__ERR |
| 64 | |
| 65 | -#ifdef __cplusplus |
| 66 | -} |
| 67 | -#endif |
| 68 | #endif /* UV_H */ |
| 69 | diff --git a/include/uv/unix.h b/include/uv/unix.h |
| 70 | index 420be86c..256fef37 100644 |
| 71 | --- a/include/uv/unix.h |
| 72 | +++ b/include/uv/unix.h |
| 73 | @@ -47,14 +47,6 @@ |
| 74 | |
| 75 | #if defined(__linux__) |
| 76 | # include "uv/linux.h" |
| 77 | -#elif defined (__MVS__) |
| 78 | -# include "uv/os390.h" |
| 79 | -#elif defined(__PASE__) /* __PASE__ and _AIX are both defined on IBM i */ |
| 80 | -# include "uv/posix.h" /* IBM i needs uv/posix.h, not uv/aix.h */ |
| 81 | -#elif defined(_AIX) |
| 82 | -# include "uv/aix.h" |
| 83 | -#elif defined(__sun) |
| 84 | -# include "uv/sunos.h" |
| 85 | #elif defined(__APPLE__) |
| 86 | # include "uv/darwin.h" |
| 87 | #elif defined(__DragonFly__) || \ |
| 88 | diff --git a/include/uv/win.h b/include/uv/win.h |
| 89 | index 10d5e8f1..0a33366f 100644 |
| 90 | --- a/include/uv/win.h |
| 91 | +++ b/include/uv/win.h |
| 92 | @@ -60,11 +60,7 @@ typedef struct pollfd { |
| 93 | #include <fcntl.h> |
| 94 | #include <sys/stat.h> |
| 95 | |
| 96 | -#if defined(_MSC_VER) && _MSC_VER < 1600 |
| 97 | -# include "uv/stdint-msvc2008.h" |
| 98 | -#else |
| 99 | -# include <stdint.h> |
| 100 | -#endif |
| 101 | +#include <stdint.h> |
| 102 | |
| 103 | #include "uv/tree.h" |
| 104 | #include "uv/threadpool.h" |
| 105 | diff --git a/src/unix/internal.h b/src/unix/internal.h |
| 106 | index f9d1666d..2b654157 100644 |
| 107 | --- a/src/unix/internal.h |
| 108 | +++ b/src/unix/internal.h |
| 109 | @@ -192,6 +192,8 @@ struct uv__stream_queued_fds_s { |
| 110 | #if defined(__linux__) && O_NDELAY != O_NONBLOCK |
| 111 | #undef uv__nonblock |
| 112 | #define uv__nonblock uv__nonblock_fcntl |
| 113 | +#undef UV__NONBLOCK_IS_IOCTL |
| 114 | +#define UV__NONBLOCK_IS_FCNTL |
| 115 | #endif |
| 116 | |
| 117 | /* core */ |
| 118 | diff --git a/src/win/fs.c b/src/win/fs.c |
| 119 | index f71b3c04..71c9b169 100644 |
| 120 | --- a/src/win/fs.c |
| 121 | +++ b/src/win/fs.c |
| 122 | @@ -38,6 +38,7 @@ |
| 123 | #include "handle-inl.h" |
| 124 | #include "fs-fd-hash-inl.h" |
| 125 | |
| 126 | +#pragma comment(lib, "Advapi32.lib") |
| 127 | |
| 128 | #define UV_FS_FREE_PATHS 0x0002 |
| 129 | #define UV_FS_FREE_PTR 0x0008 |
| 130 | diff --git a/src/win/tty.c b/src/win/tty.c |
| 131 | index d7522668..9753784d 100644 |
| 132 | --- a/src/win/tty.c |
| 133 | +++ b/src/win/tty.c |
| 134 | @@ -42,6 +42,8 @@ |
| 135 | #include "stream-inl.h" |
| 136 | #include "req-inl.h" |
| 137 | |
| 138 | +#pragma comment(lib, "User32.lib") |
| 139 | + |
| 140 | #ifndef InterlockedOr |
| 141 | # define InterlockedOr _InterlockedOr |
| 142 | #endif |
| 143 | diff --git a/src/win/util.c b/src/win/util.c |
| 144 | index c655f532..7a5dd2ef 100644 |
| 145 | --- a/src/win/util.c |
| 146 | +++ b/src/win/util.c |
| 147 | @@ -63,12 +63,20 @@ |
| 148 | |
| 149 | |
| 150 | /* A RtlGenRandom() by any other name... */ |
| 151 | +extern "C" { |
| 152 | extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength); |
| 153 | +} |
| 154 | |
| 155 | /* Cached copy of the process title, plus a mutex guarding it. */ |
| 156 | static char *process_title; |
| 157 | static CRITICAL_SECTION process_title_lock; |
| 158 | |
| 159 | +#pragma comment(lib, "Advapi32.lib") |
| 160 | +#pragma comment(lib, "IPHLPAPI.lib") |
| 161 | +#pragma comment(lib, "Psapi.lib") |
| 162 | +#pragma comment(lib, "Userenv.lib") |
| 163 | +#pragma comment(lib, "kernel32.lib") |
| 164 | + |
| 165 | /* Frequency of the high-resolution clock. */ |
| 166 | static uint64_t hrtime_frequency_ = 0; |
| 167 | |
| 168 | diff --git a/src/win/winsock.c b/src/win/winsock.c |
| 169 | index a68b0953..7843e9f1 100644 |
| 170 | --- a/src/win/winsock.c |
| 171 | +++ b/src/win/winsock.c |
| 172 | @@ -25,6 +25,7 @@ |
| 173 | #include "uv.h" |
| 174 | #include "internal.h" |
| 175 | |
| 176 | +#pragma comment(lib, "Ws2_32.lib") |
| 177 | |
| 178 | /* Whether there are any non-IFS LSPs stacked on TCP */ |
| 179 | int uv_tcp_non_ifs_lsp_ipv4; |