<commit_before>{ stdenv, fetchurl, fetchpatch
, buildPlatform, hostPlatform, autoreconfHook
, doCheck ? true, dejagnu
}:

stdenv.mkDerivation rec {
  name = "libffi-3.2.1";

  src = fetchurl {
    url = "ftp://sourceware.org/pub/libffi/${name}.tar.gz";
    sha256 = "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh";
  };

  patches = stdenv.lib.optional stdenv.isCygwin ./3.2.1-cygwin.patch
    ++ stdenv.lib.optional stdenv.isAarch64 (fetchpatch {
      url = https://src.fedoraproject.org/rpms/libffi/raw/ccffc1700abfadb0969495a6e51b964117fc03f6/f/libffi-aarch64-rhbz1174037.patch;
      sha256 = "1vpirrgny43hp0885rswgv3xski8hg7791vskpbg3wdjdpb20wbc";
    })
    ++ stdenv.lib.optional hostPlatform.isMusl (fetchpatch {
      name = "gnu-linux-define.patch";
      url = "https://git.alpinelinux.org/cgit/aports/plain/main/libffi/gnu-linux-define.patch?id=bb024fd8ec6f27a76d88396c9f7c5c4b5800d580";
      sha256 = "11pvy3xkhyvnjfyy293v51f1xjy3x0azrahv1nw9y9mw8bifa2j2";
    })
    ++ stdenv.lib.optional hostPlatform.isRiscV (fetchpatch {
      name = "riscv-support.patch";
      url = https://github.com/sorear/libffi-riscv/commit/e46492e8bb1695a19bc1053ed869e6c2bab02ff2.patch;
      sha256 = "1vl1vbvdkigs617kckxvj8j4m2cwg62kxm1clav1w5rnw9afxg0y";
    })
    ++ stdenv.lib.optionals stdenv.isMips [
      (fetchpatch {<commit_msg>libffi: don't check on darwin<commit_after>{ stdenv, fetchurl, fetchpatch
, buildPlatform, hostPlatform, autoreconfHook

# libffi is used in darwin stdenv
# we cannot run checks within it
, doCheck ? !stdenv.isDarwin, dejagnu
}:

stdenv.mkDerivation rec {
  name = "libffi-3.2.1";

  src = fetchurl {
    url = "ftp://sourceware.org/pub/libffi/${name}.tar.gz";
    sha256 = "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh";
  };

  patches = stdenv.lib.optional stdenv.isCygwin ./3.2.1-cygwin.patch
    ++ stdenv.lib.optional stdenv.isAarch64 (fetchpatch {
      url = https://src.fedoraproject.org/rpms/libffi/raw/ccffc1700abfadb0969495a6e51b964117fc03f6/f/libffi-aarch64-rhbz1174037.patch;
      sha256 = "1vpirrgny43hp0885rswgv3xski8hg7791vskpbg3wdjdpb20wbc";
    })
    ++ stdenv.lib.optional hostPlatform.isMusl (fetchpatch {
      name = "gnu-linux-define.patch";
      url = "https://git.alpinelinux.org/cgit/aports/plain/main/libffi/gnu-linux-define.patch?id=bb024fd8ec6f27a76d88396c9f7c5c4b5800d580";
      sha256 = "11pvy3xkhyvnjfyy293v51f1xjy3x0azrahv1nw9y9mw8bifa2j2";
    })
    ++ stdenv.lib.optional hostPlatform.isRiscV (fetchpatch {
      name = "riscv-support.patch";
      url = https://github.com/sorear/libffi-riscv/commit/e46492e8bb1695a19bc1053ed869e6c2bab02ff2.patch;
      sha256 = "1vl1vbvdkigs617kckxvj8j4m2cwg62kxm1clav1w5rnw9afxg0y";
    })
    ++ stdenv.lib.optionals stdenv.isMips [
      (fetchpatch {
{'fraction_non_alphanumeric': 0.1207764198418404, 'fraction_numerical': 0.11933860531991373, 'mean_word_length': 4.201869158878504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '519472', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1262, 'n_words': 121}