mirror of
https://sourceware.org/git/glibc.git
synced 2025-06-16 17:41:01 +03:00
* sysdeps/mach/hurd/times.c (__times): Use union instead of cast.
* sysdeps/mach/hurd/sendmsg.c (__libc_sendmsg): Likewise.
This commit is contained in:
@ -1,5 +1,8 @@
|
|||||||
2004-02-10 Roland McGrath <roland@frob.com>
|
2004-02-10 Roland McGrath <roland@frob.com>
|
||||||
|
|
||||||
|
* sysdeps/mach/hurd/times.c (__times): Use union instead of cast.
|
||||||
|
* sysdeps/mach/hurd/sendmsg.c (__libc_sendmsg): Likewise.
|
||||||
|
|
||||||
* sysdeps/mach/hurd/configure.in: Move `retcode' check to ...
|
* sysdeps/mach/hurd/configure.in: Move `retcode' check to ...
|
||||||
* sysdeps/mach/configure.in: ... here.
|
* sysdeps/mach/configure.in: ... here.
|
||||||
* sysdeps/mach/hurd/configure: Regenerated.
|
* sysdeps/mach/hurd/configure: Regenerated.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2001,2002,2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -35,7 +35,11 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
|
|||||||
struct sockaddr_un *addr = message->msg_name;
|
struct sockaddr_un *addr = message->msg_name;
|
||||||
socklen_t addr_len = message->msg_namelen;
|
socklen_t addr_len = message->msg_namelen;
|
||||||
addr_port_t aport = MACH_PORT_NULL;
|
addr_port_t aport = MACH_PORT_NULL;
|
||||||
char *data = NULL;
|
union
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
vm_address_t addr;
|
||||||
|
} data = { .ptr = NULL };
|
||||||
char data_buf[2048];
|
char data_buf[2048];
|
||||||
mach_msg_type_number_t len;
|
mach_msg_type_number_t len;
|
||||||
mach_msg_type_number_t amount;
|
mach_msg_type_number_t amount;
|
||||||
@ -51,15 +55,15 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
|
|||||||
/* As an optimization, if we only have a single non-empty
|
/* As an optimization, if we only have a single non-empty
|
||||||
iovec, we set DATA and LEN from it. */
|
iovec, we set DATA and LEN from it. */
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
data = message->msg_iov[i].iov_base;
|
data.ptr = message->msg_iov[i].iov_base;
|
||||||
else
|
else
|
||||||
data = NULL;
|
data.ptr = NULL;
|
||||||
|
|
||||||
len += message->msg_iov[i].iov_len;
|
len += message->msg_iov[i].iov_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data == NULL)
|
if (data.ptr == NULL)
|
||||||
{
|
{
|
||||||
size_t to_copy;
|
size_t to_copy;
|
||||||
char *buf;
|
char *buf;
|
||||||
@ -70,8 +74,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
|
|||||||
limit of 2048 bytes is inspired by the MiG stubs. */
|
limit of 2048 bytes is inspired by the MiG stubs. */
|
||||||
if (len > 2048)
|
if (len > 2048)
|
||||||
{
|
{
|
||||||
err = __vm_allocate (__mach_task_self (),
|
err = __vm_allocate (__mach_task_self (), &data.addr, len, 1);
|
||||||
(vm_address_t *) &data, len, 1);
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
__set_errno (err);
|
__set_errno (err);
|
||||||
@ -80,11 +83,11 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
|
|||||||
dealloc = 1;
|
dealloc = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
data = data_buf;
|
data.ptr = data_buf;
|
||||||
|
|
||||||
/* Copy the data into DATA. */
|
/* Copy the data into DATA. */
|
||||||
to_copy = len;
|
to_copy = len;
|
||||||
buf = data;
|
buf = data.ptr;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
#define min(a, b) ((a) > (b) ? (b) : (a))
|
#define min(a, b) ((a) > (b) ? (b) : (a))
|
||||||
@ -131,7 +134,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
|
|||||||
{
|
{
|
||||||
/* Send the data. */
|
/* Send the data. */
|
||||||
err = __socket_send (port, aport,
|
err = __socket_send (port, aport,
|
||||||
flags, data, len,
|
flags, data.ptr, len,
|
||||||
NULL,
|
NULL,
|
||||||
MACH_MSG_TYPE_COPY_SEND, 0,
|
MACH_MSG_TYPE_COPY_SEND, 0,
|
||||||
message->msg_control,
|
message->msg_control,
|
||||||
@ -144,7 +147,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if (dealloc)
|
if (dealloc)
|
||||||
__vm_deallocate (__mach_task_self (), (vm_address_t) data, len);
|
__vm_deallocate (__mach_task_self (), data.addr, len);
|
||||||
|
|
||||||
return err ? __hurd_dfail (fd, err) : amount;
|
return err ? __hurd_dfail (fd, err) : amount;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Return CPU and real time used by process and its children. Hurd version.
|
/* Return CPU and real time used by process and its children. Hurd version.
|
||||||
Copyright (C) 2001,2002,2003 Free Software Foundation, Inc.
|
Copyright (C) 2001,2002,2003,2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -43,7 +43,7 @@ __times (struct tms *tms)
|
|||||||
struct task_basic_info bi;
|
struct task_basic_info bi;
|
||||||
struct task_thread_times_info tti;
|
struct task_thread_times_info tti;
|
||||||
mach_msg_type_number_t count;
|
mach_msg_type_number_t count;
|
||||||
time_value_t now;
|
union { time_value_t tvt; struct timeval tv; } now;
|
||||||
error_t err;
|
error_t err;
|
||||||
|
|
||||||
count = TASK_BASIC_INFO_COUNT;
|
count = TASK_BASIC_INFO_COUNT;
|
||||||
@ -66,10 +66,10 @@ __times (struct tms *tms)
|
|||||||
/* XXX This can't be implemented until getrusage(RUSAGE_CHILDREN) can be. */
|
/* XXX This can't be implemented until getrusage(RUSAGE_CHILDREN) can be. */
|
||||||
tms->tms_cutime = tms->tms_cstime = 0;
|
tms->tms_cutime = tms->tms_cstime = 0;
|
||||||
|
|
||||||
if (__gettimeofday ((struct timeval *) &now, NULL) < 0)
|
if (__gettimeofday (&now.tv, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (clock_from_time_value (&now)
|
return (clock_from_time_value (&now.tvt)
|
||||||
- clock_from_time_value (&bi.creation_time));
|
- clock_from_time_value (&bi.creation_time));
|
||||||
}
|
}
|
||||||
weak_alias (__times, times)
|
weak_alias (__times, times)
|
||||||
|
Reference in New Issue
Block a user