Merge pull request #304129 from viraptor/rs-darwin

rs: fix darwin

authored by Stanisław Pitucha and committed by GitHub f66faca8 5956ef0f

+32
+26
pkgs/by-name/rs/rs/macos-reallocarray.patch
···
··· 1 + Original from OpenBSD src/lib/libc/stdlib/reallocarray.c 2 + 3 + --- a/rs.c 2024-04-15 10:13:41 4 + +++ b/rs.c 2024-04-15 10:15:20 5 + @@ -103,6 +103,21 @@ 6 + ep = getptrs(ep); \ 7 + } while(0) 8 + 9 + +#ifdef __APPLE__ 10 + +#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) 11 + + 12 + +void * 13 + +reallocarray(void *optr, size_t nmemb, size_t size) 14 + +{ 15 + + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && 16 + + nmemb > 0 && SIZE_MAX / nmemb < size) { 17 + + errno = ENOMEM; 18 + + return NULL; 19 + + } 20 + + return realloc(optr, size * nmemb); 21 + +} 22 + +#endif 23 + + 24 + int 25 + main(int argc, char *argv[]) 26 + {
+6
pkgs/by-name/rs/rs/package.nix
··· 16 17 nativeBuildInputs = [ installShellFiles ]; 18 19 buildInputs = [ libbsd ]; 20 21 buildPhase = '' ··· 63 license = licenses.bsd3; 64 maintainers = with maintainers; [ AndersonTorres ]; 65 platforms = platforms.unix; 66 }; 67 }
··· 16 17 nativeBuildInputs = [ installShellFiles ]; 18 19 + patches = [ 20 + # add an implementation of reallocarray() from openbsd (not available on darwin) 21 + ./macos-reallocarray.patch 22 + ]; 23 + 24 buildInputs = [ libbsd ]; 25 26 buildPhase = '' ··· 68 license = licenses.bsd3; 69 maintainers = with maintainers; [ AndersonTorres ]; 70 platforms = platforms.unix; 71 + broken = stdenv.isx86_64 && stdenv.isDarwin; # missing strtonum() 72 }; 73 }