diff --git a/common/alog.cpp b/common/alog.cpp index 7d93a373..4d5a7aad 100644 --- a/common/alog.cpp +++ b/common/alog.cpp @@ -14,6 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ +#ifdef _WIN64 +#define _POSIX_C_SOURCE 1 +#endif #include "alog.h" #include "lockfree_queue.h" #include "photon/thread/thread.h" @@ -251,7 +254,11 @@ class LogOutputFile final : public BaseLogOutput { if (log_file_fd < 0) return; uint64_t length = end - begin; iovec iov{(void*)begin, length}; +#ifndef _WIN64 ::writev(log_file_fd, &iov, 1); // writev() is atomic, whereas write() is not +#else + ::write(log_file_fd, iov.iov_base, iov.iov_len); +#endif throttle_block(); if (log_file_name && log_file_size_limit) { log_file_size += length; diff --git a/thread/test/test.cpp b/thread/test/test.cpp index afaf6164..36404a98 100644 --- a/thread/test/test.cpp +++ b/thread/test/test.cpp @@ -1465,8 +1465,14 @@ TEST(workpool, async_work_lambda_threadpool_append) { LOG_INFO("DONE"); } +#if defined(_WIN64) #define SAVE_REG(R) register uint64_t R asm(#R); volatile uint64_t saved_##R = R; -#define CHECK_REG(R) asm volatile ("" : "=r"(saved_##R) : "0"(saved_##R)); if (saved_##R != R) puts("differs after context switch!" #R); +#define CHECK_REG(R) asm volatile ("" : "=m"(saved_##R)); if (saved_##R != R) puts(#R " differs after context switch!"); +#else +#define SAVE_REG(R) +#define CHECK_REG(R) +#endif + void* waiter(void* arg) { auto p = (int*)arg; LOG_INFO("Start", VALUE(p), VALUE(*p)); diff --git a/thread/test/x.cpp b/thread/test/x.cpp index 0c35e8d5..3bf8ba69 100644 --- a/thread/test/x.cpp +++ b/thread/test/x.cpp @@ -21,7 +21,7 @@ int DevNull(void* x, int) int (*pDevNull)(void*, int) = &DevNull; -#ifdef TEST +#ifdef ThreadUT #include "../thread.h" namespace photon {