From: Alex Hornung Date: Sun, 18 Apr 2010 18:00:19 +0000 (+0000) Subject: proplib - port to dragonfly X-Git-Tag: v2.9.0~953 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/9f95f3e011845db37485e8cbbeb48b49de992957 proplib - port to dragonfly Many-thanks-to: Sascha Wildner --- diff --git a/Makefile.inc1 b/Makefile.inc1 index 7c302ead05..b7ef4b715b 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -890,7 +890,8 @@ _generic_libs= gnu/lib _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \ lib/libncurses/libncurses lib/libopie lib/libradius \ lib/libsbuf lib/libtacplus lib/libm \ - lib/libpam lib/libypclnt lib/lib${THREAD_LIB} + lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \ + lib/libpthread lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L diff --git a/common/include/prop/CVS/Entries b/common/include/prop/CVS/Entries deleted file mode 100644 index 4218e77564..0000000000 --- a/common/include/prop/CVS/Entries +++ /dev/null @@ -1,12 +0,0 @@ -/Makefile/1.3/Mon Aug 20 16:54:32 2007// -/plistref.h/1.2/Fri May 2 00:57:09 2008// -/prop_bool.h/1.4/Fri May 2 00:57:09 2008// -/prop_data.h/1.3/Fri May 2 00:57:09 2008// -/prop_ingest.h/1.3/Fri May 2 00:57:09 2008// -/prop_number.h/1.6/Fri May 2 00:57:09 2008// -/prop_string.h/1.3/Fri May 2 00:57:09 2008// -/prop_object.h/1.8/Tue Dec 9 19:27:22 2008// -/proplib.h/1.7/Wed Sep 16 21:31:10 2009// -/prop_array.h/1.9/Wed Oct 14 20:29:37 2009// -/prop_dictionary.h/1.10/Wed Oct 14 20:29:37 2009// -D diff --git a/common/include/prop/CVS/Repository b/common/include/prop/CVS/Repository deleted file mode 100644 index 52bad24d5c..0000000000 --- a/common/include/prop/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -src/common/include/prop diff --git a/common/include/prop/CVS/Root b/common/include/prop/CVS/Root deleted file mode 100644 index a31a411d60..0000000000 --- a/common/include/prop/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/archive/NetBSD-CVS diff --git a/common/lib/libprop/CVS/Entries b/common/lib/libprop/CVS/Entries deleted file mode 100644 index 71d7cb4fcd..0000000000 --- a/common/lib/libprop/CVS/Entries +++ /dev/null @@ -1,31 +0,0 @@ -/prop_stack.c/1.2/Wed Sep 12 20:23:13 2007// -/prop_stack.h/1.2/Wed Sep 12 20:23:13 2007// -/prop_dictionary_util.c/1.3/Fri May 2 00:57:13 2008// -/prop_ingest.c/1.3/Fri May 2 00:57:13 2008// -/prop_number.3/1.9/Fri May 2 00:57:13 2008// -/prop_object.3/1.7/Fri May 2 00:57:13 2008// -/prop_send_ioctl.3/1.5/Fri May 2 00:57:14 2008// -/prop_dictionary_util.3/1.4/Mon Jun 2 17:12:13 2008// -/prop_rb.c/1.9/Wed Jun 18 10:46:26 2008// -/Makefile.inc/1.8/Sat Jul 26 07:53:00 2008// -/prop_rb_impl.h/1.7/Sat Jul 26 07:53:01 2008// -/prop_bool.3/1.6/Sun Aug 3 12:06:35 2008// -/prop_string.c/1.11/Sun Aug 3 12:06:35 2008// -/prop_array.c/1.20/Mon Aug 11 12:15:57 2008// -/prop_array_util.3/1.3/Fri Sep 12 12:36:01 2008// -/prop_array_util.c/1.2/Fri Sep 12 12:36:01 2008// -/prop_bool.c/1.17/Wed Jan 7 13:47:30 2009// -/prop_data.c/1.14/Tue Jan 27 15:04:32 2009// -/prop_number.c/1.22/Tue Mar 17 12:30:29 2009// -/prop_object.c/1.26/Tue Mar 31 12:51:15 2009// -/prop_dictionary.c/1.35/Wed Apr 15 14:56:17 2009// -/proplib.3/1.6/Fri May 15 14:14:42 2009// -/prop_object_impl.h/1.30/Wed Sep 16 21:31:22 2009// -/prop_kern.c/1.13/Wed Oct 14 20:29:48 2009// -/prop_dictionary.3/1.15/Mon Dec 7 22:11:23 2009// -/prop_array.3/1.11/Thu Dec 17 21:46:34 2009// -/prop_copyin_ioctl.9/1.7/Thu Dec 17 21:46:34 2009// -/prop_data.3/1.7/Thu Dec 17 21:46:34 2009// -/prop_string.3/1.7/Thu Dec 17 21:46:34 2009// -/prop_ingest.3/1.6/Fri Feb 19 12:29:47 2010// -D diff --git a/common/lib/libprop/CVS/Repository b/common/lib/libprop/CVS/Repository deleted file mode 100644 index 7e24249aa8..0000000000 --- a/common/lib/libprop/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -src/common/lib/libprop diff --git a/common/lib/libprop/CVS/Root b/common/lib/libprop/CVS/Root deleted file mode 100644 index a31a411d60..0000000000 --- a/common/lib/libprop/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/archive/NetBSD-CVS diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index f386262e67..967a1fc0de 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -96,6 +96,8 @@ .. libmilter .. + libprop + .. machine pc .. diff --git a/include/Makefile b/include/Makefile index 909ff94d75..8b169b4915 100644 --- a/include/Makefile +++ b/include/Makefile @@ -76,7 +76,7 @@ LSUBDIRS= bus/cam bus/cam/scsi \ dev/misc/lpt dev/misc/ppi \ dev/netif/wi \ dev/raid/ciss \ - dev/video/bktr dev/video/meteor + dev/video/bktr dev/video/meteor libprop # For SHARED=symlinks, bus/cam and netproto/atm are symlinks, so cam/scsi # and netproto/atm/* are taken care of diff --git a/lib/Makefile b/lib/Makefile index fa7a7ad1fe..343db4e99d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -15,6 +15,7 @@ # libsbuf must be built before libcam. # libthread_xu must be built before libpthread. # ${_libc_r} must be built before libpthread. +# libpthread must be built before libprop. # # Otherwise, the SUBDIR list should be in alphabetical order. @@ -27,7 +28,8 @@ SUBDIR= csu \ libftpio libipsec libipx libkcore libkiconv libkinfo \ libkvm libmagic \ ${_libmilter} ${_libncp} libnetgraph libopie libpam \ - libpcap libposix1e libsdp libthread_xu libpthread librpcsvc ${_libsm} \ + libpcap libposix1e libsdp libthread_xu libpthread libprop \ + librpcsvc ${_libsm} \ ${_libsmb} ${_libsmdb} ${_libsmutil} libstand libtelnet libusbhid \ ${_libvgl} libwrap libxpg4 liby libypclnt libz i18n_module pam_module \ libc_rtld libsctp libevtr diff --git a/lib/libprop/Makefile b/lib/libprop/Makefile new file mode 100644 index 0000000000..686db776d2 --- /dev/null +++ b/lib/libprop/Makefile @@ -0,0 +1,182 @@ +# $NetBSD: Makefile,v 1.17 2009/10/10 18:06:54 bad Exp $ + +.include + +WARNS=0 +USE_SHLIBDIR= yes + +PROPLIBDIR=${.CURDIR}/../../sys/libprop +.PATH: ${PROPLIBDIR} + +CFLAGS+=-D_LIBPROP +CFLAGS+=-D_REENTRANT -I${.CURDIR}/../../sys -I${.CURDIR}/../../../lib/libc/include +LDADD+=-lpthread +DPADD+=${LIBPTHREAD} + +SRCS+= prop_array.c prop_array_util.c prop_bool.c prop_data.c \ + prop_dictionary.c prop_dictionary_util.c prop_ingest.c \ + prop_kern.c prop_number.c prop_object.c prop_stack.c \ + prop_rb.c prop_string.c + +LIB= prop + +MAN= prop_array.3 prop_bool.3 prop_data.3 prop_dictionary.3 \ + prop_ingest.3 prop_number.3 prop_object.3 prop_string.3 proplib.3 + +MAN+= prop_send_ioctl.3 +MLINKS+= prop_send_ioctl.3 prop_array_send_ioctl.3 +MLINKS+= prop_send_ioctl.3 prop_array_recv_ioctl.3 +MLINKS+= prop_send_ioctl.3 prop_dictionary_send_ioctl.3 +MLINKS+= prop_send_ioctl.3 prop_dictionary_recv_ioctl.3 +MLINKS+= prop_send_ioctl.3 prop_dictionary_sendrecv_ioctl.3 + +MAN+= prop_dictionary_util.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_bool.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_bool.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_int8.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_uint8.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_int8.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_uint8.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_int16.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_uint16.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_int16.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_uint16.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_int32.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_uint32.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_int32.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_uint32.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_int64.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_uint64.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_int64.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_uint64.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_cstring.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_cstring.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_get_cstring_nocopy.3 +MLINKS+= prop_dictionary_util.3 prop_dictionary_set_cstring_nocopy.3 + +MLINKS+= prop_array.3 prop_array_add.3 +MLINKS+= prop_array.3 prop_array_capacity.3 +MLINKS+= prop_array.3 prop_array_copy.3 +MLINKS+= prop_array.3 prop_array_copy_mutable.3 +MLINKS+= prop_array.3 prop_array_count.3 +MLINKS+= prop_array.3 prop_array_create.3 +MLINKS+= prop_array.3 prop_array_create_with_capacity.3 +MLINKS+= prop_array.3 prop_array_ensure_capacity.3 +MLINKS+= prop_array.3 prop_array_equals.3 +MLINKS+= prop_array.3 prop_array_externalize.3 +MLINKS+= prop_array.3 prop_array_externalize_to_file.3 +MLINKS+= prop_array.3 prop_array_externalize_to_pref.3 +MLINKS+= prop_array.3 prop_array_get.3 +MLINKS+= prop_array.3 prop_array_internalize.3 +MLINKS+= prop_array.3 prop_array_internalize_from_file.3 +MLINKS+= prop_array.3 prop_array_iterator.3 +MLINKS+= prop_array.3 prop_array_make_immutable.3 +MLINKS+= prop_array.3 prop_array_mutable.3 +MLINKS+= prop_array.3 prop_array_remove.3 +MLINKS+= prop_array.3 prop_array_set.3 + +MAN+= prop_array_util.3 +MLINKS+= prop_array_util.3 prop_array_get_bool.3 +MLINKS+= prop_array_util.3 prop_array_set_bool.3 +MLINKS+= prop_array_util.3 prop_array_get_int8.3 +MLINKS+= prop_array_util.3 prop_array_get_uint8.3 +MLINKS+= prop_array_util.3 prop_array_set_int8.3 +MLINKS+= prop_array_util.3 prop_array_set_uint8.3 +MLINKS+= prop_array_util.3 prop_array_get_int16.3 +MLINKS+= prop_array_util.3 prop_array_get_uint16.3 +MLINKS+= prop_array_util.3 prop_array_set_int16.3 +MLINKS+= prop_array_util.3 prop_array_set_uint16.3 +MLINKS+= prop_array_util.3 prop_array_get_int32.3 +MLINKS+= prop_array_util.3 prop_array_get_uint32.3 +MLINKS+= prop_array_util.3 prop_array_set_int32.3 +MLINKS+= prop_array_util.3 prop_array_set_uint32.3 +MLINKS+= prop_array_util.3 prop_array_get_int64.3 +MLINKS+= prop_array_util.3 prop_array_get_uint64.3 +MLINKS+= prop_array_util.3 prop_array_set_int64.3 +MLINKS+= prop_array_util.3 prop_array_set_uint64.3 +MLINKS+= prop_array_util.3 prop_array_get_cstring.3 +MLINKS+= prop_array_util.3 prop_array_set_cstring.3 +MLINKS+= prop_array_util.3 prop_array_get_cstring_nocopy.3 +MLINKS+= prop_array_util.3 prop_array_set_cstring_nocopy.3 + +MLINKS+= prop_bool.3 prop_bool_copy.3 +MLINKS+= prop_bool.3 prop_bool_create.3 +MLINKS+= prop_bool.3 prop_bool_true.3 + +MLINKS+= prop_data.3 prop_data_copy.3 +MLINKS+= prop_data.3 prop_data_create_data.3 +MLINKS+= prop_data.3 prop_data_create_data_nocopy.3 +MLINKS+= prop_data.3 prop_data_data.3 +MLINKS+= prop_data.3 prop_data_data_nocopy.3 +MLINKS+= prop_data.3 prop_data_equals.3 +MLINKS+= prop_data.3 prop_data_equals_data.3 +MLINKS+= prop_data.3 prop_data_size.3 + +MLINKS+= prop_dictionary.3 prop_dictionary_all_keys.3 +MLINKS+= prop_dictionary.3 prop_dictionary_capacity.3 +MLINKS+= prop_dictionary.3 prop_dictionary_copy.3 +MLINKS+= prop_dictionary.3 prop_dictionary_copy_mutable.3 +MLINKS+= prop_dictionary.3 prop_dictionary_count.3 +MLINKS+= prop_dictionary.3 prop_dictionary_create.3 +MLINKS+= prop_dictionary.3 prop_dictionary_create_with_capacity.3 +MLINKS+= prop_dictionary.3 prop_dictionary_ensure_capacity.3 +MLINKS+= prop_dictionary.3 prop_dictionary_equals.3 +MLINKS+= prop_dictionary.3 prop_dictionary_externalize.3 +MLINKS+= prop_dictionary.3 prop_dictionary_externalize_to_file.3 +MLINKS+= prop_dictionary.3 prop_dictionary_externalize_to_pref.3 +MLINKS+= prop_dictionary.3 prop_dictionary_get.3 +MLINKS+= prop_dictionary.3 prop_dictionary_get_keysym.3 +MLINKS+= prop_dictionary.3 prop_dictionary_internalize.3 +MLINKS+= prop_dictionary.3 prop_dictionary_internalize_from_file.3 +MLINKS+= prop_dictionary.3 prop_dictionary_iterator.3 +MLINKS+= prop_dictionary.3 prop_dictionary_keysym_cstring_nocopy.3 +MLINKS+= prop_dictionary.3 prop_dictionary_keysym_equals.3 +MLINKS+= prop_dictionary.3 prop_dictionary_make_immutable.3 +MLINKS+= prop_dictionary.3 prop_dictionary_mutable.3 +MLINKS+= prop_dictionary.3 prop_dictionary_remove.3 +MLINKS+= prop_dictionary.3 prop_dictionary_remove_keysym.3 +MLINKS+= prop_dictionary.3 prop_dictionary_set.3 +MLINKS+= prop_dictionary.3 prop_dictionary_set_keysym.3 + +MLINKS+= prop_ingest.3 prop_ingest_context_alloc.3 +MLINKS+= prop_ingest.3 prop_ingest_context_error.3 +MLINKS+= prop_ingest.3 prop_ingest_context_free.3 +MLINKS+= prop_ingest.3 prop_ingest_context_key.3 +MLINKS+= prop_ingest.3 prop_ingest_context_private.3 +MLINKS+= prop_ingest.3 prop_ingest_context_type.3 +MLINKS+= prop_ingest.3 prop_dictionary_ingest.3 + +MLINKS+= prop_number.3 prop_number_copy.3 +MLINKS+= prop_number.3 prop_number_create_integer.3 +MLINKS+= prop_number.3 prop_number_create_unsigned_integer.3 +MLINKS+= prop_number.3 prop_number_equals.3 +MLINKS+= prop_number.3 prop_number_equals_integer.3 +MLINKS+= prop_number.3 prop_number_equals_unsigned_integer.3 +MLINKS+= prop_number.3 prop_number_size.3 +MLINKS+= prop_number.3 prop_number_unsigned.3 +MLINKS+= prop_number.3 prop_number_integer_value.3 +MLINKS+= prop_number.3 prop_number_unsigned_integer_value.3 + +MLINKS+= prop_object.3 prop_object_equals.3 +MLINKS+= prop_object.3 prop_object_iterator_next.3 +MLINKS+= prop_object.3 prop_object_iterator_release.3 +MLINKS+= prop_object.3 prop_object_iterator_reset.3 +MLINKS+= prop_object.3 prop_object_release.3 +MLINKS+= prop_object.3 prop_object_retain.3 +MLINKS+= prop_object.3 prop_object_type.3 + +MLINKS+= prop_string.3 prop_string_append.3 +MLINKS+= prop_string.3 prop_string_append_cstring.3 +MLINKS+= prop_string.3 prop_string_copy.3 +MLINKS+= prop_string.3 prop_string_copy_mutable.3 +MLINKS+= prop_string.3 prop_string_create.3 +MLINKS+= prop_string.3 prop_string_create_cstring.3 +MLINKS+= prop_string.3 prop_string_create_cstring_nocopy.3 +MLINKS+= prop_string.3 prop_string_cstring.3 +MLINKS+= prop_string.3 prop_string_cstring_nocopy.3 +MLINKS+= prop_string.3 prop_string_equals.3 +MLINKS+= prop_string.3 prop_string_equals_cstring.3 +MLINKS+= prop_string.3 prop_string_mutable.3 +MLINKS+= prop_string.3 prop_string_size.3 + +.include diff --git a/common/lib/libprop/prop_array.3 b/lib/libprop/prop_array.3 similarity index 99% rename from common/lib/libprop/prop_array.3 rename to lib/libprop/prop_array.3 index 7c8a6bedc5..df89d6e813 100644 --- a/common/lib/libprop/prop_array.3 +++ b/lib/libprop/prop_array.3 @@ -219,7 +219,7 @@ constant, as defined in .Pa libprop/prop_array.c file, e.g. .Pp -.Dl #define EXPAND_STEP 16 +.Dl "#define EXPAND_STEP 16" .It Fn prop_array_remove "prop_array_t array" "unsigned int index" Remove the reference to the object stored at array index .Fa index . @@ -266,7 +266,7 @@ Returns .Dv NULL on failure. .It Fn prop_array_externalize_to_pref "prop_array_t array" \ - "struct plistref *pref" +"struct plistref *pref" Externalizes an array and packs it into the plistref specified by .Fa pref . Returns diff --git a/common/lib/libprop/prop_array_util.3 b/lib/libprop/prop_array_util.3 similarity index 97% rename from common/lib/libprop/prop_array_util.3 rename to lib/libprop/prop_array_util.3 index 27561a7aa0..bd225b41ef 100644 --- a/common/lib/libprop/prop_array_util.3 +++ b/lib/libprop/prop_array_util.3 @@ -127,12 +127,12 @@ "uint64_t val" .\" .Ft bool -.Fn prop_array_set_int32 "prop_array_t dict" "unsigned int indx" \ +.Fn prop_array_set_int32 "prop_array_t dict" "unsigned int indx" \ "int32_t val" .Ft bool -.Fn prop_array_set_uint32 "prop_array_t dict" "unsigned int indx" \ +.Fn prop_array_set_uint32 "prop_array_t dict" "unsigned int indx" \ "uint32_t val" -.\" +.\" .Ft bool .Fn prop_array_add_int8 "prop_array_t dict" "int8_t val" .Ft bool diff --git a/common/lib/libprop/prop_bool.3 b/lib/libprop/prop_bool.3 similarity index 100% rename from common/lib/libprop/prop_bool.3 rename to lib/libprop/prop_bool.3 diff --git a/common/lib/libprop/prop_data.3 b/lib/libprop/prop_data.3 similarity index 100% rename from common/lib/libprop/prop_data.3 rename to lib/libprop/prop_data.3 diff --git a/common/lib/libprop/prop_dictionary.3 b/lib/libprop/prop_dictionary.3 similarity index 100% rename from common/lib/libprop/prop_dictionary.3 rename to lib/libprop/prop_dictionary.3 diff --git a/common/lib/libprop/prop_dictionary_util.3 b/lib/libprop/prop_dictionary_util.3 similarity index 100% rename from common/lib/libprop/prop_dictionary_util.3 rename to lib/libprop/prop_dictionary_util.3 diff --git a/common/lib/libprop/prop_ingest.3 b/lib/libprop/prop_ingest.3 similarity index 100% rename from common/lib/libprop/prop_ingest.3 rename to lib/libprop/prop_ingest.3 diff --git a/common/lib/libprop/prop_number.3 b/lib/libprop/prop_number.3 similarity index 100% rename from common/lib/libprop/prop_number.3 rename to lib/libprop/prop_number.3 diff --git a/common/lib/libprop/prop_object.3 b/lib/libprop/prop_object.3 similarity index 99% rename from common/lib/libprop/prop_object.3 rename to lib/libprop/prop_object.3 index bb1a3f1fbe..6719b7acf5 100644 --- a/common/lib/libprop/prop_object.3 +++ b/lib/libprop/prop_object.3 @@ -65,7 +65,7 @@ The .Nm prop_object family of functions operate on all property container object types. -.Bl -tag -width "" +.Bl -tag -width 0n .It Fn prop_object_retain "prop_object_t obj" Increment the reference count on an object. .It Fn prop_object_release "prop_object_t obj" diff --git a/common/lib/libprop/prop_send_ioctl.3 b/lib/libprop/prop_send_ioctl.3 similarity index 100% rename from common/lib/libprop/prop_send_ioctl.3 rename to lib/libprop/prop_send_ioctl.3 diff --git a/common/lib/libprop/prop_string.3 b/lib/libprop/prop_string.3 similarity index 100% rename from common/lib/libprop/prop_string.3 rename to lib/libprop/prop_string.3 diff --git a/common/lib/libprop/proplib.3 b/lib/libprop/proplib.3 similarity index 100% rename from common/lib/libprop/proplib.3 rename to lib/libprop/proplib.3 diff --git a/share/man/man7/hier.7 b/share/man/man7/hier.7 index 864266e646..752f3f8ef5 100644 --- a/share/man/man7/hier.7 +++ b/share/man/man7/hier.7 @@ -243,6 +243,8 @@ see .Xr pcap 3 .It Pa pccard/ PC-CARD controllers +.It Pa prop/ +C include files for libprop .It Pa protocols/ C include files for Berkeley service protocols .It Pa readline/ diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 3e8321d856..e3624219db 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -127,6 +127,7 @@ MAN= accept_filter.9 \ physio.9 \ posix4.9 \ priv.9 \ + prop_copyin_ioctl.9 \ resettodr.9 \ rman.9 \ rtalloc.9 \ @@ -653,6 +654,12 @@ MLINKS+=physio.9 physread.9 \ MLINKS+=posix4.9 p1003_1b.9 MLINKS+=priv.9 priv_check.9 \ priv.9 priv_check_cred.9 +MLINKS+=prop_copyin_ioctl.9 prop_array_copyin.9 \ + prop_copyin_ioctl.9 prop_array_copyin_ioctl.9 \ + prop_copyin_ioctl.9 prop_array_copyout_ioctl.9 \ + prop_copyin_ioctl.9 prop_dictionary_copyin.9 \ + prop_copyin_ioctl.9 prop_dictionary_copyin_ioctl.9 \ + prop_copyin_ioctl.9 prop_dictionary_copyout_ioctl.9 MLINKS+=rman.9 rman_activate_resource.9 \ rman.9 rman_deactivate_resource.9 \ rman.9 rman_fini.9 \ diff --git a/common/lib/libprop/prop_copyin_ioctl.9 b/share/man/man9/prop_copyin_ioctl.9 similarity index 100% rename from common/lib/libprop/prop_copyin_ioctl.9 rename to share/man/man9/prop_copyin_ioctl.9 diff --git a/sys/conf/files b/sys/conf/files index 44d6adef6d..6ccbd6b037 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1617,9 +1617,6 @@ libkern/bsearch.c standard libkern/crc32.c standard libkern/cmpdi2.c standard libkern/ucmpdi2.c standard -libiconv/iconv.c optional libiconv -libiconv/iconv_xlat.c optional libiconv -libiconv/iconv_converter_if.m optional libiconv libkern/index.c standard libkern/inet_ntoa.c standard libkern/mcount.c optional profiling-routine @@ -1645,6 +1642,22 @@ libkern/strtoq.c standard libkern/strtoul.c standard libkern/strtouq.c standard #libkern/stack_protector.c standard +libiconv/iconv.c optional libiconv +libiconv/iconv_xlat.c optional libiconv +libiconv/iconv_converter_if.m optional libiconv +libprop/prop_array.c standard +libprop/prop_array_util.c standard +libprop/prop_bool.c standard +libprop/prop_data.c standard +libprop/prop_dictionary.c standard +libprop/prop_dictionary_util.c standard +libprop/prop_ingest.c standard +libprop/prop_kern.c standard +libprop/prop_number.c standard +libprop/prop_object.c standard +libprop/prop_stack.c standard +libprop/prop_string.c standard +libprop/prop_rb.c standard crypto/blowfish/bf_ecb.c optional ipsec crypto/blowfish/bf_skey.c optional crypto crypto/camellia/camellia.c optional crypto diff --git a/common/include/prop/Makefile b/sys/libprop/Makefile similarity index 86% rename from common/include/prop/Makefile rename to sys/libprop/Makefile index 0efa775b87..980cf8013f 100644 --- a/common/include/prop/Makefile +++ b/sys/libprop/Makefile @@ -1,9 +1,9 @@ # $NetBSD: Makefile,v 1.3 2007/08/17 11:05:04 pavel Exp $ - +NOOBJ= INCS= prop_array.h prop_bool.h prop_data.h prop_dictionary.h \ prop_ingest.h prop_number.h prop_object.h prop_string.h \ proplib.h plistref.h -INCSDIR= /usr/include/prop +INCSDIR=${INCLUDEDIR}/prop .include diff --git a/common/lib/libprop/Makefile.inc b/sys/libprop/Makefile.inc similarity index 93% rename from common/lib/libprop/Makefile.inc rename to sys/libprop/Makefile.inc index 65685934e4..977f179f88 100644 --- a/common/lib/libprop/Makefile.inc +++ b/sys/libprop/Makefile.inc @@ -1,6 +1,5 @@ # $NetBSD: Makefile.inc,v 1.8 2008/06/30 20:14:09 matt Exp $ -.PATH: ${.PARSEDIR} SRCS+= prop_array.c prop_array_util.c prop_bool.c prop_data.c \ prop_dictionary.c prop_dictionary_util.c prop_ingest.c \ diff --git a/common/include/prop/plistref.h b/sys/libprop/plistref.h similarity index 100% rename from common/include/prop/plistref.h rename to sys/libprop/plistref.h diff --git a/common/lib/libprop/prop_array.c b/sys/libprop/prop_array.c similarity index 99% rename from common/lib/libprop/prop_array.c rename to sys/libprop/prop_array.c index ecb6a8689f..080184fb98 100644 --- a/common/lib/libprop/prop_array.c +++ b/sys/libprop/prop_array.c @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" #if !defined(_KERNEL) && !defined(_STANDALONE) diff --git a/common/include/prop/prop_array.h b/sys/libprop/prop_array.h similarity index 98% rename from common/include/prop/prop_array.h rename to sys/libprop/prop_array.h index cf46ab133a..7f5c9a3429 100644 --- a/common/include/prop/prop_array.h +++ b/sys/libprop/prop_array.h @@ -32,7 +32,7 @@ #ifndef _PROPLIB_PROP_ARRAY_H_ #define _PROPLIB_PROP_ARRAY_H_ -#include +#include typedef struct _prop_array *prop_array_t; @@ -65,7 +65,6 @@ prop_array_t prop_array_internalize(const char *); bool prop_array_externalize_to_file(prop_array_t, const char *); prop_array_t prop_array_internalize_from_file(const char *); -#if defined(__NetBSD__) struct plistref; #if !defined(_KERNEL) && !defined(_STANDALONE) @@ -79,7 +78,6 @@ int prop_array_copyin_ioctl(const struct plistref *, const u_long, int prop_array_copyout_ioctl(struct plistref *, const u_long, prop_array_t); #endif -#endif /* __NetBSD__ */ /* * Utility routines to make it more convenient to work with values diff --git a/common/lib/libprop/prop_array_util.c b/sys/libprop/prop_array_util.c similarity index 99% rename from common/lib/libprop/prop_array_util.c rename to sys/libprop/prop_array_util.c index c7951cca04..6d5dd61f34 100644 --- a/common/lib/libprop/prop_array_util.c +++ b/sys/libprop/prop_array_util.c @@ -38,7 +38,7 @@ * exactly what we're doing here. */ -#include +#include #include "prop_object_impl.h" /* hide kernel vs. not-kernel vs. standalone */ bool @@ -51,7 +51,7 @@ prop_array_get_bool(prop_array_t array, b = prop_array_get(array, indx); if (prop_object_type(b) != PROP_TYPE_BOOL) return (false); - + *valp = prop_bool_true(b); return (true); diff --git a/common/lib/libprop/prop_bool.c b/sys/libprop/prop_bool.c similarity index 99% rename from common/lib/libprop/prop_bool.c rename to sys/libprop/prop_bool.c index d9e912b2cc..9af2c239e7 100644 --- a/common/lib/libprop/prop_bool.c +++ b/sys/libprop/prop_bool.c @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" struct _prop_bool { @@ -209,7 +209,7 @@ _prop_bool_internalize(prop_stack_t stack, prop_object_t *obj, /* No attributes, and it must be an empty element. */ if (ctx->poic_tagattr != NULL || ctx->poic_is_empty_element == false) - return (true); + return (true); if (_PROP_TAG_MATCH(ctx, "true")) val = true; diff --git a/common/include/prop/prop_bool.h b/sys/libprop/prop_bool.h similarity index 98% rename from common/include/prop/prop_bool.h rename to sys/libprop/prop_bool.h index f727ff4910..9ca6d9fe00 100644 --- a/common/include/prop/prop_bool.h +++ b/sys/libprop/prop_bool.h @@ -32,7 +32,7 @@ #ifndef _PROPLIB_PROP_BOOL_H_ #define _PROPLIB_PROP_BOOL_H_ -#include +#include typedef struct _prop_bool *prop_bool_t; diff --git a/common/lib/libprop/prop_data.c b/sys/libprop/prop_data.c similarity index 97% rename from common/lib/libprop/prop_data.c rename to sys/libprop/prop_data.c index 5ef9e35e30..3fb8a0f384 100644 --- a/common/lib/libprop/prop_data.c +++ b/sys/libprop/prop_data.c @@ -29,11 +29,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" #if defined(_KERNEL) #include +#include #elif defined(_STANDALONE) #include #include @@ -89,7 +90,7 @@ _prop_data_free(prop_stack_t stack, prop_object_t *obj) prop_data_t pd = *obj; if ((pd->pd_flags & PD_F_NOCOPY) == 0 && pd->pd_mutable != NULL) - _PROP_FREE(pd->pd_mutable, M_PROP_DATA); + _PROP_FREE(pd->pd_mutable, M_PROP_DATA); _PROP_POOL_PUT(_prop_data_pool, pd); return (_PROP_OBJECT_FREE_DONE); @@ -134,11 +135,11 @@ _prop_data_externalize(struct _prop_object_externalize_context *ctx, void *v) if (_prop_object_externalize_append_char(ctx, _prop_data_base64[output[0]]) == false || _prop_object_externalize_append_char(ctx, - _prop_data_base64[output[1]]) == false || + _prop_data_base64[output[1]]) == false || _prop_object_externalize_append_char(ctx, - _prop_data_base64[output[2]]) == false || + _prop_data_base64[output[2]]) == false || _prop_object_externalize_append_char(ctx, - _prop_data_base64[output[3]]) == false) + _prop_data_base64[output[3]]) == false) return (false); } @@ -159,18 +160,18 @@ _prop_data_externalize(struct _prop_object_externalize_context *ctx, void *v) if (_prop_object_externalize_append_char(ctx, _prop_data_base64[output[0]]) == false || _prop_object_externalize_append_char(ctx, - _prop_data_base64[output[1]]) == false || + _prop_data_base64[output[1]]) == false || _prop_object_externalize_append_char(ctx, - srclen == 1 ? _prop_data_pad64 + srclen == 1 ? _prop_data_pad64 : _prop_data_base64[output[2]]) == false || _prop_object_externalize_append_char(ctx, - _prop_data_pad64) == false) + _prop_data_pad64) == false) return (false); } if (_prop_object_externalize_end_tag(ctx, "data") == false) return (false); - + return (true); } @@ -248,7 +249,7 @@ prop_data_t prop_data_create_data_nocopy(const void *v, size_t size) { prop_data_t pd; - + pd = _prop_data_alloc(); if (pd != NULL) { pd->pd_immutable = v; @@ -328,7 +329,7 @@ prop_data_data(prop_data_t pd) v = _PROP_MALLOC(pd->pd_size, M_TEMP); if (v != NULL) memcpy(v, pd->pd_immutable, pd->pd_size); - + return (v); } @@ -494,7 +495,7 @@ _prop_data_internalize_decode(struct _prop_object_internalize_context *ctx, return (false); ch = (unsigned char) *src; /* FALLTHROUGH */ - + case 3: /* Valid, two bytes of info */ /* * We know this char is a =. Is there anything but @@ -587,7 +588,7 @@ _prop_data_internalize(prop_stack_t stack, prop_object_t *obj, buf = _PROP_MALLOC(len + 1, M_PROP_DATA); if (buf == NULL) return (true); - + if (_prop_data_internalize_decode(ctx, buf, len + 1, &alen, &ctx->poic_cp) == false) { _PROP_FREE(buf, M_PROP_DATA); diff --git a/common/include/prop/prop_data.h b/sys/libprop/prop_data.h similarity index 98% rename from common/include/prop/prop_data.h rename to sys/libprop/prop_data.h index ead37c55f3..fd317efa1c 100644 --- a/common/include/prop/prop_data.h +++ b/sys/libprop/prop_data.h @@ -32,7 +32,7 @@ #ifndef _PROPLIB_PROP_DATA_H_ #define _PROPLIB_PROP_DATA_H_ -#include +#include typedef struct _prop_data *prop_data_t; diff --git a/common/lib/libprop/prop_dictionary.c b/sys/libprop/prop_dictionary.c similarity index 98% rename from common/lib/libprop/prop_dictionary.c rename to sys/libprop/prop_dictionary.c index b2a72bdb2c..9611e8d714 100644 --- a/common/lib/libprop/prop_dictionary.c +++ b/sys/libprop/prop_dictionary.c @@ -29,9 +29,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#include +#include +#include #include "prop_object_impl.h" #include "prop_rb_impl.h" @@ -62,7 +62,7 @@ struct _prop_dictionary_keysym { struct _prop_object pdk_obj; size_t pdk_size; struct rb_node pdk_link; - char pdk_key[1]; + char pdk_key[1]; /* actually variable length */ }; @@ -135,8 +135,8 @@ static const struct _prop_object_type _prop_object_type_dictionary = { .pot_extern = _prop_dictionary_externalize, .pot_equals = _prop_dictionary_equals, .pot_equals_finish = _prop_dictionary_equals_finish, - .pot_lock = _prop_dictionary_lock, - .pot_unlock = _prop_dictionary_unlock, + .pot_lock = _prop_dictionary_lock, + .pot_unlock = _prop_dictionary_unlock, }; static _prop_object_free_rv_t @@ -256,7 +256,7 @@ _prop_dict_keysym_externalize(struct _prop_object_externalize_context *ctx, pdk->pdk_key) == false || _prop_object_externalize_end_tag(ctx, "string") == false) return (false); - + return (true); } @@ -451,7 +451,7 @@ _prop_dictionary_externalize(struct _prop_object_externalize_context *ctx, pi = _prop_dictionary_iterator_locked(pd); if (pi == NULL) goto out; - + ctx->poec_depth++; _PROP_ASSERT(ctx->poec_depth != 0); @@ -478,7 +478,7 @@ _prop_dictionary_externalize(struct _prop_object_externalize_context *ctx, } if (_prop_object_externalize_end_tag(ctx, "dict") == false) goto out; - + rv = true; out: @@ -537,7 +537,7 @@ _prop_dictionary_equals(prop_object_t v1, prop_object_t v2, return (_PROP_OBJECT_EQUALS_RECURSE); out: - _PROP_RWLOCK_UNLOCK(dict1->pd_rwlock); + _PROP_RWLOCK_UNLOCK(dict1->pd_rwlock); _PROP_RWLOCK_UNLOCK(dict2->pd_rwlock); return (rv); } @@ -545,8 +545,8 @@ _prop_dictionary_equals(prop_object_t v1, prop_object_t v2, static void _prop_dictionary_equals_finish(prop_object_t v1, prop_object_t v2) { - _PROP_RWLOCK_UNLOCK(((prop_dictionary_t)v1)->pd_rwlock); - _PROP_RWLOCK_UNLOCK(((prop_dictionary_t)v2)->pd_rwlock); + _PROP_RWLOCK_UNLOCK(((prop_dictionary_t)v1)->pd_rwlock); + _PROP_RWLOCK_UNLOCK(((prop_dictionary_t)v2)->pd_rwlock); } static prop_dictionary_t @@ -600,7 +600,7 @@ _prop_dictionary_expand(prop_dictionary_t pd, unsigned int capacity) if (oarray != NULL) _PROP_FREE(oarray, M_PROP_DICT); - + return (true); } @@ -1009,9 +1009,9 @@ prop_dictionary_set(prop_dictionary_t pd, const char *key, prop_object_t po) if (pd->pd_count == pd->pd_capacity && _prop_dictionary_expand(pd, - pd->pd_capacity + EXPAND_STEP) == false) { + pd->pd_capacity + EXPAND_STEP) == false) { prop_object_release(pdk); - goto out; + goto out; } /* At this point, the store will succeed. */ @@ -1333,7 +1333,7 @@ _prop_dictionary_internalize_body(prop_stack_t stack, prop_object_t *obj, if (!_PROP_TAG_MATCH(ctx, "key") || ctx->poic_tag_type != _PROP_TAG_TYPE_START || ctx->poic_is_empty_element) - goto bad; + goto bad; if (_prop_object_internalize_decode_string(ctx, tmpkey, PDK_MAXKEY, &keylen, @@ -1346,7 +1346,7 @@ _prop_dictionary_internalize_body(prop_stack_t stack, prop_object_t *obj, if (_prop_object_internalize_find_tag(ctx, "key", _PROP_TAG_TYPE_END) == false) goto bad; - + /* ..and now the beginning of the value. */ if (_prop_object_internalize_find_tag(ctx, NULL, _PROP_TAG_TYPE_START) == false) diff --git a/common/include/prop/prop_dictionary.h b/sys/libprop/prop_dictionary.h similarity index 98% rename from common/include/prop/prop_dictionary.h rename to sys/libprop/prop_dictionary.h index 8f26657c5a..1305302559 100644 --- a/common/include/prop/prop_dictionary.h +++ b/sys/libprop/prop_dictionary.h @@ -32,7 +32,7 @@ #ifndef _PROPLIB_PROP_DICTIONARY_H_ #define _PROPLIB_PROP_DICTIONARY_H_ -#include +#include typedef struct _prop_dictionary *prop_dictionary_t; typedef struct _prop_dictionary_keysym *prop_dictionary_keysym_t; @@ -81,7 +81,6 @@ const char * prop_dictionary_keysym_cstring_nocopy(prop_dictionary_keysym_t); bool prop_dictionary_keysym_equals(prop_dictionary_keysym_t, prop_dictionary_keysym_t); -#if defined(__NetBSD__) struct plistref; #if !defined(_KERNEL) && !defined(_STANDALONE) @@ -103,7 +102,6 @@ int prop_dictionary_copyout_ioctl(struct plistref *, const u_long, prop_dictionary_t); #endif -#endif /* __NetBSD__ */ /* * Utility routines to make it more convenient to work with values diff --git a/common/lib/libprop/prop_dictionary_util.c b/sys/libprop/prop_dictionary_util.c similarity index 99% rename from common/lib/libprop/prop_dictionary_util.c rename to sys/libprop/prop_dictionary_util.c index a26443e4bd..681a9253d7 100644 --- a/common/lib/libprop/prop_dictionary_util.c +++ b/sys/libprop/prop_dictionary_util.c @@ -38,7 +38,7 @@ * exactly what we're doing here. */ -#include +#include #include "prop_object_impl.h" /* only to hide kernel vs. not-kernel */ bool @@ -51,7 +51,7 @@ prop_dictionary_get_bool(prop_dictionary_t dict, b = prop_dictionary_get(dict, key); if (prop_object_type(b) != PROP_TYPE_BOOL) return (false); - + *valp = prop_bool_true(b); return (true); diff --git a/common/lib/libprop/prop_ingest.c b/sys/libprop/prop_ingest.c similarity index 99% rename from common/lib/libprop/prop_ingest.c rename to sys/libprop/prop_ingest.c index 823d2c6c73..fe44bcafc1 100644 --- a/common/lib/libprop/prop_ingest.c +++ b/sys/libprop/prop_ingest.c @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" struct _prop_ingest_context { diff --git a/common/include/prop/prop_ingest.h b/sys/libprop/prop_ingest.h similarity index 98% rename from common/include/prop/prop_ingest.h rename to sys/libprop/prop_ingest.h index f82a57de06..206b42154f 100644 --- a/common/include/prop/prop_ingest.h +++ b/sys/libprop/prop_ingest.h @@ -32,7 +32,7 @@ #ifndef _PROPLIB_PROP_INGEST_H_ #define _PROPLIB_PROP_INGEST_H_ -#include +#include typedef enum { PROP_INGEST_ERROR_NO_ERROR = 0, diff --git a/common/lib/libprop/prop_kern.c b/sys/libprop/prop_kern.c similarity index 93% rename from common/lib/libprop/prop_kern.c rename to sys/libprop/prop_kern.c index 96d84477b7..9387c5d63e 100644 --- a/common/lib/libprop/prop_kern.c +++ b/sys/libprop/prop_kern.c @@ -29,12 +29,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(__NetBSD__) - #include -#include -#include +#include #if !defined(_KERNEL) && !defined(_STANDALONE) #include @@ -42,6 +39,7 @@ #include #include #include +#include static int _prop_object_externalize_to_pref(prop_object_t obj, struct plistref *pref, char **bufp) @@ -117,7 +115,7 @@ _prop_object_send_ioctl(prop_object_t obj, int fd, unsigned long cmd) error = errno; else error = 0; - + free(buf); return (error); @@ -195,7 +193,7 @@ prop_array_recv_ioctl(int fd, unsigned long cmd, prop_array_t *arrayp) if (ioctl(fd, cmd, &pref) == -1) return (errno); - + return (_prop_object_internalize_from_pref(&pref, PROP_TYPE_ARRAY, (prop_object_t *)arrayp)); } @@ -237,7 +235,7 @@ prop_dictionary_sendrecv_ioctl(prop_dictionary_t dict, int fd, error = errno; else error = 0; - + free(buf); if (error) @@ -256,27 +254,17 @@ prop_dictionary_sendrecv_ioctl(prop_dictionary_t dict, int fd, #include #include #include -#include - -#include +#include +#include +#include +#include +#include #include "prop_object_impl.h" /* Arbitrary limit ioctl input to 64KB */ unsigned int prop_object_copyin_limit = 65536; -/* initialize proplib for use in the kernel */ -void -prop_kern_init(void) -{ - __link_set_decl(prop_linkpools, struct prop_pool_init); - struct prop_pool_init * const *pi; - - __link_set_foreach(pi, prop_linkpools) - pool_init((*pi)->pp, (*pi)->size, 0, 0, 0, (*pi)->wchan, - &pool_allocator_nointr, IPL_NONE); -} - static int _prop_object_copyin(const struct plistref *pref, const prop_type_t type, prop_object_t *objp) @@ -290,12 +278,12 @@ _prop_object_copyin(const struct plistref *pref, const prop_type_t type, * * Allow malloc to fail in case pmap would be exhausted. */ - buf = malloc(pref->pref_len + 1, M_TEMP, M_WAITOK | M_CANFAIL); + buf = kmalloc(pref->pref_len + 1, M_TEMP, M_WAITOK); if (buf == NULL) return (ENOMEM); error = copyin(pref->pref_plist, buf, pref->pref_len); if (error) { - free(buf, M_TEMP); + kfree(buf, M_TEMP); return (error); } buf[pref->pref_len] = '\0'; @@ -311,7 +299,7 @@ _prop_object_copyin(const struct plistref *pref, const prop_type_t type, error = ENOTSUP; } - free(buf, M_TEMP); + kfree(buf, M_TEMP); if (obj == NULL) { if (error == 0) error = EIO; @@ -383,12 +371,11 @@ static int _prop_object_copyout_ioctl(struct plistref *pref, const u_long cmd, prop_object_t obj) { - struct lwp *l = curlwp; /* XXX */ - struct proc *p = l->l_proc; + struct proc *p = curproc; char *buf; size_t len, rlen; int error = 0; - vaddr_t uaddr; + vm_offset_t uaddr; if ((cmd & IOC_OUT) == 0) return (EFAULT); @@ -413,17 +400,18 @@ _prop_object_copyout_ioctl(struct plistref *pref, const u_long cmd, * See sys_mmap() in sys/uvm/uvm_mmap.c. * Let's act as if we were calling mmap(0, ...) */ +#if 0 uaddr = p->p_emul->e_vm_default_addr(p, (vaddr_t)p->p_vmspace->vm_daddr, rlen); +#endif + uaddr = round_page((vm_offset_t)p->p_vmspace->vm_daddr + maxdsiz); - error = uvm_mmap(&p->p_vmspace->vm_map, + error = vm_mmap(&p->p_vmspace->vm_map, &uaddr, rlen, VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, MAP_PRIVATE|MAP_ANON, - NULL, 0, - p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur); - + NULL, 0); if (error == 0) { error = copyout(buf, (char *)uaddr, len); if (error == 0) { @@ -432,7 +420,7 @@ _prop_object_copyout_ioctl(struct plistref *pref, const u_long cmd, } } - free(buf, M_TEMP); + kfree(buf, M_TEMP); return (error); } @@ -459,5 +447,3 @@ prop_dictionary_copyout_ioctl(struct plistref *pref, const u_long cmd, return (_prop_object_copyout_ioctl(pref, cmd, dict)); } #endif /* _KERNEL */ - -#endif /* __NetBSD__ */ diff --git a/common/lib/libprop/prop_number.c b/sys/libprop/prop_number.c similarity index 98% rename from common/lib/libprop/prop_number.c rename to sys/libprop/prop_number.c index 1f7de0e1e3..4bd715a6bb 100644 --- a/common/lib/libprop/prop_number.c +++ b/sys/libprop/prop_number.c @@ -29,12 +29,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" #include "prop_rb_impl.h" #if defined(_KERNEL) #include +#define strtoll strtoq +#define strtoull strtouq +#define sprintf ksprintf #elif defined(_STANDALONE) #include #include @@ -82,8 +85,8 @@ static const struct _prop_object_type _prop_object_type_number = { .pot_free = _prop_number_free, .pot_extern = _prop_number_externalize, .pot_equals = _prop_number_equals, - .pot_lock = _prop_number_lock, - .pot_unlock = _prop_number_unlock, + .pot_lock = _prop_number_lock, + .pot_unlock = _prop_number_unlock, }; #define prop_object_is_number(x) \ @@ -174,7 +177,7 @@ _prop_number_init(void) return 0; } -static void +static void _prop_number_lock(void) { /* XXX: init necessary? */ @@ -187,7 +190,7 @@ _prop_number_unlock(void) { _PROP_MUTEX_UNLOCK(_prop_number_tree_mutex); } - + static bool _prop_number_externalize(struct _prop_object_externalize_context *ctx, void *v) @@ -208,7 +211,7 @@ _prop_number_externalize(struct _prop_object_externalize_context *ctx, _prop_object_externalize_append_cstring(ctx, tmpstr) == false || _prop_object_externalize_end_tag(ctx, "integer") == false) return (false); - + return (true); } @@ -412,7 +415,7 @@ prop_number_size(prop_number_t pn) } if (pnv->pnv_signed > INT32_MAX || pnv->pnv_signed < INT32_MIN) - return (64); + return (64); if (pnv->pnv_signed > INT16_MAX || pnv->pnv_signed < INT16_MIN) return (32); if (pnv->pnv_signed > INT8_MAX || pnv->pnv_signed < INT8_MIN) @@ -483,7 +486,7 @@ prop_number_equals_integer(prop_number_t pn, int64_t val) if (pn->pn_value.pnv_is_unsigned && (pn->pn_value.pnv_unsigned > INT64_MAX || val < 0)) return (false); - + return (pn->pn_value.pnv_signed == val); } @@ -498,11 +501,11 @@ prop_number_equals_unsigned_integer(prop_number_t pn, uint64_t val) if (! prop_object_is_number(pn)) return (false); - + if (! pn->pn_value.pnv_is_unsigned && (pn->pn_value.pnv_signed < 0 || val > INT64_MAX)) return (false); - + return (pn->pn_value.pnv_unsigned == val); } @@ -544,7 +547,7 @@ _prop_number_internalize_signed(struct _prop_object_internalize_context *ctx, #ifndef _KERNEL /* XXX can't check for ERANGE in the kernel */ if ((pnv->pnv_signed == INT64_MAX || pnv->pnv_signed == INT64_MIN) && errno == ERANGE) - return (false); + return (false); #endif pnv->pnv_is_unsigned = false; ctx->poic_cp = cp; @@ -586,7 +589,7 @@ _prop_number_internalize(prop_stack_t stack, prop_object_t *obj, } else { if (_prop_number_internalize_signed(ctx, &pnv) == false && _prop_number_internalize_unsigned(ctx, &pnv) == false) - return (true); + return (true); } if (_prop_object_internalize_find_tag(ctx, "integer", diff --git a/common/include/prop/prop_number.h b/sys/libprop/prop_number.h similarity index 98% rename from common/include/prop/prop_number.h rename to sys/libprop/prop_number.h index a6a2a1491d..17cec6908a 100644 --- a/common/include/prop/prop_number.h +++ b/sys/libprop/prop_number.h @@ -35,7 +35,7 @@ #if !defined(_KERNEL) && !defined(_STANDALONE) #include #endif -#include +#include typedef struct _prop_number *prop_number_t; diff --git a/common/lib/libprop/prop_object.c b/sys/libprop/prop_object.c similarity index 97% rename from common/lib/libprop/prop_object.c rename to sys/libprop/prop_object.c index 3f5fccfa6b..dbdde97ea5 100644 --- a/common/lib/libprop/prop_object.c +++ b/sys/libprop/prop_object.c @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" #if !defined(_KERNEL) && !defined(_STANDALONE) @@ -40,7 +40,14 @@ #include #include #endif -#include + +/* XXX: netbsd's _nv stuff effectively does addfetch, not fetchadd */ +#define atomic_inc_32_nv(x) (atomic_fetchadd_int(x, 1)+1) +#define atomic_dec_32_nv(x) (atomic_fetchadd_int(x, -1)-1) +#define atomic_inc_32(x) atomic_add_int(x, 1) +#define atomic_dec_32(x) atomic_add_int(x, 1) + +#include #ifdef _STANDALONE void * @@ -65,7 +72,7 @@ _prop_standalone_realloc(void *v, size_t size) memcpy(rv, v, size); /* XXX */ dealloc(v, 0); /* XXX */ } - + return (rv); } #endif /* _STANDALONE */ @@ -113,7 +120,7 @@ _prop_object_externalize_start_tag( _prop_object_externalize_append_cstring(ctx, tag) == false || _prop_object_externalize_append_char(ctx, '>') == false) return (false); - + return (true); } @@ -156,8 +163,8 @@ _prop_object_externalize_empty_tag( _prop_object_externalize_append_char(ctx, '/') == false || _prop_object_externalize_append_char(ctx, '>') == false || _prop_object_externalize_append_char(ctx, '\n') == false) - return (false); - + return (false); + return (true); } @@ -425,7 +432,7 @@ _prop_object_internalize_find_tag(struct _prop_object_internalize_context *ctx, (taglen != ctx->poic_tagname_len || memcmp(tag, ctx->poic_tagname, taglen) != 0)) return (false); - + /* Check for empty tag. */ if (*cp == '/') { if (ctx->poic_tag_type != _PROP_TAG_TYPE_START) @@ -465,21 +472,21 @@ _prop_object_internalize_find_tag(struct _prop_object_internalize_context *ctx, return (false); ctx->poic_tagattr_len = cp - ctx->poic_tagattr; - + cp++; if (*cp != '\"') return (false); cp++; if (_PROP_EOF(*cp)) return (false); - + ctx->poic_tagattrval = cp; while (*cp != '\"') cp++; if (_PROP_EOF(*cp)) return (false); ctx->poic_tagattrval_len = cp - ctx->poic_tagattrval; - + cp++; if (*cp != '>') return (false); @@ -501,7 +508,7 @@ _prop_object_internalize_decode_string( const char *src; size_t tarindex; char c; - + tarindex = 0; src = ctx->poic_cp; @@ -517,7 +524,7 @@ _prop_object_internalize_decode_string( src[2] == 'm' && src[3] == 'p' && src[4] == ';') { - c = '&'; + c = '&'; src += 5; } else if (src[1] == 'l' && src[2] == 't' && @@ -560,7 +567,7 @@ _prop_object_internalize_decode_string( *sizep = tarindex; if (cpp != NULL) *cpp = src; - + return (true); } @@ -699,7 +706,7 @@ _prop_generic_internalize(const char *xml, const char *master_tag) } out: - _prop_object_internalize_context_free(ctx); + _prop_object_internalize_context_free(ctx); return (obj); } @@ -716,7 +723,7 @@ _prop_object_internalize_context_alloc(const char *xml) M_TEMP); if (ctx == NULL) return (NULL); - + ctx->poic_xml = ctx->poic_cp = xml; /* @@ -799,12 +806,12 @@ _prop_object_externalize_file_dirname(const char *path, char *result) */ if (path == NULL || *path == '\0') goto singledot; - + /* String trailing slashes, if any. */ lastp = path + strlen(path) - 1; while (lastp != path && *lastp == '/') lastp--; - + /* Terminate path at the last occurrence of '/'. */ do { if (*lastp == '/') { @@ -823,7 +830,7 @@ _prop_object_externalize_file_dirname(const char *path, char *result) } } while (--lastp >= path); - /* No /'s found, return ".". */ + /* No /'s found, return ".". */ singledot: strcpy(result, "."); } @@ -905,7 +912,7 @@ _prop_object_internalize_map_file(const char *fname) mf = _PROP_MALLOC(sizeof(*mf), M_TEMP); if (mf == NULL) return (NULL); - + fd = open(fname, O_RDONLY, 0400); if (fd == -1) { _PROP_FREE(mf, M_TEMP); @@ -933,7 +940,7 @@ _prop_object_internalize_map_file(const char *fname) need_guard = true; mf->poimf_xml = mmap(NULL, need_guard ? mf->poimf_mapsize + pgsize - : mf->poimf_mapsize, + : mf->poimf_mapsize, PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0); (void) close(fd); if (mf->poimf_xml == MAP_FAILED) { @@ -1012,7 +1019,7 @@ prop_object_release_emergency(prop_object_t obj) /* Save pointerto unlock function */ unlock = po->po_type->pot_unlock; - + /* Dance a bit to make sure we always get the non-racy ocnt */ ocnt = atomic_dec_32_nv(&po->po_refcnt); ocnt++; @@ -1023,8 +1030,8 @@ prop_object_release_emergency(prop_object_t obj) unlock(); break; } - - _PROP_ASSERT(po->po_type); + + _PROP_ASSERT(po->po_type); if ((po->po_type->pot_free)(NULL, &obj) == _PROP_OBJECT_FREE_DONE) { if (unlock != NULL) @@ -1034,7 +1041,7 @@ prop_object_release_emergency(prop_object_t obj) if (unlock != NULL) unlock(); - + parent = po; atomic_inc_32(&po->po_refcnt); } @@ -1056,7 +1063,7 @@ prop_object_release(prop_object_t obj) { struct _prop_object *po; struct _prop_stack stack; - void (*unlock)(void); + void (*unlock)(void); int ret; uint32_t ocnt; @@ -1072,7 +1079,7 @@ prop_object_release(prop_object_t obj) /* Save pointer to object unlock function */ unlock = po->po_type->pot_unlock; - + ocnt = atomic_dec_32_nv(&po->po_refcnt); ocnt++; _PROP_ASSERT(ocnt != 0); @@ -1083,7 +1090,7 @@ prop_object_release(prop_object_t obj) unlock(); break; } - + ret = (po->po_type->pot_free)(&stack, &obj); if (unlock != NULL) @@ -1091,7 +1098,7 @@ prop_object_release(prop_object_t obj) if (ret == _PROP_OBJECT_FREE_DONE) break; - + atomic_inc_32(&po->po_refcnt); } while (ret == _PROP_OBJECT_FREE_RECURSE); if (ret == _PROP_OBJECT_FREE_FAILED) @@ -1147,7 +1154,7 @@ prop_object_equals_with_error(prop_object_t obj1, prop_object_t obj2, if (po1->po_type != po2->po_type) return (false); - + continue_subtree: ret = (*po1->po_type->pot_equals)(obj1, obj2, &stored_pointer1, &stored_pointer2, @@ -1177,7 +1184,7 @@ finish: po1 = obj1; (*po1->po_type->pot_equals_finish)(obj1, obj2); } - return (false); + return (false); } /* diff --git a/common/include/prop/prop_object.h b/sys/libprop/prop_object.h similarity index 97% rename from common/include/prop/prop_object.h rename to sys/libprop/prop_object.h index e1203339c9..120ac373c5 100644 --- a/common/include/prop/prop_object.h +++ b/sys/libprop/prop_object.h @@ -36,6 +36,10 @@ #if !defined(_KERNEL) && !defined(_STANDALONE) #include +#else +typedef int bool; +#define false 0 +#define true 1 #endif /* ! _KERNEL && ! _STANDALONE */ typedef void *prop_object_t; diff --git a/common/lib/libprop/prop_object_impl.h b/sys/libprop/prop_object_impl.h similarity index 89% rename from common/lib/libprop/prop_object_impl.h rename to sys/libprop/prop_object_impl.h index 0768c9f1f7..fd1fb3b954 100644 --- a/common/lib/libprop/prop_object_impl.h +++ b/sys/libprop/prop_object_impl.h @@ -33,7 +33,7 @@ #define _PROPLIB_PROP_OBJECT_IMPL_H_ #if defined(_KERNEL) || defined(_STANDALONE) -#include +#include #else #include #endif @@ -246,52 +246,59 @@ struct _prop_object_iterator { * proplib in the kernel... */ +#include +#include #include +#include #include -#include +#include #include -#include -#include +#include +#include +#include -#define _PROP_ASSERT(x) KASSERT(x) +#define _PROP_ASSERT(x) KKASSERT(x) -#define _PROP_MALLOC(s, t) malloc((s), (t), M_WAITOK) -#define _PROP_CALLOC(s, t) malloc((s), (t), M_WAITOK | M_ZERO) -#define _PROP_REALLOC(v, s, t) realloc((v), (s), (t), M_WAITOK) -#define _PROP_FREE(v, t) free((v), (t)) +#define _PROP_MALLOC(s, t) kmalloc((s), (t), M_WAITOK) +#define _PROP_CALLOC(s, t) kmalloc((s), (t), M_WAITOK | M_ZERO) +#define _PROP_REALLOC(v, s, t) krealloc((v), (s), (t), M_WAITOK) +#define _PROP_FREE(v, t) kfree((v), (t)) -#define _PROP_POOL_GET(p) pool_get(&(p), PR_WAITOK) -#define _PROP_POOL_PUT(p, v) pool_put(&(p), (v)) +#define _PROP_POOL_GET(p) objcache_get((p), M_WAITOK) +#define _PROP_POOL_PUT(p, v) objcache_put((p), (v)) struct prop_pool_init { struct pool *pp; size_t size; const char *wchan; }; -#define _PROP_POOL_INIT(pp, size, wchan) \ -struct pool pp; \ -static const struct prop_pool_init _link_ ## pp[1] = { \ - { &pp, size, wchan } \ -}; \ -__link_set_add_rodata(prop_linkpools, _link_ ## pp); +#define _PROP_POOL_INIT(pp, size, wchan) \ +MALLOC_DEFINE(M_##pp, wchan, wchan); \ +struct objcache *pp; \ +static void \ +pp##_init(void) \ +{ \ + pp = objcache_create_simple(M_##pp, size); \ +} \ +SYSINIT(pp##_init, SI_SUB_PRE_DRIVERS, SI_ORDER_ANY, pp##_init, NULL) #define _PROP_MALLOC_DEFINE(t, s, l) \ MALLOC_DEFINE(t, s, l); -#define _PROP_MUTEX_DECL_STATIC(x) static kmutex_t x; -#define _PROP_MUTEX_INIT(x) mutex_init(&(x),MUTEX_DEFAULT,IPL_NONE) -#define _PROP_MUTEX_LOCK(x) mutex_enter(&(x)) -#define _PROP_MUTEX_UNLOCK(x) mutex_exit(&(x)) +#define _PROP_MUTEX_DECL_STATIC(x) static struct lock x; +#define _PROP_MUTEX_INIT(x) lockinit(&(x),"proplib",0,LK_CANRECURSE) +#define _PROP_MUTEX_LOCK(x) lockmgr(&(x), LK_EXCLUSIVE) +#define _PROP_MUTEX_UNLOCK(x) lockmgr(&(x), LK_RELEASE) -#define _PROP_RWLOCK_DECL(x) krwlock_t x ; -#define _PROP_RWLOCK_INIT(x) rw_init(&(x)) -#define _PROP_RWLOCK_RDLOCK(x) rw_enter(&(x), RW_READER) -#define _PROP_RWLOCK_WRLOCK(x) rw_enter(&(x), RW_WRITER) -#define _PROP_RWLOCK_UNLOCK(x) rw_exit(&(x)) -#define _PROP_RWLOCK_DESTROY(x) rw_destroy(&(x)) +#define _PROP_RWLOCK_DECL(x) struct spinlock x; +#define _PROP_RWLOCK_INIT(x) spin_init(&(x)) +#define _PROP_RWLOCK_RDLOCK(x) spin_lock_wr(&(x)) +#define _PROP_RWLOCK_WRLOCK(x) spin_lock_wr(&(x)) +#define _PROP_RWLOCK_UNLOCK(x) spin_unlock_wr(&(x)) +#define _PROP_RWLOCK_DESTROY(x) spin_uninit(&(x)) -#define _PROP_ONCE_DECL(x) static ONCE_DECL(x); -#define _PROP_ONCE_RUN(x,f) RUN_ONCE(&(x), f) +#define _PROP_ONCE_DECL(x) static int x = 0; +#define _PROP_ONCE_RUN(x,f) if (atomic_cmpset_int(&(x), 0, 1)) f() #elif defined(_STANDALONE) @@ -426,11 +433,7 @@ void * _prop_standalone_realloc(void *, size_t); /* * Language features. */ -#if defined(__NetBSD__) #include #define _PROP_ARG_UNUSED __unused -#else -#define _PROP_ARG_UNUSED /* delete */ -#endif /* __NetBSD__ */ #endif /* _PROPLIB_PROP_OBJECT_IMPL_H_ */ diff --git a/common/lib/libprop/prop_rb.c b/sys/libprop/prop_rb.c similarity index 99% rename from common/lib/libprop/prop_rb.c rename to sys/libprop/prop_rb.c index 83657bc288..f907f28b04 100644 --- a/common/lib/libprop/prop_rb.c +++ b/sys/libprop/prop_rb.c @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" #include "prop_rb_impl.h" @@ -858,7 +858,7 @@ rb_tree_check_node(const struct rb_tree *rbt, const struct rb_node *self, /* * The root must be black. - * There can never be two adjacent red nodes. + * There can never be two adjacent red nodes. */ if (red_check) { KASSERT(!RB_ROOT_P(self) || RB_BLACK_P(self)); @@ -867,7 +867,7 @@ rb_tree_check_node(const struct rb_tree *rbt, const struct rb_node *self, KASSERT(!RB_ROOT_P(self)); brother = self->rb_parent->rb_nodes[self->rb_position ^ RB_NODE_OTHER]; KASSERT(RB_BLACK_P(self->rb_parent)); - /* + /* * I'm red and have no children, then I must either * have no brother or my brother also be red and * also have no children. (black count == 0) @@ -1045,7 +1045,7 @@ _prop_rb_tree_check(const struct rb_tree *rbt, bool red_check) /* * The root must be black. - * There can never be two adjacent red nodes. + * There can never be two adjacent red nodes. */ if (red_check) { KASSERT(rbt->rbt_root == NULL || RB_BLACK_P(rbt->rbt_root)); diff --git a/common/lib/libprop/prop_rb_impl.h b/sys/libprop/prop_rb_impl.h similarity index 100% rename from common/lib/libprop/prop_rb_impl.h rename to sys/libprop/prop_rb_impl.h diff --git a/common/lib/libprop/prop_stack.c b/sys/libprop/prop_stack.c similarity index 100% rename from common/lib/libprop/prop_stack.c rename to sys/libprop/prop_stack.c diff --git a/common/lib/libprop/prop_stack.h b/sys/libprop/prop_stack.h similarity index 98% rename from common/lib/libprop/prop_stack.h rename to sys/libprop/prop_stack.h index dca99c1527..0b4fada75f 100644 --- a/common/lib/libprop/prop_stack.h +++ b/sys/libprop/prop_stack.h @@ -34,7 +34,7 @@ #include -#include +#include struct _prop_stack_intern_elem { prop_object_t object; diff --git a/common/lib/libprop/prop_string.c b/sys/libprop/prop_string.c similarity index 98% rename from common/lib/libprop/prop_string.c rename to sys/libprop/prop_string.c index 4f9ed88603..63e34405b0 100644 --- a/common/lib/libprop/prop_string.c +++ b/sys/libprop/prop_string.c @@ -29,9 +29,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "prop_object_impl.h" +#if defined(_KERNEL) +#define sprintf ksprintf +#endif + struct _prop_string { struct _prop_object ps_obj; union { @@ -79,7 +83,7 @@ _prop_string_free(prop_stack_t stack, prop_object_t *obj) prop_string_t ps = *obj; if ((ps->ps_flags & PS_F_NOCOPY) == 0 && ps->ps_mutable != NULL) - _PROP_FREE(ps->ps_mutable, M_PROP_STRING); + _PROP_FREE(ps->ps_mutable, M_PROP_STRING); _PROP_POOL_PUT(_prop_string_pool, ps); return (_PROP_OBJECT_FREE_DONE); @@ -96,10 +100,10 @@ _prop_string_externalize(struct _prop_object_externalize_context *ctx, if (_prop_object_externalize_start_tag(ctx, "string") == false || _prop_object_externalize_append_encoded_cstring(ctx, - ps->ps_immutable) == false || + ps->ps_immutable) == false || _prop_object_externalize_end_tag(ctx, "string") == false) return (false); - + return (true); } @@ -185,7 +189,7 @@ prop_string_t prop_string_create_cstring_nocopy(const char *str) { prop_string_t ps; - + ps = _prop_string_alloc(); if (ps != NULL) { ps->ps_immutable = str; @@ -298,7 +302,7 @@ prop_string_cstring(prop_string_t ps) cp = _PROP_MALLOC(ps->ps_size + 1, M_TEMP); if (cp != NULL) strcpy(cp, prop_string_contents(ps)); - + return (cp); } @@ -346,7 +350,7 @@ prop_string_append(prop_string_t dst, prop_string_t src) dst->ps_size = len; if (ocp != NULL) _PROP_FREE(ocp, M_PROP_STRING); - + return (true); } @@ -368,7 +372,7 @@ prop_string_append_cstring(prop_string_t dst, const char *src) if (dst->ps_flags & PS_F_NOCOPY) return (false); - + len = dst->ps_size + strlen(src); cp = _PROP_MALLOC(len + 1, M_PROP_STRING); if (cp == NULL) @@ -379,7 +383,7 @@ prop_string_append_cstring(prop_string_t dst, const char *src) dst->ps_size = len; if (ocp != NULL) _PROP_FREE(ocp, M_PROP_STRING); - + return (true); } @@ -429,7 +433,7 @@ _prop_string_internalize(prop_stack_t stack, prop_object_t *obj, *obj = prop_string_create(); return (true); } - + /* No attributes recognized here. */ if (ctx->poic_tagattr != NULL) return (true); @@ -438,11 +442,11 @@ _prop_string_internalize(prop_stack_t stack, prop_object_t *obj, if (_prop_object_internalize_decode_string(ctx, NULL, 0, &len, NULL) == false) return (true); - + str = _PROP_MALLOC(len + 1, M_PROP_STRING); if (str == NULL) return (true); - + if (_prop_object_internalize_decode_string(ctx, str, len, &alen, &ctx->poic_cp) == false || alen != len) { diff --git a/common/include/prop/prop_string.h b/sys/libprop/prop_string.h similarity index 98% rename from common/include/prop/prop_string.h rename to sys/libprop/prop_string.h index eb64e8773e..9798361de8 100644 --- a/common/include/prop/prop_string.h +++ b/sys/libprop/prop_string.h @@ -32,7 +32,7 @@ #ifndef _PROPLIB_PROP_STRING_H_ #define _PROPLIB_PROP_STRING_H_ -#include +#include typedef struct _prop_string *prop_string_t; diff --git a/common/include/prop/proplib.h b/sys/libprop/proplib.h similarity index 86% rename from common/include/prop/proplib.h rename to sys/libprop/proplib.h index f136265dec..7bef13be25 100644 --- a/common/include/prop/proplib.h +++ b/sys/libprop/proplib.h @@ -32,16 +32,16 @@ #ifndef _PROPLIB_PROPLIB_H_ #define _PROPLIB_PROPLIB_H_ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include -#include +#include #ifdef _KERNEL void prop_kern_init(void);