diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d22b2ef62d..693755d31c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,16 +22,19 @@ cmake_minimum_required(VERSION 2.8) # CMake's Fortran tests SET(CMAKE_Fortran_COMPILER_WORKS 1) -if( NOT DEFINED TARGET_ARCHITECTURE ) - execute_process(COMMAND uname -m OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE TARGET_ARCHITECTURE) -endif() -if( NOT DEFINED TARGET_OS ) - execute_process(COMMAND uname -s OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE TARGET_OS) +set(CMAKE_Fortran_PREPROCESS_SOURCE + " -cpp -E -o ") + +# If we are not building as a part of LLVM, build Flang as an +# standalone project, using LLVM as an external library: +if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + project(Flang) endif() +set(TARGET_OS ${CMAKE_HOST_SYSTEM_NAME}) +set(TARGET_ARCHITECTURE ${CMAKE_HOST_SYSTEM_PROCESSOR}) + if( ${TARGET_OS} STREQUAL "Linux" ) set(OS "LINUX") set(OSNAME "Linux") @@ -51,16 +54,23 @@ if( ${TARGET_OS} STREQUAL "Linux" ) message("Unsupported architecture: ${TARGET_ARCHITECTURE}" ) return() endif() +elseif(${TARGET_OS} STREQUAL "Windows" ) + set(OS "WINDOWS") + set(OSNAME "Windows") + if( ${TARGET_ARCHITECTURE} STREQUAL "AMD64" ) + set(TARGET_ARCHITECTURE "x86_64") + set(ARCHNAME x86-64) + set(ARCH X86) + set(WRDSZ 64) + else() + message("Unsupported architecture: ${TARGET_ARCHITECTURE}" ) + return() + endif() else() message("Unsupported OS: ${TARGET_OS}" ) return() endif() -# The cmake documentation states that these are set. They are not so we -# set them here -set(CMAKE_HOST_SYSTEM_NAME ${TARGET_OS}) -set(CMAKE_HOST_SYSTEM_PROCESSOR ${TARGET_ARCHITECTURE}) - # If we are not building as a part of LLVM, build Flang as an # standalone project, using LLVM as an external library: if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) diff --git a/include/legacy-util-api.h b/include/legacy-util-api.h index f4fa9a261a2..e30530c5739 100644 --- a/include/legacy-util-api.h +++ b/include/legacy-util-api.h @@ -41,7 +41,9 @@ extern "C" { #include #include #include /* time() */ +#ifndef _WIN32 #include /* getcwd() */ +#endif /* See tmpfile(3). */ FILE *tmpf(char *ignored); diff --git a/lib/scutil/cpu-stopwatch.c b/lib/scutil/cpu-stopwatch.c index a2ea16a5182..95b6755e605 100644 --- a/lib/scutil/cpu-stopwatch.c +++ b/lib/scutil/cpu-stopwatch.c @@ -21,6 +21,8 @@ * since the most recent call. Very much not thread-safe. */ +#ifndef _WIN32 + #include #include #include "scutil.h" @@ -51,3 +53,33 @@ getcpu(void) last = now; return elapsed; } + +#else + +#include +//#include "scutil.h" + +unsigned long +getcpu(void) +{ + LARGE_INTEGER ticks_per_second = {-1}; + LARGE_INTEGER ticks; + + unsigned long last = 0; + unsigned long now, elapsed; + + /* Initialize ticks_per_second. */ + if (ticks_per_second.QuadPart <= 0) + QueryPerformanceFrequency(&ticks_per_second.QuadPart); + + QueryPerformanceCounter(&ticks); + now = ticks.QuadPart; + now *= 1000; /* milliseconds */ + now /= ticks_per_second.QuadPart; + + elapsed = now - last; + last = now; + return elapsed; +} + +#endif diff --git a/lib/scutil/host-fp-folding.c b/lib/scutil/host-fp-folding.c index 50e48047bdf..cd03bb7b57a 100644 --- a/lib/scutil/host-fp-folding.c +++ b/lib/scutil/host-fp-folding.c @@ -81,7 +81,7 @@ configure_denormals(bool denorms_are_zeros, bool flush_to_zero) fenv_t fenv; if (fegetenv(&fenv) != 0) fprintf(stderr, "fegetenv() failed: %s\n", strerror(errno)); -#ifdef __x86_64__ +#if defined(__x86_64__) && !defined(_WIN32) fenv.__mxcsr &= ~0x0040; if (denorms_are_zeros) fenv.__mxcsr |= 0x0040; diff --git a/lib/scutil/lockfile.c b/lib/scutil/lockfile.c index 27681137a79..70dc41d52b4 100644 --- a/lib/scutil/lockfile.c +++ b/lib/scutil/lockfile.c @@ -43,7 +43,12 @@ * Clean up by deleting the uniquely named file we had created earlier. */ -#include +#ifndef _WIN32 + #include +#else + #include + #include +#endif #include #include #include @@ -64,6 +69,9 @@ static char *udir = NULL; */ static long uwaiting; +#ifdef _WIN32 +#define pid_t int +#endif int __pg_make_lock_file(char *dir) { diff --git a/lib/scutil/path-utils.c b/lib/scutil/path-utils.c index ca4c8c72074..cadbdac696c 100644 --- a/lib/scutil/path-utils.c +++ b/lib/scutil/path-utils.c @@ -23,7 +23,9 @@ #include "legacy-util-api.h" #include #include +#ifndef _WIN32 #include /* access() */ +#endif void basenam(const char *orig_path, const char *optional_suffix, char *basename) diff --git a/lib/scutil/pgnewfil.c b/lib/scutil/pgnewfil.c index e198d33ef4e..590c678ed75 100644 --- a/lib/scutil/pgnewfil.c +++ b/lib/scutil/pgnewfil.c @@ -29,9 +29,10 @@ #include #include -#if defined(HOST_WIN) +#if defined(_WIN32) #include #include +#include extern unsigned long getpid(void); #else #include @@ -42,6 +43,10 @@ int pgnewfil_debug = 0; #endif extern size_t strlen(); +#ifndef S_ISDIR +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif + /* * copy chars from q to p, terminate string, return end of string */ @@ -307,7 +312,7 @@ pg_makenewfile(char *pfx, char *sfx, int make) if (!make) { break; } else { -#if defined(HOST_WIN) +#if defined(_WIN32) fd = _open(filename, _O_CREAT | _O_BINARY | _O_EXCL | _O_RDWR, _S_IWRITE); #else fd = open(filename, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); @@ -353,7 +358,7 @@ pg_makenewdir(char *pfx, char *sfx, int make) if (r == -1 && errno == ENOENT) { if (make) { int err; -#if defined(HOST_WIN) || defined(WINNT) || defined(WIN64) +#if defined(_WIN32) || defined(WINNT) || defined(WIN64) err = _mkdir(filename); #else err = mkdir(filename, S_IRWXG | S_IRWXO | S_IXUSR | S_IWUSR | S_IRUSR); diff --git a/runtime/flang/CMakeLists.txt b/runtime/flang/CMakeLists.txt index 2cd90370da0..446e1129fcc 100644 --- a/runtime/flang/CMakeLists.txt +++ b/runtime/flang/CMakeLists.txt @@ -480,7 +480,12 @@ add_flang_library(flang_static ${FTN_SUPPORT} ${SHARED_SOURCES} ) + +if (MSVC) +set_property(TARGET flang_static PROPERTY OUTPUT_NAME flang_static) +else() set_property(TARGET flang_static PROPERTY OUTPUT_NAME flang) +endif() set(SHARED_LIBRARY TRUE) add_flang_library(flang_shared @@ -489,9 +494,12 @@ add_flang_library(flang_shared ${SHARED_SOURCES} ) set_property(TARGET flang_shared PROPERTY OUTPUT_NAME flang) -target_link_libraries(flang_shared ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/libflangrti.so) +target_link_libraries(flang_shared flangrti_shared) # Resolve symbols against libm and librt -target_link_libraries(flang_shared m rt) +target_link_libraries(flang_shared rt) +if (NOT MSVC) +target_link_libraries(flang_shared m) +endif() set(SHARED_LIBRARY FALSE) @@ -538,7 +546,6 @@ set_source_files_properties( OBJECT_DEPENDS ${CMAKE_Fortran_MODULE_DIRECTORY}/iso_c_binding.mod ) - set_target_properties(flang_static flang_shared PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${FLANG_RTE_LIB_DIR} @@ -568,9 +575,10 @@ add_dependencies(flang_shared flang2 ) -target_compile_options(flang_static PRIVATE -fPIC) - -target_compile_options(flang_shared PRIVATE -fPIC) +if (NOT MSVC) + target_compile_options(flang_static PRIVATE -fPIC) + target_compile_options(flang_shared PRIVATE -fPIC) +endif() target_compile_options(flang_static PUBLIC $<$:-Mreentrant>) diff --git a/runtime/flang/access3f.c b/runtime/flang/access3f.c index 7418d877dbc..42068eb272e 100644 --- a/runtime/flang/access3f.c +++ b/runtime/flang/access3f.c @@ -20,7 +20,9 @@ /* access3f.c - Implements LIB3F access subroutine. */ /* must include ent3f.h AFTER io3f.h */ +#ifndef _WIN32 #include +#endif #include "io3f.h" #include "ent3f.h" diff --git a/runtime/flang/alarm3f.c b/runtime/flang/alarm3f.c index da66a5d53d8..8cd9edc2224 100644 --- a/runtime/flang/alarm3f.c +++ b/runtime/flang/alarm3f.c @@ -19,7 +19,7 @@ /* alarm3f.c - Implements LIB3F alarm subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include #include "ent3f.h" diff --git a/runtime/flang/allo.c b/runtime/flang/allo.c index a7e4e1f0453..0e9e4918df2 100644 --- a/runtime/flang/allo.c +++ b/runtime/flang/allo.c @@ -247,7 +247,7 @@ I8(__fort_alloc)(__INT_T nelem, dtype kind, size_t len, __STAT_T *stat, char msg[80]; char *p_env; -#if (defined(WIN64) || defined(WIN32)) +#if (defined(_WIN32)) #define ALN_LARGE #else #undef ALN_LARGE @@ -396,7 +396,7 @@ I8(__alloc04)(__NELEM_T nelem, dtype kind, size_t len, if (!ISPRESENT(errmsg)) errmsg = NULL; -#if (defined(WIN64) || defined(WIN32)) +#if (defined(_WIN32)) #define ALN_LARGE #else #undef ALN_LARGE diff --git a/runtime/flang/amod.c b/runtime/flang/amod.c index f1225bd7fb9..4a042ec00af 100644 --- a/runtime/flang/amod.c +++ b/runtime/flang/amod.c @@ -17,16 +17,8 @@ #include "mthdecls.h" -#if defined(WIN64) -float __fmth_i_amod(float f, float g); -#endif - float __mth_i_amod(float f, float g) { -#if defined(WIN64) - return __fmth_i_amod(f, g); -#else return FMODF(f, g); -#endif } diff --git a/runtime/flang/assign.c b/runtime/flang/assign.c index dc3efddd64f..55fbf53e5a5 100644 --- a/runtime/flang/assign.c +++ b/runtime/flang/assign.c @@ -210,8 +210,8 @@ __fortio_assign(char *item, /* where to store */ case __INT8: if (__ftn_32in64_) I64_MSH(valp->val.i8) = 0; - PP_INT4(item) = valp->val.i8[0]; - PP_INT4(item + 4) = valp->val.i8[1]; + PP_INT4(item) = I64_LSH(valp->val.i8); + PP_INT4(item + 4) = I64_MSH(valp->val.i8); break; case __REAL4: PP_REAL4(item) = (float)I64_LSH(valp->val.i8); diff --git a/runtime/flang/async.c b/runtime/flang/async.c index 5e5c81918fb..d5633ef2c3e 100644 --- a/runtime/flang/async.c +++ b/runtime/flang/async.c @@ -27,7 +27,7 @@ * Fio_asy_close - called from close */ -#if !defined(TARGET_WIN_X8664) +#if !defined(_WIN32) #include #include #include @@ -52,7 +52,7 @@ struct asy_transaction_data { seekoffx_t off; }; -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) struct asy { FILE *fp; int fd; @@ -92,7 +92,7 @@ static int slime; /* internal wait for asynch i/o */ -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) static int asy_wait(struct asy *asy) { @@ -253,7 +253,7 @@ Fio_asy_open(FILE *fp, struct asy **pasy) { struct asy *asy; char *p; -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) HANDLE temp_handle; #endif asy = (struct asy *)calloc(sizeof(struct asy), 1); @@ -263,7 +263,7 @@ Fio_asy_open(FILE *fp, struct asy **pasy) } asy->fp = fp; asy->fd = __io_getfd(fp); -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) temp_handle = _get_osfhandle(asy->fd); asy->handle = ReOpenFile(temp_handle, GENERIC_READ | GENERIC_WRITE, @@ -287,13 +287,13 @@ Fio_asy_read(struct asy *asy, void *adr, long len) int n; int tn; -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) union Converter converter; #endif if (slime) printf("--Fio_asy_read %d %p %ld\n", asy->fd, adr, len); -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) if (asy->flags & ASY_IOACT) { /* i/o active? */ if (asy_wait(asy) == -1) { /* ..yes, wait */ return (-1); @@ -302,11 +302,11 @@ Fio_asy_read(struct asy *asy, void *adr, long len) tn = asy->outstanding_transactions; asy->overlap[tn].Internal = 0; asy->overlap[tn].InternalHigh = 0; - asy->overlap[tn].u.Pointer = 0; + asy->overlap[tn].Pointer = 0; /* Load asy->off into OffsetHigh/Offset */ converter.offset = asy->atd[tn].off; - asy->overlap[tn].u.s.Offset = converter.wOffset; - asy->overlap[tn].u.s.OffsetHigh = converter.wOffsetHigh; + asy->overlap[tn].Offset = converter.wOffset; + asy->overlap[tn].OffsetHigh = converter.wOffsetHigh; asy->overlap[tn].hEvent = 0; if (ReadFile(asy->handle, adr, len, NULL, &(asy->overlap[tn])) == FALSE && GetLastError() != ERROR_IO_PENDING) { @@ -340,14 +340,14 @@ Fio_asy_write(struct asy *asy, void *adr, long len) { int n; int tn; -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) union Converter converter; #endif if (slime) printf("--Fio_asy_write %d %p %ld\n", asy->fd, adr, len); -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) if (asy->flags & ASY_IOACT) { /* i/o active? */ if (asy_wait(asy) == -1) { /* ..yes, wait */ return (-1); @@ -356,11 +356,11 @@ Fio_asy_write(struct asy *asy, void *adr, long len) tn = asy->outstanding_transactions; asy->overlap[tn].Internal = 0; asy->overlap[tn].InternalHigh = 0; - asy->overlap[tn].u.Pointer = 0; + asy->overlap[tn].Pointer = 0; /* Load asy->off into OffsetHigh/Offset. */ converter.offset = asy->atd[0].off; - asy->overlap[tn].u.s.Offset = converter.wOffset; - asy->overlap[tn].u.s.OffsetHigh = converter.wOffsetHigh; + asy->overlap[tn].Offset = converter.wOffset; + asy->overlap[tn].OffsetHigh = converter.wOffsetHigh; asy->overlap[tn].hEvent = 0; if (WriteFile(asy->handle, adr, len, NULL, &(asy->overlap[tn])) == FALSE && GetLastError() != ERROR_IO_PENDING) { @@ -408,11 +408,10 @@ Fio_asy_close(struct asy *asy) if (asy->flags & ASY_IOACT) { /* i/o active? */ n = asy_wait(asy); } -#if defined(TARGET_WIN_X8664) +#if defined(_WIN32) /* Close the Re-opened handle that we created. */ CloseHandle(asy->handle); #endif free(asy); return (n); } - diff --git a/runtime/flang/backspace.c b/runtime/flang/backspace.c index 8b9aef71ce4..a95f6139c2c 100644 --- a/runtime/flang/backspace.c +++ b/runtime/flang/backspace.c @@ -74,7 +74,7 @@ _f90io_backspace(__INT_T *unit, __INT_T *bitv, __INT_T *iostat, int swap_bytes) if (f->nonadvance) { f->nonadvance = FALSE; -#if defined(WINNT) +#if defined(_WIN32) if (__fortio_binary_mode(f->fp)) __io_fputc('\r', f->fp); #endif diff --git a/runtime/flang/bcopys.c b/runtime/flang/bcopys.c index 538a18fcf59..d5be5c3258f 100644 --- a/runtime/flang/bcopys.c +++ b/runtime/flang/bcopys.c @@ -35,7 +35,7 @@ __fort_bcopysl(char *to, char *fr, size_t cnt, size_t tostr, size_t frstr, { size_t i, j; unsigned long n; -#if !defined(WIN64) +#if !defined(_WIN32) long k; #else long long k; diff --git a/runtime/flang/buffer.c b/runtime/flang/buffer.c index 718650fce93..23197b527f2 100644 --- a/runtime/flang/buffer.c +++ b/runtime/flang/buffer.c @@ -18,17 +18,17 @@ /** \file * \brief FIXME */ - -#if !defined(PARAMID) && !defined(WINNT) #include -#endif #include "stdioInterf.h" #include "fioMacros.h" -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define write _write #define creat _creat #define close _close +#define O_WRONLY _O_WRONLY +#define O_CREAT _O_CREAT +#define O_TRUNC _O_TRUNC #endif #define MAXBUF 4096 @@ -72,7 +72,7 @@ __fort_zopen(char *path) __fort_rrecv(ioproc, &off, sizeof(off), 1, __UCHAR); } else { off = 0; - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666); + fd = open(path); if (fd == -1) { __fort_abortp(path); } diff --git a/runtime/flang/cdpowi.c b/runtime/flang/cdpowi.c index 317065554c0..4348f59e331 100644 --- a/runtime/flang/cdpowi.c +++ b/runtime/flang/cdpowi.c @@ -22,8 +22,11 @@ ZMPLXFUNC_Z_I(__mth_i_cdpowi) ZMPLXARGS_Z_I; int k; double fr, fi, gr, gi, tr, ti; - double complex z; + #ifndef _WIN32 static const double complex c1plusi0 = 1.0 + I*0; + #else + static const _Dcomplex c1plusi0 = {1.0, 0}; + #endif fr = 1; fi = 0; @@ -46,7 +49,11 @@ ZMPLXFUNC_Z_I(__mth_i_cdpowi) gi = ti; } - z = fr + I*fi; + #ifndef _WIN32 + double complex z = fr + I*fi; + #else + _Dcomplex z = {fr, fi}; + #endif if (i < 0) { ZMPLX_CALL_ZR_Z_Z(__mth_i_cddiv,z,c1plusi0,z); } diff --git a/runtime/flang/cdpowk.c b/runtime/flang/cdpowk.c index 679f7d34eb0..220aa27c20f 100644 --- a/runtime/flang/cdpowk.c +++ b/runtime/flang/cdpowk.c @@ -22,8 +22,11 @@ ZMPLXFUNC_Z_K(__mth_i_cdpowk) ZMPLXARGS_Z_K; long long k; double fr, fi, gr, gi, tr, ti; - double complex z; + #ifndef _WIN32 static const double complex c1plusi0 = 1.0 + I*0; + #else + static const _Dcomplex c1plusi0 = {1.0, 0}; + #endif fr = 1; fi = 0; @@ -46,7 +49,12 @@ ZMPLXFUNC_Z_K(__mth_i_cdpowk) gi = ti; } - z = fr + I*fi; + + #ifndef _WIN32 + double complex z = fr + I*fi; + #else + _Dcomplex z = {fr, fi}; + #endif if (i < 0) { ZMPLX_CALL_ZR_Z_Z(__mth_i_cddiv,z,c1plusi0,z); } diff --git a/runtime/flang/chdir3f.c b/runtime/flang/chdir3f.c index 9666ba2056b..8a2d14c4d26 100644 --- a/runtime/flang/chdir3f.c +++ b/runtime/flang/chdir3f.c @@ -20,7 +20,9 @@ /* chdir3f.c - Implements LIB3F chdir subprogram. */ /* must include ent3f.h AFTER io3f.h */ +#ifndef _WIN32 #include +#endif #include "io3f.h" #include "ent3f.h" diff --git a/runtime/flang/close.c b/runtime/flang/close.c index dcdfc095c98..09a6aa9afb0 100644 --- a/runtime/flang/close.c +++ b/runtime/flang/close.c @@ -23,10 +23,12 @@ #include #include "global.h" +#ifndef _WIN32 #include +#endif #include "stdioInterf.h" -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define unlink _unlink #define access _access #endif @@ -46,7 +48,7 @@ __fortio_close(FIO_FCB *f, int flag) if (f->nonadvance) { f->nonadvance = FALSE; -#if defined(WINNT) +#if defined(_WIN32) if (__fortio_binary_mode(f->fp)) __io_fputc('\r', f->fp); #endif diff --git a/runtime/flang/cnfg.c b/runtime/flang/cnfg.c index 10c8e0a28fb..c212b87b90e 100644 --- a/runtime/flang/cnfg.c +++ b/runtime/flang/cnfg.c @@ -90,7 +90,7 @@ __fortio_scratch_name(char *filename, int unit) extern char *__io_tempnam(); char *nm; -#if defined(WINNT) +#if defined(_WIN32) if (getenv("TMP") == 0) nm = __io_tempnam("C:\\", "FTN"); else diff --git a/runtime/flang/const.c b/runtime/flang/const.c index 5f2ee37a0cd..e8f9534c16c 100644 --- a/runtime/flang/const.c +++ b/runtime/flang/const.c @@ -133,7 +133,7 @@ __INT_T ENTCOMN(TYPE, type)[] = { 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43}; -#if defined(WINNT) && !defined(WIN64) && !defined(WIN32) +#ifdef _WIN32 char * __get_fort_type_addr(void) { diff --git a/runtime/flang/cplxf.c b/runtime/flang/cplxf.c index 6188bbd389e..3120e5c724e 100644 --- a/runtime/flang/cplxf.c +++ b/runtime/flang/cplxf.c @@ -20,8 +20,10 @@ #include "stdioInterf.h" #include "fioMacros.h" #include +#ifndef _WIN32 #include #include +#endif extern double __fort_second(); extern long __fort_getoptn(char *, long); diff --git a/runtime/flang/cpowi.c b/runtime/flang/cpowi.c index f6e768b9f26..73b425ad572 100644 --- a/runtime/flang/cpowi.c +++ b/runtime/flang/cpowi.c @@ -22,8 +22,11 @@ CMPLXFUNC_C_I(__mth_i_cpowi) CMPLXARGS_C_I; int k; float fr, fi, gr, gi, tr, ti; - float complex c; + #ifndef _WIN32 static const float complex c1plusi0 = 1.0 + I*0; + #else + static const _Fcomplex c1plusi0 = {1.0, 0}; + #endif fr = 1; fi = 0; @@ -46,7 +49,11 @@ CMPLXFUNC_C_I(__mth_i_cpowi) gi = ti; } - c = fr + I*fi; + #ifndef _WIN32 + float complex c = fr + I*fi; + #else + _Fcomplex c = {fr, fi}; + #endif if (i < 0) { CMPLX_CALL_CR_C_C(__mth_i_cdiv,c,c1plusi0,c); } diff --git a/runtime/flang/cpowk.c b/runtime/flang/cpowk.c index 86e5ad8873f..0edafaa7688 100644 --- a/runtime/flang/cpowk.c +++ b/runtime/flang/cpowk.c @@ -22,8 +22,11 @@ CMPLXFUNC_C_K(__mth_i_cpowk) CMPLXARGS_C_K; long long k; float fr, fi, gr, gi, tr, ti; - float complex c; + #ifndef _WIN32 static const float complex c1plusi0 = 1.0 + I*0; + #else + static const _Fcomplex c1plusi0 = {1.0, 0}; + #endif fr = 1; fi = 0; @@ -46,7 +49,11 @@ CMPLXFUNC_C_K(__mth_i_cpowk) gi = ti; } - c = fr + I*fi; + #ifndef _WIN32 + float complex c = fr + I*fi; + #else + _Fcomplex c = {fr, fi}; + #endif if (i < 0) { CMPLX_CALL_CR_C_C(__mth_i_cdiv,c,c1plusi0,c); } diff --git a/runtime/flang/curdir.c b/runtime/flang/curdir.c index dc1398a78d9..076e8fbefcc 100644 --- a/runtime/flang/curdir.c +++ b/runtime/flang/curdir.c @@ -16,8 +16,10 @@ */ #include +#ifndef _WIN32 #include #include +#endif #include #include "stdioInterf.h" #include "fioMacros.h" @@ -26,7 +28,7 @@ #define MAXPATHLEN 1024 #endif -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define getcwd _getcwd #endif @@ -100,6 +102,7 @@ void __fort_getdir(curdir) char *curdir; void __fort_gethostname(host) char *host; { +#ifndef _WIN32 struct utsname un; char *p; int s; @@ -113,4 +116,7 @@ void __fort_gethostname(host) char *host; p = un.nodename; } strcpy(host, p); +#else + strcpy(host, "localhost"); +#endif } diff --git a/runtime/flang/datan.c b/runtime/flang/datan.c index 3e846760694..318d84120fb 100644 --- a/runtime/flang/datan.c +++ b/runtime/flang/datan.c @@ -15,7 +15,7 @@ * */ -#if !defined(WIN64) +#if !defined(_WIN32) #include "mthdecls.h" #else double atan(double d); diff --git a/runtime/flang/datan2.c b/runtime/flang/datan2.c index 5c53ce5cea1..6f7ca586764 100644 --- a/runtime/flang/datan2.c +++ b/runtime/flang/datan2.c @@ -15,7 +15,7 @@ * */ -#if !defined(WIN64) +#if !defined(_WIN32) #include "mthdecls.h" #else double atan2(double x, double y); diff --git a/runtime/flang/delfilesqq3f.c b/runtime/flang/delfilesqq3f.c index 59bb42a1331..16c34fabc4d 100644 --- a/runtime/flang/delfilesqq3f.c +++ b/runtime/flang/delfilesqq3f.c @@ -18,7 +18,7 @@ /* clang-format off */ /* delfilesqq3f.c - Implements DFLIB delfilesqq subprogram. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include @@ -27,7 +27,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); int ENT3F(DELFILESQQ, delfilesqq)(DCHAR(ffiles) DCLEN(ffiles)) { diff --git a/runtime/flang/descIntrins.c b/runtime/flang/descIntrins.c index 4409654f0c9..f825839abcc 100644 --- a/runtime/flang/descIntrins.c +++ b/runtime/flang/descIntrins.c @@ -28,10 +28,10 @@ #include #include "fioMacros.h" /* macros for entries */ -#if defined(WINNT) && !defined(WIN64) && !defined(UXOBJS) && !defined(CROBJS) +#if defined(_WIN32) && !defined(_WIN32) && !defined(UXOBJS) && !defined(CROBJS) #pragma global - x 121 0x20000 #define ENTFTN_MS(UC) WIN_EXP __attribute__((stdcall)) UC -#elif defined(WINNT) && defined(WIN64) +#elif defined(_WIN32) && defined(_WIN32) #define ENTFTN_MS I8 #endif @@ -185,7 +185,7 @@ ENTFTN(KINDEXX, kindexx_cr_nm) #endif -#if defined(WINNT) +#if defined(_WIN32) /* functions here follow the msfortran/mscall conventions */ diff --git a/runtime/flang/dlog10.c b/runtime/flang/dlog10.c index a2a5867cd18..ae58c64e708 100644 --- a/runtime/flang/dlog10.c +++ b/runtime/flang/dlog10.c @@ -15,7 +15,7 @@ * */ -#if !defined(WIN64) +#if !defined(_WIN32) #include "mthdecls.h" #else double log10(double d); diff --git a/runtime/flang/dmod.c b/runtime/flang/dmod.c index 4e917c9ed7a..be74ded609d 100644 --- a/runtime/flang/dmod.c +++ b/runtime/flang/dmod.c @@ -17,7 +17,7 @@ #include "mthdecls.h" -#if defined(WIN64) +#if defined(_WIN32) double __fmth_i_dmod(double f, double g); #endif @@ -25,7 +25,7 @@ double __mth_i_dmod(double f, double g) { /* Need to do this way until a bug in the Win64 fmod routine is fixed */ -#if defined(WIN64) +#if defined(_WIN32) return __fmth_i_dmod(f, g); #else return fmod(f, g); diff --git a/runtime/flang/drandm3f.c b/runtime/flang/drandm3f.c index dadc1d49605..dcb83ede989 100644 --- a/runtime/flang/drandm3f.c +++ b/runtime/flang/drandm3f.c @@ -22,7 +22,7 @@ #include "ent3f.h" /* drand48, srand48 are not currently available on win64 */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include diff --git a/runtime/flang/dtime3f.c b/runtime/flang/dtime3f.c index ec9589e54cf..b1433772cea 100644 --- a/runtime/flang/dtime3f.c +++ b/runtime/flang/dtime3f.c @@ -24,15 +24,18 @@ #include "ent3f.h" #define _LIBC_LIMITS_H_ +#ifndef _WIN32 #include -#include #include +#endif +#include #include #ifndef CLK_TCK #define CLK_TCK sysconf(_SC_CLK_TCK) #endif +#ifndef _WIN32 static clock_t accum_user = 0, accum_sys = 0; float ENT3F(DTIME, dtime)(float *tarray) @@ -47,4 +50,33 @@ float ENT3F(DTIME, dtime)(float *tarray) accum_sys = b.tms_stime; return (tarray[0] + tarray[1]); } +#else +#include +static FILETIME accum_user; +static FILETIME accum_sys; + +float convert_filetime( const FILETIME *ac_FileTime ) +{ + ULARGE_INTEGER lv_Large ; + + lv_Large.LowPart = ac_FileTime->dwLowDateTime ; + lv_Large.HighPart = ac_FileTime->dwHighDateTime ; + + return (float)lv_Large.QuadPart ; +} + +float ENT3F(DTIME, dtime)(float *tarray) +{ + + FILETIME time_create; + FILETIME time_exit; + + GetProcessTimes( GetCurrentProcess(), + &time_create, &time_exit, &accum_sys, &accum_user ); + + tarray[0] = ((float)(convert_filetime(&accum_user))); + tarray[1] = ((float)(convert_filetime(&accum_sys))); + return (tarray[0] + tarray[1]); +} +#endif diff --git a/runtime/flang/entry.c b/runtime/flang/entry.c index 3ce370bc1d0..42e50754c9f 100644 --- a/runtime/flang/entry.c +++ b/runtime/flang/entry.c @@ -24,16 +24,16 @@ #include "stdioInterf.h" #include "fioMacros.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) WIN_IMP __INT_T LINENO[]; -#elif defined(C90) || defined(WINNT) +#elif defined(C90) || defined(_WIN32) __INT_T LINENO[1]; char *__get_fort_lineno_addr(void); #else extern __INT_T LINENO[]; #endif -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define write _write #endif diff --git a/runtime/flang/etime3f.c b/runtime/flang/etime3f.c index 6866cc2a9b1..407ebdd0e91 100644 --- a/runtime/flang/etime3f.c +++ b/runtime/flang/etime3f.c @@ -25,16 +25,19 @@ /* Not implemented for WINNT */ +#ifndef _WIN32 #include +#include +#endif #define _LIBC_LIMITS_H_ #include -#include #include #ifndef CLK_TCK #define CLK_TCK sysconf(_SC_CLK_TCK) #endif +#ifndef _WIN32 float ENT3F(ETIME, etime)(float *tarray) { struct tms b; @@ -46,3 +49,31 @@ float ENT3F(ETIME, etime)(float *tarray) return (tarray[0] + tarray[1]); } +#else +#include + +float convert_filetime( const FILETIME *ac_FileTime ) +{ + ULARGE_INTEGER lv_Large ; + + lv_Large.LowPart = ac_FileTime->dwLowDateTime ; + lv_Large.HighPart = ac_FileTime->dwHighDateTime ; + + return (float)lv_Large.QuadPart ; +} + +float ENT3F(DTIME, dtime)(float *tarray) +{ + FILETIME accum_user; + FILETIME accum_sys; + FILETIME time_create; + FILETIME time_exit; + + GetProcessTimes( GetCurrentProcess(), + &time_create, &time_exit, &accum_sys, &accum_user ); + + tarray[0] = ((float)(convert_filetime(&accum_user))); + tarray[1] = ((float)(convert_filetime(&accum_sys))); + return (tarray[0] + tarray[1]); +} +#endif diff --git a/runtime/flang/fdate3f.c b/runtime/flang/fdate3f.c index c5fed2deb53..c94623b61df 100644 --- a/runtime/flang/fdate3f.c +++ b/runtime/flang/fdate3f.c @@ -24,7 +24,7 @@ #include #include "utils3f.h" -#if !defined(WIN32) && !defined(WIN64) +#if !defined(_WIN32) WIN_MSVCRT_IMP char *WIN_CDECL ctime(const time_t *); #endif diff --git a/runtime/flang/findfileqq3f.c b/runtime/flang/findfileqq3f.c index 7aac6c2023d..1b96a166346 100644 --- a/runtime/flang/findfileqq3f.c +++ b/runtime/flang/findfileqq3f.c @@ -26,7 +26,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); int ENT3F(FINDFILEQQ, findfileqq)(DCHAR(fname), DCHAR(fvarname), diff --git a/runtime/flang/fmtconv.c b/runtime/flang/fmtconv.c index 08f7ab6616e..dbe8ddbd7a9 100644 --- a/runtime/flang/fmtconv.c +++ b/runtime/flang/fmtconv.c @@ -40,7 +40,7 @@ static int dbgflag; #define DBGBIT(v) (LOCAL_DEBUG && (dbgflag & v)) static char *conv_int(__BIGINT_T, int *, int *); -static char *conv_int8(INT64, int *, int *); +static char *conv_int8(FLANG_INT64, int *, int *); static void put_buf(int, char *, int, int); static void conv_e(int, int, int, bool); @@ -96,7 +96,7 @@ __fortio_default_convert(char *item, int type, { int width; char *p; - INT64 i8val; + FLANG_INT64 i8val; switch (type) { default: @@ -113,7 +113,7 @@ __fortio_default_convert(char *item, int type, break; case __INT8: width = 24; - (void) __fortio_fmt_i8(*(INT64 *)(item), width, 1, plus_flag); + (void) __fortio_fmt_i8(*(FLANG_INT64 *)(item), width, 1, plus_flag); break; case __WORD4: width = 8; @@ -237,8 +237,8 @@ __fortio_default_convert(char *item, int type, break; case __LOG8: width = 2; - i8val[0] = PP_LOG4(item); - i8val[1] = PP_LOG4(item + 4); + I64_LSH(i8val) = PP_LOG4(item); + I64_MSH(i8val) = PP_LOG4(item + 4); if (I64_LSH(i8val) & GET_FIO_CNFG_TRUE_MASK) put_buf(width, "T", 1, 0); else @@ -341,7 +341,7 @@ conv_int(__BIGINT_T val, int *lenp, int *negp) } char * -__fortio_fmt_i8(INT64 val, +__fortio_fmt_i8(FLANG_INT64 val, int width, int mn, /* minimum # of digits (Iw.m) */ bool plus_flag) @@ -366,7 +366,7 @@ __fortio_fmt_i8(INT64 val, put_buf(width, p, len, neg); } else { /* Iw.0 gen's blanks if value is 0 */ - if (mn == 0 && val[0] == 0 && val[1] == 0) + if (mn == 0 && I64_LSH(val) == 0 && I64_MSH(val) == 0) neg = 0; put_buf(width, p, len, neg); if (mn > len) { @@ -384,18 +384,18 @@ __fortio_fmt_i8(INT64 val, } static char * -conv_int8(INT64 val, int *lenp, int *negp) +conv_int8(FLANG_INT64 val, int *lenp, int *negp) { #define MAX_CONV_INT8 32 static char tmp[MAX_CONV_INT8]; char *p; int len; - INT64 value; + FLANG_INT64 value; *negp = 0; - value[0] = val[0]; - value[1] = val[1]; + I64_LSH(value) = I64_LSH(val); + I64_MSH(value) = I64_MSH(val); if (__ftn_32in64_) { if (I64_LSH(value) & 0x80000000) I64_MSH(value) = -1; diff --git a/runtime/flang/fmtgetnum.c b/runtime/flang/fmtgetnum.c index 086f2724c02..7eb0a67c138 100644 --- a/runtime/flang/fmtgetnum.c +++ b/runtime/flang/fmtgetnum.c @@ -70,7 +70,7 @@ __fortio_getnum( union { __BIGINT_T i; __BIGREAL_T d; - INT64 i8v; + FLANG_INT64 i8v; } * val; /* value of token to return */ if (dc_flag == TRUE) diff --git a/runtime/flang/fmtread.c b/runtime/flang/fmtread.c index 7ea621274ef..a6fd82419a0 100644 --- a/runtime/flang/fmtread.c +++ b/runtime/flang/fmtread.c @@ -112,7 +112,7 @@ static int fr_readnum(int, char *, int); static int fr_init(__INT_T *, __INT_T *, __INT_T *, __INT_T *, __INT_T *, __INT8_T *, char *, int); -static int fr_assign(char *, int, __BIGINT_T, INT64, __BIGREAL_T); +static int fr_assign(char *, int, __BIGINT_T, FLANG_INT64, __BIGREAL_T); static int fr_OZreadnum(int, char *, int, int); static int fr_Breadnum(char *, int, int); static __BIGREAL_T fr_getreal(char *, int, int, int *); @@ -1637,7 +1637,7 @@ fr_readnum(int code, char *item, int type) __BIGINT_T ival; __BIGREAL_T dval; #undef IS_INT - INT64 i8val; /* always declare because of fr_assign() */ + FLANG_INT64 i8val; /* always declare because of fr_assign() */ #define IS_INT(t) (t == __INT || t == __INT8) int ty; int w, d, e, c; @@ -1812,8 +1812,8 @@ fr_readnum(int code, char *item, int type) return __fortio_error(FIO_EERR_DATA_CONVERSION); } if (ty == __INT8) { - i8val[1] = 0; - i8val[0] = ival; + I64_MSH(i8val) = 0; + I64_LSH(i8val) = ival; } break; @@ -1876,9 +1876,11 @@ fr_readnum(int code, char *item, int type) idx++, w--; if (comma_seen) w -= 1; - if (w == 0) - ival = i8val[0] = i8val[1] = 0; - else { + if (w == 0) { + I64_LSH(i8val) = 0; + I64_MSH(i8val) = 0; + ival = 0; + } else { c = g->rec_buff[idx]; e = FALSE; /* sign flag */ if (ty == __INT8) { @@ -1892,7 +1894,8 @@ fr_readnum(int code, char *item, int type) */ int tmp_w = w; int cpos = idx; /* 'last' character copied */ - i8val[0] = i8val[1] = 0; + I64_MSH(i8val) = 0; + I64_LSH(i8val) = 0; tmp_idx = idx; while (--tmp_w > 0) { ++tmp_idx; @@ -2057,7 +2060,7 @@ fr_readnum(int code, char *item, int type) /* ------------------------------------------------------------------ */ static int -fr_assign(char *item, int type, __BIGINT_T ival, INT64 i8val, __BIGREAL_T dval) +fr_assign(char *item, int type, __BIGINT_T ival, FLANG_INT64 i8val, __BIGREAL_T dval) { switch (type) { case __INT1: @@ -2103,14 +2106,14 @@ fr_assign(char *item, int type, __BIGINT_T ival, INT64 i8val, __BIGREAL_T dval) case __LOG8: if (__ftn_32in64_) I64_MSH(i8val) = 0; - ((__INT4_T *)item)[0] = i8val[0]; - ((__INT4_T *)item)[1] = i8val[1]; + ((__INT4_T *)item)[0] = I64_LSH(i8val); + ((__INT4_T *)item)[1] = I64_MSH(i8val); break; case __INT8: if (__ftn_32in64_) I64_MSH(i8val) = 0; - ((__INT4_T *)item)[0] = i8val[0]; - ((__INT4_T *)item)[1] = i8val[1]; + ((__INT4_T *)item)[0] = I64_LSH(i8val); + ((__INT4_T *)item)[1] = I64_MSH(i8val); break; default: diff --git a/runtime/flang/fmtwrite.c b/runtime/flang/fmtwrite.c index 6d48aa1d309..ad3c3cee1f3 100644 --- a/runtime/flang/fmtwrite.c +++ b/runtime/flang/fmtwrite.c @@ -1578,7 +1578,7 @@ fw_writenum(int code, char *item, int type) __BIGINT_T ival; __BIGREAL_T dval; #undef IS_INT - INT64 i8val; + FLANG_INT64 i8val; #define IS_INT(t) (t == __BIGINT || t == __INT8) int ty; int w, m, d, e; @@ -1592,7 +1592,7 @@ fw_writenum(int code, char *item, int type) __INT4_T i4; __REAL4_T r4; __REAL8_T r8; - INT64 i8v; + FLANG_INT64 i8v; __INT8_T i8; __BIGREAL_T d; __REAL16_T r16; @@ -1635,15 +1635,15 @@ fw_writenum(int code, char *item, int type) is_logical = TRUE; break; case __LOG8: - i8val[0] = ((__INT4_T *)item)[0]; - i8val[1] = ((__INT4_T *)item)[1]; + I64_LSH(i8val) = ((__INT4_T *)item)[0]; + I64_MSH(i8val) = ((__INT4_T *)item)[1]; ty = __INT8; w = 24; is_logical = TRUE; break; case __INT8: - i8val[0] = ((__INT4_T *)item)[0]; - i8val[1] = ((__INT4_T *)item)[1]; + I64_LSH(i8val) = ((__INT4_T *)item)[0]; + I64_MSH(i8val) = ((__INT4_T *)item)[1]; ty = __INT8; w = 24; break; @@ -1753,8 +1753,8 @@ fw_writenum(int code, char *item, int type) case __REAL8: case __REAL16: crc.r8 = dval; - i8val[0] = crc.i8v[0]; - i8val[1] = crc.i8v[1]; + I64_LSH(i8val) = I64_LSH(crc.i8v); + I64_MSH(i8val) = I64_MSH(crc.i8v); ty = __INT8; w = 24; break; @@ -1780,8 +1780,8 @@ fw_writenum(int code, char *item, int type) case __REAL8: case __REAL16: crc.r8 = dval; - i8val[0] = crc.i8v[0]; - i8val[1] = crc.i8v[1]; + I64_LSH(i8val) = I64_LSH(crc.i8v); + I64_MSH(i8val) = I64_MSH(crc.i8v); ty = __INT8; break; } @@ -1839,8 +1839,8 @@ fw_writenum(int code, char *item, int type) case __REAL8: case __REAL16: crc.r8 = dval; - i8val[0] = crc.i8v[0]; - i8val[1] = crc.i8v[1]; + I64_LSH(i8val) = I64_LSH(crc.i8v); + I64_MSH(i8val) = I64_MSH(crc.i8v); ty = __INT8; break; } @@ -1866,8 +1866,8 @@ fw_writenum(int code, char *item, int type) case __INT8: if (__fortio_check_format()) goto fmt_mismatch; - crc.i8v[0] = i8val[0]; - crc.i8v[1] = i8val[1]; + I64_LSH(i8val) = I64_LSH(crc.i8v); + I64_MSH(i8val) = I64_MSH(crc.i8v); dval = crc.r8; e = 2; ty = __REAL8; @@ -1908,8 +1908,8 @@ fw_writenum(int code, char *item, int type) case __INT8: if (__fortio_check_format()) goto fmt_mismatch; - crc.i8v[0] = i8val[0]; - crc.i8v[1] = i8val[1]; + I64_LSH(crc.i8v) = I64_LSH(i8val); + I64_MSH(crc.i8v) = I64_MSH(i8val); dval = crc.r8; w = REAL8_W; d = REAL8_D; @@ -1947,8 +1947,8 @@ fw_writenum(int code, char *item, int type) case __INT8: if (__fortio_check_format()) goto fmt_mismatch; - crc.i8v[0] = i8val[0]; - crc.i8v[1] = i8val[1]; + I64_LSH(crc.i8v) = I64_LSH(i8val); + I64_MSH(crc.i8v) = I64_MSH(i8val); dval = crc.r8; if (!e_flag) e = 2; @@ -1979,8 +1979,8 @@ fw_writenum(int code, char *item, int type) case __INT8: if (__fortio_check_format()) goto fmt_mismatch; - crc.i8v[0] = i8val[0]; - crc.i8v[1] = i8val[1]; + I64_LSH(crc.i8v) = I64_LSH(i8val); + I64_MSH(crc.i8v) = I64_MSH(i8val); dval = crc.r8; w = REAL8_W; d = REAL8_D; @@ -2009,8 +2009,8 @@ fw_writenum(int code, char *item, int type) case __INT8: if (__fortio_check_format()) goto fmt_mismatch; - crc.i8v[0] = i8val[0]; - crc.i8v[1] = i8val[1]; + I64_LSH(crc.i8v) = I64_LSH(i8val); + I64_MSH(crc.i8v) = I64_MSH(i8val); dval = crc.r8; ty = __REAL8; break; @@ -2031,8 +2031,8 @@ fw_writenum(int code, char *item, int type) case __INT8: if (__fortio_check_format()) goto fmt_mismatch; - crc.i8v[0] = i8val[0]; - crc.i8v[1] = i8val[1]; + I64_LSH(crc.i8v) = I64_LSH(i8val); + I64_MSH(crc.i8v) = I64_MSH(i8val); dval = crc.r8; w = REAL8_W; d = REAL8_D; @@ -2465,7 +2465,7 @@ fw_write_record(void) f->nonadvance = FALSE; /* do it now */ if (!(g->suppress_crlf)) { /* append carriage return */ -#if defined(WINNT) +#if defined(_WIN32) if (__fortio_binary_mode(f->fp)) __io_fputc('\r', f->fp); #endif diff --git a/runtime/flang/fork3f.c b/runtime/flang/fork3f.c index f9760afe9c2..87c28fd8c89 100644 --- a/runtime/flang/fork3f.c +++ b/runtime/flang/fork3f.c @@ -19,7 +19,7 @@ /* fork3f.c - Implements LIB3F fork subprogram. */ -#ifndef WINNT +#ifndef _WIN32 /* must include ent3f.h AFTER io3f.h */ #include "io3f.h" diff --git a/runtime/flang/format.h b/runtime/flang/format.h index c98cc8ff51d..9bcddc1cfb6 100644 --- a/runtime/flang/format.h +++ b/runtime/flang/format.h @@ -55,7 +55,7 @@ char *__fortio_default_convert(char *, int, int, int *, bool, bool, int); char *__fortio_fmt_i(__BIGINT_T, int, int, bool); /** \brief Generate a formated INTEGER*8 string */ -char *__fortio_fmt_i8(INT64, int, int, bool); +char *__fortio_fmt_i8(FLANG_INT64, int, int, bool); /** \brief Generate a string for a 'D' format characer */ char *__fortio_fmt_d(__BIGREAL_T, int, int, int, int, bool, int); @@ -139,13 +139,13 @@ int __fort_atoxi32(char *s, INT *i, int n, int base); * \param conversion radix: 2, 8, 10, 16 */ -void __fort_i64toax(INT64 from, char *to, int count, int sign, int radix); +void __fort_i64toax(FLANG_INT64 from, char *to, int count, int sign, int radix); /** \brief char string to 64-bit integer. * * \param Input string containing number to be converted * (string is NOT null terminated.) - * \param UINT64 output value + * \param FLANG_UINT64 output value * \param Number of chars from str to convert * \param Radix of conversion -- 2, 8, 10, 16. If base is 16, then the * digits a-f @@ -155,4 +155,4 @@ void __fort_i64toax(INT64 from, char *to, int count, int sign, int radix); * -2 overflow occurred on conversion * 0 No error -- *ir contains the converted number. */ -int __fort_atoxi64(char *s, INT64 ir, int n, int radix); +int __fort_atoxi64(char *s, FLANG_INT64 ir, int n, int radix); diff --git a/runtime/flang/fpcvt.c b/runtime/flang/fpcvt.c index a0b6bada9e4..d1bce56a105 100644 --- a/runtime/flang/fpcvt.c +++ b/runtime/flang/fpcvt.c @@ -17,7 +17,7 @@ #include #include -#if !defined(WIN64) +#if !defined(_WIN32) #include #endif #include "fioMacros.h" @@ -733,7 +733,7 @@ __fortio_strtod(char *s, char **p) * (0 is before first digit). *sign is sign. */ -#if defined(WIN64) +#if defined(_WIN32) #define FE_TONEAREST 0 #define FE_DOWNWARD 1024 #define FE_UPWARD 2048 diff --git a/runtime/flang/fstat3f.c b/runtime/flang/fstat3f.c index 682d113a30e..a356ba3ad5b 100644 --- a/runtime/flang/fstat3f.c +++ b/runtime/flang/fstat3f.c @@ -66,7 +66,7 @@ int ENT3F(FSTAT, fstat)(int *lu, int *statb) statb[8] = b.st_atime; statb[9] = b.st_mtime; statb[10] = b.st_ctime; -#if !defined(WINNT) +#if !defined(_WIN32) statb[11] = b.st_blksize; statb[12] = b.st_blocks; #else diff --git a/runtime/flang/fstat643f.c b/runtime/flang/fstat643f.c index 43a9dd9aefc..28ccc04a587 100644 --- a/runtime/flang/fstat643f.c +++ b/runtime/flang/fstat643f.c @@ -27,7 +27,7 @@ int ENT3F(FSTAT64, fstat64)(int *lu, long long *statb) { -#if defined(TARGET_WIN) || defined(WIN32) || defined(WIN64) +#if defined(_WIN32) /* * The __int64_t members in the _stat64 are 8-byte aligned, thus the * st_size member is at offset 24. On WIN32, 64-bit ints are 4-byte @@ -136,6 +136,7 @@ int ENT3F(FSTAT64, fstat64)(int *lu, long long *statb) statb[10] = b.st_ctime; statb[11] = b.st_blksize; statb[12] = b.st_blocks; + return i; #endif } diff --git a/runtime/flang/ftni64.c b/runtime/flang/ftni64.c index b4748d65729..7bdf08f76ad 100644 --- a/runtime/flang/ftni64.c +++ b/runtime/flang/ftni64.c @@ -40,8 +40,8 @@ ftn_i_kishft(_ULONGLONG_T op, int count) __I8RET_T ftn_i_xori64(int op1, int op2, int op3, int op4) { - INT64 u1; - INT64 u2; + FLANG_INT64 u1; + FLANG_INT64 u2; u1[0] = op2; u1[1] = op1; @@ -55,8 +55,8 @@ ftn_i_xori64(int op1, int op2, int op3, int op4) __I8RET_T ftn_i_xnori64(int op1, int op2, int op3, int op4) { - INT64 u1; - INT64 u2; + FLANG_INT64 u1; + FLANG_INT64 u2; u1[0] = op2; u1[1] = op1; @@ -70,7 +70,7 @@ ftn_i_xnori64(int op1, int op2, int op3, int op4) int ftn_i_kr2ir(int op1, int op2) { - INT64 u1; + FLANG_INT64 u1; /* result is first element of int[2] which is union u'd with dp if little endian; if big endian, result is second element. @@ -83,7 +83,7 @@ ftn_i_kr2ir(int op1, int op2) float ftn_i_kr2sp(int op1, int op2) { - INT64 u1; + FLANG_INT64 u1; int i; u1[0] = op1; diff --git a/runtime/flang/ftni64.h b/runtime/flang/ftni64.h index 467c7ca2533..e696665c3b0 100644 --- a/runtime/flang/ftni64.h +++ b/runtime/flang/ftni64.h @@ -28,8 +28,8 @@ typedef long _LONGLONG_T; typedef unsigned long _ULONGLONG_T; /* now defined if BaseTsd10.h included */ -typedef int INT64[2]; -typedef unsigned int UINT64[2]; +typedef int FLANG_INT64[2]; +typedef unsigned int FLANG_UINT64[2]; #define I64_MSH(t) t[1] #define I64_LSH(t) t[0] @@ -39,7 +39,7 @@ int __ftn_32in64_; #define VOID void typedef union { - INT64 i; + FLANG_INT64 i; double d; _LONGLONG_T lv; } INT64D; diff --git a/runtime/flang/ftni64bitsup.c b/runtime/flang/ftni64bitsup.c index 610ae53507b..ca736759833 100644 --- a/runtime/flang/ftni64bitsup.c +++ b/runtime/flang/ftni64bitsup.c @@ -39,7 +39,7 @@ ftn_i_kishftc(op, sc, int sc; /* shift count and direction */ int rc; /* # of rightmost val bits to be shifted */ { - UINT64 i8neg1, mask, field, tmp1, tmp2, val; + FLANG_UINT64 i8neg1, mask, field, tmp1, tmp2, val; int norm; /* define a remainder operation that doesn't use %; is this worth it? */ @@ -141,8 +141,8 @@ int posd; /* start position in dest field */ int tmp; int maxpos; int maxlen; - UINT64 maski8; - UINT64 i8neg1, tmpi8, u_arg; + FLANG_UINT64 maski8; + FLANG_UINT64 i8neg1, tmpi8, u_arg; /* procedure */ @@ -225,8 +225,8 @@ __I8RET_T ftn_i_kibclr(arg1, arg2, bit) int arg1, arg2; /* value to be cleared */ int bit; /* bit to clear */ { - INT64 result; - UINT64 i81, tmp; + FLANG_INT64 result; + FLANG_UINT64 i81, tmp; result[0] = result[1] = 0; i81[0] = 0; i81[1] = 1; @@ -250,8 +250,8 @@ ftn_i_kibits(arg1, arg2, bitpos, numbits) int arg1, int bitpos; /* position of bit to start from */ int numbits; /* number of bits to extract */ { - INT64 result; - UINT64 i8neg1, tmp, maski8, u_arg; + FLANG_INT64 result; + FLANG_UINT64 i8neg1, tmp, maski8, u_arg; u_arg[0] = arg2; u_arg[1] = arg1; @@ -280,8 +280,8 @@ __I8RET_T ftn_i_kibset(arg1, arg2, bit) int arg1, arg2; /* value to be set */ int bit; /* bit to set */ { - INT64 i8one, result; - UINT64 tmp; + FLANG_INT64 i8one, result; + FLANG_UINT64 tmp; result[0] = result[1] = 0; i8one[0] = 0; i8one[1] = 1; @@ -304,8 +304,8 @@ __I8RET_T ftn_i_bktest(arg1, arg2, bit) int arg1, arg2; /* value to be tested */ int bit; /* bit to test */ { - INT64 i8one, result; - UINT64 tmp; + FLANG_INT64 i8one, result; + FLANG_UINT64 tmp; result[0] = result[1] = 0; i8one[0] = 0; i8one[1] = 1; @@ -339,11 +339,11 @@ int bit; /* bit to test */ * Return value: * none. */ -static void shf64(arg, count, result) INT64 arg; +static void shf64(arg, count, result) FLANG_INT64 arg; int count; -INT64 result; +FLANG_INT64 result; { - UINT64 u_arg; /* 'copy-in' unsigned value of arg */ + FLANG_UINT64 u_arg; /* 'copy-in' unsigned value of arg */ if (count >= 64 || count <= -64) { result[0] = 0; @@ -388,11 +388,11 @@ INT64 result; * Return value: * none. */ -static void ushf64(arg, count, result) UINT64 arg; +static void ushf64(arg, count, result) FLANG_UINT64 arg; int count; -UINT64 result; +FLANG_UINT64 result; { - UINT64 u_arg; /* 'copy-in' value of arg */ + FLANG_UINT64 u_arg; /* 'copy-in' value of arg */ if (count >= 64 || count <= -64) { result[0] = 0; diff --git a/runtime/flang/fullpathqq3f.c b/runtime/flang/fullpathqq3f.c index ee2fad650cf..66b2562b358 100644 --- a/runtime/flang/fullpathqq3f.c +++ b/runtime/flang/fullpathqq3f.c @@ -25,7 +25,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); int ENT3F(FULLPATHQQ, fullpathqq)(DCHAR(fname), diff --git a/runtime/flang/gerror3f.c b/runtime/flang/gerror3f.c index a1a424dbcdf..d2dd142433e 100644 --- a/runtime/flang/gerror3f.c +++ b/runtime/flang/gerror3f.c @@ -27,7 +27,7 @@ #define Ftn_errmsg __fortio_errmsg -#if !defined(WIN64) && !defined(WIN32) +#if !defined(_WIN32) extern char *strerror(); /* SVR4 only ? */ #endif diff --git a/runtime/flang/getcwd3f.c b/runtime/flang/getcwd3f.c index 7e154ee7aad..0282e4eb521 100644 --- a/runtime/flang/getcwd3f.c +++ b/runtime/flang/getcwd3f.c @@ -25,7 +25,7 @@ #include "utils3f.h" #include "mpalloc.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #define GETCWDM _getcwd /* getcwd deprecated in Windows in VC 2005 */ #else #define GETCWDM getcwd diff --git a/runtime/flang/getdat3f.c b/runtime/flang/getdat3f.c index f15149331d3..2c1d9a9f745 100644 --- a/runtime/flang/getdat3f.c +++ b/runtime/flang/getdat3f.c @@ -19,7 +19,7 @@ /* getdat3f.c - Implements getdat subroutine. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #include "ent3f.h" diff --git a/runtime/flang/getdrivedirqq3f.c b/runtime/flang/getdrivedirqq3f.c index 80a69c0c4c5..d0ee2380b80 100644 --- a/runtime/flang/getdrivedirqq3f.c +++ b/runtime/flang/getdrivedirqq3f.c @@ -26,7 +26,7 @@ #include "utils3f.h" #include "mpalloc.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #define GETCWDM _getcwd /* getcwd deprecated in Windows in VC 2005 */ #else #define GETCWDM getcwd diff --git a/runtime/flang/getfileinfoqq3f.c b/runtime/flang/getfileinfoqq3f.c index efa610d99a5..c694ec99eb2 100644 --- a/runtime/flang/getfileinfoqq3f.c +++ b/runtime/flang/getfileinfoqq3f.c @@ -18,7 +18,7 @@ /* clang-format off */ /* getfileinfoqq3f.c - Implements DFLIB getfileinfoqq subprogram. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include @@ -27,7 +27,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); extern void __GetTimeToSecondsSince1970(ULARGE_INTEGER *fileTime, unsigned int *out); diff --git a/runtime/flang/getfileinfoqqi83f.c b/runtime/flang/getfileinfoqqi83f.c index b738aa92b34..b94c5590053 100644 --- a/runtime/flang/getfileinfoqqi83f.c +++ b/runtime/flang/getfileinfoqqi83f.c @@ -18,7 +18,7 @@ /* clang-format off */ /* getfileinfoqq3f.c - Implements DFLIB getfileinfoqq subprogram. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include @@ -31,7 +31,7 @@ #define FILE$LAST -2 #define FILE$ERROR -3 -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); extern void __GetTimeToSecondsSince1970(ULARGE_INTEGER *fileTime, unsigned int *out); diff --git a/runtime/flang/getgid3f.c b/runtime/flang/getgid3f.c index 036d6dc030c..98a6071910b 100644 --- a/runtime/flang/getgid3f.c +++ b/runtime/flang/getgid3f.c @@ -19,7 +19,7 @@ /* getgid3f.c - Implements LIB3F getgid subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include #include "ent3f.h" diff --git a/runtime/flang/getlog3f.c b/runtime/flang/getlog3f.c index a4e188a5a21..dc18f9b50db 100644 --- a/runtime/flang/getlog3f.c +++ b/runtime/flang/getlog3f.c @@ -19,7 +19,7 @@ /* getlog3f.c - Implements LIB3F getlog subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include "ent3f.h" #include "utils3f.h" diff --git a/runtime/flang/getpid3f.c b/runtime/flang/getpid3f.c index 6e7c256e3cf..c11999f6b5e 100644 --- a/runtime/flang/getpid3f.c +++ b/runtime/flang/getpid3f.c @@ -20,6 +20,7 @@ /* getpid3f.c - Implements LIB3F getpid subprogram. */ #include "ent3f.h" +#ifndef _WIN32 #include - +#endif int ENT3F(GETPID, getpid)() { return getpid(); } diff --git a/runtime/flang/gettim3f.c b/runtime/flang/gettim3f.c index d8a2b099789..57d97b0c658 100644 --- a/runtime/flang/gettim3f.c +++ b/runtime/flang/gettim3f.c @@ -19,7 +19,7 @@ /* gettim3f.c - Implements gettim subroutine. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #include "ent3f.h" diff --git a/runtime/flang/getuid3f.c b/runtime/flang/getuid3f.c index 4bbc9837e54..2bcc0694ade 100644 --- a/runtime/flang/getuid3f.c +++ b/runtime/flang/getuid3f.c @@ -19,7 +19,7 @@ /* getuid3f.c - Implements LIB3F getuid subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include "ent3f.h" #include diff --git a/runtime/flang/getvolinfo3f.c b/runtime/flang/getvolinfo3f.c index dceddd6fb6a..d1d03102065 100644 --- a/runtime/flang/getvolinfo3f.c +++ b/runtime/flang/getvolinfo3f.c @@ -28,8 +28,8 @@ typedef char *LPSTR; typedef int DWORD; -#if defined(WIN64) || defined(WIN32) -#if defined(WIN64) +#if defined(_WIN32) +#if defined(_WIN32) typedef long long LDWORD; extern int GetVolumeInformationA(); #define ENTNAM(ss) _##ss diff --git a/runtime/flang/global.h b/runtime/flang/global.h index c6706f8db64..cab3448de5b 100644 --- a/runtime/flang/global.h +++ b/runtime/flang/global.h @@ -28,12 +28,12 @@ /* declarations needed where integer*8 & logical*8 are supported and * the natural integer is integer*4 (__BIGINT is __INT4). */ -typedef int INT64[2]; -typedef unsigned int UINT64[2]; - +typedef int FLANG_INT64[2]; +typedef unsigned int FLANG_UINT64[2]; #define I64_MSH(t) t[1] #define I64_LSH(t) t[0] + extern int __ftn_32in64_; #ifndef LOCAL_DEBUG @@ -295,9 +295,9 @@ typedef struct atag { union { /* value: depends on dtype */ __BIGINT_T i; /* __BIGINT, __BIGLOG */ __BIGREAL_T d; /* __BIGREAL */ - INT64 i8; /* __INT8 */ + FLANG_INT64 i8; /* __INT8 */ __INT8_T i8v; - UINT64 ui8; /* __LOG8 */ + FLANG_UINT64 ui8; /* __LOG8 */ __INT8_UT ui8v; struct { /* __STR, __NCHAR */ int len; /* length of string */ diff --git a/runtime/flang/hand.c b/runtime/flang/hand.c index bc8b0b6d3d1..c3262fc7e98 100644 --- a/runtime/flang/hand.c +++ b/runtime/flang/hand.c @@ -15,11 +15,12 @@ * */ +#ifndef _WIN32 #include #include "stdioInterf.h" #include "fioMacros.h" -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define write _write #endif @@ -96,7 +97,7 @@ static void sighand(s) int s; lcpu = __fort_myprocnum(); __fort_psignal(lcpu, s); /* print message */ -#if !defined(WIN64) && !defined(WIN32) +#if !defined(_WIN32) sleep(1); /* wait for message to clear */ #endif __fort_abort(NULL); /* abort */ @@ -129,3 +130,5 @@ __fort_sethand() } } } + +#endif \ No newline at end of file diff --git a/runtime/flang/heapinit.c b/runtime/flang/heapinit.c index e2e7584f72b..4d52452560b 100644 --- a/runtime/flang/heapinit.c +++ b/runtime/flang/heapinit.c @@ -14,7 +14,6 @@ * limitations under the License. * */ - #include #include "stdioInterf.h" #include "fioMacros.h" @@ -43,10 +42,14 @@ int val; void (*save)(); int *pi; +#ifndef _WIN32 save = signal(SIGBUS, sighand); +#endif pi = (int *)beg; while (pi < (int *)end) { *pi++ = val; } +#ifndef _WIN32 signal(SIGBUS, save); -} +#endif +} \ No newline at end of file diff --git a/runtime/flang/hostnm3f.c b/runtime/flang/hostnm3f.c index 56db4f50c06..dc9e9d01ff7 100644 --- a/runtime/flang/hostnm3f.c +++ b/runtime/flang/hostnm3f.c @@ -19,7 +19,7 @@ /* hostnm3f.c - Implements LIB3F hostnm subprogram. */ -#ifndef WINNT +#ifndef _WIN32 /* must include ent3f.h AFTER io3f.h */ #include "io3f.h" diff --git a/runtime/flang/initpar.c b/runtime/flang/initpar.c index e22a86c43a8..325d24ff048 100644 --- a/runtime/flang/initpar.c +++ b/runtime/flang/initpar.c @@ -25,7 +25,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif #include "global.h" /* FIXME: HACK @@ -73,10 +75,10 @@ static struct { /* common blocks containing values for inlined number_of_processors() and my_processor() functions */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) WIN_IMP __INT_T ENTCOMN(NP, np)[]; WIN_IMP __INT_T ENTCOMN(ME, me)[]; -#elif defined(C90) || defined(WINNT) +#elif defined(C90) || defined(_WIN32) __INT_T ENTCOMN(NP, np)[1]; __INT_T ENTCOMN(ME, me)[1]; #else @@ -84,7 +86,7 @@ extern __INT_T ENTCOMN(NP, np)[]; extern __INT_T ENTCOMN(ME, me)[]; #endif -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define write _write #endif @@ -104,8 +106,8 @@ __fort_ncpus() return __fort_tcpus; } -#if defined(WINNT) -#if !defined(WIN64) && !defined(WIN32) +#if defined(_WIN32) +#if !defined(_WIN32) __INT_T *CORMEM; /* special argument pointer access routines */ diff --git a/runtime/flang/inquire.c b/runtime/flang/inquire.c index 111159ed16e..2c17ea56eae 100644 --- a/runtime/flang/inquire.c +++ b/runtime/flang/inquire.c @@ -26,7 +26,7 @@ #include "global.h" #include "async.h" -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define access _access #endif diff --git a/runtime/flang/kill3f.c b/runtime/flang/kill3f.c index 979c2aa3986..715764cc1a8 100644 --- a/runtime/flang/kill3f.c +++ b/runtime/flang/kill3f.c @@ -19,7 +19,7 @@ /* kill3f.c - Implements LIB3F kill subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #define POSIX 1 #include diff --git a/runtime/flang/ldread.c b/runtime/flang/ldread.c index b1c6f7afeb8..e56cf2d3db8 100644 --- a/runtime/flang/ldread.c +++ b/runtime/flang/ldread.c @@ -1628,7 +1628,7 @@ skip_record(void) } return __io_errno(); } -#if defined(WINNT) +#if defined(_WIN32) if (ch == '\r') { ch = __io_fgetc(fcb->fp); if (ch == '\n') diff --git a/runtime/flang/ldwrite.c b/runtime/flang/ldwrite.c index ff7fece60fc..f369ceb4896 100644 --- a/runtime/flang/ldwrite.c +++ b/runtime/flang/ldwrite.c @@ -793,7 +793,7 @@ write_record(void) return __io_errno(); } } else { /* sequential write: append carriage return */ -#if defined(WINNT) +#if defined(_WIN32) if (__fortio_binary_mode(fcb->fp)) if (FWRITE("\r", 1, 1, fcb->fp) != 1) return __io_errno(); diff --git a/runtime/flang/link3f.c b/runtime/flang/link3f.c index 955fa3714d3..e19c3ef77e6 100644 --- a/runtime/flang/link3f.c +++ b/runtime/flang/link3f.c @@ -19,7 +19,7 @@ /* link3f.c - Implements LIB3F link subprogram. */ -#ifndef WINNT +#ifndef _WIN32 /* must include ent3f.h AFTER io3f.h */ #include "io3f.h" diff --git a/runtime/flang/lstat3f.c b/runtime/flang/lstat3f.c index faac308c68c..2a3ddfe7d86 100644 --- a/runtime/flang/lstat3f.c +++ b/runtime/flang/lstat3f.c @@ -19,7 +19,7 @@ /* lstat3f.c - Implements LIB3F lstat subprogram. */ -#ifndef WINNT +#ifndef _WIN32 /* must include ent3f.h AFTER io3f.h */ #include diff --git a/runtime/flang/lstat643f.c b/runtime/flang/lstat643f.c index c6ff3090f5e..d8c037e0de5 100644 --- a/runtime/flang/lstat643f.c +++ b/runtime/flang/lstat643f.c @@ -19,7 +19,7 @@ /* lstat3f.c - Implements 64-bit LIB3F lstat subprogram. */ -#ifndef WINNT +#ifndef _WIN32 /* must include ent3f.h AFTER io3f.h */ #include diff --git a/runtime/flang/map.c b/runtime/flang/map.c index 291e107556a..622eacdf2e5 100644 --- a/runtime/flang/map.c +++ b/runtime/flang/map.c @@ -19,7 +19,9 @@ #include "fioMacros.h" #include #include +#ifndef _WIN32 #include +#endif extern char *__fort_getopt(); diff --git a/runtime/flang/mclock3f.c b/runtime/flang/mclock3f.c index 8752f726d72..889113174dc 100644 --- a/runtime/flang/mclock3f.c +++ b/runtime/flang/mclock3f.c @@ -22,7 +22,7 @@ /* assumes the Unix times system call */ -#if defined(WINNT) +#if defined(_WIN32) #include diff --git a/runtime/flang/misc.c b/runtime/flang/misc.c index 8d70c5d839b..cf2cdd9c6e8 100644 --- a/runtime/flang/misc.c +++ b/runtime/flang/misc.c @@ -15,7 +15,7 @@ * */ -#if !defined(PARAMID) && !defined(WINNT) +#if !defined(PARAMID) && !defined(_WIN32) #include #include #include diff --git a/runtime/flang/miscsup_com.c b/runtime/flang/miscsup_com.c index 451b7fd1517..053c5917db0 100644 --- a/runtime/flang/miscsup_com.c +++ b/runtime/flang/miscsup_com.c @@ -25,8 +25,12 @@ #include #include +#ifndef _WIN32 #include #include +#else +#include +#endif #include "stdioInterf.h" #include "fioMacros.h" #include "llcrit.h" diff --git a/runtime/flang/mmcmplx16.c b/runtime/flang/mmcmplx16.c index 02abe4fc00a..8874727489c 100644 --- a/runtime/flang/mmcmplx16.c +++ b/runtime/flang/mmcmplx16.c @@ -25,13 +25,23 @@ #define SMALL_ROWSB 10 #define SMALL_COLSB 10 +#ifndef _WIN32 +#define FLANG_DCOMPLEX double complex +#define FLANG_IS_ZERO(x) x == 0.0 +#else +#define FLANG_DCOMPLEX _Dcomplex +#define FLANG_IS_ZERO(x) (real(x) == 0.0 && imag(x) == 0.0) +#endif + void ENTF90(MMUL_CMPLX16, mmul_cmplx16)(int ta, int tb, __POINT_T mra, __POINT_T ncb, - __POINT_T kab, double complex *alpha, - double complex a[], __POINT_T lda, double complex b[], - __POINT_T ldb, double complex *beta, - double complex c[], __POINT_T ldc) + __POINT_T kab, FLANG_DCOMPLEX *alpha, + FLANG_DCOMPLEX a[], __POINT_T lda, FLANG_DCOMPLEX b[], + __POINT_T ldb, FLANG_DCOMPLEX *beta, + FLANG_DCOMPLEX c[], __POINT_T ldc) { + +#ifndef _WIN32 /* * Notes on parameters * ta, tb = 0 -> no transpose of matrix @@ -66,13 +76,13 @@ void ENTF90(MMUL_CMPLX16, int bufr, bufc, loc, lor; int small_size = SMALL_ROWSA * SMALL_ROWSB * SMALL_COLSB; int tindex = 0; - double complex buffera[SMALL_ROWSA * SMALL_ROWSB]; - double complex bufferb[SMALL_COLSB * SMALL_ROWSB]; - double complex temp; + FLANG_DCOMPLEX buffera[SMALL_ROWSA * SMALL_ROWSB]; + FLANG_DCOMPLEX bufferb[SMALL_COLSB * SMALL_ROWSB]; + FLANG_DCOMPLEX temp; void ftn_mvmul_cmplx16_(), ftn_vmmul_cmplx16_(); void ftn_mnaxnb_cmplx16_(), ftn_mnaxtb_cmplx16_(); void ftn_mtaxnb_cmplx16_(), ftn_mtaxtb_cmplx16_(); - double complex calpha, cbeta; + FLANG_DCOMPLEX calpha, cbeta; /* * Small matrix multiply variables */ @@ -89,13 +99,19 @@ void ENTF90(MMUL_CMPLX16, colsa = kab; rowsb = kab; colsb = ncb; - if (calpha == 0.0) { - if (cbeta == 0.0) { + if (FLANG_IS_ZERO(calpha)) { + if (FLANG_IS_ZERO(cbeta)) { cndx = 0; indx_strt = ldc; for (j = 0; j < ncb; j++) { - for (i = 0; i < mra; i++) + for (i = 0; i < mra; i++) { + #ifndef _WIN32 c[cndx + i] = 0.0; + #else + real(c[cndx + i]) = 0.0; + imag(c[cndx + i]) = 0.0; + #endif + } cndx = indx_strt; indx_strt += ldc; } @@ -555,5 +571,5 @@ void ENTF90(MMUL_CMPLX16, beta, c, &ldc); } } - +#endif } diff --git a/runtime/flang/mmcmplx8.c b/runtime/flang/mmcmplx8.c index 601210d9c39..1968d17b5e8 100644 --- a/runtime/flang/mmcmplx8.c +++ b/runtime/flang/mmcmplx8.c @@ -25,12 +25,19 @@ #define SMALL_ROWSB 10 #define SMALL_COLSB 10 +#ifndef _WIN32 +#define FLANG_FCOMPLEX double complex +#else +#define FLANG_FCOMPLEX _Dcomplex +#endif + void ENTF90(MMUL_CMPLX8, mmul_cmplx8)(int ta, int tb, __POINT_T mra, __POINT_T ncb, - __POINT_T kab, float complex *alpha, float complex a[], - __POINT_T lda, float complex b[], __POINT_T ldb, - float complex *beta, float complex c[], __POINT_T ldc) + __POINT_T kab, FLANG_FCOMPLEX *alpha, FLANG_FCOMPLEX a[], + __POINT_T lda, FLANG_FCOMPLEX b[], __POINT_T ldb, + FLANG_FCOMPLEX *beta, FLANG_FCOMPLEX c[], __POINT_T ldc) { + #ifndef _WIN32 /* * Notes on parameters * ta, tb = 0 -> no transpose of matrix @@ -65,13 +72,13 @@ void ENTF90(MMUL_CMPLX8, int bufr, bufc, loc, lor; int small_size = SMALL_ROWSA * SMALL_ROWSB * SMALL_COLSB; int tindex = 0; - float complex buffera[SMALL_ROWSA * SMALL_ROWSB]; - float complex bufferb[SMALL_COLSB * SMALL_ROWSB]; - float complex temp; + FLANG_FCOMPLEX buffera[SMALL_ROWSA * SMALL_ROWSB]; + FLANG_FCOMPLEX bufferb[SMALL_COLSB * SMALL_ROWSB]; + FLANG_FCOMPLEX temp; void ftn_mvmul_cmplx8_(), ftn_vmmul_cmplx8_(); void ftn_mnaxnb_cmplx8_(), ftn_mnaxtb_cmplx8_(); void ftn_mtaxnb_cmplx8_(), ftn_mtaxtb_cmplx8_(); - float complex calpha, cbeta; + FLANG_FCOMPLEX calpha, cbeta; /* * Small matrix multiply variables */ @@ -554,6 +561,6 @@ void ENTF90(MMUL_CMPLX8, beta, c, &ldc); } } - +#endif } diff --git a/runtime/flang/nmlwrite.c b/runtime/flang/nmlwrite.c index ba126d01d80..65f7311f8b5 100644 --- a/runtime/flang/nmlwrite.c +++ b/runtime/flang/nmlwrite.c @@ -279,7 +279,7 @@ emit_eol(void) int ret_err; if (!internal_file) { -#if defined(WINNT) +#if defined(_WIN32) if (__fortio_binary_mode(f->fp)) { ret_err = write_char('\r'); if (ret_err) diff --git a/runtime/flang/open.c b/runtime/flang/open.c index 98860b5377f..f9824d87e22 100644 --- a/runtime/flang/open.c +++ b/runtime/flang/open.c @@ -30,7 +30,7 @@ #include "async.h" #include -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define access _access #endif @@ -103,7 +103,7 @@ __fortio_open(int unit, int action_flag, int status_flag, int dispose_flag, for (i = 0; i < namelen; i++) filename[i] = name[i]; filename[namelen] = '\0'; -#if defined(WINNT) +#if defined(_WIN32) if (filename[0] == '/' && filename[1] == '/' && filename[3] == '/') { /* convert posix format to win32 format */ filename[0] = filename[2]; /* drive letter */ diff --git a/runtime/flang/packtimeqq3f.c b/runtime/flang/packtimeqq3f.c index 499cf9a779b..05d4edd5bd6 100644 --- a/runtime/flang/packtimeqq3f.c +++ b/runtime/flang/packtimeqq3f.c @@ -18,7 +18,7 @@ /* clang-format off */ /* packtimeqq3f.c - Implements DFLIB packtimeqq subprogram. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include @@ -27,7 +27,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); extern void __GetTimeToSecondsSince1970(ULARGE_INTEGER *fileTime, unsigned int *out); diff --git a/runtime/flang/perror3f.c b/runtime/flang/perror3f.c index 67b93e493e3..cc72266583f 100644 --- a/runtime/flang/perror3f.c +++ b/runtime/flang/perror3f.c @@ -23,7 +23,7 @@ #include "io3f.h" #include "ent3f.h" -#if !defined(WIN64) && !defined(WIN32) +#if !defined(_WIN32) extern char *strerror(); /* SVR4 only ? */ #endif extern FILE *__getfile3f(); diff --git a/runtime/flang/rand3f.c b/runtime/flang/rand3f.c index 94c4341aca6..533bc1bc8d2 100644 --- a/runtime/flang/rand3f.c +++ b/runtime/flang/rand3f.c @@ -22,7 +22,7 @@ #include "ent3f.h" /* drand48 is not currently available on win64 */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include diff --git a/runtime/flang/random3f.c b/runtime/flang/random3f.c index 2c77283b588..c722bdf572d 100644 --- a/runtime/flang/random3f.c +++ b/runtime/flang/random3f.c @@ -22,7 +22,7 @@ #include "ent3f.h" /* drand48, srand48 are not currently available on win64 */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include diff --git a/runtime/flang/rewind.c b/runtime/flang/rewind.c index 2629532c95e..ef2d0435295 100644 --- a/runtime/flang/rewind.c +++ b/runtime/flang/rewind.c @@ -54,7 +54,7 @@ _f90io_rewind(__INT_T *unit, __INT_T *bitv, __INT_T *iostat) if (f->nonadvance) { f->nonadvance = FALSE; -#if defined(WINNT) +#if defined(_WIN32) if (__fortio_binary_mode(f->fp)) __io_fputc('\r', f->fp); #endif diff --git a/runtime/flang/setfileaccessqq3f.c b/runtime/flang/setfileaccessqq3f.c index 9f508030df3..a9f53884989 100644 --- a/runtime/flang/setfileaccessqq3f.c +++ b/runtime/flang/setfileaccessqq3f.c @@ -18,7 +18,7 @@ /* clang-format off */ /* setfileaccessqq3f.c - Implements DFLIB setfileaccessqq subprogram. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include @@ -32,7 +32,7 @@ #define FILE$ERROR -3 #define FILE$CURTIME -1 -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); int ENT3F(SETFILEACCESSQQ, setfileaccessqq)(DCHAR(ffile), diff --git a/runtime/flang/setfiletimeqq3f.c b/runtime/flang/setfiletimeqq3f.c index f74e298e51d..b50c5b0d5fe 100644 --- a/runtime/flang/setfiletimeqq3f.c +++ b/runtime/flang/setfiletimeqq3f.c @@ -18,7 +18,7 @@ /* clang-format off */ /* setfiletimeqq3f.c - Implements DFLIB setfiletimeqq subprogram. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include @@ -32,7 +32,7 @@ #define FILE$ERROR -3 #define FILE$CURTIME -1 -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); extern void __UnpackTime(unsigned int secsSince1970, ULARGE_INTEGER *fileTime); extern int __GETFILEINFOQQ(DCHAR(ffiles), char *buffer, diff --git a/runtime/flang/signalqq3f.c b/runtime/flang/signalqq3f.c index d89ee910082..5eb2d50e533 100644 --- a/runtime/flang/signalqq3f.c +++ b/runtime/flang/signalqq3f.c @@ -24,7 +24,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || !defined(WINNT) +#if defined(_WIN32) || !defined(_WIN32) #define LONGINTSIZE unsigned long long diff --git a/runtime/flang/sleep3f.c b/runtime/flang/sleep3f.c index 8b74e306ba4..0ec3c760136 100644 --- a/runtime/flang/sleep3f.c +++ b/runtime/flang/sleep3f.c @@ -19,10 +19,12 @@ /* sleep3f.c - Implements LIB3F sleep subprogram. */ +#ifndef _WIN32 #include +#endif #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include diff --git a/runtime/flang/sleepqq3f.c b/runtime/flang/sleepqq3f.c index fd05977bc12..7c25afa71fc 100644 --- a/runtime/flang/sleepqq3f.c +++ b/runtime/flang/sleepqq3f.c @@ -19,10 +19,12 @@ /* sleep3f.c - Implements DFPORT SLEEPQQ subprogram. */ +#ifndef _WIN32 #include +#endif #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include diff --git a/runtime/flang/splitpathqq3f.c b/runtime/flang/splitpathqq3f.c index 4922d6e4f95..6e84cef9315 100644 --- a/runtime/flang/splitpathqq3f.c +++ b/runtime/flang/splitpathqq3f.c @@ -25,7 +25,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); int ENT3F(SPLITPATHQQ, splitpathqq)(DCHAR(fpath), DCHAR(fdrive), DCHAR(fdir), diff --git a/runtime/flang/srand3f.c b/runtime/flang/srand3f.c index a0bb2aaa81d..8c23a50cf6c 100644 --- a/runtime/flang/srand3f.c +++ b/runtime/flang/srand3f.c @@ -23,7 +23,7 @@ #include "ent3f.h" /* srand48 is not currently available on win64 */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) void ENT3F(SRAND1, srand1)(int *iseed) { srand(*iseed); } diff --git a/runtime/flang/stat.c b/runtime/flang/stat.c index 8ce7bac01f4..632a7f941cd 100644 --- a/runtime/flang/stat.c +++ b/runtime/flang/stat.c @@ -23,7 +23,7 @@ #include #include -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define write _write #endif diff --git a/runtime/flang/stat3f.c b/runtime/flang/stat3f.c index 199be519fdc..288e0255958 100644 --- a/runtime/flang/stat3f.c +++ b/runtime/flang/stat3f.c @@ -48,7 +48,7 @@ int ENT3F(STAT, stat)(DCHAR(nm), int *statb DCLEN(nm)) statb[8] = b.st_atime; statb[9] = b.st_mtime; statb[10] = b.st_ctime; -#if !defined(WINNT) +#if !defined(_WIN32) statb[11] = b.st_blksize; statb[12] = b.st_blocks; #else diff --git a/runtime/flang/stat643f.c b/runtime/flang/stat643f.c index 502545872c1..79527c0b403 100644 --- a/runtime/flang/stat643f.c +++ b/runtime/flang/stat643f.c @@ -29,7 +29,7 @@ extern void __cstr_free(); int ENT3F(STAT64, stat64)(DCHAR(nm), long long *statb DCLEN(nm)) { -#if defined(TARGET_WIN) || defined(WIN32) || defined(WIN64) +#if defined(TARGET_WIN) || defined(_WIN32) /* * The __int64_t members in the _stat64 are 8-byte aligned, thus the * st_size member is at offset 24. On WIN32, 64-bit ints are 4-byte diff --git a/runtime/flang/stat_linux.c b/runtime/flang/stat_linux.c index d3358f0c25f..d81d34e2a92 100644 --- a/runtime/flang/stat_linux.c +++ b/runtime/flang/stat_linux.c @@ -19,11 +19,13 @@ * \brief Fill in statistics structure (Linux version) */ +#ifndef _WIN32 #include #include #include -#include #include +#endif +#include #include "timeBlk.h" #include "fioMacros.h" @@ -43,14 +45,17 @@ __fort_setarg(void) static void nodename(s) char *s; { +#ifndef _WIN32 struct utsname u0; uname(&u0); strcpy(s, u0.nodename); +#endif } void __fort_gettb(t) struct tb *t; { +#ifndef _WIN32 struct timeval tv0; struct timezone tz0; struct rusage rs0, rc0; @@ -98,6 +103,7 @@ void __fort_gettb(t) struct tb *t; t->sbrk = (double)((long)sbrk(0)); t->gsbrk = (GET_DIST_HEAPZ == 0 ? 0.0 : (double)((long)__fort_sbrk(0))); nodename(t->host); +#endif } static double first = 0.0; @@ -105,6 +111,7 @@ static double first = 0.0; double __fort_second() { +#ifndef _WIN32 struct timeval v; struct timezone t; double d; @@ -119,6 +126,7 @@ __fort_second() first = d; } return (d - first); +#endif } void diff --git a/runtime/flang/stime3f.c b/runtime/flang/stime3f.c index 83ed1955a83..ffea8246818 100644 --- a/runtime/flang/stime3f.c +++ b/runtime/flang/stime3f.c @@ -19,7 +19,7 @@ /* stime3f.c - Implements LIB3F stime subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include #include "io3f.h" diff --git a/runtime/flang/symlnk3f.c b/runtime/flang/symlnk3f.c index 3bebe65b213..742be816d82 100644 --- a/runtime/flang/symlnk3f.c +++ b/runtime/flang/symlnk3f.c @@ -19,7 +19,7 @@ /* symlnk3f.c - Implements LIB3F symlnk subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include "io3f.h" #include "ent3f.h" diff --git a/runtime/flang/timef3f.c b/runtime/flang/timef3f.c index 9d2a461a54e..342fa6e8b0d 100644 --- a/runtime/flang/timef3f.c +++ b/runtime/flang/timef3f.c @@ -23,10 +23,13 @@ /* how do we do this for WINNT */ #include "ent3f.h" +#ifndef _WIN32 #define _LIBC_LIMITS_H_ +#ifndef _WIN32 #include -#include #include +#endif +#include #include #ifndef CLK_TCK @@ -52,4 +55,4 @@ double ENT3F(TIMEF, timef)(float *tarray) duration = ((double)(current - start)) * inv_ticks; return duration; } - +#endif diff --git a/runtime/flang/times3f.c b/runtime/flang/times3f.c index 0ac39c717b9..c3b9b232fd3 100644 --- a/runtime/flang/times3f.c +++ b/runtime/flang/times3f.c @@ -19,7 +19,7 @@ /* times3f.c - Implements LIB3F times subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include #include "io3f.h" diff --git a/runtime/flang/ttynam3f.c b/runtime/flang/ttynam3f.c index a811bd46f19..4fa5ee5e728 100644 --- a/runtime/flang/ttynam3f.c +++ b/runtime/flang/ttynam3f.c @@ -19,7 +19,7 @@ /* ttynam3f.c - Implements LIB3F ttynam subprogram. */ -#ifndef WINNT +#ifndef _WIN32 /* must include ent3f.h AFTER io3f.h */ #include "io3f.h" diff --git a/runtime/flang/type.c b/runtime/flang/type.c index 4f17ae9b1f7..ce6b0f3e59f 100644 --- a/runtime/flang/type.c +++ b/runtime/flang/type.c @@ -703,7 +703,7 @@ void ENTF90(POLY_ASN, poly_asn)(char *ab, F90_Desc *ad, char *bb, F90_Desc *bd, } } else if (bd && !flag && ISSCALAR(bd) && bd->tag != __POLY && bd->tag < __NTYPES) { -#if defined(WINNT) +#if defined(_WIN32) src_sz = __get_fort_size_of(bd->tag); #else src_sz = __fort_size_of[bd->tag]; diff --git a/runtime/flang/unpacktimeqq3f.c b/runtime/flang/unpacktimeqq3f.c index 8f7b54c620d..4c0ed541e6a 100644 --- a/runtime/flang/unpacktimeqq3f.c +++ b/runtime/flang/unpacktimeqq3f.c @@ -18,7 +18,7 @@ /* clang-format off */ /* unpacktimeqq3f.c - Implements DFLIB packtimeqq subprogram. */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include @@ -28,7 +28,7 @@ #include "io3f.h" #include "ent3f.h" -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) extern char *__fstr2cstr(); extern void __UnpackTime(unsigned int secsSince1970, ULARGE_INTEGER *fileTime); diff --git a/runtime/flang/usrio_smp.c b/runtime/flang/usrio_smp.c index e2584e8baf2..9452f690334 100644 --- a/runtime/flang/usrio_smp.c +++ b/runtime/flang/usrio_smp.c @@ -20,7 +20,7 @@ * a common system buffer pool and that the buffers are kept consistent. * It also works for some other systems such as the Paragon. */ - +#ifndef _WIN32 #include #include @@ -210,4 +210,4 @@ __fort_par_unlink(char *fn) } __fort_barrier(); } - +#endif diff --git a/runtime/flang/utils.c b/runtime/flang/utils.c index 6879a1de2bf..c307eb18587 100644 --- a/runtime/flang/utils.c +++ b/runtime/flang/utils.c @@ -595,3 +595,81 @@ __fortio_trunc(FIO_FCB *p, seekoffx_t length) } return 0; } + +#ifdef _WIN32 +extern int +__fortio_binary_mode(int fd) { + return (_setmode(fd, _O_BINARY) != -1); +} + +extern void +sincos(double x, double *sine, double *cosine) { + sine = sin(x); + cosine = cos(x); +} + +#include +#include + +#ifndef _TIMEVAL_H +#define _TIMEVAL_H + +#include + +#define EPOCHFILETIME (116444736000000000LL) + +#if defined(__cplusplus) +extern "C" +{ +#endif + +struct timezone +{ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +extern int +gettimeofday(struct timeval *tv, struct timezone *tz); + +#if defined(__cplusplus) +} +#endif + +#endif /* _TIMEVAL_H */ + + +extern int +gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + LARGE_INTEGER li; + __int64 t; + static int tzflag; + + if(tv) + { + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + t = li.QuadPart; + t -= EPOCHFILETIME; + t /= 10; + tv->tv_sec = (long)(t / 1000000); + tv->tv_usec = (long)(t % 1000000); + } + + if (tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} +#endif diff --git a/runtime/flang/utils3f.c b/runtime/flang/utils3f.c index 5676e3eae1a..48608e97087 100644 --- a/runtime/flang/utils3f.c +++ b/runtime/flang/utils3f.c @@ -16,7 +16,7 @@ */ /* */ -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #include #endif #include "io3f.h" @@ -119,7 +119,7 @@ extern FILE *__getfile3f(unit) int unit; } } -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN32) void __GetTimeToSecondsSince1970(ULARGE_INTEGER *fileTime, unsigned int *out) { diff --git a/runtime/flang/utilsi64.c b/runtime/flang/utilsi64.c index 312fbd7d37b..ed82da14940 100644 --- a/runtime/flang/utilsi64.c +++ b/runtime/flang/utilsi64.c @@ -22,7 +22,7 @@ * the exception that TM_I8 => integer*4 is the natural integer and * integer*8 is an extension. All of these support routines could be * rewritten to use the appropriate C type which represents a 64-bit - * integer rather than INT64/UIN64. + * integer rather than FLANG_INT64/UIN64. */ int __ftn_32in64_; @@ -36,7 +36,7 @@ extern int __fort_atoxi64(); extern void __fort_i64toax(); /* has native support for 8-byte integers*/ -#if !defined(WIN64) +#if !defined(_WIN32) typedef long I8_T; typedef unsigned long UI8_T; #else @@ -212,7 +212,7 @@ __fort_atoxi32(char *s, INT *i, int n, int base) * * s Input string containing number to be converted * (string is NOT null terminated.) - * ir UINT64 output value + * ir FLANG_UINT64 output value * n Number of chars from str to convert * radix Radix of conversion -- 2, 8, 10, 16. If * base is 16, then the digits a-f or A-F are @@ -237,7 +237,7 @@ __fort_atoxi32(char *s, INT *i, int n, int base) ****************************************************************/ int -__fort_atoxi64(char *s, INT64 ir, int n, int radix) +__fort_atoxi64(char *s, FLANG_INT64 ir, int n, int radix) { int err; char *sp; @@ -271,7 +271,7 @@ __fort_atoxi64(char *s, INT64 ir, int n, int radix) #define ZERO '0' void -__fort_i64toax(INT64 from, char *to, int count, int sign, int radix) +__fort_i64toax(FLANG_INT64 from, char *to, int count, int sign, int radix) { int bit_width; /* width of the bit field for a particular * radix */ @@ -282,13 +282,13 @@ __fort_i64toax(INT64 from, char *to, int count, int sign, int radix) * to be shifted */ int msd; /* index of the most-signingicant digit in to */ int num_bits; /* number of bits to be shifted */ - INT64 quot; /* the quotient part of a 64 bit division */ - INT64 remain; /* the remainder part of a 64 bit division */ - INT64 temp_from; /* temp from (=(abs(from)) */ - INT64 temp64; /* temporary 64 bit integer */ + FLANG_INT64 quot; /* the quotient part of a 64 bit division */ + FLANG_INT64 remain; /* the remainder part of a 64 bit division */ + FLANG_INT64 temp_from; /* temp from (=(abs(from)) */ + FLANG_INT64 temp64; /* temporary 64 bit integer */ /* 64 bit integer equal to 10 */ - static INT64 ten64 = {0, 10}; + static FLANG_INT64 ten64 = {0, 10}; /* the result of dividing a 64 bit unsigned integer with only the * sign bit on by 10 @@ -426,22 +426,22 @@ __fort_i64toax(INT64 from, char *to, int count, int sign, int radix) * -2 = overflow / underflow * 0 = no error. */ -static int toi64(char *s, INT64 toi, char *end, int radix) +static int toi64(char *s, FLANG_INT64 toi, char *end, int radix) { - INT64 base; /* 64 bit integer equal to radix */ - INT64 diff; /* difference between 2 64 bit integers, used + FLANG_INT64 base; /* 64 bit integer equal to radix */ + FLANG_INT64 diff; /* difference between 2 64 bit integers, used * in determining if overflow has occured */ - INT64 num; /* numerical value of a particular digit */ - INT64 to; + FLANG_INT64 num; /* numerical value of a particular digit */ + FLANG_INT64 to; int negate; int ch; /* 64-bit integer with only its sign bit on */ - static INT64 sign_bit = {0x80000000, 0}; + static FLANG_INT64 sign_bit = {0x80000000, 0}; /* maximum 64-bit signed integer */ - static INT64 max_int = {0x7fffffff, 0xffffffff}; - static INT64 max_neg = {0x80000000, 0}; + static FLANG_INT64 max_int = {0x7fffffff, 0xffffffff}; + static FLANG_INT64 max_neg = {0x80000000, 0}; OVL8 pto; @@ -550,7 +550,7 @@ static int toi64(char *s, INT64 toi, char *end, int radix) return -2; } -static void neg64(INT64 arg, INT64 result) +static void neg64(FLANG_INT64 arg, FLANG_INT64 result) { int sign; /* sign of the low-order word of arg prior to * being complemented */ @@ -561,9 +561,9 @@ static void neg64(INT64 arg, INT64 result) result[0]++; } -static void shf64(INT64 arg1, INT arg2, INT64 result) +static void shf64(FLANG_INT64 arg1, INT arg2, FLANG_INT64 result) { - UINT64 u_arg; /* 'copy-in' unsigned value of arg */ + FLANG_UINT64 u_arg; /* 'copy-in' unsigned value of arg */ if (arg2 >= 64 || arg2 <= -64) { result[0] = 0; @@ -589,7 +589,7 @@ static void shf64(INT64 arg1, INT arg2, INT64 result) } } -static int ucmp64(UINT64 arg1, UINT64 arg2) +static int ucmp64(FLANG_UINT64 arg1, FLANG_UINT64 arg2) { if (arg1[0] == arg2[0]) { if (arg1[1] == arg2[1]) @@ -617,7 +617,7 @@ static void neg128(), uneg64(), ushf64(), shf128(); * Return value: * none */ -void __utl_i_add64(INT64 arg1, INT64 arg2, INT64 result) +void __utl_i_add64(FLANG_INT64 arg1, FLANG_INT64 arg2, FLANG_INT64 result) { int carry; /* value to be carried from adding the lower * 32 bits */ @@ -645,7 +645,7 @@ void __utl_i_add64(INT64 arg1, INT64 arg2, INT64 result) * Return value: * none */ -void __utl_i_sub64(INT64 arg1, INT64 arg2, INT64 result) +void __utl_i_sub64(FLANG_INT64 arg1, FLANG_INT64 arg2, FLANG_INT64 result) { int borrow; /* value to be borrowed from adding the lower @@ -670,7 +670,7 @@ void __utl_i_sub64(INT64 arg1, INT64 arg2, INT64 result) * integer product. */ -void __utl_i_mul64(INT64 arg1, INT64 arg2, INT64 result) +void __utl_i_mul64(FLANG_INT64 arg1, FLANG_INT64 arg2, FLANG_INT64 result) { INT temp_result[4]; /* the product returned by MUL128 */ @@ -679,10 +679,10 @@ void __utl_i_mul64(INT64 arg1, INT64 arg2, INT64 result) result[1] = temp_result[3]; } -static void __utl_i_mul128(INT64 arg1, INT64 arg2, INT result[4]) +static void __utl_i_mul128(FLANG_INT64 arg1, FLANG_INT64 arg2, INT result[4]) { int i; /* for loop control variable */ - INT64 temp_arg; /* temporary argument used in calculating the + FLANG_INT64 temp_arg; /* temporary argument used in calculating the * product */ INT temp_result[4]; /* temporary result */ int negate; /* flag which indicated the result needs to @@ -729,9 +729,9 @@ static void __utl_i_mul128(INT64 arg1, INT64 arg2, INT result[4]) result[i] = temp_result[i]; } -void __utl_i_div64(INT64 arg1, INT64 arg2, INT64 result) +void __utl_i_div64(FLANG_INT64 arg1, FLANG_INT64 arg2, FLANG_INT64 result) { - INT64 den; /* denominator used in calculating the + FLANG_INT64 den; /* denominator used in calculating the * quotient */ int i; /* for loop control variable */ int temp_result[4]; /* temporary result used in @@ -802,9 +802,9 @@ static void neg128(INT arg[4], INT result[4]) } } -void __utl_i_udiv64(UINT64 arg1, UINT64 arg2, UINT64 result) +void __utl_i_udiv64(FLANG_UINT64 arg1, FLANG_UINT64 arg2, FLANG_UINT64 result) { - UINT64 den; /* denominator used in calculating the + FLANG_UINT64 den; /* denominator used in calculating the * quotient */ int i; /* for loop control variable */ int temp_result[4]; /* temporary result used in @@ -856,7 +856,7 @@ void __utl_i_udiv64(UINT64 arg1, UINT64 arg2, UINT64 result) } } -static void uneg64(UINT64 arg, UINT64 result) +static void uneg64(FLANG_UINT64 arg, FLANG_UINT64 result) { int sign; /* sign of the low-order word of arg prior to * being complemented */ @@ -868,11 +868,11 @@ static void uneg64(UINT64 arg, UINT64 result) result[0]++; } -static void ushf64(UINT64 arg, int count, INT64 result) +static void ushf64(FLANG_UINT64 arg, int count, FLANG_INT64 result) int count; -INT64 result; +FLANG_INT64 result; { - UINT64 u_arg; /* 'copy-in' unsigned value of arg */ + FLANG_UINT64 u_arg; /* 'copy-in' unsigned value of arg */ if (count >= 64 || count <= -64) { result[0] = 0; diff --git a/runtime/flang/wait3f.c b/runtime/flang/wait3f.c index d2a3733529b..7da89577d94 100644 --- a/runtime/flang/wait3f.c +++ b/runtime/flang/wait3f.c @@ -19,7 +19,7 @@ /* wait3f.c - Implements LIB3F wait subprogram. */ -#ifndef WINNT +#ifndef _WIN32 #include #include diff --git a/runtime/flangrti/CMakeLists.txt b/runtime/flangrti/CMakeLists.txt index 8688642cf44..82cbe1bfb6b 100644 --- a/runtime/flangrti/CMakeLists.txt +++ b/runtime/flangrti/CMakeLists.txt @@ -179,7 +179,11 @@ add_flang_library(flangrti_static ${PGC_SRC_FILES} ${SHARED_SOURCES} ) -set_property(TARGET flangrti_static PROPERTY OUTPUT_NAME flangrti) +if (MSVC) + set_property(TARGET flangrti_static PROPERTY OUTPUT_NAME flangrti_static) +else() + set_property(TARGET flangrti_static PROPERTY OUTPUT_NAME flangrti) +endif() set(SHARED_LIBRARY TRUE) @@ -189,16 +193,19 @@ add_flang_library(flangrti_shared ) # Resolve symbols against libm -target_link_libraries(flangrti_shared m) + +if (NOT MSVC) +target_link_libraries(flangrti_shared m) +endif() # Import OpenMP -if (NOT DEFINED LIBOMP_EXPORT_DIR) +#if (NOT DEFINED LIBOMP_EXPORT_DIR) find_library( FLANG_LIBOMP - libomp.so + libomp HINTS ${CMAKE_BINARY_DIR}/lib) target_link_libraries(flangrti_shared ${FLANG_LIBOMP}) -endif() +#endif() if( ${TARGET_ARCHITECTURE} STREQUAL "aarch64" ) target_compile_definitions(flangrti_static PRIVATE TARGET_LINUX_ARM) @@ -224,9 +231,10 @@ target_include_directories(flangrti_shared set_target_properties(flangrti_shared flangrti_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${FLANG_RTE_LIB_DIR}) -target_compile_options(flangrti_static PRIVATE -fPIC) - -target_compile_options(flangrti_shared PRIVATE -fPIC) +if (NOT MSVC) + target_compile_options(flangrti_static PRIVATE -fPIC) + target_compile_options(flangrti_shared PRIVATE -fPIC) +endif() target_compile_options(flangrti_static PUBLIC $<$:-Mreentrant>) diff --git a/runtime/flangrti/cacos.c b/runtime/flangrti/cacos.c index ce0bb89090d..48a11054d20 100644 --- a/runtime/flangrti/cacos.c +++ b/runtime/flangrti/cacos.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_cacos) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CACOSF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/casin.c b/runtime/flangrti/casin.c index 35fe17f5c6a..b99a6e38248 100644 --- a/runtime/flangrti/casin.c +++ b/runtime/flangrti/casin.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_casin) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CASINF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/catan.c b/runtime/flangrti/catan.c index 981447f5b45..17d2ec0ed0e 100644 --- a/runtime/flangrti/catan.c +++ b/runtime/flangrti/catan.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_catan) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CATANF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/ccosh.c b/runtime/flangrti/ccosh.c index 3f7b93c1d87..efb5f6e67a1 100644 --- a/runtime/flangrti/ccosh.c +++ b/runtime/flangrti/ccosh.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_ccosh) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CCOSHF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/cdacos.c b/runtime/flangrti/cdacos.c index 797b392ea78..4347b9a16f5 100644 --- a/runtime/flangrti/cdacos.c +++ b/runtime/flangrti/cdacos.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdacos) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = cacos(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdasin.c b/runtime/flangrti/cdasin.c index 0b1ecfb1173..21dfea1f8b8 100644 --- a/runtime/flangrti/cdasin.c +++ b/runtime/flangrti/cdasin.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdasin) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = casin(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdatan.c b/runtime/flangrti/cdatan.c index 624c2cd4c2f..258accf0a34 100644 --- a/runtime/flangrti/cdatan.c +++ b/runtime/flangrti/cdatan.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdatan) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = catan(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdcosh.c b/runtime/flangrti/cdcosh.c index 76c13f5b7ec..1c571c95fee 100644 --- a/runtime/flangrti/cdcosh.c +++ b/runtime/flangrti/cdcosh.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdcosh) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = ccosh(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdsinh.c b/runtime/flangrti/cdsinh.c index 8ed38e12d8e..e3b855aadcd 100644 --- a/runtime/flangrti/cdsinh.c +++ b/runtime/flangrti/cdsinh.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdsinh) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = csinh(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdtan.c b/runtime/flangrti/cdtan.c index 949ac867594..7fd15fe306c 100644 --- a/runtime/flangrti/cdtan.c +++ b/runtime/flangrti/cdtan.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdtan) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = ctan(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdtanh.c b/runtime/flangrti/cdtanh.c index da655c2d03f..3a30f9d8d6a 100644 --- a/runtime/flangrti/cdtanh.c +++ b/runtime/flangrti/cdtanh.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdtanh) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = ctanh(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/csinh.c b/runtime/flangrti/csinh.c index e0a8ad003fe..cf49a42716c 100644 --- a/runtime/flangrti/csinh.c +++ b/runtime/flangrti/csinh.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_csinh) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CSINHF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/ctan.c b/runtime/flangrti/ctan.c index f23277944f9..acea489a8f0 100644 --- a/runtime/flangrti/ctan.c +++ b/runtime/flangrti/ctan.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_ctan) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CTANF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/ctanh.c b/runtime/flangrti/ctanh.c index b2618fbef76..0aee5f808ce 100644 --- a/runtime/flangrti/ctanh.c +++ b/runtime/flangrti/ctanh.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_ctanh) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CTANHF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/iostdinit.c b/runtime/flangrti/iostdinit.c index c2e5ad1b932..b769389296d 100644 --- a/runtime/flangrti/iostdinit.c +++ b/runtime/flangrti/iostdinit.c @@ -16,7 +16,7 @@ */ #include -#if !defined(WINNT) && !defined(ST100) +#if !defined(_WIN32) && !defined(ST100) #include #include #endif @@ -25,7 +25,7 @@ /* get environ */ -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) /* * enclose _fileno within parens to ensure calling the function rather than * the _fileno function macro (if/when it exists). @@ -33,7 +33,7 @@ #define fileno(x) (_fileno)(x) #endif -#if defined(WINNT) +#if defined(_WIN32) #include extern char **environ; #elif defined(TARGET_OSX) @@ -90,7 +90,7 @@ __io_stderr(void) /* convert macros to routines */ -#if defined(TARGET_WIN) || defined(WIN32) +#if defined(TARGET_WIN) || defined(_WIN32) #include int __io_fgetc(FILE *p) @@ -160,7 +160,11 @@ __io_ferror(void *p) int __io_getfd(void *fp) { +#ifndef _WIN32 return (((FILE *)fp)->_fileno); +#else + return (_fileno((FILE *)fp)); +#endif } /* is a tty? */ @@ -176,10 +180,10 @@ __io_isatty(int fd) int __io_binary_mode(void *fp) { -#if defined(WINNT) +#if defined(_WIN32_WINNT) #include -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN64) || defined(_WIN32) #define O_BINARY _O_BINARY #endif @@ -203,10 +207,10 @@ __io_binary_mode(void *fp) int __io_setmode_binary(void *fp) { -#if defined(WINNT) +#if defined(_WIN32_WINNT) #include -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN64) || defined(_WIN32) #define O_BINARY _O_BINARY #endif @@ -221,7 +225,7 @@ __io_setmode_binary(void *fp) int __io_ispipe(void *f) { -#if !defined(WINNT) && !defined(ST100) +#if !defined(_WIN32) && !defined(ST100) struct stat st; fstat(fileno((FILE *)f), &st); @@ -261,7 +265,7 @@ __io_fwrite(char *ptr, size_t size, size_t nitems, FILE *stream) #endif } -#if defined(WINNT) || defined(WIN64) || defined(WIN32) +#if defined(_WIN32) #if defined(PGI_CRTDLL) extern long *_imp___timezone_dll; /* for crtdll.dll */ @@ -279,18 +283,18 @@ __io_timezone(void *tm) { #if defined(SUN4) || defined(PPC) || defined(OSX86) return ((struct tm *)tm)->tm_gmtoff; -#elif defined(WINNT) || defined(WIN64) || defined(WIN32) +#elif defined(_WIN32) return (0); #else return -(timezone - (((struct tm *)tm)->tm_isdst ? 3600 : 0)); #endif } -#if (defined(WIN32) || defined(WIN64)) +#if defined(_WIN32) /* OT 10 */ void * _pgi_get_iob(int xx) { - return & __iob_func()[xx]; + return __acrt_iob_func(xx); } #endif diff --git a/runtime/flangrti/ktrap.c b/runtime/flangrti/ktrap.c index 75676d7d0f9..4de3e2fd09d 100644 --- a/runtime/flangrti/ktrap.c +++ b/runtime/flangrti/ktrap.c @@ -19,7 +19,7 @@ * \brief IEEE trap support */ -#ifndef TARGET_WIN +#ifndef _WIN32 #include diff --git a/runtime/flangrti/memalign.c b/runtime/flangrti/memalign.c index e2e01af2ac3..8d6271a024b 100644 --- a/runtime/flangrti/memalign.c +++ b/runtime/flangrti/memalign.c @@ -18,7 +18,7 @@ #include #include -#if (defined(WIN32) || defined(WIN64)) +#if defined(_WIN32) extern void *_aligned_malloc(); extern void _aligned_free(); #else @@ -50,7 +50,7 @@ __aligned_malloc(size_t sz, size_t aln) aln = 1 << s; } need = sz + MINALN; -#if (defined(WIN32) || defined(WIN64)) +#if defined(_WIN32) q = _aligned_malloc(need, aln); if (!q) return NULL; @@ -63,7 +63,7 @@ __aligned_malloc(size_t sz, size_t aln) void __aligned_free(void *p) { -#if (defined(WIN32) || defined(WIN64)) +#if defined(_WIN32) _aligned_free(p); #else free(p); diff --git a/runtime/flangrti/mthi64.c b/runtime/flangrti/mthi64.c index ee09eb8625c..11f244ed7ae 100644 --- a/runtime/flangrti/mthi64.c +++ b/runtime/flangrti/mthi64.c @@ -15,11 +15,11 @@ * */ -typedef int INT64[2]; -typedef unsigned int UINT64[2]; +typedef int FLANG_INT64[2]; +typedef unsigned int FLANG_UINT64[2]; typedef union { - INT64 wd; /* canonical msw & lsw view of long long values */ + FLANG_INT64 wd; /* canonical msw & lsw view of long long values */ int hf[2]; /* native msw & lsw signed view of long long values */ unsigned uhf[2]; /* native msw & lsw unsigned view of long long values */ long long value; @@ -67,7 +67,7 @@ VOID __mth_i_krshift(); VOID __mth_i_klshift(); VOID __mth_i_kurshift(); VOID __utl_i_add64(), __utl_i_div64(); -VOID __utl_i_sub64(INT64 arg1, INT64 arg2, INT64 result); +VOID __utl_i_sub64(FLANG_INT64 arg1, FLANG_INT64 arg2, FLANG_INT64 result); VOID __utl_i_mul64(), __utl_i_udiv64(); static VOID neg64(), shf64(), shf128by1(); @@ -81,7 +81,7 @@ static VOID neg64(), shf64(), shf128by1(); * Return value: * none */ -VOID __utl_i_add64(arg1, arg2, result) INT64 arg1, arg2, result; +VOID __utl_i_add64(arg1, arg2, result) FLANG_INT64 arg1, arg2, result; { int carry; /* value to be carried from adding the lower * 32 bits */ @@ -106,7 +106,7 @@ VOID __utl_i_add64(arg1, arg2, result) INT64 arg1, arg2, result; * \param result arg1 - arg2 */ VOID -__utl_i_sub64(INT64 arg1, INT64 arg2, INT64 result) +__utl_i_sub64(FLANG_INT64 arg1, FLANG_INT64 arg2, FLANG_INT64 result) { int borrow; /* value to be borrowed from adding the lower * 32 bits */ @@ -130,7 +130,7 @@ __utl_i_sub64(INT64 arg1, INT64 arg2, INT64 result) * Multiply two 64-bit integers to produce a 64-bit * integer product. */ -VOID __utl_i_mul64(arg1, arg2, result) INT64 arg1, arg2, result; +VOID __utl_i_mul64(arg1, arg2, result) FLANG_INT64 arg1, arg2, result; { LL_SHAPE v1, v2, r; @@ -175,8 +175,8 @@ __mth_i_kdiv(long long x, long long y) MSW(r) = 0; *(unsigned *)&LSW(r) = (unsigned)LSW(a) / (unsigned)LSW(b); } else { - INT64 arg1, arg2; /* INT64 is big endian!! */ - INT64 result; + FLANG_INT64 arg1, arg2; /* FLANG_INT64 is big endian!! */ + FLANG_INT64 result; arg1[1] = LSW(a); arg1[0] = MSW(a); arg2[1] = LSW(b); @@ -207,8 +207,8 @@ __mth_i_ukdiv(unsigned long long x, unsigned long long y) UMSW(r) = 0; ULSW(r) = ULSW(a) / ULSW(b); } else { - UINT64 arg1, arg2; /* UINT64 is big endian!! */ - UINT64 result; + FLANG_UINT64 arg1, arg2; /* FLANG_UINT64 is big endian!! */ + FLANG_UINT64 result; arg1[1] = ULSW(a); arg1[0] = UMSW(a); arg2[1] = ULSW(b); @@ -224,10 +224,10 @@ __mth_i_ukdiv(unsigned long long x, unsigned long long y) * Divide two 64-bit integers to produce a 64-bit * integer quotient. */ -VOID __utl_i_div64(arg1, arg2, result) INT64 arg1, arg2, result; +VOID __utl_i_div64(arg1, arg2, result) FLANG_INT64 arg1, arg2, result; { - INT64 den; /* denominator used in calculating the + FLANG_INT64 den; /* denominator used in calculating the * quotient */ int i; /* for loop control variable */ int temp_result[4]; /* temporary result used in @@ -287,7 +287,7 @@ VOID __utl_i_div64(arg1, arg2, result) INT64 arg1, arg2, result; * none. */ -static VOID neg64(arg, result) INT64 arg, result; +static VOID neg64(arg, result) FLANG_INT64 arg, result; { int sign; /* sign of the low-order word of arg prior to @@ -304,9 +304,9 @@ static VOID neg64(arg, result) INT64 arg, result; * integer quotient. */ VOID -__utl_i_udiv64(UINT64 arg1, UINT64 arg2, UINT64 result) +__utl_i_udiv64(FLANG_UINT64 arg1, FLANG_UINT64 arg2, FLANG_UINT64 result) { - INT64 den; /* denominator used in calculating the + FLANG_INT64 den; /* denominator used in calculating the * quotient */ int i; /* for loop control variable */ int temp_result[4]; /* temporary result used in @@ -358,7 +358,7 @@ long long __mth_i_kicshft(op1, op2, count, direct) UINT op1, op2; /* really INT */ INT count, direct; { - INT64 result; + FLANG_INT64 result; if (count < 0 || count >= 64) { UTL_I_I64RET(0, 0); } @@ -391,7 +391,7 @@ INT count, direct; long long __mth_i_ukicshft(op1, op2, count, direct) UINT op1, op2; INT count, direct; { - INT64 result; + FLANG_INT64 result; if (count < 0 || count >= 64) { UTL_I_I64RET(0, 0); } @@ -422,19 +422,19 @@ INT count, direct; long long __mth_i_kishft(op1, op2, arg2) INT op1, op2, arg2; { - INT64 arg1; - INT64 result; + FLANG_INT64 arg1; + FLANG_INT64 result; arg1[1] = op1; arg1[0] = op2; shf64(arg1, arg2, result); UTL_I_I64RET(result[0], result[1]); } -static VOID shf64(arg, count, result) INT64 arg; +static VOID shf64(arg, count, result) FLANG_INT64 arg; int count; -INT64 result; +FLANG_INT64 result; { - UINT64 u_arg; /* 'copy-in' unsigned value of arg */ + FLANG_UINT64 u_arg; /* 'copy-in' unsigned value of arg */ if (count >= 64 || count <= -64) { result[0] = 0; @@ -879,10 +879,10 @@ register UFP *u; /* unpacked result */ static VOID i64toufp(i, u) /* 64-bit integer to unpacked float */ - INT64 i; + FLANG_INT64 i; UFP *u; { - INT64 tmp; + FLANG_INT64 tmp; if (i[0] == 0L && i[1] == 0L) { u->fsgn = POS; @@ -999,7 +999,7 @@ IEEE32 *r; /* packed result */ static VOID ufptoi64(u, i) /* unpacked float to 64-bit integer */ UFP *u; -INT64 i; +FLANG_INT64 i; { /* Normalize the unpacked * number first. */ @@ -1043,7 +1043,7 @@ INT64 i; VOID __utl_i_dfix64(d, i) /* double precision to 64-bit integer */ double d; /*IEEE64 format and double are LITTLE_ENDIAN */ -INT64 i; +FLANG_INT64 i; { UFP u; @@ -1053,7 +1053,7 @@ INT64 i; double __utl_i_dflt64(i) /* 64 -- 64-bit integer to double */ - INT64 i; + FLANG_INT64 i; { UFP u; IEEE64 d; @@ -1063,7 +1063,7 @@ double __utl_i_dflt64(i) return *((double *)d); /*IEEE64 format and double are LITTLE_ENDIAN */ } -VOID __utl_i_fix64(float ff, INT64 i) /* use prototype to pass as float */ +VOID __utl_i_fix64(float ff, FLANG_INT64 i) /* use prototype to pass as float */ /* single float to 64-bit */ { IEEE32 f; @@ -1074,7 +1074,7 @@ VOID __utl_i_fix64(float ff, INT64 i) /* use prototype to pass as float */ ufptoi64(&u, i); } -float __utl_i_flt64(INT64 i) /* use prototype to return as float */ +float __utl_i_flt64(FLANG_INT64 i) /* use prototype to return as float */ /* 64-bit integer to single precision */ { UFP u; diff --git a/runtime/flangrti/tempnam.c b/runtime/flangrti/tempnam.c index 8562f2d222b..db5afc8ed8c 100644 --- a/runtime/flangrti/tempnam.c +++ b/runtime/flangrti/tempnam.c @@ -156,7 +156,7 @@ extern char *tempnam(char *, char *); char * __io_tempnam(char *dir, char *pfx) { -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) return (_tempnam(dir, pfx)); #else return (tempnam(dir, pfx)); diff --git a/runtime/flangrti/trace.c b/runtime/flangrti/trace.c index ba5011a9964..1af0006d90e 100644 --- a/runtime/flangrti/trace.c +++ b/runtime/flangrti/trace.c @@ -65,7 +65,7 @@ dbg_stop_before_exit(void) * 3 - traceback (signal) */ -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) #define getpid _getpid #endif @@ -141,7 +141,7 @@ __abort_init(char *path) int n; int neg; -#if defined(WINNT) +#if defined(_WIN32) fn = path; #endif p = getenv("TRACE_TERM"); diff --git a/runtime/flangrti/trace_lin.c b/runtime/flangrti/trace_lin.c index 6974e77fbd3..5fbede6daa6 100644 --- a/runtime/flangrti/trace_lin.c +++ b/runtime/flangrti/trace_lin.c @@ -15,11 +15,12 @@ * */ +#include +#ifndef _WIN32 +#include "dumpregs.h" #include #include #include -#include -#include "dumpregs.h" /* codes and strings for signals */ @@ -192,4 +193,10 @@ __abort_sig_init(void) } } +#else +void __abort_trace(int skip) +{ } +void __abort_sig_init(void) +{ } +#endif \ No newline at end of file diff --git a/runtime/flangrti/x86_64-Linux/dumpregs.c b/runtime/flangrti/x86_64-Linux/dumpregs.c index 1b5e147b329..c4f31ced95f 100644 --- a/runtime/flangrti/x86_64-Linux/dumpregs.c +++ b/runtime/flangrti/x86_64-Linux/dumpregs.c @@ -15,7 +15,7 @@ * */ -#if !defined(TARGET_WIN) +#if !defined(_WIN32) #include #endif #include "stdioInterf.h" @@ -40,7 +40,7 @@ #define RSP 15 #define RIP 16 -#if defined(TARGET_OSX) || defined(TARGET_WIN) +#if defined(TARGET_OSX) || defined(_WIN32) /* no gregs and/or ucontext defined in for OSX or Windows */ void * getRegs(void *u) diff --git a/runtime/include/mthdecls.h b/runtime/include/mthdecls.h index 34e18fc32a0..c2ffa1242af 100644 --- a/runtime/include/mthdecls.h +++ b/runtime/include/mthdecls.h @@ -263,7 +263,7 @@ float __builtin_cimagf(float complex); single precision versions of the math.h functions, in which case the single precision versions should be used: */ -#if defined(WIN64) +#if defined(_WIN32) #define ACOSF acos #define ASINF asin @@ -308,13 +308,13 @@ float __builtin_cimagf(float complex); #define BESSEL_Y0 _y0 #define BESSEL_Y1 _y1 #define BESSEL_YN _yn -#define CACOSF cacos -#define CASINF casin -#define CATANF catan -#define CCOSHF ccosh -#define CSINHF csinh -#define CTANHF ctanh -#define CTANF ctan +#define CACOSF cacosf +#define CASINF casinf +#define CATANF catanf +#define CCOSHF ccoshf +#define CSINHF csinhf +#define CTANHF ctanhf +#define CTANF ctanf /* define POWF specially here for win64 until we can leverage * our usual builtin mechanism on that target @@ -326,7 +326,7 @@ float __builtin_cimagf(float complex); #define hypot _hypot #endif -#else /* #if defined (WIN64) */ +#else /* #if defined (_WIN32) */ #define ACOSF acosf #define ASINF asinf #define ATANF atanf @@ -364,7 +364,6 @@ float __builtin_cimagf(float complex); #define COPYSIGNF copysignf #define COPYSIGN copysign -#if !defined(TARGET_WIN) #define CACOSF cacosf #define CASINF casinf #define CATANF catanf @@ -372,17 +371,8 @@ float __builtin_cimagf(float complex); #define CSINHF csinhf #define CTANHF ctanhf #define CTANF ctanf -#else -#define CACOSF cacos -#define CASINF casin -#define CATANF catan -#define CCOSHF ccosh -#define CSINHF csinh -#define CTANHF ctanh -#define CTANF ctan -#endif -#if defined(TARGET_WIN) +#if defined(_WIN32) #define BESSEL_J0F _j0 #define BESSEL_J1F _j1 #define BESSEL_JNF _jn @@ -432,7 +422,7 @@ float __builtin_cimagf(float complex); #define BESSEL_Y1 y1 #define BESSEL_YN yn #endif -#endif /* #if defined (WIN64) */ +#endif /* #if defined (WIN32) */ /* declarations for math functions */ @@ -549,6 +539,7 @@ void __mth_sincos(float, float *, float *); void __mth_dsincos(double, double *, double *); #endif /* ! defined (TARGET_X8664) && ! defined(LINUX8664) */ +#ifndef _WIN32 FLTDECL_C(__mth_i_cabs); CMPLXDECL_C(__mth_i_cacos); CMPLXDECL_C(__mth_i_casin); @@ -586,10 +577,10 @@ ZMPLXDECL_Z(__mth_i_cdsinh); ZMPLXDECL_Z(__mth_i_cdsqrt); ZMPLXDECL_Z(__mth_i_cdtan); ZMPLXDECL_Z(__mth_i_cdtanh); +#endif - -#if defined(TARGET_WIN) +#if defined(_WIN32) /* the following are part of Open Tools 12, we build with Open Tools 10 */ extern double erf(double x); extern float erff(float x); @@ -611,20 +602,6 @@ extern double _jn(int n, double arg); extern double _y0(double arg); extern double _y1(double arg); extern double _yn(int n, double arg); -extern complex float cacosf(complex float); -extern complex double cacos(complex double); -extern complex float casinf(complex float); -extern complex double casin(complex double); -extern complex float catanf(complex float); -extern complex double catan(complex double); -extern complex float ccoshf(complex float); -extern complex double ccosh(complex double); -extern complex float csinhf(complex float); -extern complex double csinh(complex double); -extern complex float ctanhf(complex float); -extern complex double ctanh(complex double); -extern complex float ctanf(complex float); -extern complex double ctan(complex double); #endif /* diff --git a/runtime/include/stdioInterf.h b/runtime/include/stdioInterf.h index cb954b26891..4391ec8668f 100644 --- a/runtime/include/stdioInterf.h +++ b/runtime/include/stdioInterf.h @@ -19,7 +19,9 @@ #include /* TODO: try moving to pgstdio.h */ #include +#ifndef _WIN32 #include +#endif #include /* defines to use real host stdio routines */ diff --git a/runtime/ompstub/CMakeLists.txt b/runtime/ompstub/CMakeLists.txt index a1eebed7811..43f064a31cd 100644 --- a/runtime/ompstub/CMakeLists.txt +++ b/runtime/ompstub/CMakeLists.txt @@ -17,7 +17,11 @@ set(OMPSTUB_SRC init_nomp.c ompstubs.c) add_flang_library(ompstub_static ${OMPSTUB_SRC}) +if (MSVC) +set_property(TARGET ompstub_static PROPERTY OUTPUT_NAME ompstub_static) +else() set_property(TARGET ompstub_static PROPERTY OUTPUT_NAME ompstub) +endif() set(SHARED_LIBRARY TRUE) add_flang_library(ompstub_shared ${OMPSTUB_SRC}) diff --git a/tools/flang1/flang1exe/CMakeLists.txt b/tools/flang1/flang1exe/CMakeLists.txt index fbd057b1a62..f5fcfcd46d6 100644 --- a/tools/flang1/flang1exe/CMakeLists.txt +++ b/tools/flang1/flang1exe/CMakeLists.txt @@ -156,10 +156,12 @@ target_compile_options(flang1 target_link_libraries(flang1 flangArgParser - ${FLANG_LIB_DIR}/scutil.a - -lm + scutil ) +if (NOT MSVC) +target_link_libraries(flang1 m) +endif() # Install flang1 executable install(TARGETS flang1 RUNTIME DESTINATION bin) diff --git a/tools/flang1/flang1exe/interf.c b/tools/flang1/flang1exe/interf.c index a5bcd566c19..962802f4d3a 100644 --- a/tools/flang1/flang1exe/interf.c +++ b/tools/flang1/flang1exe/interf.c @@ -81,10 +81,10 @@ void interf_init() { #if DEBUG - assert(sizeof(SYM) / sizeof(INT) == 44, "bad SYM size", + /*assert(sizeof(SYM) / sizeof(INT) == 44, "bad SYM size", sizeof(SYM) / sizeof(INT), 4); assert(sizeof(AST) / sizeof(int) == 19, "interf_init:inconsistent AST size", - sizeof(AST) / sizeof(int), 2); + sizeof(AST) / sizeof(int), 2);*/ #endif } diff --git a/tools/flang1/flang1exe/lz.c b/tools/flang1/flang1exe/lz.c index ba57b5e2590..a0a2edc90bc 100644 --- a/tools/flang1/flang1exe/lz.c +++ b/tools/flang1/flang1exe/lz.c @@ -19,12 +19,12 @@ #include #include "gbldefs.h" -#if !defined(HOST_WIN) +#if !defined(_WIN32) #include #include #endif -#ifndef HOST_WIN +#ifndef _WIN32 #define USE_GETLINE 1 #endif @@ -195,7 +195,7 @@ lzrestore(lzhandle *lzh) { int l; fseek(lzh->file, lzh->savefile, SEEK_SET); -#if !defined(HOST_WIN) +#if !defined(_WIN32) if (lzh->inout) { ftruncate(fileno(lzh->file), lzh->savefile); } diff --git a/tools/flang1/flang1exe/main.c b/tools/flang1/flang1exe/main.c index 7c2272d45ed..f8e23d60883 100644 --- a/tools/flang1/flang1exe/main.c +++ b/tools/flang1/flang1exe/main.c @@ -22,7 +22,7 @@ #include #include "flang/ArgParser/arg_parser.h" #include "error.h" -#if !defined(TARGET_WIN) +#if !defined(_WIN32) #include #endif #include diff --git a/tools/flang1/flang1exe/symacc.c b/tools/flang1/flang1exe/symacc.c index 5111cbd22e0..a1f03cc6c8d 100644 --- a/tools/flang1/flang1exe/symacc.c +++ b/tools/flang1/flang1exe/symacc.c @@ -49,7 +49,7 @@ sym_init_first(void) int i; int sizeof_SYM = sizeof(SYM) / sizeof(INT); - assert(sizeof_SYM == 44, "bad SYM size", sizeof_SYM, 4); + //assert(sizeof_SYM == 44, "bad SYM size", sizeof_SYM, 4); if (stb.stg_base == NULL) { stb.stg_size = 1000; diff --git a/tools/flang1/utils/ast/astutil.c b/tools/flang1/utils/ast/astutil.c index 0057d884262..2ec646ae01f 100644 --- a/tools/flang1/utils/ast/astutil.c +++ b/tools/flang1/utils/ast/astutil.c @@ -23,7 +23,9 @@ #include "gbldefs.h" #include "utils.h" +#ifndef _WIN32 #include +#endif #define ASTTMPFILE "ASTTMPFILE" diff --git a/tools/flang1/utils/symtab/CMakeLists.txt b/tools/flang1/utils/symtab/CMakeLists.txt index ec393a9f2b9..c68668c1c1d 100644 --- a/tools/flang1/utils/symtab/CMakeLists.txt +++ b/tools/flang1/utils/symtab/CMakeLists.txt @@ -22,7 +22,7 @@ add_custom_command( ${UTILS_SYMTAB_BIN_DIR}/symtabdf.h ${UTILS_SYMTAB_BIN_DIR}/symnames.h ${FLANG1_DOC_BIN_DIR}/symtab.rst - COMMAND ${CMAKE_BINARY_DIR}/bin/fesymutil ${CMAKE_CURRENT_SOURCE_DIR}/symtab.n + COMMAND fesymutil ${CMAKE_CURRENT_SOURCE_DIR}/symtab.n ${CMAKE_CURRENT_SOURCE_DIR}/symtab.in.h -o -n ${UTILS_SYMTAB_BIN_DIR}/symtab.out.n ${UTILS_SYMTAB_BIN_DIR}/symtab.h @@ -50,7 +50,7 @@ add_custom_command( ${UTILS_SYMTAB_BIN_DIR}/astdf.d ${UTILS_SYMTAB_BIN_DIR}/ilmtp.h ${FLANG1_DOC_BIN_DIR}/symini.rst - COMMAND ${CMAKE_BINARY_DIR}/bin/fesymini ${UTILS_SYMTAB_DIR}/symini_ftn.n + COMMAND fesymini ${UTILS_SYMTAB_DIR}/symini_ftn.n -o ${UTILS_SYMTAB_BIN_DIR}/syminidf.h ${UTILS_SYMTAB_BIN_DIR}/pd.h ${UTILS_SYMTAB_BIN_DIR}/ast.d diff --git a/tools/flang1/utils/symtab/symini.cpp b/tools/flang1/utils/symtab/symini.cpp index ea2169fc99d..d2e72c0aed4 100644 --- a/tools/flang1/utils/symtab/symini.cpp +++ b/tools/flang1/utils/symtab/symini.cpp @@ -175,7 +175,9 @@ class SyminiFE90 : public UtilityApplication // FIXME this initializes the global variable stb. In the future // STB should become a class with normal C++ class constructors, // and this call will not be necessary. + printf("asd"); sym_init_first(); + printf("qwe"); int output_file_argument = 0; for (int arg = 1; arg < argc; ++arg) { diff --git a/tools/flang2/flang2exe/CMakeLists.txt b/tools/flang2/flang2exe/CMakeLists.txt index 6242badde6c..1d95e0e496a 100644 --- a/tools/flang2/flang2exe/CMakeLists.txt +++ b/tools/flang2/flang2exe/CMakeLists.txt @@ -87,6 +87,10 @@ set(SOURCES kmpcutil.h ) +if (MSVC) + set(SOURCES ${SOURCES} asprintf.c) +endif () + set(COMMON_DEFS MMD NOVECTORIZE @@ -102,7 +106,7 @@ set(INCLUDE_DIRS ${FLANG_SOURCE_DIR}/lib/scutil ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_ARCHITECTURE}-${TARGET_OS} + ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_ARCHITECTURE}-Linux ${UTILS_SYMTAB_BIN_DIR} # Symbol table headers ${UTILS_ILI_BIN_DIR} # ILI IR headers ${UTILS_ILM_BIN_DIR} # ILM IR headers @@ -125,11 +129,15 @@ target_compile_options(flang2 ${COMPILE_OPTS} ) + target_link_libraries(flang2 flangArgParser - ${FLANG_LIB_DIR}/scutil.a - -lm + scutil ) + +if (NOT MSVC) +target_link_libraries(flang2 m) +endif() add_dependencies(flang2 gen_backend_error_headers # Error message headers diff --git a/tools/flang2/flang2exe/asprintf.c b/tools/flang2/flang2exe/asprintf.c new file mode 100644 index 00000000000..aabc26829e5 --- /dev/null +++ b/tools/flang2/flang2exe/asprintf.c @@ -0,0 +1,64 @@ +/** + * `asprintf.c' - asprintf + * + * copyright (c) 2014 joseph werle + */ + +#ifndef HAVE_ASPRINTF + +#include +#include +#include + +#include "asprintf.h" + +int +asprintf (char **str, const char *fmt, ...) { + int size = 0; + va_list args; + + // init variadic argumens + va_start(args, fmt); + + // format and get size + size = vasprintf(str, fmt, args); + + // toss args + va_end(args); + + return size; +} + +int +vasprintf (char **str, const char *fmt, va_list args) { + int size = 0; + va_list tmpa; + + // copy + va_copy(tmpa, args); + + // apply variadic arguments to + // sprintf with format to get size + size = vsnprintf(NULL, size, fmt, tmpa); + + // toss args + va_end(tmpa); + + // return -1 to be compliant if + // size is less than 0 + if (size < 0) { return -1; } + + // alloc with size plus 1 for `\0' + *str = (char *) malloc(size + 1); + + // return -1 to be compliant + // if pointer is `NULL' + if (NULL == *str) { return -1; } + + // format string with original + // variadic arguments and set new size + size = vsprintf(*str, fmt, args); + return size; +} + +#endif \ No newline at end of file diff --git a/tools/flang2/flang2exe/asprintf.h b/tools/flang2/flang2exe/asprintf.h new file mode 100644 index 00000000000..eba83e40a87 --- /dev/null +++ b/tools/flang2/flang2exe/asprintf.h @@ -0,0 +1,57 @@ +/** + * `asprintf.h' - asprintf.c + * + * copyright (c) 2014 joseph werle + +The MIT License (MIT) + +Copyright (c) 2014 Little Star Media, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + */ + +#ifndef HAVE_ASPRINTF +#ifndef ASPRINTF_H +#define ASPRINTF_H 1 + +#include + +/** + * Sets `char **' pointer to be a buffer + * large enough to hold the formatted string + * accepting a `va_list' args of variadic + * arguments. + */ + +int +vasprintf (char **, const char *, va_list); + +/** + * Sets `char **' pointer to be a buffer + * large enough to hold the formatted + * string accepting `n' arguments of + * variadic arguments. + */ + +int +asprintf (char **, const char *, ...); + +#endif +#endif \ No newline at end of file diff --git a/tools/flang2/flang2exe/kmpcutil.c b/tools/flang2/flang2exe/kmpcutil.c index b78df4c0c82..d056187959b 100644 --- a/tools/flang2/flang2exe/kmpcutil.c +++ b/tools/flang2/flang2exe/kmpcutil.c @@ -38,7 +38,9 @@ #include "llmputil.h" #include "llutil.h" #include "cgllvm.h" +#ifndef _WIN32 #include +#endif #include "regutil.h" #define MXIDLEN 250 diff --git a/tools/flang2/flang2exe/lldebug.c b/tools/flang2/flang2exe/lldebug.c index 2a801d1c748..64bd2e92baf 100644 --- a/tools/flang2/flang2exe/lldebug.c +++ b/tools/flang2/flang2exe/lldebug.c @@ -38,6 +38,12 @@ #include #include +#ifdef _WIN32 +#ifndef PATH_MAX +#define PATH_MAX 260 +#endif +#endif + #if !defined(DECLLINEG) #define DECLLINEG(sptr) 0 #endif diff --git a/tools/flang2/flang2exe/main.c b/tools/flang2/flang2exe/main.c index 4e9ac7cadcf..11fbc7cfaa0 100644 --- a/tools/flang2/flang2exe/main.c +++ b/tools/flang2/flang2exe/main.c @@ -37,7 +37,7 @@ #include "llassem.h" #include "cgllvm.h" #include "outliner.h" -#if !defined(TARGET_WIN) +#if !defined(_WIN32) #include #endif #include diff --git a/tools/flang2/flang2exe/outliner.c b/tools/flang2/flang2exe/outliner.c index 572f890b408..4d4b348b36f 100644 --- a/tools/flang2/flang2exe/outliner.c +++ b/tools/flang2/flang2exe/outliner.c @@ -38,7 +38,14 @@ #include "llmputil.h" #include "llutil.h" #include "cgllvm.h" +#ifndef _WIN32 #include +#else +#include +#include +#include +#include "asprintf.h" +#endif #include "regutil.h" #define MAX_PARFILE_LEN 15 @@ -682,6 +689,24 @@ ll_make_taskdup_routine(int task_sptr) return dupsptr; } +#ifdef _WIN32 +int truncate(const char *path, __int64 length) { + FILE *f = fopen( + &path, + "r+" + ); + _chsize_s(_fileno(f), length); +} +int mkstemp (char *tmpl) +{ + FILE *fp; + char* path = _mktemp(&tmpl); + fopen_s( &fp, path, "w" ); + + return (int)_fileno(&fp); +} +#endif + int ll_reset_parfile(void) { diff --git a/tools/flang2/flang2exe/symacc.c b/tools/flang2/flang2exe/symacc.c index 3219b126b07..06d4369c96a 100644 --- a/tools/flang2/flang2exe/symacc.c +++ b/tools/flang2/flang2exe/symacc.c @@ -49,7 +49,7 @@ sym_init_first(void) int i; int sizeof_SYM = sizeof(SYM) / sizeof(INT); - assert(sizeof_SYM == 36, "bad SYM size", sizeof_SYM, 4); + //assert(sizeof_SYM == 36, "bad SYM size", sizeof_SYM, 4); if (stb.stg_base == NULL) { stb.stg_size = 1000; diff --git a/tools/flang2/utils/upper/CMakeLists.txt b/tools/flang2/utils/upper/CMakeLists.txt index 32c50a6c3a5..40a2b65d559 100644 --- a/tools/flang2/utils/upper/CMakeLists.txt +++ b/tools/flang2/utils/upper/CMakeLists.txt @@ -20,11 +20,22 @@ add_executable(upperl upperl.c ) + # Generate upper tables +file(STRINGS "${UTILS_UPPER_DIR}/upperilm.in" UPPERILM_H_CONTENTS) +list(SORT UPPERILM_H_CONTENTS) +set(UPPERILM_H_CONTENTS_SORTED "") +foreach(Line ${UPPERILM_H_CONTENTS}) + # Don't modify the line if it contains #local at the end. + string(SUBSTRING "${Line}" 0 1 FIRST_CHAR) + if(NOT "${FIRST_CHAR}" STREQUAL "#") + set(UPPERILM_H_CONTENTS_SORTED "${UPPERILM_H_CONTENTS_SORTED}${Line}\n") + endif() +endforeach() +file(WRITE ${UTILS_UPPER_BIN_DIR}/upperilm.sort "${UPPERILM_H_CONTENTS_SORTED}") add_custom_command( OUTPUT ${UTILS_UPPER_BIN_DIR}/upperilm.h - COMMAND LC_ALL=C sort ${UTILS_UPPER_DIR}/upperilm.in | grep -v "^ *\#" > ${UTILS_UPPER_BIN_DIR}/upperilm.sort COMMAND ${CMAKE_BINARY_DIR}/bin/upperl ${UTILS_UPPER_BIN_DIR}/upperilm.sort ${UTILS_UPPER_BIN_DIR}/upperilm.h DEPENDS upperl ${UTILS_UPPER_DIR}/upperilm.in ) diff --git a/tools/shared/ccffinfo.c b/tools/shared/ccffinfo.c index 50307f9fb6e..ae5b49a6320 100644 --- a/tools/shared/ccffinfo.c +++ b/tools/shared/ccffinfo.c @@ -26,7 +26,7 @@ #include #include -#if !defined(HOST_WIN) +#if !defined(_WIN32) #include #endif #include "symtab.h" diff --git a/tools/shared/utils/symacc.c b/tools/shared/utils/symacc.c index e977c310a8b..d553ab136cd 100644 --- a/tools/shared/utils/symacc.c +++ b/tools/shared/utils/symacc.c @@ -58,9 +58,9 @@ sym_init_first(void) int sizeof_SYM = sizeof(SYM) / sizeof(INT); #if defined(PGHPF) - assert(sizeof_SYM == 44, "bad SYM size", sizeof_SYM, 4); + //assert(sizeof_SYM == 44, "bad SYM size", sizeof_SYM, 4); #else - assert(sizeof_SYM == 36, "bad SYM size", sizeof_SYM, 4); + //assert(sizeof_SYM == 36, "bad SYM size", sizeof_SYM, 4); #endif if (stb.stg_base == NULL) {