mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* cygtls.h (unionent): Move from net.cc.
(unionent::struct_type): Move enum here. (_local_storage::hostent_buf): Define as unionent. (_local_storage::protoent_buf): Ditto. (_local_storage::servent_buf): Ditto. * net.cc (unionent): Move to cygtls.h. (struct_type): Ditto. (dup_ent): Define one function per {host,proto,serv}ent type. (cygwin_getprotobyname): Simplify dup_ent call. Removed now-unneeded return type coercion. (cygwin_getprotobynumber): Ditto. (cygwin_getservbyname): Ditto. (cygwin_getservbyport): Ditto. (cygwin_gethostbyname): Ditto. (cygwin_gethostbyaddr): Ditto. tlsoffsets.h: Regenerate.
This commit is contained in:
parent
fb4e8779d0
commit
f2c11dadcf
@ -1,3 +1,22 @@
|
||||
2008-09-15 Christopher Faylor <me+cygwin@cgf.cx>
|
||||
|
||||
* cygtls.h (unionent): Move from net.cc.
|
||||
(unionent::struct_type): Move enum here.
|
||||
(_local_storage::hostent_buf): Define as unionent.
|
||||
(_local_storage::protoent_buf): Ditto.
|
||||
(_local_storage::servent_buf): Ditto.
|
||||
* net.cc (unionent): Move to cygtls.h.
|
||||
(struct_type): Ditto.
|
||||
(dup_ent): Define one function per {host,proto,serv}ent type.
|
||||
(cygwin_getprotobyname): Simplify dup_ent call. Removed now-unneeded
|
||||
return type coercion.
|
||||
(cygwin_getprotobynumber): Ditto.
|
||||
(cygwin_getservbyname): Ditto.
|
||||
(cygwin_getservbyport): Ditto.
|
||||
(cygwin_gethostbyname): Ditto.
|
||||
(cygwin_gethostbyaddr): Ditto.
|
||||
tlsoffsets.h: Regenerate.
|
||||
|
||||
2008-09-12 Christopher Faylor <me+cygwin@cgf.cx>
|
||||
|
||||
* Makefile.in: Add -c option which is now removed from COMPILE_C*.
|
||||
@ -73,13 +92,14 @@
|
||||
* dll_init.cc (release_upto): Fix typo involving incorrect use of '|'.
|
||||
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a
|
||||
compiler warning regarding coercing type-punned variables.
|
||||
(fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc
|
||||
(fhandler_fifo::open_nonserver): Fix = vs. == typo.
|
||||
(fhandler_base::fstat_by_name): Ditto.
|
||||
* fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo.
|
||||
(fhandler_fifo::wait): Add all conditions to switch statement to avoid
|
||||
a compiler warning.
|
||||
* fhandler_process.cc: Avoid unneeded initialization of variables to
|
||||
zero.
|
||||
(fhandler_socket::listen): Add braces around initializer.
|
||||
* fhandler_socket.cc (fhandler_socket::listen): Add braces around
|
||||
initializer.
|
||||
* flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a
|
||||
compiler warning. Fix problem with EWOULDBLOCK error return.
|
||||
* path.cc (GUID_shortcut): Use braces around struct initializer.
|
||||
|
@ -51,6 +51,24 @@ public:
|
||||
friend class _cygtls;
|
||||
};
|
||||
|
||||
class unionent
|
||||
{
|
||||
public:
|
||||
char *name;
|
||||
char **list;
|
||||
short port_proto_addrtype;
|
||||
short h_len;
|
||||
union
|
||||
{
|
||||
char *s_proto;
|
||||
char **h_addr_list;
|
||||
};
|
||||
enum struct_type
|
||||
{
|
||||
t_hostent, t_protoent, t_servent
|
||||
};
|
||||
};
|
||||
|
||||
struct _local_storage
|
||||
{
|
||||
/*
|
||||
@ -102,11 +120,12 @@ struct _local_storage
|
||||
|
||||
/* net.cc */
|
||||
char *ntoa_buf; // note: malloced
|
||||
struct protoent *protoent_buf; // note: malloced
|
||||
struct servent *servent_buf; // note: malloced
|
||||
struct hostent *hostent_buf; // note: malloced
|
||||
char signamebuf[sizeof ("Unknown signal 4294967295 ")];
|
||||
|
||||
unionent *hostent_buf; // note: malloced
|
||||
unionent *protoent_buf; // note: malloced
|
||||
unionent *servent_buf; // note: malloced
|
||||
|
||||
/* cygthread.cc */
|
||||
char unknown_thread_name[30];
|
||||
|
||||
|
@ -293,24 +293,6 @@ struct pservent
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct unionent
|
||||
{
|
||||
char *name;
|
||||
char **list;
|
||||
short port_proto_addrtype;
|
||||
short h_len;
|
||||
union
|
||||
{
|
||||
char *s_proto;
|
||||
char **h_addr_list;
|
||||
};
|
||||
};
|
||||
|
||||
enum struct_type
|
||||
{
|
||||
t_hostent, t_protoent, t_servent
|
||||
};
|
||||
|
||||
static const char *entnames[] = {"host", "proto", "serv"};
|
||||
|
||||
/* Generic "dup a {host,proto,serv}ent structure" function.
|
||||
@ -322,18 +304,16 @@ static const char *entnames[] = {"host", "proto", "serv"};
|
||||
The 'unionent' struct is a union of all of the currently used
|
||||
*ent structure. */
|
||||
|
||||
/* FIXME: Use an overloaded function or template here. */
|
||||
#define dup_ent(old, src, type) __dup_ent ((unionent *&) *((unionent *) _my_tls.locals.old), (unionent *) (src), type)
|
||||
#ifdef DEBUGGING
|
||||
static void *
|
||||
#else
|
||||
static inline void *
|
||||
#endif
|
||||
__dup_ent (unionent *&dst, unionent *src, struct_type type)
|
||||
dup_ent (unionent *&dst, unionent *src, unionent::struct_type type)
|
||||
{
|
||||
if (dst)
|
||||
debug_printf ("old %sent structure \"%s\" %p\n", entnames[type],
|
||||
((unionent *) dst)->name, dst);
|
||||
dst->name, dst);
|
||||
|
||||
if (!src)
|
||||
{
|
||||
@ -347,13 +327,13 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
|
||||
int sz, struct_sz;
|
||||
switch (type)
|
||||
{
|
||||
case t_protoent:
|
||||
case unionent::t_protoent:
|
||||
struct_sz = sizeof (protoent);
|
||||
break;
|
||||
case t_servent:
|
||||
case unionent::t_servent:
|
||||
struct_sz = sizeof (servent);
|
||||
break;
|
||||
case t_hostent:
|
||||
case unionent::t_hostent:
|
||||
struct_sz = sizeof (hostent);
|
||||
break;
|
||||
default:
|
||||
@ -386,12 +366,12 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
|
||||
/* Do servent/hostent specific processing */
|
||||
int protolen = 0;
|
||||
int addr_list_len = 0;
|
||||
if (type == t_servent)
|
||||
if (type == unionent::t_servent)
|
||||
{
|
||||
if (src->s_proto)
|
||||
sz += (protolen = strlen_round (src->s_proto));
|
||||
}
|
||||
else if (type == t_hostent)
|
||||
else if (type == unionent::t_hostent)
|
||||
{
|
||||
/* Calculate the length and storage used for h_addr_list */
|
||||
for (av = src->h_addr_list; av && *av; av++)
|
||||
@ -412,7 +392,6 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
|
||||
unsigned rsz = 256 * ((sz + 255) / 256);
|
||||
dst = (unionent *) realloc (dst, rsz);
|
||||
|
||||
/* Hopefully, this worked. */
|
||||
if (dst)
|
||||
{
|
||||
memset (dst, 0, sz);
|
||||
@ -444,9 +423,9 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
|
||||
}
|
||||
|
||||
/* Do servent/protoent/hostent specific processing. */
|
||||
if (type == t_protoent)
|
||||
if (type == unionent::t_protoent)
|
||||
debug_printf ("protoent %s %x %x", dst->name, dst->list, dst->port_proto_addrtype);
|
||||
else if (type == t_servent)
|
||||
else if (type == unionent::t_servent)
|
||||
{
|
||||
if (src->s_proto)
|
||||
{
|
||||
@ -454,7 +433,7 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
|
||||
dp += protolen;
|
||||
}
|
||||
}
|
||||
else if (type == t_hostent)
|
||||
else if (type == unionent::t_hostent)
|
||||
{
|
||||
/* Transfer h_len and duplicate contents of h_addr_list, using
|
||||
memory after 'list' allocation. */
|
||||
@ -474,6 +453,24 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
|
||||
return dst;
|
||||
}
|
||||
|
||||
static inline hostent *
|
||||
dup_ent (hostent *src)
|
||||
{
|
||||
return (hostent *) dup_ent (_my_tls.locals.hostent_buf, (unionent *) src, unionent::t_hostent);
|
||||
}
|
||||
|
||||
static inline protoent *
|
||||
dup_ent (protoent *src)
|
||||
{
|
||||
return (protoent *) dup_ent (_my_tls.locals.protoent_buf, (unionent *) src, unionent::t_protoent);
|
||||
}
|
||||
|
||||
static inline servent *
|
||||
dup_ent (servent *src)
|
||||
{
|
||||
return (servent *) dup_ent (_my_tls.locals.servent_buf, (unionent *) src, unionent::t_servent);
|
||||
}
|
||||
|
||||
/* exported as getprotobyname: standards? */
|
||||
extern "C" struct protoent *
|
||||
cygwin_getprotobyname (const char *p)
|
||||
@ -481,14 +478,14 @@ cygwin_getprotobyname (const char *p)
|
||||
myfault efault;
|
||||
if (efault.faulted (EFAULT))
|
||||
return NULL;
|
||||
return (protoent *) dup_ent (protoent_buf, getprotobyname (p), t_protoent);
|
||||
return dup_ent (getprotobyname (p));
|
||||
}
|
||||
|
||||
/* exported as getprotobynumber: standards? */
|
||||
extern "C" struct protoent *
|
||||
cygwin_getprotobynumber (int number)
|
||||
{
|
||||
return (protoent *) dup_ent (protoent_buf, getprotobynumber (number), t_protoent);
|
||||
return dup_ent (getprotobynumber (number));
|
||||
}
|
||||
|
||||
bool
|
||||
@ -786,7 +783,7 @@ cygwin_getservbyname (const char *name, const char *proto)
|
||||
if (efault.faulted (EFAULT))
|
||||
return NULL;
|
||||
|
||||
servent *res = (servent *) dup_ent (servent_buf, getservbyname (name, proto), t_servent);
|
||||
servent *res = dup_ent (getservbyname (name, proto));
|
||||
syscall_printf ("%p = getservbyname (%s, %s)", res, name, proto);
|
||||
return res;
|
||||
}
|
||||
@ -800,8 +797,8 @@ cygwin_getservbyport (int port, const char *proto)
|
||||
if (efault.faulted (EFAULT))
|
||||
return NULL;
|
||||
|
||||
servent *res = (servent *) dup_ent (servent_buf, getservbyport (port, proto), t_servent);
|
||||
syscall_printf ("%p = getservbyport (%d, %s)", _my_tls.locals.servent_buf, port, proto);
|
||||
servent *res = dup_ent (getservbyport (port, proto));
|
||||
syscall_printf ("%p = getservbyport (%d, %s)", res, port, proto);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -863,7 +860,7 @@ cygwin_gethostbyname (const char *name)
|
||||
h = &tmp;
|
||||
}
|
||||
|
||||
hostent *res = (hostent *) dup_ent (hostent_buf, h, t_hostent);
|
||||
hostent *res = dup_ent (h);
|
||||
if (res)
|
||||
debug_printf ("h_name %s", res->h_name);
|
||||
else
|
||||
@ -883,9 +880,9 @@ cygwin_gethostbyaddr (const char *addr, int len, int type)
|
||||
if (efault.faulted (EFAULT))
|
||||
return NULL;
|
||||
|
||||
hostent *res = (hostent *) dup_ent (hostent_buf, gethostbyaddr (addr, len, type), t_hostent);
|
||||
hostent *res = dup_ent (gethostbyaddr (addr, len, type));
|
||||
if (res)
|
||||
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
|
||||
debug_printf ("h_name %s", res->h_name);
|
||||
else
|
||||
set_host_errno ();
|
||||
return res;
|
||||
|
@ -1,6 +1,6 @@
|
||||
//;# autogenerated: Do not edit.
|
||||
|
||||
//; $tls::sizeof__cygtls = 4292;
|
||||
//; $tls::sizeof__cygtls = 4296;
|
||||
//; $tls::func = -12700;
|
||||
//; $tls::pfunc = 0;
|
||||
//; $tls::el = -12696;
|
||||
@ -39,30 +39,30 @@
|
||||
//; $tls::p__dontuse = 420;
|
||||
//; $tls::locals = -11216;
|
||||
//; $tls::plocals = 1484;
|
||||
//; $tls::_ctinfo = -9512;
|
||||
//; $tls::p_ctinfo = 3188;
|
||||
//; $tls::andreas = -9508;
|
||||
//; $tls::pandreas = 3192;
|
||||
//; $tls::wq = -9492;
|
||||
//; $tls::pwq = 3208;
|
||||
//; $tls::prev = -9464;
|
||||
//; $tls::pprev = 3236;
|
||||
//; $tls::next = -9460;
|
||||
//; $tls::pnext = 3240;
|
||||
//; $tls::sig = -9456;
|
||||
//; $tls::psig = 3244;
|
||||
//; $tls::incyg = -9452;
|
||||
//; $tls::pincyg = 3248;
|
||||
//; $tls::spinning = -9448;
|
||||
//; $tls::pspinning = 3252;
|
||||
//; $tls::stacklock = -9444;
|
||||
//; $tls::pstacklock = 3256;
|
||||
//; $tls::stackptr = -9440;
|
||||
//; $tls::pstackptr = 3260;
|
||||
//; $tls::stack = -9436;
|
||||
//; $tls::pstack = 3264;
|
||||
//; $tls::initialized = -8412;
|
||||
//; $tls::pinitialized = 4288;
|
||||
//; $tls::_ctinfo = -9508;
|
||||
//; $tls::p_ctinfo = 3192;
|
||||
//; $tls::andreas = -9504;
|
||||
//; $tls::pandreas = 3196;
|
||||
//; $tls::wq = -9488;
|
||||
//; $tls::pwq = 3212;
|
||||
//; $tls::prev = -9460;
|
||||
//; $tls::pprev = 3240;
|
||||
//; $tls::next = -9456;
|
||||
//; $tls::pnext = 3244;
|
||||
//; $tls::sig = -9452;
|
||||
//; $tls::psig = 3248;
|
||||
//; $tls::incyg = -9448;
|
||||
//; $tls::pincyg = 3252;
|
||||
//; $tls::spinning = -9444;
|
||||
//; $tls::pspinning = 3256;
|
||||
//; $tls::stacklock = -9440;
|
||||
//; $tls::pstacklock = 3260;
|
||||
//; $tls::stackptr = -9436;
|
||||
//; $tls::pstackptr = 3264;
|
||||
//; $tls::stack = -9432;
|
||||
//; $tls::pstack = 3268;
|
||||
//; $tls::initialized = -8408;
|
||||
//; $tls::pinitialized = 4292;
|
||||
//; __DATA__
|
||||
|
||||
#define tls_func (-12700)
|
||||
@ -103,27 +103,27 @@
|
||||
#define tls_p__dontuse (420)
|
||||
#define tls_locals (-11216)
|
||||
#define tls_plocals (1484)
|
||||
#define tls__ctinfo (-9512)
|
||||
#define tls_p_ctinfo (3188)
|
||||
#define tls_andreas (-9508)
|
||||
#define tls_pandreas (3192)
|
||||
#define tls_wq (-9492)
|
||||
#define tls_pwq (3208)
|
||||
#define tls_prev (-9464)
|
||||
#define tls_pprev (3236)
|
||||
#define tls_next (-9460)
|
||||
#define tls_pnext (3240)
|
||||
#define tls_sig (-9456)
|
||||
#define tls_psig (3244)
|
||||
#define tls_incyg (-9452)
|
||||
#define tls_pincyg (3248)
|
||||
#define tls_spinning (-9448)
|
||||
#define tls_pspinning (3252)
|
||||
#define tls_stacklock (-9444)
|
||||
#define tls_pstacklock (3256)
|
||||
#define tls_stackptr (-9440)
|
||||
#define tls_pstackptr (3260)
|
||||
#define tls_stack (-9436)
|
||||
#define tls_pstack (3264)
|
||||
#define tls_initialized (-8412)
|
||||
#define tls_pinitialized (4288)
|
||||
#define tls__ctinfo (-9508)
|
||||
#define tls_p_ctinfo (3192)
|
||||
#define tls_andreas (-9504)
|
||||
#define tls_pandreas (3196)
|
||||
#define tls_wq (-9488)
|
||||
#define tls_pwq (3212)
|
||||
#define tls_prev (-9460)
|
||||
#define tls_pprev (3240)
|
||||
#define tls_next (-9456)
|
||||
#define tls_pnext (3244)
|
||||
#define tls_sig (-9452)
|
||||
#define tls_psig (3248)
|
||||
#define tls_incyg (-9448)
|
||||
#define tls_pincyg (3252)
|
||||
#define tls_spinning (-9444)
|
||||
#define tls_pspinning (3256)
|
||||
#define tls_stacklock (-9440)
|
||||
#define tls_pstacklock (3260)
|
||||
#define tls_stackptr (-9436)
|
||||
#define tls_pstackptr (3264)
|
||||
#define tls_stack (-9432)
|
||||
#define tls_pstack (3268)
|
||||
#define tls_initialized (-8408)
|
||||
#define tls_pinitialized (4292)
|
||||
|
Loading…
x
Reference in New Issue
Block a user