Skip to content

Commit

Permalink
[runtime/curdir] implement gethostname (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoviat committed Dec 23, 2017
1 parent 086ca05 commit 1e54c29
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ macro(add_flang_library name)
endif( LLVM_COMMON_DEPENDS )

llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
if(WIN32)
list(APPEND LLVM_COMMON_LIBS Dbghelp.lib)
endif()
target_link_libraries( ${name} ${LLVM_COMMON_LIBS})
# link_system_libs( ${name} ) # getd of cmake warning messages

Expand Down
3 changes: 3 additions & 0 deletions runtime/flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ if (NOT MSVC)
target_compile_options(flang_static PRIVATE -fPIC)
target_compile_options(flang_shared PRIVATE -fPIC)
else()
target_link_libraries(flang_shared PRIVATE Ws2_32.lib)
target_link_libraries(flang_static PRIVATE Ws2_32.lib)

set_target_properties(flang_static PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(flang_shared PROPERTIES LINKER_LANGUAGE CXX)
endif()
Expand Down
15 changes: 8 additions & 7 deletions runtime/flang/curdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ void __fort_getdir(curdir) char *curdir;

void __fort_gethostname(host) char *host;
{
#ifndef _WIN32
struct utsname un;
char *p;
int s;
#ifndef _WIN32
struct utsname un;

p = __fort_getopt("-curhost");
if (p == NULL) {
Expand All @@ -117,10 +117,11 @@ void __fort_gethostname(host) char *host;
}
p = un.nodename;
}
strcpy(host, p);
#else
char temp[128] = "";
gethostname(host, sizeof(temp));
strcpy(host, temp);
#endif
s = gethostname(&p, 256);
if (s != 0) {
__fort_abortp("uname");
}
#endif
strcpy(host, p);
}
3 changes: 3 additions & 0 deletions runtime/flangrti/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ if (NOT MSVC)
target_compile_options(flangrti_shared PRIVATE -fPIC)
else()
set_target_properties(flangrti_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

target_link_libraries(flangrti_shared PRIVATE Dbghelp.lib)
target_link_libraries(flangrti_static PRIVATE Dbghelp.lib)
endif()

target_compile_options(flangrti_static PUBLIC $<$<COMPILE_LANGUAGE:Fortran>:-Mreentrant>)
Expand Down

0 comments on commit 1e54c29

Please sign in to comment.