Revert errnoneous commit.
This commit is contained in:
		| @@ -637,6 +637,9 @@ dll_crt0_1 () | |||||||
|  |  | ||||||
|   (void) SetErrorMode (SEM_FAILCRITICALERRORS); |   (void) SetErrorMode (SEM_FAILCRITICALERRORS); | ||||||
|  |  | ||||||
|  |   /* Initialize the heap. */ | ||||||
|  |   heap_init (); | ||||||
|  |  | ||||||
|   /* Initialize events. */ |   /* Initialize events. */ | ||||||
|   events_init (); |   events_init (); | ||||||
|  |  | ||||||
| @@ -670,9 +673,6 @@ dll_crt0_1 () | |||||||
|       longjmp (ciresrv->jmp, ciresrv->cygpid); |       longjmp (ciresrv->jmp, ciresrv->cygpid); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   /* Initialize the heap. */ |  | ||||||
|   heap_init (); |  | ||||||
|  |  | ||||||
|   /* Initialize our process table entry. Don't use the parent info for |   /* Initialize our process table entry. Don't use the parent info for | ||||||
|      dynamically loaded case. */ |      dynamically loaded case. */ | ||||||
|   pinfo_init ((dynamically_loaded) ? NULL : info); |   pinfo_init ((dynamically_loaded) ? NULL : info); | ||||||
|   | |||||||
| @@ -445,13 +445,13 @@ fork () | |||||||
|  |  | ||||||
|  |  | ||||||
|       MALLOC_CHECK; |       MALLOC_CHECK; | ||||||
|       rc = fork_copy (pi, "dll data", dll_data_start, dll_data_end, |  | ||||||
| 		      dll_bss_start, dll_bss_end, NULL); |  | ||||||
|       rc = fork_copy (pi, "user/cygwin data", |       rc = fork_copy (pi, "user/cygwin data", | ||||||
| 		      user_data->data_start, user_data->data_end, | 		      user_data->data_start, user_data->data_end, | ||||||
| 		      user_data->bss_start, user_data->bss_end, | 		      user_data->bss_start, user_data->bss_end, | ||||||
|  | 		      ch.heapbase, ch.heapptr, | ||||||
| 		      stack_here, ch.stackbottom, | 		      stack_here, ch.stackbottom, | ||||||
| 		      NULL); | 		      dll_data_start, dll_data_end, | ||||||
|  | 		      dll_bss_start, dll_bss_end, NULL); | ||||||
|  |  | ||||||
|       MALLOC_CHECK; |       MALLOC_CHECK; | ||||||
|       if (!rc) |       if (!rc) | ||||||
| @@ -526,22 +526,14 @@ fork () | |||||||
|         } |         } | ||||||
|  |  | ||||||
|       sync_with_parent ("after longjmp.", TRUE); |       sync_with_parent ("after longjmp.", TRUE); | ||||||
|  |       ProtectHandle (hParent); | ||||||
|  |  | ||||||
| #ifdef DEBUGGING | #ifdef DEBUGGING | ||||||
|       char c; |       char c; | ||||||
|       if (GetEnvironmentVariable ("FORKDEBUG", &c, 1)) |       if (GetEnvironmentVariable ("FORKDEBUG", &c, 1)) | ||||||
| 	try_to_debug (); | 	try_to_debug (); | ||||||
|       char buf[80]; |  | ||||||
|       if (GetEnvironmentVariable ("CYGWIN_FORK_SLEEP", buf, sizeof (buf))) |  | ||||||
| 	{ |  | ||||||
| 	  small_printf ("Sleeping %d after fork, pid %u\n", atoi (buf), GetCurrentProcessId ()); |  | ||||||
| 	  Sleep (atoi(buf)); |  | ||||||
| 	} |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|       heap_init (); |  | ||||||
|       ProtectHandle (hParent); |  | ||||||
|  |  | ||||||
|       /* If we've played with the stack, stacksize != 0.  That means that |       /* If we've played with the stack, stacksize != 0.  That means that | ||||||
| 	 fork() was invoked from other than the main thread.  Make sure that | 	 fork() was invoked from other than the main thread.  Make sure that | ||||||
| 	 when the "main" thread exits it calls do_exit, like a normal process. | 	 when the "main" thread exits it calls do_exit, like a normal process. | ||||||
|   | |||||||
| @@ -20,8 +20,6 @@ details. */ | |||||||
|  |  | ||||||
| static unsigned page_const = 0; | static unsigned page_const = 0; | ||||||
|  |  | ||||||
| HANDLE cygwin_heap; |  | ||||||
|  |  | ||||||
| static  __inline__ int | static  __inline__ int | ||||||
| getpagesize(void) | getpagesize(void) | ||||||
| { | { | ||||||
| @@ -38,9 +36,9 @@ heap_init () | |||||||
|   /* If we're the forkee, we must allocate the heap at exactly the same place |   /* If we're the forkee, we must allocate the heap at exactly the same place | ||||||
|      as our parent.  If not, we don't care where it ends up.  */ |      as our parent.  If not, we don't care where it ends up.  */ | ||||||
|  |  | ||||||
|  |   page_const = getpagesize(); | ||||||
|   if (brkbase) |   if (brkbase) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|       DWORD chunk = brkchunk;	/* allocation chunk */ |       DWORD chunk = brkchunk;	/* allocation chunk */ | ||||||
|       /* total size commited in parent */ |       /* total size commited in parent */ | ||||||
|       DWORD allocsize = (char *) brktop - (char *) brkbase; |       DWORD allocsize = (char *) brktop - (char *) brkbase; | ||||||
| @@ -48,13 +46,14 @@ heap_init () | |||||||
|       DWORD reserve_size = chunk * ((allocsize + (chunk - 1)) / chunk); |       DWORD reserve_size = chunk * ((allocsize + (chunk - 1)) / chunk); | ||||||
|  |  | ||||||
|       /* Loop until we've managed to reserve an adequate amount of memory. */ |       /* Loop until we've managed to reserve an adequate amount of memory. */ | ||||||
|       void *p; |       char *p; | ||||||
|       for (;;) |       for (;;) | ||||||
| 	{ | 	{ | ||||||
| 	  p = MapViewOfFileEx (cygwin_heap, FILE_MAP_COPY, 0L, 0L, 0L, brkbase); | 	  p = (char *) VirtualAlloc (brkbase, reserve_size, | ||||||
|  | 				     MEM_RESERVE, PAGE_READWRITE); | ||||||
| 	  if (p) | 	  if (p) | ||||||
| 	    break; | 	    break; | ||||||
| 	  if ((reserve_size -= (page_const + 1)) <= allocsize) | 	  if ((reserve_size -= page_const) <= allocsize) | ||||||
| 	    break; | 	    break; | ||||||
| 	} | 	} | ||||||
|       if (p == NULL) |       if (p == NULL) | ||||||
| @@ -62,25 +61,20 @@ heap_init () | |||||||
| 		   brkchunk, myself->pid); | 		   brkchunk, myself->pid); | ||||||
|       if (p != brkbase) |       if (p != brkbase) | ||||||
| 	api_fatal ("heap allocated but not at %p", brkbase); | 	api_fatal ("heap allocated but not at %p", brkbase); | ||||||
|       if (!VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE)) |       if (! VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE)) | ||||||
| 	api_fatal ("MEM_COMMIT failed, %E"); | 	api_fatal ("MEM_COMMIT failed, %E"); | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       page_const = getpagesize() - 1; |  | ||||||
|       /* Initialize page mask and default heap size.  Preallocate a heap |       /* Initialize page mask and default heap size.  Preallocate a heap | ||||||
|        * to assure contiguous memory.  */ |        * to assure contiguous memory.  */ | ||||||
|       cygwin_heap = CreateFileMapping ((HANDLE) 0xffffffff, &sec_all, PAGE_WRITECOPY | SEC_RESERVE, 0L, brkchunk, NULL); |       brk = brktop = brkbase = VirtualAlloc(NULL, brkchunk, MEM_RESERVE, PAGE_NOACCESS); | ||||||
|       if (cygwin_heap == NULL) |  | ||||||
| 	api_fatal ("2. unable to allocate shared memory for heap, heap_chunk_size %d, %E", brkchunk); |  | ||||||
|        |  | ||||||
|       brk = brktop = brkbase = MapViewOfFile (cygwin_heap, 0, 0L, 0L, 0); |  | ||||||
| //    brk = brktop = brkbase = VirtualAlloc(NULL, brkchunk, MEM_RESERVE, PAGE_NOACCESS); |  | ||||||
|       if (brkbase == NULL) |       if (brkbase == NULL) | ||||||
| 	api_fatal ("2. unable to allocate heap, heap_chunk_size %d, %E", | 	api_fatal ("2. unable to allocate heap, heap_chunk_size %d, %E", | ||||||
| 		   brkchunk); | 		   brkchunk); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |   page_const--; | ||||||
|   malloc_init (); |   malloc_init (); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -172,7 +172,7 @@ pinfo *__stdcall procinfo (int n); | |||||||
|  |  | ||||||
| enum | enum | ||||||
| { | { | ||||||
|   PROC_MAGIC = 0xaf09f000, |   PROC_MAGIC = 0xaf08f000, | ||||||
|   PROC_FORK = PROC_MAGIC + 1, |   PROC_FORK = PROC_MAGIC + 1, | ||||||
|   PROC_EXEC = PROC_MAGIC + 2, |   PROC_EXEC = PROC_MAGIC + 2, | ||||||
|   PROC_SPAWN = PROC_MAGIC + 3, |   PROC_SPAWN = PROC_MAGIC + 3, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user