diff --git a/libc/Android.mk b/libc/Android.mk index 3ad5cd76c..984b24736 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -11,7 +11,6 @@ libc_common_src_files := \ unistd/exec.c \ unistd/fnmatch.c \ unistd/getopt_long.c \ - unistd/killpg.c \ unistd/popen.c \ unistd/syslog.c \ unistd/system.c \ @@ -80,19 +79,13 @@ libc_common_src_files := \ stdio/vsscanf.c \ stdio/wbuf.c \ stdio/wsetup.c \ - stdlib/assert.c \ stdlib/atexit.c \ - stdlib/bsearch.c \ stdlib/ctype_.c \ - stdlib/div.c \ stdlib/exit.c \ stdlib/getenv.c \ - stdlib/ldiv.c \ - stdlib/lldiv.c \ stdlib/putenv.c \ stdlib/qsort.c \ stdlib/setenv.c \ - stdlib/setjmperr.c \ stdlib/strtod.c \ stdlib/strtoimax.c \ stdlib/strtol.c \ @@ -169,7 +162,6 @@ libc_common_src_files := \ bionic/err.c \ bionic/ether_aton.c \ bionic/ether_ntoa.c \ - bionic/eventfd.c \ bionic/fcntl.c \ bionic/fdprintf.c \ bionic/flockfile.c \ @@ -258,8 +250,6 @@ libc_common_src_files := \ bionic/wait.c \ bionic/wcscoll.c \ netbsd/gethnamaddr.c \ - netbsd/isc/ev_timers.c \ - netbsd/isc/ev_streams.c \ netbsd/inet/nsap_addr.c \ netbsd/resolv/__dn_comp.c \ netbsd/resolv/__res_close.c \ @@ -289,6 +279,8 @@ libc_common_src_files := \ netbsd/nameser/ns_samedomain.c \ libc_bionic_src_files := \ + bionic/assert.cpp \ + bionic/eventfd.cpp \ bionic/__fgets_chk.cpp \ bionic/getcwd.cpp \ bionic/__memcpy_chk.cpp \ @@ -321,19 +313,26 @@ libc_upstream_netbsd_src_files := \ upstream-netbsd/libc/gen/nftw.c \ upstream-netbsd/libc/gen/nice.c \ upstream-netbsd/libc/gen/psignal.c \ + upstream-netbsd/libc/gen/setjmperr.c \ upstream-netbsd/libc/gen/utime.c \ upstream-netbsd/libc/inet/inet_ntoa.c \ upstream-netbsd/libc/inet/inet_ntop.c \ upstream-netbsd/libc/inet/inet_pton.c \ + upstream-netbsd/libc/isc/ev_streams.c \ + upstream-netbsd/libc/isc/ev_timers.c \ upstream-netbsd/libc/regex/regcomp.c \ upstream-netbsd/libc/regex/regerror.c \ upstream-netbsd/libc/regex/regexec.c \ upstream-netbsd/libc/regex/regfree.c \ upstream-netbsd/libc/stdio/getdelim.c \ upstream-netbsd/libc/stdio/getline.c \ + upstream-netbsd/libc/stdlib/bsearch.c \ + upstream-netbsd/libc/stdlib/div.c \ upstream-netbsd/libc/stdlib/drand48.c \ upstream-netbsd/libc/stdlib/erand48.c \ upstream-netbsd/libc/stdlib/jrand48.c \ + upstream-netbsd/libc/stdlib/ldiv.c \ + upstream-netbsd/libc/stdlib/lldiv.c \ upstream-netbsd/libc/stdlib/lrand48.c \ upstream-netbsd/libc/stdlib/mrand48.c \ upstream-netbsd/libc/stdlib/nrand48.c \ @@ -345,6 +344,7 @@ libc_upstream_netbsd_src_files := \ upstream-netbsd/libc/stdlib/tsearch.c \ upstream-netbsd/libc/string/strcasestr.c \ upstream-netbsd/libc/string/strxfrm.c \ + upstream-netbsd/libc/unistd/killpg.c \ # The following files are common, but must be compiled # with different C flags when building a static C library. @@ -763,6 +763,7 @@ LOCAL_SRC_FILES := $(libc_upstream_netbsd_src_files) LOCAL_CFLAGS := \ $(libc_common_cflags) \ -I$(LOCAL_PATH)/upstream-netbsd \ + -I$(LOCAL_PATH)/upstream-netbsd/libc/include \ -include upstream-netbsd/netbsd-compat.h LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_netbsd @@ -795,7 +796,9 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_common_src_files) -LOCAL_CFLAGS := $(libc_common_cflags) -std=gnu99 +LOCAL_CFLAGS := $(libc_common_cflags) \ + -std=gnu99 \ + -I$(LOCAL_PATH)/upstream-netbsd/libc/include # for netbsd private headers LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_common LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk diff --git a/libc/stdlib/assert.c b/libc/bionic/assert.cpp similarity index 100% rename from libc/stdlib/assert.c rename to libc/bionic/assert.cpp diff --git a/libc/bionic/eventfd.c b/libc/bionic/eventfd.cpp similarity index 100% rename from libc/bionic/eventfd.c rename to libc/bionic/eventfd.cpp diff --git a/libc/upstream-netbsd/fd_setsize.h b/libc/upstream-netbsd/fd_setsize.h new file mode 100644 index 000000000..e69de29bb diff --git a/libc/stdlib/setjmperr.c b/libc/upstream-netbsd/libc/gen/setjmperr.c similarity index 85% rename from libc/stdlib/setjmperr.c rename to libc/upstream-netbsd/libc/gen/setjmperr.c index 9a06cdc5f..5b1432e15 100644 --- a/libc/stdlib/setjmperr.c +++ b/libc/upstream-netbsd/libc/gen/setjmperr.c @@ -1,4 +1,5 @@ -/* $OpenBSD: setjmperr.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */ +/* $NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $ */ + /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. @@ -28,6 +29,15 @@ * SUCH DAMAGE. */ +#include +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)setjmperr.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + /* * This routine is called from longjmp() when an error occurs. * Programs that wish to exit gracefully from this error may diff --git a/libc/private/isc/assertions.h b/libc/upstream-netbsd/libc/include/isc/assertions.h similarity index 72% rename from libc/private/isc/assertions.h rename to libc/upstream-netbsd/libc/include/isc/assertions.h index 921d18fe9..7db7361d0 100644 --- a/libc/private/isc/assertions.h +++ b/libc/upstream-netbsd/libc/include/isc/assertions.h @@ -1,24 +1,24 @@ -/* $NetBSD: assertions.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */ +/* $NetBSD: assertions.h,v 1.5 2009/04/12 17:07:16 christos Exp $ */ /* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997-1999 by Internet Software Consortium. + * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1997-2001 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC 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. */ /* - * Id: assertions.h,v 1.1.206.1 2004/03/09 08:33:30 marka Exp + * Id: assertions.h,v 1.5 2008/11/14 02:36:51 marka Exp */ #ifndef ASSERTIONS_H @@ -31,24 +31,26 @@ typedef enum { typedef void (*assertion_failure_callback)(const char *, int, assertion_type, const char *, int); +/* coverity[+kill] */ extern assertion_failure_callback __assertion_failed; void set_assertion_failure_callback(assertion_failure_callback f); const char *assertion_type_to_text(assertion_type type); -#ifdef CHECK_ALL +#if defined(CHECK_ALL) || defined(__COVERITY__) #define CHECK_REQUIRE 1 #define CHECK_ENSURE 1 #define CHECK_INSIST 1 #define CHECK_INVARIANT 1 #endif -#ifdef CHECK_NONE +#if defined(CHECK_NONE) && !defined(__COVERITY__) #define CHECK_REQUIRE 0 #define CHECK_ENSURE 0 #define CHECK_INSIST 0 #define CHECK_INVARIANT 0 #endif +#ifdef _DIAGNOSTIC #ifndef CHECK_REQUIRE #define CHECK_REQUIRE 1 #endif @@ -64,6 +66,7 @@ const char *assertion_type_to_text(assertion_type type); #ifndef CHECK_INVARIANT #define CHECK_INVARIANT 1 #endif +#endif /* _DIAGNOSTIC */ #if CHECK_REQUIRE != 0 #define REQUIRE(cond) \ @@ -103,8 +106,13 @@ const char *assertion_type_to_text(assertion_type type); ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \ #cond, 1), 0))) #else +#if !defined(__lint__) #define INSIST(cond) ((void) (cond)) #define INSIST_ERR(cond) ((void) (cond)) +#else /* !__lint__ */ +#define INSIST(cond) +#define INSIST_ERR(cond) +#endif /* !__lint__ */ #endif /* CHECK_INSIST */ #if CHECK_INVARIANT != 0 @@ -120,5 +128,5 @@ const char *assertion_type_to_text(assertion_type type); #define INVARIANT(cond) ((void) (cond)) #define INVARIANT_ERR(cond) ((void) (cond)) #endif /* CHECK_INVARIANT */ - #endif /* ASSERTIONS_H */ +/*! \file */ diff --git a/libc/private/isc/dst.h b/libc/upstream-netbsd/libc/include/isc/dst.h similarity index 57% rename from libc/private/isc/dst.h rename to libc/upstream-netbsd/libc/include/isc/dst.h index afb071048..5537e3d73 100644 --- a/libc/private/isc/dst.h +++ b/libc/upstream-netbsd/libc/include/isc/dst.h @@ -1,19 +1,18 @@ -/* $NetBSD: dst.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */ +/* $NetBSD: dst.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $ */ #ifndef DST_H #define DST_H #ifndef HAS_DST_KEY typedef struct dst_key { - char *dk_key_name; /* name of the key */ - int dk_key_size; /* this is the size of the key in bits */ - int dk_proto; /* what protocols this key can be used for */ - int dk_alg; /* algorithm number from key record */ - u_int32_t dk_flags; /* and the flags of the public key */ - u_int16_t dk_id; /* identifier of the key */ + char *dk_key_name; /*%< name of the key */ + int dk_key_size; /*%< this is the size of the key in bits */ + int dk_proto; /*%< what protocols this key can be used for */ + int dk_alg; /*%< algorithm number from key record */ + u_int32_t dk_flags; /*%< and the flags of the public key */ + u_int16_t dk_id; /*%< identifier of the key */ } DST_KEY; #endif /* HAS_DST_KEY */ - /* * do not taint namespace */ @@ -61,58 +60,47 @@ typedef struct dst_key { void dst_init(void); int dst_check_algorithm(const int); -int dst_sign_data(const int, /* specifies INIT/UPDATE/FINAL/ALL */ - DST_KEY *, /* the key to use */ - void **, /* pointer to state structure */ - const u_char *, /* data to be signed */ - const int, /* length of input data */ - u_char *, /* buffer to write signature to */ - const int); /* size of output buffer */ - -int dst_verify_data(const int, /* specifies INIT/UPDATE/FINAL/ALL */ - DST_KEY *, /* the key to use */ - void **, /* pointer to state structure */ - const u_char *, /* data to be verified */ - const int, /* length of input data */ - const u_char *, /* buffer containing signature */ - const int); /* length of signature */ - - -DST_KEY *dst_read_key(const char *, /* name of key */ - const u_int16_t, /* key tag identifier */ - const int, /* key algorithm */ - const int); /* Private/PublicKey wanted*/ - -int dst_write_key(const DST_KEY *, /* key to write out */ - const int); /* Public/Private */ - -DST_KEY *dst_dnskey_to_key(const char *, /* KEY record name */ - const u_char *, /* KEY RDATA */ - const int); /* size of input buffer*/ - - -int dst_key_to_dnskey(const DST_KEY *, /* key to translate */ - u_char *, /* output buffer */ - const int); /* size of out_storage*/ - - -DST_KEY *dst_buffer_to_key(const char *, /* name of the key */ - const int, /* algorithm */ - const int, /* dns flags */ - const int, /* dns protocol */ - const u_char *, /* key in dns wire fmt */ - const int); /* size of key */ - +int dst_sign_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */ + DST_KEY *, /*!< the key to use */ + void **, /*!< pointer to state structure */ + const u_char *, /*!< data to be signed */ + const int, /*!< length of input data */ + u_char *, /*!< buffer to write signature to */ + const int); /*!< size of output buffer */ +int dst_verify_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */ + DST_KEY *, /*!< the key to use */ + void **, /*!< pointer to state structure */ + const u_char *, /*!< data to be verified */ + const int, /*!< length of input data */ + const u_char *, /*!< buffer containing signature */ + const int); /*!< length of signature */ +DST_KEY *dst_read_key(const char *, /*!< name of key */ + const u_int16_t, /*!< key tag identifier */ + const int, /*!< key algorithm */ + const int); /*!< Private/PublicKey wanted */ +int dst_write_key(const DST_KEY *, /*!< key to write out */ + const int); /*!< Public/Private */ +DST_KEY *dst_dnskey_to_key(const char *, /*!< KEY record name */ + const u_char *, /*!< KEY RDATA */ + const int); /*!< size of input buffer */ +int dst_key_to_dnskey(const DST_KEY *, /*!< key to translate */ + u_char *, /*!< output buffer */ + const int); /*!< size of out_storage */ +DST_KEY *dst_buffer_to_key(const char *, /*!< name of the key */ + const int, /*!< algorithm */ + const int, /*!< dns flags */ + const int, /*!< dns protocol */ + const u_char *, /*!< key in dns wire fmt */ + const int); /*!< size of key */ int dst_key_to_buffer(DST_KEY *, u_char *, int); -DST_KEY *dst_generate_key(const char *, /* name of new key */ - const int, /* key algorithm to generate */ - const int, /* size of new key */ - const int, /* alg dependent parameter*/ - const int, /* key DNS flags */ - const int); /* key DNS protocol */ - +DST_KEY *dst_generate_key(const char *, /*!< name of new key */ + const int, /*!< key algorithm to generate */ + const int, /*!< size of new key */ + const int, /*!< alg dependent parameter */ + const int, /*!< key DNS flags */ + const int); /*!< key DNS protocol */ DST_KEY *dst_free_key(DST_KEY *); int dst_compare_keys(const DST_KEY *, const DST_KEY *); @@ -124,13 +112,12 @@ u_int16_t dst_s_dns_key_id(const u_char *, const int); u_int16_t dst_s_id_calc(const u_char *, const int); /* Used by callers as well as by the library. */ -#define RAW_KEY_SIZE 8192 /* large enough to store any key */ - +#define RAW_KEY_SIZE 8192 /*%< large enough to store any key */ /* DST_API control flags */ /* These are used used in functions dst_sign_data and dst_verify_data */ -#define SIG_MODE_INIT 1 /* initialize digest */ -#define SIG_MODE_UPDATE 2 /* add data to digest */ -#define SIG_MODE_FINAL 4 /* generate/verify signature */ +#define SIG_MODE_INIT 1 /*%< initialize digest */ +#define SIG_MODE_UPDATE 2 /*%< add data to digest */ +#define SIG_MODE_FINAL 4 /*%< generate/verify signature */ #define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL) /* Flags for dst_read_private_key() */ @@ -180,3 +167,4 @@ u_int16_t dst_s_id_calc(const u_char *, const int); #define UNSUPPORTED_KEYALG (-31) #endif /* DST_H */ +/*! \file */ diff --git a/libc/private/isc/eventlib.h b/libc/upstream-netbsd/libc/include/isc/eventlib.h similarity index 88% rename from libc/private/isc/eventlib.h rename to libc/upstream-netbsd/libc/include/isc/eventlib.h index 9185f67a2..4e9cc2e40 100644 --- a/libc/private/isc/eventlib.h +++ b/libc/upstream-netbsd/libc/include/isc/eventlib.h @@ -1,26 +1,26 @@ -/* $NetBSD: eventlib.h,v 1.1.1.3 2005/12/21 23:15:22 christos Exp $ */ +/* $NetBSD: eventlib.h,v 1.3 2009/04/12 17:07:16 christos Exp $ */ /* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-1999 by Internet Software Consortium + * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1995-1999, 2001, 2003 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC 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. */ /* eventlib.h - exported interfaces for eventlib * vix 09sep95 [initial] * - * Id: eventlib.h,v 1.1.2.1.4.2 2005/07/28 07:43:18 marka Exp + * Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp */ #ifndef _EVENTLIB_H @@ -202,3 +202,5 @@ int evDefer __P((evContext, evWaitFunc, void *)); #endif #endif /*_EVENTLIB_H*/ + +/*! \file */ diff --git a/libc/private/isc/heap.h b/libc/upstream-netbsd/libc/include/isc/heap.h similarity index 95% rename from libc/private/isc/heap.h rename to libc/upstream-netbsd/libc/include/isc/heap.h index ea5a6e9d3..30cec98f2 100644 --- a/libc/private/isc/heap.h +++ b/libc/upstream-netbsd/libc/include/isc/heap.h @@ -1,4 +1,4 @@ -/* $NetBSD: heap.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */ +/* $NetBSD: heap.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -47,3 +47,5 @@ int heap_increased(heap_context, int); int heap_decreased(heap_context, int); void * heap_element(heap_context, int); int heap_for_each(heap_context, heap_for_each_func, void *); + +/*! \file */ diff --git a/libc/private/isc/list.h b/libc/upstream-netbsd/libc/include/isc/list.h similarity index 93% rename from libc/private/isc/list.h rename to libc/upstream-netbsd/libc/include/isc/list.h index 489766a9f..46f2e79be 100644 --- a/libc/private/isc/list.h +++ b/libc/upstream-netbsd/libc/include/isc/list.h @@ -1,4 +1,4 @@ -/* $NetBSD: list.h,v 1.2 2004/05/20 19:51:55 christos Exp $ */ +/* $NetBSD: list.h,v 1.5 2009/04/12 17:07:16 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -33,7 +33,8 @@ } while (/*CONSTCOND*/0) #define INIT_LINK(elt, link) \ INIT_LINK_TYPE(elt, link, void) -#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1)) +#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1) && \ + (void *)((elt)->link.next) != (void *)(-1)) #define HEAD(list) ((list).head) #define TAIL(list) ((list).tail) @@ -68,12 +69,16 @@ INSIST(LINKED(elt, link));\ if ((elt)->link.next != NULL) \ (elt)->link.next->link.prev = (elt)->link.prev; \ - else \ + else { \ + INSIST((list).tail == (elt)); \ (list).tail = (elt)->link.prev; \ + } \ if ((elt)->link.prev != NULL) \ (elt)->link.prev->link.next = (elt)->link.next; \ - else \ + else { \ + INSIST((list).head == (elt)); \ (list).head = (elt)->link.next; \ + } \ INIT_LINK_TYPE(elt, link, type); \ } while (/*CONSTCOND*/0) #define UNLINK(list, elt, link) \ @@ -112,3 +117,4 @@ #define DEQUEUE(list, elt, link) UNLINK(list, elt, link) #endif /* LIST_H */ +/*! \file */ diff --git a/libc/private/isc/memcluster.h b/libc/upstream-netbsd/libc/include/isc/memcluster.h similarity index 95% rename from libc/private/isc/memcluster.h rename to libc/upstream-netbsd/libc/include/isc/memcluster.h index edaaf20e8..3c1b489cb 100644 --- a/libc/private/isc/memcluster.h +++ b/libc/upstream-netbsd/libc/include/isc/memcluster.h @@ -1,4 +1,4 @@ -/* $NetBSD: memcluster.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */ +/* $NetBSD: memcluster.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -49,3 +49,4 @@ void memstats(FILE *); int memactive(void); #endif /* MEMCLUSTER_H */ +/*! \file */ diff --git a/libc/netbsd/isc/ev_streams.c b/libc/upstream-netbsd/libc/isc/ev_streams.c similarity index 95% rename from libc/netbsd/isc/ev_streams.c rename to libc/upstream-netbsd/libc/isc/ev_streams.c index aeecc3e14..2804b9f5b 100644 --- a/libc/netbsd/isc/ev_streams.c +++ b/libc/upstream-netbsd/libc/isc/ev_streams.c @@ -1,4 +1,4 @@ -/* $NetBSD: ev_streams.c,v 1.2 2004/05/20 19:52:31 christos Exp $ */ +/* $NetBSD: ev_streams.c,v 1.6 2009/04/12 17:07:17 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -24,20 +24,26 @@ #include #if !defined(LINT) && !defined(CODECENTER) && !defined(lint) #ifdef notdef -static const char rcsid[] = "Id: ev_streams.c,v 1.2.206.2 2004/03/17 00:29:51 marka Exp"; +static const char rcsid[] = "Id: ev_streams.c,v 1.5 2005/04/27 04:56:36 sra Exp"; #else -__RCSID("$NetBSD: ev_streams.c,v 1.2 2004/05/20 19:52:31 christos Exp $"); +__RCSID("$NetBSD: ev_streams.c,v 1.6 2009/04/12 17:07:17 christos Exp $"); #endif #endif +#include "port_before.h" +#include "fd_setsize.h" + #include #include #include #include +#include #include "eventlib_p.h" +#include "port_after.h" + #ifndef _LIBC static int copyvec(evStream *str, const struct iovec *iov, int iocnt); static void consume(evStream *str, size_t bytes); @@ -309,3 +315,5 @@ readable(evContext opaqueCtx, void *uap, int fd, int evmask) { done(opaqueCtx, str); } #endif + +/*! \file */ diff --git a/libc/netbsd/isc/ev_timers.c b/libc/upstream-netbsd/libc/isc/ev_timers.c similarity index 91% rename from libc/netbsd/isc/ev_timers.c rename to libc/upstream-netbsd/libc/isc/ev_timers.c index a584f9979..40521a78d 100644 --- a/libc/netbsd/isc/ev_timers.c +++ b/libc/upstream-netbsd/libc/isc/ev_timers.c @@ -1,4 +1,4 @@ -/* $NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $ */ +/* $NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -24,21 +24,25 @@ #include #if !defined(LINT) && !defined(CODECENTER) && !defined(lint) #ifdef notdef -static const char rcsid[] = "Id: ev_timers.c,v 1.2.2.1.4.5 2004/03/17 02:39:13 marka Exp"; +static const char rcsid[] = "Id: ev_timers.c,v 1.6 2005/04/27 04:56:36 sra Exp"; #else -__RCSID("$NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $"); +__RCSID("$NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $"); #endif #endif /* Import. */ +#include "port_before.h" +#include "fd_setsize.h" + #include -#include #include #include #include "eventlib_p.h" +#include "port_after.h" + /* Constants. */ #define MILLION 1000000 @@ -104,29 +108,36 @@ evSubTime(struct timespec minuend, struct timespec subtrahend) { int evCmpTime(struct timespec a, struct timespec b) { - long x = a.tv_sec - b.tv_sec; +#define SGN(x) ((x) < 0 ? (-1) : (x) > 0 ? (1) : (0)); + time_t s = a.tv_sec - b.tv_sec; + long n; - if (x == 0L) - x = a.tv_nsec - b.tv_nsec; - return (x < 0L ? (-1) : x > 0L ? (1) : (0)); + if (s != 0) + return SGN(s); + + n = a.tv_nsec - b.tv_nsec; + return SGN(n); } struct timespec -evNowTime() { +evNowTime(void) +{ struct timeval now; #ifdef CLOCK_REALTIME struct timespec tsnow; int m = CLOCK_REALTIME; #ifdef CLOCK_MONOTONIC +#ifndef _LIBC if (__evOptMonoTime) m = CLOCK_MONOTONIC; +#endif #endif if (clock_gettime(m, &tsnow) == 0) return (tsnow); #endif if (gettimeofday(&now, NULL) < 0) - return (evConsTime(0L, 0L)); + return (evConsTime((time_t)0, 0L)); return (evTimeSpec(now)); } @@ -139,7 +150,7 @@ evUTCTime(void) { return (tsnow); #endif if (gettimeofday(&now, NULL) < 0) - return (evConsTime(0L, 0L)); + return (evConsTime((time_t)0, 0L)); return (evTimeSpec(now)); } @@ -166,7 +177,7 @@ evTimeVal(struct timespec ts) { struct timeval tv; tv.tv_sec = ts.tv_sec; - tv.tv_usec = ts.tv_nsec / 1000; + tv.tv_usec = (suseconds_t)(ts.tv_nsec / 1000); return (tv); } @@ -182,7 +193,8 @@ evSetTimer(evContext opaqueCtx, evContext_p *ctx = opaqueCtx.opaque; evTimer *id; - printf("evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n", + evPrintf(ctx, 1, +"evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n", ctx, func, uap, (long)due.tv_sec, due.tv_nsec, (long)inter.tv_sec, inter.tv_nsec); @@ -223,7 +235,7 @@ evSetTimer(evContext opaqueCtx, opaqueID->opaque = id; if (ctx->debug > 7) { - printf("timers after evSetTimer:\n"); + evPrintf(ctx, 7, "timers after evSetTimer:\n"); (void) heap_for_each(ctx->timers, print_timer, (void *)ctx); } @@ -238,7 +250,7 @@ evClearTimer(evContext opaqueCtx, evTimerID id) { if (ctx->cur != NULL && ctx->cur->type == Timer && ctx->cur->u.timer.this == del) { - printf("deferring delete of timer (executing)\n"); + evPrintf(ctx, 8, "deferring delete of timer (executing)\n"); /* * Setting the interval to zero ensures that evDrop() will * clean up the timer. @@ -255,7 +267,7 @@ evClearTimer(evContext opaqueCtx, evTimerID id) { FREE(del); if (ctx->debug > 7) { - printf("timers after evClearTimer:\n"); + evPrintf(ctx, 7, "timers after evClearTimer:\n"); (void) heap_for_each(ctx->timers, print_timer, (void *)ctx); } @@ -340,7 +352,7 @@ evResetTimer(evContext opaqueCtx, } if (ctx->debug > 7) { - printf("timers after evResetTimer:\n"); + evPrintf(ctx, 7, "timers after evResetTimer:\n"); (void) heap_for_each(ctx->timers, print_timer, (void *)ctx); } @@ -503,3 +515,5 @@ idle_timeout(evContext opaqueCtx, } } #endif + +/*! \file */ diff --git a/libc/netbsd/isc/eventlib_p.h b/libc/upstream-netbsd/libc/isc/eventlib_p.h similarity index 67% rename from libc/netbsd/isc/eventlib_p.h rename to libc/upstream-netbsd/libc/isc/eventlib_p.h index 7edc5a0d3..4d6b78855 100644 --- a/libc/netbsd/isc/eventlib_p.h +++ b/libc/upstream-netbsd/libc/isc/eventlib_p.h @@ -1,7 +1,7 @@ -/* $NetBSD: eventlib_p.h,v 1.1.1.1 2004/05/20 19:34:32 christos Exp $ */ +/* $NetBSD: eventlib_p.h,v 1.3 2009/04/12 17:07:17 christos Exp $ */ /* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1995-1999 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -17,10 +17,11 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* eventlib_p.h - private interfaces for eventlib - * vix 09sep95 [initial] +/*! \file + * \brief private interfaces for eventlib + * \author vix 09sep95 [initial] * - * Id: eventlib_p.h,v 1.3.2.1.4.1 2004/03/09 08:33:43 marka Exp + * Id: eventlib_p.h,v 1.9 2006/03/09 23:57:56 marka Exp */ #ifndef _EVENTLIB_P_H @@ -44,13 +45,12 @@ #include #include - #define EV_MASK_ALL (EV_READ | EV_WRITE | EV_EXCEPT) #define EV_ERR(e) return (errno = (e), -1) #define OK(x) if ((x) < 0) EV_ERR(errno); else (void)NULL +#define OKFREE(x, y) if ((x) < 0) { FREE((y)); EV_ERR(errno); } \ + else (void)NULL - -#if HAVE_MEM_GET_SET #define NEW(p) if (((p) = memget(sizeof *(p))) != NULL) \ FILL(p); \ else \ @@ -68,24 +68,21 @@ #define FILL(p) #endif -#else - -#define NEW(p) p = malloc(sizeof *(p)); -#define OKNEW(p) if (!((p) = malloc(sizeof *(p)))) { errno = ENOMEM; return (-1); } -#define FREE(p) free(p) -#define FILL(p) - +#ifdef USE_POLL +#ifdef HAVE_STROPTS_H +#include #endif - +#include +#endif /* USE_POLL */ typedef struct evConn { evConnFunc func; void * uap; int fd; int flags; -#define EV_CONN_LISTEN 0x0001 /* Connection is a listener. */ -#define EV_CONN_SELECTED 0x0002 /* evSelectFD(conn->file). */ -#define EV_CONN_BLOCK 0x0004 /* Listener fd was blocking. */ +#define EV_CONN_LISTEN 0x0001 /*%< Connection is a listener. */ +#define EV_CONN_SELECTED 0x0002 /*%< evSelectFD(conn->file). */ +#define EV_CONN_BLOCK 0x0004 /*%< Listener fd was blocking. */ evFileID file; struct evConn * prev; struct evConn * next; @@ -100,7 +97,7 @@ typedef struct evAccept { struct sockaddr_un un; #endif } la; - socklen_t lalen; + ISC_SOCKLEN_T lalen; union { struct sockaddr sa; struct sockaddr_in in; @@ -108,7 +105,7 @@ typedef struct evAccept { struct sockaddr_un un; #endif } ra; - socklen_t ralen; + ISC_SOCKLEN_T ralen; int ioErrno; evConn * conn; LINK(struct evAccept) link; @@ -132,7 +129,7 @@ typedef struct evStream { evFileID file; evTimerID timer; int flags; -#define EV_STR_TIMEROK 0x0001 /* IFF timer valid. */ +#define EV_STR_TIMEROK 0x0001 /*%< IFF timer valid. */ int fd; struct iovec * iovOrig; int iovOrigCount; @@ -181,6 +178,40 @@ typedef struct evEvent_p { } u; } evEvent_p; +#ifdef USE_POLL +typedef struct { + void *ctx; /* pointer to the evContext_p */ + uint32_t type; /* READ, WRITE, EXCEPT, nonblk */ + uint32_t result; /* 1 => revents, 0 => events */ +} __evEmulMask; + +#define emulMaskInit(ctx, field, ev, lastnext) \ + ctx->field.ctx = ctx; \ + ctx->field.type = ev; \ + ctx->field.result = lastnext; + +extern short *__fd_eventfield(int fd, __evEmulMask *maskp); +extern short __poll_event(__evEmulMask *maskp); +extern void __fd_clr(int fd, __evEmulMask *maskp); +extern void __fd_set(int fd, __evEmulMask *maskp); + +#undef FD_ZERO +#define FD_ZERO(maskp) + +#undef FD_SET +#define FD_SET(fd, maskp) \ + __fd_set(fd, maskp) + +#undef FD_CLR +#define FD_CLR(fd, maskp) \ + __fd_clr(fd, maskp) + +#undef FD_ISSET +#define FD_ISSET(fd, maskp) \ + ((*__fd_eventfield(fd, maskp) & __poll_event(maskp)) != 0) + +#endif /* USE_POLL */ + typedef struct { /* Global. */ const evEvent_p *cur; @@ -192,12 +223,26 @@ typedef struct { LIST(evAccept) accepts; /* Files. */ evFile *files, *fdNext; +#ifndef USE_POLL fd_set rdLast, rdNext; fd_set wrLast, wrNext; fd_set exLast, exNext; fd_set nonblockBefore; int fdMax, fdCount, highestFD; evFile *fdTable[FD_SETSIZE]; +#else + struct pollfd *pollfds; /* Allocated as needed */ + evFile **fdTable; /* Ditto */ + int maxnfds; /* # elements in above */ + int firstfd; /* First active fd */ + int fdMax; /* Last active fd */ + int fdCount; /* # fd:s with I/O */ + int highestFD; /* max fd allowed by OS */ + __evEmulMask rdLast, rdNext; + __evEmulMask wrLast, wrNext; + __evEmulMask exLast, exNext; + __evEmulMask nonblockBefore; +#endif /* USE_POLL */ #ifdef EVENTLIB_TIME_CHECKS struct timespec lastSelectTime; int lastFdCount; @@ -215,7 +260,12 @@ typedef struct { /* eventlib.c */ #define evPrintf __evPrintf -void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...); +void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...) + ISC_FORMAT_PRINTF(3, 4); + +#ifdef USE_POLL +extern int evPollfdRealloc(evContext_p *ctx, int pollfd_chunk_size, int fd); +#endif /* USE_POLL */ /* ev_timers.c */ #define evCreateTimers __evCreateTimers @@ -228,6 +278,6 @@ void evDestroyTimers(const evContext_p *); evWait *evFreeWait(evContext_p *ctx, evWait *old); /* Global options */ -int __evOptMonoTime; +extern int __evOptMonoTime; #endif /*_EVENTLIB_P_H*/ diff --git a/libc/stdlib/bsearch.c b/libc/upstream-netbsd/libc/stdlib/bsearch.c similarity index 79% rename from libc/stdlib/bsearch.c rename to libc/upstream-netbsd/libc/stdlib/bsearch.c index 7eb63255f..2b0e0d86f 100644 --- a/libc/stdlib/bsearch.c +++ b/libc/upstream-netbsd/libc/stdlib/bsearch.c @@ -1,6 +1,8 @@ +/* $NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $ */ + /* - * Copyright (c) 1990 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,6 +29,17 @@ * SUCH DAMAGE. */ +#include +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)bsearch.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + +#include +#include #include /* @@ -50,18 +63,23 @@ bsearch(const void *key, const void *base0, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { const char *base = base0; - int lim, cmp; + size_t lim; + int cmp; const void *p; + _DIAGASSERT(key != NULL); + _DIAGASSERT(base0 != NULL || nmemb == 0); + _DIAGASSERT(compar != NULL); + for (lim = nmemb; lim != 0; lim >>= 1) { p = base + (lim >> 1) * size; cmp = (*compar)(key, p); + if (cmp == 0) + return __UNCONST(p); if (cmp > 0) { /* key > p: move right */ - base = (char *)p + size; + base = (const char *)p + size; lim--; - } else if (cmp == 0) { - return ((void *)p); - } /* else move left */ + } /* else move left */ } return (NULL); } diff --git a/libc/stdlib/div.c b/libc/upstream-netbsd/libc/stdlib/div.c similarity index 87% rename from libc/stdlib/div.c rename to libc/upstream-netbsd/libc/stdlib/div.c index f7ac2db4b..f3bd32f26 100644 --- a/libc/stdlib/div.c +++ b/libc/upstream-netbsd/libc/stdlib/div.c @@ -1,7 +1,8 @@ -/* $OpenBSD: div.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* $NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */ + /* - * Copyright (c) 1990 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. @@ -31,6 +32,15 @@ * SUCH DAMAGE. */ +#include +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)div.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + #include /* div_t */ div_t diff --git a/libc/stdlib/ldiv.c b/libc/upstream-netbsd/libc/stdlib/ldiv.c similarity index 81% rename from libc/stdlib/ldiv.c rename to libc/upstream-netbsd/libc/stdlib/ldiv.c index 775065f52..507c831bf 100644 --- a/libc/stdlib/ldiv.c +++ b/libc/upstream-netbsd/libc/stdlib/ldiv.c @@ -1,7 +1,8 @@ -/* $OpenBSD: ldiv.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* $NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */ + /* - * Copyright (c) 1990 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. @@ -31,6 +32,15 @@ * SUCH DAMAGE. */ +#include +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)ldiv.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + #include /* ldiv_t */ ldiv_t diff --git a/libc/stdlib/lldiv.c b/libc/upstream-netbsd/libc/stdlib/lldiv.c similarity index 76% rename from libc/stdlib/lldiv.c rename to libc/upstream-netbsd/libc/stdlib/lldiv.c index e8d6c978b..47104b378 100644 --- a/libc/stdlib/lldiv.c +++ b/libc/upstream-netbsd/libc/stdlib/lldiv.c @@ -1,7 +1,8 @@ -/* $OpenBSD: lldiv.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ +/* $NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $ */ + /* - * Copyright (c) 1990 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. @@ -31,10 +32,25 @@ * SUCH DAMAGE. */ +#include +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "from: @(#)ldiv.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" #include /* lldiv_t */ +#ifdef __weak_alias +__weak_alias(lldiv, _lldiv) +#endif + +/* LONGLONG */ lldiv_t -lldiv(long long num, long long denom) +lldiv(long long int num, long long int denom) { lldiv_t r; diff --git a/libc/unistd/killpg.c b/libc/upstream-netbsd/libc/unistd/killpg.c similarity index 80% rename from libc/unistd/killpg.c rename to libc/upstream-netbsd/libc/unistd/killpg.c index 75b1ad98a..ceac3f486 100644 --- a/libc/unistd/killpg.c +++ b/libc/upstream-netbsd/libc/unistd/killpg.c @@ -1,6 +1,8 @@ +/* $NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $ */ + /* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,6 +29,15 @@ * SUCH DAMAGE. */ +#include +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)killpg.c 8.1 (Berkeley) 6/2/93"; +#else +__RCSID("$NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + #include #include #include diff --git a/libc/upstream-netbsd/port_before.h b/libc/upstream-netbsd/port_before.h index 87af595f2..70eed2687 100644 --- a/libc/upstream-netbsd/port_before.h +++ b/libc/upstream-netbsd/port_before.h @@ -21,4 +21,7 @@ #include #include +#define ISC_FORMAT_PRINTF(a,b) __attribute__((__format__(__printf__,a,b))) +#define ISC_SOCKLEN_T socklen_t + #endif