/*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#if DEBUG
#include <kern/simple_lock.h>
-static int uio_t_count = 0;
+static uint32_t uio_t_count = 0;
#endif /* DEBUG */
+/*
+ * Returns: 0 Success
+ * uiomove64:EFAULT
+ *
+ * Notes: The first argument should be a caddr_t, but const poisoning
+ * for typedef'ed types doesn't work in gcc.
+ */
int
-uiomove(cp, n, uio)
- register caddr_t cp;
- register int n;
- register uio_t uio;
+uiomove(const char * cp, int n, uio_t uio)
{
- return uiomove64((addr64_t)((unsigned int)cp), n, uio);
+ return uiomove64((const addr64_t)((const unsigned int)cp), n, uio);
}
+/*
+ * Returns: 0 Success
+ * EFAULT
+ * copyout:EFAULT
+ * copyin:EFAULT
+ * copywithin:EFAULT
+ * copypv:EFAULT
+ */
// LP64todo - fix this! 'n' should be int64_t?
int
-uiomove64(addr64_t cp, int n, register struct uio *uio)
+uiomove64(const addr64_t c_cp, int n, struct uio *uio)
{
+ addr64_t cp = c_cp;
#if LP64KERN
- register uint64_t acnt;
+ uint64_t acnt;
#else
- register u_int acnt;
+ u_int acnt;
#endif
int error = 0;
* Give next character to user as result of read.
*/
int
-ureadc(c, uio)
- register int c;
- register struct uio *uio;
+ureadc(int c, struct uio *uio)
{
if (uio_resid(uio) <= 0)
panic("ureadc: non-positive resid");
* Get next character written in by user from uio.
*/
int
-uwritec(uio)
- uio_t uio;
+uwritec(uio_t uio)
{
- register int c = 0;
+ int c = 0;
if (uio_resid(uio) <= 0)
return (-1);
* General routine to allocate a hash table.
*/
void *
-hashinit(elements, type, hashmask)
- int elements, type;
- u_long *hashmask;
+hashinit(int elements, int type, u_long *hashmask)
{
long hashsize;
LIST_HEAD(generic, generic) *hashtbl;
{
#if DEBUG
if (a_uio == NULL) {
- panic("%s :%d - invalid uio_t\n", __FILE__, __LINE__);
+ printf("%s :%d - invalid uio_t\n", __FILE__, __LINE__);
}
/* if (IS_VALID_UIO_SEGFLG(a_uio->uio_segflg) == 0) { */
/* panic("%s :%d - invalid uio_segflg\n", __FILE__, __LINE__); */
return;
}
-#if 0 // obsolete
-/*
- * uio_proc_t - return the proc_t for the given uio_t
- * WARNING - This call is going away. Find another way to get the proc_t!!
- */
-__private_extern__ proc_t uio_proc_t( uio_t a_uio )
-{
-#if LP64_DEBUG
- if (a_uio == NULL) {
- panic("%s :%d - invalid uio_t\n", __FILE__, __LINE__);
- }
-#endif /* LP64_DEBUG */
-
- /* return 0 if there are no active iovecs */
- if (a_uio == NULL) {
- return( NULL );
- }
- return( a_uio->uio_procp );
-}
-
-/*
- * uio_setproc_t - set the residual IO value for the given uio_t
- * WARNING - This call is going away.
- */
-__private_extern__ void uio_setproc_t( uio_t a_uio, proc_t a_proc_t )
-{
- if (a_uio == NULL) {
-#if LP64_DEBUG
- panic("%s :%d - invalid uio_t\n", __FILE__, __LINE__);
-#endif /* LP64_DEBUG */
- return;
- }
-
- a_uio->uio_procp = a_proc_t;
- return;
-}
-#endif // obsolete
-
/*
* uio_curriovbase - return the base address of the current iovec associated
* with the given uio_t. May return 0.
int my_size;
uio_t my_uio;
- my_size = sizeof(struct uio) + (sizeof(struct user_iovec) * a_iovcount);
+ my_size = UIO_SIZEOF(a_iovcount);
my_buf_p = kalloc(my_size);
my_uio = uio_createwithbuffer( a_iovcount,
a_offset,
/* leave a note that we allocated this uio_t */
my_uio->uio_flags |= UIO_FLAGS_WE_ALLOCED;
#if DEBUG
- hw_atomic_add(&uio_t_count, 1);
+ (void)hw_atomic_add(&uio_t_count, 1);
#endif
}
if (a_uio != NULL && (a_uio->uio_flags & UIO_FLAGS_WE_ALLOCED) != 0) {
#if DEBUG
- if ((int)(hw_atomic_sub(&uio_t_count, 1)) < 0) {
- panic("%s :%d - uio_t_count has gone negative\n", __FILE__, __LINE__);
- }
+ if (hw_atomic_sub(&uio_t_count, 1) == UINT_MAX)
+ panic("%s :%d - uio_t_count underflow\n", __FILE__, __LINE__);
#endif
kfree(a_uio, a_uio->uio_size);
}
}
}
+ my_uio->uio_flags = UIO_FLAGS_WE_ALLOCED | UIO_FLAGS_INITED;
+
return(my_uio);
}