X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Futils-c.c;fp=src%2Futils-c.c;h=3c6554f62138eb8ed2305ffc74ba7513522ec041;hb=349ba0ff3bded60e8035d5896a6d5f689a632ae7;hp=0000000000000000000000000000000000000000;hpb=d4e38a120ebe65ef688472506b0b5900f955ded1;p=goals.git diff --git a/src/utils-c.c b/src/utils-c.c new file mode 100644 index 0000000..3c6554f --- /dev/null +++ b/src/utils-c.c @@ -0,0 +1,45 @@ +/* Goalfile utilities + * Copyright (C) 2020 Richard W.M. Jones + * Copyright (C) 2020 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include +#include + +#include +#include + +#ifdef HAVE_SYS_SYSINFO_H +#include +#endif + +value +nprocs (value unitv) +{ + CAMLparam1 (unitv); + int n; + +#ifdef HAVE_GET_NPROCS + n = get_nprocs (); +#else + n = 1; +#endif + + CAMLreturn (Val_int (n)); +}