diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-03-08 13:36:11 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-03-08 13:36:11 +0400 |
commit | 75543537a16a0911af61045a96926cdb81f51383 (patch) | |
tree | 34fa443cb5d7c48e058d17cb2605e10d3947b521 /winsup/cygwin | |
parent | 106833e9b360c8f56e465e2e80141a13dc193635 (diff) |
* Throughout, replace usage of w32api's min with MIN from sys/param.h.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_floppy.cc | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_serial.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 17 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tape.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 5 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/select.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/strfuncs.cc | 7 | ||||
-rw-r--r-- | winsup/cygwin/sysconf.cc | 5 |
12 files changed, 38 insertions, 25 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 66d389dac..698587559 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -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 diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index c3bca4f7d..d0210f83b 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -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; diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index a30b717d2..32454511a 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -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, diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 070a30ab5..0caca96e8 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -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); diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 8668808f8..677b6221f 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -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); diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 17d98dc38..f78002801 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -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; } diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index 17d2685f1..c394d862d 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -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); diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 547cf72b8..6189046b9 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -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; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index aa0521d4f..17ae5e109 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -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 */ diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 316073e00..72900866e 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -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)) { diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index 3b532f9e0..467f54e87 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -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) diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index f5bfe60d1..1014d4f5a 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -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; } |