2 * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version,
8 * with the OCaml linking exception described in COPYING.LIB.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * $Id: bitstring.ml 146 2008-08-20 16:58:33Z richard.wm.jones $
22 /* This file contains hand-coded, optimized C implementations of
23 * certain very frequently used functions.
29 #include <caml/mlvalues.h>
30 #include <caml/fail.h>
32 /* Return a mask of 0-31 bits wide. */
34 ocaml_bitstring_I_mask (value bitsv)
36 int bits = Int_val (bitsv);
39 return Val_int ((1 << bits) - 1);
41 caml_invalid_argument ("Bitstring.I.mask");