Commit 386a52a5 authored by Brian Wellington's avatar Brian Wellington

Add isc/unix/os.c, which has isc_os_ncpus()

parent 7005cfed
......@@ -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@
......
......@@ -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 \
......
/*
* 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.h>
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 */
......@@ -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}
......
/*
* 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 <config.h>
#include <unistd.h>
#include <isc/os.h>
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
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment