Skip to content

Commit

Permalink
Rename dll from cygwin to msys
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexpux authored and dscho committed Apr 6, 2024
1 parent e5ae236 commit d1cb51f
Show file tree
Hide file tree
Showing 40 changed files with 197 additions and 95 deletions.
2 changes: 1 addition & 1 deletion winsup/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# This makefile requires GNU make.

cygdocdir = $(datarootdir)/doc/Cygwin
cygdocdir = $(datarootdir)/doc/Msys

cygdoc_DATA = \
CYGWIN_LICENSE \
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygserver/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ libcygserver_a_SOURCES = \

libcygserver_a_CXXFLAGS = $(cygserver_flags)

cygdocdir = $(datarootdir)/doc/Cygwin
cygdocdir = $(datarootdir)/doc/Msys

install-data-local:
@$(MKDIR_P) $(DESTDIR)$(cygdocdir)
Expand Down
4 changes: 4 additions & 0 deletions winsup/cygserver/transport_pipes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ details. */
#ifndef _TRANSPORT_PIPES_H
#define _TRANSPORT_PIPES_H

#ifdef __MSYS__
#define PIPE_NAME_PREFIX L"\\\\.\\pipe\\msys-"
#else
#define PIPE_NAME_PREFIX L"\\\\.\\pipe\\cygwin-"
#endif
#define PIPE_NAME_SUFFIX L"-lpc"

/* Named pipes based transport, for security on NT */
Expand Down
27 changes: 14 additions & 13 deletions winsup/cygwin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ newlib_build=$(target_builddir)/newlib
toollibdir=$(tooldir)/lib
toolincludedir=$(tooldir)/include

# Parameters used in building the cygwin.dll.
# Parameters used in building the msys-2.0.dll.

DLL_NAME=cygwin1.dll
NEW_DLL_NAME=new-cygwin1.dll
DEF_FILE=cygwin.def
LIB_NAME=libcygwin.a
DLL_NAME=msys-2.0.dll
NEW_DLL_NAME=new-msys-2.0.dll
DEF_FILE=msys.def
LIB_NAME=libmsys-2.0.a

#
# sources
Expand Down Expand Up @@ -584,16 +584,16 @@ LIBSERVER = $(cygserver_blddir)/libcygserver.a
$(LIBSERVER):
$(MAKE) -C $(cygserver_blddir) libcygserver.a

# We build as new-cygwin1.dll and rename at install time to overcome native
# We build as new-msys-2.0.dll and rename at install time to overcome native
# rebuilding issues (we don't want the build tools to see a partially built
# cygwin1.dll and attempt to use it instead of the old one).
# msys-2.0.dll and attempt to use it instead of the old one).

# linker script
LDSCRIPT=cygwin.sc
$(LDSCRIPT): $(LDSCRIPT).in
$(AM_V_GEN)$(CC) -E - -P < $^ -o $@

# cygwin dll
# msys-2.0 dll
# Set PE and export table header timestamps to zero for reproducible builds.
$(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\
$(newlib_build)/libm.a $(newlib_build)/libc.a
Expand All @@ -602,18 +602,18 @@ $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\
-Wl,--gc-sections -nostdlib -Wl,-T$(LDSCRIPT) \
-Wl,--dynamicbase -static \
$${SOURCE_DATE_EPOCH:+-Wl,--no-insert-timestamp} \
-Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \
-Wl,--heap=0 -Wl,--out-implib,msysdll.a -shared -o $@ \
-e @DLL_ENTRY@ $(DEF_FILE) \
-Wl,-whole-archive libdll.a -Wl,-no-whole-archive \
$(VERSION_OFILES) \
$(LIBSERVER) \
$(newlib_build)/libm.a \
$(newlib_build)/libc.a \
-lgcc -lkernel32 -lntdll -Wl,-Map,cygwin.map
-lgcc -lkernel32 -lntdll -Wl,-Map,msys.map
@$(MKDIR_P) ${target_builddir}/winsup/testsuite/testinst/bin/
$(AM_V_at)$(INSTALL_PROGRAM) $(NEW_DLL_NAME) ${target_builddir}/winsup/testsuite/testinst/bin/$(DLL_NAME)

# cygwin import library
# msys-2.0 import library
toolopts=--cpu=@target_cpu@ --ar=@AR@ --as=@AS@ --nm=@NM@ --objcopy=@OBJCOPY@

$(DEF_FILE): scripts/gendef cygwin.din
Expand All @@ -626,13 +626,14 @@ sigfe.s: $(DEF_FILE) tlsoffsets

LIBCOS=$(addsuffix .o,$(basename $(LIB_FILES)))
$(LIB_NAME): $(DEF_FILE) $(LIBCOS) | $(NEW_DLL_NAME)
$(AM_V_GEN)$(srcdir)/scripts/mkimport $(toolopts) $(NEW_FUNCTIONS) $@ cygdll.a $(wordlist 2,99,$^)
$(AM_V_GEN)$(srcdir)/scripts/mkimport $(toolopts) $(NEW_FUNCTIONS) $@ msysdll.a $(wordlist 2,99,$^)

# sublibs
# import libraries for some subset of symbols indicated by given objects
speclib=\
$(srcdir)/scripts/speclib $(toolopts) \
--exclude='cygwin' \
--exclude='msys' \
--exclude='(?i:dll)' \
--exclude='reloc' \
--exclude='^main$$' \
Expand Down Expand Up @@ -679,7 +680,7 @@ all-local: $(LIB_NAME) $(SUBLIBS)
clean-local:
-rm -f $(BUILT_SOURCES)
-rm -f $(DEF_FILE) sigfe.s
-rm -f cygwin.sc cygdll.a cygwin.map
-rm -f cygwin.sc msysdll.a msys.map
-rm -f $(NEW_DLL_NAME)
-rm -f $(LIB_NAME) $(SUBLIBS)
-rm -f version.cc
Expand Down
8 changes: 8 additions & 0 deletions winsup/cygwin/crt0.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ details. */

extern int main (int argc, char **argv);

#ifdef __MSYS__
void msys_crt0 (int (*main) (int, char **));
#else
void cygwin_crt0 (int (*main) (int, char **));
#endif

void
mainCRTStartup ()
{
#ifdef __MSYS__
msys_crt0 (main);
#else
cygwin_crt0 (main);
#endif

/* These are never actually called. They are just here to force the inclusion
of things like -lbinmode. */
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/cygthread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ new (size_t)
}

#ifdef DEBUGGING
if (!getenv ("CYGWIN_FREERANGE_NOCHECK"))
if (!getenv ("MSYS_FREERANGE_NOCHECK"))
api_fatal ("overflowed cygwin thread pool");
else
thread_printf ("overflowed cygwin thread pool");
Expand Down
6 changes: 3 additions & 3 deletions winsup/cygwin/cygwin.din
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LIBRARY "cygwin1.dll" BASE=0x180040000
LIBRARY "msys-2.0.dll" BASE=0x180040000

EXPORTS
# Exported variables
Expand Down Expand Up @@ -404,8 +404,8 @@ cygwin_attach_handle_to_fd SIGFE
cygwin_conv_path SIGFE
cygwin_conv_path_list SIGFE
cygwin_create_path SIGFE
cygwin_detach_dll SIGFE_MAYBE
cygwin_dll_init NOSIGFE
msys_detach_dll SIGFE_MAYBE
msys_dll_init NOSIGFE
cygwin_internal NOSIGFE
cygwin_logon_user SIGFE
cygwin_posix_path_list_p NOSIGFE
Expand Down
4 changes: 4 additions & 0 deletions winsup/cygwin/cygwin.sc.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifdef __x86_64__
OUTPUT_FORMAT(pei-x86-64)
# ifdef __MSYS__
SEARCH_DIR("/usr/x86_64-pc-msys/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api");
# else
SEARCH_DIR("/usr/x86_64-pc-cygwin/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api");
# endif
#else
#error unimplemented for this target
#endif
Expand Down
16 changes: 10 additions & 6 deletions winsup/cygwin/dcrt0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,12 @@ check_sanity_and_sync (per_process *p)

/* magic_biscuit must be SIZEOF_PER_PROCESS. */
if (p->magic_biscuit != SIZEOF_PER_PROCESS)
api_fatal ("Incompatible cygwin .dll -- incompatible per_process info %u != %u",
api_fatal ("Incompatible msys .dll -- incompatible per_process info %u != %u",
p->magic_biscuit, SIZEOF_PER_PROCESS);

/* Complain if incompatible API changes made */
if (p->api_major > cygwin_version.api_major)
api_fatal ("cygwin DLL and APP are out of sync -- API version mismatch %u > %u",
api_fatal ("msys DLL and APP are out of sync -- API version mismatch %u > %u",
p->api_major, cygwin_version.api_major);
}

Expand Down Expand Up @@ -476,12 +476,12 @@ break_here ()
static void
initial_env ()
{
if (GetEnvironmentVariableA ("CYGWIN_TESTING", NULL, 0))
if (GetEnvironmentVariableA ("MSYS_TESTING", NULL, 0))
_cygwin_testing = 1;

#ifdef DEBUGGING
char buf[PATH_MAX];
if (GetEnvironmentVariableA ("CYGWIN_DEBUG", buf, sizeof (buf) - 1))
if (GetEnvironmentVariableA ("MSYS_DEBUG", buf, sizeof (buf) - 1))
{
char buf1[PATH_MAX];
GetModuleFileName (NULL, buf1, PATH_MAX);
Expand Down Expand Up @@ -1076,7 +1076,11 @@ dll_crt0 (per_process *uptr)
See winsup/testsuite/cygload for an example of how to use cygwin1.dll
from MSVC and non-cygwin MinGW applications. */
extern "C" void
#ifdef __MSYS__
msys_dll_init ()
#else
cygwin_dll_init ()
#endif
{
static int _fmode;

Expand Down Expand Up @@ -1277,7 +1281,7 @@ multiple_cygwin_problem (const char *what, uintptr_t magic_version, uintptr_t ve
return;
}

if (GetEnvironmentVariableA ("CYGWIN_MISMATCH_OK", NULL, 0))
if (GetEnvironmentVariableA ("MSYS_MISMATCH_OK", NULL, 0))
return;

if (CYGWIN_VERSION_MAGIC_VERSION (magic_version) == version)
Expand All @@ -1297,7 +1301,7 @@ are unable to find another cygwin DLL.",
void
cygbench (const char *s)
{
if (GetEnvironmentVariableA ("CYGWIN_BENCH", NULL, 0))
if (GetEnvironmentVariableA ("MSYS_BENCH", NULL, 0))
small_printf ("%05u ***** %s : %10d\n", GetCurrentProcessId (), s, strace.microseconds ());
}
#endif
5 changes: 5 additions & 0 deletions winsup/cygwin/dlfcn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,13 @@ collect_basenames (pathfinder::basenamelist & basenames,
/* If the basename starts with "lib", ... */
if (!strncmp (basename, "lib", 3))
{
#ifdef __MSYS__
/* ... replace "lib" with "msys-", before ... */
basenames.appendv ("msys-", 5, basename+3, baselen-3, ext, extlen, NULL);
#else
/* ... replace "lib" with "cyg", before ... */
basenames.appendv ("cyg", 3, basename+3, baselen-3, ext, extlen, NULL);
#endif
}
/* ... using original basename with new suffix. */
basenames.appendv (basename, baselen, ext, extlen, NULL);
Expand Down
4 changes: 4 additions & 0 deletions winsup/cygwin/dll_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,11 @@ dll_dllcrt0_1 (VOID *x)
}

extern "C" void
#ifdef __MSYS__
msys_detach_dll (dll *)
#else
cygwin_detach_dll (dll *)
#endif
{
HANDLE retaddr;
if (_my_tls.isinitialized ())
Expand Down
6 changes: 6 additions & 0 deletions winsup/cygwin/dtable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -998,9 +998,15 @@ handle_to_fn (HANDLE h, char *posix_fn)
if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0)
{
w32 += DEV_NAMED_PIPE_LEN;
#ifdef __MSYS__
if (wcsncmp (w32, L"msys-", WCLEN (L"msys-")) != 0)
return false;
w32 += WCLEN (L"msys-");
#else
if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0)
return false;
w32 += WCLEN (L"cygwin-");
#endif
/* Check for installation key and trailing dash. */
w32len = cygheap->installation_key.Length / sizeof (WCHAR);
if (w32len
Expand Down
4 changes: 2 additions & 2 deletions winsup/cygwin/exceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,14 @@ int exec_prepared_command (PWCHAR command)
PWCHAR rawenv = GetEnvironmentStringsW () ;
for (PWCHAR p = rawenv; *p != L'\0'; p = wcschr (p, L'\0') + 1)
{
if (wcsncmp (p, L"CYGWIN=", wcslen (L"CYGWIN=")) == 0)
if (wcsncmp (p, L"MSYS=", wcslen (L"MSYS=")) == 0)
{
PWCHAR q = wcsstr (p, L"error_start") ;
/* replace 'error_start=...' with '_rror_start=...' */
if (q)
{
*q = L'_' ;
SetEnvironmentVariableW (L"CYGWIN", p + wcslen (L"CYGWIN=")) ;
SetEnvironmentVariableW (L"MSYS", p + wcslen (L"MSYS=")) ;
}
break;
}
Expand Down
4 changes: 4 additions & 0 deletions winsup/cygwin/fhandler/pipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,11 @@ fhandler_pipe::close ()
return ret;
}

#ifdef __MSYS__
#define PIPE_INTRO "\\\\.\\pipe\\msys-"
#else
#define PIPE_INTRO "\\\\.\\pipe\\cygwin-"
#endif

/* Create a pipe, and return handles to the read and write ends,
just like CreatePipe, but ensure that the write end permits
Expand Down
20 changes: 20 additions & 0 deletions winsup/cygwin/fhandler/pty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,11 @@ fhandler_pty_slave::open (int flags, mode_t)
pipe_reply repl;
DWORD len;

#ifdef __MSYS__
__small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl",
#else
__small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
#endif
&cygheap->installation_key, get_minor ());
termios_printf ("dup handles via master control pipe %s", buf);
if (!CallNamedPipe (buf, &req, sizeof req, &repl, sizeof repl,
Expand Down Expand Up @@ -1206,7 +1210,11 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void)
{
char pipe[MAX_PATH];
__small_sprintf (pipe,
#ifdef __MSYS__
"\\\\.\\pipe\\msys-%S-pty%d-master-ctl",
#else
"\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
#endif
&cygheap->installation_key, get_minor ());
pipe_request req = { GetCurrentProcessId () };
pipe_reply repl;
Expand Down Expand Up @@ -2090,7 +2098,11 @@ fhandler_pty_master::close ()
pipe_reply repl;
DWORD len;

#ifdef __MSYS__
__small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl",
#else
__small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
#endif
&cygheap->installation_key, get_minor ());
acquire_output_mutex (mutex_timeout);
if (master_ctl)
Expand Down Expand Up @@ -2996,7 +3008,11 @@ fhandler_pty_master::setup ()

/* Create master control pipe which allows the master to duplicate
the pty pipe handles to processes which deserve it. */
#ifdef __MSYS__
__small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl",
#else
__small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
#endif
&cygheap->installation_key, unit);
master_ctl = CreateNamedPipe (buf, PIPE_ACCESS_DUPLEX
| FILE_FLAG_FIRST_PIPE_INSTANCE,
Expand Down Expand Up @@ -3861,7 +3877,11 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp,
{
char pipe[MAX_PATH];
__small_sprintf (pipe,
#ifdef __MSYS__
"\\\\.\\pipe\\msys-%S-pty%d-master-ctl",
#else
"\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
#endif
&cygheap->installation_key, ttyp->get_minor ());
pipe_request req = { GetCurrentProcessId () };
pipe_reply repl;
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/fork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ frok::child (volatile char * volatile here)
char buf[80];
/* This is useful for debugging fork problems. Use gdb to attach to
the pid reported here. */
if (GetEnvironmentVariableA ("CYGWIN_FORK_SLEEP", buf, sizeof (buf)))
if (GetEnvironmentVariableA ("MSYS_FORK_SLEEP", buf, sizeof (buf)))
{
small_printf ("Sleeping %d after fork, pid %u\n", atoi (buf), GetCurrentProcessId ());
Sleep (atoi (buf));
Expand Down
4 changes: 4 additions & 0 deletions winsup/cygwin/hookapi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h)
for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
{
if (!ascii_strcasematch (rva (PSTR, map ?: (char *) hm, pd->Name - delta),
#ifdef __MSYS__
"msys-2.0.dll"))
#else
"cygwin1.dll"))
#endif
continue;
if (!fn)
{
Expand Down
Loading

0 comments on commit d1cb51f

Please sign in to comment.