-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#include <hurd.h>
#include <stdio.h>
mach_msg_type_number_t nread;
error_t err;
char *bufp = buf;
+ io_t io = (io_t) (uintptr_t) cookie;
nread = n;
- if (err = __io_read ((io_t) cookie, &bufp, &nread, -1, n))
+ if (err = __io_read (io, &bufp, &nread, -1, n))
return __hurd_fail (err);
if (bufp != buf)
static ssize_t
writeio (void *cookie, const char *buf, size_t n)
{
- mach_msg_type_number_t wrote;
+ vm_size_t wrote;
error_t err;
+ io_t io = (io_t) (uintptr_t) cookie;
- if (err = __io_write ((io_t) cookie, buf, n, -1, &wrote))
+ if (err = __io_write (io, buf, n, -1, &wrote))
return __hurd_fail (err);
return wrote;
Returns zero if successful, nonzero if not. */
static int
seekio (void *cookie,
- _IO_off64_t *pos,
+ off64_t *pos,
int whence)
{
- error_t err = __io_seek ((file_t) cookie, *pos, whence, pos);
+ io_t io = (io_t) (uintptr_t) cookie;
+ error_t err = __io_seek (io, *pos, whence, pos);
return err ? __hurd_fail (err) : 0;
}
static int
closeio (void *cookie)
{
+ io_t io = (io_t) (uintptr_t) cookie;
error_t error = __mach_port_deallocate (__mach_task_self (),
- (mach_port_t) cookie);
+ io);
if (error)
return __hurd_fail (error);
return 0;
/* Check the access mode. */
if ((pflags & needflags) != needflags)
- {
- errno = EBADF;
- return NULL;
- }
+ return __hurd_fail (EBADF), NULL;
- return fopencookie ((void *) port, mode, funcsio);
+ return fopencookie ((void *) (uintptr_t) port,
+ mode, funcsio);
}
weak_alias (__fopenport, fopenport)