public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: simplify create_new_main_thread_stack
Date: Tue,  3 May 2022 13:16:46 +0000 (GMT)	[thread overview]
Message-ID: <20220503131646.9A31838485AF@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b827d4d36a7df77e8e0bcaed38bf639d83f6d233

commit b827d4d36a7df77e8e0bcaed38bf639d83f6d233
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue May 3 14:34:42 2022 +0200

    Cygwin: simplify create_new_main_thread_stack
    
    Originally the function was designed to be used in forked
    processes as well, but it has never been used this way. Drop
    the parameter only required for forkees.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/dcrt0.cc     | 6 +-----
 winsup/cygwin/miscfuncs.cc | 7 ++-----
 winsup/cygwin/miscfuncs.h  | 3 +--
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index e757c47ec..dee8482c2 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -1064,11 +1064,7 @@ _dll_crt0 ()
 	  /* Must be static since it's referenced after the stack and frame
 	     pointer registers have been changed. */
 	  static PVOID allocationbase;
-	  SIZE_T commitsize = in_forkee ? (PBYTE) fork_info->stackbase
-					  - (PBYTE) fork_info->stacklimit
-					: 0;
-	  PVOID stackaddr = create_new_main_thread_stack (allocationbase,
-							  commitsize);
+	  PVOID stackaddr = create_new_main_thread_stack (allocationbase);
 	  if (stackaddr)
 	    {
 	      /* Set stack pointer to new address.  Set frame pointer to
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index fcb082216..905c242c5 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -629,7 +629,7 @@ thread_allocator thr_alloc NO_COPY;
    maintained by the thr_alloc class.  See the description in the x86_64-only
    code in _dll_crt0 to understand why we have to do this. */
 PVOID
-create_new_main_thread_stack (PVOID &allocationbase, SIZE_T parent_commitsize)
+create_new_main_thread_stack (PVOID &allocationbase)
 {
   PIMAGE_DOS_HEADER dosheader;
   PIMAGE_NT_HEADERS ntheader;
@@ -647,10 +647,7 @@ create_new_main_thread_stack (PVOID &allocationbase, SIZE_T parent_commitsize)
   allocationbase
 	= thr_alloc.alloc (ntheader->OptionalHeader.SizeOfStackReserve);
   guardsize = wincap.def_guard_page_size ();
-  if (parent_commitsize)
-    commitsize = (SIZE_T) parent_commitsize;
-  else
-    commitsize = ntheader->OptionalHeader.SizeOfStackCommit;
+  commitsize = ntheader->OptionalHeader.SizeOfStackCommit;
   commitsize = roundup2 (commitsize, wincap.page_size ());
   if (commitsize > stacksize - guardsize - wincap.page_size ())
     commitsize = stacksize - guardsize - wincap.page_size ();
diff --git a/winsup/cygwin/miscfuncs.h b/winsup/cygwin/miscfuncs.h
index 47cef6f20..f571031eb 100644
--- a/winsup/cygwin/miscfuncs.h
+++ b/winsup/cygwin/miscfuncs.h
@@ -109,8 +109,7 @@ ssize_t __reg3 check_iovec (const struct iovec *, int, bool);
 #define check_iovec_for_write(a, b) check_iovec ((a), (b), true)
 
 #ifdef __x86_64__
-extern PVOID create_new_main_thread_stack (PVOID &allocationbase,
-					   SIZE_T parent_commitsize);
+extern PVOID create_new_main_thread_stack (PVOID &allocationbase);
 #endif
 
 extern "C" DWORD WINAPI pthread_wrapper (PVOID arg);


                 reply	other threads:[~2022-05-03 13:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220503131646.9A31838485AF@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).