* Throughout, replace usage of w32api's min with MIN from sys/param.h.

This commit is contained in:
Corinna Vinschen 2012-03-08 09:36:11 +00:00
parent 106833e9b3
commit 75543537a1
12 changed files with 38 additions and 25 deletions

View File

@ -1,3 +1,7 @@
2012-03-07 Corinna Vinschen <corinna@vinschen.de>
* Throughout, replace usage of w32api's min with MIN from sys/param.h.
2012-03-07 Christopher Faylor <me.cygwin2012@cgf.cx>
* pinfo.cc (_pinfo::dup_proc_pipe): Reorganize to provide more

View File

@ -14,6 +14,7 @@ details. */
#include <stdlib.h>
#include <sys/uio.h>
#include <sys/acl.h>
#include <sys/param.h>
#include "cygerrno.h"
#include "perprocess.h"
#include "security.h"
@ -949,7 +950,7 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
char *p = buf;
while (nbytes > 0)
{
const int frag = min (nbytes, (ssize_t) iovptr->iov_len);
const int frag = MIN (nbytes, (ssize_t) iovptr->iov_len);
memcpy (iovptr->iov_base, p, frag);
p += frag;
iovptr += 1;
@ -1001,7 +1002,7 @@ fhandler_base::writev (const struct iovec *const iov, const int iovcnt,
while (nbytes != 0)
{
const int frag = min (nbytes, (ssize_t) iovptr->iov_len);
const int frag = MIN (nbytes, (ssize_t) iovptr->iov_len);
memcpy (bufptr, iovptr->iov_base, frag);
bufptr += frag;
iovptr += 1;

View File

@ -18,6 +18,7 @@ details. */
#include <winuser.h>
#include <winnls.h>
#include <ctype.h>
#include <sys/param.h>
#include <sys/cygwin.h>
#include <cygwin/kd.h>
#include "cygerrno.h"
@ -1740,7 +1741,7 @@ fhandler_console::write_normal (const unsigned char *src,
if (trunc_buf.len)
{
const unsigned char *nfound;
int cp_len = min (end - src, 4 - trunc_buf.len);
int cp_len = MIN (end - src, 4 - trunc_buf.len);
memcpy (trunc_buf.buf + trunc_buf.len, src, cp_len);
memset (&ps, 0, sizeof ps);
switch (ret = f_mbtowc (_REENT, NULL, (const char *) trunc_buf.buf,

View File

@ -2,7 +2,7 @@
fhandler classes.
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009, 2011 Red Hat, Inc.
2009, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@ -13,6 +13,7 @@ details. */
#include "winsup.h"
#include <alloca.h>
#include <unistd.h>
#include <sys/param.h>
#include <winioctl.h>
#include <cygwin/rdevio.h>
#include <cygwin/hdreg.h>
@ -446,7 +447,7 @@ fhandler_dev_floppy::raw_read (void *ptr, size_t& ulen)
{
if (devbufstart < devbufend)
{
bytes_to_read = min (len, devbufend - devbufstart);
bytes_to_read = MIN (len, devbufend - devbufstart);
debug_printf ("read %d bytes from buffer (rest %d)",
bytes_to_read,
devbufend - devbufstart - bytes_to_read);

View File

@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include <unistd.h>
#include <sys/param.h>
#include "cygerrno.h"
#include "security.h"
#include "path.h"
@ -44,7 +45,7 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
int tot;
DWORD n;
size_t minchars = vmin_ ? min (vmin_, ulen) : ulen;
size_t minchars = vmin_ ? MIN (vmin_, ulen) : ulen;
debug_printf ("ulen %d, vmin_ %d, vtime_ %d, hEvent %p", ulen, vmin_, vtime_,
io_status.hEvent);

View File

@ -1,7 +1,7 @@
/* fhandler_socket.cc. See fhandler.h for a description of the fhandler classes.
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009, 2010, 2011 Red Hat, Inc.
2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@ -34,6 +34,7 @@
#include "sigproc.h"
#include "wininfo.h"
#include <unistd.h>
#include <sys/param.h>
#include <sys/acl.h>
#include "cygtls.h"
#include "cygwin/in6.h"
@ -1213,12 +1214,12 @@ fhandler_socket::accept4 (struct sockaddr *peer, int *len, int flags)
bound socket name of the peer's socket. For now
we just fake an unbound socket on the other side. */
static struct sockaddr_un un = { AF_LOCAL, "" };
memcpy (peer, &un, min (*len, (int) sizeof (un.sun_family)));
memcpy (peer, &un, MIN (*len, (int) sizeof (un.sun_family)));
*len = (int) sizeof (un.sun_family);
}
else
{
memcpy (peer, &lpeer, min (*len, llen));
memcpy (peer, &lpeer, MIN (*len, llen));
*len = llen;
}
}
@ -1247,7 +1248,7 @@ fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
sun.sun_path[0] = '\0';
if (get_sun_path ())
strncat (sun.sun_path, get_sun_path (), UNIX_PATH_LEN - 1);
memcpy (name, &sun, min (*namelen, (int) SUN_LEN (&sun) + 1));
memcpy (name, &sun, MIN (*namelen, (int) SUN_LEN (&sun) + 1));
*namelen = (int) SUN_LEN (&sun) + (get_sun_path () ? 1 : 0);
res = 0;
}
@ -1261,7 +1262,7 @@ fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
res = ::getsockname (get_socket (), (struct sockaddr *) &sock, &len);
if (!res)
{
memcpy (name, &sock, min (*namelen, len));
memcpy (name, &sock, MIN (*namelen, len));
*namelen = len;
}
else
@ -1290,7 +1291,7 @@ fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
}
if (!res)
{
memcpy (name, &sock, min (*namelen, len));
memcpy (name, &sock, MIN (*namelen, len));
*namelen = len;
}
}
@ -1321,12 +1322,12 @@ fhandler_socket::getpeername (struct sockaddr *name, int *namelen)
sun.sun_path[0] = '\0';
if (get_peer_sun_path ())
strncat (sun.sun_path, get_peer_sun_path (), UNIX_PATH_LEN - 1);
memcpy (name, &sun, min (*namelen, (int) SUN_LEN (&sun) + 1));
memcpy (name, &sun, MIN (*namelen, (int) SUN_LEN (&sun) + 1));
*namelen = (int) SUN_LEN (&sun) + (get_peer_sun_path () ? 1 : 0);
}
else
{
memcpy (name, &sock, min (*namelen, len));
memcpy (name, &sock, MIN (*namelen, len));
*namelen = len;
}

View File

@ -2,7 +2,7 @@
classes.
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2010, 2011 Red Hat, Inc.
2008, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@ -1278,7 +1278,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
{
if (devbufend > devbufstart)
{
bytes_to_read = min (len, devbufend - devbufstart);
bytes_to_read = MIN (len, devbufend - devbufstart);
debug_printf ("read %d bytes from buffer (rest %d)",
bytes_to_read, devbufend - devbufstart - bytes_to_read);
memcpy (buf, devbuf + devbufstart, bytes_to_read);

View File

@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include <sys/param.h>
#include <cygwin/kd.h>
#include "cygerrno.h"
#include "security.h"
@ -623,7 +624,7 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
while (len)
{
n = min (OUT_BUFFER_SIZE, len);
n = MIN (OUT_BUFFER_SIZE, len);
char *buf = (char *)ptr;
ptr = (char *) ptr + n;
len -= n;
@ -802,7 +803,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
return;
}
readlen = min (bytes_in_pipe, min (len, sizeof (buf)));
readlen = MIN (bytes_in_pipe, MIN (len, sizeof (buf)));
if (ptr && vmin && readlen > (unsigned) vmin)
readlen = vmin;

View File

@ -57,6 +57,7 @@
#include <winnetwk.h>
#include <winnls.h>
#include <shlobj.h>
#include <sys/param.h>
#include <sys/cygwin.h>
#include "cygerrno.h"
#include "security.h"
@ -2782,7 +2783,7 @@ readlink (const char *path, char *buf, size_t buflen)
return -1;
}
ssize_t len = min (buflen, strlen (pathbuf.get_win32 ()));
ssize_t len = MIN (buflen, strlen (pathbuf.get_win32 ()));
memcpy (buf, pathbuf.get_win32 (), len);
/* errno set by symlink.check if error */

View File

@ -1293,7 +1293,7 @@ thread_socket (void *arg)
event = true;
if (!event)
for (int i = 0; i < si->num_w4; i += MAXIMUM_WAIT_OBJECTS)
switch (WaitForMultipleObjects (min (si->num_w4 - i,
switch (WaitForMultipleObjects (MIN (si->num_w4 - i,
MAXIMUM_WAIT_OBJECTS),
si->w4 + i, FALSE, timeout))
{

View File

@ -1,7 +1,7 @@
/* strfuncs.cc: misc funcs that don't belong anywhere else
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include <sys/param.h>
#include <wchar.h>
#include <winnls.h>
#include <ntdll.h>
@ -238,7 +239,7 @@ __db_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, UINT cp,
*pwc = *(unsigned char *) s;
return *s ? 1 : 0;
}
size_t cnt = min (n, 2);
size_t cnt = MIN (n, 2);
ret = MultiByteToWideChar (cp, MB_ERR_INVALID_CHARS, s, cnt, pwc, 1);
if (ret)
return cnt;
@ -312,7 +313,7 @@ __eucjp_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n,
ret = 3;
goto jis_x_0212;
}
size_t cnt = min (n, 2);
size_t cnt = MIN (n, 2);
if (MultiByteToWideChar (20932, MB_ERR_INVALID_CHARS, s, cnt, pwc, 1))
return cnt;
if (n == 1)

View File

@ -1,7 +1,7 @@
/* sysconf.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2009, 2010, 2011 Red Hat, Inc.
2006, 2007, 2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include <unistd.h>
#include <sys/param.h>
#include <sys/sysinfo.h>
#include "cygerrno.h"
#include "security.h"
@ -294,7 +295,7 @@ confstr (int in, char *buf, size_t len)
if (csa[in].l && len)
{
buf[0] = 0;
strncat (buf, csa[in].s, min (len, csa[in].l) - 1);
strncat (buf, csa[in].s, MIN (len, csa[in].l) - 1);
}
return csa[in].l;
}