Skip to content

Commit

Permalink
use getentropy on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Doridian committed Jul 1, 2023
1 parent 7d7da2b commit fa06c71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
- name: Build
run: |
set -ex
sudo apt-get -y install gcc-multilib g++-multilib cmake
mkdir build
Expand All @@ -57,9 +58,9 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- run: |
- name: Build
run: |
set -ex
brew install cmake
mkdir build
cd build
cmake ..
Expand Down
9 changes: 8 additions & 1 deletion module/random.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include "GarrysMod/Lua/Interface.h"
#include <math.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>

using namespace GarrysMod::Lua;
Expand Down Expand Up @@ -30,6 +30,13 @@ size_t getrandom(void *buf, size_t buflen, unsigned int flags)
#include <sys/random.h>
#endif

#ifdef __APPLE__
size_t getrandom(void *buf, size_t buflen, unsigned int flags)
{
return getentropy(buf, buflen);
}
#endif

struct RandInts {
unsigned short int a;
unsigned short int b;
Expand Down

0 comments on commit fa06c71

Please sign in to comment.