Skip to content

Commit

Permalink
Minimal code changes to allow msvc compilation.
Browse files Browse the repository at this point in the history
-add msvc ssize_t definition in compat.h
-change NUM_OS_RANDOM_BYTES to int from ssize_t in random.h

Includes squashed commit: f7dc992

Inspired by: fbf327b
  • Loading branch information
sipsorcery authored and xanimo committed Jun 18, 2024
1 parent 90d1972 commit 3606c85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ typedef u_int SOCKET;
#define MAX_PATH 1024
#endif

// ssize_t is POSIX, and not present when using MSVC.
#ifdef _MSC_VER
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

// As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
Expand Down
2 changes: 1 addition & 1 deletion src/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class FastRandomContext {
* sure that the underlying OS APIs for all platforms support the number.
* (many cap out at 256 bytes).
*/
static const ssize_t NUM_OS_RANDOM_BYTES = 32;
static const int NUM_OS_RANDOM_BYTES = 32;

/** Get 32 bytes of system entropy. Do not use this in application code: use
* GetStrongRandBytes instead.
Expand Down

0 comments on commit 3606c85

Please sign in to comment.