diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index 6f3d4634f7..e2e38804d9 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -33,7 +33,8 @@ UNIXOBJS = @ISC_ISCIPV6_O@ \ unix/app.@O@ unix/dir.@O@ unix/entropy.@O@ \ unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \ unix/interfaceiter.@O@ unix/keyboard.@O@ unix/net.@O@ \ - unix/socket.@O@ unix/time.@O@ unix/stdio.@O@ unix/stdtime.@O@ + unix/os.@O@ unix/socket.@O@ unix/time.@O@ \ + unix/stdio.@O@ unix/stdtime.@O@ NLSOBJS = nls/msgcat.@O@ diff --git a/lib/isc/include/isc/Makefile.in b/lib/isc/include/isc/Makefile.in index a8a50e2b90..3ca0ebee21 100644 --- a/lib/isc/include/isc/Makefile.in +++ b/lib/isc/include/isc/Makefile.in @@ -27,7 +27,7 @@ HEADERS = assertions.h base64.h bitstring.h boolean.h buffer.h \ file.h formatcheck.h fsaccess.h heap.h interfaceiter.h \ @ISC_IPV6_H@ lang.h lex.h \ lfsr.h lib.h list.h log.h magic.h md5.h mem.h msgcat.h \ - mutexblock.h netaddr.h ondestroy.h platform.h \ + mutexblock.h netaddr.h ondestroy.h os.h platform.h \ print.h quota.h random.h ratelimiter.h region.h \ result.h resultclass.h rwlock.h serial.h sha1.h sockaddr.h \ socket.h stdio.h string.h symtab.h task.h taskpool.h timer.h \ diff --git a/lib/isc/include/isc/os.h b/lib/isc/include/isc/os.h new file mode 100644 index 0000000000..ad673c9de9 --- /dev/null +++ b/lib/isc/include/isc/os.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_OS_H +#define ISC_OS_H 1 + +#include + +ISC_LANG_BEGINDECLS + +unsigned int +isc_os_ncpus(void); +/* + * Return the number of CPUs available on the system, or 1 if this cannot + * be determined. + */ + +ISC_LANG_ENDDECLS + +#endif /* ISC_OS_H */ diff --git a/lib/isc/unix/Makefile.in b/lib/isc/unix/Makefile.in index dc980f705c..e8ff723857 100644 --- a/lib/isc/unix/Makefile.in +++ b/lib/isc/unix/Makefile.in @@ -30,13 +30,13 @@ CWARNINGS = OBJS = @ISC_IPV6_O@ \ app.@O@ dir.@O@ entropy.@O@ errno2result.@O@ file.@O@ \ fsaccess.@O@ interfaceiter.@O@ keyboard.@O@ net.@O@ \ - socket.@O@ stdio.@O@ stdtime.@O@ time.@O@ + os.@O@ socket.@O@ stdio.@O@ stdtime.@O@ time.@O@ # Alphabetically SRCS = @ISC_IPV6_C@ \ app.c dir.c entropy.c errno2result.c file.c \ fsaccess.c interfaceiter.c keyboard.c net.c \ - socket.c stdio.c stdtime.c time.c + os.c socket.c stdio.c stdtime.c time.c SUBDIRS = include TARGETS = ${OBJS} diff --git a/lib/isc/unix/os.c b/lib/isc/unix/os.c new file mode 100644 index 0000000000..f9095e7ad2 --- /dev/null +++ b/lib/isc/unix/os.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include + +#include + +#include + +unsigned int +isc_os_ncpus(void) { +#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) + long ncpus; + + ncpus = sysconf(_SC_NPROCESSORS_ONLN); + if (ncpus <= 0) + return (1); +#else + return (1); +#endif +}