-
Notifications
You must be signed in to change notification settings - Fork 24
/
misc.c
82 lines (72 loc) · 2.01 KB
/
misc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* PANDAseq -- Assemble paired FASTQ Illumina reads and strip the region between amplification primers.
Copyright (C) 2011-2012 Andre Masella
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <unistd.h>
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#if HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#include "pandaseq.h"
char const *panda_version(
void) {
return PACKAGE_STRING;
}
int panda_api_version(
void) {
return PANDA_API;
}
size_t panda_max_len(
void) {
return MAX_LEN;
}
#ifdef _WIN32
# include <windows.h>
int panda_get_default_worker_threads(
void) {
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return (sysinfo.dwNumberOfProcessors < 1) ? 1 : sysinfo.dwNumberOfProcessors;
}
#elif defined(_SC_NPROCESSORS_ONLN)
int panda_get_default_worker_threads(
void) {
int num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
return (num_cpus < 1) ? 1 : num_cpus;
}
#elif defined(HW_AVAILCPU)
# include <unistd.h>
# include <sys/types.h>
# include <sys/sysctl.h>
int panda_get_default_worker_threads(
void) {
int num_cpus;
int mib[4];
size_t len = sizeof(num_cpus);
mib[0] = CTL_HW;
mib[1] = HW_AVAILCPU;
sysctl(mib, 2, &num_cpu, &len, NULL, 0);
if (num_cpu < 1) {
mib[1] = HW_NCPU;
sysctl(mib, 2, &numCPU, &len, NULL, 0);
}
return (num_cpus < 1) ? 1 : num_cpus;
}
#else
int panda_get_default_worker_threads(
void) {
return 1;
}
#endif