Skip to content

Commit

Permalink
8345589: Simplify Windows definition of strtok_r
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, jwaters
  • Loading branch information
Kim Barrett committed Dec 9, 2024
1 parent 153dc6d commit e821d59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/hotspot/share/runtime/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
#include "jvm_md.h"
#include "runtime/osInfo.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/ostream.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "utilities/ostream.hpp"
#ifdef __APPLE__
# include <mach/mach_time.h>
#endif
Expand Down Expand Up @@ -1027,14 +1028,6 @@ class os: AllStatic {
class Posix;
#endif

// FIXME - some random stuff that was in os_windows.hpp
#ifdef _WINDOWS
// strtok_s is the Windows thread-safe equivalent of POSIX strtok_r
# define strtok_r strtok_s
# define S_ISCHR(mode) (((mode) & _S_IFCHR) == _S_IFCHR)
# define S_ISFIFO(mode) (((mode) & _S_IFIFO) == _S_IFIFO)
#endif

#ifndef OS_NATIVE_THREAD_CREATION_FAILED_MSG
#define OS_NATIVE_THREAD_CREATION_FAILED_MSG "unable to create native thread: possibly out of memory or process/resource limits reached"
#endif
Expand Down
13 changes: 13 additions & 0 deletions src/hotspot/share/utilities/globalDefinitions_visCPP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# include <stdlib.h>
# include <stdint.h>
# include <stddef.h>// for offsetof
# include <sys/stat.h>
# include <io.h> // for stream.cpp
# include <float.h> // for _isnan
# include <stdio.h> // for va_list
Expand Down Expand Up @@ -80,6 +81,18 @@ inline int strncasecmp(const char *s1, const char *s2, size_t n) {
return _strnicmp(s1,s2,n);
}

// VS doesn't provide strtok_r, which is a POSIX function. Instead, it
// provides the same function under the name strtok_s. Note that this is
// *not* the same as the C99 Annex K strtok_s. VS provides that function
// under the name strtok_s_l. Make strtok_r a synonym so we can use that name
// in shared code.
const auto strtok_r = strtok_s;

// VS doesn't provide POSIX macros S_ISFIFO or S_IFIFO. It doesn't even
// provide _S_ISFIFO, per its usual naming convention for POSIX stuff. But it
// does provide _S_IFIFO, so we can roll our own S_ISFIFO.
#define S_ISFIFO(mode) (((mode) & _S_IFIFO) == _S_IFIFO)

// Checking for nanness

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

0 comments on commit e821d59

Please sign in to comment.