diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b5ca6b51c..6b0c2eccd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,23 @@ +Fri Sep 7 17:11:11 2001 Christopher Faylor + + * cygheap.h (init_cygheap): Move heap pointers here. + * include/sys/cygwin.h (perprocess): Remove heap pointers. + * dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff. + (_dll_crt0): Don't initialize heap pointers. + (cygwin_dll_init): Ditto. + (release_upto): Use heap pointers from cygheap. + * heap.h: Ditto. + * fork.cc (fork_parent): Ditto. Don't set heap pointers in ch. + (fork_child): Remove obsolete sigproc_fixup_after_fork. + * shared.cc (memory_init): Reorganize so that cygheap initialization is + called prior to regular heap since regular heap uses cygheap now. + * sigproc.cc (proc_subproc): Eliminate zombies allocation. + (sigproc_init): Move zombies alloation here. Don't free up array on + fork, just reuse it. + (sigproc_fixup_after_fork): Eliminate. + * sigproc.h: Ditto. + * include/cygwin/version.h: Reflect change to perprocess structure. + Fri Sep 7 10:53:34 2001 Jason Tishler * poll.cc (poll): Change implementation to only call select() when no @@ -86,7 +106,7 @@ Tue Sep 4 22:14:00 2001 Corinna Vinschen 2001-09-04 Kazuhiro Fujieda - * fhandler_console.cc (fhandler_console::char_command): Save the cursor + * fhandler_console.cc (fhandler_console::char_command): Save the cursor position relative to the top of the window. * fhandler_cc (fhandler_console::write): Ditto. diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index 1cd0e7e12..bcbaac3cd 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -268,9 +268,9 @@ wsock_init () int (*wsastartup) (int, WSADATA *); wsastartup = (int (*)(int, WSADATA *)) - GetProcAddress ((HMODULE) (dll->handle), "WSAStartup"); + GetProcAddress ((HMODULE) (dll->handle), "WSAStartup"); if (wsastartup) - { + { int res = wsastartup ((2<<8) | 2, &wsadata); debug_printf ("res %d", res); @@ -283,7 +283,7 @@ wsock_init () debug_printf ("lpVendorInfo %d", wsadata.lpVendorInfo); wsock_started = 1; - } + } } InterlockedDecrement (&here); diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index 5b385f5c1..1a90a94b6 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -67,7 +67,7 @@ public: if (!m) return 1; return strncasematch (m->native_path, path, m->native_pathlen) - && (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]); + && (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]); } const char *unchroot (const char *path) { @@ -153,6 +153,9 @@ struct init_cygheap { _cmalloc_entry *chain; char *buckets[32]; + void *heapbase; + void *heapptr; + void *heaptop; cygheap_root root; cygheap_user user; mode_t umask; diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index ae95c8b4f..4f278cee1 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -101,9 +101,9 @@ extern "C" /* calloc */ export_calloc, /* premain */ {NULL, NULL, NULL, NULL}, /* run_ctors_p */ 0, - /* unused */ { 0, 0, 0}, - /* heapbase */ NULL, /* heapptr */ NULL, /* heaptop */ NULL, - /* unused1 */ 0, /* forkee */ 0, /* hmodule */ NULL, + /* unused */ {0, 0, 0, 0, 0, 0, 0}, + /* forkee */ 0, + /* hmodule */ NULL, /* api_major */ CYGWIN_VERSION_API_MAJOR, /* api_minor */ CYGWIN_VERSION_API_MINOR, /* unused2 */ {0, 0, 0, 0, 0}, @@ -683,9 +683,6 @@ dll_crt0_1 () cygheap_fixup_in_child (child_proc_info, 0); alloc_stack (fork_info); set_myself (mypid); - user_data->heaptop = child_proc_info->heaptop; - user_data->heapbase = child_proc_info->heapbase; - user_data->heapptr = child_proc_info->heapptr; ProtectHandle (child_proc_info->forker_finished); break; case PROC_SPAWN: @@ -896,7 +893,6 @@ _dll_crt0 () main_environ = user_data->envptr; *main_environ = NULL; - user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL; set_console_handler (); if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (), @@ -954,7 +950,6 @@ cygwin_dll_init () { static char **envp; static int _fmode; - user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL; if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (), GetCurrentProcess (), &hMainProc, 0, FALSE, diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index f716f23ba..9174d04cf 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -201,14 +201,14 @@ readdir (DIR * dir) char *c = dir->__d_dirent->d_name; int len = strlen (c); if (strcasematch (c + len - 4, ".lnk")) - { + { char fbuf[MAX_PATH + 1]; strcpy (fbuf, dir->__d_dirname); strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name); path_conv fpath (fbuf, PC_SYM_NOFOLLOW); if (fpath.issymlink ()) - c[len - 4] = '\0'; - } + c[len - 4] = '\0'; + } } /* Compute d_ino by combining filename hash with the directory hash @@ -387,7 +387,7 @@ rmdir (const char *dir) /* Even own directories can't be removed if R/O attribute is set. */ if (real_dir.file_attributes () & FILE_ATTRIBUTE_READONLY) SetFileAttributes (real_dir.get_win32 (), real_dir.file_attributes () & - ~FILE_ATTRIBUTE_READONLY); + ~FILE_ATTRIBUTE_READONLY); if (RemoveDirectoryA (real_dir.get_win32 ())) { @@ -402,7 +402,7 @@ rmdir (const char *dir) else { if (GetLastError() == ERROR_ACCESS_DENIED) - { + { /* On 9X ERROR_ACCESS_DENIED is returned if you try to remove a non-empty directory. */ if (!iswinnt) diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 265ebf85a..4a23166e4 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -13,6 +13,10 @@ details. */ #include "perprocess.h" #include "dll_init.h" #include "environ.h" +#include "security.h" +#include "fhandler.h" +#include "dtable.h" +#include "cygheap.h" extern void __stdcall check_sanity_and_sync (per_process *); @@ -253,7 +257,7 @@ release_upto (const char *name, DWORD here) { size = mb.RegionSize; if (!(mb.State == MEM_RESERVE && mb.AllocationProtect == PAGE_NOACCESS && - ((void *) start < user_data->heapbase || (void *) start > user_data->heaptop))) + ((void *) start < cygheap->heapbase || (void *) start > cygheap->heaptop))) continue; if (!VirtualFree ((void *) start, 0, MEM_RELEASE)) api_fatal ("couldn't release memory %p(%d) for '%s' alignment, %E\n", diff --git a/winsup/cygwin/dlmalloc.c b/winsup/cygwin/dlmalloc.c index 809728c8a..3435950b4 100644 --- a/winsup/cygwin/dlmalloc.c +++ b/winsup/cygwin/dlmalloc.c @@ -28,6 +28,25 @@ * malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P)) * * $Log$ + * Revision 1.4 2001/09/07 21:32:04 cgf + * * cygheap.h (init_cygheap): Move heap pointers here. + * * include/sys/cygwin.h (perprocess): Remove heap pointers. + * * dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff. + * (_dll_crt0): Don't initialize heap pointers. + * (cygwin_dll_init): Ditto. + * (release_upto): Use heap pointers from cygheap. + * * heap.h: Ditto. + * * fork.cc (fork_parent): Ditto. Don't set heap pointers in ch. + * (fork_child): Remove obsolete sigproc_fixup_after_fork. + * * shared.cc (memory_init): Reorganize so that cygheap initialization is called + * prior to regular heap since regular heap uses cygheap now. + * * sigproc.cc (proc_subproc): Eliminate zombies allocation. + * (sigproc_init): Move zombies alloation here. Don't free up array on fork, just + * reuse it. + * (sigproc_fixup_after_fork): Eliminate. + * * sigproc.h: Ditto. + * * include/cygwin/version.h: Reflect change to perprocess structure. + * * Revision 1.3 2001/06/26 14:47:48 cgf * * mmap.cc: Clean up *ResourceLock calls throughout. * * thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well as @@ -64,8 +83,8 @@ * VERSION 2.6.4 Thu Nov 28 07:54:55 1996 Doug Lea (dl at gee) Note: There may be an updated version of this malloc obtainable at - ftp://g.oswego.edu/pub/misc/malloc.c - Check before installing! + ftp://g.oswego.edu/pub/misc/malloc.c + Check before installing! * Why use this malloc? @@ -142,7 +161,7 @@ and status information. Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead) - 8-byte ptrs: 24/32 bytes (including, 4/8 overhead) + 8-byte ptrs: 24/32 bytes (including, 4/8 overhead) When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte ptrs but 4 byte size) or 24 (for 8/8) additional bytes are @@ -154,7 +173,7 @@ pointer to something of the minimum allocatable size. Maximum allocated size: 4-byte size_t: 2^31 - 8 bytes - 8-byte size_t: 2^63 - 16 bytes + 8-byte size_t: 2^63 - 16 bytes It is assumed that (possibly signed) size_t bit values suffice to represent chunk sizes. `Possibly signed' is due to the fact @@ -170,11 +189,11 @@ make the normal worst-case wastage 15 bytes (i.e., up to 15 more bytes will be allocated than were requested in malloc), with two exceptions: - 1. Because requests for zero bytes allocate non-zero space, - the worst case wastage for a request of zero bytes is 24 bytes. - 2. For requests >= mmap_threshold that are serviced via - mmap(), the worst case wastage is 8 bytes plus the remainder - from a system page (the minimal mmap unit); typically 4096 bytes. + 1. Because requests for zero bytes allocate non-zero space, + the worst case wastage for a request of zero bytes is 24 bytes. + 2. For requests >= mmap_threshold that are serviced via + mmap(), the worst case wastage is 8 bytes plus the remainder + from a system page (the minimal mmap unit); typically 4096 bytes. * Limitations @@ -435,14 +454,14 @@ do { \ if(mzsz <= 9*sizeof(mzsz)) { \ INTERNAL_SIZE_T* mz = (INTERNAL_SIZE_T*) (charp); \ if(mzsz >= 5*sizeof(mzsz)) { *mz++ = 0; \ - *mz++ = 0; \ + *mz++ = 0; \ if(mzsz >= 7*sizeof(mzsz)) { *mz++ = 0; \ - *mz++ = 0; \ - if(mzsz >= 9*sizeof(mzsz)) { *mz++ = 0; \ - *mz++ = 0; }}} \ - *mz++ = 0; \ - *mz++ = 0; \ - *mz = 0; \ + *mz++ = 0; \ + if(mzsz >= 9*sizeof(mzsz)) { *mz++ = 0; \ + *mz++ = 0; }}} \ + *mz++ = 0; \ + *mz++ = 0; \ + *mz = 0; \ } else memset((charp), 0, mzsz); \ } while(0) @@ -453,14 +472,14 @@ do { \ INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) (src); \ INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) (dest); \ if(mcsz >= 5*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; \ + *mcdst++ = *mcsrc++; \ if(mcsz >= 7*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; \ - if(mcsz >= 9*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; }}} \ - *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; \ - *mcdst = *mcsrc ; \ + *mcdst++ = *mcsrc++; \ + if(mcsz >= 9*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \ + *mcdst++ = *mcsrc++; }}} \ + *mcdst++ = *mcsrc++; \ + *mcdst++ = *mcsrc++; \ + *mcdst = *mcsrc ; \ } else memcpy(dest, src, mcsz); \ } while(0) @@ -588,9 +607,9 @@ do { \ # else # if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) # if __STD_C - extern size_t getpagesize(void); + extern size_t getpagesize(void); # else - extern size_t getpagesize(); + extern size_t getpagesize(); # endif # define malloc_getpagesize getpagesize() # else @@ -751,11 +770,11 @@ struct mallinfo { retain whenever sbrk is called. It is used in two ways internally: * When sbrk is called to extend the top of the arena to satisfy - a new malloc request, this much padding is added to the sbrk - request. + a new malloc request, this much padding is added to the sbrk + request. * When malloc_trim is called automatically from free(), - it is used as the `pad' argument. + it is used as the `pad' argument. In both cases, the actual amount of padding is rounded so that the end of the arena is always a system page boundary. @@ -801,15 +820,15 @@ struct mallinfo { However, it has the disadvantages that: - 1. The space cannot be reclaimed, consolidated, and then - used to service later requests, as happens with normal chunks. - 2. It can lead to more wastage because of mmap page alignment - requirements - 3. It causes malloc performance to be more dependent on host - system memory management support routines which may vary in - implementation quality and may impose arbitrary - limitations. Generally, servicing a request via normal - malloc steps is faster than going through a system's mmap. + 1. The space cannot be reclaimed, consolidated, and then + used to service later requests, as happens with normal chunks. + 2. It can lead to more wastage because of mmap page alignment + requirements + 3. It causes malloc performance to be more dependent on host + system memory management support routines which may vary in + implementation quality and may impose arbitrary + limitations. Generally, servicing a request via normal + malloc steps is faster than going through a system's mmap. All together, these considerations should lead you to use mmap only for relatively large requests. @@ -831,15 +850,15 @@ struct mallinfo { M_MMAP_MAX is the maximum number of requests to simultaneously service using mmap. This parameter exists because: - 1. Some systems have a limited number of internal tables for - use by mmap. - 2. In most systems, overreliance on mmap can degrade overall - performance. - 3. If a program allocates many large regions, it is probably - better off using normal sbrk-based allocation routines that - can reclaim and reallocate normal heap memory. Using a - small value allows transition into this mode after the - first few allocations. + 1. Some systems have a limited number of internal tables for + use by mmap. + 2. In most systems, overreliance on mmap can degrade overall + performance. + 3. If a program allocates many large regions, it is probably + better off using normal sbrk-based allocation routines that + can reclaim and reallocate normal heap memory. Using a + small value allows transition into this mode after the + first few allocations. Setting to 0 disables all use of mmap. If HAVE_MMAP is not set, the default value is 0, and attempts to set it to non-zero values @@ -1162,7 +1181,7 @@ void gcleanup () rval = VirtualFree ((void*)gAddressBase, gNextAddress - gAddressBase, MEM_DECOMMIT); - ASSERT (rval); + ASSERT (rval); } while (head) { @@ -1326,17 +1345,17 @@ typedef Chunk* mchunkptr; chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk, if allocated | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk, in bytes |P| + | Size of previous chunk, if allocated | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of chunk, in bytes |P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | User data starts here... . - . . - . (malloc_usable_space() bytes) . - . | + | User data starts here... . + . . + . (malloc_usable_space() bytes) . + . | nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Where "chunk" is the front of the chunk for the purpose of most of @@ -1350,20 +1369,20 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Free chunks are stored in circular doubly-linked lists, and look like this: chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `head:' | Size of chunk, in bytes |P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space (may be 0 bytes long) . - . . - . | + | Forward pointer to next chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Back pointer to previous chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Unused space (may be 0 bytes long) . + . . + . | nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The P (PREV_INUSE) bit, stored in the unused low-order bit of the chunk size (which is always a multiple of two words), is an in-use @@ -1380,16 +1399,16 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The two exceptions to all this are 1. The special chunk `top', which doesn't bother using the - trailing size field since there is no - next contiguous chunk that would have to index off it. (After - initialization, `top' is forced to always exist. If it would - become less than MINSIZE bytes long, it is replenished via - malloc_extend_top.) + trailing size field since there is no + next contiguous chunk that would have to index off it. (After + initialization, `top' is forced to always exist. If it would + become less than MINSIZE bytes long, it is replenished via + malloc_extend_top.) 2. Chunks allocated via mmap, which have the second-lowest-order - bit (IS_MMAPPED) set in their size fields. Because they are - never merged or traversed from any other chunk, they have no - foot size or inuse information. + bit (IS_MMAPPED) set in their size fields. Because they are + never merged or traversed from any other chunk, they have no + foot size or inuse information. Available chunks are kept in any of several places (all declared below): @@ -1682,7 +1701,7 @@ static mbinptr av_[NAV * 2 + 2] = { ((((unsigned long)(sz)) >> 9) <= 84) ? 110 + (((unsigned long)(sz)) >> 12): \ ((((unsigned long)(sz)) >> 9) <= 340) ? 119 + (((unsigned long)(sz)) >> 15): \ ((((unsigned long)(sz)) >> 9) <= 1364) ? 124 + (((unsigned long)(sz)) >> 18): \ - 126) + 126) /* bins for chunks < 512 are all spaced 8 bytes apart, and hold identically sized chunks. This is exploited in malloc. @@ -2565,20 +2584,20 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb; /* If not enough space to do this, then user did something very wrong */ if (old_top_size < MINSIZE) { - set_head(top, PREV_INUSE); /* will force null return from malloc */ - return; + set_head(top, PREV_INUSE); /* will force null return from malloc */ + return; } old_top_size -= 2*SIZE_SZ; chunk_at_offset(old_top, old_top_size )->size = - SIZE_SZ|PREV_INUSE; + SIZE_SZ|PREV_INUSE; chunk_at_offset(old_top, old_top_size + SIZE_SZ)->size = - SIZE_SZ|PREV_INUSE; + SIZE_SZ|PREV_INUSE; set_head_size(old_top, old_top_size); /* If possible, release the rest. */ if (old_top_size >= MINSIZE) { init_freeable_chunk(old_top); - fREe(chunk2mem(old_top)); + fREe(chunk2mem(old_top)); } } #endif /* OTHER_SBRKS */ @@ -2613,43 +2632,43 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb; From there, the first successful of the following steps is taken: 1. The bin corresponding to the request size is scanned, and if - a chunk of exactly the right size is found, it is taken. + a chunk of exactly the right size is found, it is taken. 2. The most recently remaindered chunk is used if it is big - enough. This is a form of (roving) first fit, used only in - the absence of exact fits. Runs of consecutive requests use - the remainder of the chunk used for the previous such request - whenever possible. This limited use of a first-fit style - allocation strategy tends to give contiguous chunks - coextensive lifetimes, which improves locality and can reduce - fragmentation in the long run. + enough. This is a form of (roving) first fit, used only in + the absence of exact fits. Runs of consecutive requests use + the remainder of the chunk used for the previous such request + whenever possible. This limited use of a first-fit style + allocation strategy tends to give contiguous chunks + coextensive lifetimes, which improves locality and can reduce + fragmentation in the long run. 3. Other bins are scanned in increasing size order, using a - chunk big enough to fulfill the request, and splitting off - any remainder. This search is strictly by best-fit; i.e., - the smallest (with ties going to approximately the least - recently used) chunk that fits is selected. + chunk big enough to fulfill the request, and splitting off + any remainder. This search is strictly by best-fit; i.e., + the smallest (with ties going to approximately the least + recently used) chunk that fits is selected. 4. If large enough, the chunk bordering the end of memory - (`top') is split off. (This use of `top' is in accord with - the best-fit search rule. In effect, `top' is treated as - larger (and thus less well fitting) than any other available - chunk since it can be extended to be as large as necessary - (up to system limitations). + (`top') is split off. (This use of `top' is in accord with + the best-fit search rule. In effect, `top' is treated as + larger (and thus less well fitting) than any other available + chunk since it can be extended to be as large as necessary + (up to system limitations). 5. If the request size meets the mmap threshold and the - system supports mmap, and there are few enough currently - allocated mmapped regions, and a call to mmap succeeds, - the request is allocated via direct memory mapping. + system supports mmap, and there are few enough currently + allocated mmapped regions, and a call to mmap succeeds, + the request is allocated via direct memory mapping. 6. Otherwise, the top of memory is extended by - obtaining more space from the system (normally using sbrk, - but definable to anything else via the MORECORE macro). - Memory is gathered from the system (in system page-sized - units) in a way that allows chunks obtained across different - sbrk calls to be consolidated, but does not require - contiguous memory. Thus, it should be safe to intersperse - mallocs with other sbrk calls. + obtaining more space from the system (normally using sbrk, + but definable to anything else via the MORECORE macro). + Memory is gathered from the system (in system page-sized + units) in a way that allows chunks obtained across different + sbrk calls to be consolidated, but does not require + contiguous memory. Thus, it should be safe to intersperse + mallocs with other sbrk calls. All allocations are made from the the `lowest' part of any found @@ -2725,18 +2744,18 @@ Void_t* mALLOc(bytes) size_t bytes; if (remainder_size >= (long)MINSIZE) /* too big */ { - --idx; /* adjust to rescan below after checking last remainder */ - break; + --idx; /* adjust to rescan below after checking last remainder */ + break; } else if (remainder_size >= 0) /* exact fit */ { - unlink(victim, bck, fwd); - set_inuse_bit_at_offset(victim, victim_size); + unlink(victim, bck, fwd); + set_inuse_bit_at_offset(victim, victim_size); check_freefill(victim, victim_size, victim_size); init_malloced_chunk(victim, bytes); check_malloced_chunk(victim, nb); - return chunk2mem(victim); + return chunk2mem(victim); } } @@ -2798,8 +2817,8 @@ Void_t* mALLOc(bytes) size_t bytes; block <<= 1; while ((block & binblocks) == 0) { - idx += BINBLOCKWIDTH; - block <<= 1; + idx += BINBLOCKWIDTH; + block <<= 1; } } @@ -2812,39 +2831,39 @@ Void_t* mALLOc(bytes) size_t bytes; /* For each bin in this block ... */ do { - /* Find and use first big enough chunk ... */ + /* Find and use first big enough chunk ... */ - for (victim = last(bin); victim != bin; victim = victim->bk) - { - victim_size = chunksize(victim); - remainder_size = victim_size - nb; + for (victim = last(bin); victim != bin; victim = victim->bk) + { + victim_size = chunksize(victim); + remainder_size = victim_size - nb; - if (remainder_size >= (long)MINSIZE) /* split */ - { - remainder = chunk_at_offset(victim, nb); - set_head(victim, nb | PREV_INUSE); + if (remainder_size >= (long)MINSIZE) /* split */ + { + remainder = chunk_at_offset(victim, nb); + set_head(victim, nb | PREV_INUSE); check_freefill(victim, nb, victim_size); - unlink(victim, bck, fwd); - init_malloced_chunk(victim, bytes); + unlink(victim, bck, fwd); + init_malloced_chunk(victim, bytes); link_last_remainder(remainder); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); + set_head(remainder, remainder_size | PREV_INUSE); + set_foot(remainder, remainder_size); init_freed_chunk(remainder, remainder_size, 0); check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } + return chunk2mem(victim); + } - else if (remainder_size >= 0) /* take */ - { + else if (remainder_size >= 0) /* take */ + { check_freefill(victim, victim_size, victim_size); - set_inuse_bit_at_offset(victim, victim_size); - unlink(victim, bck, fwd); + set_inuse_bit_at_offset(victim, victim_size); + unlink(victim, bck, fwd); init_malloced_chunk(victim, bytes); check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } + return chunk2mem(victim); + } - } + } bin = next_bin(bin); @@ -2854,12 +2873,12 @@ Void_t* mALLOc(bytes) size_t bytes; do /* Possibly backtrack to try to clear a partial block */ { - if ((startidx & (BINBLOCKWIDTH - 1)) == 0) - { - binblocks &= ~block; - break; - } - --startidx; + if ((startidx & (BINBLOCKWIDTH - 1)) == 0) + { + binblocks &= ~block; + break; + } + --startidx; q = prev_bin(q); } while (first(q) == q); @@ -2867,14 +2886,14 @@ Void_t* mALLOc(bytes) size_t bytes; if ( (block <<= 1) <= binblocks && (block != 0) ) { - while ((block & binblocks) == 0) - { - idx += BINBLOCKWIDTH; - block <<= 1; - } + while ((block & binblocks) == 0) + { + idx += BINBLOCKWIDTH; + block <<= 1; + } } else - break; + break; } } @@ -2888,7 +2907,7 @@ Void_t* mALLOc(bytes) size_t bytes; #if HAVE_MMAP /* If big and would otherwise need to extend, try to use mmap instead */ if ((unsigned long)nb >= (unsigned long)mmap_threshold && - (victim = mmap_chunk(nb)) != 0) { + (victim = mmap_chunk(nb)) != 0) { init_malloced_chunk(victim, bytes); return chunk2mem(victim); } @@ -2926,13 +2945,13 @@ Void_t* mALLOc(bytes) size_t bytes; 2. If the chunk was allocated via mmap, it is release via munmap(). 3. If a returned chunk borders the current high end of memory, - it is consolidated into the top, and if the total unused - topmost memory exceeds the trim threshold, malloc_trim is - called. + it is consolidated into the top, and if the total unused + topmost memory exceeds the trim threshold, malloc_trim is + called. 4. Other chunks are consolidated as they arrive, and - placed in corresponding bins. (This includes the case of - consolidating with the current `last_remainder'). + placed in corresponding bins. (This includes the case of + consolidating with the current `last_remainder'). */ @@ -3152,26 +3171,26 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; /* Forward into top only if a remainder */ if (next == top) { - if ((long)(nextsize + newsize) >= (long)(nb + MINSIZE)) - { + if ((long)(nextsize + newsize) >= (long)(nb + MINSIZE)) + { check_freefill(next, nb - oldsize, nextsize); newsize += nextsize; - top = chunk_at_offset(oldp, nb); - set_head(top, (newsize - nb) | PREV_INUSE); + top = chunk_at_offset(oldp, nb); + set_head(top, (newsize - nb) | PREV_INUSE); init_freed_chunk(top, newsize - nb, 0); - set_head_size(oldp, nb); + set_head_size(oldp, nb); init_realloced_chunk(oldp, bytes, oldsize); return chunk2mem(oldp); - } + } } /* Forward into next chunk */ else if (((long)(nextsize + newsize) >= (long)nb)) { check_freefill(next, nb - oldsize, nextsize); - unlink(next, bck, fwd); - newsize += nextsize; - goto split; + unlink(next, bck, fwd); + newsize += nextsize; + goto split; } } else @@ -3191,52 +3210,52 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; if (next != 0) { - /* into top */ - if (next == top) - { - if ((long)(nextsize + prevsize + newsize) >= (long)(nb + MINSIZE)) - { + /* into top */ + if (next == top) + { + if ((long)(nextsize + prevsize + newsize) >= (long)(nb + MINSIZE)) + { check_freefill(prev, nb, prevsize); check_freefill(next, nb - (prevsize + newsize), nextsize); unlink(prev, bck, fwd); - newp = prev; - newsize += prevsize + nextsize; - newmem = chunk2mem(newp); - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); - top = chunk_at_offset(newp, nb); - set_head(top, (newsize - nb) | PREV_INUSE); + newp = prev; + newsize += prevsize + nextsize; + newmem = chunk2mem(newp); + malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); + top = chunk_at_offset(newp, nb); + set_head(top, (newsize - nb) | PREV_INUSE); init_freed_chunk(top, newsize - nb, 0); - set_head_size(newp, nb); + set_head_size(newp, nb); init_realloced_chunk(newp, bytes, oldsize); - return newmem; - } - } + return newmem; + } + } - /* into next chunk */ - else if (((long)(nextsize + prevsize + newsize) >= (long)(nb))) - { + /* into next chunk */ + else if (((long)(nextsize + prevsize + newsize) >= (long)(nb))) + { check_freefill(prev, nb, prevsize); check_freefill(next, nb - (prevsize + newsize), nextsize); - unlink(next, bck, fwd); - unlink(prev, bck, fwd); - newp = prev; - newsize += nextsize + prevsize; - newmem = chunk2mem(newp); - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); - goto split; - } + unlink(next, bck, fwd); + unlink(prev, bck, fwd); + newp = prev; + newsize += nextsize + prevsize; + newmem = chunk2mem(newp); + malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); + goto split; + } } /* backward only */ if (prev != 0 && (long)(prevsize + newsize) >= (long)nb) { check_freefill(prev, nb, prevsize); - unlink(prev, bck, fwd); - newp = prev; - newsize += prevsize; - newmem = chunk2mem(newp); - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); - goto split; + unlink(prev, bck, fwd); + newp = prev; + newsize += prevsize; + newmem = chunk2mem(newp); + malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); + goto split; } } @@ -3572,27 +3591,27 @@ int malloc_trim(pad) size_t pad; if (new_lim == (char*)(MORECORE_FAILURE)) /* sbrk failed? */ { - /* Try to figure out what we have */ - current_lim = (char*)(MORECORE (0)); - top_size = current_lim - (char*)top; - if (top_size >= (long)MINSIZE) /* if not, we are very very dead! */ - { - sbrked_mem = current_lim - sbrk_base; - set_head(top, top_size | PREV_INUSE); + /* Try to figure out what we have */ + current_lim = (char*)(MORECORE (0)); + top_size = current_lim - (char*)top; + if (top_size >= (long)MINSIZE) /* if not, we are very very dead! */ + { + sbrked_mem = current_lim - sbrk_base; + set_head(top, top_size | PREV_INUSE); init_freed_chunk(top, top_size, 0); - } - check_chunk(top); - return 0; + } + check_chunk(top); + return 0; } else { - /* Success. Adjust top accordingly. */ - set_head(top, (top_size - extra) | PREV_INUSE); - sbrked_mem -= extra; + /* Success. Adjust top accordingly. */ + set_head(top, (top_size - extra) | PREV_INUSE); + sbrked_mem -= extra; init_freed_chunk(top, top_size - extra, 0); - check_chunk(top); - return 1; + check_chunk(top); + return 1; } } } diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 9bbdc6024..099993e5c 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -91,7 +91,7 @@ fillout_pinfo (pid_t pid, int winpid) static DWORD get_cygdrive_info (char *user, char *system, char *user_flags, - char *system_flags) + char *system_flags) { int res = mount_table->get_cygdrive_info (user, system, user_flags, system_flags); diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 88b80afe5..ec3690473 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -960,7 +960,7 @@ fhandler_disk_file::fstat (struct stat *buf) { /* If read-only attribute is set, modify ntsec return value */ if ((local.dwFileAttributes & FILE_ATTRIBUTE_READONLY) - && !get_symlink_p ()) + && !get_symlink_p ()) buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); if (!(buf->st_mode & S_IFMT)) @@ -1094,9 +1094,9 @@ int fhandler_base::fcntl (int cmd, void *arg) * Since O_ASYNC isn't defined in fcntl.h it's currently * ignored as well. */ - const int allowed_flags = O_APPEND | O_NONBLOCK_MASK; + const int allowed_flags = O_APPEND | O_NONBLOCK_MASK; int new_flags = (int) arg & allowed_flags; - /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag. + /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag. Set only the flag that has been passed in. If both are set, just record O_NONBLOCK. */ if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK)) @@ -1249,7 +1249,7 @@ fhandler_disk_file::open (const char *path, int flags, mode_t mode) || !(flags & O_CREAT) || real_path.case_clash)) { set_errno (flags & O_CREAT && real_path.case_clash ? ECASECLASH - : real_path.error); + : real_path.error); syscall_printf ("0 = fhandler_disk_file::open (%s, %p)", path, flags); return 0; } diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 98155c9c1..de21bc446 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -321,7 +321,7 @@ fhandler_console::read (void *pv, size_t buflen) an ASCII control character, interpret is as META. */ meta = (control_key_state & ALT_PRESSED) != 0 && ((control_key_state & CTRL_PRESSED) == 0 - || (ich >= 0 && ich <= 0x1f || ich == 0x7f)); + || (ich >= 0 && ich <= 0x1f || ich == 0x7f)); else /* Win9x: there's no way to distinguish Alt from AltGr, so rely on meta_mask heuristic (see fhandler_console constructor). */ diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 471b16b18..994bba9f1 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -179,8 +179,8 @@ fhandler_dev_floppy::lseek (off_t offset, int whence) devbufstart = devbufend = 0; if (SetFilePointer (get_handle (), sector_aligned_offset, NULL, FILE_BEGIN) - == INVALID_SET_FILE_POINTER) - { + == INVALID_SET_FILE_POINTER) + { __seterrno (); return -1; } diff --git a/winsup/cygwin/fhandler_mem.cc b/winsup/cygwin/fhandler_mem.cc index 58aeeb3db..bc4cb36bf 100644 --- a/winsup/cygwin/fhandler_mem.cc +++ b/winsup/cygwin/fhandler_mem.cc @@ -39,15 +39,15 @@ fhandler_dev_mem::fhandler_dev_mem (const char *name, int nunit) NTSTATUS ret; SYSTEM_BASIC_INFORMATION sbi; if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi, - sizeof sbi, NULL)) != STATUS_SUCCESS) - { - __seterrno_from_win_error (RtlNtStatusToDosError (ret)); - debug_printf("NtQuerySystemInformation: ret = %d, Dos(ret) = %d", - ret, RtlNtStatusToDosError (ret)); - mem_size = 0; - } + sizeof sbi, NULL)) != STATUS_SUCCESS) + { + __seterrno_from_win_error (RtlNtStatusToDosError (ret)); + debug_printf("NtQuerySystemInformation: ret = %d, Dos(ret) = %d", + ret, RtlNtStatusToDosError (ret)); + mem_size = 0; + } else - mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages; + mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages; debug_printf ("MemSize: %d MB", mem_size >> 20); } else if (unit == 2) /* /dev/kmem - Not yet supported */ @@ -78,9 +78,9 @@ fhandler_dev_mem::open (const char *, int flags, mode_t) { set_errno (ENOENT); debug_printf ("%s is accessible under NT/W2K only", - unit == 1 ? "/dev/mem" : - unit == 2 ? "/dev/kmem" : - "/dev/port"); + unit == 1 ? "/dev/mem" : + unit == 2 ? "/dev/kmem" : + "/dev/port"); return 0; } @@ -96,7 +96,7 @@ fhandler_dev_mem::open (const char *, int flags, mode_t) OBJECT_ATTRIBUTES attr; InitializeObjectAttributes(&attr, &memstr, - OBJ_CASE_INSENSITIVE | OBJ_INHERIT, + OBJ_CASE_INSENSITIVE | OBJ_INHERIT, NULL, NULL); ACCESS_MASK section_access; @@ -152,15 +152,15 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen) phys.QuadPart = (ULONGLONG) pos; if ((ret = NtMapViewOfSection (get_handle (), - INVALID_HANDLE_VALUE, - &viewmem, - 0L, - len, - &phys, - &len, - ViewShare, - 0, - PAGE_READONLY)) != STATUS_SUCCESS) + INVALID_HANDLE_VALUE, + &viewmem, + 0L, + len, + &phys, + &len, + ViewShare, + 0, + PAGE_READONLY)) != STATUS_SUCCESS) { __seterrno_from_win_error (RtlNtStatusToDosError (ret)); return -1; @@ -200,15 +200,15 @@ fhandler_dev_mem::read (void *ptr, size_t ulen) phys.QuadPart = (ULONGLONG) pos; if ((ret = NtMapViewOfSection (get_handle (), - INVALID_HANDLE_VALUE, - &viewmem, - 0L, - len, - &phys, - &len, - ViewShare, - 0, - PAGE_READONLY)) != STATUS_SUCCESS) + INVALID_HANDLE_VALUE, + &viewmem, + 0L, + len, + &phys, + &len, + ViewShare, + 0, + PAGE_READONLY)) != STATUS_SUCCESS) { __seterrno_from_win_error (RtlNtStatusToDosError (ret)); return -1; @@ -283,7 +283,7 @@ fhandler_dev_mem::mmap (caddr_t *addr, size_t len, DWORD access, OBJECT_ATTRIBUTES attr; InitializeObjectAttributes(&attr, &memstr, OBJ_CASE_INSENSITIVE | OBJ_INHERIT, - NULL, NULL); + NULL, NULL); ACCESS_MASK section_access; ULONG protect; diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index a434a0129..77a041c0f 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -46,7 +46,7 @@ fhandler_socket::fhandler_socket (const char *name) : set_cb (sizeof *this); set_need_fork_fixup (); prot_info_ptr = (LPWSAPROTOCOL_INFOA) ccalloc (HEAP_BUF, 1, - sizeof (WSAPROTOCOL_INFOA)); + sizeof (WSAPROTOCOL_INFOA)); } fhandler_socket::~fhandler_socket () @@ -134,8 +134,8 @@ fhandler_socket::check_peer_secret_event (struct sockaddr_in* peer, int* secret) int* secret_ptr = (secret ? : connect_secret); __small_sprintf (buf, SECRET_EVENT_NAME, peer->sin_port, - secret_ptr [0], secret_ptr [1], - secret_ptr [2], secret_ptr [3]); + secret_ptr [0], secret_ptr [1], + secret_ptr [2], secret_ptr [3]); ev = CreateEvent (&sec_all_nih, FALSE, FALSE, buf); if (!ev && GetLastError () == ERROR_ALREADY_EXISTS) { @@ -188,9 +188,9 @@ fhandler_socket::fixup_after_fork (HANDLE parent) prot_info_ptr->dwServiceFlags1); if (prot_info_ptr && (new_sock = WSASocketA (FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - prot_info_ptr, 0, 0)) == INVALID_SOCKET) + FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, + prot_info_ptr, 0, 0)) == INVALID_SOCKET) { debug_printf ("WSASocket error"); set_winsock_errno (); @@ -312,10 +312,10 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) } ifr->ifr_flags = IFF_NOTRAILERS | IFF_UP | IFF_RUNNING; if (ntohl (((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr) - == INADDR_LOOPBACK) - ifr->ifr_flags |= IFF_LOOPBACK; + == INADDR_LOOPBACK) + ifr->ifr_flags |= IFF_LOOPBACK; else - ifr->ifr_flags |= IFF_BROADCAST; + ifr->ifr_flags |= IFF_BROADCAST; res = 0; break; case SIOCGIFBRDADDR: @@ -424,18 +424,18 @@ fhandler_socket::fcntl (int cmd, void *arg) { case F_SETFL: { - /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag. + /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag. Set only the flag that has been passed in. If both are set, just record O_NONBLOCK. */ int new_flags = (int) arg & O_NONBLOCK_MASK; if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK)) new_flags = O_NONBLOCK; - current = get_flags () & O_NONBLOCK_MASK; + current = get_flags () & O_NONBLOCK_MASK; request = new_flags ? 1 : 0; - if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request))) - break; + if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request))) + break; set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags); - break; + break; } default: res = fhandler_base::fcntl (cmd, arg); diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index e3ca86d55..b0ee336aa 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -711,11 +711,11 @@ fhandler_tty_slave::read (void *ptr, size_t len) termios_printf ("read failed, %E"); _raise (SIGHUP); } - /* MSDN states that 5th prameter can be used to determine total - number of bytes in pipe, but for some reason this number doesn't - change after successful read. So we have to peek into the pipe - again to see if input is still available */ - if (!PeekNamedPipe (get_handle (), peek_buf, 1, &bytes_in_pipe, NULL, NULL)) + /* MSDN states that 5th prameter can be used to determine total + number of bytes in pipe, but for some reason this number doesn't + change after successful read. So we have to peek into the pipe + again to see if input is still available */ + if (!PeekNamedPipe (get_handle (), peek_buf, 1, &bytes_in_pipe, NULL, NULL)) { termios_printf ("PeekNamedPipe failed, %E"); _raise (SIGHUP); diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 696daaf05..b72b441dc 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -246,7 +246,7 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls) sync_with_parent ("after longjmp.", TRUE); ProtectHandle (hParent); sigproc_printf ("hParent %p, child 1 first_dll %p, load_dlls %d\n", hParent, - first_dll, load_dlls); + first_dll, load_dlls); #ifdef DEBUGGING char c; @@ -279,7 +279,6 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls) debug_fixup_after_fork (); pinfo_fixup_after_fork (); cygheap->fdtab.fixup_after_fork (hParent); - sigproc_fixup_after_fork (); signal_fixup_after_fork (); MALLOC_CHECK; @@ -430,9 +429,6 @@ fork_parent (HANDLE& hParent, dll *&first_dll, init_child_info (PROC_FORK1, &ch, 1, subproc_ready); ch.forker_finished = forker_finished; - ch.heaptop = user_data->heaptop; - ch.heapbase = user_data->heapbase; - ch.heapptr = user_data->heapptr; stack_base (ch); @@ -489,7 +485,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll, ForceCloseHandle(forker_finished); /* Restore impersonation */ if (cygheap->user.impersonated - && cygheap->user.token != INVALID_HANDLE_VALUE) + && cygheap->user.token != INVALID_HANDLE_VALUE) ImpersonateLoggedOnUser (cygheap->user.token); return -1; } @@ -556,7 +552,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll, rc = fork_copy (pi, "user/cygwin data", user_data->data_start, user_data->data_end, user_data->bss_start, user_data->bss_end, - ch.heapbase, ch.heapptr, + cygheap->heapbase, cygheap->heapptr, stack_here, ch.stackbottom, dll_data_start, dll_data_end, dll_bss_start, dll_bss_end, NULL); diff --git a/winsup/cygwin/gmon.c b/winsup/cygwin/gmon.c index e07d62221..95a7f430e 100644 --- a/winsup/cygwin/gmon.c +++ b/winsup/cygwin/gmon.c @@ -104,7 +104,7 @@ monstartup(lowpc, highpc) cp += p->kcountsize; p->froms = (u_short *)cp; - /* XXX minbrk needed? */ + /* XXX minbrk needed? */ //minbrk = fake_sbrk(0); p->tos[0].link = 0; @@ -151,7 +151,7 @@ _mcleanup() if (p->state == GMON_PROF_ERROR) ERR("_mcleanup: tos overflow\n"); - hz = PROF_HZ; + hz = PROF_HZ; moncontrol(0); #ifdef nope diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index e73c9a058..b70db13f8 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -83,7 +83,7 @@ public: last_modified = data.ftLastWriteTime; } FindClose (h); - } + } return state; } void operator = (grp_state nstate) @@ -118,37 +118,37 @@ parse_grp (struct group &grp, const char *line) { *dp++ = '\0'; if (!strlen (grp.gr_passwd)) - grp.gr_passwd = NULL; + grp.gr_passwd = NULL; grp.gr_gid = strtol (dp, NULL, 10); dp = strchr (dp, ':'); if (dp) - { - if (*++dp) - { - int i = 0; - char *cp; + { + if (*++dp) + { + int i = 0; + char *cp; - for (cp = dp; (cp = strchr (cp, ',')) != NULL; ++cp) - ++i; - char **namearray = (char **) calloc (i + 2, sizeof (char *)); - if (namearray) - { - i = 0; - for (cp = dp; (cp = strchr (dp, ',')) != NULL; dp = cp + 1) - { - *cp = '\0'; - namearray[i++] = dp; - } - namearray[i++] = dp; - namearray[i] = NULL; - } + for (cp = dp; (cp = strchr (cp, ',')) != NULL; ++cp) + ++i; + char **namearray = (char **) calloc (i + 2, sizeof (char *)); + if (namearray) + { + i = 0; + for (cp = dp; (cp = strchr (dp, ',')) != NULL; dp = cp + 1) + { + *cp = '\0'; + namearray[i++] = dp; + } + namearray[i++] = dp; + namearray[i] = NULL; + } grp.gr_mem = namearray; - } - else - grp.gr_mem = (char **) calloc (1, sizeof (char *)); - return 1; - } + } + else + grp.gr_mem = (char **) calloc (1, sizeof (char *)); + return 1; + } } return 0; } @@ -195,7 +195,7 @@ read_etc_group () { group_state = initializing; if (max_lines) /* When rereading, free allocated memory first. */ - { + { for (int i = 0; i < curr_lines; ++i) { free (group_buf[i].gr_name); @@ -256,9 +256,9 @@ getgrgid (gid_t gid) for (int i = 0; i < curr_lines; i++) { if (group_buf[i].gr_gid == DEFAULT_GID) - default_grp = group_buf + i; + default_grp = group_buf + i; if (group_buf[i].gr_gid == gid) - return group_buf + i; + return group_buf + i; } return default_grp; @@ -333,8 +333,8 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username) OpenProcessToken (hMainProc, TOKEN_QUERY, &hToken)) { if (GetTokenInformation (hToken, TokenGroups, NULL, 0, &size) - || GetLastError () == ERROR_INSUFFICIENT_BUFFER) - { + || GetLastError () == ERROR_INSUFFICIENT_BUFFER) + { char buf[size]; TOKEN_GROUPS *groups = (TOKEN_GROUPS *) buf; @@ -358,12 +358,12 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username) break; } } - } + } else - debug_printf ("%d = GetTokenInformation(NULL) %E", size); + debug_printf ("%d = GetTokenInformation(NULL) %E", size); CloseHandle (hToken); if (cnt) - return cnt; + return cnt; } for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index 3fd6d5465..6ee295817 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -16,6 +16,10 @@ details. */ #include "pinfo.h" #include "heap.h" #include "shared_info.h" +#include "security.h" +#include "fhandler.h" +#include "dtable.h" +#include "cygheap.h" #define assert(x) diff --git a/winsup/cygwin/heap.h b/winsup/cygwin/heap.h index 848be5735..fca9d9e5c 100644 --- a/winsup/cygwin/heap.h +++ b/winsup/cygwin/heap.h @@ -16,9 +16,9 @@ void malloc_init (); #define inheap(s) (brk && ((char *) (s) >= (char *) brkbase) && ((char *) (s) <= (char *) brktop)) -#define brksize ((char *) user_data->heaptop - (char *) user_data->heapbase) -#define brk (user_data->heapptr) -#define brkbase (user_data->heapbase) -#define brktop (user_data->heaptop) +#define brksize ((char *) cygheap->heaptop - (char *) cygheap->heapbase) +#define brk (cygheap->heapptr) +#define brkbase (cygheap->heapbase) +#define brktop (cygheap->heaptop) #define brkchunk (cygwin_shared->heap_chunk_size ()) diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index f270a82d0..a468b54f3 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -142,6 +142,7 @@ details. */ 42: sys_errlist, sys_nerr 43: sigsetjmp, siglongjmp fixed 44: Export dirfd + 45: perprocess change */ #define CYGWIN_VERSION_API_MAJOR 0 diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 6b0dc91b7..1d53f636b 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -163,14 +163,7 @@ struct per_process /* non-zero of ctors have been run. Inherited from parent. */ int run_ctors_p; - DWORD unused[3]; - - /* Heap management. Inherited from parent. */ - void *heapbase; /* bottom of the heap */ - void *heapptr; /* current index into heap */ - void *heaptop; /* current top of heap */ - - DWORD unused1; + DWORD unused[7]; /* Non-zero means the task was forked. The value is the pid. Inherited from parent. */ diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 1dfff73a2..c5d46fbf0 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -129,11 +129,11 @@ check_null_empty_str (const char *name) int __stdcall check_null_empty_str_errno (const char *name) -{ - int __err; - if ((__err = check_null_empty_str (name))) - set_errno (__err); - return __err; +{ + int __err; + if ((__err = check_null_empty_str (name))) + set_errno (__err); + return __err; } int __stdcall @@ -147,9 +147,9 @@ __check_null_invalid_struct (const void *s, unsigned sz) int __stdcall __check_null_invalid_struct_errno (const void *s, unsigned sz) -{ - int __err; - if ((__err = __check_null_invalid_struct (s, sz))) - set_errno (__err); - return __err; +{ + int __err; + if ((__err = __check_null_invalid_struct (s, sz))) + set_errno (__err); + return __err; } diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 18ff29be5..9bb84b419 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -388,7 +388,7 @@ free_char_list (char **clist) if (clist) { for (char **cl = clist; *cl; ++cl) - free (*cl); + free (*cl); free (clist); } } @@ -416,7 +416,7 @@ dup_addr_list (char **src, unsigned int size) { char **dst; int cnt = 0; - + for (char **cl = src; *cl; ++cl) ++cnt; if (!(dst = (char **) calloc (cnt + 1, sizeof *dst))) @@ -424,7 +424,7 @@ dup_addr_list (char **src, unsigned int size) while (cnt-- > 0) { if (!(dst[cnt] = (char *) malloc(size))) - return NULL; + return NULL; memcpy(dst[cnt], src[cnt], size); } return dst; @@ -438,7 +438,7 @@ free_protoent_ptr (struct protoent *&p) debug_printf ("protoent: %s", p->p_name); if (p->p_name) - free (p->p_name); + free (p->p_name); free_char_list (p->p_aliases); p = NULL; } @@ -878,7 +878,7 @@ cygwin_connect (int fd, in_progress = TRUE; } else if (err == WSAEINVAL) - WSASetLastError (WSAEISCONN); + WSASetLastError (WSAEISCONN); } set_winsock_errno (); } @@ -924,9 +924,9 @@ free_servent_ptr (struct servent *&p) debug_printf ("servent: %s", p->s_name); if (p->s_name) - free (p->s_name); + free (p->s_name); if (p->s_proto) - free (p->s_proto); + free (p->s_proto); free_char_list (p->s_aliases); p = NULL; } @@ -1022,7 +1022,7 @@ free_hostent_ptr (struct hostent *&p) debug_printf ("hostent: %s", p->h_name); if (p->h_name) - free ((void *)p->h_name); + free ((void *)p->h_name); free_char_list (p->h_aliases); free_addr_list (p->h_addr_list); p = NULL; @@ -1858,18 +1858,18 @@ get_nt_ifconf (struct ifconf *ifc, int what) /* * IFCONF Windows 95: * HKLM/Enum/Network/MSTCP/"*" - * -> Value "Driver" enthält Subkey relativ zu - * HKLM/System/CurrentControlSet/Class/ - * -> In Subkey "Bindings" die Values aufzählen - * -> Enthält Subkeys der Form "VREDIR\*" - * Das * ist ein Subkey relativ zu - * HKLM/System/CurrentControlSet/Class/Net/ + * -> Value "Driver" enthält Subkey relativ zu + * HKLM/System/CurrentControlSet/Class/ + * -> In Subkey "Bindings" die Values aufzählen + * -> Enthält Subkeys der Form "VREDIR\*" + * Das * ist ein Subkey relativ zu + * HKLM/System/CurrentControlSet/Class/Net/ * HKLM/System/CurrentControlSet/Class/"Driver" - * -> Value "IPAddress" - * -> Value "IPMask" + * -> Value "IPAddress" + * -> Value "IPMask" * HKLM/System/CurrentControlSet/Class/Net/"*"(aus "VREDIR\*") - * -> Wenn Value "AdapterName" == "MS$PPP" -> ppp interface - * -> Value "DriverDesc" enthält den Namen + * -> Wenn Value "AdapterName" == "MS$PPP" -> ppp interface + * -> Value "DriverDesc" enthält den Namen * */ static void diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index 465d60969..f11ce46f7 100644 --- a/winsup/cygwin/ntdll.h +++ b/winsup/cygwin/ntdll.h @@ -137,10 +137,10 @@ typedef struct _SYSTEM_PROCESSES extern "C" { NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - TOKEN_TYPE, PLUID, PLARGE_INTEGER, PTOKEN_USER, - PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_OWNER, - PTOKEN_PRIMARY_GROUP, PTOKEN_DEFAULT_DACL, - PTOKEN_SOURCE); + TOKEN_TYPE, PLUID, PLARGE_INTEGER, PTOKEN_USER, + PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_OWNER, + PTOKEN_PRIMARY_GROUP, PTOKEN_DEFAULT_DACL, + PTOKEN_SOURCE); NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG, ULONG, PLARGE_INTEGER, PULONG, SECTION_INHERIT, ULONG, ULONG); diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index 4fe7166aa..a43869676 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -72,7 +72,7 @@ public: last_modified = data.ftLastWriteTime; } FindClose (h); - } + } return state; } void operator = (pwd_state nstate) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 57e4e2c12..92611d7b1 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3115,7 +3115,7 @@ fchdir (int fd) char path[MAX_PATH]; char posix_path[MAX_PATH]; mount_table->conv_to_posix_path (cygheap->cwd.get (path, 0, 1), - posix_path, 0); + posix_path, 0); cygheap->fdtab[fd]->set_name (path, posix_path); } diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index 6361c4fd1..cd1b27462 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -124,7 +124,7 @@ getrlimit (int resource, struct rlimit *rlp) if (!VirtualQuery ((LPCVOID) &m, &m, sizeof m)) debug_printf ("couldn't get stack info, returning def.values. %E"); else - { + { rlp->rlim_cur = (DWORD) &m - (DWORD) m.AllocationBase; rlp->rlim_max = (DWORD) m.BaseAddress + m.RegionSize - (DWORD) m.AllocationBase; @@ -174,7 +174,7 @@ setrlimit (int resource, const struct rlimit *rlp) break; case RLIMIT_NOFILE: if (rlp->rlim_cur != RLIM_INFINITY) - return setdtablesize (rlp->rlim_cur); + return setdtablesize (rlp->rlim_cur); break; default: set_errno (EINVAL); diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index 2b2ee744e..feb261674 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -125,7 +125,7 @@ setacl (const char *file, int nentries, aclent_t *aclbufp) if (aclbufp[i].a_perm & S_IXOTH) allow |= FILE_GENERIC_EXECUTE; if ((aclbufp[i].a_perm & (S_IWOTH | S_IXOTH)) == (S_IWOTH | S_IXOTH)) - allow |= FILE_DELETE_CHILD; + allow |= FILE_DELETE_CHILD; /* Set inherit property. */ DWORD inheritance = (aclbufp[i].a_type & ACL_DEFAULT) ? INHERIT_ONLY : DONT_INHERIT; @@ -433,7 +433,7 @@ acl_access (const char *path, int flags) && owner == group && is_grp_member (myself->uid, gr->gr_gid)) break; - } + } if (!gr) continue; } diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index 925a6b237..a512effac 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -36,12 +36,12 @@ details. */ #include "cygheap.h" SID_IDENTIFIER_AUTHORITY sid_auth[] = { - {SECURITY_NULL_SID_AUTHORITY}, - {SECURITY_WORLD_SID_AUTHORITY}, - {SECURITY_LOCAL_SID_AUTHORITY}, - {SECURITY_CREATOR_SID_AUTHORITY}, - {SECURITY_NON_UNIQUE_AUTHORITY}, - {SECURITY_NT_AUTHORITY} + {SECURITY_NULL_SID_AUTHORITY}, + {SECURITY_WORLD_SID_AUTHORITY}, + {SECURITY_LOCAL_SID_AUTHORITY}, + {SECURITY_CREATOR_SID_AUTHORITY}, + {SECURITY_NON_UNIQUE_AUTHORITY}, + {SECURITY_NT_AUTHORITY} }; cygsid well_known_null_sid ("S-1-0-0"); @@ -348,7 +348,7 @@ set_process_privilege (const char *privilege, BOOL enable) DWORD size; if (!OpenProcessToken (hMainProc, TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, - &hToken)) + &hToken)) { __seterrno (); goto out; @@ -365,7 +365,7 @@ set_process_privilege (const char *privilege, BOOL enable) new_priv.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0; if (!AdjustTokenPrivileges (hToken, FALSE, &new_priv, - sizeof orig_priv, &orig_priv, &size)) + sizeof orig_priv, &orig_priv, &size)) { __seterrno (); goto out; diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index f208ebeec..5cbf44230 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -83,7 +83,7 @@ extract_nt_dom_user (const struct passwd *pw, char *domain, char *user) if (pw->pw_gecos) { if ((c = strstr (pw->pw_gecos, "U-")) != NULL && - (c == pw->pw_gecos || c[-1] == ',')) + (c == pw->pw_gecos || c[-1] == ',')) { buf[0] = '\0'; strncat (buf, c + 2, INTERNET_MAX_HOST_NAME_LENGTH + UNLEN + 1); @@ -210,7 +210,7 @@ get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain) PPOLICY_PRIMARY_DOMAIN_INFO pdi; if ((ret = LsaQueryInformationPolicy (lsa, PolicyAccountDomainInformation, - (PVOID *) &adi)) != STATUS_SUCCESS) + (PVOID *) &adi)) != STATUS_SUCCESS) { set_errno (LsaNtStatusToWinError(ret)); return FALSE; @@ -218,7 +218,7 @@ get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain) lsa2wchar (account, adi->DomainName, INTERNET_MAX_HOST_NAME_LENGTH + 1); LsaFreeMemory (adi); if ((ret = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation, - (PVOID *) &pdi)) != STATUS_SUCCESS) + (PVOID *) &pdi)) != STATUS_SUCCESS) { set_errno (LsaNtStatusToWinError(ret)); return FALSE; @@ -226,18 +226,18 @@ get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain) lsa2wchar (primary, pdi->Name, INTERNET_MAX_HOST_NAME_LENGTH + 1); LsaFreeMemory (pdi); if ((ret = NetServerEnum (NULL, 101, (LPBYTE *) &buf, MAX_PREFERRED_LENGTH, - &cnt, &tot, SV_TYPE_DOMAIN_CTRL, primary, NULL)) + &cnt, &tot, SV_TYPE_DOMAIN_CTRL, primary, NULL)) == STATUS_SUCCESS && cnt > 0) { sys_wcstombs (name, buf[0].sv101_name, INTERNET_MAX_HOST_NAME_LENGTH + 1); if (domain) - sys_wcstombs (domain, primary, INTERNET_MAX_HOST_NAME_LENGTH + 1); + sys_wcstombs (domain, primary, INTERNET_MAX_HOST_NAME_LENGTH + 1); } else { sys_wcstombs (name, account, INTERNET_MAX_HOST_NAME_LENGTH + 1); if (domain) - sys_wcstombs (domain, account, INTERNET_MAX_HOST_NAME_LENGTH + 1); + sys_wcstombs (domain, account, INTERNET_MAX_HOST_NAME_LENGTH + 1); } if (ret == STATUS_SUCCESS) NetApiBufferFree (buf); @@ -298,19 +298,19 @@ get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user) sys_wcstombs (group, buf[i].grui0_name, UNLEN + 1); if (!LookupAccountName (NULL, group, gsid, &glen, domain, &dlen, &use)) - debug_printf ("LookupAccountName(%s): %lu\n", group, GetLastError ()); + debug_printf ("LookupAccountName(%s): %lu\n", group, GetLastError ()); if (!legal_sid_type (use)) - { - strcat (strcpy (group, domain), "\\"); - sys_wcstombs (group + strlen (group), buf[i].grui0_name, - UNLEN + 1 - strlen (group)); - glen = UNLEN + 1; - dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1; - if (!LookupAccountName(NULL, group, gsid, &glen, domain, &dlen, &use)) - debug_printf ("LookupAccountName(%s): %lu\n", group,GetLastError()); - } + { + strcat (strcpy (group, domain), "\\"); + sys_wcstombs (group + strlen (group), buf[i].grui0_name, + UNLEN + 1 - strlen (group)); + glen = UNLEN + 1; + dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1; + if (!LookupAccountName(NULL, group, gsid, &glen, domain, &dlen, &use)) + debug_printf ("LookupAccountName(%s): %lu\n", group,GetLastError()); + } if (legal_sid_type (use)) - grp_list += gsid; + grp_list += gsid; } NetApiBufferFree (buf); @@ -319,7 +319,7 @@ get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user) static BOOL is_group_member (WCHAR *wlogonserver, WCHAR *wgroup, - cygsid &usersid, cygsidlist &grp_list) + cygsid &usersid, cygsidlist &grp_list) { LPLOCALGROUP_MEMBERS_INFO_0 buf; DWORD cnt, tot; @@ -390,7 +390,7 @@ get_user_local_groups (WCHAR *wlogonserver, const char *logonserver, { strcat (strcpy (group, domain), "\\"); sys_wcstombs (group + strlen (group), buf[i].lgrpi0_name, - UNLEN + 1 - strlen (group)); + UNLEN + 1 - strlen (group)); glen = UNLEN + 1; dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1; if (!LookupAccountName (NULL, group, gsid, &glen, @@ -565,7 +565,7 @@ get_system_priv_list (cygsidlist &grp_list) { privs->Privileges[privs->PrivilegeCount].Luid = priv; privs->Privileges[privs->PrivilegeCount].Attributes = - SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT; + SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT; ++privs->PrivilegeCount; } return privs; @@ -586,52 +586,52 @@ get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list) for (int grp = -1; grp < grp_list.count; ++grp) { if (grp == -1) - { - if ((ret = LsaEnumerateAccountRights (lsa, usersid, &privstrs, &cnt)) - != STATUS_SUCCESS) - continue; - } + { + if ((ret = LsaEnumerateAccountRights (lsa, usersid, &privstrs, &cnt)) + != STATUS_SUCCESS) + continue; + } else if ((ret = LsaEnumerateAccountRights (lsa, grp_list.sids[grp], - &privstrs, &cnt)) - != STATUS_SUCCESS) + &privstrs, &cnt)) + != STATUS_SUCCESS) continue; for (ULONG i = 0; i < cnt; ++i) - { - LUID priv; - PTOKEN_PRIVILEGES tmp; - DWORD tmp_count; + { + LUID priv; + PTOKEN_PRIVILEGES tmp; + DWORD tmp_count; - sys_wcstombs (buf, privstrs[i].Buffer, - INTERNET_MAX_HOST_NAME_LENGTH + 1); - if (!LookupPrivilegeValue (NULL, buf, &priv)) - continue; + sys_wcstombs (buf, privstrs[i].Buffer, + INTERNET_MAX_HOST_NAME_LENGTH + 1); + if (!LookupPrivilegeValue (NULL, buf, &priv)) + continue; - for (DWORD p = 0; privs && p < privs->PrivilegeCount; ++p) - if (!memcmp (&priv, &privs->Privileges[p].Luid, sizeof (LUID))) - goto next_account_right; + for (DWORD p = 0; privs && p < privs->PrivilegeCount; ++p) + if (!memcmp (&priv, &privs->Privileges[p].Luid, sizeof (LUID))) + goto next_account_right; - tmp_count = privs ? privs->PrivilegeCount : 0; - tmp = (PTOKEN_PRIVILEGES) - realloc (privs, sizeof (ULONG) + - (tmp_count + 1) * sizeof (LUID_AND_ATTRIBUTES)); - if (!tmp) - { + tmp_count = privs ? privs->PrivilegeCount : 0; + tmp = (PTOKEN_PRIVILEGES) + realloc (privs, sizeof (ULONG) + + (tmp_count + 1) * sizeof (LUID_AND_ATTRIBUTES)); + if (!tmp) + { if (privs) free (privs); - LsaFreeMemory (privstrs); + LsaFreeMemory (privstrs); debug_printf ("realloc (privs) failed."); - return NULL; - } - tmp->PrivilegeCount = tmp_count; - privs = tmp; - privs->Privileges[privs->PrivilegeCount].Luid = priv; - privs->Privileges[privs->PrivilegeCount].Attributes = - SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT; - ++privs->PrivilegeCount; + return NULL; + } + tmp->PrivilegeCount = tmp_count; + privs = tmp; + privs->Privileges[privs->PrivilegeCount].Luid = priv; + privs->Privileges[privs->PrivilegeCount].Attributes = + SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT; + ++privs->PrivilegeCount; - next_account_right: - ; - } + next_account_right: + ; + } LsaFreeMemory (privstrs); } return privs; @@ -652,10 +652,10 @@ get_dacl (PACL acl, cygsid usersid, cygsidlist &grp_list) { if (!AddAccessAllowedAce(acl, ACL_REVISION, GENERIC_ALL, well_known_admins_sid)) - { + { __seterrno (); - return FALSE; - } + return FALSE; + } } else if (!AddAccessAllowedAce(acl, ACL_REVISION, GENERIC_ALL, usersid)) { @@ -712,7 +712,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid) /* SE_CREATE_TOKEN_NAME privilege needed to call NtCreateToken. */ if ((old_priv_state = set_process_privilege (SE_CREATE_TOKEN_NAME)) < 0) goto out; - + /* Open policy object. */ if ((lsa = open_local_policy ()) == INVALID_HANDLE_VALUE) goto out; @@ -1191,7 +1191,7 @@ get_nt_attribute (const char *file, int *attribute, *flags |= S_ISVTX; } else if (ace_sid == well_known_null_sid) - { + { /* Read SUID, SGID and VTX bits from NULL ACE. */ if (ace->Mask & FILE_READ_DATA) *flags |= S_ISVTX; @@ -1416,11 +1416,11 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute, if (attribute & (S_ISUID | S_ISGID | S_ISVTX)) { if (attribute & S_ISUID) - null_allow |= FILE_APPEND_DATA; + null_allow |= FILE_APPEND_DATA; if (attribute & S_ISGID) - null_allow |= FILE_WRITE_DATA; + null_allow |= FILE_WRITE_DATA; if (attribute & S_ISVTX) - null_allow |= FILE_READ_DATA; + null_allow |= FILE_READ_DATA; } /* Construct deny attributes for owner and group. */ @@ -1548,7 +1548,7 @@ set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa, psa->lpSecurityDescriptor = sd_buf; InitializeSecurityDescriptor ((PSECURITY_DESCRIPTOR)sd_buf, - SECURITY_DESCRIPTOR_REVISION); + SECURITY_DESCRIPTOR_REVISION); psa->lpSecurityDescriptor = alloc_sd (geteuid (), getegid (), cygheap->user.logsrv (), attribute, (PSECURITY_DESCRIPTOR)sd_buf, diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h index e2060802b..95f97b8ca 100644 --- a/winsup/cygwin/security.h +++ b/winsup/cygwin/security.h @@ -29,12 +29,12 @@ class cygsid { inline const PSID assign (const PSID nsid) { if (!nsid) - psid = NO_SID; + psid = NO_SID; else - { - psid = (PSID) sbuf; - CopySid (MAX_SID_LEN, psid, nsid); - } + { + psid = (PSID) sbuf; + CopySid (MAX_SID_LEN, psid, nsid); + } return psid; } @@ -64,7 +64,7 @@ public: inline BOOL operator== (const PSID nsid) const { if (!psid || !nsid) - return nsid == psid; + return nsid == psid; return EqualSid (psid, nsid); } inline BOOL operator== (const char *nsidstr) const @@ -98,9 +98,9 @@ public: { cygsid *tmp = new cygsid [count + 1]; if (!tmp) - return FALSE; + return FALSE; for (int i = 0; i < count; ++i) - tmp[i] = sids[i]; + tmp[i] = sids[i]; delete [] sids; sids = tmp; sids[count++] = nsi; @@ -116,7 +116,7 @@ public: BOOL contains (cygsid &sid) const { for (int i = 0; i < count; ++i) - if (sids[i] == sid) + if (sids[i] == sid) return TRUE; return FALSE; } @@ -124,9 +124,9 @@ public: { debug_printf ("-- begin sidlist ---"); if (!count) - debug_printf ("No elements"); + debug_printf ("No elements"); for (int i = 0; i < count; ++i) - sids[i].debug_print (prefix); + sids[i].debug_print (prefix); debug_printf ("-- ende sidlist ---"); } }; diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 5622765fa..2fe5b85a9 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -151,7 +151,6 @@ memory_init () cygwin_shared_address); cygwin_shared->initialize (); - heap_init (); /* Allocate memory for the per-user mount table */ char user_name[UNLEN + 1]; @@ -159,12 +158,6 @@ memory_init () if (!GetUserName (user_name, &user_name_len)) strcpy (user_name, "unknown"); - mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h, - sizeof (mount_info), 0); - debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (), - mount_table_address); - ProtectHandle (cygwin_mount_h); - debug_printf ("mount table version %x at %p", mount_table->version, mount_table); /* Initialize the Cygwin heap, if necessary */ if (!cygheap) @@ -172,9 +165,18 @@ memory_init () cygheap_init (); cygheap->user.set_name (user_name); } + cygheap->shared_h = shared_h; ProtectHandle (cygheap->shared_h); + heap_init (); + mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h, + sizeof (mount_info), 0); + debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (), + mount_table_address); + ProtectHandle (cygwin_mount_h); + debug_printf ("mount table version %x at %p", mount_table->version, mount_table); + /* Initialize the Cygwin per-user mount table, if necessary */ if (!mount_table->version) { diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index 40ddb9662..2a814afbb 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -85,7 +85,7 @@ class mount_info int write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags); int remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags); int get_cygdrive_info (char *user, char *system, char* user_flags, - char* system_flags); + char* system_flags); void import_v1_mounts (); diff --git a/winsup/cygwin/shortcut.c b/winsup/cygwin/shortcut.c index fd684e83b..d0c511da5 100644 --- a/winsup/cygwin/shortcut.c +++ b/winsup/cygwin/shortcut.c @@ -1,5 +1,5 @@ /* shortcut.c: Read shortcuts. This part of the code must be in C because - the C++ interface to COM doesn't work without -fvtable-thunk + the C++ interface to COM doesn't work without -fvtable-thunk which is too dangerous to use. Copyright 2001 Red Hat, Inc. @@ -107,7 +107,7 @@ check_shortcut (const char *path, DWORD fileattr, HANDLE h, { /* Check header if the shortcut is really created by Cygwin or U/WIN. */ if (got == SHORTCUT_HDR_SIZE && !cmp_shortcut_header (file_header)) - { + { hres = psl->lpVtbl->GetDescription (psl, contents, MAX_PATH); if (FAILED (hres)) goto file_not_symlink; diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index fcb82cd11..70671b884 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -224,8 +224,8 @@ kill_pgrp (pid_t pid, int sig) /* Is it a process we want to kill? */ if ((pid == 0 && (p->pgid != myself->pgid || p->ctty != myself->ctty)) || - (pid > 1 && p->pgid != pid) || - (sig < 0 && NOTSTATE(p, PID_STOPPED))) + (pid > 1 && p->pgid != pid) || + (sig < 0 && NOTSTATE(p, PID_STOPPED))) continue; sigproc_printf ("killing pid %d, pgrp %d, p->ctty %d, myself->ctty %d", p->pid, p->pgid, p->ctty, myself->ctty); diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index b3c69ffd5..39a300bf2 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -303,8 +303,6 @@ proc_subproc (DWORD what, DWORD val) int thiszombie; thiszombie = nzombies; - if (!zombies) - zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX); zombies[nzombies] = pchildren[val]; // Add to zombie array zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead @@ -545,6 +543,11 @@ sig_dispatch_pending (int justwake) void __stdcall sigproc_init () { + if (!zombies) + zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX); + else + nzombies = 0; + wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); ProtectHandle (wait_sig_inited); @@ -1304,17 +1307,6 @@ wait_subproc (VOID *) return 0; } -void __stdcall -sigproc_fixup_after_fork () -{ - if (zombies) - { - free (zombies); - nzombies = 0; - zombies = NULL; - } -} - extern "C" { /* Provide a stack frame when calling WaitFor* functions */ diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index c9b5cad3e..5726a4519 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -115,7 +115,6 @@ int __stdcall sig_send (_pinfo *, int, DWORD ebp = (DWORD) __builtin_frame_addre bool exception = 0) __attribute__ ((regparm(3))); void __stdcall signal_fixup_after_fork (); void __stdcall signal_fixup_after_exec (bool); -void __stdcall sigproc_fixup_after_fork (); extern char myself_nowait_dummy[]; extern char myself_nowait_nonmain_dummy[]; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 110efa325..61ca4dbc2 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -616,7 +616,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, cygsid sid; DWORD ret_len; if (!GetTokenInformation (hToken, TokenUser, &sid, sizeof sid, &ret_len)) - { + { sid = NO_SID; system_printf ("GetTokenInformation: %E"); } @@ -628,15 +628,15 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, /* Remove impersonation */ if (cygheap->user.impersonated - && cygheap->user.token != INVALID_HANDLE_VALUE) + && cygheap->user.token != INVALID_HANDLE_VALUE) RevertToSelf (); static BOOL first_time = TRUE; if (first_time) - { - set_process_privilege (SE_RESTORE_NAME); - first_time = FALSE; - } + { + set_process_privilege (SE_RESTORE_NAME); + first_time = FALSE; + } /* Load users registry hive. */ load_registry_hive (sid); @@ -703,7 +703,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, { cygheap->fdtab.fixup_before_exec (pi.dwProcessId); if (mode == _P_OVERLAY) - ResumeThread (pi.hThread); + ResumeThread (pi.hThread); } if (mode == _P_OVERLAY) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 5e5566a4b..3359c352e 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1138,7 +1138,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf, } } if (atts != -1 && (oret || (!oret && get_errno () != ENOENT - && get_errno () != ENOSHARE))) + && get_errno () != ENOSHARE))) { /* Unfortunately, the above open may fail if the file exists, though. So we have to care for this case here, too. */ @@ -1340,7 +1340,7 @@ _rename (const char *oldpath, const char *newpath) if (real_new.file_attributes () != (DWORD) -1 && real_new.file_attributes () & FILE_ATTRIBUTE_READONLY) SetFileAttributesA (real_new.get_win32 (), - real_new.file_attributes () & ~FILE_ATTRIBUTE_READONLY); + real_new.file_attributes () & ~FILE_ATTRIBUTE_READONLY); /* Shortcut hack No. 2, part 1 */ if (!real_old.issymlink () && !real_new.error && real_new.issymlink () && @@ -1400,9 +1400,9 @@ done: /* Shortcut hack, No. 2, part 2 */ /* if the new filename was an existing shortcut, remove it now if the - new filename is equal to the shortcut name without .lnk suffix. */ + new filename is equal to the shortcut name without .lnk suffix. */ if (lnk_suffix) - { + { *lnk_suffix = '.'; DeleteFile (real_new.get_win32 ()); } @@ -1494,7 +1494,7 @@ check_posix_perm (const char *fname, int v) if (!allow_smbntsec && ((root[0] == '\\' && root[1] == '\\') - || GetDriveType (root) == DRIVE_REMOTE)) + || GetDriveType (root) == DRIVE_REMOTE)) return 0; DWORD vsn, len, flags; @@ -1584,7 +1584,7 @@ pathconf (const char *file, int v) case _PC_POSIX_PERMISSIONS: case _PC_POSIX_SECURITY: { - path_conv full_path (file, PC_SYM_FOLLOW | PC_FULL); + path_conv full_path (file, PC_SYM_FOLLOW | PC_FULL); if (full_path.error) { set_errno (full_path.error); @@ -1595,7 +1595,7 @@ pathconf (const char *file, int v) set_errno (EINVAL); return -1; } - return check_posix_perm (full_path, v); + return check_posix_perm (full_path, v); } default: set_errno (EINVAL); @@ -2048,9 +2048,9 @@ seteuid (uid_t uid) char *env; orig_username[0] = orig_domain[0] = '\0'; if ((env = getenv ("USERNAME"))) - strncat (orig_username, env, UNLEN + 1); + strncat (orig_username, env, UNLEN + 1); if ((env = getenv ("USERDOMAIN"))) - strncat (orig_domain, env, INTERNET_MAX_HOST_NAME_LENGTH + 1); + strncat (orig_domain, env, INTERNET_MAX_HOST_NAME_LENGTH + 1); if (uid == cygheap->user.orig_uid) { @@ -2064,7 +2064,7 @@ seteuid (uid_t uid) if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &ptok)) debug_printf ("OpenProcessToken(): %E\n"); else if (!GetTokenInformation (ptok, TokenUser, &tok_usersid, - sizeof tok_usersid, &siz)) + sizeof tok_usersid, &siz)) debug_printf ("GetTokenInformation(): %E"); else if (!LookupAccountSid (NULL, tok_usersid, username, &ulen, domain, &dlen, &use)) @@ -2100,7 +2100,7 @@ seteuid (uid_t uid) &tok_usersid, sizeof tok_usersid, &siz)) { debug_printf ("GetTokenInformation(): %E"); - tok_usersid = NO_SID; + tok_usersid = NO_SID; } if (!GetTokenInformation (cygheap->user.token, TokenPrimaryGroup, &tok_pgrpsid, sizeof tok_pgrpsid, &siz)) @@ -2119,7 +2119,7 @@ seteuid (uid_t uid) /* Check for pgrp only if current token is an internal token. Otherwise the external provided token is very likely overwritten here. */ - (current_token_is_internal_token && + (current_token_is_internal_token && pgrpsid && tok_pgrpsid && pgrpsid != tok_pgrpsid)) { /* If not, RevertToSelf and close old token. */ @@ -2143,19 +2143,19 @@ seteuid (uid_t uid) if (ptok != INVALID_HANDLE_VALUE) explicitely_created_token = TRUE; else - { + { /* create_token failed. Try subauthentication. */ debug_printf ("create token failed, try subauthentication."); ptok = subauth (pw_new); } if (ptok != INVALID_HANDLE_VALUE) - { + { cygwin_set_impersonation_token (ptok); /* If sav_token was internally created, destroy it. */ if (sav_token != INVALID_HANDLE_VALUE && current_token_is_internal_token) CloseHandle (sav_token); - } + } else if (sav_token != INVALID_HANDLE_VALUE) cygheap->user.token = sav_token; } @@ -2168,9 +2168,9 @@ seteuid (uid_t uid) RevertToSelf (); /* If the token was explicitely created, all information has - already been set correctly. */ + already been set correctly. */ if (!explicitely_created_token) - { + { /* Try setting owner to same value as user. */ if (usersid && !SetTokenInformation (cygheap->user.token, TokenOwner, @@ -2186,7 +2186,7 @@ seteuid (uid_t uid) debug_printf ("SetTokenInformation(user.token, " "TokenPrimaryGroup): %E"); - } + } /* Now try to impersonate. */ if (!LookupAccountSid (NULL, usersid, username, &ulen, @@ -2196,11 +2196,11 @@ seteuid (uid_t uid) system_printf ("Impersonating (%d) in set(e)uid failed: %E", cygheap->user.token); else - { + { cygheap->user.impersonated = TRUE; setenv ("USERNAME", username, 1); setenv ("USERDOMAIN", domain, 1); - } + } } } @@ -2253,7 +2253,7 @@ setegid (gid_t gid) HANDLE ptok; if (gsid.getfromgr (gr)) - { + { if (!OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_DEFAULT, &ptok)) @@ -2261,12 +2261,12 @@ setegid (gid_t gid) else { if (!SetTokenInformation (ptok, TokenPrimaryGroup, - &gsid, sizeof gsid)) + &gsid, sizeof gsid)) debug_printf ("SetTokenInformation(myself, " "TokenPrimaryGroup): %E"); CloseHandle (ptok); } - } + } } } } diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 5ffb03789..7a608eb67 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -61,20 +61,20 @@ sysconf (int in) /*FALLTHRU*/ case _SC_PHYS_PAGES: case _SC_AVPHYS_PAGES: - { + { NTSTATUS ret; SYSTEM_BASIC_INFORMATION sbi; - if ((ret = NtQuerySystemInformation (SystemBasicInformation, + if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi, sizeof sbi, NULL)) != STATUS_SUCCESS) - { - __seterrno_from_win_error (RtlNtStatusToDosError (ret)); - debug_printf("NtQuerySystemInformation: ret = %d, " - "Dos(ret) = %d", - ret, RtlNtStatusToDosError (ret)); + { + __seterrno_from_win_error (RtlNtStatusToDosError (ret)); + debug_printf("NtQuerySystemInformation: ret = %d, " + "Dos(ret) = %d", + ret, RtlNtStatusToDosError (ret)); return -1; - } + } switch (in) { case _SC_NPROCESSORS_CONF: diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index 860cc55b4..f75bc2a0e 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -102,11 +102,11 @@ settimeofday (const struct timeval *tv, const struct timezone *tz) tz = tz; /* silence warning about unused variable */ ptm = gmtime(&tv->tv_sec); - st.wYear = ptm->tm_year + 1900; - st.wMonth = ptm->tm_mon + 1; + st.wYear = ptm->tm_year + 1900; + st.wMonth = ptm->tm_mon + 1; st.wDayOfWeek = ptm->tm_wday; - st.wDay = ptm->tm_mday; - st.wHour = ptm->tm_hour; + st.wDay = ptm->tm_mday; + st.wHour = ptm->tm_hour; st.wMinute = ptm->tm_min; st.wSecond = ptm->tm_sec; st.wMilliseconds = tv->tv_usec / 1000; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 969e18d97..aa12d4684 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -63,13 +63,13 @@ internal_getlogin (cygheap_user &user) sys_wcstombs (buf, wui->wkui1_username, UNLEN + 1); user.set_name (buf); sys_wcstombs (buf, wui->wkui1_logon_server, - INTERNET_MAX_HOST_NAME_LENGTH + 1); + INTERNET_MAX_HOST_NAME_LENGTH + 1); user.set_logsrv (buf); sys_wcstombs (buf, wui->wkui1_logon_domain, INTERNET_MAX_HOST_NAME_LENGTH + 1); user.set_domain (buf); NetApiBufferFree (wui); - } + } if (!user.logsrv () && get_logon_server_and_user_domain (buf, NULL)) { user.set_logsrv (buf + 2); @@ -84,7 +84,7 @@ internal_getlogin (cygheap_user &user) sys_mbstowcs (wuser, user.name (), UNLEN + 1); wlogsrv[0] = '\0'; if (user.logsrv ()) - { + { strcat (strcpy (buf, "\\\\"), user.logsrv ()); sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3); } @@ -128,7 +128,7 @@ internal_getlogin (cygheap_user &user) in a process token of a currently impersonated process. */ if (ptok == INVALID_HANDLE_VALUE && !OpenProcessToken (GetCurrentProcess (), - TOKEN_ADJUST_DEFAULT | TOKEN_QUERY, + TOKEN_ADJUST_DEFAULT | TOKEN_QUERY, &ptok)) debug_printf ("OpenProcessToken(): %E\n"); else if (!GetTokenInformation (ptok, TokenUser, &tu, sizeof tu, &siz)) @@ -188,7 +188,7 @@ internal_getlogin (cygheap_user &user) if (!SetTokenInformation (ptok, TokenOwner, &tu, sizeof tu)) debug_printf ("SetTokenInformation(TokenOwner): %E"); if (gsid && !SetTokenInformation (ptok, TokenPrimaryGroup, - &gsid, sizeof gsid)) + &gsid, sizeof gsid)) debug_printf ("SetTokenInformation(TokenPrimaryGroup): %E"); } diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc index b930a875e..2e709d244 100644 --- a/winsup/cygwin/uname.cc +++ b/winsup/cygwin/uname.cc @@ -61,7 +61,7 @@ uname (struct utsname *name) else ptype = sysinfo.dwProcessorType; - __small_sprintf (name->machine, "i%d86", ptype); + __small_sprintf (name->machine, "i%d86", ptype); break; case PROCESSOR_ARCHITECTURE_ALPHA: strcpy (name->machine, "alpha");