4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-01 03:50:28 +08:00

Fix copyright throughout.

Eliminate use of _impure_ptr outside Cygwin.
	* bsd_helper.cc: Include errno.h instead of cygerrno.h.
	* bsd_mutex.cc : Ditto.
	* client.cc: Ditto.
	* cygserver.cc: Ditto.
	* process.cc: Don't build functions inside Cygwin.  Don't include
	cygerrno.h.  Don't set errno.
	* transport_pipes.cc (SET_ERRNO): New define.  Use througout.
	* transport_sockets.cc (SET_ERRNO): Ditto.
	(GET_ERRNO): Ditto.
This commit is contained in:
Corinna Vinschen 2004-09-15 10:17:53 +00:00
parent b103e0d732
commit 1dcd520bb8
17 changed files with 74 additions and 48 deletions

View File

@ -1,3 +1,17 @@
2004-09-15 Corinna Vinschen <corinna@vinschen.de>
Fix copyright throughout.
Eliminate use of _impure_ptr outside Cygwin.
* bsd_helper.cc: Include errno.h instead of cygerrno.h.
* bsd_mutex.cc : Ditto.
* client.cc: Ditto.
* cygserver.cc: Ditto.
* process.cc: Don't build functions inside Cygwin. Don't include
cygerrno.h. Don't set errno.
* transport_pipes.cc (SET_ERRNO): New define. Use througout.
* transport_sockets.cc (SET_ERRNO): Ditto.
(GET_ERRNO): Ditto.
2004-09-06 Corinna Vinschen <corinna@vinschen.de> 2004-09-06 Corinna Vinschen <corinna@vinschen.de>
* bsd_mutex.cc (_msleep): Disable resetting event object for now. * bsd_mutex.cc (_msleep): Disable resetting event object for now.

View File

@ -1,6 +1,6 @@
/* bsd_helper.cc /* bsd_helper.cc
Copyright 2003 Red Hat Inc. Copyright 2003, 2004 Red Hat Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -9,7 +9,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
#ifdef __OUTSIDE_CYGWIN__ #ifdef __OUTSIDE_CYGWIN__
#include "woutsup.h" #include "woutsup.h"
#include "cygerrno.h" #include <errno.h>
#define _KERNEL 1 #define _KERNEL 1
#define __BSD_VISIBLE 1 #define __BSD_VISIBLE 1
#include <sys/smallprint.h> #include <sys/smallprint.h>

View File

@ -1,6 +1,6 @@
/* bsd_log.cc /* bsd_log.cc
Copyright 2003 Red Hat Inc. Copyright 2003, 2004 Red Hat Inc.
This file is part of Cygwin. This file is part of Cygwin.

View File

@ -1,6 +1,6 @@
/* bsd_mutex.cc /* bsd_mutex.cc
Copyright 2003 Red Hat Inc. Copyright 2003, 2004 Red Hat Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -9,7 +9,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
#ifdef __OUTSIDE_CYGWIN__ #ifdef __OUTSIDE_CYGWIN__
#include "woutsup.h" #include "woutsup.h"
#include "cygerrno.h" #include <errno.h>
#define _KERNEL 1 #define _KERNEL 1
#define __BSD_VISIBLE 1 #define __BSD_VISIBLE 1
#include <sys/smallprint.h> #include <sys/smallprint.h>

View File

@ -1,6 +1,6 @@
/* client.cc /* client.cc
Copyright 2001, 2002, 2003 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Egor Duda <deo@logos-m.ru> Written by Egor Duda <deo@logos-m.ru>
@ -18,12 +18,12 @@ details. */
#endif #endif
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "sigproc.h" #include "sigproc.h"
#include "cygerrno.h"
#include "cygserver_msg.h" #include "cygserver_msg.h"
#include "cygserver_sem.h" #include "cygserver_sem.h"
#include "cygserver_shm.h" #include "cygserver_shm.h"

View File

@ -1,6 +1,6 @@
/* cygserver.cc /* cygserver.cc
Copyright 2001, 2002, 2003 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Egor Duda <deo@logos-m.ru> Written by Egor Duda <deo@logos-m.ru>
@ -16,6 +16,7 @@ details. */
#include <sys/types.h> #include <sys/types.h>
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <ctype.h> #include <ctype.h>
#include <getopt.h> #include <getopt.h>
#include <signal.h> #include <signal.h>
@ -24,7 +25,6 @@ details. */
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "cygerrno.h"
#include "cygwin_version.h" #include "cygwin_version.h"
#include "cygserver.h" #include "cygserver.h"

View File

@ -1,6 +1,6 @@
/* msg.cc: Single unix specification IPC interface for Cygwin. /* msg.cc: Single unix specification IPC interface for Cygwin.
Copyright 2003 Red Hat, Inc. Copyright 2003, 2004 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.

View File

@ -1,6 +1,6 @@
/* process.cc /* process.cc
Copyright 2001, 2002 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>
@ -10,6 +10,7 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
#ifdef __OUTSIDE_CYGWIN__
#include "woutsup.h" #include "woutsup.h"
#include <sys/types.h> #include <sys/types.h>
@ -17,8 +18,6 @@ details. */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "cygerrno.h"
#include "process.h" #include "process.h"
/*****************************************************************************/ /*****************************************************************************/
@ -250,7 +249,6 @@ process_cache::process (const pid_t cygpid, const DWORD winpid,
"new connection refused for %d(%lu)"), "new connection refused for %d(%lu)"),
MAXIMUM_WAIT_OBJECTS - SPECIALS_COUNT, MAXIMUM_WAIT_OBJECTS - SPECIALS_COUNT,
cygpid, winpid); cygpid, winpid);
set_errno (EAGAIN);
return NULL; return NULL;
} }
@ -259,7 +257,6 @@ process_cache::process (const pid_t cygpid, const DWORD winpid,
{ {
LeaveCriticalSection (&_cache_write_access); LeaveCriticalSection (&_cache_write_access);
delete entry; delete entry;
set_errno (ESRCH);
return NULL; return NULL;
} }
@ -433,3 +430,4 @@ process_cache::find (const DWORD winpid, class process **previous)
} }
/*****************************************************************************/ /*****************************************************************************/
#endif /* __OUTSIDE_CYGWIN__ */

View File

@ -1,6 +1,6 @@
/* process.h /* process.h
Copyright 2001, 2002 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>

View File

@ -1,6 +1,6 @@
/* sem.cc: Single unix specification IPC interface for Cygwin. /* sem.cc: Single unix specification IPC interface for Cygwin.
Copyright 2003 Red Hat, Inc. Copyright 2003, 2004 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.

View File

@ -1,6 +1,6 @@
/* shm.cc: Single unix specification IPC interface for Cygwin. /* shm.cc: Single unix specification IPC interface for Cygwin.
Copyright 2003 Red Hat, Inc. Copyright 2003, 2004 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.

View File

@ -1,6 +1,6 @@
/* threaded_queue.h /* threaded_queue.h
Copyright 2001, 2002 Red Hat Inc. Copyright 2001, 2002, 2003 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>

View File

@ -1,6 +1,6 @@
/* transport.cc /* transport.cc
Copyright 2001, 2002, 2003 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>

View File

@ -1,6 +1,6 @@
/* transport.h /* transport.h
Copyright 2001, 2002, 2003 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>

View File

@ -1,6 +1,6 @@
/* transport_pipes.cc /* transport_pipes.cc
Copyright 2001, 2002, 2003 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>
@ -35,6 +35,12 @@ details. */
#include "security.h" #include "security.h"
#endif #endif
#ifdef __INSIDE_CYGWIN__
#define SET_ERRNO(err) set_errno (err)
#else
#define SET_ERRNO(err) errno = (err)
#endif
enum enum
{ {
MAX_WAIT_NAMED_PIPE_RETRY = 64, MAX_WAIT_NAMED_PIPE_RETRY = 64,
@ -214,7 +220,7 @@ transport_layer_pipes::read (void *const buf, const size_t len)
if (!ReadFile (_hPipe, buf, len, &count, NULL)) if (!ReadFile (_hPipe, buf, len, &count, NULL))
{ {
debug_printf ("error reading from pipe (%lu)", GetLastError ()); debug_printf ("error reading from pipe (%lu)", GetLastError ());
set_errno (EINVAL); // FIXME? SET_ERRNO (EINVAL); // FIXME?
return -1; return -1;
} }
@ -234,7 +240,7 @@ transport_layer_pipes::write (void *const buf, const size_t len)
if (!WriteFile (_hPipe, buf, len, &count, NULL)) if (!WriteFile (_hPipe, buf, len, &count, NULL))
{ {
debug_printf ("error writing to pipe, error = %lu", GetLastError ()); debug_printf ("error writing to pipe, error = %lu", GetLastError ());
set_errno (EINVAL); // FIXME? SET_ERRNO (EINVAL); // FIXME?
return -1; return -1;
} }

View File

@ -1,6 +1,6 @@
/* transport_sockets.cc /* transport_sockets.cc
Copyright 2001, 2002 Red Hat Inc. Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>
@ -22,13 +22,21 @@ details. */
#include <sys/stat.h> #include <sys/stat.h>
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "cygerrno.h"
#include "transport.h" #include "transport.h"
#include "transport_sockets.h" #include "transport_sockets.h"
#ifdef __INSIDE_CYGWIN__
#define SET_ERRNO(err) set_errno (err)
#define GET_ERRNO() get_errno ()
#else
#define SET_ERRNO(err) errno = (err)
#define GET_ERRNO() (errno)
#endif
/* to allow this to link into cygwin and the .dll, a little magic is needed. */ /* to allow this to link into cygwin and the .dll, a little magic is needed. */
#ifndef __OUTSIDE_CYGWIN__ #ifndef __OUTSIDE_CYGWIN__
@ -99,10 +107,10 @@ transport_layer_sockets::listen ()
if (stat (_addr.sun_path, &sbuf) == -1) if (stat (_addr.sun_path, &sbuf) == -1)
{ {
if (errno != ENOENT) if (GET_ERRNO () != ENOENT)
{ {
system_printf ("cannot access socket file `%s': %s", system_printf ("cannot access socket file `%s': %s",
_addr.sun_path, strerror (errno)); _addr.sun_path, strerror (GET_ERRNO ()));
return -1; return -1;
} }
} }
@ -115,7 +123,7 @@ transport_layer_sockets::listen ()
if (newfd == -1) if (newfd == -1)
{ {
system_printf ("failed to create UNIX domain socket: %s", system_printf ("failed to create UNIX domain socket: %s",
strerror (errno)); strerror (GET_ERRNO ()));
return -1; return -1;
} }
@ -133,7 +141,7 @@ transport_layer_sockets::listen ()
if (unlink (_addr.sun_path) == -1) if (unlink (_addr.sun_path) == -1)
{ {
system_printf ("failed to remove `%s': %s", system_printf ("failed to remove `%s': %s",
_addr.sun_path, strerror (errno)); _addr.sun_path, strerror (GET_ERRNO ()));
(void) ::close (newfd); (void) ::close (newfd);
return -1; return -1;
} }
@ -150,17 +158,17 @@ transport_layer_sockets::listen ()
if (_fd == -1) if (_fd == -1)
{ {
system_printf ("failed to create UNIX domain socket: %s", system_printf ("failed to create UNIX domain socket: %s",
strerror (errno)); strerror (GET_ERRNO ()));
return -1; return -1;
} }
if (cygwin_bind (_fd, (struct sockaddr *) &_addr, _addr_len) == -1) if (cygwin_bind (_fd, (struct sockaddr *) &_addr, _addr_len) == -1)
{ {
const int saved_errno = errno; const int saved_errno = GET_ERRNO ();
close (); close ();
errno = saved_errno; SET_ERRNO (saved_errno);
system_printf ("failed to bind UNIX domain socket `%s': %s", system_printf ("failed to bind UNIX domain socket `%s': %s",
_addr.sun_path, strerror (errno)); _addr.sun_path, strerror (GET_ERRNO ()));
return -1; return -1;
} }
@ -168,11 +176,11 @@ transport_layer_sockets::listen ()
if (cygwin_listen (_fd, SOMAXCONN) == -1) if (cygwin_listen (_fd, SOMAXCONN) == -1)
{ {
const int saved_errno = errno; const int saved_errno = GET_ERRNO ();
close (); close ();
errno = saved_errno; SET_ERRNO (saved_errno);
system_printf ("failed to listen on UNIX domain socket `%s': %s", system_printf ("failed to listen on UNIX domain socket `%s': %s",
_addr.sun_path, strerror (errno)); _addr.sun_path, strerror (GET_ERRNO ()));
return -1; return -1;
} }
@ -198,8 +206,8 @@ transport_layer_sockets::accept (bool *const recoverable)
if (accept_fd == -1) if (accept_fd == -1)
{ {
system_printf ("failed to accept connection: %s", strerror (errno)); system_printf ("failed to accept connection: %s", strerror (GET_ERRNO ()));
switch (errno) switch (GET_ERRNO ())
{ {
case ECONNABORTED: case ECONNABORTED:
case EINTR: case EINTR:
@ -276,7 +284,7 @@ transport_layer_sockets::read (void *const buf, const size_t buf_len)
if (res != -1) if (res != -1)
{ {
if (res == 0) if (res == 0)
errno = EIO; // FIXME? SET_ERRNO (EIO); // FIXME?
res = buf_len - read_buf_len; res = buf_len - read_buf_len;
} }
@ -284,7 +292,7 @@ transport_layer_sockets::read (void *const buf, const size_t buf_len)
if (res != static_cast<ssize_t> (buf_len)) if (res != static_cast<ssize_t> (buf_len))
debug_printf ("%d = read (buf = %p, len = %u) [this = %p, fd = %d]: %s", debug_printf ("%d = read (buf = %p, len = %u) [this = %p, fd = %d]: %s",
res, buf, buf_len, this, _fd, res, buf, buf_len, this, _fd,
(res == -1 ? strerror (errno) : "EOF")); (res == -1 ? strerror (GET_ERRNO ()) : "EOF"));
else else
{ {
// verbose: debug_printf ("%d = read (buf = %p, len = %u) [this = %p, fd = %d]", // verbose: debug_printf ("%d = read (buf = %p, len = %u) [this = %p, fd = %d]",
@ -322,7 +330,7 @@ transport_layer_sockets::write (void *const buf, const size_t buf_len)
if (res != -1) if (res != -1)
{ {
if (res == 0) if (res == 0)
errno = EIO; // FIXME? SET_ERRNO (EIO); // FIXME?
res = buf_len - write_buf_len; res = buf_len - write_buf_len;
} }
@ -330,7 +338,7 @@ transport_layer_sockets::write (void *const buf, const size_t buf_len)
if (res != static_cast<ssize_t> (buf_len)) if (res != static_cast<ssize_t> (buf_len))
debug_printf ("%d = write (buf = %p, len = %u) [this = %p, fd = %d]: %s", debug_printf ("%d = write (buf = %p, len = %u) [this = %p, fd = %d]: %s",
res, buf, buf_len, this, _fd, res, buf, buf_len, this, _fd,
(res == -1 ? strerror (errno) : "EOF")); (res == -1 ? strerror (GET_ERRNO ()) : "EOF"));
else else
{ {
// verbose: debug_printf ("%d = write (buf = %p, len = %u) [this = %p, fd = %d]", // verbose: debug_printf ("%d = write (buf = %p, len = %u) [this = %p, fd = %d]",
@ -358,7 +366,7 @@ transport_layer_sockets::connect ()
if (_fd == -1) if (_fd == -1)
{ {
system_printf ("failed to create UNIX domain socket: %s", system_printf ("failed to create UNIX domain socket: %s",
strerror (errno)); strerror (GET_ERRNO ()));
return -1; return -1;
} }
@ -369,9 +377,9 @@ transport_layer_sockets::connect ()
return 0; return 0;
} }
if (!assume_cygserver || errno != ECONNREFUSED) if (!assume_cygserver || GET_ERRNO () != ECONNREFUSED)
{ {
debug_printf ("failed to connect to server: %s", strerror (errno)); debug_printf ("failed to connect to server: %s", strerror (GET_ERRNO ()));
(void) ::close (_fd); (void) ::close (_fd);
_fd = -1; _fd = -1;
return -1; return -1;
@ -382,6 +390,6 @@ transport_layer_sockets::connect ()
Sleep (0); // Give the server a chance. Sleep (0); // Give the server a chance.
} }
debug_printf ("failed to connect to server: %s", strerror (errno)); debug_printf ("failed to connect to server: %s", strerror (GET_ERRNO ()));
return -1; return -1;
} }

View File

@ -1,6 +1,6 @@
/* transport_sockets.h /* transport_sockets.h
Copyright 2001, 2002 Red Hat Inc. Copyright 2001, 2002, 2003 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com> Written by Robert Collins <rbtcollins@hotmail.com>