mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-30 11:00:41 +08:00
* fork.cc: White space.
* net.cc: Ditto. * posix_ipc.cc: Ditto.
This commit is contained in:
parent
a5a0080d9c
commit
7b44665a7b
@ -1,3 +1,9 @@
|
|||||||
|
2007-07-07 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
|
* fork.cc: White space.
|
||||||
|
* net.cc: Ditto.
|
||||||
|
* posix_ipc.cc: Ditto.
|
||||||
|
|
||||||
2007-07-06 Corinna Vinschen <corinna@vinschen.de>
|
2007-07-06 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* times.cc (gettimeofday): Align definition to POSIX.
|
* times.cc (gettimeofday): Align definition to POSIX.
|
||||||
|
@ -98,10 +98,10 @@ public: /* DELETEME*/
|
|||||||
bool& ischild;
|
bool& ischild;
|
||||||
/* Note the order of the locks below. It is important,
|
/* Note the order of the locks below. It is important,
|
||||||
to avoid races, that the lock order be preserved.
|
to avoid races, that the lock order be preserved.
|
||||||
|
|
||||||
pthread is first because it serves as a master lock
|
pthread is first because it serves as a master lock
|
||||||
against other forks being attempted while this one is active.
|
against other forks being attempted while this one is active.
|
||||||
|
|
||||||
signals is next to stop signal processing for the duration
|
signals is next to stop signal processing for the duration
|
||||||
of the fork.
|
of the fork.
|
||||||
|
|
||||||
|
@ -1296,7 +1296,7 @@ get_routedst (DWORD if_index)
|
|||||||
&& GetIpForwardTable (pift, &size, FALSE) == NO_ERROR)
|
&& GetIpForwardTable (pift, &size, FALSE) == NO_ERROR)
|
||||||
for (DWORD i = 0; i < pift->dwNumEntries; ++i)
|
for (DWORD i = 0; i < pift->dwNumEntries; ++i)
|
||||||
{
|
{
|
||||||
if (pift->table[i].dwForwardIfIndex == if_index
|
if (pift->table[i].dwForwardIfIndex == if_index
|
||||||
&& pift->table[i].dwForwardMask == INADDR_BROADCAST)
|
&& pift->table[i].dwForwardMask == INADDR_BROADCAST)
|
||||||
return pift->table[i].dwForwardDest;
|
return pift->table[i].dwForwardDest;
|
||||||
}
|
}
|
||||||
@ -1408,7 +1408,7 @@ get_xp_ifs (ULONG family)
|
|||||||
{
|
{
|
||||||
/* Destination address */
|
/* Destination address */
|
||||||
if (sa->sa_family == AF_INET)
|
if (sa->sa_family == AF_INET)
|
||||||
{
|
{
|
||||||
if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr;
|
if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr;
|
||||||
if_sin->sin_addr.s_addr = get_routedst (pap->IfIndex);
|
if_sin->sin_addr.s_addr = get_routedst (pap->IfIndex);
|
||||||
if_sin->sin_family = AF_INET;
|
if_sin->sin_family = AF_INET;
|
||||||
@ -1417,7 +1417,7 @@ get_xp_ifs (ULONG family)
|
|||||||
/* FIXME: No official way to get the dstaddr for ipv6? */
|
/* FIXME: No official way to get the dstaddr for ipv6? */
|
||||||
memcpy (&ifp->ifa_addr, sa, sa_size);
|
memcpy (&ifp->ifa_addr, sa, sa_size);
|
||||||
ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *)
|
ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *)
|
||||||
&ifp->ifa_brddstaddr;
|
&ifp->ifa_brddstaddr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1425,7 +1425,7 @@ get_xp_ifs (ULONG family)
|
|||||||
if (sa->sa_family == AF_INET)
|
if (sa->sa_family == AF_INET)
|
||||||
{
|
{
|
||||||
if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr;
|
if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr;
|
||||||
uint32_t mask =
|
uint32_t mask =
|
||||||
((struct sockaddr_in *) &ifp->ifa_netmask)->sin_addr.s_addr;
|
((struct sockaddr_in *) &ifp->ifa_netmask)->sin_addr.s_addr;
|
||||||
if_sin->sin_addr.s_addr = sin->sin_addr.s_addr & mask | ~mask;
|
if_sin->sin_addr.s_addr = sin->sin_addr.s_addr & mask | ~mask;
|
||||||
if_sin->sin_family = AF_INET;
|
if_sin->sin_family = AF_INET;
|
||||||
@ -1604,7 +1604,7 @@ get_2k_ifs ()
|
|||||||
{
|
{
|
||||||
ifp->ifa_ifa.ifa_flags |= IFF_UP | IFF_LOWER_UP;
|
ifp->ifa_ifa.ifa_flags |= IFF_UP | IFF_LOWER_UP;
|
||||||
/* Bug in NT4's IP Helper lib. The dwOperStatus has just
|
/* Bug in NT4's IP Helper lib. The dwOperStatus has just
|
||||||
two values, 0 or 1, non operational, operational. */
|
two values, 0 or 1, non operational, operational. */
|
||||||
if (ifrow->dwOperStatus >= (wincap.has_broken_if_oper_status ()
|
if (ifrow->dwOperStatus >= (wincap.has_broken_if_oper_status ()
|
||||||
? 1 : IF_OPER_STATUS_CONNECTED))
|
? 1 : IF_OPER_STATUS_CONNECTED))
|
||||||
ifp->ifa_ifa.ifa_flags |= IFF_RUNNING;
|
ifp->ifa_ifa.ifa_flags |= IFF_RUNNING;
|
||||||
@ -1625,7 +1625,7 @@ get_2k_ifs ()
|
|||||||
{
|
{
|
||||||
/* Destination address */
|
/* Destination address */
|
||||||
if_sin->sin_addr.s_addr =
|
if_sin->sin_addr.s_addr =
|
||||||
get_routedst (ipt->table[ip_cnt].dwIndex);
|
get_routedst (ipt->table[ip_cnt].dwIndex);
|
||||||
ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *)
|
ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *)
|
||||||
&ifp->ifa_brddstaddr;
|
&ifp->ifa_brddstaddr;
|
||||||
}
|
}
|
||||||
@ -1746,7 +1746,7 @@ get_nt_ifs ()
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
(unsigned char *) netmask,
|
(unsigned char *) netmask,
|
||||||
(size = 256, &size)) == ERROR_SUCCESS)
|
(size = 256, &size)) == ERROR_SUCCESS)
|
||||||
++cnt;
|
++cnt;
|
||||||
RegCloseKey (key);
|
RegCloseKey (key);
|
||||||
}
|
}
|
||||||
++cnt; /* loopback */
|
++cnt; /* loopback */
|
||||||
@ -1788,7 +1788,7 @@ get_nt_ifs ()
|
|||||||
ifp->ifa_ifindex = -1;
|
ifp->ifa_ifindex = -1;
|
||||||
/* Friendly name */
|
/* Friendly name */
|
||||||
struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *)
|
struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *)
|
||||||
&ifp->ifa_frndlyname;
|
&ifp->ifa_frndlyname;
|
||||||
strcpy (iff->ifrf_friendlyname, "Default loopback");
|
strcpy (iff->ifrf_friendlyname, "Default loopback");
|
||||||
iff->ifrf_len = 16;
|
iff->ifrf_len = 16;
|
||||||
|
|
||||||
@ -1875,7 +1875,7 @@ get_nt_ifs ()
|
|||||||
sin->sin_family = AF_INET;
|
sin->sin_family = AF_INET;
|
||||||
ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask;
|
ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask;
|
||||||
if (ppp)
|
if (ppp)
|
||||||
{
|
{
|
||||||
/* Destination address */
|
/* Destination address */
|
||||||
sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr;
|
sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr;
|
||||||
sin->sin_addr.s_addr =
|
sin->sin_addr.s_addr =
|
||||||
@ -1885,7 +1885,7 @@ get_nt_ifs ()
|
|||||||
&ifp->ifa_brddstaddr;
|
&ifp->ifa_brddstaddr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Broadcast address */
|
/* Broadcast address */
|
||||||
lip = cygwin_inet_addr (dhcp ? dhcpaddress : ip);
|
lip = cygwin_inet_addr (dhcp ? dhcpaddress : ip);
|
||||||
lnp = cygwin_inet_addr (dhcp ? dhcpnetmask : np);
|
lnp = cygwin_inet_addr (dhcp ? dhcpnetmask : np);
|
||||||
@ -1978,7 +1978,7 @@ get_ifconf (struct ifconf *ifc, int what)
|
|||||||
++cnt;
|
++cnt;
|
||||||
strcpy (ifr->ifr_name, ifp->ifa_name);
|
strcpy (ifr->ifr_name, ifp->ifa_name);
|
||||||
switch (what)
|
switch (what)
|
||||||
{
|
{
|
||||||
case SIOCGIFFLAGS:
|
case SIOCGIFFLAGS:
|
||||||
ifr->ifr_flags = ifp->ifa_ifa.ifa_flags;
|
ifr->ifr_flags = ifp->ifa_ifa.ifa_flags;
|
||||||
break;
|
break;
|
||||||
|
@ -105,7 +105,7 @@ ipc_mutex_lock (HANDLE mtx)
|
|||||||
HANDLE h[2] = { mtx, signal_arrived };
|
HANDLE h[2] = { mtx, signal_arrived };
|
||||||
|
|
||||||
switch (WaitForMultipleObjects (2, h, FALSE, INFINITE))
|
switch (WaitForMultipleObjects (2, h, FALSE, INFINITE))
|
||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
case WAIT_ABANDONED_0:
|
case WAIT_ABANDONED_0:
|
||||||
return 0;
|
return 0;
|
||||||
@ -114,7 +114,7 @@ ipc_mutex_lock (HANDLE mtx)
|
|||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return geterrno_from_win_error ();
|
return geterrno_from_win_error ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ ipc_cond_timedwait (HANDLE evt, HANDLE mtx, const struct timespec *abstime)
|
|||||||
if (ipc_mutex_unlock (mtx))
|
if (ipc_mutex_unlock (mtx))
|
||||||
return -1;
|
return -1;
|
||||||
switch (WaitForMultipleObjects (2, h, TRUE, timeout))
|
switch (WaitForMultipleObjects (2, h, TRUE, timeout))
|
||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
case WAIT_ABANDONED_0:
|
case WAIT_ABANDONED_0:
|
||||||
ResetEvent (evt);
|
ResetEvent (evt);
|
||||||
@ -178,7 +178,7 @@ ipc_cond_timedwait (HANDLE evt, HANDLE mtx, const struct timespec *abstime)
|
|||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return geterrno_from_win_error ();
|
return geterrno_from_win_error ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ struct mq_hdr
|
|||||||
long mqh_nwait; /* #threads blocked in mq_receive() */
|
long mqh_nwait; /* #threads blocked in mq_receive() */
|
||||||
pid_t mqh_pid; /* nonzero PID if mqh_event set */
|
pid_t mqh_pid; /* nonzero PID if mqh_event set */
|
||||||
char mqh_uname[36]; /* unique name used to identify synchronization
|
char mqh_uname[36]; /* unique name used to identify synchronization
|
||||||
objects connected to this queue */
|
objects connected to this queue */
|
||||||
struct sigevent mqh_event; /* for mq_notify() */
|
struct sigevent mqh_event; /* for mq_notify() */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ again:
|
|||||||
/* Open and specify O_EXCL and user-execute */
|
/* Open and specify O_EXCL and user-execute */
|
||||||
fd = open (mqname, oflag | O_EXCL | O_RDWR, mode | S_IXUSR);
|
fd = open (mqname, oflag | O_EXCL | O_RDWR, mode | S_IXUSR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
if (errno == EEXIST && (oflag & O_EXCL) == 0)
|
if (errno == EEXIST && (oflag & O_EXCL) == 0)
|
||||||
goto exists; /* already exists, OK */
|
goto exists; /* already exists, OK */
|
||||||
return (mqd_t) -1;
|
return (mqd_t) -1;
|
||||||
@ -356,7 +356,7 @@ again:
|
|||||||
/* Calculate and set the file size */
|
/* Calculate and set the file size */
|
||||||
msgsize = MSGSIZE (attr->mq_msgsize);
|
msgsize = MSGSIZE (attr->mq_msgsize);
|
||||||
filesize = sizeof (struct mq_hdr)
|
filesize = sizeof (struct mq_hdr)
|
||||||
+ (attr->mq_maxmsg * (sizeof (struct msg_hdr) + msgsize));
|
+ (attr->mq_maxmsg * (sizeof (struct msg_hdr) + msgsize));
|
||||||
if (lseek64 (fd, filesize - 1, SEEK_SET) == -1)
|
if (lseek64 (fd, filesize - 1, SEEK_SET) == -1)
|
||||||
goto err;
|
goto err;
|
||||||
if (write (fd, "", 1) == -1)
|
if (write (fd, "", 1) == -1)
|
||||||
@ -384,7 +384,7 @@ again:
|
|||||||
mqhdr->mqh_nwait = 0;
|
mqhdr->mqh_nwait = 0;
|
||||||
mqhdr->mqh_pid = 0;
|
mqhdr->mqh_pid = 0;
|
||||||
if (!AllocateLocallyUniqueId (&luid))
|
if (!AllocateLocallyUniqueId (&luid))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -497,7 +497,7 @@ mq_getattr (mqd_t mqd, struct mq_attr *mqstat)
|
|||||||
struct mq_hdr *mqhdr;
|
struct mq_hdr *mqhdr;
|
||||||
struct mq_attr *attr;
|
struct mq_attr *attr;
|
||||||
struct mq_info *mqinfo;
|
struct mq_info *mqinfo;
|
||||||
|
|
||||||
myfault efault;
|
myfault efault;
|
||||||
if (efault.faulted (EBADF))
|
if (efault.faulted (EBADF))
|
||||||
return -1;
|
return -1;
|
||||||
@ -514,7 +514,7 @@ mq_getattr (mqd_t mqd, struct mq_attr *mqstat)
|
|||||||
{
|
{
|
||||||
errno = n;
|
errno = n;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mqstat->mq_flags = mqinfo->mqi_flags; /* per-open */
|
mqstat->mq_flags = mqinfo->mqi_flags; /* per-open */
|
||||||
mqstat->mq_maxmsg = attr->mq_maxmsg; /* remaining three per-queue */
|
mqstat->mq_maxmsg = attr->mq_maxmsg; /* remaining three per-queue */
|
||||||
mqstat->mq_msgsize = attr->mq_msgsize;
|
mqstat->mq_msgsize = attr->mq_msgsize;
|
||||||
@ -522,13 +522,13 @@ mq_getattr (mqd_t mqd, struct mq_attr *mqstat)
|
|||||||
|
|
||||||
ipc_mutex_unlock (mqinfo->mqi_lock);
|
ipc_mutex_unlock (mqinfo->mqi_lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
mq_setattr (mqd_t mqd, const struct mq_attr *mqstat, struct mq_attr *omqstat)
|
mq_setattr (mqd_t mqd, const struct mq_attr *mqstat, struct mq_attr *omqstat)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
struct mq_hdr *mqhdr;
|
struct mq_hdr *mqhdr;
|
||||||
struct mq_attr *attr;
|
struct mq_attr *attr;
|
||||||
struct mq_info *mqinfo;
|
struct mq_info *mqinfo;
|
||||||
|
|
||||||
@ -574,7 +574,7 @@ mq_notify (mqd_t mqd, const struct sigevent *notification)
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
struct mq_hdr *mqhdr;
|
struct mq_hdr *mqhdr;
|
||||||
struct mq_info *mqinfo;
|
struct mq_info *mqinfo;
|
||||||
|
|
||||||
myfault efault;
|
myfault efault;
|
||||||
if (efault.faulted (EBADF))
|
if (efault.faulted (EBADF))
|
||||||
return -1;
|
return -1;
|
||||||
@ -582,16 +582,16 @@ mq_notify (mqd_t mqd, const struct sigevent *notification)
|
|||||||
mqinfo = (struct mq_info *) mqd;
|
mqinfo = (struct mq_info *) mqd;
|
||||||
if (mqinfo->mqi_magic != MQI_MAGIC)
|
if (mqinfo->mqi_magic != MQI_MAGIC)
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mqhdr = mqinfo->mqi_hdr;
|
mqhdr = mqinfo->mqi_hdr;
|
||||||
if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0)
|
if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0)
|
||||||
{
|
{
|
||||||
errno = n;
|
errno = n;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = getpid ();
|
pid = getpid ();
|
||||||
if (!notification)
|
if (!notification)
|
||||||
{
|
{
|
||||||
@ -611,10 +611,10 @@ mq_notify (mqd_t mqd, const struct sigevent *notification)
|
|||||||
}
|
}
|
||||||
mqhdr->mqh_pid = pid;
|
mqhdr->mqh_pid = pid;
|
||||||
mqhdr->mqh_event = *notification;
|
mqhdr->mqh_event = *notification;
|
||||||
}
|
}
|
||||||
ipc_mutex_unlock (mqinfo->mqi_lock);
|
ipc_mutex_unlock (mqinfo->mqi_lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_mq_send (mqd_t mqd, const char *ptr, size_t len, unsigned int prio,
|
_mq_send (mqd_t mqd, const char *ptr, size_t len, unsigned int prio,
|
||||||
@ -747,7 +747,7 @@ _mq_receive (mqd_t mqd, char *ptr, size_t maxlen, unsigned int *priop,
|
|||||||
long index;
|
long index;
|
||||||
int8_t *mptr;
|
int8_t *mptr;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
struct mq_hdr *mqhdr;
|
struct mq_hdr *mqhdr;
|
||||||
struct mq_attr *attr;
|
struct mq_attr *attr;
|
||||||
struct msg_hdr *msghdr;
|
struct msg_hdr *msghdr;
|
||||||
struct mq_info *mqinfo;
|
struct mq_info *mqinfo;
|
||||||
@ -926,7 +926,7 @@ again:
|
|||||||
/* Open and specify O_EXCL and user-execute */
|
/* Open and specify O_EXCL and user-execute */
|
||||||
fd = open (semname, oflag | O_EXCL | O_RDWR, mode | S_IXUSR);
|
fd = open (semname, oflag | O_EXCL | O_RDWR, mode | S_IXUSR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
if (errno == EEXIST && (oflag & O_EXCL) == 0)
|
if (errno == EEXIST && (oflag & O_EXCL) == 0)
|
||||||
goto exists; /* already exists, OK */
|
goto exists; /* already exists, OK */
|
||||||
return SEM_FAILED;
|
return SEM_FAILED;
|
||||||
@ -934,17 +934,17 @@ again:
|
|||||||
created = 1;
|
created = 1;
|
||||||
/* First one to create the file initializes it. */
|
/* First one to create the file initializes it. */
|
||||||
if (!AllocateLocallyUniqueId (&sf.luid))
|
if (!AllocateLocallyUniqueId (&sf.luid))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
sf.value = value;
|
sf.value = value;
|
||||||
sf.hash = hash_path_name (0, semname);
|
sf.hash = hash_path_name (0, semname);
|
||||||
if (write (fd, &sf, sizeof sf) != sizeof sf)
|
if (write (fd, &sf, sizeof sf) != sizeof sf)
|
||||||
goto err;
|
goto err;
|
||||||
sem = semaphore::open (sf.hash, sf.luid, fd, oflag, mode, value, wasopen);
|
sem = semaphore::open (sf.hash, sf.luid, fd, oflag, mode, value, wasopen);
|
||||||
if (sem == SEM_FAILED)
|
if (sem == SEM_FAILED)
|
||||||
goto err;
|
goto err;
|
||||||
/* Initialization complete, turn off user-execute bit */
|
/* Initialization complete, turn off user-execute bit */
|
||||||
if (fchmod (fd, mode) == -1)
|
if (fchmod (fd, mode) == -1)
|
||||||
goto err;
|
goto err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user