Skip to content

Return WIN32_NO_SOCKETS for miniperl.exe #22679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: blead
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion win32/perllib.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ DllMain(HINSTANCE hModule, /* DLL module handle */
A. Not called at all.
B. Called after memory allocation for Heap has been forcibly removed by OS.
PerlIO_cleanup() was done here but fails (B).
*/
*/
#ifndef WIN32_NO_SOCKETS
EndSockets();
#endif
#if defined(USE_ITHREADS)
if (PL_curinterp)
FREE_THREAD_KEY;
Expand Down
7 changes: 4 additions & 3 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -5461,13 +5461,12 @@ Perl_win32_init(int *argcp, char ***argvp)
*/
InitCommonControls();

WSADATA wsadata;
WSAStartup(MAKEWORD(2, 2), &wsadata);

g_osver.dwOSVersionInfoSize = sizeof(g_osver);
GetVersionEx(&g_osver);

#ifndef WIN32_NO_SOCKETS
win32_hook_closehandle_in_crt();
#endif

ansify_path();

Expand Down Expand Up @@ -5516,7 +5515,9 @@ Perl_win32_term(void)
RegCloseKey(HKCU_Perl_hnd);
/* the handles are in an undefined state until the next PERL_SYS_INIT3 */
#endif
#ifndef WIN32_NO_SOCKETS
win32_unhook_closehandle_in_crt();
#endif
}

void
Expand Down
29 changes: 29 additions & 0 deletions win32/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

/* Win32 only optimizations for faster building */
#ifdef PERL_IS_MINIPERL
/* this macro will remove Winsock only on miniperl, PERL_IMPLICIT_SYS and
* makedef.pl create dependencies that will keep Winsock linked in even with
* this macro defined, even though sockets will be umimplemented from a script
* level in full perl
*/
# define WIN32_NO_SOCKETS
/* less I/O calls during each require */
# define PERL_DISABLE_PMC

Expand All @@ -25,6 +31,29 @@
# define PERL_TEXTMODE_SCRIPTS
#endif

#ifdef WIN32_NO_SOCKETS
# undef HAS_SOCKET
# undef HAS_GETPROTOBYNAME
# undef HAS_GETPROTOBYNUMBER
# undef HAS_GETPROTOENT
# undef HAS_GETNETBYNAME
# undef HAS_GETNETBYADDR
# undef HAS_GETNETENT
# undef HAS_GETSERVBYNAME
# undef HAS_GETSERVBYPORT
# undef HAS_GETSERVENT
# undef HAS_GETHOSTBYNAME
# undef HAS_GETHOSTBYADDR
# undef HAS_GETHOSTENT
# undef HAS_SELECT
# undef HAS_IOCTL
# undef HAS_NTOHL
# undef HAS_HTONL
# undef HAS_HTONS
# undef HAS_NTOHS
# define WIN32SCK_IS_STDSCK
#endif

#if defined(PERL_IMPLICIT_SYS)
# define DYNAMIC_ENV_FETCH
# define HAS_GETENV_LEN
Expand Down
Loading