Skip to content

Commit e821d59

Browse files
author
Kim Barrett
committed
8345589: Simplify Windows definition of strtok_r
Reviewed-by: dholmes, jwaters
1 parent 153dc6d commit e821d59

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/hotspot/share/runtime/os.hpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
#include "jvm_md.h"
2929
#include "runtime/osInfo.hpp"
3030
#include "utilities/exceptions.hpp"
31-
#include "utilities/ostream.hpp"
31+
#include "utilities/globalDefinitions.hpp"
3232
#include "utilities/macros.hpp"
33+
#include "utilities/ostream.hpp"
3334
#ifdef __APPLE__
3435
# include <mach/mach_time.h>
3536
#endif
@@ -1027,14 +1028,6 @@ class os: AllStatic {
10271028
class Posix;
10281029
#endif
10291030

1030-
// FIXME - some random stuff that was in os_windows.hpp
1031-
#ifdef _WINDOWS
1032-
// strtok_s is the Windows thread-safe equivalent of POSIX strtok_r
1033-
# define strtok_r strtok_s
1034-
# define S_ISCHR(mode) (((mode) & _S_IFCHR) == _S_IFCHR)
1035-
# define S_ISFIFO(mode) (((mode) & _S_IFIFO) == _S_IFIFO)
1036-
#endif
1037-
10381031
#ifndef OS_NATIVE_THREAD_CREATION_FAILED_MSG
10391032
#define OS_NATIVE_THREAD_CREATION_FAILED_MSG "unable to create native thread: possibly out of memory or process/resource limits reached"
10401033
#endif

src/hotspot/share/utilities/globalDefinitions_visCPP.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
# include <stdlib.h>
3838
# include <stdint.h>
3939
# include <stddef.h>// for offsetof
40+
# include <sys/stat.h>
4041
# include <io.h> // for stream.cpp
4142
# include <float.h> // for _isnan
4243
# include <stdio.h> // for va_list
@@ -80,6 +81,18 @@ inline int strncasecmp(const char *s1, const char *s2, size_t n) {
8081
return _strnicmp(s1,s2,n);
8182
}
8283

84+
// VS doesn't provide strtok_r, which is a POSIX function. Instead, it
85+
// provides the same function under the name strtok_s. Note that this is
86+
// *not* the same as the C99 Annex K strtok_s. VS provides that function
87+
// under the name strtok_s_l. Make strtok_r a synonym so we can use that name
88+
// in shared code.
89+
const auto strtok_r = strtok_s;
90+
91+
// VS doesn't provide POSIX macros S_ISFIFO or S_IFIFO. It doesn't even
92+
// provide _S_ISFIFO, per its usual naming convention for POSIX stuff. But it
93+
// does provide _S_IFIFO, so we can roll our own S_ISFIFO.
94+
#define S_ISFIFO(mode) (((mode) & _S_IFIFO) == _S_IFIFO)
95+
8396
// Checking for nanness
8497

8598
inline int g_isnan(jfloat f) { return _isnan(f); }

0 commit comments

Comments
 (0)