Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
68f4547b
Commit
68f4547b
authored
Nov 21, 2016
by
Guolin Ke
Browse files
fix build error in mingw on windows
parent
88b84436
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
4 deletions
+42
-4
include/LightGBM/utils/text_reader.h
include/LightGBM/utils/text_reader.h
+4
-4
src/CMakeLists.txt
src/CMakeLists.txt
+7
-0
src/network/socket_wrapper.hpp
src/network/socket_wrapper.hpp
+31
-0
No files found.
include/LightGBM/utils/text_reader.h
View file @
68f4547b
...
...
@@ -159,7 +159,7 @@ public:
}
else
{
const
size_t
idx
=
random
.
NextInt
(
0
,
line_idx
+
1
);
if
(
idx
<
sample_cnt
)
{
if
(
idx
<
static_cast
<
size_t
>
(
sample_cnt
)
)
{
out_sampled_data
->
operator
[](
idx
)
=
std
::
string
(
buffer
,
size
);
}
}
...
...
@@ -184,7 +184,7 @@ public:
}
INDEX_T
SampleAndFilterFromFile
(
const
std
::
function
<
bool
(
INDEX_T
)
>&
filter_fun
,
std
::
vector
<
INDEX_T
>*
out_used_data_indices
,
Random
&
random
,
size_t
sample_cnt
,
std
::
vector
<
std
::
string
>*
out_sampled_data
)
{
Random
&
random
,
INDEX_T
sample_cnt
,
std
::
vector
<
std
::
string
>*
out_sampled_data
)
{
INDEX_T
cur_sample_cnt
=
0
;
out_used_data_indices
->
clear
();
INDEX_T
total_cnt
=
ReadAllAndProcess
(
...
...
@@ -199,7 +199,7 @@ public:
}
else
{
const
size_t
idx
=
random
.
NextInt
(
0
,
out_used_data_indices
->
size
());
if
(
idx
<
sample_cnt
)
{
if
(
idx
<
static_cast
<
size_t
>
(
sample_cnt
)
)
{
out_sampled_data
->
operator
[](
idx
)
=
std
::
string
(
buffer
,
size
);
}
}
...
...
@@ -286,7 +286,7 @@ public:
INDEX_T
ReadPartAndProcessParallel
(
const
std
::
vector
<
INDEX_T
>&
used_data_indices
,
const
std
::
function
<
void
(
INDEX_T
,
const
std
::
vector
<
std
::
string
>&
)
>&
process_fun
)
{
return
ReadAllAndProcessParallelWithFilter
(
process_fun
,
[
&
used_data_indices
](
INDEX_T
used_cnt
,
INDEX_T
total_cnt
)
{
if
(
used_cnt
<
used_data_indices
.
size
()
&&
total_cnt
==
used_data_indices
[
used_cnt
])
{
if
(
static_cast
<
size_t
>
(
used_cnt
)
<
used_data_indices
.
size
()
&&
total_cnt
==
used_data_indices
[
used_cnt
])
{
return
true
;
}
else
{
...
...
src/CMakeLists.txt
View file @
68f4547b
...
...
@@ -25,3 +25,10 @@ if(USE_MPI)
TARGET_LINK_LIBRARIES
(
_lightgbm
${
MPI_CXX_LIBRARIES
}
)
endif
(
USE_MPI
)
if
(
WIN32
)
TARGET_LINK_LIBRARIES
(
lightgbm Ws2_32
)
TARGET_LINK_LIBRARIES
(
_lightgbm Ws2_32
)
TARGET_LINK_LIBRARIES
(
lightgbm IPHLPAPI
)
TARGET_LINK_LIBRARIES
(
_lightgbm IPHLPAPI
)
endif
(
WIN32
)
src/network/socket_wrapper.hpp
View file @
68f4547b
...
...
@@ -3,7 +3,9 @@
#ifdef USE_SOCKET
#if defined(_WIN32)
#ifdef _MSC_VER
#define NOMINMAX
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
...
...
@@ -46,6 +48,35 @@ const int INVALID_SOCKET = -1;
#endif
#ifdef _WIN32
#ifndef _MSC_VER
// not using visual studio in windows
inline
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
struct
sockaddr_storage
ss
;
int
size
=
sizeof
(
ss
);
char
src_copy
[
INET6_ADDRSTRLEN
+
1
];
ZeroMemory
(
&
ss
,
sizeof
(
ss
));
/* stupid non-const API */
strncpy
(
src_copy
,
src
,
INET6_ADDRSTRLEN
+
1
);
src_copy
[
INET6_ADDRSTRLEN
]
=
0
;
if
(
WSAStringToAddress
(
src_copy
,
af
,
NULL
,
(
struct
sockaddr
*
)
&
ss
,
&
size
)
==
0
)
{
switch
(
af
)
{
case
AF_INET
:
*
(
struct
in_addr
*
)
dst
=
((
struct
sockaddr_in
*
)
&
ss
)
->
sin_addr
;
return
1
;
case
AF_INET6
:
*
(
struct
in6_addr
*
)
dst
=
((
struct
sockaddr_in6
*
)
&
ss
)
->
sin6_addr
;
return
1
;
}
}
return
0
;
}
#endif
#endif
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment