diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2012-10-27 22:25:47 -0400 |
---|---|---|
committer | Jan Dubois <jand@activestate.com> | 2012-11-08 16:54:55 -0800 |
commit | 073dd0357a846739ff3ae9a14379de2302d5e877 (patch) | |
tree | e98d00b9a5881f5381d9815828990a60737fe091 | |
parent | e566981e5a5b2c2716eea4363106c4ed7620e5bb (diff) | |
download | perl-073dd0357a846739ff3ae9a14379de2302d5e877.tar.gz |
"func not implemented" croaks optimizations in /win32/*
This commit removes a number of "* not implemented" strings from the image.
A win32_croak_not_implemented wrapper is created to reduce machine code
by not putting the format string on the C stack many times. embed.fnc was
used to declare win32_croak_not_implemented for proper cross compiler
support of noreturn (noreturn on GCC and VC ok). Tailcalling and noreturn
optimizations of the C compiler are heavily used in this commit.
-rw-r--r-- | embed.fnc | 4 | ||||
-rw-r--r-- | proto.h | 8 | ||||
-rw-r--r-- | win32/perlhost.h | 5 | ||||
-rw-r--r-- | win32/win32.c | 11 | ||||
-rw-r--r-- | win32/win32sck.c | 39 |
5 files changed, 35 insertions, 32 deletions
@@ -249,7 +249,9 @@ Aprd |void |vcroak |NULLOK const char* pat|NULLOK va_list* args Aprd |void |croak_no_modify Aprd |void |croak_xs_usage |NN const CV *const cv \ |NN const char *const params - +#if defined(WIN32) +norx |void |win32_croak_not_implemented|NN const char * fname +#endif #if defined(PERL_IMPLICIT_CONTEXT) Afnrp |void |croak_nocontext|NULLOK const char* pat|... Afnp |OP* |die_nocontext |NULLOK const char* pat|... @@ -7728,6 +7728,14 @@ PERL_CALLCONV SSize_t Perl_PerlIO_write(pTHX_ PerlIO *f, const void *vbuf, Size_ assert(vbuf) #endif +#if defined(WIN32) +PERL_CALLCONV_NO_RET void win32_croak_not_implemented(const char * fname) + __attribute__noreturn__ + __attribute__nonnull__(1); +#define PERL_ARGS_ASSERT_WIN32_CROAK_NOT_IMPLEMENTED \ + assert(fname) + +#endif #if defined(WIN32) || defined(__SYMBIAN32__) || defined(VMS) PERL_CALLCONV int Perl_do_aspawn(pTHX_ SV* really, SV** mark, SV** sp) __attribute__nonnull__(pTHX_2) diff --git a/win32/perlhost.h b/win32/perlhost.h index 3f18126f5d..7b3f0379c5 100644 --- a/win32/perlhost.h +++ b/win32/perlhost.h @@ -1278,8 +1278,7 @@ PerlSockGethostbyname(struct IPerlSock* piPerl, const char* name) struct hostent* PerlSockGethostent(struct IPerlSock* piPerl) { - dTHX; - Perl_croak(aTHX_ "gethostent not implemented!\n"); + win32_croak_not_implemented("gethostent"); return NULL; } @@ -1861,7 +1860,7 @@ PerlProcFork(struct IPerlProc* piPerl) # endif return -(int)id; #else - Perl_croak(aTHX_ "fork() not implemented!\n"); + win32_croak_not_implemented("fork()"); return -1; #endif /* USE_ITHREADS */ } diff --git a/win32/win32.c b/win32/win32.c index 5a932ca7f6..1686594a3c 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1676,6 +1676,14 @@ out_of_memory(void) exit(1); } +void +win32_croak_not_implemented(const char * fname) +{ + PERL_ARGS_ASSERT_WIN32_CROAK_NOT_IMPLEMENTED; + + Perl_croak_nocontext("%s not implemented!\n", fname); +} + /* Converts a wide character (UTF-16) string to the Windows ANSI code page, * potentially using the system's default replacement character for any * unrepresentable characters. The caller must free() the returned string. */ @@ -2901,8 +2909,7 @@ win32_pipe(int *pfd, unsigned int size, int mode) DllExport PerlIO* win32_popenlist(const char *mode, IV narg, SV **args) { - dTHX; - Perl_croak(aTHX_ "List form of pipe open not implemented"); + Perl_croak_nocontext("List form of pipe open not implemented"); return NULL; } diff --git a/win32/win32sck.c b/win32/win32sck.c index 9032a6d7f5..4285b29e27 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -596,101 +596,88 @@ win32_inet_addr(const char FAR *cp) void win32_endhostent() { - dTHX; - Perl_croak_nocontext("endhostent not implemented!\n"); + win32_croak_not_implemented("endhostent"); } void win32_endnetent() { - dTHX; - Perl_croak_nocontext("endnetent not implemented!\n"); + win32_croak_not_implemented("endnetent"); } void win32_endprotoent() { - dTHX; - Perl_croak_nocontext("endprotoent not implemented!\n"); + win32_croak_not_implemented("endprotoent"); } void win32_endservent() { - dTHX; - Perl_croak_nocontext("endservent not implemented!\n"); + win32_croak_not_implemented("endservent"); } struct netent * win32_getnetent(void) { - dTHX; - Perl_croak_nocontext("getnetent not implemented!\n"); + win32_croak_not_implemented("getnetent"); return (struct netent *) NULL; } struct netent * win32_getnetbyname(char *name) { - dTHX; - Perl_croak_nocontext("getnetbyname not implemented!\n"); + win32_croak_not_implemented("getnetbyname"); return (struct netent *)NULL; } struct netent * win32_getnetbyaddr(long net, int type) { - dTHX; - Perl_croak_nocontext("getnetbyaddr not implemented!\n"); + win32_croak_not_implemented("getnetbyaddr"); return (struct netent *)NULL; } struct protoent * win32_getprotoent(void) { - dTHX; - Perl_croak_nocontext("getprotoent not implemented!\n"); + win32_croak_not_implemented("getprotoent"); return (struct protoent *) NULL; } struct servent * win32_getservent(void) { - dTHX; - Perl_croak_nocontext("getservent not implemented!\n"); + win32_croak_not_implemented("getservent"); return (struct servent *) NULL; } void win32_sethostent(int stayopen) { - dTHX; - Perl_croak_nocontext("sethostent not implemented!\n"); + win32_croak_not_implemented("sethostent"); } void win32_setnetent(int stayopen) { - dTHX; - Perl_croak_nocontext("setnetent not implemented!\n"); + win32_croak_not_implemented("setnetent"); } void win32_setprotoent(int stayopen) { - dTHX; - Perl_croak_nocontext("setprotoent not implemented!\n"); + win32_croak_not_implemented("setprotoent"); } void win32_setservent(int stayopen) { - dTHX; - Perl_croak_nocontext("setservent not implemented!\n"); + win32_croak_not_implemented("setservent"); } static struct servent* |