diff options
Diffstat (limited to 'winsup/cygserver')
35 files changed, 0 insertions, 15664 deletions
diff --git a/winsup/cygserver/ChangeLog b/winsup/cygserver/ChangeLog deleted file mode 100644 index 0b08894d2..000000000 --- a/winsup/cygserver/ChangeLog +++ /dev/null @@ -1,804 +0,0 @@ -2014-11-06 Florian Friesdorf <flo@chaoflow.net> - - * cygserver-config: Add -N option to allow different service name. - -2014-08-15 Corinna Vinschen <corinna@vinschen.de> - - * configure.ac: Convert to new AC_INIT style. - * configure: Regenerate. - -2014-06-23 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (ipcexit_creat_hookthread): Delete shs in another error - case to make Coverity really happy (CID 59993). - -2014-06-23 Corinna Vinschen <corinna@vinschen.de> - - * client.cc: Throughout, fix debug output of signed byte count value. - -2014-05-19 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (msleep_sync_array::~msleep_sync_array): New destructor - to make Coverity happy (CID 59838). - -2014-05-19 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (ipcexit_creat_hookthread): Delete shs to make - Coverity happy (CID 59993). - * transport_pipes.cc (transport_layer_pipes::listen): Make listen_pipe - and connect_pipe statics to make Coverity happy (CID 60010/60011). - -2014-04-16 Corinna Vinschen <corinna@vinschen.de> - - * pwdgrp.cc (client_request_pwdgrp::pwd_serve): Add 1 to the message - length to account for the trailing NUL. - -2014-04-16 Corinna Vinschen <corinna@vinschen.de> - - * cygserver-config: Use numeric id 18 instead of "system" in chown. - -2014-04-07 Corinna Vinschen <corinna@vinschen.de> - - * process.cc (process::process): Only notice that signal_arrived is - NULL in debug output. - -2014-03-12 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (OBJS): Add pwdgrp.o. - * client.cc (client_request::handle_request): Handle - CYGSERVER_REQUEST_PWDGRP message. - * pwdgrp.cc: New file implementing CYGSERVER_REQUEST_PWDGRP. - -2014-03-12 Corinna Vinschen <corinna@vinschen.de> - - * Throughout, fix format specifiers in debug statements to accommodate - x86_64. - -2014-03-06 Corinna Vinschen <corinna@vinschen.de> - - * setpwd.cc (client_request_setpwd::serve): Use RtlSecureZeroMemory to - delete password from memory. - -2013-11-06 Christopher Faylor <me.cygwin2013@cgf.cx> - - * configure.ac: Detect windows headers/libs after we've figured out the - C compiler. - * configure: Regenerate. - * aclocal.m4: Regenerate. - -2013-04-23 Corinna Vinschen <corinna@vinschen.de> - - * Merge in cygwin-64bit-branch. See ChangeLog.64bit for details. - -2012-11-27 Christopher Faylor <me.cygwin2012@cgf.cx> - - * Makefile.in: Remove old from CFLAGS and move C*FLAGS so that they can - be manipulated by Makefile.common. - -2012-11-26 Christopher Faylor <me.cygwin2012@cgf.cx> - - * configure.ac: Rename from configure.in. - * configure.in: Delete. - * configure: Regenerate. - -2012-11-26 Corinna Vinschen <corinna@vinschen.de> - - * transport_pipes.cc (pipe_instance_lock_once): Remove. - (pipe_instance_lock): Remove. - (pipe_instance): Remove. - (initialise_pipe_instance_lock): Remove. - (transport_layer_pipes::accept): Drop entire pipe_instance handling. - (transport_layer_pipes::close): Ditto. - -2012-11-23 Corinna Vinschen <corinna@vinschen.de> - - * cygserver.cc (main): Call listen right after creating the - transport. - * transport_pipes.cc (transport_layer_pipes::listen): Create - first instance of the named pipe here. Connect the client side - to block it for further use by the system. - (transport_layer_pipes::accept): Don't handle first pipe instance - here. Change debug output accordingly. - -2012-11-23 Christopher Faylor <me.cygwin2012@cgf.cx> - - * Makefile.in: Use /bin/mkdir to make install directories. - -2012-11-23 Corinna Vinschen <corinna@vinschen.de> - - * sysv_sem.cc (semundo_clear): Move condition to break from - inner loop to the right spot. - -2012-11-12 Christopher Faylor <me.cygwin2012@cgf.cx> - - * Makefile.in: Revamp for new configury. - * configure.in: Revamp for new configury. - * aclocal.m4: Regenerate. - * configure: Ditto. - * autogen.sh: New script. - -2012-10-25 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (adjust_identity_info): Fix typo in log message. - -2012-07-19 Corinna Vinschen <corinna@vinschen.de> - - * woutsup.h: Just include winlean.h. - -2012-03-19 Christopher Faylor <me.cygwin2012@cgf.cx> - - * client.cc: Revert sigproc.h inclusion since it was fixed elsewhere. - -2012-03-19 Corinna Vinschen <corinna@vinschen.de> - - * client.cc: Include sigproc.h if __INSIDE_CYGWIN__ is defined. - -2012-03-19 Christopher Faylor <me.cygwin2012@cgf.cx> - - * client.cc: Remove unneeded #include "sigproc.h". - -2012-02-14 Corinna Vinschen <corinna@vinschen.de> - - * transport_pipes.cc (transport_layer_pipes::transport_layer_pipes): - Always use cygwin_internal to fetch installation key. - -2011-10-10 Corinna Vinschen <corinna@vinschen.de> - - * cygserver.cc (print_usage): Align output to utilities in utils - directory. - (print_version): Ditto. - -2011-08-18 Yaakov Selkowitz <yselkowitz@users.sourceforge.net> - - * sysv_shm.cc (ACCESSPERMS): Remove to fix redefined warning, as - this is now defined in <sys/stat.h>. - -2011-02-07 Corinna Vinschen <corinna@vinschen.de> - - * configure.in: Remove AC_ALLOCA test and test for __builtin_memset. - * configure: Regenerate. - -2010-04-19 Christopher Faylor <me+cygwin@cgf.cx> - - * transport_pipes.cc: Include ntdef.h to accommodate cygerrno.h. - -2009-11-16 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (cygserver.exe): Link with -static to avoid linking - against cygstdc++-6.dll due to references to __cxa_pure_virtual. - -2009-11-06 Corinna Vinschen <corinna@vinschen.de> - - * transport_pipes.cc (transport_layer_pipes::transport_layer_pipes): - Check cygwin_internal for returning 0 rather than for != 0. - (transport_layer_pipes::accept): Add debug output. - (transport_layer_pipes::connect): Ditto. - -2009-10-31 Corinna Vinschen <corinna@vinschen.de> - - * transport_pipes.h (PIPE_NAME_PREFIX): New define. - (PIPE_NAME_SUFFIX): Ditto. - (class transport_layer_pipes): Convert _pipe_name from char pointer - to wchar_t array. - * transport_pipes.cc (transport_layer_pipes::transport_layer_pipes): - Accommodate the fact that _pipe_name is a wchar_t array, rather than - a char pointer. - (transport_layer_pipes::transport_layer_pipes): Initialize _pipe_name - with variable pipe name based in installation key fetched from Cygwin - DLL. - (transport_layer_pipes::accept): Call CreateNamedPipeW explicitely. - (transport_layer_pipes::connect): Call CreateFileW and WaitNamedPipeW - explicitely. - -2009-08-18 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (CXXFLAGS): Allow override. - -2009-03-26 Yaakov Selkowitz <yselkowitz@cygwin.com> - - * README: Remove "How to use" section, as CYGWIN="server" is - no longer required. - -2009-03-20 Corinna Vinschen <corinna@vinschen.de> - - * cygserver-config: Remove misleading text describing the - "CYGWIN=server" setting for the client. - -2009-02-23 Sjors Gielen <mailinglist@dazjorz.com> - - * Makefile.in: Add DESTDIR functionality. - -2009-01-21 Corinna Vinschen <corinna@vinschen.de> - - * client.cc (allow_server): Remove variable. - (client_request_get_version::client_request_get_version): Drop checking - allow_server. - -2009-01-03 Christopher Faylor <me+cygwin@cgf.cx> - - * Makefile.in (CFLAGS): Look in cygwin's build directory for header - files. - -2008-12-15 Corinna Vinschen <corinna@vinschen.de> - - * setpwd.cc (client_request_setpwd::serve): Don't treat removing - non-existant private data as error. - -2008-12-15 Corinna Vinschen <corinna@vinschen.de> - - * setpwd.cc (client_request_setpwd::serve): Explicitely erase password - buffer content after usage. - -2008-11-26 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (OBJS): Add setpwd.o. - * README: Explain new service to store passwords in the LSA registry - area. - * bsd_helper.cc (get_token_info): Make externally available. - * bsd_helper.h (get_token_info): Declare. - * client.cc (client_request::handle_request): Add case for - CYGSERVER_REQUEST_SETPWD request. - * setpwd.cc: New file implementing the CYGSERVER_REQUEST_SETPWD - request. - -2008-10-30 Christopher Faylor <me+cygwin@cgf.cx> - - * Makefile.in: Use -static-libgcc when creating cygserver.exe. - -2008-04-30 Corinna Vinschen <corinna@vinschen.de> - - * sysv_msg.cc: Add fix from upstream version 1.65. - (msgsnd): Call msleep with timeout value. Handle EWOULDBLOCK. Make - sure it's clear from where msleep has been called in debug output. - (msgrcv): Make sure it's clear from where msleep has been called in - debug output. - -2008-02-06 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc: Replace %E __small_printf format specifier with %lu - and call to GetLastError throughout. - * bsd_mutex.cc: Ditto. - * sysv_sem.cc (semget): Replace %X __small_printf format specifier - with %llx. - -2008-02-06 Corinna Vinschen <corinna@vinschen.de> - - Remove dependency from Cygwin internal code. - * Makefile.in (CYGWIN_OBJS): Remove smallprint.o. - (cygserver.exe): Remove strfuncs.o - (strfuncs.o): Drop rule. - * bsd_log.cc (_vlog): Use snprintf/vsnprintf instead of - __small_sprintf/__small_vsprintf. - * sysv_sem.cc (seminit): Use sys_malloc instead of malloc. Use - snprintf instead of __small_sprintf. - (semunload): Free the above allocated sema_mtx names here. - -2008-02-03 Brian Dessent <brian@dessent.net> - - * Makefile.in: Don't link strfuncs.o from the Cygwin build dir. - Build it again with __OUTSIDE_CYGWIN__ defined. - -2007-11-05 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (tunable_params): Add kern.ipc.shm_allow_removed as - bool parameter. - * cygserver.conf: Add a description for the kern.ipc.shm_allow_removed - parameter. - * sysv_shm.cc (shminit): Set shm_allow_removed variable according to - kern.ipc.shm_allow_removed setting. - -2007-08-02 Corinna Vinschen <corinna@vinschen.de> - - * smallprint.c: Remove. - -2007-08-02 Christopher Faylor <me+cygwin@cgf.cx> - - * Makefile.in: Add -lntdll to link line. - (CYGWIN_OBJS): Include strfuncs.o. - -2007-08-02 Corinna Vinschen <corinna@vinschen.de> - - * smallprint.c: New file. - * Makefile.in (OBJS): Add smallprint.o. - (CYGWIN_OBJS): Remove smallprint.o from Cygwin dir. - -2007-07-21 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc: Drop unnecessary security.h include. - -2007-02-23 Corinna Vinschen <corinna@vinschen.de> - - Throughout remove using wincap. - * Makefile.in (OBJS): Remove wincap.o. - * README: Don't mention 9x. - * bsd_mutex.cc (_mtx_unlock): Drop checking for 9x error codes. - * cygserver.cc (server_submission_loop::request_loop): Add FIXME - comment. - * wincap.cc: Remove. - * wincap.h: Remove. - * woutsup.h: Don't include wincap.h. - -2007-02-22 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (OBJS): Drop transport_sockets.o. - * sysv_shm.cc (shmget_allocate_segment): Remove spurious cast. - * transport.cc: Don't include transport_sockets.h. - (create_server_transport): Always create transport_layer_pipes. - * transport_sockets.cc: Remove. - * transport_sockets.h: Remove. - -2006-05-24 Christopher Faylor <cgf@timesys.com> - - * configure.in: Update to newer autoconf. - (thanks to Steve Ellcey) - * configure: Regenerate. - * aclocal.m4: New file. - -2006-01-12 Corinna Vinschen <corinna@vinschen.de> - - * wincap.cc: New file. - * wincap.h: New file. - * Makefile.in: Accomodate having our own wincap implementation now. - -2006-01-09 Corinna Vinschen <corinna@vinschen.de> - - Check FreeBSD upstream changes and apply important patches. - * sysv_sem.cc (__semctl): Check copyin return value (from 1.76). - * sysv_shm.cc (shminit): Actually use the iterating variable in the - for loop when trying to avoid overflow (from 1.102). - -2005-11-10 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (securityinit): New function. Move initialization - of security related variables from ipcinit here. - * bsd_helper.h (securityinit): Add prototype. - * cygserver.cc (main): Call securityinit right after wincap.init. - -2005-11-10 Corinna Vinschen <corinna@vinschen.de> - - * bsd_log.cc (_vpanic): LOG_EMERG is overkill, use LOG_CRIT. - -2005-11-09 Corinna Vinschen <corinna@vinschen.de> - - * process.cc (process_cache::process): Fix maximum process condition. - -2005-10-24 Corinna Vinschen <corinna@vinschen.de> - - * README: Add description for new -p/--process-cache option. - * bsd_helper.cc (default_tun_check): Add kern.srv.process_cache_size - entry to tunable_params. Set max value of kern.srv.request_threads - to 310. - * cygserver.cc (SERVER_VERSION): Set to 1.20. - (print_usage): Print usage of new parameter -p. - (main): Add process cache parameter handling. Accomodate new max - value of request threads. - * cygserver.conf: Add kern.srv.process_cache_size tunable parameter. - Accomodate new max value of kern.srv.request_threads. - * process.cc: Fix a comment. - (process_cache::process_cache): Add max process cache size parameter. - Change _cache_add_trigger to manual reset event. - (struct pcache_wait_t): New struct used as parameter to - pcache_wait_thread. - (pcache_wait_thread): New thread function used for threaded process - cache. - (process_cache::wait_for_processes): Use threaded waiting if number - of processes to wait for is bigger than 62. Always check all processes - to avoid race under heavy load. - (process_cache::sync_wait_array): Remove useless assert. Reset - _cache_add_trigger right at the start since it's manual reset now. - Accomodate threaded waiting. - * process.h (process_cache::process_cache): Add max_procs parameter. - (process_cache::_max_process_count): New member. - (process_cache::_wait_array: Raise to allow up to 5 wait threads. - (process_cache::_process_array): Ditto. - -2005-08-08 Christopher Faylor <cgf@timesys.com> - - * cygserver.cc (main): Call wincap.init() earlier to avoid a NULL - dereference. - -2005-06-14 Corinna Vinschen <corinna@vinschen.de> - - * sysv_sem.cc (semu_list): Define static to avoid gcc 4.x compiler - warning. - -2005-04-08 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (msleep_cnt): Remove. - (msleep_max_cnt): Remove. - (msleep_arr): Remove. - (class msleep_sync_array): New class to encapsulate msleep/wakeup - thread synchronization. - (msleep_sync): New object pointer. - (msleep_init): Initialize new msleep_sync object. - (_mutex): Just call msleep_sync->enter() and msleep_sync->leave() for - thread synchronization. Improve debug output a bit more. - (wakeup): Just call msleep_sync->wakeup(). - (wakeup_all): Whitespace fix. - -2005-04-06 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (ipcexit_hookthread): Fix whitespace and handle leak. - * bsd_mutex.cc: Include stdlib.h, sys/msg.h and sys/sem.h. - (mtx_init): Initialize lock counter to 0. - (_mtx_lock): Increment and log mutex lock counter. - (mtx_owned): Add winpid argument. Return true only if mutex is - actually owned by process winpid. - (_mtx_assert): Add winpid argument accordingly. - (_mtx_unlock): Log owner and lock count. - (MSLEEP_MUTEX): Remove. - (MSLEEP_SEM): Ditto. - (MSLEEP_EVENT): Ditto. - (msleep_event_name): Ditto. - (msleep_cs): New global critical section. - (msleep_cnt): New global variable indicating msleep record usage. - (msleep_max_cnt): New global variable indicating msleep record size. - (msleep_arr): New global pointer to msleep records. - (msleep_init): Initialize msleep_cs. Allocate msleep_arr array. - (_msleep): Rewrite using new msleep_cs/msleep_arr based thread - synchronization. Don't be shy with debug output. - (wakeup): Rewrite using new msleep_cs/msleep_arr based thread - synchronization. - * bsd_mutex.h (struct mtx): Add lock counter for better debugging. - (mtx_owned): Declare with winpid argument. - (_mtx_assert): Ditto. - (mtx_assert): Define with winpid argument. - * cygserver.cc (version): Remove. - (SERVER_VERSION): New define, decoupling server version information - from source code control system. - (print_version): Simplify printing server version. - * process.cc (process::process): Fix wrong bracketing (and handle leak). - (process::~process): Only try to close _signal_arrived if valid. - * sysv_sem.cc: Include sys/smallprint.h. - (semundo_clear): Define with additional struct thread pointer argument. - Accomodate throughout. - (SEMUNDO_LOCKASSERT): Define with winpid argument. Accomodate - throughout. - (struct sem_undo): Define un_proc as pid_t on Cygwin. Accomodate - throughout. - (seminit): Improve debugging by adding the semid to the mutex name. - (semget): Correctly print key value as 64 bit hex value in debug - output. - (semexit_myhook): Remove Cygwin specific unlocking of mutexes owned - by exiting process. Keep semaphore global lock throughout whole - function to avoid races. - * sysv_shm.cc (GIANT_REQUIRED): Define empty on Cygwin. We know that - Giant is locked. - -2005-04-01 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (_msleep): Whitespace fix. - * process.cc (process::process): Handle invalid signal_arrived values - more gracefully. - -2004-12-30 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc: Include limits.h. - (MSLEEP_MUTEX): New define for third parameter to msleep_event_name. - (MSLEEP_SEM): Ditto. - (MSLEEP_EVENT): Ditto. - (msleep_event_name): Add third parameter to allow multiple - synchronization objects per ident. - (_msleep): Implement new synchronization technique to make sure - that all threads have been woken up by a corresponding wakeup call. - (wakeup): Ditto. - -2004-10-18 Corinna Vinschen <corinna@vinschen.de> - - * sysv_sem.cc: Redefine offsetof to circumvent build problems with - gcc 3.4. - -2004-10-04 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (_msleep): Simplify event creation. Revert change from - 2004-08-24. It should be unnecessary now. - * msg.cc (client_request_msg::serve): Release process critical - section as early as possible. - * sem.cc (client_request_sem::serve): Ditto. - * shm.cc (client_request_shm::serve): Ditto. - * process.cc: Use hold and release method calls instead of - EnterCriticalSection/LeaveCriticalSection calls throughout. - * process.h (_hold): Rename from hold. Take filename and linenumber - parameter for logging. Define matching hold macro. - (release): Ditto. - -2004-10-01 Corinna Vinschen <corinna@vinschen.de> - - * sysv_sem.cc: Update to FreeBSD version 1.69. - 1.68: Reduce the overhead of semop() by using the kernel stack - instead of malloc'd memory to store the operations array if it - is small enough to fit. - 1.69: Adjust the number of processes waiting on a semaphore properly - if we're woken up in the middle of sleeping. - -2004-09-23 Corinna Vinschen <corinna@vinschen.de> - - * sysv_shm.cc (kern_shmat): Avoid compiler warning. - -2004-09-21 Corinna Vinschen <corinna@vinschen.de> - - * sysv_shm.cc (vm_object_reference): remove Cygwin specific define. - (vm_map_find): Ditto. - (vm_map_inherit): Ditto. - (kern_shmat): On Cygwin, take shmaddr just as is. Don't call vm - system calls on Cygwin. Add comment. - -2004-09-15 Corinna Vinschen <corinna@vinschen.de> - - Fix copyright throughout. - Eliminate use of _impure_ptr outside Cygwin. - * bsd_helper.cc: Include errno.h instead of cygerrno.h. - * bsd_mutex.cc : Ditto. - * client.cc: Ditto. - * cygserver.cc: Ditto. - * process.cc: Don't build functions inside Cygwin. Don't include - cygerrno.h. Don't set errno. - * transport_pipes.cc (SET_ERRNO): New define. Use througout. - * transport_sockets.cc (SET_ERRNO): Ditto. - (GET_ERRNO): Ditto. - -2004-09-06 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (_msleep): Disable resetting event object for now. - -2004-08-31 Corinna Vinschen <corinna@vinschen.de> - - * sysv_shm.cc (kern_shmat): Add debug_printf's. - -2004-08-24 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (_msleep): Release process object while waiting. - -2004-08-03 Corinna Vinschen <corinna@vinschen.de> - - * transport.cc (transport_layer_base::~transport_layer_base): Resurrect. - * transport.h (transport_layer_base::~transport_layer_base): Ditto. - -2004-07-30 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (_msleep): Reset event object and close it before - entering mutex. Turn order of conditional for better readability. - -2004-07-26 Corinna Vinschen <corinna@vinschen.de> - - * cygserver.conf: Describe relation between shmmaxpgs and SHMMAX. - -2004-07-20 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc: Whitespace fixes. - * bsd_mutex.cc: Ditto. - -2004-07-19 Corinna Vinschen <corinna@vinschen.de> - - * transport.cc (transport_layer_base::~transport_layer_base): Remove. - * transport.h (transport_layer_base::~transport_layer_base): Ditto. - -2004-07-19 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (win_priority): Actually calculate p from priority. - -2004-06-03 Corinna Vinschen <corinna@vinschen.de> - - * shm.cc (shmget): Explicitely set td_retval[0] to -1 on error. - -2004-03-30 Corinna Vinschen <corinna@vinschen.de> - - * sysv_shm.cc (shmget): Allow to retrieve shared memory segments - by shmid when IPC_KEY_IS_SHMID is set. - -2004-03-02 Corinna Vinschen <corinna@vinschen.de> - - * sysv_sem.cc (semundo_adjust): Check for process id instead of - process struct pointer, which isn't fixed under Cygwin. - (semexit_myhook): Ditto. Adjust debug print statements to print - Cygwin and Windows PIDs instead of process pointer under Cygwin. - -2004-02-07 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (win_priority): Move to msleep helper function section. - (set_priority): Ditto. Fix formatting. - (_msleep): Cleanup obj formatting. Rearrange obj order. - -2004-02-06 Corinna Vinschen <corinna@vinschen.de> - - * bsd_mutex.cc (_msleep): Handle PCATCH using signal_arrived event. - * client.cc: Include sigproc.h. - * msg.cc (client_request_msg::serve): Accomodate third parameter to - process::process. - * sem.cc (client_request_sem::serve): Ditto. - * shm.cc (client_request_shm::serve): Ditto. - * process.cc (process::process): Duplicate signal_arrived into - Cygserver process space. - (process::~process): Close _signal_arrived handle. - (process_cache::process): Add signal_arrived handling. - * process.h (process::process): Add signal_arrived parameter. - (process:signal_arrived): New read accessor. - (process:_signal_arrived): New member. - (process_cache::process): Add signal_arrived parameter. - -2004-01-16 Corinna Vinschen <corinna@vinschen.de> - - * process.h (cleanup_routine::~cleanup_routine): Make pure virtual - function to avoid miscompilation with certain versions of gcc. - * process.cc (cleanup_routine::~cleanup_routine): Remove. - -2003-12-26 Christopher Faylor <cgf@redhat.com> - - * Makefile.in (CFLAGS, CXXFLAGS): Remove unneeded include. - (CYGWIN_LIB): Delete. - (cygserver.exe target): Add -L$(cygwin_build) to the link line to force - linker to use build tree version of the library. Remove specific - inclusion of libcygwin.a from the link line. - -2003-12-16 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (tunable_params): Add entries for kern.ipc.msgmnb and - kern.ipc.msgtql. Raise max value for kern.ipc.msgseg to 65535. - * cygserver.conf: Add kern.ipc.msgmnb and kern.ipc.msgtql. - * sysv_msg.cc (msginit): Add TUNABLE_INT_FETCH call for - kern.ipc.msgmnb and kern.ipc.msgtql. - -2003-11-26 Corinna Vinschen <corinna@vinschen.de> - - * cygserver.cc (main): Move call to ipcinit() up before installing - any threads. - * sysv_sem.cc: Update to FreeBSD version 1.67. - (seminit): Initialize semaphore sequence numbers to 0. - -2003-11-26 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (CYGWIN_LIB): Variable pointing to libcygwin.a in - the parallel cygwin dir. - (cygserver.exe): Depend on and link against $CYGWIN_LIB. - -2003-11-25 Christopher Faylor <cgf@redhat.com> - - * Makefile.in (CXXFLAGS): Remove duplicate options handled in - Makefile.common. - -2003-11-22 Corinna Vinschen <corinna@vinschen.de> - - * msg.cc (client_request_msg::serve): Add default case to msgop switch. - * sem.cc (client_request_sem::serve): Add default case to semop switch. - * shm.cc (client_request_shm::serve): Add default case to shmop switch. - -2003-11-21 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (install): Explicitely create directories. Install - README to $(prefix)/share/doc/Cygwin. - * README: New file. - -2003-11-21 Corinna Vinschen <corinna@vinschen.de> - - * cygserver.cc (print_usage): Fix scrambled output. - -2003-11-20 Corinna Vinschen <corinna@vinschen.de> - - * cygserver-config: Slightly modify printed message. - -2003-11-20 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (install): Install cygserver-config script to bindir. - * cygserver-config: New script. - -2003-11-19 Corinna Vinschen <corinna@vinschen.de> - - Don't use safe_new but new throughout. Fix copyright dates - throughout. - * Makefile.in: Accomodate all new files and name changes. - Add a *.d dependency. - (sbindir): Add. - (etcdir): Drop in favor of more appropriate sysconfdir definition. - (sysconfdir): Add. - (CXXFLAGS): Add -MMD flag. Add SYSCONFDIR definition. - (.SUFFIXES): Add. - (install): Add action items. - (libclean): New target. - (fullclean): Ditto. - * bsd_helper.cc: New file. - * bsd_helper.h: Ditto. - * bsd_log.cc: Ditto. - * bsd_log.h: Ditto. - * bsd_mutex.cc: Ditto. - * bsd_mutex.h: Ditto. - * client.cc: Rearrange to build as less as possible if - __INSIDE_CYGWIN__. - (client_request::handle_request): Add Message Queue and Semaphore - handling. - * cygserver.cc: Rearrange to build as less as possible if - __INSIDE_CYGWIN__. Use new debug/log/panic logging functions. - (DEF_CONFIG_FILE): New definition for configuration file. Use - throughout. - (getfunc): Remove. - (__cygserver__printf): Remove. - (client_request_attach_tty::serve): Return error if impersonation - fails. - (print_usage): Pump up help message. - (print_version): Add output of default configuration file. - (main): Accommodate new options. Allow overwrite of threading options - from config file. Call several new initialization functions. Drop - printing dots. Don't define SIGHANDLE inline. - * cygserver.conf: New file. - * cygserver_process.h: Rename to process.h. - * cygserver_transport.h: Rename to transport.h. - * cygserver_transport_pipes.h: Rename to transport_pipes.h. - * cygserver_transport_sockets.h: Rename to transport_sockets.h. - * msg.cc: Rewrite. - * sem.cc: Rewrite. - * shm.cc: Rewrite. - * sysv_msg.cc: New file, derived from FreeBSD version 1.52. - * sysv_sem.cc: New file, derived from FreeBSD version 1.66. - * sysv_shm.cc: New file, derived from FreeBSD version 1.89. - * threaded_queue.cc: Rearrange to build as less as possible if - __INSIDE_CYGWIN__. - * transport.cc (transport_layer_base::impersonate_client): Define bool. - (transport_layer_base::revert_to_self): Ditto. - * transport.h (transport_layer_base::impersonate_client): Declare bool. - (transport_layer_base::revert_to_self): Ditto. - * transport_pipes.cc (transport_layer_pipes::transport_layer_pipes): - Don't call init_security. - (init_security): Remove. - (transport_layer_pipes::accept): Use global sec_all_nih. - (transport_layer_pipes::connect): Ditto. - (transport_layer_pipes::impersonate_client): Define bool. - (transport_layer_pipes::revert_to_self): Ditt. - * transport_pipes.h (transport_layer_pipes::impersonate_client): Declare - bool. - (transport_layer_pipes::revert_to_self): Ditto. - * woutsup.h: Include bsd compatibility headers. - (SIGHANDLE): Add definition. - (__cygserver__printf): Remove definition. - (__noop_printf): Ditto. - (debug_printf): Define using debug. - (syscall_printf): Define using log. - (system_printf): Ditto. - Drop all other _printf definitions. - -2003-10-22 Corinna Vinschen <corinna@vinschen.de> - - Accomodate moving cygserver header files from cygwin/include/cygwin - to here and cygwin dir. - * Makefile.in (EXEEXT): Drop as unused. - (EXEEXT_FOR_BUILD): Ditto. - (all): Don't build libcygserver.a. - * cygserver_process.h: Moved from cygwin/include/cygwin to here. - * cygserver_transport.h: Ditto. - * cygserver_transport_pipes.h: Ditto. - * cygserver_transport_sockets.h: Ditto. - * ipc.h: Moved to ../cygwin and renamed to cygserver_ipc.h. - * shm.h: Moved to ../cygwin and renamed to cygserver_shm.h. - -2003-08-30 Christopher Faylor <cgf@redhat.com> - - * msg.cc: New file. - * sem.cc: Ditto. - -2003-08-30 Christopher Faylor <cgf@redhat.com> - - * threaded_queue.h: New file. - -2003-08-25 Christopher Faylor <cgf@redhat.com> - - * Makefile.in: Build libcygserver.a. - * client.cc: Rename allow_daemon to allow_server. - -2003-07-25 Christopher Faylor <cgf@redhat.com> - - * configure.in: Use 'install-sh -c'. - * configure: Regenerate. - -2003-07-25 Christopher Faylor <cgf@redhat.com> - - * configure.in: Always use install-sh. - * configure: Regenerate. - -2003-07-01 Christopher Faylor <cgf@redhat.com> - - * Makefile.in (OBJS): Move some more files from cygwin directory. - * woutsup.h: Define _MT_SAFE. - -2003-07-01 Christopher Faylor <cgf@redhat.com> - - * configure.in: First pass. - * Makefile.in: Ditto. - * configure: Generate. diff --git a/winsup/cygserver/ChangeLog.64bit b/winsup/cygserver/ChangeLog.64bit deleted file mode 100644 index 7ab21bf54..000000000 --- a/winsup/cygserver/ChangeLog.64bit +++ /dev/null @@ -1,87 +0,0 @@ -2013-03-07 Corinna Vinschen <corinna@vinschen.de> - - * msg.cc (client_request_msg::serve): Revert change to refuse 64 bit - processes on 32 bit systems. - * sem.cc (client_request_sem::serve): Ditto. - * shm.cc (client_request_shm::serve): Ditto. - -2013-03-01 Corinna Vinschen <corinna@vinschen.de> - - * client.cc: Revert changes to handle 32 bit processes on 64 bit - systems. - * sysv_msg.cc: Ditto. - * sysv_sem.cc: Ditto. - * sysv_shm.cc: Ditto. - -2013-02-13 Corinna Vinschen <corinna@vinschen.de> - - * Makefile.in (cygserver.exe): Make cygwin_build a tooldir (-B instead - of -L) to support bootstrapping. - -2013-02-09 Corinna Vinschen <corinna@vinschen.de> - - * configure: Regenerate to fix wrong ac_unique_file dependency. - -2012-12-06 Corinna Vinschen <corinna@vinschen.de> - - * sysv_msg.cc (conv_timespec32_to_timespec): Move implementation to - cygserver_ipc.h. - (conv_timespec_to_timespec32): Ditto. - (conv_msqid_ds32_to_msqid_ds): Drop and move code into copyin_msqid_ds. - (conv_msqid_ds_to_msqid_ds32): Drop and move code into copyout_msqid_ds. - * sysv_sem.cc (copyin_semid_ds): New inline function on Cygwin. - (copyout_semid_ds): Ditto. - (__semctl): Use a conditional arg_size value rather than a fixed - sizeof(real_arg) throughout, to accommodate 64/32 bit conversion. - Use copyout_semid_ds and copyin_semid_ds to copy semid_ds - structures from cygserver to client and vice versa on Cygwin. - * sysv_shm.cc (copyin_shmid_ds): New inline function on Cygwin. - (copyout_shmid_ds): Ditto. - (shmctl): Use copyout_shmid_ds and copyin_shmid_ds to copy shmid_ds - structures from cygserver to client and vice versa on Cygwin. - -2012-12-05 Corinna Vinschen <corinna@vinschen.de> - - * client.cc (client_request::header_t::header_t): Accommodate changes - to msglen member. - (client_request::handle_request): Ditto. - (client_request::client_request): Zero out entire parameter block. - Explain why. - * sysv_msg.cc (conv_timespec32_to_timespec): New inline function on - 64 bit Cygwin. - (conv_timespec_to_timespec32): Ditto. - (conv_msqid_ds32_to_msqid_ds): Ditto. - (conv_msqid_ds_to_msqid_ds32): Ditto. - (copyin_msqid_ds): New inline function on Cygwin. - (copyout_msqid_ds): Ditto. - (msgctl): Use copyout_msqid_ds and copyin_msqid_ds to copy msqid_ds - structures from cygserver to client and vice versa on Cygwin. - (msgsnd): Special case copyin of msg_type on 64 bit Cygwin. - (msgrcv): Special case copyout of msg_type on 64 bit Cygwin. - -2012-12-04 Corinna Vinschen <corinna@vinschen.de> - - * bsd_helper.cc (tunable_int_fetch): Convert 2nd parameter to - int32_t. - * bsd_helper.h (tunable_int_fetch): Fix declaration accordingly. - * bsd_log.cc (log_level): Change type to int32_t. - * bsd_log.h (log_level): Fix declaration accordingly. - * bsd_mutex.cc (msgmni): Change type to int32_t. - (semmni): Ditto. - * cygserver.cc: Fix debug output to be target agnostic. Use same - style throughout. - * msg.cc (client_request_msg::serve): Refuse to serve 64 bit processes - from 32 bit cygserver. - * sem.cc (client_request_sem::serve): Ditto. - * shm.cc (client_request_shm::serve): Ditto. - * sysv_shm.cc (shm_delete_mapping): Mark size as unused to make gcc - happy. - (kern_shmat): Ditto with flags. - * process.h (class process): Change type of _cleaning_up member to LONG. - * threaded_queue.h (class threaded_queue): Ditto for _workers_count. - -2012-08-14 Corinna Vinschen <corinna@vinschen.de> - - * configure.in: Add AC_NO_EXECUTABLES to allow bootstrap. - * configure: Regenerate. - diff --git a/winsup/cygserver/Makefile.in b/winsup/cygserver/Makefile.in deleted file mode 100644 index 816f5b3db..000000000 --- a/winsup/cygserver/Makefile.in +++ /dev/null @@ -1,94 +0,0 @@ -# Makefile for Cygwin server -# Copyright 2003, 2006, 2007, 2008, 2009, 2014 Red Hat, Inc. - -# This file is part of Cygwin. - -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. - -srcdir:=@srcdir@ -target_builddir:=@target_builddir@ -winsup_srcdir:=@winsup_srcdir@ -configure_args=@configure_args@ - -export CC:=@CC@ -export CXX:=@CXX@ - -CFLAGS:=@CFLAGS@ -override CXXFLAGS=@CXXFLAGS@ -override CXXFLAGS+=-MMD -D__OUTSIDE_CYGWIN__ -DSYSCONFDIR="\"$(sysconfdir)\"" - -include ${srcdir}/../Makefile.common - -cygwin_build:=${target_builddir}/winsup/cygwin - -# environment variables used by ccwrap -export CCWRAP_HEADERS:=$(dir ${srcdir})/cygwin ${cygwin_build} -export CCWRAP_SYSTEM_HEADERS:=@cygwin_headers@ @newlib_headers@ -export CCWRAP_DIRAFTER_HEADERS:=@windows_headers@ - -DESTDIR= -prefix:=${DESTDIR}@prefix@ -exec_prefix:=${DESTDIR}@exec_prefix@ -bindir:=${DESTDIR}@bindir@ -sbindir:=${DESTDIR}@sbindir@ -sysconfdir:=${DESTDIR}@sysconfdir@ -program_transform_name:=@program_transform_name@ - -INSTALL:=@INSTALL@ -INSTALL_PROGRAM:=@INSTALL_PROGRAM@ -INSTALL_DATA:=@INSTALL_DATA@ - -AR:=@AR@ - - -OBJS:= cygserver.o client.o process.o msg.o sem.o shm.o threaded_queue.o \ - transport.o transport_pipes.o \ - bsd_helper.o bsd_log.o bsd_mutex.o \ - sysv_msg.o sysv_sem.o sysv_shm.o setpwd.o pwdgrp.o -LIBOBJS:=${patsubst %.o,lib%.o,$(OBJS)} - -CYGWIN_OBJS:=$(cygwin_build)/version.o - -CYGWIN_LIB:=$(cygwin_build)/libcygwin.a - -all: cygserver.exe - -install: all cygserver.conf cygserver-config README - /bin/mkdir -p $(DESTDIR)$(sbindir) $(DESTDIR)$(bindir) $(DESTDIR)$(sysconfdir)/defaults/etc $(DESTDIR)$(prefix)/share/doc/Cygwin - $(INSTALL_PROGRAM) cygserver.exe $(DESTDIR)$(sbindir)/cygserver.exe - $(INSTALL_PROGRAM) $(srcdir)/cygserver-config $(DESTDIR)$(bindir)/cygserver-config - $(INSTALL_DATA) $(srcdir)/cygserver.conf $(DESTDIR)$(sysconfdir)/defaults/etc/cygserver.conf - $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(prefix)/share/doc/Cygwin/cygserver.README - -clean: - rm -f $(OBJS) ${patsubst %.o,%.d,$(OBJS)} cygserver.exe - -libclean: - rm -f $(LIBOBJS) ${patsubst %.o,%.d,$(LIBOBJS)} libcygserver.a - -fullclean: clean libclean - -cygserver.exe: $(CYGWIN_LIB) $(OBJS) $(CYGWIN_OBJS) - $(CXX) -o $@ ${wordlist 2,999,$^} -static -static-libgcc -B$(cygwin_build) -lntdll - -$(cygwin_build)/%.o: $(cygwin_source)/%.cc - @$(MAKE) -C $(@D) $(@F) - -$(cygwin_build)/%.o: $(cygwin_source)/%.c - @$(MAKE) -C $(@D) $(@F) - -Makefile: Makefile.in configure - ./config.status - -lib%.o: %.cc - ${filter-out -D__OUTSIDE_CYGWIN__, $(COMPILE.cc)} -c -o $(@D)/${basename $(@F)}.o $< - -libcygserver.a: $(LIBOBJS) - $(AR) crus $@ $? - -deps:=${wildcard *.d} -ifneq (,$(deps)) -include $(deps) -endif diff --git a/winsup/cygserver/README b/winsup/cygserver/README deleted file mode 100644 index b667cb08a..000000000 --- a/winsup/cygserver/README +++ /dev/null @@ -1,198 +0,0 @@ -What is Cygserver? - - Cygserver is a program which is designed to run as a background service. - It provides Cygwin applications with services which require security - arbitration or which need to persist while no other cygwin application - is running. - - The implemented services so far are: - - - Control slave tty/pty handle dispersal from tty owner to other - processes without compromising the owner processes' security. - - XSI IPC Message Queues. - - XSI IPC Semaphores. - - XSI IPC Shared Memory. - - Allows non-privileged users to store obfuscated passwords in the - registry to be used for setuid(2) to create user tokens with network - credentials. This service is used by `passwd -R'. Using the stored - passwords in setuid(2) does not require running cygserver. The - registry storage is the same as Windows uses to store passwords for - accounts running Windows services. - - -Cygserver command line options: - - Options to Cygserver take the normal UNIX-style `-X' or `--longoption' form. - Nearly all options have a counterpart in the configuration file (see below) - so setting them on the command line isn't really necessary. Command line - options override settings from the Cygserver configuration file. - - The one-character options are prepended by a single dash, the long variants - are prepended with two dashes. Arguments to options are marked in angle - brackets below. These are not part of the actual syntax but are used only to - denote the arguments. Note that all arguments are required. Cygserver - has no options with optional arguments. - - The options recognized are: - - -f, --config-file <file> - - Use <file> as configuration file instead of the default configuration - line. The default configuration file is /etc/cygserver.conf, typically. - The --help and --version options will print the default configuration - pathname. - - This option has no counterpart in the configuration file, for obvious - reasons. - - -c, --cleanup-threads <num> - - Number of threads started to perform cleanup tasks. Default is 2. - Configuration file option: kern.srv.cleanup_threads - - -r, --request-threads <num> - - Number of threads started to serve application requests. Default is 10. - The -c and -r options can be used to play with Cygserver's performance - under heavy load conditions or on slow machines. - Configuration file option: kern.srv.request_threads - - -p, --process-cache <num> - - Number of processes which can connect concurrently to cygserver. - Default is 62. Each process connected to cygserver is a synchronization - object which has to be maintained. The data structure to maintain these - processes is the so-called "process cache". In theory, an arbitrary - number of processes could connect to cygserver, but due to the need to - synchronize, the higher the number of connected processes, the more - synchronization overhead exists. By using this option, you can set an - upper limit to the synchronization effort. If more than 62 processes - try to connect to cygserver concurrently, two additional synchronization - threads are necessary, and one for each further 62 concurrent - processes. So, useful values for the --process-cache option are 62, 124, - 186, 248, 310. 310 is the maximum value. - Configuration file option: kern.srv.process_cache_size - - NOTE: The number of child processes of a single parent process is limited - to 256. So in case of taking advantage of a process cache size beyond 256, - keep in mind that not all of these processes can be child processes of one - single parent process. - - -d, --debug - - Log debug messages to stderr. These will clutter your stderr output with - a lot of information, typically only useful to developers. - - -e, --stderr - - Force logging to stderr. This is the default if stderr is connected to - a tty. Otherwise, the default is logging to the system log. By using - the -e, -E, -y, -Y options (or the appropriate settings in the - configuration file), you can explicitely set the logging output as you - like, even to both, stderr and syslog. - Configuration file option: kern.log.stderr - - -E, --no-stderr - - Don't log to stderr. Configuration file option: kern.log.stderr - - -y, --syslog - - Force logging to the system log. This is the default, if stderr is not - connected to a tty, e. g. redirected to a file. - - -Y, --no-syslog - - Don't log to syslog. Configuration file option: kern.log.syslog - - -l, --log-level <level> - - Set the verbosity level of the logging output. Valid values are between - 1 and 7. The default level is 6, which is relatively chatty. If you set - it to 1, you will get only messages which are printed under severe conditions, - which will result in stopping Cygserver itself. - Configuration file option: kern.log.level - - -m, --no-sharedmem - - Don't start XSI IPC Shared Memory support. If you don't need XSI IPC - Shared Memory support, you can switch it off here. - Configuration file option: kern.srv.sharedmem - - -q, --no-msgqueues - - Don't start XSI IPC Message Queues. - Configuration file option: kern.srv.msgqueues - - -s, --no-semaphores - - Don't start XSI IPC Semaphores. - Configuration file option: kern.srv.semaphores - - -S, --shutdown - - Shutdown a running daemon and exit. Other methods are sending a SIGHUP - to the Cygserver PID or, if running as service under NT, calling - `net stop cygserver' or `cygrunsrv -E cygserver'. - - -h, --help - - Output usage information and exit. - - -v, --version - - Output version information and exit. - - -How to start Cygserver: - - Before you run Cygserver for the first time, you should run the - /usr/bin/cygserver-config script once. It creates the default - configuration file and, upon request, installs Cygserver as service - when running under NT. The script only performs a default install, - with no further options given to Cygserver when running as service. - Due to the wide configurability by changing the configuration file, - that's typically not necessary. - - It's best practice to run Cygserver as a service under LocalSystem - account. This is the way it is installed for you by the - /usr/bin/cygserver-config script. - - -The Cygserver configuration file: - - Cygserver has many options, which allow to customize the server - to your needs. Customization is accomplished by editing the configuration - file, which is by default /etc/cygserver.conf. This file is read only - once on startup of Cygserver. There's no option to re-read the file on - runtime by, say, sending a signal to Cygserver. - - The configuration file determines how Cygserver operates. There are - options which set the number of threads running in parallel, options - for setting how and what to log and options to set various maximum - values for the IPC services. - - The default configuration file delivered with Cygserver is installed - to /etc/defaults/etc. The /usr/bin/cygserver-config script copies it to - /etc, giving you the option to overwrite an already existing file or to - leave it alone. Therefore, the /etc file is safe to be changed by you, - since it will not be overwritten by a later update installation. - - The default configuration file contains many comments which describe - everything needed to understand the settings. A comment at the start of the - file describes the syntax rules for the file. The default options are shown - in the file but are commented out. - - It is generally a good idea to uncomment only options which you intend to - change from the default values. Since reading the options file on Cygserver - startup doesn't take much time, it's also considered good practice to keep - all other comments in the file. This keeps you from searching for clues - in other sources. - - -If you have problems with Cygserver, or you have found a bug, or you -think you have found a bug, or you don't understand configuration file -options, the mailing list <cygwin@cygwin.com> is the right place to ask -questions. - -Have fun! diff --git a/winsup/cygserver/aclocal.m4 b/winsup/cygserver/aclocal.m4 deleted file mode 100644 index 5bf14e574..000000000 --- a/winsup/cygserver/aclocal.m4 +++ /dev/null @@ -1,98 +0,0 @@ -# generated automatically by aclocal 1.11.6 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, -# Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -dnl This provides configure definitions used by all the cygwin -dnl configure.in files. - -AC_DEFUN([AC_WINDOWS_HEADERS],[ -AC_ARG_WITH( - [windows-headers], - [AS_HELP_STRING([--with-windows-headers=DIR], - [specify where the windows includes are located])], - [test -z "$withval" && AC_MSG_ERROR([must specify value for --with-windows-headers])] -) -]) - -AC_DEFUN([AC_WINDOWS_LIBS],[ -AC_ARG_WITH( - [windows-libs], - [AS_HELP_STRING([--with-windows-libs=DIR], - [specify where the windows libraries are located])], - [test -z "$withval" && AC_MSG_ERROR([must specify value for --with-windows-libs])] -) -windows_libdir=$(realdirpath "$with_windows_libs") -if test -z "$windows_libdir"; then - windows_libdir=$(realdirpath $(${ac_cv_prog_CC:-$CC} -xc /dev/null -Wl,--verbose=1 -lntdll 2>&1 | sed -rn 's%^.*\s(\S+)/libntdll\..*succeeded%\1%p')) - if test -z "$windows_libdir"; then - AC_MSG_ERROR([cannot find windows library files]) - fi -fi -AC_SUBST(windows_libdir) -] -) - -AC_DEFUN([AC_CYGWIN_INCLUDES], [ -addto_CPPFLAGS -nostdinc -: ${ac_cv_prog_CXX:=$CXX} -: ${ac_cv_prog_CC:=$CC} - -cygwin_headers=$(realdirpath "$winsup_srcdir/cygwin/include") -if test -z "$cygwin_headers"; then - AC_MSG_ERROR([cannot find $winsup_srcdir/cygwin/include directory]) -fi - -newlib_headers=$(realdirpath $winsup_srcdir/../newlib/libc/include) -if test -z "$newlib_headers"; then - AC_MSG_ERROR([cannot find newlib source directory: $winsup_srcdir/../newlib/libc/include]) -fi -newlib_headers="$target_builddir/newlib/targ-include $newlib_headers" - -if test -n "$with_windows_headers"; then - if test -e "$with_windows_headers/windef.h"; then - windows_headers="$with_windows_headers" - else - AC_MSG_ERROR([cannot find windef.h in specified --with-windows-headers path: $saw_windows_headers]); - fi -elif test -d "$winsup_srcdir/w32api/include/windef.h"; then - windows_headers="$winsup_srcdir/w32api/include" -else - windows_headers=$(cd $($ac_cv_prog_CC -xc /dev/null -E -include windef.h 2>/dev/null | sed -n 's%^# 1 "\([^"]*\)/windef\.h".*$%\1%p' | head -n1) 2>/dev/null && pwd) - if test -z "$windows_headers" -o ! -d "$windows_headers"; then - AC_MSG_ERROR([cannot find windows header files]) - fi -fi -CC=$ac_cv_prog_CC -CXX=$ac_cv_prog_CXX -export CC -export CXX -AC_SUBST(windows_headers) -AC_SUBST(newlib_headers) -AC_SUBST(cygwin_headers) -]) - -AC_DEFUN([AC_CONFIGURE_ARGS], [ -configure_args=X -for f in $ac_configure_args; do - case "$f" in - *--srcdir*) ;; - *) configure_args="$configure_args $f" ;; - esac -done -configure_args=$(/usr/bin/expr "$configure_args" : 'X \(.*\)') -AC_SUBST(configure_args) -]) - -AC_SUBST(target_builddir) -AC_SUBST(winsup_srcdir) - diff --git a/winsup/cygserver/autogen.sh b/winsup/cygserver/autogen.sh deleted file mode 100755 index 87a0d9c06..000000000 --- a/winsup/cygserver/autogen.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -e -/usr/bin/aclocal --acdir=.. -/usr/bin/autoconf -f -exec /bin/rm -rf autom4te.cache diff --git a/winsup/cygserver/bsd_helper.cc b/winsup/cygserver/bsd_helper.cc deleted file mode 100644 index 524817f1d..000000000 --- a/winsup/cygserver/bsd_helper.cc +++ /dev/null @@ -1,693 +0,0 @@ -/* bsd_helper.cc - - Copyright 2003, 2004, 2005, 2007, 2012, 2014 Red Hat Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#include <errno.h> -#define _KERNEL 1 -#define __BSD_VISIBLE 1 -#include <sys/smallprint.h> -#include <sys/cygwin.h> -#include <sys/ipc.h> -#include <sys/param.h> -#include <sys/msg.h> -#include <sys/queue.h> -#include <malloc.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> - -#include "cygserver.h" -#include "process.h" -#include "cygserver_ipc.h" -#include "cygserver_msg.h" -#include "cygserver_sem.h" -#include "cygserver_shm.h" - -/* - * Copy a piece of memory from the client process into the server process. - * Returns an error code. - */ -int -win_copyin (struct thread *td, const void *client_src, - void *server_tgt, size_t len) -{ - if (!ReadProcessMemory (td->client->handle (), client_src, server_tgt, - len, NULL)) - return cygwin_internal (CW_GET_ERRNO_FROM_WINERROR, - GetLastError (), EINVAL); - return 0; -} - -/* - * Copy a piece of memory from the server process into the client process. - * Returns an error code. - */ -int -win_copyout (struct thread *td, const void *server_src, - void *client_tgt, size_t len) -{ - if (!WriteProcessMemory (td->client->handle (), client_tgt, server_src, - len, NULL)) - return cygwin_internal (CW_GET_ERRNO_FROM_WINERROR, - GetLastError (), EINVAL); - return 0; -} - -#define enter_critical_section(c) _enter_critical_section((c),__FILE__,__LINE__) -static void -_enter_critical_section (LPCRITICAL_SECTION pcs, const char *file, int line) -{ - _log (file, line, LOG_DEBUG, "Try enter critical section(%p)", pcs); - EnterCriticalSection (pcs); - _log (file, line, LOG_DEBUG, "Entered critical section(%p)", pcs); -} - -#define leave_critical_section(c) _leave_critical_section((c),__FILE__,__LINE__) -static void -_leave_critical_section (LPCRITICAL_SECTION pcs, const char *file, int line) -{ - LeaveCriticalSection (pcs); - _log (file, line, LOG_DEBUG, "Left critical section(%p)", pcs); -} - -CRITICAL_SECTION ipcht_cs; - -struct ipc_hookthread_storage { - HANDLE process_hdl; - proc ipcblk; -}; - -struct ipc_hookthread { - SLIST_ENTRY (ipc_hookthread) sht_next; - HANDLE thread; - DWORD winpid; - struct vmspace vmspace; -}; -static SLIST_HEAD (, ipc_hookthread) ipcht_list; /* list of hook threads */ - -static HANDLE ipcexit_event; - -struct vmspace * -ipc_p_vmspace (struct proc *proc) -{ - struct vmspace *ret = NULL; - ipc_hookthread *ipcht_entry; - enter_critical_section (&ipcht_cs); - SLIST_FOREACH (ipcht_entry, &ipcht_list, sht_next) - { - if (ipcht_entry->winpid == proc->winpid) - { - ret = proc->p_vmspace = &ipcht_entry->vmspace; - break; - } - } - leave_critical_section (&ipcht_cs); - return ret; -} - -static DWORD WINAPI -ipcexit_hookthread (const LPVOID param) -{ - ipc_hookthread_storage *shs = (ipc_hookthread_storage *) param; - HANDLE obj[2] = { ipcexit_event, shs->process_hdl }; - switch (WaitForMultipleObjects (2, obj, FALSE, INFINITE)) - { - case WAIT_OBJECT_0: - /* Cygserver shutdown. */ - /*FALLTHRU*/ - case WAIT_OBJECT_0 + 1: - /* Process exited. Call semexit_myhook to handle SEM_UNDOs for the - exiting process and shmexit_myhook to keep track of shared - memory. */ - if (Giant.owner == shs->ipcblk.winpid) - mtx_unlock (&Giant); - if (support_semaphores == TUN_TRUE) - semexit_myhook (NULL, &shs->ipcblk); - if (support_sharedmem == TUN_TRUE) - { - _mtx_lock (&Giant, shs->ipcblk.winpid, __FILE__, __LINE__); - ipc_p_vmspace (&shs->ipcblk); - shmexit_myhook (shs->ipcblk.p_vmspace); - mtx_unlock (&Giant); - } - break; - default: - /* FIXME: Panic? */ - break; - } - CloseHandle (shs->process_hdl); - ipc_hookthread *ipcht_entry, *sav_entry; - enter_critical_section (&ipcht_cs); - SLIST_FOREACH_SAFE (ipcht_entry, &ipcht_list, sht_next, sav_entry) - { - if (ipcht_entry->winpid == shs->ipcblk.winpid) - { - SLIST_REMOVE (&ipcht_list, ipcht_entry, ipc_hookthread, sht_next); - CloseHandle (ipcht_entry->thread); - delete ipcht_entry; - } - } - leave_critical_section (&ipcht_cs); - delete shs; - return 0; -} - -/* Deletes all pending hook threads. Called by ipcunload() which in turn - is called by the cygserver main routine. */ -static void -ipcexit_dispose_hookthreads (void) -{ - SetEvent (ipcexit_event); - ipc_hookthread *ipcht_entry; - enter_critical_section (&ipcht_cs); - SLIST_FOREACH (ipcht_entry, &ipcht_list, sht_next) - { - WaitForSingleObject (ipcht_entry->thread, 1000); - /* Don't bother removing the linked list on cygserver shutdown. */ - /* FIXME: Error handling? */ - } - leave_critical_section (&ipcht_cs); -} - -/* Creates the per process wait thread. Called by semget() under locked - Giant mutex condition. */ -int -ipcexit_creat_hookthread (struct thread *td) -{ - ipc_hookthread *ipcht_entry; - int ret = -1; - enter_critical_section (&ipcht_cs); - SLIST_FOREACH (ipcht_entry, &ipcht_list, sht_next) - { - if (ipcht_entry->winpid == td->ipcblk->winpid) - ret = 0; - } - leave_critical_section (&ipcht_cs); - if (!ret) - return 0; - - DWORD tid; - ipc_hookthread_storage *shs = new ipc_hookthread_storage; - if (!DuplicateHandle (GetCurrentProcess (), td->client->handle (), - GetCurrentProcess (), &shs->process_hdl, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - delete shs; - log (LOG_CRIT, "failed to duplicate process handle, error = %u", - GetLastError ()); - return cygwin_internal (CW_GET_ERRNO_FROM_WINERROR, - GetLastError (), ENOMEM); - } - shs->ipcblk = *td->ipcblk; - HANDLE thread = CreateThread (NULL, 0, ipcexit_hookthread, shs, 0, &tid); - if (!thread) - { - delete shs; - log (LOG_CRIT, "failed to create thread, error = %u", GetLastError ()); - return cygwin_internal (CW_GET_ERRNO_FROM_WINERROR, - GetLastError (), ENOMEM); - } - ipcht_entry = new ipc_hookthread; - ipcht_entry->thread = thread; - ipcht_entry->winpid = td->ipcblk->winpid; - ipcht_entry->vmspace.vm_map = NULL; - ipcht_entry->vmspace.vm_shm = NULL; - enter_critical_section (&ipcht_cs); - SLIST_INSERT_HEAD (&ipcht_list, ipcht_entry, sht_next); - leave_critical_section (&ipcht_cs); - return 0; -} - -/* - * Need the admins group SID to compare with groups in client token. - */ -PSID admininstrator_group_sid; - -static void -init_admin_sid (void) -{ - SID_IDENTIFIER_AUTHORITY nt_auth = {SECURITY_NT_AUTHORITY}; - if (! AllocateAndInitializeSid (&nt_auth, 2, 32, 544, 0, 0, 0, 0, 0, 0, - &admininstrator_group_sid)) - panic ("failed to create well known sids, error = %u", - GetLastError ()); -} - -SECURITY_DESCRIPTOR sec_all_nih_sd; -SECURITY_ATTRIBUTES sec_all_nih = { sizeof (SECURITY_ATTRIBUTES), - &sec_all_nih_sd, - FALSE }; - -void -securityinit () -{ - InitializeSecurityDescriptor (&sec_all_nih_sd, SECURITY_DESCRIPTOR_REVISION); - SetSecurityDescriptorDacl (&sec_all_nih_sd, TRUE, 0, FALSE); - init_admin_sid (); -} - -/* Global vars, determining whether the IPC stuff should be started or not. */ -tun_bool_t support_sharedmem = TUN_UNDEF; -tun_bool_t support_msgqueues = TUN_UNDEF; -tun_bool_t support_semaphores = TUN_UNDEF; - -void -ipcinit () -{ - mtx_init (&Giant, "Giant", NULL, MTX_DEF); - msleep_init (); - ipcexit_event = CreateEvent (NULL, TRUE, FALSE, NULL); - if (!ipcexit_event) - panic ("Failed to create ipcexit event object"); - InitializeCriticalSection (&ipcht_cs); - if (support_msgqueues == TUN_TRUE) - msginit (); - if (support_semaphores == TUN_TRUE) - seminit (); - if (support_sharedmem == TUN_TRUE) - shminit (); -} - -int -ipcunload () -{ - ipcexit_dispose_hookthreads (); - CloseHandle (ipcexit_event); - wakeup_all (); - if (support_semaphores == TUN_TRUE) - semunload (); - if (support_sharedmem == TUN_TRUE) - shmunload (); - if (support_msgqueues == TUN_TRUE) - msgunload (); - mtx_destroy (&Giant); - return 0; -} - -/* - * Helper function to find a gid in a list of gids. - */ -static bool -is_grp_member (gid_t grp, gid_t *grplist, int listsize) -{ - if (grplist) - for (; listsize > 0; --listsize) - if (grp == grplist[listsize - 1]) - return true; - return false; -} - -/* - * Helper function to get a specific token information from a token. - * This function mallocs the necessary buffer spcae by itself. It - * must be free'd by the calling function. - */ -void * -get_token_info (HANDLE tok, TOKEN_INFORMATION_CLASS tic) -{ - void *buf; - DWORD size; - - if (!GetTokenInformation (tok, tic, NULL, 0, &size) - && GetLastError () != ERROR_INSUFFICIENT_BUFFER) - return NULL; - if (!(buf = malloc (size))) - return NULL; - if (!GetTokenInformation (tok, tic, buf, size, &size)) - { - free (buf); - return NULL; - } - return buf; -} - -/* - * Check if client user helds "mode" permission when accessing object - * associated with "perm" permission record. - * Returns an error code. - */ -int -ipcperm (struct thread *td, ipc_perm *perm, unsigned int mode) -{ - proc *p = td->ipcblk; - - if (!suser (td)) - return 0; - if (mode & IPC_M) - { - return (p->uid != perm->cuid && p->uid != perm->uid) - ? EACCES : 0; - } - if (p->uid != perm->cuid && p->uid != perm->uid) - { - /* If the user is a member of the creator or owner group, test - against group bits, otherwise against other bits. */ - mode >>= p->gid != perm->gid && p->gid != perm->cgid - && !is_grp_member (perm->gid, p->gidlist, p->gidcnt) - && !is_grp_member (perm->cgid, p->gidlist, p->gidcnt) - ? 6 : 3; - } - return (mode & perm->mode) != mode ? EACCES : 0; -} - -/* - * Check for client user being superuser. - * Returns an error code. - */ -int -suser (struct thread *td) -{ - /* This value has been set at ImpersonateNamedPipeClient() time - using the token information. See adjust_identity_info() below. */ - return td->ipcblk->is_admin ? 0 : EACCES; -} - -/* - * Retrieves user and group info from impersonated token and creates the - * correct uid, gid, gidlist and is_admin entries in p from that. - */ -bool -adjust_identity_info (struct proc *p) -{ - HANDLE tok; - - if (!OpenThreadToken (GetCurrentThread (), TOKEN_READ, TRUE, &tok)) - { - debug ("Failed to open worker thread access token for pid %d, winpid %d", - p->cygpid, p->winpid); - return false; - } - - /* Get uid from user SID in token. */ - PTOKEN_USER user; - if (!(user = (PTOKEN_USER)get_token_info (tok, TokenUser))) - goto faulty; - p->uid = cygwin_internal (CW_GET_UID_FROM_SID, user->User.Sid); - free (user); - if (p->uid == (uid_t)-1) - log (LOG_WARNING, "WARNING: User not found in /etc/passwd! Using uid -1!"); - - /* Get gid from primary group SID in token. */ - PTOKEN_PRIMARY_GROUP pgrp; - if (!(pgrp = (PTOKEN_PRIMARY_GROUP)get_token_info (tok, TokenPrimaryGroup))) - goto faulty; - p->gid = cygwin_internal (CW_GET_GID_FROM_SID, pgrp->PrimaryGroup); - free (pgrp); - if (p->gid == (gid_t)-1) - log (LOG_WARNING,"WARNING: Group not found in /etc/group! Using gid -1!"); - - /* Generate gid list from token group's SID list. Also look if the token - has an enabled admin group SID. That means, the process has admin - privileges. That knowledge is used in suser(). */ - PTOKEN_GROUPS gsids; - if (!(gsids = (PTOKEN_GROUPS)get_token_info (tok, TokenGroups))) - goto faulty; - if (gsids->GroupCount) - { - p->gidlist = (gid_t *) calloc (gsids->GroupCount, sizeof (gid_t)); - if (p->gidlist) - p->gidcnt = gsids->GroupCount; - } - for (DWORD i = 0; i < gsids->GroupCount; ++i) - { - if (p->gidlist) - p->gidlist[i] = cygwin_internal (CW_GET_GID_FROM_SID, - gsids->Groups[i].Sid); - if (EqualSid (gsids->Groups[i].Sid, admininstrator_group_sid) - && (gsids->Groups[i].Attributes & SE_GROUP_ENABLED)) - p->is_admin = true; - } - free (gsids); - - CloseHandle (tok); - return true; - -faulty: - CloseHandle (tok); - log (LOG_CRIT, "Failed to get token information for pid %d, winpid %d", - p->cygpid, p->winpid); - return false; -} - -/* - * Windows wrapper implementation of the VM functions called by sysv_shm.cc. - */ - -vm_object_t -_vm_pager_allocate (int size, int shmflg) -{ - /* Create the file mapping object with full access for everyone. This is - necessary to allow later calls to shmctl(..., IPC_SET,...) to - change the access rights and ownership of a shared memory region. - The access rights are tested at the beginning of every shm... function. - Note that this does not influence the actual read or write access - defined in a call to shmat. */ - vm_object_t object = CreateFileMapping (INVALID_HANDLE_VALUE, &sec_all_nih, - PAGE_READWRITE, 0, size, NULL); - if (!object) - panic ("CreateFileMapping in _vm_pager_allocate failed, %u", GetLastError ()); - return object; -} - -vm_object_t -vm_object_duplicate (struct thread *td, vm_object_t object) -{ - vm_object_t dup_object; - if (!DuplicateHandle (GetCurrentProcess (), object, - td->client->handle (), &dup_object, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - panic ("!DuplicateHandle in vm_object_duplicate failed, %u", GetLastError ()); - return dup_object; -} - -void -vm_object_deallocate (vm_object_t object) -{ - if (object) - CloseHandle (object); -} - -/* - * Tunable parameters are read from a system wide cygserver.conf file. - * On the first call to tunable_int_fetch, the file is read and the - * parameters are set accordingly. Each parameter has default, max and - * min settings. - */ - -enum tun_params_type { - TUN_NULL, - TUN_INT, - TUN_BOOL -}; - -union tun_value { - long ival; - tun_bool_t bval; -}; - -struct tun_struct { - const char *name; - tun_params_type type; - union tun_value value; - union tun_value min; - union tun_value max; - void (*check_func)(tun_struct *, char *, const char *); -}; - -static void -default_tun_check (tun_struct *that, char *value, const char *fname) -{ - char *c = NULL; - tun_value val; - switch (that->type) - { - case TUN_INT: - val.ival = strtoul (value, &c, 10); - if (!val.ival || (c && *c)) - panic ("Error in config file %s: Value of parameter %s malformed", - fname, that->name); - if (val.ival < that->min.ival || val.ival > that->max.ival) - panic ("Error in config file %s: Value of parameter %s must be " - "between %lu and %lu", - fname, that->name, that->min.ival, that->max.ival); - if (that->value.ival) - panic ("Error in config file %s: Parameter %s set twice.\n", - fname, that->name); - that->value.ival = val.ival; - break; - case TUN_BOOL: - if (!strcasecmp (value, "no") || !strcasecmp (value, "n") - || !strcasecmp (value, "false") || !strcasecmp (value, "f") - || !strcasecmp (value, "0")) - val.bval = TUN_FALSE; - else if (!strcasecmp (value, "yes") || !strcasecmp (value, "y") - || !strcasecmp (value, "true") || !strcasecmp (value, "t") - || !strcasecmp (value, "1")) - val.bval = TUN_TRUE; - else - panic ("Error in config file %s: Value of parameter %s malformed\n" - "Allowed values: \"yes\", \"no\", \"y\", \"n\", \"true\", \"false\", \"t\", \"f\", \"1\" and \"0\"", fname, that->name); - that->value.bval = val.bval; - break; - default: - /* Shouldn't happen. */ - panic ("Internal error: Wrong type of tunable parameter"); - break; - } -} - -static tun_struct tunable_params[] = -{ - /* SRV */ - { "kern.srv.cleanup_threads", TUN_INT, {0}, {1}, {32}, default_tun_check}, - { "kern.srv.request_threads", TUN_INT, {0}, {1}, {310}, default_tun_check}, - { "kern.srv.process_cache_size", TUN_INT, {0}, {1}, {310}, default_tun_check}, - { "kern.srv.sharedmem", TUN_BOOL, {TUN_UNDEF}, {TUN_FALSE}, {TUN_TRUE}, default_tun_check}, - { "kern.srv.msgqueues", TUN_BOOL, {TUN_UNDEF}, {TUN_FALSE}, {TUN_TRUE}, default_tun_check}, - { "kern.srv.semaphores", TUN_BOOL, {TUN_UNDEF}, {TUN_FALSE}, {TUN_TRUE}, default_tun_check}, - - /* LOG */ - { "kern.log.syslog", TUN_BOOL, {TUN_UNDEF}, {TUN_FALSE}, {TUN_TRUE}, default_tun_check}, - { "kern.log.stderr", TUN_BOOL, {TUN_UNDEF}, {TUN_FALSE}, {TUN_TRUE}, default_tun_check}, - { "kern.log.debug", TUN_BOOL, {TUN_UNDEF}, {TUN_FALSE}, {TUN_TRUE}, default_tun_check}, - { "kern.log.level", TUN_INT, {0}, {1}, {7}, default_tun_check}, - - /* MSG */ - { "kern.ipc.msgseg", TUN_INT, {0}, {256}, {65535}, default_tun_check}, - { "kern.ipc.msgssz", TUN_INT, {0}, {8}, {1024}, default_tun_check}, - { "kern.ipc.msgmnb", TUN_INT, {0}, {1}, {65535}, default_tun_check}, - { "kern.ipc.msgmni", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.msgtql", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - - /* SEM */ - //{ "kern.ipc.semmap", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.semmni", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.semmns", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.semmnu", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.semmsl", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.semopm", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.semume", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - //{ "kern.ipc.semusz", TUN_INT, {0}, {1}, {1024}, default_tun_check}, - { "kern.ipc.semvmx", TUN_INT, {0}, {1}, {32767}, default_tun_check}, - { "kern.ipc.semaem", TUN_INT, {0}, {1}, {32767}, default_tun_check}, - - /* SHM */ - { "kern.ipc.shmmaxpgs", TUN_INT, {0}, {1}, {32767}, default_tun_check}, - //{ "kern.ipc.shmmin", TUN_INT, {0}, {1}, {32767}, default_tun_check}, - { "kern.ipc.shmmni", TUN_INT, {0}, {1}, {32767}, default_tun_check}, - { "kern.ipc.shmseg", TUN_INT, {0}, {1}, {32767}, default_tun_check}, - { "kern.ipc.shm_allow_removed", TUN_BOOL, {TUN_UNDEF}, {TUN_FALSE}, {TUN_TRUE}, default_tun_check}, - //{ "kern.ipc.shm_use_phys", TUN_INT, {0}, {1}, {32767}, default_tun_check}, - { NULL, TUN_NULL, {0}, {0}, {0}, NULL} -}; - -#define skip_whitespace(c) while (*(c) && isspace (*(c))) ++(c) -#define skip_nonwhitespace(c) while (*(c) && !isspace (*(c)) && *(c) != '#') ++(c) -#define end_of_content(c) (!*(c) || *(c) == '#') - -void -tunable_param_init (const char *config_file, bool force) -{ - FILE *fp = fopen (config_file, "rt"); - if (!fp) - { - if (force) - panic ("can't open config file %s\n", config_file); - return; - } - char line[1024]; - while (fgets (line, 1024, fp)) - { - char *c = strrchr (line, '\n'); - if (!c) - panic ("Line too long in confg file %s\n", config_file); - /* Overwrite trailing NL. */ - *c = '\0'; - c = line; - skip_whitespace (c); - if (end_of_content (c)) - continue; - /* So we are on the first character of a parameter name. */ - char *name = c; - /* Find end of name. */ - skip_nonwhitespace (c); - if (end_of_content (c)) - { - *c++ = '\0'; - panic ("Error in config file %s: Parameter %s has no value.\n", - config_file, name); - } - /* Mark end of name. */ - *c++ = '\0'; - skip_whitespace (c); - if (end_of_content (c)) - panic ("Error in config file %s: Parameter %s has no value.\n", - config_file, name); - /* Now we are on the first character of a parameter's value. */ - char *value = c; - /* This only works for simple parameters. If complex string parameters - are added at one point, the scanning routine must be changed here. */ - /* Find end of value. */ - skip_nonwhitespace (c); - /* Mark end of value. */ - *c++ = '\0'; - /* Now look if name is one from our list. */ - tun_struct *s; - for (s = &tunable_params[0]; s->name; ++s) - if (!strcmp (name, s->name)) - { - /* Now read value and check for validity. check_func doesn't - return on error. */ - s->check_func (s, value, config_file); - break; - } - if (!s->name) - panic ("Error in config file %s: Unknown parameter %s.\n", - config_file, name); - } - fclose (fp); -} - -void -tunable_int_fetch (const char *name, int32_t *tunable_target) -{ - tun_struct *s; - for (s = &tunable_params[0]; s->name; ++s) - if (!strcmp (name, s->name)) - break; - if (!s) /* Not found */ - return; - if (s->type != TUN_INT) /* Wrong type */ - return; - if (!s->value.ival) /* Not set in config file */ - return; - *tunable_target = s->value.ival; - debug ("\nSet %s to %u\n", name, *tunable_target); -} - -void -tunable_bool_fetch (const char *name, tun_bool_t *tunable_target) -{ - tun_struct *s; - const char *tun_bool_val_string[] = { "undefined", "no", "yes" }; - for (s = &tunable_params[0]; s->name; ++s) - if (!strcmp (name, s->name)) - break; - if (!s) /* Not found */ - return; - if (s->type != TUN_BOOL) /* Wrong type */ - return; - if (!s->value.ival) /* Not set in config file */ - return; - *tunable_target = s->value.bval; - debug ("\nSet %s to %s\n", name, tun_bool_val_string[*tunable_target]); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/bsd_helper.h b/winsup/cygserver/bsd_helper.h deleted file mode 100644 index bc8d22810..000000000 --- a/winsup/cygserver/bsd_helper.h +++ /dev/null @@ -1,66 +0,0 @@ -/* bsd_helper.h: Helps integrating BSD kernel code - - Copyright 2003, 2012 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ -#ifndef _BSD_HELPER_H -#define _BSD_HELPER_H - -#include <sys/types.h> -#include <sys/syslog.h> - -enum tun_bool_t { - TUN_UNDEF = 0, - TUN_FALSE = 1, - TUN_TRUE = 2 -}; - -#define TUNABLE_INT_FETCH(a,b) tunable_int_fetch((a),(b)) -#define TUNABLE_BOOL_FETCH(a,b) tunable_bool_fetch((a),(b)) - -#define sys_malloc(a,b,c) (malloc(a)?:(panic("malloc failed in %s, line %d"),(void*)NULL)) -#define sys_free(a,b) free(a) - -#define jail_sysvipc_allowed true -#define jailed(a) false - -extern const char *__progname; - -/* Global vars, determining whether the IPC stuff should be started or not. */ -extern tun_bool_t support_sharedmem; -extern tun_bool_t support_msgqueues; -extern tun_bool_t support_semaphores; - -extern SECURITY_ATTRIBUTES sec_all_nih; - -void securityinit (void); - -int win_copyin (struct thread *, const void *, void *, size_t); -int win_copyout (struct thread *, const void *, void *, size_t); -#define copyin(a,b,c) win_copyin((td),(a),(b),(c)) -#define copyout(a,b,c) win_copyout((td),(a),(b),(c)) - -void *get_token_info (HANDLE, TOKEN_INFORMATION_CLASS); -int ipcperm (struct thread *, struct ipc_perm *, unsigned int); -int suser (struct thread *); -bool adjust_identity_info (struct proc *p); - -struct vmspace *ipc_p_vmspace (struct proc *); -int ipcexit_creat_hookthread(struct thread *); -void ipcinit (void); -int ipcunload (void); - -vm_object_t _vm_pager_allocate (int, int); -#define vm_pager_allocate(a,b,s,c,d) _vm_pager_allocate((s),(mode)) -vm_object_t vm_object_duplicate (struct thread *td, vm_object_t object); -void vm_object_deallocate (vm_object_t object); - -void tunable_param_init (const char *, bool); -void tunable_int_fetch (const char *, int32_t *); -void tunable_bool_fetch (const char *, tun_bool_t *); - -#endif /* _BSD_HELPER_H */ diff --git a/winsup/cygserver/bsd_log.cc b/winsup/cygserver/bsd_log.cc deleted file mode 100644 index 18dc1a53b..000000000 --- a/winsup/cygserver/bsd_log.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* bsd_log.cc - - Copyright 2003, 2004, 2012 Red Hat Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#define _KERNEL 1 -#define __BSD_VISIBLE 1 -#include <stdio.h> -#include <stdlib.h> - -int32_t log_level = 8; /* Illegal value. Don't change! */ -tun_bool_t log_debug = TUN_UNDEF; -tun_bool_t log_syslog = TUN_UNDEF; -tun_bool_t log_stderr = TUN_UNDEF; - -void -loginit (tun_bool_t opt_stderr, tun_bool_t opt_syslog) -{ - if (log_debug == TUN_UNDEF) - TUNABLE_BOOL_FETCH ("kern.log.debug", &log_debug); - if (log_debug == TUN_UNDEF) - log_debug = TUN_FALSE; - - if (opt_stderr != TUN_UNDEF) - log_stderr = opt_stderr; - else - TUNABLE_BOOL_FETCH ("kern.log.stderr", &log_stderr); - if (log_stderr == TUN_UNDEF) - log_stderr = TUN_FALSE; - - if (opt_syslog != TUN_UNDEF) - log_syslog = opt_syslog; - else - TUNABLE_BOOL_FETCH ("kern.log.syslog", &log_syslog); - if (log_syslog == TUN_UNDEF) - log_syslog = TUN_FALSE; - - if (log_level == 8) - TUNABLE_INT_FETCH ("kern.log.level", &log_level); - if (log_level == 8) - log_level = 6; -} - -void -_vlog (const char *file, int line, int level, - const char *fmt, va_list ap) -{ - char buf[16384]; - char *pos; - - if ((level == LOG_DEBUG && log_debug != TUN_TRUE) - || (level != LOG_DEBUG && level >= log_level)) - return; - pos = stpcpy (buf, "cygserver: "); - if (file && log_debug == TUN_TRUE) - pos += snprintf (pos, 16384 - (pos - buf), "%s, line %d: ", file, line); - vsnprintf (pos, 16384 - (pos - buf), fmt, ap); - if (log_syslog == TUN_TRUE && level != LOG_DEBUG) - syslog (level, buf); - if (log_stderr == TUN_TRUE || level == LOG_DEBUG) - { - fputs (buf, stderr); - fputc ('\n', stderr); - } -} - -void -_log (const char *file, int line, int level, const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - _vlog (file, line, level, fmt, ap); -} - -void -_vpanic (const char *file, int line, const char *fmt, va_list ap) -{ - _vlog (file, line, LOG_CRIT, fmt, ap); - exit (1); -} - -void -_panic (const char *file, int line, const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - _vpanic (file, line, fmt, ap); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/bsd_log.h b/winsup/cygserver/bsd_log.h deleted file mode 100644 index 0027d4ff5..000000000 --- a/winsup/cygserver/bsd_log.h +++ /dev/null @@ -1,33 +0,0 @@ -/* bsd_log.h: Helps integrating BSD kernel code - - Copyright 2003, 2012 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ -#ifndef _BSD_LOG_H -#define _BSD_LOG_H - -#include <sys/types.h> -#include <sys/syslog.h> - -extern int32_t log_level; -extern tun_bool_t log_debug; -extern tun_bool_t log_syslog; -extern tun_bool_t log_stderr; - -void loginit (tun_bool_t, tun_bool_t); -void _vlog (const char *, int, int, const char *, va_list); -void _log (const char *, int, int, const char *, ...); -void _vpanic (const char *, int, const char *, va_list) __attribute__ ((noreturn)); -void _panic (const char *, int, const char *, ...) __attribute__ ((noreturn)); -#define vlog(l,f,a) _vlog(NULL,0,(l),(f),(a)) -#define log(l,f,...) _log(NULL,0,(l),(f),##__VA_ARGS__) -#define vdebug(f,a) _vlog(__FILE__,__LINE__,LOG_DEBUG,(f),(a)) -#define debug(f,...) _log(__FILE__,__LINE__,LOG_DEBUG,(f),##__VA_ARGS__) -#define vpanic(f,a) _vpanic(__FILE__,__LINE__,(f),(a)) -#define panic(f,...) _panic(__FILE__,__LINE__,(f),##__VA_ARGS__) - -#endif /* _BSD_LOG_H */ diff --git a/winsup/cygserver/bsd_mutex.cc b/winsup/cygserver/bsd_mutex.cc deleted file mode 100644 index 66c4b2398..000000000 --- a/winsup/cygserver/bsd_mutex.cc +++ /dev/null @@ -1,388 +0,0 @@ -/* bsd_mutex.cc - - Copyright 2003, 2004, 2005, 2007, 2012, 2014 Red Hat Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#include <errno.h> -#define _KERNEL 1 -#define __BSD_VISIBLE 1 -#include <sys/smallprint.h> -#include <limits.h> -#include <stdlib.h> -#include <sys/msg.h> -#include <sys/sem.h> - -#include "process.h" -#include "cygserver_ipc.h" - -/* A BSD kernel global mutex. */ -struct mtx Giant; - -void -mtx_init (mtx *m, const char *name, const void *, int) -{ - m->name = name; - m->owner = 0; - m->cnt = 0; - /* Can't use Windows Mutexes here since Windows Mutexes are only - unlockable by the lock owner. */ - m->h = CreateSemaphore (NULL, 1, 1, NULL); - if (!m->h) - panic ("couldn't allocate %s mutex, %u\n", name, GetLastError ()); -} - -void -_mtx_lock (mtx *m, DWORD winpid, const char *file, int line) -{ - _log (file, line, LOG_DEBUG, "Try locking mutex %s (%u) (hold: %u)", - m->name, winpid, m->owner); - if (WaitForSingleObject (m->h, INFINITE) != WAIT_OBJECT_0) - _panic (file, line, "wait for %s in %d failed, %u", m->name, winpid, - GetLastError ()); - m->owner = winpid; - _log (file, line, LOG_DEBUG, "Locked mutex %s/%u (%u)", - m->name, ++m->cnt, winpid); -} - -int -mtx_owned (mtx *m, DWORD winpid) -{ - return m->owner == winpid; -} - -void -_mtx_assert (mtx *m, int what, DWORD winpid, const char *file, int line) -{ - switch (what) - { - case MA_OWNED: - if (!mtx_owned (m, winpid)) - _panic (file, line, "Mutex %s not owned", m->name); - break; - case MA_NOTOWNED: - if (mtx_owned (m, winpid)) - _panic (file, line, "Mutex %s is owned", m->name); - break; - default: - break; - } -} - -void -_mtx_unlock (mtx *m, const char *file, int line) -{ - DWORD owner = m->owner; - unsigned long cnt = m->cnt; - m->owner = 0; - /* Cautiously check if mtx_destroy has been called (shutdown). - In that case, m->h is NULL. */ - if (m->h && !ReleaseSemaphore (m->h, 1, NULL)) - { - /* Check if the semaphore was already on it's max value. */ - if (GetLastError () != ERROR_TOO_MANY_POSTS) - _panic (file, line, "release of mutex %s failed, %u", m->name, - GetLastError ()); - } - _log (file, line, LOG_DEBUG, "Unlocked mutex %s/%u (owner: %u)", - m->name, cnt, owner); -} - -void -mtx_destroy (mtx *m) -{ - HANDLE tmp = m->h; - m->h = NULL; - if (tmp) - CloseHandle (tmp); -} - -/* - * Helper functions for msleep/wakeup. - */ - -static int -win_priority (int priority) -{ - int p = (int)((priority) & PRIO_MASK) - PZERO; - /* Generating a valid priority value is a bit tricky. The only valid - values on NT4 are -15, -2, -1, 0, 1, 2, 15. */ - switch (p) - { - case -15: case -14: case -13: case -12: case -11: - return THREAD_PRIORITY_IDLE; - case -10: case -9: case -8: case -7: case -6: - return THREAD_PRIORITY_LOWEST; - case -5: case -4: case -3: case -2: case -1: - return THREAD_PRIORITY_BELOW_NORMAL; - case 0: - return THREAD_PRIORITY_NORMAL; - case 1: case 2: case 3: case 4: case 5: - return THREAD_PRIORITY_ABOVE_NORMAL; - case 6: case 7: case 8: case 9: case 10: - return THREAD_PRIORITY_HIGHEST; - case 11: case 12: case 13: case 14: case 15: - return THREAD_PRIORITY_TIME_CRITICAL; - } - return THREAD_PRIORITY_NORMAL; -} - -/* - * Sets the thread priority, returns the old priority. - */ -static int -set_priority (int priority) -{ - int old_prio = GetThreadPriority (GetCurrentThread ()); - if (!SetThreadPriority (GetCurrentThread (), win_priority (priority))) - log (LOG_WARNING, - "Warning: Setting thread priority to %d failed with error %u\n", - win_priority (priority), GetLastError ()); - return old_prio; -} - -/* - * Original description from BSD code: - * - * General sleep call. Suspends the current process until a wakeup is - * performed on the specified identifier. The process will then be made - * runnable with the specified priority. Sleeps at most timo/hz seconds - * (0 means no timeout). If pri includes PCATCH flag, signals are checked - * before and after sleeping, else signals are not checked. Returns 0 if - * awakened, EWOULDBLOCK if the timeout expires. If PCATCH is set and a - * signal needs to be delivered, ERESTART is returned if the current system - * call should be restarted if possible, and EINTR is returned if the system - * call should be interrupted by the signal (return EINTR). - * - * The mutex argument is exited before the caller is suspended, and - * entered before msleep returns. If priority includes the PDROP - * flag the mutex is not entered before returning. - */ -static HANDLE msleep_glob_evt; - -class msleep_sync_array -{ - enum msleep_action { - MSLEEP_ENTER = 0, - MSLEEP_LEAVE, - MSLEEP_WAKEUP - }; - - CRITICAL_SECTION cs; - long cnt; - long max_cnt; - struct msleep_record { - void *ident; - HANDLE wakeup_evt; - LONG threads; - } *a; - - int find_ident (void *ident, msleep_action action) - { - int i; - for (i = 0; i < cnt; ++i) - if (a[i].ident == ident) - return i; - if (i >= max_cnt) - panic ("ident %x not found and run out of slots.", ident); - if (i >= cnt && action == MSLEEP_LEAVE) - panic ("ident %x not found (%d).", ident, action); - return i; - } - - HANDLE first_entry (int i, void *ident) - { - debug ("New ident %x, index %d", ident, i); - a[i].ident = ident; - a[i].wakeup_evt = CreateEvent (NULL, TRUE, FALSE, NULL); - if (!a[i].wakeup_evt) - panic ("CreateEvent failed: %u", GetLastError ()); - debug ("i = %d, CreateEvent: %x", i, a[i].wakeup_evt); - a[i].threads = 1; - ++cnt; - return a[i].wakeup_evt; - } - - HANDLE next_entry (int i) - { - if (a[i].ident && WaitForSingleObject (a[i].wakeup_evt, 0) != WAIT_OBJECT_0) - { - ++a[i].threads; - return a[i].wakeup_evt; - } - return NULL; - } - -public: - - msleep_sync_array (int count) : cnt (0), max_cnt (count) - { - InitializeCriticalSection (&cs); - if (!(a = new msleep_record[count])) - panic ("Allocating msleep records failed: %d", errno); - } - - ~msleep_sync_array () { delete a; } - - HANDLE enter (void *ident) - { - HANDLE evt = NULL; - while (!evt) - { - EnterCriticalSection (&cs); - int i = find_ident (ident, MSLEEP_ENTER); - if (i >= cnt) - evt = first_entry (i, ident); - else if (!(evt = next_entry (i))) - { - /* wakeup has been called, so sleep to wait until all - formerly waiting threads have left and retry. */ - LeaveCriticalSection (&cs); - Sleep (1L); - } - } - LeaveCriticalSection (&cs); - return evt; - } - - void leave (void *ident) - { - EnterCriticalSection (&cs); - int i = find_ident (ident, MSLEEP_LEAVE); - if (--a[i].threads == 0) - { - debug ("i = %d, CloseEvent: %x", i, a[i].wakeup_evt); - CloseHandle (a[i].wakeup_evt); - a[i].ident = NULL; - --cnt; - if (i < cnt) - a[i] = a[cnt]; - } - LeaveCriticalSection (&cs); - } - - void wakeup (void *ident) - { - EnterCriticalSection (&cs); - int i = find_ident (ident, MSLEEP_WAKEUP); - if (i < cnt && a[i].ident) - SetEvent (a[i].wakeup_evt); - LeaveCriticalSection (&cs); - } -}; - -static msleep_sync_array *msleep_sync; - -void -msleep_init (void) -{ - extern struct msginfo msginfo; - extern struct seminfo seminfo; - - msleep_glob_evt = CreateEvent (NULL, TRUE, FALSE, NULL); - if (!msleep_glob_evt) - panic ("CreateEvent in msleep_init failed: %u", GetLastError ()); - int32_t msgmni = support_msgqueues ? msginfo.msgmni : 0; - int32_t semmni = support_semaphores ? seminfo.semmni : 0; - TUNABLE_INT_FETCH ("kern.ipc.msgmni", &msgmni); - TUNABLE_INT_FETCH ("kern.ipc.semmni", &semmni); - debug ("Try allocating msgmni (%d) + semmni (%d) msleep records", - msgmni, semmni); - msleep_sync = new msleep_sync_array (msgmni + semmni); - if (!msleep_sync) - panic ("Allocating msleep records in msleep_init failed: %d", errno); -} - -int -_msleep (void *ident, struct mtx *mtx, int priority, - const char *wmesg, int timo, struct thread *td) -{ - int ret = -1; - - HANDLE evt = msleep_sync->enter (ident); - - if (mtx) - mtx_unlock (mtx); - int old_priority = set_priority (priority); - HANDLE obj[4] = - { - evt, - msleep_glob_evt, - td->client->handle (), - td->client->signal_arrived () - }; - /* PCATCH handling. If PCATCH is given and signal_arrived is a valid - handle, then it's used in the WaitFor call and EINTR is returned. */ - int obj_cnt = 3; - if ((priority & PCATCH) - && td->client->signal_arrived () != INVALID_HANDLE_VALUE) - obj_cnt = 4; - switch (WaitForMultipleObjects (obj_cnt, obj, FALSE, timo ?: INFINITE)) - { - case WAIT_OBJECT_0: /* wakeup() has been called. */ - ret = 0; - debug ("msleep wakeup called for %d", td->td_proc->winpid); - break; - case WAIT_OBJECT_0 + 1: /* Shutdown event (triggered by wakeup_all). */ - priority |= PDROP; - /*FALLTHRU*/ - case WAIT_OBJECT_0 + 2: /* The dependent process has exited. */ - debug ("msleep process exit or shutdown for %d", td->td_proc->winpid); - ret = EIDRM; - break; - case WAIT_OBJECT_0 + 3: /* Signal for calling process arrived. */ - debug ("msleep process got signal for %d", td->td_proc->winpid); - ret = EINTR; - break; - case WAIT_TIMEOUT: - ret = EWOULDBLOCK; - break; - default: - /* There's a chance that a process has been terminated before - WaitForMultipleObjects has been called. In this case the handles - might be invalid. The error code returned is ERROR_INVALID_HANDLE. - Since we can trust the values of these handles otherwise, we - treat an ERROR_INVALID_HANDLE as a normal process termination and - hope for the best. */ - if (GetLastError () != ERROR_INVALID_HANDLE) - panic ("wait in msleep (%s) failed, %u", wmesg, GetLastError ()); - debug ("wait in msleep (%s) failed for %d, %u", wmesg, - td->td_proc->winpid, GetLastError ()); - ret = EIDRM; - break; - } - - msleep_sync->leave (ident); - - set_priority (old_priority); - - if (mtx && !(priority & PDROP)) - mtx_lock (mtx); - return ret; -} - -/* - * Make all threads sleeping on the specified identifier runnable. - */ -int -wakeup (void *ident) -{ - msleep_sync->wakeup (ident); - return 0; -} - -/* - * Wakeup all sleeping threads. Only called in the context of cygserver - * shutdown. - */ -void -wakeup_all (void) -{ - SetEvent (msleep_glob_evt); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/bsd_mutex.h b/winsup/cygserver/bsd_mutex.h deleted file mode 100644 index c9f501576..000000000 --- a/winsup/cygserver/bsd_mutex.h +++ /dev/null @@ -1,52 +0,0 @@ -/* bsd_mutex.h: BSD Mutex helper - - Copyright 2003, 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ -#ifndef _BSD_MUTEX_H -#define _BSD_MUTEX_H - -#define MTX_DEF 0 - -#define MA_OWNED 1 -#define MA_NOTOWNED 2 - -#define PZERO (0x20) -#define PRIO_MASK (0x1f) -#define PDROP 0x1000 -#define PCATCH 0x2000 -#define PLOCK 0x3000 - -struct mtx { - HANDLE h; - const char *name; - DWORD owner; - unsigned long cnt; -}; - -/* Some BSD kernel global mutex. */ -extern struct mtx Giant; - -void mtx_init (mtx *, const char *, const void *, int); -void _mtx_lock (mtx *, DWORD winpid, const char *, int); -#define mtx_lock(m) _mtx_lock((m), (td->ipcblk->winpid), __FILE__, __LINE__) -int mtx_owned (mtx *, DWORD); -void _mtx_assert(mtx *, int, DWORD winpid, const char *, int); -#define mtx_assert(m,w,p) _mtx_assert((m),(w),(p),__FILE__,__LINE__) -void _mtx_unlock (mtx *, const char *, int); -#define mtx_unlock(m) _mtx_unlock((m),__FILE__,__LINE__) - -void mtx_destroy (mtx *); - -void msleep_init (void); -int _msleep (void *, struct mtx *, int, const char *, int, struct thread *); -#define msleep(i,m,p,w,t) _msleep((i),(m),(p),(w),(t),(td)) -#define tsleep(i,p,w,t) _msleep((i),NULL,(p),(w),(t),(td)) -int wakeup (void *); -void wakeup_all (void); - -#endif /* _BSD_MUTEX_H */ diff --git a/winsup/cygserver/client.cc b/winsup/cygserver/client.cc deleted file mode 100644 index 0c6c24ba9..000000000 --- a/winsup/cygserver/client.cc +++ /dev/null @@ -1,526 +0,0 @@ -/* client.cc - - Copyright 2001, 2002, 2003, 2004, 2008, 2009, 2012, 2013, 2014 Red Hat Inc. - - Written by Egor Duda <deo@logos-m.ru> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* to allow this to link into cygwin and the .dll, a little magic is needed. */ -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#else -#include "winsup.h" -#endif - -#include <assert.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> - -#include "cygserver_msg.h" -#include "cygserver_sem.h" -#include "cygserver_shm.h" -#include "cygserver_setpwd.h" -#include "cygserver_pwdgrp.h" - -#include "cygserver.h" -#include "transport.h" - -int cygserver_running = CYGSERVER_UNKNOWN; // Nb: inherited by children. - -client_request_get_version::client_request_get_version () - : client_request (CYGSERVER_REQUEST_GET_VERSION, &version, sizeof (version)) -{ - msglen (0); // No parameters for request. - - // verbose: syscall_printf ("created"); -} - -/* - * client_request_get_version::check_version () - * - * The major version and API version numbers must match exactly. An - * older than expected minor version number is accepted (as long as - * the first numbers match, that is). - */ - -#ifdef __INSIDE_CYGWIN__ - -bool -client_request_get_version::check_version () const -{ - const bool ok = (version.major == CYGWIN_SERVER_VERSION_MAJOR - && version.api == CYGWIN_SERVER_VERSION_API - && version.minor <= CYGWIN_SERVER_VERSION_MINOR); - - if (!ok) - syscall_printf (("incompatible version of cygwin server: " - "client version %d.%d.%d.%d, " - "server version %d.%d.%d.%d"), - CYGWIN_SERVER_VERSION_MAJOR, - CYGWIN_SERVER_VERSION_API, - CYGWIN_SERVER_VERSION_MINOR, - CYGWIN_SERVER_VERSION_PATCH, - version.major, - version.api, - version.minor, - version.patch); - - return ok; -} - -client_request_attach_tty::client_request_attach_tty (DWORD nmaster_pid, - HANDLE nfrom_master, - HANDLE nto_master) - : client_request (CYGSERVER_REQUEST_ATTACH_TTY, &req, sizeof (req)) -{ - req.pid = GetCurrentProcessId (); - req.master_pid = nmaster_pid; - req.from_master = nfrom_master; - req.to_master = nto_master; - - syscall_printf (("created: pid = %u, master_pid = %u, " - "from_master = %p, to_master = %p"), - req.pid, req.master_pid, req.from_master, req.to_master); -} -#endif /* __INSIDE_CYGWIN__ */ - -/* - * client_request_attach_tty::send () - * - * Wraps the base method to provide error handling support. If the - * reply contains a body but is flagged as an error, close any handles - * that have been returned by cygserver and then discard the message - * body, i.e. the client either sees a successful result with handles - * or an unsuccessful result with no handles. - */ - -void -client_request_attach_tty::send (transport_layer_base * const conn) -{ - client_request::send (conn); - - if (msglen () && error_code ()) - { - if (from_master ()) - CloseHandle (from_master ()); - if (to_master ()) - CloseHandle (to_master ()); - msglen (0); - } -} - -client_request::header_t::header_t (const request_code_t request_code, - const size_t len) - : request_code (request_code) -{ - assert (request_code >= 0 && request_code < CYGSERVER_REQUEST_LAST); - msglen = len; -} - -// FIXME: also check write and read result for -1. - -void -client_request::send (transport_layer_base * const conn) -{ - assert (conn); - assert (!(msglen () && !_buf)); // i.e., msglen () implies _buf - assert (msglen () <= _buflen); - - { - const ssize_t count = conn->write (&_header, sizeof (_header)); - - if (count != sizeof (_header)) - { - assert (errno); - error_code (errno); - syscall_printf (("request header write failure: " - "only %ld bytes sent of %lu, " - "error = %d(%u)"), - count, sizeof (_header), - errno, GetLastError ()); - return; - } - } - - if (msglen ()) - { - const ssize_t count = conn->write (_buf, msglen ()); - - if (count == -1 || (size_t) count != msglen ()) - { - assert (errno); - error_code (errno); - syscall_printf (("request body write failure: " - "only %ld bytes sent of %lu, " - "error = %d(%u)"), - count, msglen (), - errno, GetLastError ()); - return; - } - } - - { - const ssize_t count = conn->read (&_header, sizeof (_header)); - - if (count != sizeof (_header)) - { - assert (errno); - error_code (errno); - syscall_printf (("reply header read failure: " - "only %ld bytes received of %lu, " - "error = %d(%u)"), - count, sizeof (_header), - errno, GetLastError ()); - return; - } - } - - if (msglen () && !_buf) - { - system_printf ("no client buffer for reply body: %lu bytes needed", - msglen ()); - error_code (EINVAL); - return; - } - - if (msglen () > _buflen) - { - system_printf (("client buffer too small for reply body: " - "have %lu bytes and need %lu"), - _buflen, msglen ()); - error_code (EINVAL); - return; - } - - if (msglen ()) - { - const ssize_t count = conn->read (_buf, msglen ()); - - if (count == -1 || (size_t) count != msglen ()) - { - assert (errno); - error_code (errno); - syscall_printf (("reply body read failure: " - "only %ld bytes received of %lu, " - "error = %d(%u)"), - count, msglen (), - errno, GetLastError ()); - return; - } - } -} - -#ifdef __OUTSIDE_CYGWIN__ - -client_request_attach_tty::client_request_attach_tty () - : client_request (CYGSERVER_REQUEST_ATTACH_TTY, &req, sizeof (req)) -{ -} - -/* - * client_request::handle_request () - * - * A server-side method. - * - * This is a factory method for the client_request subclasses. It - * reads the incoming request header and, based on its request code, - * creates an instance of the appropriate class. - * - * FIXME: If the incoming packet is malformed, the server drops it on - * the floor. Should it try and generate some sort of reply for the - * client? As it is, the client will simply get a broken connection. - * - * FIXME: also check write and read result for -1. - */ - -/* static */ void -client_request::handle_request (transport_layer_base *const conn, - process_cache *const cache) -{ - // verbose: debug_printf ("about to read"); - - header_t header; - - { - const ssize_t count = conn->read (&header, sizeof (header)); - - if (count != sizeof (header)) - { - syscall_printf (("request header read failure: " - "only %ld bytes received of %lu, " - "error = %d(%u)"), - count, sizeof (header), - errno, GetLastError ()); - return; - } - } - - client_request *req = NULL; - - switch (header.request_code) - { - case CYGSERVER_REQUEST_GET_VERSION: - req = new client_request_get_version; - break; - case CYGSERVER_REQUEST_SHUTDOWN: - req = new client_request_shutdown; - break; - case CYGSERVER_REQUEST_ATTACH_TTY: - req = new client_request_attach_tty; - break; - case CYGSERVER_REQUEST_MSG: - req = new client_request_msg; - break; - case CYGSERVER_REQUEST_SEM: - req = new client_request_sem; - break; - case CYGSERVER_REQUEST_SHM: - req = new client_request_shm; - break; - case CYGSERVER_REQUEST_SETPWD: - req = new client_request_setpwd; - break; - case CYGSERVER_REQUEST_PWDGRP: - req = new client_request_pwdgrp; - break; - default: - syscall_printf ("unknown request code %d received: request ignored", - header.request_code); - return; - } - - assert (req); - - req->msglen (header.msglen); - req->handle (conn, cache); - - delete req; -} - -/* - * client_request::handle () - * - * A server-side method. - * - * At this point, the header of an incoming request has been read and - * an appropriate client_request object constructed. This method has - * to read the request body into its buffer, if there is such a body, - * then perform the request and send back the results to the client. - * - * FIXME: If the incoming packet is malformed, the server drops it on - * the floor. Should it try and generate some sort of reply for the - * client? As it is, the client will simply get a broken connection. - * - * FIXME: also check write and read result for -1. - */ - -void -client_request::handle (transport_layer_base *const conn, - process_cache *const cache) -{ - if (msglen () && !_buf) - { - system_printf ("no buffer for request body: %lu bytes needed", - msglen ()); - error_code (EINVAL); - return; - } - - if (msglen () > _buflen) - { - system_printf (("buffer too small for request body: " - "have %lu bytes and need %lu"), - _buflen, msglen ()); - error_code (EINVAL); - return; - } - - if (msglen ()) - { - const ssize_t count = conn->read (_buf, msglen ()); - - if (count == -1 || (size_t) count != msglen ()) - { - assert (errno); - error_code (errno); - syscall_printf (("request body read failure: " - "only %ld bytes received of %lu, " - "error = %d(%u)"), - count, msglen (), - errno, GetLastError ()); - return; - } - } - - error_code (0); // Overwrites the _header.request_code field. - - /* - * This is not allowed to fail. We must return ENOSYS at a minimum - * to the client. - */ - serve (conn, cache); - - { - const ssize_t count = conn->write (&_header, sizeof (_header)); - - if (count != sizeof (_header)) - { - assert (errno); - error_code (errno); - syscall_printf (("reply header write failure: " - "only %ld bytes sent of %lu, " - "error = %d(%u)"), - count, sizeof (_header), - errno, GetLastError ()); - return; - } - } - - if (msglen ()) - { - const ssize_t count = conn->write (_buf, msglen ()); - - if (count == -1 || (size_t) count != msglen ()) - { - assert (errno); - error_code (errno); - syscall_printf (("reply body write failure: " - "only %ld bytes sent of %lu, " - "error = %d(%u)"), - count, msglen (), - errno, GetLastError ()); - return; - } - } -} - -/* The server side implementation of make_request. Very simple. */ -int -client_request::make_request () -{ - transport_layer_base *const transport = create_server_transport (); - assert (transport); - if (transport->connect () == -1) - { - if (errno) - error_code (errno); - else - error_code (ENOSYS); - delete transport; - return -1; - } - send (transport); - delete transport; - return 0; -} -#endif /* __OUTSIDE_CYGWIN__ */ - -client_request::client_request (request_code_t const id, - void * const buf, - size_t const buflen) - : _header (id, buflen), - _buf (buf), - _buflen (buflen) -{ - assert ((!_buf && !_buflen) || (_buf && _buflen)); -} - -client_request::~client_request () -{} - -#ifdef __INSIDE_CYGWIN__ -int -client_request::make_request () -{ - assert (cygserver_running == CYGSERVER_UNKNOWN \ - || cygserver_running == CYGSERVER_OK \ - || cygserver_running == CYGSERVER_UNAVAIL); - - if (cygserver_running == CYGSERVER_UNKNOWN) - cygserver_init (); - - assert (cygserver_running == CYGSERVER_OK \ - || cygserver_running == CYGSERVER_UNAVAIL); - - /* Don't retry every request if the server's not there */ - if (cygserver_running == CYGSERVER_UNAVAIL) - { - syscall_printf ("cygserver un-available"); - error_code (ENOSYS); - return -1; - } - - transport_layer_base *const transport = create_server_transport (); - - assert (transport); - - if (transport->connect () == -1) - { - if (errno) - error_code (errno); - else - error_code (ENOSYS); - delete transport; - return -1; - } - - // verbose: debug_printf ("connected to server %p", transport); - - send (transport); - - delete transport; - - return 0; -} - -bool -check_cygserver_available () -{ - assert (cygserver_running == CYGSERVER_UNKNOWN \ - || cygserver_running == CYGSERVER_UNAVAIL); - - cygserver_running = CYGSERVER_OK; // For make_request (). - - client_request_get_version req; - - /* This indicates that we failed to connect to cygserver at all but - * that's fine as cygwin doesn't need it to be running. - */ - if (req.make_request () == -1) - return false; - - /* We connected to the server but something went wrong after that - * (in sending the message, in cygserver itself, or in receiving the - * reply). - */ - if (req.error_code ()) - { - syscall_printf ("failure in cygserver version request: %d", - req.error_code ()); - syscall_printf ("process will continue without cygserver support"); - return false; - } - - return req.check_version (); -} - -void -cygserver_init () -{ - assert (cygserver_running == CYGSERVER_UNKNOWN \ - || cygserver_running == CYGSERVER_OK \ - || cygserver_running == CYGSERVER_UNAVAIL); - - if (cygserver_running == CYGSERVER_OK) - return; - - if (!check_cygserver_available ()) - cygserver_running = CYGSERVER_UNAVAIL; -} -#endif /* __INSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/configure b/winsup/cygserver/configure deleted file mode 100755 index a4feae10b..000000000 --- a/winsup/cygserver/configure +++ /dev/null @@ -1,5326 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Cygwin Cygserver 0. -# -# Report bugs to <cygwin@cygwin.com>. -# -# -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org and cygwin@cygwin.com -$0: about your system, including any error possibly output -$0: before this message. Then install a modern shell, or -$0: manually run the script under such a shell if you do -$0: have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 </dev/null -exec 6>&1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='Cygwin Cygserver' -PACKAGE_TARNAME='cygwin' -PACKAGE_VERSION='0' -PACKAGE_STRING='Cygwin Cygserver 0' -PACKAGE_BUGREPORT='cygwin@cygwin.com' -PACKAGE_URL='https://cygwin.com' - -ac_unique_file="cygserver.cc" -ac_no_link=no -ac_subst_vars='LTLIBOBJS -LIBOBJS -configure_args -SET_MAKE -WINDRES -DLLTOOL -NM -LD -RANLIB -AS -AR -install_host -all_host -cygwin_headers -newlib_headers -windows_headers -windows_libdir -CPP -ac_ct_CXX -CXXFLAGS -CXX -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -target_os -target_vendor -target_cpu -target -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL -winsup_srcdir -target_builddir' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -with_windows_headers -with_windows_libs -enable_debugging -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CXX -CXXFLAGS -CCC -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures Cygwin Cygserver 0 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/cygwin] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] - --target=TARGET configure for building compilers for TARGET [HOST] -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of Cygwin Cygserver 0:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-debugging Build a cygwin DLL which has more consistency checking for debugging - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-windows-headers=DIR - specify where the windows includes are located - --with-windows-libs=DIR specify where the windows libraries are located - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a - nonstandard directory <lib dir> - LIBS libraries to pass to the linker, e.g. -l<library> - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if - you have headers in a nonstandard directory <include dir> - CXX C++ compiler command - CXXFLAGS C++ compiler flags - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to <cygwin@cygwin.com>. -Cygwin Cygserver home page: <https://cygwin.com>. -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -Cygwin Cygserver configure 0 -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_cxx_try_compile LINENO -# ---------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by Cygwin Cygserver $as_me 0, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -ac_aux_dir= -for ac_dir in .. "$srcdir"/..; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in .. \"$srcdir\"/.." "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - -. ${srcdir}/../configure.cygwin - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 -$as_echo_n "checking target system type... " >&6; } -if ${ac_cv_target+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$target_alias" = x; then - ac_cv_target=$ac_cv_host -else - ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 -$as_echo "$ac_cv_target" >&6; } -case $ac_cv_target in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; -esac -target=$ac_cv_target -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_target -shift -target_cpu=$1 -target_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -target_os=$* -IFS=$ac_save_IFS -case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac - - -# The aliases save the names the user supplied, while $host etc. -# will get canonicalized. -test -n "$target_alias" && - test "$program_prefix$program_suffix$program_transform_name" = \ - NONENONEs,x,x, && - program_prefix=${target_alias}- - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - ac_no_link=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdio.h> -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save - -else - rm -f -r a.out a.exe b.out conftest.$ac_ext conftest.o conftest.obj conftest.dSYM - ac_no_link=yes - # Setting cross_compile will disable run tests; it will - # also disable AC_CHECK_FILE but that's generally - # correct if we can't link. - cross_compiling=yes - EXEEXT= - # Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdarg.h> -#include <stdio.h> -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -else - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - -else - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - -# Check whether --with-windows-headers was given. -if test "${with_windows_headers+set}" = set; then : - withval=$with_windows_headers; test -z "$withval" && as_fn_error $? "must specify value for --with-windows-headers" "$LINENO" 5 - -fi - - - - -# Check whether --with-windows-libs was given. -if test "${with_windows_libs+set}" = set; then : - withval=$with_windows_libs; test -z "$withval" && as_fn_error $? "must specify value for --with-windows-libs" "$LINENO" 5 - -fi - -windows_libdir=$(realdirpath "$with_windows_libs") -if test -z "$windows_libdir"; then - windows_libdir=$(realdirpath $(${ac_cv_prog_CC:-$CC} -xc /dev/null -Wl,--verbose=1 -lntdll 2>&1 | sed -rn 's%^.*\s(\S+)/libntdll\..*succeeded%\1%p')) - if test -z "$windows_libdir"; then - as_fn_error $? "cannot find windows library files" "$LINENO" 5 - fi -fi - - - - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - -addto_CPPFLAGS -nostdinc -: ${ac_cv_prog_CXX:=$CXX} -: ${ac_cv_prog_CC:=$CC} - -cygwin_headers=$(realdirpath "$winsup_srcdir/cygwin/include") -if test -z "$cygwin_headers"; then - as_fn_error $? "cannot find $winsup_srcdir/cygwin/include directory" "$LINENO" 5 -fi - -newlib_headers=$(realdirpath $winsup_srcdir/../newlib/libc/include) -if test -z "$newlib_headers"; then - as_fn_error $? "cannot find newlib source directory: $winsup_srcdir/../newlib/libc/include" "$LINENO" 5 -fi -newlib_headers="$target_builddir/newlib/targ-include $newlib_headers" - -if test -n "$with_windows_headers"; then - if test -e "$with_windows_headers/windef.h"; then - windows_headers="$with_windows_headers" - else - as_fn_error $? "cannot find windef.h in specified --with-windows-headers path: $saw_windows_headers" "$LINENO" 5; - fi -elif test -d "$winsup_srcdir/w32api/include/windef.h"; then - windows_headers="$winsup_srcdir/w32api/include" -else - windows_headers=$(cd $($ac_cv_prog_CC -xc /dev/null -E -include windef.h 2>/dev/null | sed -n 's%^# 1 "\([^"]*\)/windef\.h".*$%\1%p' | head -n1) 2>/dev/null && pwd) - if test -z "$windows_headers" -o ! -d "$windows_headers"; then - as_fn_error $? "cannot find windows header files" "$LINENO" 5 - fi -fi -CC=$ac_cv_prog_CC -CXX=$ac_cv_prog_CXX -export CC -export CXX - - - - - -case "$with_cross_host" in - ""|*cygwin*) - all_host="all_host" - install_host="install_host" - ;; - *) - all_host= - install_host= - ;; -esac - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AR"; then - ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AR" = x; then - AR="ar" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -else - AR="$ac_cv_prog_AR" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. -set dummy ${ac_tool_prefix}as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AS+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AS"; then - ac_cv_prog_AS="$AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AS="${ac_tool_prefix}as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AS=$ac_cv_prog_AS -if test -n "$AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 -$as_echo "$AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AS"; then - ac_ct_AS=$AS - # Extract the first word of "as", so it can be a program name with args. -set dummy as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AS+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AS"; then - ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AS="as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AS=$ac_cv_prog_ac_ct_AS -if test -n "$ac_ct_AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 -$as_echo "$ac_ct_AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AS" = x; then - AS="as" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AS=$ac_ct_AS - fi -else - AS="$ac_cv_prog_AS" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB="ranlib" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args. -set dummy ${ac_tool_prefix}ld; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$LD"; then - ac_cv_prog_LD="$LD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_LD="${ac_tool_prefix}ld" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -LD=$ac_cv_prog_LD -if test -n "$LD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_LD"; then - ac_ct_LD=$LD - # Extract the first word of "ld", so it can be a program name with args. -set dummy ld; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_LD"; then - ac_cv_prog_ac_ct_LD="$ac_ct_LD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_LD="ld" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_LD=$ac_cv_prog_ac_ct_LD -if test -n "$ac_ct_LD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LD" >&5 -$as_echo "$ac_ct_LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_LD" = x; then - LD="ld" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - LD=$ac_ct_LD - fi -else - LD="$ac_cv_prog_LD" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args. -set dummy ${ac_tool_prefix}nm; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NM+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NM"; then - ac_cv_prog_NM="$NM" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_NM="${ac_tool_prefix}nm" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -NM=$ac_cv_prog_NM -if test -n "$NM"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5 -$as_echo "$NM" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_NM"; then - ac_ct_NM=$NM - # Extract the first word of "nm", so it can be a program name with args. -set dummy nm; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NM+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_NM"; then - ac_cv_prog_ac_ct_NM="$ac_ct_NM" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_NM="nm" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_NM=$ac_cv_prog_ac_ct_NM -if test -n "$ac_ct_NM"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NM" >&5 -$as_echo "$ac_ct_NM" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_NM" = x; then - NM="nm" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - NM=$ac_ct_NM - fi -else - NM="$ac_cv_prog_NM" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="dlltool" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. -set dummy ${ac_tool_prefix}windres; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINDRES+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$WINDRES"; then - ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_WINDRES="${ac_tool_prefix}windres" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -WINDRES=$ac_cv_prog_WINDRES -if test -n "$WINDRES"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINDRES" >&5 -$as_echo "$WINDRES" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_WINDRES"; then - ac_ct_WINDRES=$WINDRES - # Extract the first word of "windres", so it can be a program name with args. -set dummy windres; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_WINDRES+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_WINDRES"; then - ac_cv_prog_ac_ct_WINDRES="$ac_ct_WINDRES" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_WINDRES="windres" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_WINDRES=$ac_cv_prog_ac_ct_WINDRES -if test -n "$ac_ct_WINDRES"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_WINDRES" >&5 -$as_echo "$ac_ct_WINDRES" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_WINDRES" = x; then - WINDRES="windres" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - WINDRES=$ac_ct_WINDRES - fi -else - WINDRES="$ac_cv_prog_WINDRES" -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - - -# Check whether --enable-debugging was given. -if test "${enable_debugging+set}" = set; then : - enableval=$enable_debugging; case "${enableval}" in -yes) $as_echo "#define DEBUGGING 1" >>confdefs.h - ;; -no) ;; -esac - -fi - - - -configure_args=X -for f in $ac_configure_args; do - case "$f" in - *--srcdir*) ;; - *) configure_args="$configure_args $f" ;; - esac -done -configure_args=$(/usr/bin/expr "$configure_args" : 'X \(.*\)') - - -ac_config_files="$ac_config_files Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by Cygwin Cygserver $as_me 0, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Report bugs to <cygwin@cygwin.com>. -Cygwin Cygserver home page: <https://cygwin.com>." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -Cygwin Cygserver config.status 0 -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' <conf$$subs.awk | sed ' -/^[^""]/{ - N - s/\n// -} -' >>$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - - -eval set X " :F $CONFIG_FILES " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - - - - esac - -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/winsup/cygserver/configure.ac b/winsup/cygserver/configure.ac deleted file mode 100644 index 4e2cb4582..000000000 --- a/winsup/cygserver/configure.ac +++ /dev/null @@ -1,69 +0,0 @@ -dnl Autoconf configure script for Cygserver. -dnl Copyright 2003, 2012, 2013, 2014 Red Hat, Inc. -dnl -dnl This file is part of Cygwin. -dnl -dnl This software is a copyrighted work licensed under the terms of the -dnl Cygwin license. Please consult the file "CYGWIN_LICENSE" for -dnl details. -dnl -dnl Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59)dnl -AC_INIT([Cygwin Cygserver], 0, - cygwin@cygwin.com, cygwin, https://cygwin.com) -AC_CONFIG_SRCDIR(cygserver.cc) -AC_CONFIG_AUX_DIR(..) - -. ${srcdir}/../configure.cygwin - -AC_PROG_INSTALL -AC_NO_EXECUTABLES -AC_CANONICAL_SYSTEM - -AC_PROG_CC -AC_PROG_CXX -AC_PROG_CPP -AC_LANG(C) - -AC_WINDOWS_HEADERS -AC_WINDOWS_LIBS - -AC_LANG(C++) - -AC_CYGWIN_INCLUDES - -case "$with_cross_host" in - ""|*cygwin*) - all_host="all_host" - install_host="install_host" - ;; - *) - all_host= - install_host= - ;; -esac - -AC_SUBST(all_host) -AC_SUBST(install_host) - -AC_CHECK_TOOL(AR, ar, ar) -AC_CHECK_TOOL(AS, as, as) -AC_CHECK_TOOL(RANLIB, ranlib, ranlib) -AC_CHECK_TOOL(LD, ld, ld) -AC_CHECK_TOOL(NM, nm, nm) -AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool) -AC_CHECK_TOOL(WINDRES, windres, windres) - -AC_PROG_MAKE_SET - -AC_ARG_ENABLE(debugging, -[ --enable-debugging Build a cygwin DLL which has more consistency checking for debugging], -[case "${enableval}" in -yes) AC_DEFINE(DEBUGGING) ;; -no) ;; -esac -]) - -AC_CONFIGURE_ARGS -AC_OUTPUT(Makefile) diff --git a/winsup/cygserver/cygserver-config b/winsup/cygserver/cygserver-config deleted file mode 100755 index abe943c3f..000000000 --- a/winsup/cygserver/cygserver-config +++ /dev/null @@ -1,209 +0,0 @@ -#!/bin/bash -# -# cygserver-config, Copyright 2003 Red Hat Inc. -# -# This file is part of the Cygwin DLL. - -# Directory where the config files are stored -SYSCONFDIR=/etc -LOCALSTATEDIR=/var - -progname=$0 -auto_answer="" -service_name=cygserver - -request() -{ - if [ "${auto_answer}" = "yes" ] - then - echo "$1 (yes/no) yes" - return 0 - elif [ "${auto_answer}" = "no" ] - then - echo "$1 (yes/no) no" - return 1 - fi - - answer="" - while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ] - do - echo -n "$1 (yes/no) " - read -e answer - done - if [ "X${answer}" = "Xyes" ] - then - return 0 - else - return 1 - fi -} - -# Check options - -while : -do - case $# in - 0) - break - ;; - esac - - option=$1 - shift - - case "${option}" in - -d | --debug ) - set -x - ;; - - -y | --yes ) - auto_answer=yes - ;; - - -n | --no ) - auto_answer=no - ;; - - -N | --name ) - service_name=$1 - shift - ;; - - *) - echo "usage: ${progname} [OPTION]..." - echo - echo "This script creates an Cygserver service configuration." - echo - echo "Options:" - echo " --debug -d Enable shell's debug output." - echo " --yes -y Answer all questions with \"yes\" automatically." - echo " --no -n Answer all questions with \"no\" automatically." - echo " --name -N <name> cygserver windows service name." - echo - exit 1 - ;; - - esac -done - -# Check if running on NT -_sys="`uname`" -_nt=`expr "${_sys}" : "CYGWIN_NT"` - -# Check for running cygserver processes first. -if ps -ef | grep -v grep | grep -q ${service_name} -then - echo - echo "There is a cygserver (${service_name}) already running. Nothing to do, apparently." - echo - exit 1 -fi - -# Check for ${SYSCONFDIR} directory -if [ -e "${SYSCONFDIR}" -a ! -d "${SYSCONFDIR}" ] -then - echo - echo "${SYSCONFDIR} is existant but not a directory." - echo "Cannot create global configuration file." - echo - exit 1 -fi - -# Create it if necessary -if [ ! -e "${SYSCONFDIR}" ] -then - mkdir "${SYSCONFDIR}" - if [ ! -e "${SYSCONFDIR}" ] - then - echo - echo "Creating ${SYSCONFDIR} directory failed" - echo - exit 1 - fi -fi - -# Create /var/log if not already existing -if [ -f ${LOCALSTATEDIR}/log ] -then - echo "Creating ${LOCALSTATEDIR}/log failed!" -else - if [ ! -d ${LOCALSTATEDIR}/log ] - then - mkdir -p ${LOCALSTATEDIR}/log - fi -fi - -# Check if cygserver.conf exists. If yes, ask for overwriting -if [ -f "${SYSCONFDIR}/cygserver.conf" ] -then - if request "Overwrite existing ${SYSCONFDIR}/cygserver.conf file?" - then - rm -f "${SYSCONFDIR}/cygserver.conf" - if [ -f "${SYSCONFDIR}/cygserver.conf" ] - then - echo - echo "Can't overwrite. ${SYSCONFDIR}/cygserver.conf is write protected." - echo - exit 1 - fi - fi -fi - -# Create default cygserver.conf from skeleton files in /etc/defaults/etc -if [ ! -f "${SYSCONFDIR}/cygserver.conf" ] -then - echo "Generating ${SYSCONFDIR}/cygserver.conf file" - cp "${SYSCONFDIR}/defaults/etc/cygserver.conf" "${SYSCONFDIR}/cygserver.conf" - if [ ! -f "${SYSCONFDIR}/cygserver.conf" ] - then - echo - echo "Couldn't create ${SYSCONFDIR}/cygserver.conf." - echo "Perhaps there's no default file in ${SYSCONFDIR}/defaults/etc?" - echo "Reinstalling Cygwin might help." - echo - exit 1 - fi - chmod 664 "${SYSCONFDIR}/cygserver.conf" - chown 18.544 "${SYSCONFDIR}/cygserver.conf" -fi - -# On NT ask if cygserver should be installed as service -if [ ${_nt} -gt 0 ] -then - # But only if it is not already installed - if ! cygrunsrv -Q ${service_name} > /dev/null 2>&1 - then - echo - echo - echo "Warning: The following function requires administrator privileges!" - echo - echo "Do you want to install cygserver as service?" - if request "(Say \"no\" if it's already installed as service)" - then - if ! cygrunsrv -I ${service_name} -d "CYGWIN cygserver" -p /usr/sbin/cygserver - then - echo - echo "Installation of cygserver as service failed. Please check the" - echo "error messages you got. They might give a clue why it failed." - echo - echo "A good start is either you don't have administrator privileges" - echo "or a missing cygrunsrv binary. Please check for both." - echo - exit 1 - fi - echo - echo "The service has been installed under LocalSystem account." - echo "To start it, call \`net start ${service_name}' or \`cygrunsrv -S ${service_name}'." - fi - touch "${LOCALSTATEDIR}/log/cygserver.log" - chown 18.544 "${LOCALSTATEDIR}/log/cygserver.log" - fi -fi - -echo -echo "Further configuration options are available by editing the configuration" -echo "file ${SYSCONFDIR}/cygserver.conf. Please read the inline information in that" -echo "file carefully. The best option for the start is to just leave it alone." -echo -echo "Basic Cygserver configuration finished. Have fun!" -echo diff --git a/winsup/cygserver/cygserver.cc b/winsup/cygserver/cygserver.cc deleted file mode 100644 index 45048ed3c..000000000 --- a/winsup/cygserver/cygserver.cc +++ /dev/null @@ -1,762 +0,0 @@ -/* cygserver.cc - - Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2011, 2012, 2014 Red Hat Inc. - - Written by Egor Duda <deo@logos-m.ru> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <sys/types.h> - -#include <assert.h> -#include <errno.h> -#include <ctype.h> -#include <getopt.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "cygwin_version.h" - -#include "cygserver.h" -#include "process.h" -#include "transport.h" - -#include "cygserver_ipc.h" -#include "cygserver_msg.h" -#include "cygserver_sem.h" - -#define DEF_CONFIG_FILE "" SYSCONFDIR "/cygserver.conf" - -#define SERVER_VERSION "1.20" - -GENERIC_MAPPING access_mapping; - -static bool -setup_privileges () -{ - BOOL rc, ret_val; - HANDLE hToken = NULL; - TOKEN_PRIVILEGES sPrivileges; - - rc = OpenProcessToken (GetCurrentProcess () , TOKEN_ALL_ACCESS , &hToken) ; - if (!rc) - { - debug ("error opening process token (err %u)", GetLastError ()); - return false; - } - rc = LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &sPrivileges.Privileges[0].Luid); - if (!rc) - { - debug ("error getting privilege luid (err %u)", GetLastError ()); - ret_val = false; - goto out; - } - sPrivileges.PrivilegeCount = 1 ; - sPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED ; - rc = AdjustTokenPrivileges (hToken, FALSE, &sPrivileges, 0, NULL, NULL) ; - if (!rc) - { - debug ("error adjusting privilege level. (err %u)", GetLastError ()); - ret_val = false; - goto out; - } - - access_mapping.GenericRead = FILE_READ_DATA; - access_mapping.GenericWrite = FILE_WRITE_DATA; - access_mapping.GenericExecute = 0; - access_mapping.GenericAll = FILE_READ_DATA | FILE_WRITE_DATA; - - ret_val = true; - -out: - CloseHandle (hToken); - return ret_val; -} - -int -check_and_dup_handle (HANDLE from_process, HANDLE to_process, - HANDLE from_process_token, - DWORD access, - HANDLE from_handle, - HANDLE *to_handle_ptr, BOOL bInheritHandle = FALSE) -{ - HANDLE local_handle = NULL; - int ret_val = EACCES; - char sd_buf [1024]; - PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR) &sd_buf; - DWORD bytes_needed; - PRIVILEGE_SET ps; - DWORD ps_len = sizeof (ps); - BOOL status; - - if (from_process != GetCurrentProcess ()) - { - if (!DuplicateHandle (from_process, from_handle, - GetCurrentProcess (), &local_handle, - 0, bInheritHandle, - DUPLICATE_SAME_ACCESS)) - { - log (LOG_ERR, "error getting handle(%p) to server (err %u)", - from_handle, GetLastError ()); - goto out; - } - } else - local_handle = from_handle; - - if (!GetKernelObjectSecurity (local_handle, - (OWNER_SECURITY_INFORMATION - | GROUP_SECURITY_INFORMATION - | DACL_SECURITY_INFORMATION), - sd, sizeof (sd_buf), &bytes_needed)) - { - log (LOG_ERR, "error getting handle SD (err %u)", GetLastError ()); - goto out; - } - - MapGenericMask (&access, &access_mapping); - - if (!AccessCheck (sd, from_process_token, access, &access_mapping, - &ps, &ps_len, &access, &status)) - { - log (LOG_ERR, "error checking access rights (err %u)", GetLastError ()); - goto out; - } - - if (!status) - { - log (LOG_ERR, "access to object denied"); - goto out; - } - - if (!DuplicateHandle (from_process, from_handle, - to_process, to_handle_ptr, - access, bInheritHandle, 0)) - { - log (LOG_ERR, "error getting handle to client (err %u)", GetLastError ()); - goto out; - } - - debug ("Duplicated %p to %p", from_handle, *to_handle_ptr); - - ret_val = 0; - - out: - if (local_handle && from_process != GetCurrentProcess ()) - CloseHandle (local_handle); - - return (ret_val); -} - -/* - * client_request_attach_tty::serve () - */ - -void -client_request_attach_tty::serve (transport_layer_base *const conn, - process_cache *) -{ - assert (conn); - - assert (!error_code ()); - - if (msglen () != sizeof (req)) - { - log (LOG_ERR, "bad request body length: expecting %lu bytes, got %lu", - sizeof (req), msglen ()); - error_code (EINVAL); - msglen (0); - return; - } - - msglen (0); // Until we fill in some fields. - - debug ("pid %d:(%p,%p) -> pid %d", req.master_pid, req.from_master, - req.to_master, req.pid); - - debug ("opening process %d", req.master_pid); - - const HANDLE from_process_handle = - OpenProcess (PROCESS_DUP_HANDLE, FALSE, req.master_pid); - - if (!from_process_handle) - { - log (LOG_ERR, "error opening `from' process (err %u)", GetLastError ()); - error_code (EACCES); - return; - } - - debug ("opening process %d", req.pid); - - const HANDLE to_process_handle = - OpenProcess (PROCESS_DUP_HANDLE, FALSE, req.pid); - - if (!to_process_handle) - { - log (LOG_ERR, "error opening `to' process (err %u)", GetLastError ()); - CloseHandle (from_process_handle); - error_code (EACCES); - return; - } - - debug ("Impersonating client"); - if (!conn->impersonate_client ()) - { - CloseHandle (from_process_handle); - CloseHandle (to_process_handle); - error_code (EACCES); - return; - } - - HANDLE token_handle = NULL; - - debug ("about to open thread token"); - const DWORD rc = OpenThreadToken (GetCurrentThread (), - TOKEN_QUERY, - TRUE, - &token_handle); - - debug ("opened thread token, rc=%u", rc); - if (!conn->revert_to_self ()) - { - CloseHandle (from_process_handle); - CloseHandle (to_process_handle); - error_code (EACCES); - return; - } - - if (!rc) - { - log (LOG_ERR, "error opening thread token (err %u)", GetLastError ()); - CloseHandle (from_process_handle); - CloseHandle (to_process_handle); - error_code (EACCES); - return; - } - - // From this point on, a reply body is returned to the client. - - const HANDLE from_master = req.from_master; - const HANDLE to_master = req.to_master; - - req.from_master = NULL; - req.to_master = NULL; - - msglen (sizeof (req)); - - if (from_master) - if (check_and_dup_handle (from_process_handle, to_process_handle, - token_handle, - GENERIC_READ, - from_master, - &req.from_master, TRUE) != 0) - { - log (LOG_ERR, "error duplicating from_master handle (err %u)", - GetLastError ()); - error_code (EACCES); - } - - if (to_master) - if (check_and_dup_handle (from_process_handle, to_process_handle, - token_handle, - GENERIC_WRITE, - to_master, - &req.to_master, TRUE) != 0) - { - log (LOG_ERR, "error duplicating to_master handle (err %u)", - GetLastError ()); - error_code (EACCES); - } - - CloseHandle (from_process_handle); - CloseHandle (to_process_handle); - CloseHandle (token_handle); - - debug ("%u(%p, %p) -> %u(%p,%p)", req.master_pid, from_master, to_master, - req.pid, req.from_master, req.to_master); - - return; -} - -void -client_request_get_version::serve (transport_layer_base *, process_cache *) -{ - assert (!error_code ()); - - if (msglen ()) - log (LOG_ERR, "unexpected request body ignored: %lu bytes", msglen ()); - - msglen (sizeof (version)); - - version.major = CYGWIN_SERVER_VERSION_MAJOR; - version.api = CYGWIN_SERVER_VERSION_API; - version.minor = CYGWIN_SERVER_VERSION_MINOR; - version.patch = CYGWIN_SERVER_VERSION_PATCH; -} - -class server_request : public queue_request -{ -public: - server_request (transport_layer_base *const conn, process_cache *const cache) - : _conn (conn), _cache (cache) - {} - - virtual ~server_request () - { - delete _conn; - } - - virtual void process () - { - client_request::handle_request (_conn, _cache); - } - -private: - transport_layer_base *const _conn; - process_cache *const _cache; -}; - -class server_submission_loop : public queue_submission_loop -{ -public: - server_submission_loop (threaded_queue *const queue, - transport_layer_base *const transport, - process_cache *const cache) - : queue_submission_loop (queue, false), - _transport (transport), - _cache (cache) - { - assert (_transport); - assert (_cache); - } - -private: - transport_layer_base *const _transport; - process_cache *const _cache; - - virtual void request_loop (); -}; - -/* FIXME: this is a little ugly. What we really want is to wait on - * two objects: one for the pipe/socket, and one for being told to - * shutdown. Otherwise this will stay a problem (we won't actually - * shutdown until the request _AFTER_ the shutdown request. And - * sending ourselves a request is ugly - */ -void -server_submission_loop::request_loop () -{ - /* I'd like the accepting thread's priority to be above any "normal" - * thread in the system to avoid overflowing the listen queue (for - * sockets; similar issues exist for named pipes); but, for example, - * a normal priority thread in a foregrounded process is boosted to - * THREAD_PRIORITY_HIGHEST (AFAICT). Thus try to set the current - * thread's priority to a level one above that. This fails on - * win9x/ME so assume any failure in that call is due to that and - * simply call again at one priority level lower. - * FIXME: This looks weird and is an issue on NT, too. Per MSDN, - * THREAD_PRIORITY_HIGHEST + 1 is only a valid priority level if - * the priority class is set to REALTIME_PRIORITY_CLASS. - */ - if (!SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST + 1)) - if (!SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST)) - debug ("failed to raise accept thread priority (err %u)", - GetLastError ()); - - while (_running) - { - bool recoverable = false; - transport_layer_base *const conn = _transport->accept (&recoverable); - if (!conn && !recoverable) - { - log (LOG_ERR, "fatal error on IPC transport: closing down"); - return; - } - // EINTR probably implies a shutdown request; so back off for a - // moment to let the main thread take control, otherwise the - // server spins here receiving EINTR repeatedly since the signal - // handler in the main thread doesn't get a chance to be called. - if (!conn && errno == EINTR) - { - if (!SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL)) - debug ("failed to reset thread priority (err %u)", - GetLastError ()); - - Sleep (0); - if (!SetThreadPriority (GetCurrentThread (), - THREAD_PRIORITY_HIGHEST + 1)) - if (!SetThreadPriority (GetCurrentThread (), - THREAD_PRIORITY_HIGHEST)) - debug ("failed to raise thread priority (err %u)", - GetLastError ()); - } - if (conn) - _queue->add (new server_request (conn, _cache)); - } -} - -client_request_shutdown::client_request_shutdown () - : client_request (CYGSERVER_REQUEST_SHUTDOWN) -{ -} - -void -client_request_shutdown::serve (transport_layer_base *, process_cache *) -{ - assert (!error_code ()); - - if (msglen ()) - log (LOG_ERR, "unexpected request body ignored: %lu bytes", msglen ()); - - /* FIXME: link upwards, and then this becomes a trivial method call to - * only shutdown _this queue_ - */ - - kill (getpid (), SIGINT); - - msglen (0); -} - -static sig_atomic_t shutdown_server = false; - -static void -handle_signal (const int signum) -{ - /* any signal makes us die :} */ - - shutdown_server = true; -} - -/* - * print_usage () - */ - -static void -print_usage (const char *const pgm) -{ - log (LOG_NOTICE, "Usage: %s [OPTIONS]\n" -"\n" -"Cygwin background service daemon\n" -"\n" -"Configuration option:\n" -"\n" -" -f, --config-file <file> Use <file> as config file. Default is\n" -" " DEF_CONFIG_FILE "\n" -"\n" -"Performance options:\n" -"\n" -" -c, --cleanup-threads <num> Number of cleanup threads to use.\n" -" -p, --process-cache <num> Size of process cache.\n" -" -r, --request-threads <num> Number of request threads to use.\n" -"\n" -"Logging options:\n" -"\n" -" -d, --debug Log debug messages to stderr.\n" -" -e, --stderr Log to stderr (default if stderr is a tty).\n" -" -E, --no-stderr Don't log to stderr (see -y, -Y options).\n" -" -l, --log-level <level> Verbosity of logging (1..7). Default: 6\n" -" -y, --syslog Log to syslog (default if stderr is no tty).\n" -" -Y, --no-syslog Don't log to syslog (See -e, -E options).\n" -"\n" -"Support options:\n" -"\n" -" -m, --no-sharedmem Don't start XSI Shared Memory support.\n" -" -q, --no-msgqueues Don't start XSI Message Queue support.\n" -" -s, --no-semaphores Don't start XSI Semaphore support.\n" -"\n" -"Miscellaneous:\n" -"\n" -" -S, --shutdown Shutdown the daemon.\n" -" -h, --help Output usage information and exit.\n" -" -V, --version Output version information and exit.\n" -, pgm); -} - -/* - * print_version () - */ - -static void -print_version () -{ - log (LOG_INFO, - "cygserver (cygwin) %d.%d.%d\n" - "Cygwin background service daemon\n" - "Copyright (C) 2001 - %s Red Hat, Inc.\n" - "This is free software; see the source for copying conditions. There is NO\n" - "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.", - CYGWIN_VERSION_DLL_MAJOR / 1000, - CYGWIN_VERSION_DLL_MAJOR % 1000, - CYGWIN_VERSION_DLL_MINOR, - strrchr (__DATE__, ' ') + 1); -} - -/* - * main () - */ - -int -main (const int argc, char *argv[]) -{ - const struct option longopts[] = { - {"cleanup-threads", required_argument, NULL, 'c'}, - {"debug", no_argument, NULL, 'd'}, - {"stderr", no_argument, NULL, 'e'}, - {"no-stderr", no_argument, NULL, 'E'}, - {"config-file", required_argument, NULL, 'f'}, - {"help", no_argument, NULL, 'h'}, - {"log-level", required_argument, NULL, 'l'}, - {"no-sharedmem", no_argument, NULL, 'm'}, - {"process-cache", required_argument, NULL, 'p'}, - {"no-msgqueues", no_argument, NULL, 'q'}, - {"request-threads", required_argument, NULL, 'r'}, - {"no-semaphores", no_argument, NULL, 's'}, - {"shutdown", no_argument, NULL, 'S'}, - {"version", no_argument, NULL, 'V'}, - {"syslog", no_argument, NULL, 'y'}, - {"no-syslog", no_argument, NULL, 'Y'}, - {0, no_argument, NULL, 0} - }; - - const char opts[] = "c:deEf:hl:mp:qr:sSVyY"; - - int32_t cleanup_threads = 0; - int32_t request_threads = 0; - int32_t process_cache_size = 0; - bool shutdown = false; - const char *config_file = DEF_CONFIG_FILE; - bool force_config_file = false; - tun_bool_t option_log_stderr = TUN_UNDEF; - tun_bool_t option_log_syslog = TUN_UNDEF; - - char *c = NULL; - - /* Check if we have a terminal. If so, default to stderr logging, - otherwise default to syslog logging. This must be done early - to allow default logging already in option processing state. */ - openlog ("cygserver", LOG_PID, LOG_KERN); - if (isatty (2)) - log_stderr = TUN_TRUE; - else - log_syslog = TUN_TRUE; - - int opt; - - securityinit (); - - opterr = 0; - while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != EOF) - switch (opt) - { - case 'c': - c = NULL; - cleanup_threads = strtol (optarg, &c, 10); - if (cleanup_threads <= 0 || cleanup_threads > 32 || (c && *c)) - panic ("Number of cleanup threads must be between 1 and 32"); - break; - - case 'd': - log_debug = TUN_TRUE; - break; - - case 'e': - option_log_stderr = TUN_TRUE; - break; - - case 'E': - option_log_stderr = TUN_FALSE; - break; - - case 'f': - config_file = optarg; - force_config_file = true; - break; - - case 'h': - print_usage (getprogname ()); - return 0; - - case 'l': - c = NULL; - log_level = strtoul (optarg, &c, 10); - if (!log_level || log_level > 7 || (c && *c)) - panic ("Log level must be between 1 and 7"); - break; - - case 'm': - support_sharedmem = TUN_FALSE; - break; - - case 'p': - c = NULL; - process_cache_size = strtol (optarg, &c, 10); - if (process_cache_size <= 0 || process_cache_size > 310 || (c && *c)) - panic ("Size of process cache must be between 1 and 310"); - break; - - case 'q': - support_msgqueues = TUN_FALSE; - break; - - case 'r': - c = NULL; - request_threads = strtol (optarg, &c, 10); - if (request_threads <= 0 || request_threads > 310 || (c && *c)) - panic ("Number of request threads must be between 1 and 310"); - break; - - case 's': - support_semaphores = TUN_FALSE; - break; - - case 'S': - shutdown = true; - break; - - case 'V': - print_version (); - return 0; - - case 'y': - option_log_syslog = TUN_TRUE; - break; - - case 'Y': - option_log_syslog = TUN_FALSE; - break; - - case '?': - panic ("unknown option -- %c\n" - "Try `%s --help' for more information.", optopt, getprogname ()); - } - - if (optind != argc) - panic ("Too many arguments"); - - if (shutdown) - { - /* Setting `cygserver_running' stops the request code making a - * version request, which is not much to the point. - */ - cygserver_running = CYGSERVER_OK; - - client_request_shutdown req; - - if (req.make_request () == -1 || req.error_code ()) - panic("Shutdown request failed: %s", strerror (req.error_code ())); - - // FIXME: It would be nice to wait here for the daemon to exit. - - return 0; - } - - SIGHANDLE (SIGHUP); - SIGHANDLE (SIGINT); - SIGHANDLE (SIGTERM); - - tunable_param_init (config_file, force_config_file); - - loginit (option_log_stderr, option_log_syslog); - - log (LOG_INFO, "daemon starting up"); - - if (!cleanup_threads) - TUNABLE_INT_FETCH ("kern.srv.cleanup_threads", &cleanup_threads); - if (!cleanup_threads) - cleanup_threads = 2; - - if (!request_threads) - TUNABLE_INT_FETCH ("kern.srv.request_threads", &request_threads); - if (!request_threads) - request_threads = 10; - - if (!process_cache_size) - TUNABLE_INT_FETCH ("kern.srv.process_cache_size", &process_cache_size); - if (!process_cache_size) - process_cache_size = 62; - - if (support_sharedmem == TUN_UNDEF) - TUNABLE_BOOL_FETCH ("kern.srv.sharedmem", &support_sharedmem); - if (support_sharedmem == TUN_UNDEF) - support_sharedmem = TUN_TRUE; - - if (support_msgqueues == TUN_UNDEF) - TUNABLE_BOOL_FETCH ("kern.srv.msgqueues", &support_msgqueues); - if (support_msgqueues == TUN_UNDEF) - support_msgqueues = TUN_TRUE; - - if (support_semaphores == TUN_UNDEF) - TUNABLE_BOOL_FETCH ("kern.srv.semaphores", &support_semaphores); - if (support_semaphores == TUN_UNDEF) - support_semaphores = TUN_TRUE; - - if (!setup_privileges ()) - panic ("Setting process privileges failed."); - - ipcinit (); - - /*XXXXX*/ - threaded_queue request_queue (request_threads); - - transport_layer_base *const transport = create_server_transport (); - assert (transport); - - if (transport->listen () == -1) - return 1; - - process_cache cache (process_cache_size, cleanup_threads); - - server_submission_loop submission_loop (&request_queue, transport, &cache); - - request_queue.add_submission_loop (&submission_loop); - - cache.start (); - - request_queue.start (); - - log (LOG_NOTICE, "Initialization complete. Waiting for requests."); - - /* TODO: wait on multiple objects - the thread handle for each - * request loop + all the process handles. This should be done by - * querying the request_queue and the process cache for all their - * handles, and then waiting for (say) 30 seconds. after that we - * recreate the list of handles to wait on, and wait again. the - * point of all this abstraction is that we can trivially server - * both sockets and pipes simply by making a new transport, and then - * calling request_queue.process_requests (transport2); - */ - /* WaitForMultipleObjects abort && request_queue && process_queue && signal - -- if signal event then retrigger it - */ - while (!shutdown_server && request_queue.running () && cache.running ()) - { - pause (); - if (ipcunload ()) - { - shutdown_server = false; - log (LOG_WARNING, "Shutdown request received but ignored. " - "Dependent processes still running."); - } - } - - log (LOG_INFO, "Shutdown request received - new requests will be denied"); - request_queue.stop (); - log (LOG_INFO, "All pending requests processed"); - delete transport; - log (LOG_INFO, "No longer accepting requests - cygwin will operate in daemonless mode"); - cache.stop (); - log (LOG_INFO, "All outstanding process-cache activities completed"); - log (LOG_NOTICE, "Shutdown finished."); - - return 0; -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/cygserver.conf b/winsup/cygserver/cygserver.conf deleted file mode 100644 index 589931b11..000000000 --- a/winsup/cygserver/cygserver.conf +++ /dev/null @@ -1,147 +0,0 @@ -# cygserver.conf, Copyright(C) 2003, 2005 Red Hat Inc. -# -# Contains configurable parameters for the cygserver. -# -# The format of this file is easy. Lines beginning with a hash `#' are -# comments and ignored. Lines consisting of only whitespaces are ignored. -# Any other line is a setting for cygserver. -# A setting consists of a name/value pair, separated by whitespace. -# Each line must only consist of one name/value pair. -# Lines must not be longer than 1023 characters. -# -# Some settings can be overridden by a command line switch. If so, it's -# mentioned below. -# -# Settings which are commented out will use the default values. These are -# mentioned below, too. - -# kern.srv.cleanup_threads: No. of cygserver threads used for cleanup tasks. -# Default: 2, Min: 1, Max: 16, command line option -c, --cleanup-threads -#kern.srv.cleanup_threads 2 - -# kern.srv.request_threads: No. of cygserver threads used to serve -# application requests. -# Default: 10, Min: 1, Max: 310, command line option -r, --request-threads -#kern.srv.request_threads 10 - -# kern.srv.process_cache_size: No. of concurrent processes which can be handled -# by Cygserver concurrently. -# Default: 62, Min: 1, Max: 310, command line option -p, --process-cache -#kern.srv.process_cache_size 62 - -# kern.srv.msgqueues: Determines whether XSI Message Queue support should be -# started, "yes" (or "true", "y", "t", "1") or "no" (or "false", "n", "f", "0"). -# These values are valid for all binary type options. -# Default is "yes". Command line option -q, --no-msgqueues -#kern.srv.msgqueues yes - -# kern.srv.semaphores: Determines whether XSI Semaphore support should be -# started. Default is "yes". Command line option -s, --no-semaphores -#kern.srv.semaphores yes - -# kern.srv.sharedmem: Determines whether XSI Shared Memory support should be -# started. Default is "yes". Command line option -m, --no-sharedmem -#kern.srv.sharedmem yes - -# LOGGING - -# kern.log.syslog: Determines whether logging should go to the syslog, -# Default is "yes", if stderr is no tty, "no" otherwise. -# Command line option -y, --syslog or -Y, --no-syslog. -#kern.log.syslog no - -# kern.log.stderr: Determines whether logging should go to stderr, -# Default is "yes", if stderr is a tty, "no" otherwise. -# Command line option -e, --stderr or -E, --no-stderr. -#kern.log.stderr no - -# kern.log.level: Logging level. Valid values are 1 to 7 with a bigger -# value emitting more logging output. Default level is 6. -# Command line option -l, --log-level. -#kern.log.level 6 - -# kern.log.debug: Determines whether debug output should be printed to stderr. -# Default is "no". Command line option -d, --debug -#kern.log.debug no - -# XSI message queue parameters. -# -# Each message is broken up and stored in segments that are msgssz bytes -# long. For efficiency reasons, this should be a power of two. Also, -# it doesn't make sense if it is less than 8 or greater than about 256. - -# kern.ipc.msgseg: Maximum no. of message queue segments hold concurrently. -# Default: 2048, Min: 256, Max: 65535 -#kern.ipc.msgseg 2048 - -# kern.ipc.msgssz: Size of segment in bytes. Must be a power of 2 value. -# Default: 8, Min: 8, Max: 1024 -#kern.ipc.msgssz 8 - -# kern.ipc.msgmnb: Maximum no. of bytes in a single message queue. -# Default: 2048, Min: 1, Max: 65535 -#kern.ipc.msgmnb 2048 - -# kern.ipc.msgmni: Maximum no. of message queue identifiers hold concurrently. -# Default: 40, Min: 1, Max: 1024 -#kern.ipc.msgmni 40 - -# kern.ipc.msgtql: Maximum no. of messages hold concurrently. -# Default: 40, Min: 1, Max: 1024 -#kern.ipc.msgtql 40 - -# XSI semaphore parameters - -# kern.ipc.semmni: Maximum no. of semaphore identifiers hold concurrently. -# Default: 10, Min: 1, Max: 1024 -#kern.ipc.semmni 10 - -# kern.ipc.semmns: Maximum no. of semaphores hold concurrently. -# Default: 60, Min: 1, Max: 1024 -#kern.ipc.semmns 60 - -# kern.ipc.semmnu: Total no. of undo structures hold by server. -# Default: 30, Min: 1, Max: 1024 -#kern.ipc.semmnu 30 - -# kern.ipc.semmsl: Maximum no. of semaphores per semaphore id. -# Default: 60, Min: 1, Max: 1024 -#kern.ipc.semmsl 60 - -# kern.ipc.semopm: Maximum no. of operations per semop call. -# Default: 100, Min: 1, Max: 1024 -#kern.ipc.semopm 100 - -# kern.ipc.semume: Maximum no. of undo entries per process. -# Default: 10, Min: 1, Max: 1024 -#kern.ipc.semume 10 - -# kern.ipc.semvmx: Maximum value of a semaphore. -# Default: 32767, Min: 1, Max: 32767 -#kern.ipc.semvmx 32767 - -# kern.ipc.semaem: Maximum value to adjust on process exit. -# Default: 16384, Min: 1, Max: 32767 -#kern.ipc.semaem 16384 - -# XSI shared memory parameters - -# kern.ipc.shmmaxpgs: Maximum pages available for XSI shared memory. -# Changing shmmaxpgs immediately affects setting SHMMAX. The relation -# between shmmaxpgs and SHMMAX is: SHMMAX = shmmaxpgs * getpagesize(). -# Default: 8192, Min: 1, Max: 32767 -#kern.ipc.shmmaxpgs 8192 - -# kern.ipc.shmmni: Maximum number of shared memory segments, system wide. -# Default: 192, Min: 1, Max: 32767 -#kern.ipc.shmmni 192 - -# kern.ipc.shmseg: Maximum number of shared memory segments per process. -# Default: 128, Min: 1, Max: 32767 -#kern.ipc.shmseg 128 - -# kern.ipc.shm_allow_removed: Determines whether a process is allowed to -# attach to a shared memory segment (using the shmat call) after a successful -# call to shmctl(IPC_RMID). This is a Linux-specific, and therefore -# non-portable feature. Use with care. Default is "no". -#kern.ipc.shm_allow_removed no diff --git a/winsup/cygserver/msg.cc b/winsup/cygserver/msg.cc deleted file mode 100644 index c92e698b0..000000000 --- a/winsup/cygserver/msg.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* msg.cc: Single unix specification IPC interface for Cygwin. - - Copyright 2003, 2004, 2012 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <errno.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#include "cygserver.h" -#include "process.h" -#include "transport.h" - -#include "cygserver_ipc.h" -#include "cygserver_msg.h" - -client_request_msg::client_request_msg () - : client_request (CYGSERVER_REQUEST_MSG, - &_parameters, sizeof (_parameters)) -{ -} - -void -client_request_msg::serve (transport_layer_base *const conn, - process_cache *const cache) -{ - if (msglen () != sizeof (_parameters.in)) - { - syscall_printf ("bad request body length: expecting %lu bytes, got %lu", - sizeof (_parameters), msglen ()); - error_code (EINVAL); - msglen (0); - return; - } - if (support_msgqueues == TUN_FALSE) - { - syscall_printf ("Message queue support not started"); - error_code (ENOSYS); - if (_parameters.in.msgop == MSGOP_msgrcv) - _parameters.out.rcv = -1; - else - _parameters.out.ret = -1; - msglen (sizeof (_parameters.out)); - return; - } - process *const client = cache->process (_parameters.in.ipcblk.cygpid, - _parameters.in.ipcblk.winpid, - _parameters.in.ipcblk.signal_arrived); - if (!client) - { - error_code (EAGAIN); - msglen (0); - return; - } - if (!conn->impersonate_client ()) - { - client->release (); - error_code (EACCES); - msglen (0); - return; - } - if (!adjust_identity_info (&_parameters.in.ipcblk)) - { - client->release (); - conn->revert_to_self (); - error_code (EACCES); - msglen (0); - return; - } - /* Early revert_to_self since IPC code runs in kernel mode. */ - conn->revert_to_self (); - /* sysv_msg.cc takes care of itself. */ - client->release (); - thread td = { client, &_parameters.in.ipcblk, {-1, -1} }; - int res; - msgop_t msgop = _parameters.in.msgop; /* Get's overwritten otherwise. */ - switch (msgop) - { - case MSGOP_msgctl: - res = msgctl (&td, &_parameters.in.ctlargs); - break; - case MSGOP_msgget: - res = msgget (&td, &_parameters.in.getargs); - break; - case MSGOP_msgrcv: - res = msgrcv (&td, &_parameters.in.rcvargs); - break; - case MSGOP_msgsnd: - res = msgsnd (&td, &_parameters.in.sndargs); - break; - default: - res = ENOSYS; - td.td_retval[0] = -1; - break; - } - /* Allocated by the call to adjust_identity_info(). */ - if (_parameters.in.ipcblk.gidlist) - free (_parameters.in.ipcblk.gidlist); - error_code (res); - if (msgop == MSGOP_msgrcv) - _parameters.out.rcv = td.td_retval[0]; - else - _parameters.out.ret = td.td_retval[0]; - msglen (sizeof (_parameters.out)); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/process.cc b/winsup/cygserver/process.cc deleted file mode 100644 index 12989a8d4..000000000 --- a/winsup/cygserver/process.cc +++ /dev/null @@ -1,499 +0,0 @@ -/* process.cc - - Copyright 2001, 2002, 2003, 2004, 2005, 2014 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <sys/types.h> - -#include <assert.h> -#include <stdlib.h> - -#include "process.h" - -/*****************************************************************************/ - -#define elements(ARRAY) (sizeof (ARRAY) / sizeof (*ARRAY)) - -/*****************************************************************************/ - -process_cleanup::~process_cleanup () -{ - delete _process; -} - -void -process_cleanup::process () -{ - _process->cleanup (); -} - -/*****************************************************************************/ - -process::process (const pid_t cygpid, const DWORD winpid, HANDLE signal_arrived) - : _cygpid (cygpid), - _winpid (winpid), - _hProcess (NULL), - _signal_arrived (INVALID_HANDLE_VALUE), - _cleaning_up (false), - _exit_status (STILL_ACTIVE), - _routines_head (NULL), - _next (NULL) -{ - _hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, winpid); - if (!_hProcess) - { - system_printf ("unable to obtain handle for new cache process %d(%u)", - _cygpid, _winpid); - _hProcess = INVALID_HANDLE_VALUE; - _exit_status = 0; - } - else - debug_printf ("got handle %p for new cache process %d(%u)", - _hProcess, _cygpid, _winpid); - if (!signal_arrived) - debug_printf ("signal_arrived NULL for process %d(%u)", _cygpid, _winpid); - else if (signal_arrived != INVALID_HANDLE_VALUE) - { - if (!DuplicateHandle (_hProcess, signal_arrived, - GetCurrentProcess (), &_signal_arrived, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - system_printf ("error getting signal_arrived to server (%u)", - GetLastError ()); - _signal_arrived = INVALID_HANDLE_VALUE; - } - } - InitializeCriticalSection (&_access); - debug ("initialized (%u)", _cygpid); -} - -process::~process () -{ - debug ("deleting (%u)", _cygpid); - DeleteCriticalSection (&_access); - if (_signal_arrived && _signal_arrived != INVALID_HANDLE_VALUE) - CloseHandle (_signal_arrived); - CloseHandle (_hProcess); -} - -/* No need to be thread-safe as this is only ever called by - * process_cache::check_and_remove_process (). If it has to be made - * thread-safe later on, it should not use the `access' critical section as - * that is held by the client request handlers for an arbitrary length of time, - * i.e. while they do whatever processing is required for a client request. - */ -DWORD -process::check_exit_code () -{ - if (_hProcess && _hProcess != INVALID_HANDLE_VALUE - && _exit_status == STILL_ACTIVE - && !GetExitCodeProcess (_hProcess, &_exit_status)) - { - system_printf ("failed to retrieve exit code for %d(%u), error = %u", - _cygpid, _winpid, GetLastError ()); - _hProcess = INVALID_HANDLE_VALUE; - } - return _exit_status; -} - -bool -process::add (cleanup_routine *const entry) -{ - assert (entry); - - bool res = false; - hold (); - - if (!_cleaning_up) - { - entry->_next = _routines_head; - _routines_head = entry; - res = true; - } - - release (); - return res; -} - -bool -process::remove (const cleanup_routine *const entry) -{ - assert (entry); - - bool res = false; - hold (); - - if (!_cleaning_up) - { - cleanup_routine *previous = NULL; - - for (cleanup_routine *ptr = _routines_head; - ptr; - previous = ptr, ptr = ptr->_next) - { - if (*ptr == *entry) - { - if (previous) - previous->_next = ptr->_next; - else - _routines_head = ptr->_next; - - delete ptr; - res = true; - break; - } - } - } - - release (); - return res; -} - -/* This is single threaded. It's called after the process is removed - * from the cache, but inserts may be attemped by worker threads that - * have a pointer to it. - */ -void -process::cleanup () -{ - hold (); - assert (!is_active ()); - assert (!_cleaning_up); - InterlockedExchange (&_cleaning_up, true); - cleanup_routine *entry = _routines_head; - _routines_head = NULL; - release (); - - while (entry) - { - cleanup_routine *const ptr = entry; - entry = entry->_next; - ptr->cleanup (this); - delete ptr; - } -} - -/*****************************************************************************/ - -void -process_cache::submission_loop::request_loop () -{ - assert (this); - assert (_cache); - assert (_interrupt_event); - - while (_running) - _cache->wait_for_processes (_interrupt_event); -} - -/*****************************************************************************/ - -process_cache::process_cache (const size_t max_procs, - const unsigned int initial_workers) - : _queue (initial_workers), - _submitter (this, &_queue), // true == interruptible - _processes_count (0), - _max_process_count (max_procs), - _processes_head (NULL), - _cache_add_trigger (NULL) -{ - /* there can only be one */ - InitializeCriticalSection (&_cache_write_access); - - _cache_add_trigger = CreateEvent (NULL, // SECURITY_ATTRIBUTES - TRUE, // Manual-reset - FALSE, // Initially non-signalled - NULL); // Anonymous - - if (!_cache_add_trigger) - { - system_printf ("failed to create cache add trigger, error = %u", - GetLastError ()); - abort (); - } - - _queue.add_submission_loop (&_submitter); -} - -process_cache::~process_cache () -{ - (void) CloseHandle (_cache_add_trigger); - DeleteCriticalSection (&_cache_write_access); -} - -/* This returns the process object to the caller already locked, that - * is, with the object's `access' critical region entered. Thus the - * caller must unlock the object when it's finished with it (via - * process::release ()). It must then not try to access the object - * afterwards, except by going through this routine again, as it may - * have been deleted once it has been unlocked. - */ -class process * -process_cache::process (const pid_t cygpid, const DWORD winpid, - HANDLE signal_arrived) -{ - /* TODO: make this more granular, so a search doesn't involve the - * write lock. - */ - EnterCriticalSection (&_cache_write_access); - class process *previous = NULL; - class process *entry = find (winpid, &previous); - - if (!entry) - { - if (_processes_count >= _max_process_count) - { - LeaveCriticalSection (&_cache_write_access); - system_printf (("process limit (%d processes) reached; " - "new connection refused for %d(%u)"), - _max_process_count, cygpid, winpid); - return NULL; - } - - entry = new class process (cygpid, winpid, signal_arrived); - if (!entry->is_active ()) - { - LeaveCriticalSection (&_cache_write_access); - delete entry; - return NULL; - } - - if (previous) - { - entry->_next = previous->_next; - previous->_next = entry; - } - else - { - entry->_next = _processes_head; - _processes_head = entry; - } - - _processes_count += 1; - SetEvent (_cache_add_trigger); - } - - entry->hold (); // To be released by the caller. - LeaveCriticalSection (&_cache_write_access); - assert (entry); - assert (entry->_winpid == winpid); - return entry; -} - -struct pcache_wait_t -{ - size_t index; - size_t count; - HANDLE *hdls; -}; - -static DWORD WINAPI -pcache_wait_thread (const LPVOID param) -{ - pcache_wait_t *p = (pcache_wait_t *) param; - - DWORD rc = WaitForMultipleObjects (p->count, p->hdls, FALSE, INFINITE); - ExitThread (rc == WAIT_FAILED ? rc : rc + p->index); -} - -void -process_cache::wait_for_processes (const HANDLE interrupt_event) -{ - // Update `_wait_array' with handles of all current processes. - size_t idx; - const size_t count = sync_wait_array (interrupt_event); - - debug_printf ("waiting on %u objects in total (%u processes)", - count, _processes_count); - - DWORD rc = WAIT_FAILED; - - if (count <= 64) - { - /* If count <= 64, a single WaitForMultipleObjects is sufficient and - we can simply wait in the main thread. */ - rc = WaitForMultipleObjects (count, _wait_array, FALSE, INFINITE); - if (rc == WAIT_FAILED) - { - system_printf ("could not wait on the process handles, error = %u", - GetLastError ()); - abort (); - } - } - else - { - /* If count > 64 we have to create sub-threads which wait for the - actual wait objects and the main thread waits for the termination - of one of the threads. */ - HANDLE main_wait_array[5] = { NULL }; - DWORD mcount = 0; - - for (idx = 0; idx < count; idx += 64) - { - pcache_wait_t p = { idx, min (count - idx, 64), _wait_array + idx }; - main_wait_array[mcount++] = CreateThread (NULL, 0, pcache_wait_thread, - &p, 0, NULL); - } - - rc = WaitForMultipleObjects (mcount, main_wait_array, FALSE, INFINITE); - if (rc == WAIT_FAILED) - { - system_printf ("could not wait on the process handles, error = %u", - GetLastError ()); - abort (); - } - - /* Check for error condition on signalled sub-thread. */ - GetExitCodeThread (main_wait_array[rc], &rc); - if (rc == WAIT_FAILED) - { - system_printf ("could not wait on the process handles, error = %u", - GetLastError ()); - abort (); - } - - /* Wake up all waiting threads. _cache_add_trigger gets reset - in sync_wait_array again. */ - SetEvent (_cache_add_trigger); - WaitForMultipleObjects (mcount, main_wait_array, TRUE, INFINITE); - for (idx = 0; idx < mcount; idx++) - CloseHandle (main_wait_array[idx]); - } - - /* Tell all processes the bad news. This one formerly only checked - processes beginning with the index of the signalled process, but - this can result in processes which are signalled but never removed - under heavy load conditions. */ - for (idx = 0; idx < count; idx++) - if (_process_array[idx]) - check_and_remove_process (idx); -} - -/* - * process_cache::sync_wait_array () - * - * Fill-in the wait array with the handles that the cache needs to wait on. - * These handles are: - * - the process_process_param's interrupt event - * - the process_cache's cache_add_trigger event - * - the handle for each live process in the cache. - * - * Return value: the number of live handles in the array. - */ - -size_t -process_cache::sync_wait_array (const HANDLE interrupt_event) -{ - assert (this); - assert (interrupt_event && interrupt_event != INVALID_HANDLE_VALUE); - - /* Always reset _cache_add_trigger before filling up the array again. */ - ResetEvent (_cache_add_trigger); - - EnterCriticalSection (&_cache_write_access); - - size_t index = 0; - - for (class process *ptr = _processes_head; ptr; ptr = ptr->_next) - { - assert (ptr->_hProcess && ptr->_hProcess != INVALID_HANDLE_VALUE); - assert (ptr->is_active ()); - - _wait_array[index] = ptr->handle (); - _process_array[index++] = ptr; - - if (!ptr->_next || index % 64 == 62) - { - /* Added at the end of each thread's array part for efficiency. */ - _wait_array[index] = interrupt_event; - _process_array[index++] = NULL; - _wait_array[index] = _cache_add_trigger; - _process_array[index++] = NULL; - } - } - - if (!index) - { - /* To get at least *something* to wait for. */ - _wait_array[index] = interrupt_event; - _process_array[index++] = NULL; - _wait_array[index] = _cache_add_trigger; - _process_array[index++] = NULL; - } - - assert (index <= elements (_wait_array)); - - LeaveCriticalSection (&_cache_write_access); - - return index; -} - -void -process_cache::check_and_remove_process (const size_t index) -{ - assert (this); - assert (index < elements (_wait_array) - SPECIALS_COUNT); - - class process *const process = _process_array[index]; - - assert (process); - assert (process->handle () == _wait_array[index]); - - if (process->check_exit_code () == STILL_ACTIVE) - return; - - debug_printf ("process %d(%u) has left the building ($? = %u)", - process->_cygpid, process->_winpid, process->_exit_status); - - /* Unlink the process object from the process list. */ - - EnterCriticalSection (&_cache_write_access); - - class process *previous = NULL; - - const class process *const tmp = find (process->_winpid, &previous); - - assert (tmp == process); - assert (previous ? previous->_next == process : _processes_head == process); - - if (previous) - previous->_next = process->_next; - else - _processes_head = process->_next; - - _processes_count -= 1; - LeaveCriticalSection (&_cache_write_access); - - /* Schedule any cleanup tasks for this process. */ - _queue.add (new process_cleanup (process)); -} - -class process * -process_cache::find (const DWORD winpid, class process **previous) -{ - if (previous) - *previous = NULL; - - for (class process *ptr = _processes_head; ptr; ptr = ptr->_next) - if (ptr->_winpid == winpid) - return ptr; - else if (ptr->_winpid > winpid) // The list is sorted by winpid. - return NULL; - else if (previous) - *previous = ptr; - - return NULL; -} - -/*****************************************************************************/ -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/process.h b/winsup/cygserver/process.h deleted file mode 100644 index 3de11b6f8..000000000 --- a/winsup/cygserver/process.h +++ /dev/null @@ -1,179 +0,0 @@ -/* process.h - - Copyright 2001, 2002, 2003, 2004, 2005, 2012 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _PROCESS_H -#define _PROCESS_H - -#include <assert.h> - -#include "threaded_queue.h" - -class process_cleanup : public queue_request -{ -public: - process_cleanup (class process *const theprocess) - : _process (theprocess) - { - assert (_process); - } - - virtual ~process_cleanup (); - - virtual void process (); - -private: - class process *const _process; -}; - -class process; - -class cleanup_routine -{ - friend class process; - -public: - cleanup_routine (void *const key) - : _key (key), - _next (NULL) - {} - - virtual ~cleanup_routine () = 0; - - bool operator== (const cleanup_routine &rhs) const - { - return _key == rhs._key; - } - - void *key () const { return _key; } - - /* MUST BE SYNCHRONOUS */ - virtual void cleanup (class process *) = 0; - -private: - void *const _key; - cleanup_routine *_next; -}; - -class process_cache; - -#define hold() _hold(__FILE__,__LINE__) -#define release() _release(__FILE__,__LINE__) - -class process -{ - friend class process_cache; - friend class process_cleanup; - -public: - process (pid_t cygpid, DWORD winpid, - HANDLE signal_arrived = INVALID_HANDLE_VALUE); - ~process (); - - pid_t cygpid () const { return _cygpid; } - DWORD winpid () const { return _winpid; } - HANDLE handle () const { return _hProcess; } - HANDLE signal_arrived () const { return _signal_arrived; } - - bool is_active () const { return _exit_status == STILL_ACTIVE; } - - void _hold (const char *file, int line) { - _log (file, line, LOG_DEBUG, "Try hold(%lu)", _cygpid); - EnterCriticalSection (&_access); - _log (file, line, LOG_DEBUG, "holding (%lu)", _cygpid); - } - void _release (const char *file, int line) { - _log (file, line, LOG_DEBUG, "leaving (%lu)", _cygpid); - LeaveCriticalSection (&_access); - } - - bool add (cleanup_routine *); - bool remove (const cleanup_routine *); - -private: - const pid_t _cygpid; - const DWORD _winpid; - HANDLE _hProcess; - HANDLE _signal_arrived; - LONG _cleaning_up; - DWORD _exit_status; // Set in the constructor and in exit_code (). - cleanup_routine *_routines_head; - /* used to prevent races-on-delete */ - CRITICAL_SECTION _access; - class process *_next; - - DWORD check_exit_code (); - void cleanup (); -}; - -class process_cache -{ - // Number of special (i.e., non-process) handles in _wait_array. - // See wait_for_processes () and sync_wait_array () for details. - enum { - SPECIALS_COUNT = 2 - }; - - class submission_loop : public queue_submission_loop - { - public: - submission_loop (process_cache *const cache, threaded_queue *const queue) - : queue_submission_loop (queue, true), - _cache (cache) - { - assert (_cache); - } - - private: - process_cache *const _cache; - - virtual void request_loop (); - }; - - friend class submission_loop; - -public: - process_cache (const size_t max_procs, const unsigned int initial_workers); - ~process_cache (); - - class process *process (pid_t cygpid, DWORD winpid, - HANDLE signal_arrived = INVALID_HANDLE_VALUE); - - bool running () const { return _queue.running (); } - - bool start () { return _queue.start (); } - bool stop () { return _queue.stop (); } - -private: - threaded_queue _queue; - submission_loop _submitter; - - size_t _processes_count; - size_t _max_process_count; - class process *_processes_head; // A list sorted by winpid. - - // Access to the _wait_array and related fields is not thread-safe, - // since they are used solely by wait_for_processes () and its callees. - - HANDLE _wait_array[5 * MAXIMUM_WAIT_OBJECTS]; - class process *_process_array[5 * MAXIMUM_WAIT_OBJECTS]; - - HANDLE _cache_add_trigger; // Actually both add and remove. - CRITICAL_SECTION _cache_write_access; // Actually both read and write access. - - void wait_for_processes (HANDLE interrupt); - size_t sync_wait_array (HANDLE interrupt); - void check_and_remove_process (const size_t index); - - class process *find (DWORD winpid, class process **previous = NULL); -}; - -#endif /* _PROCESS_H */ diff --git a/winsup/cygserver/pwdgrp.cc b/winsup/cygserver/pwdgrp.cc deleted file mode 100644 index cc12deadd..000000000 --- a/winsup/cygserver/pwdgrp.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* pwdgrp.cc: Request account information - - Copyright 2014 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <stdio.h> -#include <errno.h> -#include <pwd.h> -#include <grp.h> -#include <sys/cygwin.h> - -#include "cygserver.h" -#include "process.h" -#include "transport.h" - -#include "cygserver_pwdgrp.h" - -#include <sddl.h> - -client_request_pwdgrp::client_request_pwdgrp () - : client_request (CYGSERVER_REQUEST_PWDGRP, - &_parameters, sizeof (_parameters)) -{ -} - -void -client_request_pwdgrp::pwd_serve () -{ - struct passwd *pwd = NULL; - - switch (_parameters.in.type) - { - case SID_arg: - pwd = (struct passwd *) cygwin_internal (CW_GETPWSID, 0, - &_parameters.in.arg.sid); - break; - case NAME_arg: - pwd = getpwnam (_parameters.in.arg.name); - break; - case ID_arg: - pwd = getpwuid (_parameters.in.arg.id); - break; - } - if (pwd) - msglen (snprintf (_parameters.out.line, sizeof _parameters.out.line, - "%s:%s:%u:%u:%s:%s:%s", - pwd->pw_name ?: "", - pwd->pw_passwd ?: "", - (uint32_t) pwd->pw_uid, - (uint32_t) pwd->pw_gid, - pwd->pw_gecos ?: "", - pwd->pw_dir ?: "", - pwd->pw_shell ?: "") + 1); - else - { - switch (_parameters.in.type) - { - case SID_arg: - { - char *str; - if (ConvertSidToStringSid (&_parameters.in.arg.sid, &str)) - { - debug_printf ("User <%s> failed", str); - LocalFree (str); - } - } - break; - case NAME_arg: - debug_printf ("User <%s> failed", _parameters.in.arg.name); - break; - case ID_arg: - debug_printf ("User <%u> failed", _parameters.in.arg.id); - break; - } - _parameters.out.line[0] = '\0'; - msglen (0); - error_code (ENOENT); - } -} - -void -client_request_pwdgrp::grp_serve () -{ - struct group *grp = NULL; - - switch (_parameters.in.type) - { - case SID_arg: - grp = (struct group *) cygwin_internal (CW_GETGRSID, 0, - &_parameters.in.arg.sid); - break; - case NAME_arg: - grp = getgrnam (_parameters.in.arg.name); - break; - case ID_arg: - grp = getgrgid (_parameters.in.arg.id); - break; - } - if (grp) - msglen (snprintf (_parameters.out.line, sizeof _parameters.out.line, - "%s:%s:%u:", - grp->gr_name ?: "", - grp->gr_passwd ?: "", - (uint32_t) grp->gr_gid) + 1); - else - { - switch (_parameters.in.type) - { - case SID_arg: - { - char *str; - if (ConvertSidToStringSid (&_parameters.in.arg.sid, &str)) - { - debug_printf ("Group <%s> failed", str); - LocalFree (str); - } - } - break; - case NAME_arg: - debug_printf ("Group <%s> failed", _parameters.in.arg.name); - break; - case ID_arg: - debug_printf ("Group <%u> failed", _parameters.in.arg.id); - break; - } - _parameters.out.line[0] = '\0'; - msglen (0); - error_code (ENOENT); - } -} - -void -client_request_pwdgrp::serve (transport_layer_base *const conn, - process_cache *const cache) -{ - debug_printf ("Request account information"); - if (msglen () < __builtin_offsetof (struct _pwdgrp_param_t::_pwdgrp_in_t, arg) - + sizeof (uint32_t) - || msglen () > sizeof (_parameters.in)) - { - syscall_printf ("bad request body length: got %lu", msglen ()); - error_code (EINVAL); - msglen (0); - return; - } - error_code (0); - if (_parameters.in.group) - grp_serve (); - else - pwd_serve (); - debug_printf ("Request account information returns <%s> error %d", _parameters.out.line, error_code ()); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/sem.cc b/winsup/cygserver/sem.cc deleted file mode 100644 index 55cd6e51e..000000000 --- a/winsup/cygserver/sem.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* sem.cc: Single unix specification IPC interface for Cygwin. - - Copyright 2003, 2004, 2012 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <errno.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#include "cygserver.h" -#include "process.h" -#include "transport.h" - -#include "cygserver_ipc.h" -#include "cygserver_sem.h" - -client_request_sem::client_request_sem () - : client_request (CYGSERVER_REQUEST_SEM, - &_parameters, sizeof (_parameters)) -{ -} - -void -client_request_sem::serve (transport_layer_base *const conn, - process_cache *const cache) -{ - if (msglen () != sizeof (_parameters.in)) - { - syscall_printf ("bad request body length: expecting %lu bytes, got %lu", - sizeof (_parameters), msglen ()); - error_code (EINVAL); - msglen (0); - return; - } - if (support_semaphores == TUN_FALSE) - { - syscall_printf ("Semaphore support not started"); - error_code (ENOSYS); - _parameters.out.ret = -1; - msglen (sizeof (_parameters.out)); - return; - } - process *const client = cache->process (_parameters.in.ipcblk.cygpid, - _parameters.in.ipcblk.winpid, - _parameters.in.ipcblk.signal_arrived); - if (!client) - { - error_code (EAGAIN); - msglen (0); - return; - } - if (!conn->impersonate_client ()) - { - client->release (); - error_code (EACCES); - msglen (0); - return; - } - if (!adjust_identity_info (&_parameters.in.ipcblk)) - { - client->release (); - conn->revert_to_self (); - error_code (EACCES); - msglen (0); - return; - } - /* Early revert_to_self since IPC code runs in kernel mode. */ - conn->revert_to_self (); - /* sysv_sem.cc takes care of itself. */ - client->release (); - thread td = { client, &_parameters.in.ipcblk, {-1, -1} }; - int res; - switch (_parameters.in.semop) - { - case SEMOP_semctl: - res = semctl (&td, &_parameters.in.ctlargs); - break; - case SEMOP_semget: - res = semget (&td, &_parameters.in.getargs); - break; - case SEMOP_semop: - res = semop (&td, &_parameters.in.opargs); - break; - default: - res = ENOSYS; - td.td_retval[0] = -1; - break; - } - /* Allocated by the call to adjust_identity_info(). */ - if (_parameters.in.ipcblk.gidlist) - free (_parameters.in.ipcblk.gidlist); - error_code (res); - _parameters.out.ret = td.td_retval[0]; - msglen (sizeof (_parameters.out)); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/setpwd.cc b/winsup/cygserver/setpwd.cc deleted file mode 100644 index 4f996d3b5..000000000 --- a/winsup/cygserver/setpwd.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* setpwd.cc: Set LSA private data password for current user. - - Copyright 2008, 2014 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <errno.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <wchar.h> - -#include <ntsecapi.h> -#include <ntdef.h> -#include "ntdll.h" - -#include "cygserver.h" -#include "process.h" -#include "transport.h" - -#include "cygserver_setpwd.h" - -client_request_setpwd::client_request_setpwd () - : client_request (CYGSERVER_REQUEST_SETPWD, - &_parameters, sizeof (_parameters)) -{ -} - -void -client_request_setpwd::serve (transport_layer_base *const conn, - process_cache *const cache) -{ - HANDLE tok; - PTOKEN_USER user; - WCHAR sidbuf[128], key_name [128 + wcslen (CYGWIN_LSA_KEY_PREFIX)]; - UNICODE_STRING sid, key, data; - - syscall_printf ("Request to set private data"); - if (msglen () != sizeof (_parameters.in)) - { - syscall_printf ("bad request body length: expecting %lu bytes, got %lu", - sizeof (_parameters), msglen ()); - error_code (EINVAL); - msglen (0); - return; - } - msglen (0); - if (!conn->impersonate_client ()) - { - error_code (EACCES); - return; - } - if (!OpenThreadToken (GetCurrentThread (), TOKEN_READ, TRUE, &tok)) - { - conn->revert_to_self (); - error_code (EACCES); - return; - } - /* Get uid from user SID in token. */ - user = (PTOKEN_USER) get_token_info (tok, TokenUser); - CloseHandle (tok); - conn->revert_to_self (); - if (!user) - { - error_code (EACCES); - return; - } - LSA_OBJECT_ATTRIBUTES oa = { 0, 0, 0, 0, 0, 0 }; - HANDLE lsa; - NTSTATUS status = LsaOpenPolicy (NULL, &oa, POLICY_CREATE_SECRET, &lsa); - if (!NT_SUCCESS (status)) - { - error_code (LsaNtStatusToWinError (status)); - return; - } - RtlInitEmptyUnicodeString (&sid, sidbuf, sizeof sidbuf); - RtlConvertSidToUnicodeString (&sid, user->User.Sid, FALSE); - free (user); - RtlInitEmptyUnicodeString (&key, key_name, sizeof key_name); - RtlAppendUnicodeToString (&key, CYGWIN_LSA_KEY_PREFIX); - RtlAppendUnicodeStringToString (&key, &sid); - RtlInitUnicodeString (&data, _parameters.in.passwd); - status = LsaStorePrivateData (lsa, &key, data.Length ? &data : NULL); - if (data.Length) - RtlSecureZeroMemory (data.Buffer, data.Length); - /* Success or we're trying to remove a password entry which doesn't exist. */ - if (NT_SUCCESS (status) - || (data.Length == 0 && status == STATUS_OBJECT_NAME_NOT_FOUND)) - error_code (0); - else - error_code (LsaNtStatusToWinError (status)); - syscall_printf ("Request to set private data returns error %d", error_code ()); - LsaClose (lsa); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/shm.cc b/winsup/cygserver/shm.cc deleted file mode 100644 index 3be0d15f4..000000000 --- a/winsup/cygserver/shm.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* shm.cc: Single unix specification IPC interface for Cygwin. - - Copyright 2003, 2004, 2012 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <errno.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#include "cygserver.h" -#include "process.h" -#include "transport.h" - -#include "cygserver_ipc.h" -#include "cygserver_shm.h" - -client_request_shm::client_request_shm () - : client_request (CYGSERVER_REQUEST_SHM, - &_parameters, sizeof (_parameters)) -{ -} - -void -client_request_shm::serve (transport_layer_base *const conn, - process_cache *const cache) -{ - if (msglen () != sizeof (_parameters.in)) - { - syscall_printf ("bad request body length: expecting %lu bytes, got %lu", - sizeof (_parameters), msglen ()); - error_code (EINVAL); - msglen (0); - return; - } - if (support_sharedmem == TUN_FALSE) - { - syscall_printf ("Shared memory support not started"); - error_code (ENOSYS); - if (_parameters.in.shmop == SHMOP_shmat) - _parameters.out.ptr = (vm_offset_t)0; - else - _parameters.out.ret = -1; - msglen (sizeof (_parameters.out)); - return; - } - process *const client = cache->process (_parameters.in.ipcblk.cygpid, - _parameters.in.ipcblk.winpid, - _parameters.in.ipcblk.signal_arrived); - if (!client) - { - error_code (EAGAIN); - msglen (0); - return; - } - if (!conn->impersonate_client ()) - { - client->release (); - error_code (EACCES); - msglen (0); - return; - } - if (!adjust_identity_info (&_parameters.in.ipcblk)) - { - client->release (); - conn->revert_to_self (); - error_code (EACCES); - msglen (0); - return; - } - /* Early revert_to_self since IPC code runs in kernel mode. */ - conn->revert_to_self (); - /* sysv_shm.cc takes care of itself. */ - client->release (); - thread td = { client, &_parameters.in.ipcblk, {0, 0} }; - int res; - shmop_t shmop = _parameters.in.shmop; /* Get's overwritten otherwise. */ - switch (shmop) - { - case SHMOP_shmat: - ipc_p_vmspace (td.ipcblk); - res = shmat (&td, &_parameters.in.atargs); - break; - case SHMOP_shmctl: - res = shmctl (&td, &_parameters.in.ctlargs); - break; - case SHMOP_shmdt: - ipc_p_vmspace (td.ipcblk); - res = shmdt (&td, &_parameters.in.dtargs); - break; - case SHMOP_shmget: - res = shmget (&td, &_parameters.in.getargs); - break; - case SHMOP_shmfork: - res = cygwin_shmfork_myhook (&td, &_parameters.in.forkargs); - break; - default: - res = ENOSYS; - td.td_retval[0] = -1; - break; - } - /* Allocated by the call to adjust_identity_info(). */ - if (_parameters.in.ipcblk.gidlist) - free (_parameters.in.ipcblk.gidlist); - error_code (res); - if (shmop == SHMOP_shmat) - _parameters.out.ptr = td.td_retval[0]; - else - _parameters.out.ret = td.td_retval[0]; - if (shmop == SHMOP_shmget) - _parameters.out.obj = td.td_retval[1]; - msglen (sizeof (_parameters.out)); -} -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/sysv_msg.cc b/winsup/cygserver/sysv_msg.cc deleted file mode 100644 index 217cc1d97..000000000 --- a/winsup/cygserver/sysv_msg.cc +++ /dev/null @@ -1,1215 +0,0 @@ -/* - * Implementation of SVID messages - * - * Author: Daniel Boulet - * - * Copyright 1993 Daniel Boulet and RTMX Inc. - * - * This system call was implemented by Daniel Boulet under contract from RTMX. - * - * Redistribution and use in source forms, with and without modification, - * are permitted provided that this entire comment appears intact. - * - * Redistribution in binary form may occur without any restrictions. - * Obviously, it would be nice if you gave credit where credit is due - * but requiring it would be too onerous. - * - * This software is provided ``AS IS'' without any warranties of any kind. - */ - -/* - * This file is heavily changed to become part of Cygwin's cygserver. - */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#include <sys/cdefs.h> -#ifndef __FBSDID -#define __FBSDID(s) const char version[] = (s) -#endif -__FBSDID("$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/kern/sysv_msg.c,v 1.52 2003/11/07 04:47:14 rwatson Exp $"); -/* CV, 2006-01-09: Inspected upstream up to version 1.60. */ - -#define _KERNEL 1 -#define __BSD_VISIBLE 1 -#include <sys/types.h> -#include <sys/sysproto.h> -#include <sys/ipc.h> -#include <sys/param.h> -#include <sys/msg.h> -#include <malloc.h> -#include <errno.h> -#include <time.h> -#include "cygserver.h" -#include "process.h" -#include "cygserver_ipc.h" - -#ifdef __CYGWIN__ -#define MSG_DEBUG -#endif /* __CYGWIN__ */ - -#ifdef MSG_DEBUG -#define DPRINTF(a) debug_printf a -#else -#define DPRINTF(a) -#endif - -static void msg_freehdr(struct msg *msghdr); - -#ifndef __CYGWIN__ -int msgctl(struct thread *, struct msgctl_args *); -int msgget(struct thread *, struct msgget_args *); -int msgsnd(struct thread *, struct msgsnd_args *); -int msgrcv(struct thread *, struct msgrcv_args *); - -static sy_call_t *msgcalls[] = { - (sy_call_t *)msgctl, (sy_call_t *)msgget, - (sy_call_t *)msgsnd, (sy_call_t *)msgrcv -}; -#endif /* __CYGWIN__ */ - - -struct msg { - struct msg *msg_next; /* next msg in the chain */ - long msg_type; /* type of this message */ - /* >0 -> type of this message */ - /* 0 -> free header */ - u_short msg_ts; /* size of this message */ - short msg_spot; /* location of start of msg in buffer */ -}; - - -#ifndef MSGSSZ -#define MSGSSZ 8 /* Each segment must be 2^N long */ -#endif -#ifndef MSGSEG -#define MSGSEG 2048 /* must be less than 32767 */ -#endif -#define MSGMAX (MSGSSZ*MSGSEG) -#ifndef MSGMNB -#define MSGMNB 2048 /* max # of bytes in a queue */ -#endif -#ifndef MSGMNI -#define MSGMNI 40 -#endif -#ifndef MSGTQL -#define MSGTQL 40 -#endif - -/* - * Based on the configuration parameters described in an SVR2 (yes, two) - * config(1m) man page. - * - * Each message is broken up and stored in segments that are msgssz bytes - * long. For efficiency reasons, this should be a power of two. Also, - * it doesn't make sense if it is less than 8 or greater than about 256. - * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of - * two between 8 and 1024 inclusive (and panic's if it isn't). - */ -struct msginfo msginfo = { - MSGMAX, /* max chars in a message */ - MSGMNB, /* max chars in a queue */ - MSGMNI, /* # of message queue identifiers */ - MSGTQL, /* max messages in system */ - MSGSSZ, /* size of a message segment */ - /* (must be small power of 2 greater than 4) */ - MSGSEG /* number of message segments */ -}; - -/* - * macros to convert between msqid_ds's and msqid's. - * (specific to this implementation) - */ -#define MSQID(ix,ds) ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000)) -#define MSQID_IX(id) ((id) & 0xffff) -#define MSQID_SEQ(id) (((id) >> 16) & 0xffff) - -/* - * The rest of this file is specific to this particular implementation. - */ - -struct msgmap { - short next; /* next segment in buffer */ - /* -1 -> available */ - /* 0..(MSGSEG-1) -> index of next segment */ -}; - -#define MSG_LOCKED 01000 /* Is this msqid_ds locked? */ - -static int nfree_msgmaps; /* # of free map entries */ -static short free_msgmaps; /* head of linked list of free map entries */ -static struct msg *free_msghdrs;/* list of free msg headers */ -static char *msgpool; /* MSGMAX byte long msg buffer pool */ -static struct msgmap *msgmaps; /* MSGSEG msgmap structures */ -static struct msg *msghdrs; /* MSGTQL msg headers */ -static struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */ -static struct mtx msq_mtx; /* global mutex for message queues. */ - -#ifdef __CYGWIN__ -static struct msg_info msg_info; -#endif /* __CYGWIN__ */ - -void -msginit() -{ - int i; - - TUNABLE_INT_FETCH("kern.ipc.msgseg", &msginfo.msgseg); - TUNABLE_INT_FETCH("kern.ipc.msgssz", &msginfo.msgssz); - msginfo.msgmax = msginfo.msgseg * msginfo.msgssz; - TUNABLE_INT_FETCH("kern.ipc.msgmnb", &msginfo.msgmnb); - TUNABLE_INT_FETCH("kern.ipc.msgmni", &msginfo.msgmni); - TUNABLE_INT_FETCH("kern.ipc.msgtql", &msginfo.msgtql); - - msgpool = (char *) sys_malloc(msginfo.msgmax, M_MSG, M_WAITOK); - if (msgpool == NULL) - panic("msgpool is NULL"); - msgmaps = (msgmap *) sys_malloc(sizeof(struct msgmap) * msginfo.msgseg, M_MSG, M_WAITOK); - if (msgmaps == NULL) - panic("msgmaps is NULL"); - msghdrs = (msg *) sys_malloc(sizeof(struct msg) * msginfo.msgtql, M_MSG, M_WAITOK); - if (msghdrs == NULL) - panic("msghdrs is NULL"); - msqids = (msqid_ds *) sys_malloc(sizeof(struct msqid_ds) * msginfo.msgmni, M_MSG, M_WAITOK); - if (msqids == NULL) - panic("msqids is NULL"); - - /* - * msginfo.msgssz should be a power of two for efficiency reasons. - * It is also pretty silly if msginfo.msgssz is less than 8 - * or greater than about 256 so ... - */ - - i = 8; - while (i < 1024 && i != msginfo.msgssz) - i <<= 1; - if (i != msginfo.msgssz) { - DPRINTF(("msginfo.msgssz=%d (0x%x)\n", msginfo.msgssz, - msginfo.msgssz)); - panic("msginfo.msgssz not a small power of 2"); - } - - if (msginfo.msgseg > 32767) { - DPRINTF(("msginfo.msgseg=%d\n", msginfo.msgseg)); - panic("msginfo.msgseg > 32767"); - } - - if (msgmaps == NULL) - panic("msgmaps is NULL"); - - for (i = 0; i < msginfo.msgseg; i++) { - if (i > 0) - msgmaps[i-1].next = i; - msgmaps[i].next = -1; /* implies entry is available */ - } - free_msgmaps = 0; - nfree_msgmaps = msginfo.msgseg; - - if (msghdrs == NULL) - panic("msghdrs is NULL"); - - for (i = 0; i < msginfo.msgtql; i++) { - msghdrs[i].msg_type = 0; - if (i > 0) - msghdrs[i-1].msg_next = &msghdrs[i]; - msghdrs[i].msg_next = NULL; - } - free_msghdrs = &msghdrs[0]; - - if (msqids == NULL) - panic("msqids is NULL"); - - for (i = 0; i < msginfo.msgmni; i++) { - msqids[i].msg_qbytes = 0; /* implies entry is available */ - msqids[i].msg_perm.seq = 0; /* reset to a known value */ - msqids[i].msg_perm.mode = 0; - } - mtx_init(&msq_mtx, "msq", NULL, MTX_DEF); -} - -int -msgunload() -{ - struct msqid_ds *msqptr; - int msqid; - - for (msqid = 0; msqid < msginfo.msgmni; msqid++) { - /* - * Look for an unallocated and unlocked msqid_ds. - * msqid_ds's can be locked by msgsnd or msgrcv while - * they are copying the message in/out. We can't - * re-use the entry until they release it. - */ - msqptr = &msqids[msqid]; - if (msqptr->msg_qbytes != 0 || - (msqptr->msg_perm.mode & MSG_LOCKED) != 0) - break; - } -#ifndef __CYGWIN__ - if (msqid != msginfo.msgmni) - return (EBUSY); -#endif /* __CYGWIN__ */ - - sys_free(msgpool, M_MSG); - sys_free(msgmaps, M_MSG); - sys_free(msghdrs, M_MSG); - sys_free(msqids, M_MSG); - mtx_destroy(&msq_mtx); - return (0); -} - - -#ifndef __CYGWIN__ -static int -sysvmsg_modload(struct module *module, int cmd, void *arg) -{ - int error = 0; - - switch (cmd) { - case MOD_LOAD: - msginit(); - break; - case MOD_UNLOAD: - error = msgunload(); - break; - case MOD_SHUTDOWN: - break; - default: - error = EINVAL; - break; - } - return (error); -} - -static moduledata_t sysvmsg_mod = { - "sysvmsg", - &sysvmsg_modload, - NULL -}; - -SYSCALL_MODULE_HELPER(msgsys); -SYSCALL_MODULE_HELPER(msgctl); -SYSCALL_MODULE_HELPER(msgget); -SYSCALL_MODULE_HELPER(msgsnd); -SYSCALL_MODULE_HELPER(msgrcv); - -DECLARE_MODULE(sysvmsg, sysvmsg_mod, - SI_SUB_SYSV_MSG, SI_ORDER_FIRST); -MODULE_VERSION(sysvmsg, 1); - -/* - * Entry point for all MSG calls - * - * MPSAFE - */ -int -msgsys(thread *td, struct msgsys_args *uap) -{ - int error; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - if (uap->which < 0 || - (unsigned) uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0])) - return (EINVAL); - error = (*msgcalls[uap->which])(td, &uap->a2); - return (error); -} -#endif - -static void -msg_freehdr(struct msg *msghdr) -{ - while (msghdr->msg_ts > 0) { - short next; - if (msghdr->msg_spot < 0 || msghdr->msg_spot >= msginfo.msgseg) - panic("msghdr->msg_spot out of range"); - next = msgmaps[msghdr->msg_spot].next; - msgmaps[msghdr->msg_spot].next = free_msgmaps; - free_msgmaps = msghdr->msg_spot; - nfree_msgmaps++; - msghdr->msg_spot = next; - if (msghdr->msg_ts >= msginfo.msgssz) - msghdr->msg_ts -= msginfo.msgssz; - else - msghdr->msg_ts = 0; - } - if (msghdr->msg_spot != -1) - panic("msghdr->msg_spot != -1"); - msghdr->msg_next = free_msghdrs; - free_msghdrs = msghdr; -} - -#ifndef _SYS_SYSPROTO_H_ -struct msgctl_args { - int msqid; - int cmd; - struct msqid_ds *buf; -}; -#endif - -/* - * MPSAFE - */ -int -msgctl(struct thread *td, struct msgctl_args *uap) -{ - int msqid = uap->msqid; - int cmd = uap->cmd; - struct msqid_ds *user_msqptr = uap->buf; - int rval, error; - struct msqid_ds msqbuf; - register struct msqid_ds *msqptr; - - DPRINTF(("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr)); - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - -#ifdef __CYGWIN__ - if (cmd == IPC_INFO) { - if (!msqid) { - error = copyout(&msginfo, user_msqptr, - sizeof(struct msginfo)); - td->td_retval[0] = error ? -1 : 0; - return (error); - } - if (msqid > msginfo.msgmni) - msqid = msginfo.msgmni; - error = copyout(msqids, user_msqptr, - msqid * sizeof(struct msqid_ds)); - td->td_retval[0] = error ? -1 : 0; - return (error); - } else if (cmd == MSG_INFO) { - mtx_lock(&msq_mtx); - error = copyout(&msg_info, user_msqptr, - sizeof(struct msg_info)); - td->td_retval[0] = error ? -1 : 0; - mtx_unlock(&msq_mtx); - return (error); - } -#endif /* __CYGWIN__ */ - msqid = IPCID_TO_IX(msqid); - - if (msqid < 0 || msqid >= msginfo.msgmni) { - DPRINTF(("msqid (%d) out of range (0<=msqid<%d)\n", msqid, - msginfo.msgmni)); - return (EINVAL); - } - if (cmd == IPC_SET && - (error = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0) - return (error); - - msqptr = &msqids[msqid]; - - mtx_lock(&msq_mtx); - if (msqptr->msg_qbytes == 0) { - DPRINTF(("no such msqid\n")); - error = EINVAL; - goto done2; - } - if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { - DPRINTF(("wrong sequence number\n")); - error = EINVAL; - goto done2; - } - - error = 0; - rval = 0; - - switch (cmd) { - - case IPC_RMID: - { - struct msg *msghdr; - if ((error = ipcperm(td, &msqptr->msg_perm, IPC_M))) - goto done2; - /* Free the message headers */ - msghdr = msqptr->msg_first; - while (msghdr != NULL) { - struct msg *msghdr_tmp; - - /* Free the segments of each message */ - msqptr->msg_cbytes -= msghdr->msg_ts; - msqptr->msg_qnum--; - msghdr_tmp = msghdr; - msghdr = msghdr->msg_next; - msg_freehdr(msghdr_tmp); - } - - if (msqptr->msg_cbytes != 0) - panic("msg_cbytes is screwed up"); - if (msqptr->msg_qnum != 0) - panic("msg_qnum is screwed up"); - - msqptr->msg_qbytes = 0; /* Mark it as free */ -#ifdef __CYGWIN__ - msg_info.msg_ids--; -#endif /* __CYGWIN__ */ - - wakeup(msqptr); - } - - break; - - case IPC_SET: - if ((error = ipcperm(td, &msqptr->msg_perm, IPC_M))) - goto done2; - if (msqbuf.msg_qbytes > msqptr->msg_qbytes) { - error = suser(td); - if (error) - goto done2; - } - if (msqbuf.msg_qbytes > (unsigned long) msginfo.msgmnb) { - DPRINTF(("can't increase msg_qbytes beyond %d" - "(truncating)\n", msginfo.msgmnb)); - msqbuf.msg_qbytes = msginfo.msgmnb; /* silently restrict qbytes to system limit */ - } - if (msqbuf.msg_qbytes == 0) { - DPRINTF(("can't reduce msg_qbytes to 0\n")); - error = EINVAL; /* non-standard errno! */ - goto done2; - } - msqptr->msg_perm.uid = msqbuf.msg_perm.uid; /* change the owner */ - msqptr->msg_perm.gid = msqbuf.msg_perm.gid; /* change the owner */ - msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) | - (msqbuf.msg_perm.mode & 0777); - msqptr->msg_qbytes = msqbuf.msg_qbytes; - msqptr->msg_ctime = time (NULL); - break; - - case IPC_STAT: - if ((error = ipcperm(td, &msqptr->msg_perm, IPC_R))) { - DPRINTF(("requester doesn't have read access\n")); - goto done2; - } - break; - - default: - DPRINTF(("invalid command %d\n", cmd)); - error = EINVAL; - goto done2; - } - - if (error == 0) - td->td_retval[0] = rval; -done2: - mtx_unlock(&msq_mtx); - if (cmd == IPC_STAT && error == 0) - error = copyout(msqptr, user_msqptr, sizeof(struct msqid_ds)); - return(error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct msgget_args { - key_t key; - int msgflg; -}; -#endif - -/* - * MPSAFE - */ -int -msgget(struct thread *td, struct msgget_args *uap) -{ - int msqid, error = 0; - key_t key = uap->key; - unsigned msgflg = uap->msgflg; - register struct msqid_ds *msqptr = NULL; - - DPRINTF(("msgget(0x%x, 0%o)\n", key, msgflg)); - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - - mtx_lock(&msq_mtx); - if (key != IPC_PRIVATE) { - for (msqid = 0; msqid < msginfo.msgmni; msqid++) { - msqptr = &msqids[msqid]; - if (msqptr->msg_qbytes != 0 && - msqptr->msg_perm.key == key) - break; - } - if (msqid < msginfo.msgmni) { - DPRINTF(("found public key\n")); - if ((msgflg & IPC_CREAT) && (msgflg & IPC_EXCL)) { - DPRINTF(("not exclusive\n")); - error = EEXIST; - goto done2; - } - if ((error = ipcperm(td, &msqptr->msg_perm, msgflg & 0700))) { - DPRINTF(("requester doesn't have 0%o access\n", - msgflg & 0700)); - goto done2; - } - goto found; - } - } - - DPRINTF(("need to allocate the msqid_ds\n")); - if (key == IPC_PRIVATE || (msgflg & IPC_CREAT)) { - for (msqid = 0; msqid < msginfo.msgmni; msqid++) { - /* - * Look for an unallocated and unlocked msqid_ds. - * msqid_ds's can be locked by msgsnd or msgrcv while - * they are copying the message in/out. We can't - * re-use the entry until they release it. - */ - msqptr = &msqids[msqid]; - if (msqptr->msg_qbytes == 0 && - (msqptr->msg_perm.mode & MSG_LOCKED) == 0) - break; - } - if (msqid == msginfo.msgmni) { - DPRINTF(("no more msqid_ds's available\n")); - error = ENOSPC; - goto done2; - } - DPRINTF(("msqid %d is available\n", msqid)); - msqptr->msg_perm.key = key; -#ifdef __CYGWIN__ - msqptr->msg_perm.cuid = td->ipcblk->uid; - msqptr->msg_perm.uid = td->ipcblk->uid; - msqptr->msg_perm.cgid = td->ipcblk->gid; - msqptr->msg_perm.gid = td->ipcblk->gid; -#else - msqptr->msg_perm.cuid = cred->cr_uid; - msqptr->msg_perm.uid = cred->cr_uid; - msqptr->msg_perm.cgid = cred->cr_gid; - msqptr->msg_perm.gid = cred->cr_gid; -#endif /* __CYGWIN__ */ - msqptr->msg_perm.mode = (msgflg & 0777); - /* Make sure that the returned msqid is unique */ - msqptr->msg_perm.seq = (msqptr->msg_perm.seq + 1) & 0x7fff; - msqptr->msg_first = NULL; - msqptr->msg_last = NULL; - msqptr->msg_cbytes = 0; - msqptr->msg_qnum = 0; - msqptr->msg_qbytes = msginfo.msgmnb; - msqptr->msg_lspid = 0; - msqptr->msg_lrpid = 0; - msqptr->msg_stime = 0; - msqptr->msg_rtime = 0; - msqptr->msg_ctime = time (NULL); -#ifdef __CYGWIN__ - msg_info.msg_ids++; -#endif /* __CYGWIN__ */ - } else { - DPRINTF(("didn't find it and wasn't asked to create it\n")); - error = ENOENT; - goto done2; - } - -found: - /* Construct the unique msqid */ - td->td_retval[0] = IXSEQ_TO_IPCID(msqid, msqptr->msg_perm); -done2: - mtx_unlock(&msq_mtx); - return (error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct msgsnd_args { - int msqid; - const void *msgp; - size_t msgsz; - int msgflg; -}; -#endif - -/* - * MPSAFE - */ -int -msgsnd(struct thread *td, struct msgsnd_args *uap) -{ - int msqid = uap->msqid; - const void *user_msgp = uap->msgp; - size_t msgsz = uap->msgsz; - int msgflg = uap->msgflg; - int segs_needed, error = 0; - register struct msqid_ds *msqptr; - register struct msg *msghdr; - short next; - - DPRINTF(("call to msgsnd(%d, 0x%x, %d, %d)\n", msqid, user_msgp, msgsz, - msgflg)); - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - - mtx_lock(&msq_mtx); - msqid = IPCID_TO_IX(msqid); - - if (msqid < 0 || msqid >= msginfo.msgmni) { - DPRINTF(("msqid (%d) out of range (0<=msqid<%d)\n", msqid, - msginfo.msgmni)); - error = EINVAL; - goto done2; - } - - msqptr = &msqids[msqid]; - if (msqptr->msg_qbytes == 0) { - DPRINTF(("no such message queue id\n")); - error = EINVAL; - goto done2; - } - if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { - DPRINTF(("wrong sequence number\n")); - error = EINVAL; - goto done2; - } - - if ((error = ipcperm(td, &msqptr->msg_perm, IPC_W))) { - DPRINTF(("requester doesn't have write access\n")); - goto done2; - } - - segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz; - DPRINTF(("msgsz=%d, msgssz=%d, segs_needed=%d\n", msgsz, msginfo.msgssz, - segs_needed)); - for (;;) { - int need_more_resources = 0; - - /* - * check msgsz - * (inside this loop in case msg_qbytes changes while we sleep) - */ - - if (msgsz > msqptr->msg_qbytes) { - DPRINTF(("msgsz > msqptr->msg_qbytes\n")); - error = EINVAL; - goto done2; - } - - if (msqptr->msg_perm.mode & MSG_LOCKED) { - DPRINTF(("msqid is locked\n")); - need_more_resources = 1; - } - if (msgsz + msqptr->msg_cbytes > msqptr->msg_qbytes) { - DPRINTF(("msgsz + msg_cbytes > msg_qbytes\n")); - need_more_resources = 1; - } - if (segs_needed > nfree_msgmaps) { - DPRINTF(("segs_needed > nfree_msgmaps\n")); - need_more_resources = 1; - } - if (free_msghdrs == NULL) { - DPRINTF(("no more msghdrs\n")); - need_more_resources = 1; - } - - if (need_more_resources) { - int we_own_it; - - if ((msgflg & IPC_NOWAIT) != 0) { - DPRINTF(("need more resources but caller " - "doesn't want to wait\n")); - error = EAGAIN; - goto done2; - } - - if ((msqptr->msg_perm.mode & MSG_LOCKED) != 0) { - DPRINTF(("we don't own the msqid_ds\n")); - we_own_it = 0; - } else { - /* Force later arrivals to wait for our - request */ - DPRINTF(("we own the msqid_ds\n")); - msqptr->msg_perm.mode |= MSG_LOCKED; - we_own_it = 1; - } - DPRINTF(("goodnight\n")); - error = msleep(msqptr, &msq_mtx, (PZERO - 4) | PCATCH, - "msgsnd", 50); - DPRINTF(("good morning, error=%d\n", error)); - if (we_own_it) - msqptr->msg_perm.mode &= ~MSG_LOCKED; - if (error == EWOULDBLOCK) { - DPRINTF(("timed out\n")); - continue; - } - if (error != 0) { - DPRINTF(("msgsnd: interrupted system call\n")); -#ifdef __CYGWIN__ - if (error != EIDRM) -#endif /* __CYGWIN__ */ - error = EINTR; - goto done2; - } - - /* - * Make sure that the msq queue still exists - */ - - if (msqptr->msg_qbytes == 0) { - DPRINTF(("msqid deleted\n")); - error = EIDRM; - goto done2; - } - - } else { - DPRINTF(("got all the resources that we need\n")); - break; - } - } - - /* - * We have the resources that we need. - * Make sure! - */ - - if (msqptr->msg_perm.mode & MSG_LOCKED) - panic("msg_perm.mode & MSG_LOCKED"); - if (segs_needed > nfree_msgmaps) - panic("segs_needed > nfree_msgmaps"); - if (msgsz + msqptr->msg_cbytes > msqptr->msg_qbytes) - panic("msgsz + msg_cbytes > msg_qbytes"); - if (free_msghdrs == NULL) - panic("no more msghdrs"); - - /* - * Re-lock the msqid_ds in case we page-fault when copying in the - * message - */ - - if ((msqptr->msg_perm.mode & MSG_LOCKED) != 0) - panic("msqid_ds is already locked"); - msqptr->msg_perm.mode |= MSG_LOCKED; - - /* - * Allocate a message header - */ - - msghdr = free_msghdrs; - free_msghdrs = msghdr->msg_next; - msghdr->msg_spot = -1; - msghdr->msg_ts = msgsz; - - /* - * Allocate space for the message - */ - - while (segs_needed > 0) { - if (nfree_msgmaps <= 0) - panic("not enough msgmaps"); - if (free_msgmaps == -1) - panic("nil free_msgmaps"); - next = free_msgmaps; - if (next <= -1) - panic("next too low #1"); - if (next >= msginfo.msgseg) - panic("next out of range #1"); - DPRINTF(("allocating segment %d to message\n", next)); - free_msgmaps = msgmaps[next].next; - nfree_msgmaps--; - msgmaps[next].next = msghdr->msg_spot; - msghdr->msg_spot = next; - segs_needed--; - } - - /* - * Copy in the message type - */ - - mtx_unlock(&msq_mtx); - if ((error = copyin(user_msgp, &msghdr->msg_type, - sizeof(msghdr->msg_type))) != 0) { - mtx_lock(&msq_mtx); - DPRINTF(("error %d copying the message type\n", error)); - msg_freehdr(msghdr); - msqptr->msg_perm.mode &= ~MSG_LOCKED; - wakeup(msqptr); - goto done2; - } - mtx_lock(&msq_mtx); - user_msgp = (const char *)user_msgp + sizeof(msghdr->msg_type); - - /* - * Validate the message type - */ - - if (msghdr->msg_type < 1) { - msg_freehdr(msghdr); - msqptr->msg_perm.mode &= ~MSG_LOCKED; - wakeup(msqptr); - DPRINTF(("mtype (%d) < 1\n", msghdr->msg_type)); - error = EINVAL; - goto done2; - } - - /* - * Copy in the message body - */ - - next = msghdr->msg_spot; - while (msgsz > 0) { - size_t tlen; - if (msgsz > (unsigned long) msginfo.msgssz) - tlen = msginfo.msgssz; - else - tlen = msgsz; - if (next <= -1) - panic("next too low #2"); - if (next >= msginfo.msgseg) - panic("next out of range #2"); - mtx_unlock(&msq_mtx); - if ((error = copyin(user_msgp, &msgpool[next * msginfo.msgssz], - tlen)) != 0) { - mtx_lock(&msq_mtx); - DPRINTF(("error %d copying in message segment\n", - error)); - msg_freehdr(msghdr); - msqptr->msg_perm.mode &= ~MSG_LOCKED; - wakeup(msqptr); - goto done2; - } - mtx_lock(&msq_mtx); - msgsz -= tlen; - user_msgp = (const char *)user_msgp + tlen; - next = msgmaps[next].next; - } - if (next != -1) - panic("didn't use all the msg segments"); - - /* - * We've got the message. Unlock the msqid_ds. - */ - - msqptr->msg_perm.mode &= ~MSG_LOCKED; - - /* - * Make sure that the msqid_ds is still allocated. - */ - - if (msqptr->msg_qbytes == 0) { - msg_freehdr(msghdr); - wakeup(msqptr); - error = EIDRM; - goto done2; - } - - /* - * Put the message into the queue - */ - - if (msqptr->msg_first == NULL) { - msqptr->msg_first = msghdr; - msqptr->msg_last = msghdr; - } else { - msqptr->msg_last->msg_next = msghdr; - msqptr->msg_last = msghdr; - } - msqptr->msg_last->msg_next = NULL; - - msqptr->msg_cbytes += msghdr->msg_ts; - msqptr->msg_qnum++; - msqptr->msg_lspid = td->td_proc->p_pid; - msqptr->msg_stime = time (NULL); - -#ifdef __CYGWIN__ - msg_info.msg_num++; - msg_info.msg_tot += uap->msgsz; -#endif /* __CYGWIN__ */ - - wakeup(msqptr); - td->td_retval[0] = 0; -done2: - mtx_unlock(&msq_mtx); - return (error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct msgrcv_args { - int msqid; - void *msgp; - size_t msgsz; - long msgtyp; - int msgflg; -}; -#endif - -/* - * MPSAFE - */ -int -msgrcv(struct thread *td, struct msgrcv_args *uap) -{ - int msqid = uap->msqid; - void *user_msgp = uap->msgp; - size_t msgsz = uap->msgsz; - long msgtyp = uap->msgtyp; - int msgflg = uap->msgflg; - size_t len; - register struct msqid_ds *msqptr; - register struct msg *msghdr; - int error = 0; - short next; - - DPRINTF(("call to msgrcv(%d, 0x%x, %d, %ld, %d)\n", msqid, user_msgp, - msgsz, msgtyp, msgflg)); - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - - msqid = IPCID_TO_IX(msqid); - - if (msqid < 0 || msqid >= msginfo.msgmni) { - DPRINTF(("msqid (%d) out of range (0<=msqid<%d)\n", msqid, - msginfo.msgmni)); - return (EINVAL); - } - - msqptr = &msqids[msqid]; - mtx_lock(&msq_mtx); - if (msqptr->msg_qbytes == 0) { - DPRINTF(("no such message queue id\n")); - error = EINVAL; - goto done2; - } - if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { - DPRINTF(("wrong sequence number\n")); - error = EINVAL; - goto done2; - } - - if ((error = ipcperm(td, &msqptr->msg_perm, IPC_R))) { - DPRINTF(("requester doesn't have read access\n")); - goto done2; - } - - msghdr = NULL; - while (msghdr == NULL) { - if (msgtyp == 0) { - msghdr = msqptr->msg_first; - if (msghdr != NULL) { - if (msgsz < msghdr->msg_ts && - (msgflg & MSG_NOERROR) == 0) { - DPRINTF(("first message on the queue " - "is too big (want %d, got %d)\n", - msgsz, msghdr->msg_ts)); - error = E2BIG; - goto done2; - } - if (msqptr->msg_first == msqptr->msg_last) { - msqptr->msg_first = NULL; - msqptr->msg_last = NULL; - } else { - msqptr->msg_first = msghdr->msg_next; - if (msqptr->msg_first == NULL) - panic("msg_first/last screwed up #1"); - } - } - } else { - struct msg *previous; - struct msg **prev; - - previous = NULL; - prev = &(msqptr->msg_first); - while ((msghdr = *prev) != NULL) { - /* - * Is this message's type an exact match or is - * this message's type less than or equal to - * the absolute value of a negative msgtyp? - * Note that the second half of this test can - * NEVER be true if msgtyp is positive since - * msg_type is always positive! - */ - - if (msgtyp == msghdr->msg_type || - msghdr->msg_type <= -msgtyp) { - DPRINTF(("found message type %d, " - "requested %d\n", - msghdr->msg_type, msgtyp)); - if (msgsz < msghdr->msg_ts && - (msgflg & MSG_NOERROR) == 0) { - DPRINTF(("requested message " - "on the queue is too big " - "(want %d, got %d)\n", - msgsz, msghdr->msg_ts)); - error = E2BIG; - goto done2; - } - *prev = msghdr->msg_next; - if (msghdr == msqptr->msg_last) { - if (previous == NULL) { - if (prev != - &msqptr->msg_first) - panic("msg_first/last screwed up #2"); - msqptr->msg_first = - NULL; - msqptr->msg_last = - NULL; - } else { - if (prev == - &msqptr->msg_first) - panic("msg_first/last screwed up #3"); - msqptr->msg_last = - previous; - } - } - break; - } - previous = msghdr; - prev = &(msghdr->msg_next); - } - } - - /* - * We've either extracted the msghdr for the appropriate - * message or there isn't one. - * If there is one then bail out of this loop. - */ - - if (msghdr != NULL) - break; - - /* - * Hmph! No message found. Does the user want to wait? - */ - - if ((msgflg & IPC_NOWAIT) != 0) { - DPRINTF(("no appropriate message found (msgtyp=%d)\n", - msgtyp)); - /* The SVID says to return ENOMSG. */ - error = ENOMSG; - goto done2; - } - - /* - * Wait for something to happen - */ - - DPRINTF(("msgrcv: goodnight\n")); - error = msleep(msqptr, &msq_mtx, (PZERO - 4) | PCATCH, - "msgrcv", 0); - DPRINTF(("msgrcv: good morning (error=%d)\n", error)); - - if (error != 0) { - DPRINTF(("msgrcv: interrupted system call\n")); -#ifdef __CYGWIN__ - if (error != EIDRM) -#endif /* __CYGWIN__ */ - error = EINTR; - goto done2; - } - - /* - * Make sure that the msq queue still exists - */ - - if (msqptr->msg_qbytes == 0 || - msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { - DPRINTF(("msqid deleted\n")); - error = EIDRM; - goto done2; - } - } - - /* - * Return the message to the user. - * - * First, do the bookkeeping (before we risk being interrupted). - */ - - msqptr->msg_cbytes -= msghdr->msg_ts; - msqptr->msg_qnum--; - msqptr->msg_lrpid = td->td_proc->p_pid; - msqptr->msg_rtime = time (NULL); - - /* - * Make msgsz the actual amount that we'll be returning. - * Note that this effectively truncates the message if it is too long - * (since msgsz is never increased). - */ - - DPRINTF(("found a message, msgsz=%d, msg_ts=%d\n", msgsz, - msghdr->msg_ts)); - if (msgsz > msghdr->msg_ts) - msgsz = msghdr->msg_ts; - - /* - * Return the type to the user. - */ - - mtx_unlock(&msq_mtx); - error = copyout(&(msghdr->msg_type), user_msgp, - sizeof(msghdr->msg_type)); - mtx_lock(&msq_mtx); - if (error != 0) { - DPRINTF(("error (%d) copying out message type\n", error)); - msg_freehdr(msghdr); - wakeup(msqptr); - goto done2; - } - user_msgp = (char *)user_msgp + sizeof(msghdr->msg_type); - - /* - * Return the segments to the user - */ - - next = msghdr->msg_spot; - for (len = 0; len < msgsz; len += msginfo.msgssz) { - size_t tlen; - - if (msgsz - len > (unsigned long) msginfo.msgssz) - tlen = msginfo.msgssz; - else - tlen = msgsz - len; - if (next <= -1) - panic("next too low #3"); - if (next >= msginfo.msgseg) - panic("next out of range #3"); - mtx_unlock(&msq_mtx); - error = copyout(&msgpool[next * msginfo.msgssz], - user_msgp, tlen); - mtx_lock(&msq_mtx); - if (error != 0) { - DPRINTF(("error (%d) copying out message segment\n", - error)); - msg_freehdr(msghdr); - wakeup(msqptr); - goto done2; - } - user_msgp = (char *)user_msgp + tlen; - next = msgmaps[next].next; - } - - /* - * Done, return the actual number of bytes copied out. - */ - -#ifdef __CYGWIN__ - msg_info.msg_num--; - msg_info.msg_tot -= msgsz; -#endif /* __CYGWIN__ */ - - msg_freehdr(msghdr); - wakeup(msqptr); - td->td_retval[0] = msgsz; -done2: - mtx_unlock(&msq_mtx); - return (error); -} - -#ifndef __CYGWIN__ -static int -sysctl_msqids(SYSCTL_HANDLER_ARGS) -{ - - return (SYSCTL_OUT(req, msqids, - sizeof(struct msqid_ds) * msginfo.msgmni)); -} - -SYSCTL_DECL(_kern_ipc); -SYSCTL_INT(_kern_ipc, OID_AUTO, msgmax, CTLFLAG_RD, &msginfo.msgmax, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, msgmni, CTLFLAG_RDTUN, &msginfo.msgmni, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, msgmnb, CTLFLAG_RD, &msginfo.msgmnb, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, msgtql, CTLFLAG_RD, &msginfo.msgtql, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, msgssz, CTLFLAG_RDTUN, &msginfo.msgssz, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0, ""); -SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLFLAG_RD, - NULL, 0, sysctl_msqids, "", "Message queue IDs"); -#endif /* __CYGWIN__ */ -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/sysv_sem.cc b/winsup/cygserver/sysv_sem.cc deleted file mode 100644 index e7ba48b61..000000000 --- a/winsup/cygserver/sysv_sem.cc +++ /dev/null @@ -1,1389 +0,0 @@ -/* - * Implementation of SVID semaphores - * - * Author: Daniel Boulet - * - * This software is provided ``AS IS'' without any warranties of any kind. - */ - -/* - * This file is heavily changed to become part of Cygwin's cygserver. - */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#include <stdio.h> -#include <sys/cygwin.h> -#include <sys/cdefs.h> -#ifndef __FBSDID -#define __FBSDID(s) const char version[] = (s) -#endif -__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/kern/sysv_sem.c,v 1.70 2004/05/30 20:34:58 phk Exp $"); -/* CV, 2006-01-09: Inspected upstream up to version 1.78. */ - -#define _KERNEL 1 -#define __BSD_VISIBLE 1 -#include <sys/types.h> -#include <sys/ipc.h> - -#include <sys/param.h> -#include <sys/sysproto.h> -#include <sys/lock.h> -#include <sys/sem.h> -#include <sys/queue.h> -#include <malloc.h> -#include <errno.h> -#include <time.h> -#include "cygserver.h" -#include "process.h" -#include "cygserver_ipc.h" -#include <sys/smallprint.h> - -#ifdef __CYGWIN__ -#define __semctl semctl -#define __semctl_args semctl_args -#define SEM_DEBUG -#endif /* __CYGWIN__ */ - -#ifdef SEM_DEBUG -#define DPRINTF(a) debug_printf a -#else -#define DPRINTF(a) -#endif - -static int semvalid(int semid, struct semid_ds *semaptr); - -static struct sem_undo *semu_alloc(struct thread *td); -static int semundo_adjust(struct thread *td, struct sem_undo **supptr, - int semid, int semnum, int adjval); -static void semundo_clear(int semid, int semnum, struct thread *td); - -#ifndef _SYS_SYSPROTO_H_ -struct __semctl_args; -int __semctl(struct thread *td, struct __semctl_args *uap); -struct semget_args; -int semget(struct thread *td, struct semget_args *uap); -struct semop_args; -int semop(struct thread *td, struct semop_args *uap); -#endif - -#ifndef __CYGWIN__ -/* XXX casting to (sy_call_t *) is bogus, as usual. */ -static sy_call_t *semcalls[] = { - (sy_call_t *)__semctl, (sy_call_t *)semget, - (sy_call_t *)semop -}; -#endif - -static struct mtx sem_mtx; /* semaphore global lock */ -static int semtots = 0; -static int semtot = 0; -static struct semid_ds *sema; /* semaphore id pool */ -static struct mtx *sema_mtx; /* semaphore id pool mutexes*/ -static struct sem *sem; /* semaphore pool */ -static SLIST_HEAD(, sem_undo) semu_list; /* list of active undo structures */ -static int *semu; /* undo structure pool */ -#ifndef __CYGWIN__ -static eventhandler_tag semexit_tag; -#endif /* __CYGWIN__ */ - -#define SEMUNDO_MTX sem_mtx -#define SEMUNDO_LOCK() mtx_lock(&SEMUNDO_MTX); -#define SEMUNDO_HOOKLOCK() _mtx_lock(&SEMUNDO_MTX, p->winpid, __FILE__, __LINE__); -#define SEMUNDO_UNLOCK() mtx_unlock(&SEMUNDO_MTX); -#define SEMUNDO_LOCKASSERT(how,pid) mtx_assert(&SEMUNDO_MTX, (how), (pid)); - -struct sem { - u_short semval; /* semaphore value */ - pid_t sempid; /* pid of last operation */ - u_short semncnt; /* # awaiting semval > cval */ - u_short semzcnt; /* # awaiting semval = 0 */ -}; - -/* - * Undo structure (one per process) - */ -struct undo { - short un_adjval; /* adjust on exit values */ - short un_num; /* semaphore # */ - int un_id; /* semid */ -} un_ent[1]; /* undo entries */ - -struct sem_undo { - SLIST_ENTRY(sem_undo) un_next; /* ptr to next active undo structure */ -#ifdef __CYGWIN__ - DWORD un_proc; /* owner of this structure */ -#else - struct proc *un_proc; /* owner of this structure */ -#endif - short un_cnt; /* # of active entries */ - struct undo un_ent[1]; /* undo entries */ -}; - -/* - * Configuration parameters - */ -#ifndef SEMMNI -#define SEMMNI 10 /* # of semaphore identifiers */ -#endif -#ifndef SEMMNS -#define SEMMNS 60 /* # of semaphores in system */ -#endif -#ifndef SEMUME -#define SEMUME 10 /* max # of undo entries per process */ -#endif -#ifndef SEMMNU -#define SEMMNU 30 /* # of undo structures in system */ -#endif - -/* shouldn't need tuning */ -#ifndef SEMMAP -#define SEMMAP 30 /* # of entries in semaphore map */ -#endif -#ifndef SEMMSL -#define SEMMSL SEMMNS /* max # of semaphores per id */ -#endif -#ifndef SEMOPM -#define SEMOPM 100 /* max # of operations per semop call */ -#endif - -#ifndef SEMVMX -#define SEMVMX 32767 /* semaphore maximum value */ -#endif -#ifndef SEMAEM -#define SEMAEM 16384 /* adjust on exit max value */ -#endif - -#ifdef __CYGWIN__ -/* gcc 3.4 defines a new offsetof which is different for C++. Since this - file is just a derived plain-C file, we need to revert to the plain-C - definition of offsetof. */ -#ifdef offsetof -#undef offsetof -#endif -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif /* __CYGWIN__ */ -/* - * Due to the way semaphore memory is allocated, we have to ensure that - * SEMUSZ is properly aligned. - */ - -#define SEM_ALIGN(bytes) (((bytes) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) - -/* actual size of an undo structure */ -#define SEMUSZ SEM_ALIGN(offsetof(struct sem_undo, un_ent[SEMUME])) - -/* - * Macro to find a particular sem_undo vector - */ -#define SEMU(ix) \ - ((struct sem_undo *)(((intptr_t)semu)+ix * seminfo.semusz)) - -/* - * semaphore info struct - */ -struct seminfo seminfo = { - SEMMNI, /* # of semaphore identifiers */ - SEMMNS, /* # of semaphores in system */ - SEMMSL, /* max # of semaphores per id */ - SEMOPM, /* max # of operations per semop call */ - SEMMNU, /* # of undo structures in system */ - SEMUME, /* max # of undo entries per process */ - SEMVMX, /* semaphore maximum value */ - SEMAEM, /* adjust on exit max value */ - SEMMAP, /* # of entries in semaphore map */ - SEMUSZ /* size in bytes of undo structure */ -}; - -#ifndef __CYGWIN__ -SYSCTL_DECL(_kern_ipc); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmap, CTLFLAG_RW, &seminfo.semmap, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmni, CTLFLAG_RDTUN, &seminfo.semmni, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmns, CTLFLAG_RDTUN, &seminfo.semmns, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmnu, CTLFLAG_RDTUN, &seminfo.semmnu, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RW, &seminfo.semmsl, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semopm, CTLFLAG_RDTUN, &seminfo.semopm, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semume, CTLFLAG_RDTUN, &seminfo.semume, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RDTUN, &seminfo.semusz, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RW, &seminfo.semvmx, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RW, &seminfo.semaem, 0, ""); -SYSCTL_PROC(_kern_ipc, OID_AUTO, sema, CTLFLAG_RD, - NULL, 0, sysctl_sema, "", ""); -#endif /* __CYGWIN__ */ - -void -seminit(void) -{ - int i; - - TUNABLE_INT_FETCH("kern.ipc.semmap", &seminfo.semmap); - TUNABLE_INT_FETCH("kern.ipc.semmni", &seminfo.semmni); - TUNABLE_INT_FETCH("kern.ipc.semmns", &seminfo.semmns); - TUNABLE_INT_FETCH("kern.ipc.semmnu", &seminfo.semmnu); - TUNABLE_INT_FETCH("kern.ipc.semmsl", &seminfo.semmsl); - TUNABLE_INT_FETCH("kern.ipc.semopm", &seminfo.semopm); - TUNABLE_INT_FETCH("kern.ipc.semume", &seminfo.semume); - TUNABLE_INT_FETCH("kern.ipc.semusz", &seminfo.semusz); - TUNABLE_INT_FETCH("kern.ipc.semvmx", &seminfo.semvmx); - TUNABLE_INT_FETCH("kern.ipc.semaem", &seminfo.semaem); - -#ifdef __CYGWIN__ - /* It's too dangerous a setting to leave it alone. - Keep that clean here. */ - seminfo.semusz = SEM_ALIGN(offsetof(struct sem_undo, - un_ent[seminfo.semume])); -#endif /* __CYGWIN__ */ - - sem = (struct sem *) sys_malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK); - sema = (struct semid_ds *) sys_malloc(sizeof(struct semid_ds) * seminfo.semmni, M_SEM, - M_WAITOK); - sema_mtx = (struct mtx *) sys_malloc(sizeof(struct mtx) * seminfo.semmni, M_SEM, - M_WAITOK | M_ZERO); - semu = (int *) sys_malloc(seminfo.semmnu * seminfo.semusz, M_SEM, M_WAITOK); - - for (i = 0; i < seminfo.semmni; i++) { - sema[i].sem_base = 0; - sema[i].sem_perm.mode = 0; - sema[i].sem_perm.seq = 0; - } - for (i = 0; i < seminfo.semmni; i++) - { - char *buf = (char *) sys_malloc(16, M_SEM, M_WAITOK); - snprintf(buf, 16, "semid[%d]", i); - mtx_init(&sema_mtx[i], buf, NULL, MTX_DEF); - } - for (i = 0; i < seminfo.semmnu; i++) { - struct sem_undo *suptr = SEMU(i); -#ifdef __CYGWIN__ - suptr->un_proc = 0; -#else - suptr->un_proc = NULL; -#endif - } - SLIST_INIT(&semu_list); - mtx_init(&sem_mtx, "sem", NULL, MTX_DEF); -#ifndef __CYGWIN__ - semexit_tag = EVENTHANDLER_REGISTER(process_exit, semexit_myhook, NULL, - EVENTHANDLER_PRI_ANY); -#endif /* __CYGWIN__ */ -} - -int -semunload(void) -{ -#ifndef __CYGWIN__ /* Would result in being unable to shutdown the - server gracefully. */ - if (semtot != 0) - return (EBUSY); - - EVENTHANDLER_DEREGISTER(process_exit, semexit_tag); -#endif /* __CYGWIN__ */ - sys_free(sem, M_SEM); - sys_free(sema, M_SEM); - sys_free(semu, M_SEM); - for (int i = 0; i < seminfo.semmni; i++) { - sys_free((void *) sema_mtx[i].name, M_SEM); - mtx_destroy(&sema_mtx[i]); - } - mtx_destroy(&sem_mtx); - return (0); -} - -#ifndef __CYGWIN__ -static int -sysvsem_modload(struct module *module, int cmd, void *arg) -{ - int error = 0; - - switch (cmd) { - case MOD_LOAD: - seminit(); - break; - case MOD_UNLOAD: - error = semunload(); - break; - case MOD_SHUTDOWN: - break; - default: - error = EINVAL; - break; - } - return (error); -} - -static moduledata_t sysvsem_mod = { - "sysvsem", - &sysvsem_modload, - NULL -}; - -SYSCALL_MODULE_HELPER(semsys); -SYSCALL_MODULE_HELPER(__semctl); -SYSCALL_MODULE_HELPER(semget); -SYSCALL_MODULE_HELPER(semop); - -DECLARE_MODULE(sysvsem, sysvsem_mod, - SI_SUB_SYSV_SEM, SI_ORDER_FIRST); -MODULE_VERSION(sysvsem, 1); - -/* - * Entry point for all SEM calls - * - * MPSAFE - */ -int -semsys(td, uap) - struct thread *td; - /* XXX actually varargs. */ - struct semsys_args /* { - int which; - int a2; - int a3; - int a4; - int a5; - } */ *uap; -{ - int error; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - if (uap->which < 0 || - uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) - return (EINVAL); - error = (*semcalls[uap->which])(td, &uap->a2); - return (error); -} -#endif /* __CYGWIN__ */ - -/* - * Allocate a new sem_undo structure for a process - * (returns ptr to structure or NULL if no more room) - */ - -static struct sem_undo * -semu_alloc(struct thread *td) -{ - int i; - struct sem_undo *suptr; - struct sem_undo **supptr; - int attempt; - - SEMUNDO_LOCKASSERT(MA_OWNED, td->td_proc->winpid); - /* - * Try twice to allocate something. - * (we'll purge an empty structure after the first pass so - * two passes are always enough) - */ - - for (attempt = 0; attempt < 2; attempt++) { - /* - * Look for a free structure. - * Fill it in and return it if we find one. - */ - - for (i = 0; i < seminfo.semmnu; i++) { - suptr = SEMU(i); -#ifdef __CYGWIN__ - if (suptr->un_proc == 0) { -#else - if (suptr->un_proc == NULL) { -#endif - SLIST_INSERT_HEAD(&semu_list, suptr, un_next); - suptr->un_cnt = 0; - suptr->un_proc = td->td_proc->winpid; - return(suptr); - } - } - - /* - * We didn't find a free one, if this is the first attempt - * then try to free a structure. - */ - - if (attempt == 0) { - /* All the structures are in use - try to free one */ - int did_something = 0; - - SLIST_FOREACH_PREVPTR(suptr, supptr, &semu_list, - un_next) { - if (suptr->un_cnt == 0) { -#ifdef __CYGWIN__ - suptr->un_proc = 0; -#else - suptr->un_proc = NULL; -#endif - did_something = 1; - *supptr = SLIST_NEXT(suptr, un_next); - break; - } - } - - /* If we didn't free anything then just give-up */ - if (!did_something) - return(NULL); - } else { - /* - * The second pass failed even though we freed - * something after the first pass! - * This is IMPOSSIBLE! - */ - panic("semu_alloc - second attempt failed"); - } - } - return (NULL); -} - -/* - * Adjust a particular entry for a particular proc - */ - -static int -semundo_adjust(struct thread *td, struct sem_undo **supptr, int semid, - int semnum, int adjval) -{ - struct proc *p = td->td_proc; - struct sem_undo *suptr; - struct undo *sunptr; - int i; - - SEMUNDO_LOCKASSERT(MA_OWNED, td->td_proc->winpid); - /* Look for and remember the sem_undo if the caller doesn't provide - it */ - - suptr = *supptr; - if (suptr == NULL) { - SLIST_FOREACH(suptr, &semu_list, un_next) { -#ifdef __CYGWIN__ - if (suptr->un_proc == p->winpid) { -#else - if (suptr->un_proc == p) { -#endif - *supptr = suptr; - break; - } - } - if (suptr == NULL) { - if (adjval == 0) - return(0); - suptr = semu_alloc(td); - if (suptr == NULL) - return(ENOSPC); - *supptr = suptr; - } - } - - /* - * Look for the requested entry and adjust it (delete if adjval becomes - * 0). - */ - sunptr = &suptr->un_ent[0]; - for (i = 0; i < suptr->un_cnt; i++, sunptr++) { - if (sunptr->un_id != semid || sunptr->un_num != semnum) - continue; - if (adjval != 0) { - adjval += sunptr->un_adjval; - if (adjval > seminfo.semaem || adjval < -seminfo.semaem) - return (ERANGE); - } - sunptr->un_adjval = adjval; - if (sunptr->un_adjval == 0) { - suptr->un_cnt--; - if (i < suptr->un_cnt) - suptr->un_ent[i] = - suptr->un_ent[suptr->un_cnt]; - } - return(0); - } - - /* Didn't find the right entry - create it */ - if (adjval == 0) - return(0); - if (adjval > seminfo.semaem || adjval < -seminfo.semaem) - return (ERANGE); - if (suptr->un_cnt != seminfo.semume) { - sunptr = &suptr->un_ent[suptr->un_cnt]; - suptr->un_cnt++; - sunptr->un_adjval = adjval; - sunptr->un_id = semid; sunptr->un_num = semnum; - } else - return(EINVAL); - return(0); -} - -static void -semundo_clear(int semid, int semnum, struct thread *td) -{ - struct sem_undo *suptr; - - SEMUNDO_LOCKASSERT(MA_OWNED, td->td_proc->winpid); - SLIST_FOREACH(suptr, &semu_list, un_next) { - struct undo *sunptr = &suptr->un_ent[0]; - int i = 0; - - while (i < suptr->un_cnt) { - if (sunptr->un_id == semid) { - if (semnum == -1 || sunptr->un_num == semnum) { - suptr->un_cnt--; - if (i < suptr->un_cnt) { - suptr->un_ent[i] = - suptr->un_ent[suptr->un_cnt]; - continue; - } - if (semnum != -1) - break; - } - } - i++, sunptr++; - } - } -} - -static int -semvalid(int semid, struct semid_ds *semaptr) -{ - - return ((semaptr->sem_perm.mode & SEM_ALLOC) == 0 || - semaptr->sem_perm.seq != IPCID_TO_SEQ(semid) ? EINVAL : 0); -} - -/* - * Note that the user-mode half of this passes a union, not a pointer - */ -#ifndef _SYS_SYSPROTO_H_ -struct __semctl_args { - int semid; - int semnum; - int cmd; - union semun *arg; -}; -#endif - -/* - * MPSAFE - */ -int -__semctl(struct thread *td, struct __semctl_args *uap) -{ - int semid = uap->semid; - int semnum = uap->semnum; - int cmd = uap->cmd; - u_short *array; - union semun *arg = uap->arg; - union semun real_arg; -#ifndef __CYGWIN__ - struct ucred *cred = td->td_ucred; -#endif - int i, rval, error; - struct semid_ds sbuf; - struct semid_ds *semaptr; - struct mtx *sema_mtxp; - u_short usval, count; - - DPRINTF(("call to semctl(%d, %d, %d, 0x%x)\n", - semid, semnum, cmd, arg)); - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - - array = NULL; - - switch(cmd) { -#ifdef __CYGWIN__ - case IPC_INFO: - if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) - return (error); - if (!semid) { - error = copyout(&seminfo, real_arg.buf, - sizeof(struct seminfo)); - td->td_retval[0] = error ? -1 : 0; - return (error); - } - if (semid > seminfo.semmni) - semid = seminfo.semmni; - error = copyout(sema, real_arg.buf, - semid * sizeof(struct semid_ds)); - td->td_retval[0] = error ? -1 : 0; - return (error); - case SEM_INFO: - if (!(error = copyin(arg, &real_arg, sizeof(real_arg)))) { - struct sem_info sem_info; - sem_info.sem_ids = semtots; - sem_info.sem_num = semtot; - error = copyout(&sem_info, real_arg.buf, - sizeof(struct sem_info)); - } - td->td_retval[0] = error ? -1 : 0; - return (error); - -#endif /* __CYGWIN__ */ - case SEM_STAT: - if (semid < 0 || semid >= seminfo.semmni) - return (EINVAL); - if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) - return (error); - semaptr = &sema[semid]; - sema_mtxp = &sema_mtx[semid]; - mtx_lock(sema_mtxp); - if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0) { - error = EINVAL; - goto done2; - } - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) - goto done2; - mtx_unlock(sema_mtxp); - error = copyout(semaptr, real_arg.buf, sizeof(struct semid_ds)); - rval = IXSEQ_TO_IPCID(semid,semaptr->sem_perm); - if (error == 0) - td->td_retval[0] = rval; - return (error); - } - - semid = IPCID_TO_IX(semid); - if (semid < 0 || semid >= seminfo.semmni) - return (EINVAL); - - semaptr = &sema[semid]; - sema_mtxp = &sema_mtx[semid]; - - error = 0; - rval = 0; - - switch (cmd) { - case IPC_RMID: - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_M))) - goto done2; -#ifdef __CYGWIN__ - semaptr->sem_perm.cuid = td->ipcblk->uid; - semaptr->sem_perm.uid = td->ipcblk->uid; -#else - semaptr->sem_perm.cuid = cred->cr_uid; - semaptr->sem_perm.uid = cred->cr_uid; -#endif - semtot -= semaptr->sem_nsems; - semtots--; - for (i = semaptr->sem_base - sem; i < semtot; i++) - sem[i] = sem[i + semaptr->sem_nsems]; - for (i = 0; i < seminfo.semmni; i++) { - if ((sema[i].sem_perm.mode & SEM_ALLOC) && - sema[i].sem_base > semaptr->sem_base) - sema[i].sem_base -= semaptr->sem_nsems; - } - semaptr->sem_perm.mode = 0; - SEMUNDO_LOCK(); - semundo_clear(semid, -1, td); - SEMUNDO_UNLOCK(); - wakeup(semaptr); - break; - - case IPC_SET: - if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) - goto done2; - if ((error = copyin(real_arg.buf, &sbuf, sizeof(sbuf))) != 0) - goto done2; - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_M))) - goto done2; - semaptr->sem_perm.uid = sbuf.sem_perm.uid; - semaptr->sem_perm.gid = sbuf.sem_perm.gid; - semaptr->sem_perm.mode = (semaptr->sem_perm.mode & ~0777) | - (sbuf.sem_perm.mode & 0777); - semaptr->sem_ctime = time (NULL); - break; - - case IPC_STAT: - if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) - goto done2; - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) - goto done2; - sbuf = *semaptr; - mtx_unlock(sema_mtxp); - error = copyout(semaptr, real_arg.buf, - sizeof(struct semid_ds)); - break; - - case GETNCNT: - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) - goto done2; - if (semnum < 0 || semnum >= semaptr->sem_nsems) { - error = EINVAL; - goto done2; - } - rval = semaptr->sem_base[semnum].semncnt; - break; - - case GETPID: - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) - goto done2; - if (semnum < 0 || semnum >= semaptr->sem_nsems) { - error = EINVAL; - goto done2; - } - rval = semaptr->sem_base[semnum].sempid; - break; - - case GETVAL: - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) - goto done2; - if (semnum < 0 || semnum >= semaptr->sem_nsems) { - error = EINVAL; - goto done2; - } - rval = semaptr->sem_base[semnum].semval; - break; - - case GETALL: - if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) - goto done2; - array = (u_short *) sys_malloc(sizeof(*array) * semaptr->sem_nsems, M_TEMP, - M_WAITOK); - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) - goto done2; - for (i = 0; i < semaptr->sem_nsems; i++) - array[i] = semaptr->sem_base[i].semval; - mtx_unlock(sema_mtxp); - error = copyout(array, real_arg.array, - i * sizeof(real_arg.array[0])); - break; - - case GETZCNT: - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) - goto done2; - if (semnum < 0 || semnum >= semaptr->sem_nsems) { - error = EINVAL; - goto done2; - } - rval = semaptr->sem_base[semnum].semzcnt; - break; - - case SETVAL: - if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) - goto done2; - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_W))) - goto done2; - if (semnum < 0 || semnum >= semaptr->sem_nsems) { - error = EINVAL; - goto done2; - } - if (real_arg.val < 0 || real_arg.val > seminfo.semvmx) { - error = ERANGE; - goto done2; - } - semaptr->sem_base[semnum].semval = real_arg.val; - SEMUNDO_LOCK(); - semundo_clear(semid, semnum, td); - SEMUNDO_UNLOCK(); - wakeup(semaptr); - break; - - case SETALL: - mtx_lock(sema_mtxp); -raced: - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - count = semaptr->sem_nsems; - mtx_unlock(sema_mtxp); - if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) - goto done2; - array = (u_short *) sys_malloc(sizeof(*array) * count, M_TEMP, M_WAITOK); - error = copyin(real_arg.array, array, count * sizeof(*array)); - if (error) - break; - mtx_lock(sema_mtxp); - if ((error = semvalid(uap->semid, semaptr)) != 0) - goto done2; - /* we could have raced? */ - if (count != semaptr->sem_nsems) { - sys_free(array, M_TEMP); - array = NULL; - goto raced; - } - if ((error = ipcperm(td, &semaptr->sem_perm, IPC_W))) - goto done2; - for (i = 0; i < semaptr->sem_nsems; i++) { - usval = array[i]; - if (usval > seminfo.semvmx) { - error = ERANGE; - break; - } - semaptr->sem_base[i].semval = usval; - } - SEMUNDO_LOCK(); - semundo_clear(semid, -1, td); - SEMUNDO_UNLOCK(); - wakeup(semaptr); - break; - - default: - error = EINVAL; - break; - } - - if (error == 0) - td->td_retval[0] = rval; -done2: - if (mtx_owned(sema_mtxp, td->td_proc->winpid)) - mtx_unlock(sema_mtxp); - if (array != NULL) - sys_free(array, M_TEMP); - return(error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct semget_args { - key_t key; - int nsems; - int semflg; -}; -#endif - -/* - * MPSAFE - */ -int -semget(struct thread *td, struct semget_args *uap) -{ - int semid, error = 0; - key_t key = uap->key; - int nsems = uap->nsems; - int semflg = uap->semflg; -#ifndef __CYGWIN__ - struct ucred *cred = td->td_ucred; -#endif - - DPRINTF(("semget(0x%llx, %d, 0%o)\n", key, nsems, semflg)); - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - - mtx_lock(&Giant); - if (key != IPC_PRIVATE) { - for (semid = 0; semid < seminfo.semmni; semid++) { - if ((sema[semid].sem_perm.mode & SEM_ALLOC) && - sema[semid].sem_perm.key == key) - break; - } - if (semid < seminfo.semmni) { - DPRINTF(("found public key\n")); - if ((error = ipcperm(td, &sema[semid].sem_perm, - semflg & 0700))) { - goto done2; - } - if (nsems > 0 && sema[semid].sem_nsems < nsems) { - DPRINTF(("too small\n")); - error = EINVAL; - goto done2; - } - if ((semflg & IPC_CREAT) && (semflg & IPC_EXCL)) { - DPRINTF(("not exclusive\n")); - error = EEXIST; - goto done2; - } - goto found; - } - } - - DPRINTF(("need to allocate the semid_ds\n")); - if (key == IPC_PRIVATE || (semflg & IPC_CREAT)) { - if (nsems <= 0 || nsems > seminfo.semmsl) { - DPRINTF(("nsems out of range (0<%d<=%d)\n", nsems, - seminfo.semmsl)); - error = EINVAL; - goto done2; - } - if (nsems > seminfo.semmns - semtot) { - DPRINTF(( - "not enough semaphores left (need %d, got %d)\n", - nsems, seminfo.semmns - semtot)); - error = ENOSPC; - goto done2; - } - for (semid = 0; semid < seminfo.semmni; semid++) { - if ((sema[semid].sem_perm.mode & SEM_ALLOC) == 0) - break; - } - if (semid == seminfo.semmni) { - DPRINTF(("no more semid_ds's available\n")); - error = ENOSPC; - goto done2; - } - DPRINTF(("semid %d is available\n", semid)); - sema[semid].sem_perm.key = key; -#ifdef __CYGWIN__ - sema[semid].sem_perm.cuid = td->ipcblk->uid; - sema[semid].sem_perm.uid = td->ipcblk->uid; - sema[semid].sem_perm.cgid = td->ipcblk->gid; - sema[semid].sem_perm.gid = td->ipcblk->gid; -#else - sema[semid].sem_perm.cuid = cred->cr_uid; - sema[semid].sem_perm.uid = cred->cr_uid; - sema[semid].sem_perm.cgid = cred->cr_gid; - sema[semid].sem_perm.gid = cred->cr_gid; -#endif - sema[semid].sem_perm.mode = (semflg & 0777) | SEM_ALLOC; - sema[semid].sem_perm.seq = - (sema[semid].sem_perm.seq + 1) & 0x7fff; - sema[semid].sem_nsems = nsems; - sema[semid].sem_otime = 0; - sema[semid].sem_ctime = time (NULL); - sema[semid].sem_base = &sem[semtot]; - semtot += nsems; - semtots++; - bzero(sema[semid].sem_base, - sizeof(sema[semid].sem_base[0])*nsems); - DPRINTF(("sembase = 0x%x, next = 0x%x\n", sema[semid].sem_base, - &sem[semtot])); - } else { - DPRINTF(("didn't find it and wasn't asked to create it\n")); - error = ENOENT; - goto done2; - } - -found: - td->td_retval[0] = IXSEQ_TO_IPCID(semid, sema[semid].sem_perm); -done2: -#ifdef __CYGWIN__ - if (!error) - ipcexit_creat_hookthread (td); -#endif - mtx_unlock(&Giant); - return (error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct semop_args { - int semid; - struct sembuf *sops; - size_t nsops; -}; -#endif - -/* - * MPSAFE - */ -int -semop(struct thread *td, struct semop_args *uap) -{ -#define SMALL_SOPS 8 - struct sembuf small_sops[SMALL_SOPS]; - int semid = uap->semid; - size_t nsops = uap->nsops; - struct sembuf *sops; - struct semid_ds *semaptr; - struct sembuf *sopptr = 0; - struct sem *semptr = 0; - struct sem_undo *suptr; - struct mtx *sema_mtxp; - size_t i, j, k; - int error; - int do_wakeup, do_undos; - - DPRINTF(("call to semop(%d, 0x%x, %u)\n", semid, uap->sops, nsops)); - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - - semid = IPCID_TO_IX(semid); /* Convert back to zero origin */ - - if (semid < 0 || semid >= seminfo.semmni) - return (EINVAL); - - /* Allocate memory for sem_ops */ - if (nsops <= SMALL_SOPS) - sops = small_sops; - else if (nsops <= (unsigned long) seminfo.semopm) - sops = (struct sembuf *) sys_malloc(nsops * sizeof(*sops), M_SEM, M_WAITOK); - else { - DPRINTF(("too many sops (max=%d, nsops=%d)\n", seminfo.semopm, - nsops)); - return (E2BIG); - } - if ((error = copyin(uap->sops, sops, nsops * sizeof(sops[0]))) != 0) { - DPRINTF(("error = %d from copyin(%08x, %08x, %d)\n", error, - uap->sops, sops, nsops * sizeof(sops[0]))); - if (sops != small_sops) - sys_free(sops, M_SEM); - return (error); - } - - semaptr = &sema[semid]; - sema_mtxp = &sema_mtx[semid]; - mtx_lock(sema_mtxp); - if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0) { - error = EINVAL; - goto done2; - } - if (semaptr->sem_perm.seq != IPCID_TO_SEQ(uap->semid)) { - error = EINVAL; - goto done2; - } - /* - * Initial pass thru sops to see what permissions are needed. - * Also perform any checks that don't need repeating on each - * attempt to satisfy the request vector. - */ - j = 0; /* permission needed */ - do_undos = 0; - for (i = 0; i < nsops; i++) { - sopptr = &sops[i]; - if (sopptr->sem_num >= semaptr->sem_nsems) { - error = EFBIG; - goto done2; - } - if (sopptr->sem_flg & SEM_UNDO && sopptr->sem_op != 0) - do_undos = 1; - j |= (sopptr->sem_op == 0) ? SEM_R : SEM_A; - } - - if ((error = ipcperm(td, &semaptr->sem_perm, j))) { - DPRINTF(("error = %d from ipaccess\n", error)); - goto done2; - } - - /* - * Loop trying to satisfy the vector of requests. - * If we reach a point where we must wait, any requests already - * performed are rolled back and we go to sleep until some other - * process wakes us up. At this point, we start all over again. - * - * This ensures that from the perspective of other tasks, a set - * of requests is atomic (never partially satisfied). - */ - for (;;) { - do_wakeup = 0; - error = 0; /* error return if necessary */ - - for (i = 0; i < nsops; i++) { - sopptr = &sops[i]; - semptr = &semaptr->sem_base[sopptr->sem_num]; - - DPRINTF(( - "semop: semaptr=%x, sem_base=%x, " - "semptr=%x, sem[%d]=%d : op=%d, flag=%s\n", - semaptr, semaptr->sem_base, semptr, - sopptr->sem_num, semptr->semval, sopptr->sem_op, - (sopptr->sem_flg & IPC_NOWAIT) ? - "nowait" : "wait")); - - if (sopptr->sem_op < 0) { - if (semptr->semval + sopptr->sem_op < 0) { - DPRINTF(("semop: can't do it now\n")); - break; - } else { - semptr->semval += sopptr->sem_op; - if (semptr->semval == 0 && - semptr->semzcnt > 0) - do_wakeup = 1; - } - } else if (sopptr->sem_op == 0) { - if (semptr->semval != 0) { - DPRINTF(("semop: not zero now\n")); - break; - } - } else if (semptr->semval + sopptr->sem_op > - seminfo.semvmx) { - error = ERANGE; - break; - } else { - if (semptr->semncnt > 0) - do_wakeup = 1; - semptr->semval += sopptr->sem_op; - } - } - - /* - * Did we get through the entire vector? - */ - if (i >= nsops) - goto done; - - /* - * No ... rollback anything that we've already done - */ - DPRINTF(("semop: rollback 0 through %d\n", i-1)); - for (j = 0; j < i; j++) - semaptr->sem_base[sops[j].sem_num].semval -= - sops[j].sem_op; - - /* If we detected an error, return it */ - if (error != 0) - goto done2; - - /* - * If the request that we couldn't satisfy has the - * NOWAIT flag set then return with EAGAIN. - */ - if (sopptr->sem_flg & IPC_NOWAIT) { - error = EAGAIN; - goto done2; - } - - if (sopptr->sem_op == 0) - semptr->semzcnt++; - else - semptr->semncnt++; - - DPRINTF(("semop: good night!\n")); - error = msleep(semaptr, sema_mtxp, (PZERO - 4) | PCATCH, - "semwait", 0); - DPRINTF(("semop: good morning (error=%d)!\n", error)); - /* return code is checked below, after sem[nz]cnt-- */ - - /* - * Make sure that the semaphore still exists - */ - if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0 || - semaptr->sem_perm.seq != IPCID_TO_SEQ(uap->semid)) { - error = EIDRM; - goto done2; - } - - /* - * The semaphore is still alive. Readjust the count of - * waiting processes. - */ - if (sopptr->sem_op == 0) - semptr->semzcnt--; - else - semptr->semncnt--; - - /* - * Is it really morning, or was our sleep interrupted? - * (Delayed check of msleep() return code because we - * need to decrement sem[nz]cnt either way.) - */ - if (error != 0) { -#ifdef __CYGWIN__ - if (error != EIDRM) -#endif /* __CYGWIN__ */ - error = EINTR; - goto done2; - } - DPRINTF(("semop: good morning!\n")); - } - -done: - /* - * Process any SEM_UNDO requests. - */ - if (do_undos) { - SEMUNDO_LOCK(); - suptr = NULL; - for (i = 0; i < nsops; i++) { - /* - * We only need to deal with SEM_UNDO's for non-zero - * op's. - */ - int adjval; - - if ((sops[i].sem_flg & SEM_UNDO) == 0) - continue; - adjval = sops[i].sem_op; - if (adjval == 0) - continue; - error = semundo_adjust(td, &suptr, semid, - sops[i].sem_num, -adjval); - if (error == 0) - continue; - - /* - * Oh-Oh! We ran out of either sem_undo's or undo's. - * Rollback the adjustments to this point and then - * rollback the semaphore ups and down so we can return - * with an error with all structures restored. We - * rollback the undo's in the exact reverse order that - * we applied them. This guarantees that we won't run - * out of space as we roll things back out. - */ - for (j = 0; j < i; j++) { - k = i - j - 1; - if ((sops[k].sem_flg & SEM_UNDO) == 0) - continue; - adjval = sops[k].sem_op; - if (adjval == 0) - continue; - if (semundo_adjust(td, &suptr, semid, - sops[k].sem_num, adjval) != 0) - panic("semop - can't undo undos"); - } - - for (j = 0; j < nsops; j++) - semaptr->sem_base[sops[j].sem_num].semval -= - sops[j].sem_op; - - DPRINTF(("error = %d from semundo_adjust\n", error)); - SEMUNDO_UNLOCK(); - goto done2; - } /* loop through the sops */ - SEMUNDO_UNLOCK(); - } /* if (do_undos) */ - - /* We're definitely done - set the sempid's and time */ - for (i = 0; i < nsops; i++) { - sopptr = &sops[i]; - semptr = &semaptr->sem_base[sopptr->sem_num]; - semptr->sempid = td->td_proc->p_pid; - } - semaptr->sem_otime = time (NULL); - - /* - * Do a wakeup if any semaphore was up'd whilst something was - * sleeping on it. - */ - if (do_wakeup) { - DPRINTF(("semop: doing wakeup\n")); - wakeup(semaptr); - DPRINTF(("semop: back from wakeup\n")); - } - DPRINTF(("semop: done\n")); - td->td_retval[0] = 0; -done2: - mtx_unlock(sema_mtxp); - if (sops != small_sops) - sys_free(sops, M_SEM); - return (error); -} - -/* - * Go through the undo structures for this process and apply the adjustments to - * semaphores. - */ -void -semexit_myhook(void *arg, struct proc *p) -{ - struct sem_undo *suptr; - struct sem_undo **supptr; - - /* - * Go through the chain of undo vectors looking for one - * associated with this process. - */ - SEMUNDO_HOOKLOCK(); - SLIST_FOREACH_PREVPTR(suptr, supptr, &semu_list, un_next) { -#ifdef __CYGWIN__ - if (suptr->un_proc == p->winpid) -#else - if (suptr->un_proc == p) -#endif - break; - } -#ifndef __CYGWIN__ - SEMUNDO_UNLOCK(); -#endif - - if (suptr == NULL) { - SEMUNDO_UNLOCK(); - return; - } - -#ifdef __CYGWIN__ - DPRINTF(("proc @%u(%u) has undo structure with %d entries\n", - p->cygpid, p->winpid, suptr->un_cnt)); -#else - DPRINTF(("proc @%08x has undo structure with %d entries\n", p, - suptr->un_cnt)); -#endif - - /* - * If there are any active undo elements then process them. - */ - if (suptr->un_cnt > 0) { - int ix; - - for (ix = 0; ix < suptr->un_cnt; ix++) { - int semid = suptr->un_ent[ix].un_id; - int semnum = suptr->un_ent[ix].un_num; - int adjval = suptr->un_ent[ix].un_adjval; - struct semid_ds *semaptr; - struct mtx *sema_mtxp; - - semaptr = &sema[semid]; - sema_mtxp = &sema_mtx[semid]; -#ifdef __CYGWIN__ - _mtx_lock(sema_mtxp, p->winpid, __FILE__, __LINE__); -#else - mtx_lock(sema_mtxp); - SEMUNDO_HOOKLOCK(); -#endif - if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0) - panic("semexit - semid not allocated"); - if (semnum >= semaptr->sem_nsems) - panic("semexit - semnum out of range"); - - DPRINTF(( -#ifdef __CYGWIN__ - "semexit: %u id=%d num=%d(adj=%d) ; sem=%d\n", -#else - "semexit: %08x id=%d num=%d(adj=%d) ; sem=%d\n", -#endif - suptr->un_proc, suptr->un_ent[ix].un_id, - suptr->un_ent[ix].un_num, - suptr->un_ent[ix].un_adjval, - semaptr->sem_base[semnum].semval)); - - if (adjval < 0) { - if (semaptr->sem_base[semnum].semval < -adjval) - semaptr->sem_base[semnum].semval = 0; - else - semaptr->sem_base[semnum].semval += - adjval; - } else - semaptr->sem_base[semnum].semval += adjval; - - wakeup(semaptr); - DPRINTF(("semexit: back from wakeup\n")); - _mtx_unlock(sema_mtxp, __FILE__, __LINE__); -#ifndef __CYGWIN__ - SEMUNDO_UNLOCK(); -#endif - } - } - - /* - * Deallocate the undo vector. - */ - DPRINTF(("removing vector (%u)\n", suptr->un_proc)); -#ifdef __CYGWIN__ - suptr->un_proc = 0; -#else - suptr->un_proc = NULL; -#endif - *supptr = SLIST_NEXT(suptr, un_next); -#ifdef __CYGWIN__ - SEMUNDO_UNLOCK(); -#endif -} - -#ifndef __CYGWIN__ -static int -sysctl_sema(SYSCTL_HANDLER_ARGS) -{ - - return (SYSCTL_OUT(req, sema, - sizeof(struct semid_ds) * seminfo.semmni)); -} -#endif /* __CYGWIN__ */ -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/sysv_shm.cc b/winsup/cygserver/sysv_shm.cc deleted file mode 100644 index 4578c53a2..000000000 --- a/winsup/cygserver/sysv_shm.cc +++ /dev/null @@ -1,1045 +0,0 @@ -/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */ -/* - * Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Adam Glass and Charles - * Hannum. - * 4. The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This file is heavily changed to become part of Cygwin's cygserver. - */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#include <sys/cdefs.h> -#ifndef __FBSDID -#define __FBSDID(s) const char version[] = (s) -#endif -__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/kern/sysv_shm.c,v 1.89 2003/11/07 04:47:14 rwatson Exp $"); -/* CV, 2006-01-09: Inspected upstream up to version 1.104. */ - -#define _KERNEL 1 -#define __BSD_VISIBLE 1 -#include <sys/param.h> -#include <sys/lock.h> -#include <sys/shm.h> -#include <malloc.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/sysproto.h> - -#include <errno.h> -#include <time.h> -#include <unistd.h> -#include "cygserver.h" -#include "process.h" -#include "cygserver_ipc.h" - -#ifdef __CYGWIN__ -#ifndef PAGE_SIZE -#define PAGE_SIZE (getpagesize ()) -#endif -#ifndef PAGE_MASK -#define PAGE_MASK (PAGE_SIZE - 1) -#endif -#define btoc(b) (((b) + PAGE_MASK) / PAGE_SIZE) -#define round_page(p) ((((unsigned long)(p)) + PAGE_MASK) & ~(PAGE_MASK)) -#ifdef __CYGWIN__ -#define GIANT_REQUIRED -#else -#define GIANT_REQUIRED mtx_assert(&Giant, MA_OWNED) -#endif -#define KERN_SUCCESS 0 -#define VM_PROT_READ PROT_READ -#define VM_PROT_WRITE PROT_WRITE -#define VM_INHERIT_SHARE 0 -#define OBJT_PHYS 0 -#define OBJT_SWAP 0 -#define VM_PROT_DEFAULT 0 -#define VM_OBJECT_LOCK(a) -#define vm_object_clear_flag(a,b) -#define vm_object_set_flag(a,b) -#define VM_OBJECT_UNLOCK(a) -#define vm_map_remove(a,b,c) KERN_SUCCESS -typedef int vm_prot_t; -#endif /* __CYGWIN__ */ - -#ifndef __CYGWIN__ -static MALLOC_DEFINE(M_SHM, "shm", "SVID compatible shared memory segments"); - -struct oshmctl_args; -static int oshmctl(struct thread *td, struct oshmctl_args *uap); -#endif /* __CYGWIN__ */ - -static int shmget_allocate_segment(struct thread *td, - struct shmget_args *uap, int mode); -static int shmget_existing(struct thread *td, struct shmget_args *uap, - int mode, int segnum); - -#ifndef __CYGWIN__ -/* XXX casting to (sy_call_t *) is bogus, as usual. */ -static sy_call_t *shmcalls[] = { - (sy_call_t *)shmat, (sy_call_t *)oshmctl, - (sy_call_t *)shmdt, (sy_call_t *)shmget, - (sy_call_t *)shmctl -}; -#endif /* __CYGWIN__ */ - -#define SHMSEG_FREE 0x0200 -#define SHMSEG_REMOVED 0x0400 -#define SHMSEG_ALLOCATED 0x0800 -#define SHMSEG_WANTED 0x1000 - -static int shm_last_free, shm_nused, shm_committed, shmalloced, shm_nattch; -static struct shmid_ds *shmsegs; - -struct shm_handle { - /* vm_offset_t kva; */ - vm_object_t shm_object; -}; - -struct shmmap_state { - vm_offset_t va; - int shmid; -}; - -static void shm_deallocate_segment(struct shmid_ds *); -static int shm_find_segment_by_key(key_t); -static struct shmid_ds *shm_find_segment_by_shmid(int); -static struct shmid_ds *shm_find_segment_by_shmidx(int); -static int shm_delete_mapping(struct vmspace *vm, struct shmmap_state *); -static void shmrealloc(void); - -/* - * Tuneable values. - */ -#ifndef SHMMAXPGS -#define SHMMAXPGS 8192 /* Note: sysv shared memory is swap backed. */ -#endif -#ifndef SHMMAX -#define SHMMAX (SHMMAXPGS*PAGE_SIZE) -#endif -#ifndef SHMMIN -#define SHMMIN 1 -#endif -#ifndef SHMMNI -#define SHMMNI 192 -#endif -#ifndef SHMSEG -#define SHMSEG 128 -#endif -#ifndef SHMALL -#define SHMALL (SHMMAXPGS) -#endif - -struct shminfo shminfo = { - SHMMAX, - SHMMIN, - SHMMNI, - SHMSEG, - SHMALL -}; - -#ifndef __CYGWIN__ -static int shm_use_phys; -#else -static long shm_use_phys; -static long shm_allow_removed; -#endif /* __CYGWIN__ */ - -#ifndef __CYGWIN__ -struct shm_info shm_info; -#endif /* __CYGWIN__ */ - -#ifndef __CYGWIN__ -SYSCTL_DECL(_kern_ipc); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RDTUN, &shminfo.shmmni, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RDTUN, &shminfo.shmseg, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RW, - &shm_use_phys, 0, ""); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_allow_removed, CTLFLAG_RW, - &shm_allow_removed, 0, ""); -SYSCTL_PROC(_kern_ipc, OID_AUTO, shmsegs, CTLFLAG_RD, - NULL, 0, sysctl_shmsegs, "", ""); -#endif /* __CYGWIN__ */ - -static int -shm_find_segment_by_key(key_t key) -{ - int i; - - for (i = 0; i < shmalloced; i++) - if ((shmsegs[i].shm_perm.mode & SHMSEG_ALLOCATED) && - shmsegs[i].shm_perm.key == key) - return (i); - return (-1); -} - -static struct shmid_ds * -shm_find_segment_by_shmid(int shmid) -{ - int segnum; - struct shmid_ds *shmseg; - - segnum = IPCID_TO_IX(shmid); - if (segnum < 0 || segnum >= shmalloced) - return (NULL); - shmseg = &shmsegs[segnum]; - if ((shmseg->shm_perm.mode & SHMSEG_ALLOCATED) == 0 || - (!shm_allow_removed && - (shmseg->shm_perm.mode & SHMSEG_REMOVED) != 0) || - shmseg->shm_perm.seq != IPCID_TO_SEQ(shmid)) - return (NULL); - return (shmseg); -} - -static struct shmid_ds * -shm_find_segment_by_shmidx(int segnum) -{ - struct shmid_ds *shmseg; - - if (segnum < 0 || segnum >= shmalloced) - return (NULL); - shmseg = &shmsegs[segnum]; - if ((shmseg->shm_perm.mode & SHMSEG_ALLOCATED) == 0 || - (!shm_allow_removed && - (shmseg->shm_perm.mode & SHMSEG_REMOVED) != 0)) - return (NULL); - return (shmseg); -} - -static void -shm_deallocate_segment(struct shmid_ds *shmseg) -{ - struct shm_handle *shm_handle; - size_t size; - - GIANT_REQUIRED; - - shm_handle = shmseg->shm_internal; - vm_object_deallocate(shm_handle->shm_object); - sys_free(shm_handle, M_SHM); - shmseg->shm_internal = NULL; - size = round_page(shmseg->shm_segsz); - shm_committed -= btoc(size); - shm_nused--; - shmseg->shm_perm.mode = SHMSEG_FREE; -} - -static int -shm_delete_mapping(struct vmspace *vm, struct shmmap_state *shmmap_s) -{ - struct shmid_ds *shmseg; - int segnum, result; - size_t size __attribute__ ((unused)); - - GIANT_REQUIRED; - - segnum = IPCID_TO_IX(shmmap_s->shmid); - shmseg = &shmsegs[segnum]; - size = round_page(shmseg->shm_segsz); - result = vm_map_remove(&vm->vm_map, shmmap_s->va, shmmap_s->va + size); - if (result != KERN_SUCCESS) - return (EINVAL); - shmmap_s->shmid = -1; - shmseg->shm_dtime = time (NULL); - --shm_nattch; - if ((--shmseg->shm_nattch <= 0) && - (shmseg->shm_perm.mode & SHMSEG_REMOVED)) { - shm_deallocate_segment(shmseg); - shm_last_free = segnum; - } - return (0); -} - -#ifndef _SYS_SYSPROTO_H_ -struct shmdt_args { - const void *shmaddr; -}; -#endif - -/* - * MPSAFE - */ -int -shmdt(struct thread *td, struct shmdt_args *uap) -{ - struct proc *p = td->td_proc; - struct shmmap_state *shmmap_s; - int i; - int error = 0; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - mtx_lock(&Giant); - shmmap_s = p->p_vmspace->vm_shm; - if (shmmap_s == NULL) { - error = EINVAL; - goto done2; - } - for (i = 0; i < shminfo.shmseg; i++, shmmap_s++) { - if (shmmap_s->shmid != -1 && - shmmap_s->va == (vm_offset_t)uap->shmaddr) { - break; - } - } - if (i == shminfo.shmseg) { - error = EINVAL; - goto done2; - } - error = shm_delete_mapping(p->p_vmspace, shmmap_s); -done2: - mtx_unlock(&Giant); - return (error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct shmat_args { - int shmid; - const void *shmaddr; - int shmflg; -}; -#endif - -/* - * MPSAFE - */ -int -kern_shmat(struct thread *td, int shmid, const void *shmaddr, int shmflg) -{ - struct proc *p = td->td_proc; - int i, flags __attribute__ ((unused)); - struct shmid_ds *shmseg; - struct shmmap_state *shmmap_s = NULL; -#ifndef __CYGWIN__ - struct shm_handle *shm_handle; -#endif - vm_offset_t attach_va; - vm_prot_t prot; - vm_size_t size; -#ifndef __CYGWIN__ - int rv; -#endif - int error = 0; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - mtx_lock(&Giant); - shmmap_s = p->p_vmspace->vm_shm; - if (shmmap_s == NULL) { - size = shminfo.shmseg * sizeof(struct shmmap_state); - shmmap_s = (struct shmmap_state *) sys_malloc(size, M_SHM, M_WAITOK); - for (i = 0; i < shminfo.shmseg; i++) - shmmap_s[i].shmid = -1; - p->p_vmspace->vm_shm = shmmap_s; - } - shmseg = shm_find_segment_by_shmid(shmid); - if (shmseg == NULL) { - error = EINVAL; - goto done2; - } - error = ipcperm(td, &shmseg->shm_perm, - (shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W); - if (error) - goto done2; - for (i = 0; i < shminfo.shmseg; i++) { - if (shmmap_s->shmid == -1) - break; - shmmap_s++; - } - if (i >= shminfo.shmseg) { - error = EMFILE; - goto done2; - } - size = round_page(shmseg->shm_segsz); -#ifdef VM_PROT_READ_IS_EXEC - prot = VM_PROT_READ | VM_PROT_EXECUTE; -#else - prot = VM_PROT_READ; -#endif - if ((shmflg & SHM_RDONLY) == 0) - prot |= VM_PROT_WRITE; - flags = MAP_ANON | MAP_SHARED; - debug_printf ("shmaddr: %x, shmflg: %x", shmaddr, shmflg); -#ifdef __CYGWIN__ - /* The alignment checks have already been made in the Cygwin DLL - and shmat's only job is to keep record of the attached mem. - These checks break shm on 9x since MapViewOfFileEx apparently - returns memory which isn't aligned to SHMLBA. Go figure! */ - attach_va = (vm_offset_t)shmaddr; -#else - if (shmaddr) { - flags |= MAP_FIXED; - if (shmflg & SHM_RND) { - attach_va = (vm_offset_t)shmaddr & ~(SHMLBA-1); - } else if (((vm_offset_t)shmaddr & (SHMLBA-1)) == 0) { - attach_va = (vm_offset_t)shmaddr; - } else { - error = EINVAL; - goto done2; - } - } else { - /* - * This is just a hint to vm_map_find() about where to - * put it. - */ - attach_va = round_page((vm_offset_t)p->p_vmspace->vm_taddr - + maxtsiz + maxdsiz); - } - - shm_handle = shmseg->shm_internal; - vm_object_reference(shm_handle->shm_object); - rv = vm_map_find(&p->p_vmspace->vm_map, shm_handle->shm_object, - 0, &attach_va, size, (flags & MAP_FIXED)?0:1, prot, prot, 0); - if (rv != KERN_SUCCESS) { - error = ENOMEM; - goto done2; - } - vm_map_inherit(&p->p_vmspace->vm_map, - attach_va, attach_va + size, VM_INHERIT_SHARE); -#endif - - shmmap_s->va = attach_va; - shmmap_s->shmid = shmid; - shmseg->shm_lpid = p->p_pid; - shmseg->shm_atime = time (NULL); - shmseg->shm_nattch++; - shm_nattch++; - td->td_retval[0] = attach_va; -done2: - mtx_unlock(&Giant); - return (error); -} - -int -shmat(struct thread *td, struct shmat_args *uap) -{ - return kern_shmat(td, uap->shmid, uap->shmaddr, uap->shmflg); -} - -#ifndef __CYGWIN__ -struct oshmid_ds { - struct ipc_perm shm_perm; /* operation perms */ - int shm_segsz; /* size of segment (bytes) */ - u_short shm_cpid; /* pid, creator */ - u_short shm_lpid; /* pid, last operation */ - short shm_nattch; /* no. of current attaches */ - time_t shm_atime; /* last attach time */ - time_t shm_dtime; /* last detach time */ - time_t shm_ctime; /* last change time */ - void *shm_handle; /* internal handle for shm segment */ -}; - -struct oshmctl_args { - int shmid; - int cmd; - struct oshmid_ds *ubuf; -}; - -/* - * MPSAFE - */ -static int -oshmctl(struct thread *td, struct oshmctl_args *uap) -{ -#ifdef COMPAT_43 - int error = 0; - struct shmid_ds *shmseg; - struct oshmid_ds outbuf; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - mtx_lock(&Giant); - shmseg = shm_find_segment_by_shmid(uap->shmid); - if (shmseg == NULL) { - error = EINVAL; - goto done2; - } - switch (uap->cmd) { - case IPC_STAT: - error = ipcperm(td, &shmseg->shm_perm, IPC_R); - if (error) - goto done2; - outbuf.shm_perm = shmseg->shm_perm; - outbuf.shm_segsz = shmseg->shm_segsz; - outbuf.shm_cpid = shmseg->shm_cpid; - outbuf.shm_lpid = shmseg->shm_lpid; - outbuf.shm_nattch = shmseg->shm_nattch; - outbuf.shm_atime = shmseg->shm_atime; - outbuf.shm_dtime = shmseg->shm_dtime; - outbuf.shm_ctime = shmseg->shm_ctime; - outbuf.shm_handle = shmseg->shm_internal; - error = copyout(&outbuf, uap->ubuf, sizeof(outbuf)); - if (error) - goto done2; - break; - default: - /* XXX casting to (sy_call_t *) is bogus, as usual. */ - error = ((sy_call_t *)shmctl)(td, uap); - break; - } -done2: - mtx_unlock(&Giant); - return (error); -#else - return (EINVAL); -#endif -} -#endif /* !__CYGWIN__ */ - -#ifndef _SYS_SYSPROTO_H_ -struct shmctl_args { - int shmid; - int cmd; - struct shmid_ds *buf; -}; -#endif - -/* - * MPSAFE - */ -int -kern_shmctl(struct thread *td, int shmid, int cmd, void *buf, size_t *bufsz) -{ - int error = 0; - struct shmid_ds *shmseg; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - - mtx_lock(&Giant); - switch (cmd) { - case IPC_INFO: - memcpy(buf, &shminfo, sizeof(shminfo)); - if (bufsz) - *bufsz = sizeof(shminfo); - td->td_retval[0] = shmalloced; - goto done2; - case SHM_INFO: { - struct shm_info shm_info; - shm_info.used_ids = shm_nused; - shm_info.shm_tot = shm_committed * PAGE_SIZE; -#ifdef __CYGWIN__ - shm_info.shm_atts = shm_nattch; -#else - shm_info.shm_rss = 0; /*XXX where to get from ? */ - shm_info.shm_swp = 0; /*XXX where to get from ? */ - shm_info.swap_attempts = 0; /*XXX where to get from ? */ - shm_info.swap_successes = 0; /*XXX where to get from ? */ -#endif /* __CYGWIN__ */ - memcpy(buf, &shm_info, sizeof(shm_info)); - if (bufsz) - *bufsz = sizeof(shm_info); - td->td_retval[0] = shmalloced; - goto done2; - } - } - if (cmd == SHM_STAT) - shmseg = shm_find_segment_by_shmidx(shmid); - else - shmseg = shm_find_segment_by_shmid(shmid); - if (shmseg == NULL) { - error = EINVAL; - goto done2; - } - switch (cmd) { - case SHM_STAT: - case IPC_STAT: - error = ipcperm(td, &shmseg->shm_perm, IPC_R); - if (error) - goto done2; - memcpy(buf, shmseg, sizeof(struct shmid_ds)); - if (bufsz) - *bufsz = sizeof(struct shmid_ds); - if (cmd == SHM_STAT) - td->td_retval[0] = IXSEQ_TO_IPCID(shmid, shmseg->shm_perm); - break; - case IPC_SET: { - struct shmid_ds *shmid; - - shmid = (struct shmid_ds *)buf; - error = ipcperm(td, &shmseg->shm_perm, IPC_M); - if (error) - goto done2; - shmseg->shm_perm.uid = shmid->shm_perm.uid; - shmseg->shm_perm.gid = shmid->shm_perm.gid; - shmseg->shm_perm.mode = - (shmseg->shm_perm.mode & ~ACCESSPERMS) | - (shmid->shm_perm.mode & ACCESSPERMS); - shmseg->shm_ctime = time (NULL); - break; - } - case IPC_RMID: - error = ipcperm(td, &shmseg->shm_perm, IPC_M); - if (error) - goto done2; - shmseg->shm_perm.key = IPC_PRIVATE; - shmseg->shm_perm.mode |= SHMSEG_REMOVED; - if (shmseg->shm_nattch <= 0) { - shm_deallocate_segment(shmseg); - shm_last_free = IPCID_TO_IX(shmid); - } - break; -#if 0 - case SHM_LOCK: - case SHM_UNLOCK: -#endif - default: - error = EINVAL; - break; - } -done2: - mtx_unlock(&Giant); - return (error); -} - -int -shmctl(struct thread *td, struct shmctl_args *uap) -{ - int error = 0; - struct shmid_ds buf; - size_t bufsz; - - /* IPC_SET needs to copyin the buffer before calling kern_shmctl */ - if (uap->cmd == IPC_SET) { - if ((error = copyin(uap->buf, &buf, sizeof(struct shmid_ds)))) - goto done; - } -#ifdef __CYGWIN__ - if (uap->cmd == IPC_INFO && uap->shmid > 0) { - /* Can't use the default kern_shmctl interface. */ - int shmid = uap->shmid; - if (shmid > shminfo.shmmni) - shmid = shminfo.shmmni; - error = copyout(shmsegs, uap->buf, - shmid * sizeof(struct shmid_ds)); - td->td_retval[0] = error ? -1 : 0; - return (error); - } -#endif /* __CYGWIN__ */ - - error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&buf, &bufsz); - if (error) - goto done; - - /* Cases in which we need to copyout */ - switch (uap->cmd) { - case IPC_INFO: - case SHM_INFO: - case SHM_STAT: - case IPC_STAT: - error = copyout(&buf, uap->buf, bufsz); - break; - } - -done: - if (error) { - /* Invalidate the return value */ - td->td_retval[0] = -1; - } - return (error); -} - - -#ifndef _SYS_SYSPROTO_H_ -struct shmget_args { - key_t key; - size_t size; - int shmflg; -}; -#endif - -static int -shmget_existing(struct thread *td, struct shmget_args *uap, int mode, int segnum) -{ - struct shmid_ds *shmseg; - int error; - - shmseg = &shmsegs[segnum]; - if (shmseg->shm_perm.mode & SHMSEG_REMOVED) { - /* - * This segment is in the process of being allocated. Wait - * until it's done, and look the key up again (in case the - * allocation failed or it was freed). - */ - shmseg->shm_perm.mode |= SHMSEG_WANTED; - error = tsleep(shmseg, PLOCK | PCATCH, "shmget", 0); - if (error) - return (error); - return (EAGAIN); - } - if ((uap->shmflg & (IPC_CREAT | IPC_EXCL)) == (IPC_CREAT | IPC_EXCL)) - return (EEXIST); - error = ipcperm(td, &shmseg->shm_perm, mode); - if (error) - return (error); - if (uap->size && uap->size > shmseg->shm_segsz) - return (EINVAL); - td->td_retval[0] = IXSEQ_TO_IPCID(segnum, shmseg->shm_perm); -#ifdef __CYGWIN__ - td->td_retval[1] = - vm_object_duplicate(td, shmseg->shm_internal->shm_object); -#endif /* __CYGWIN__ */ - return (0); -} - -static int -shmget_allocate_segment(struct thread *td, struct shmget_args *uap, int mode) -{ - int i, segnum, shmid, size; -#ifndef __CYGWIN__ - struct ucred *cred = td->td_ucred; -#endif /* __CYGWIN__ */ - struct shmid_ds *shmseg; - struct shm_handle *shm_handle; - - GIANT_REQUIRED; - - if (uap->size < (unsigned long) shminfo.shmmin || - uap->size > (unsigned long) shminfo.shmmax) - return (EINVAL); - if (shm_nused >= shminfo.shmmni) /* Any shmids left? */ - return (ENOSPC); - size = round_page(uap->size); - if (shm_committed + btoc(size) > shminfo.shmall) - return (ENOMEM); - if (shm_last_free < 0) { - shmrealloc(); /* Maybe expand the shmsegs[] array. */ - for (i = 0; i < shmalloced; i++) - if (shmsegs[i].shm_perm.mode & SHMSEG_FREE) - break; - if (i == shmalloced) - return (ENOSPC); - segnum = i; - } else { - segnum = shm_last_free; - shm_last_free = -1; - } - shmseg = &shmsegs[segnum]; - /* - * In case we sleep in malloc(), mark the segment present but deleted - * so that noone else tries to create the same key. - */ - shmseg->shm_perm.mode = SHMSEG_ALLOCATED | SHMSEG_REMOVED; - shmseg->shm_perm.key = uap->key; - shmseg->shm_perm.seq = (shmseg->shm_perm.seq + 1) & 0x7fff; - shm_handle = (struct shm_handle *) - sys_malloc(sizeof(struct shm_handle), M_SHM, M_WAITOK); - shmid = IXSEQ_TO_IPCID(segnum, shmseg->shm_perm); - - /* - * We make sure that we have allocated a pager before we need - * to. - */ - if (shm_use_phys) { - shm_handle->shm_object = - vm_pager_allocate(OBJT_PHYS, 0, size, VM_PROT_DEFAULT, 0); - } else { - shm_handle->shm_object = - vm_pager_allocate(OBJT_SWAP, 0, size, VM_PROT_DEFAULT, 0); - } - VM_OBJECT_LOCK(shm_handle->shm_object); - vm_object_clear_flag(shm_handle->shm_object, OBJ_ONEMAPPING); - vm_object_set_flag(shm_handle->shm_object, OBJ_NOSPLIT); - VM_OBJECT_UNLOCK(shm_handle->shm_object); - - shmseg->shm_internal = shm_handle; -#ifdef __CYGWIN__ - shmseg->shm_perm.cuid = shmseg->shm_perm.uid = td->ipcblk->uid; - shmseg->shm_perm.cgid = shmseg->shm_perm.gid = td->ipcblk->gid; -#else - shmseg->shm_perm.cuid = shmseg->shm_perm.uid = cred->cr_uid; - shmseg->shm_perm.cgid = shmseg->shm_perm.gid = cred->cr_gid; -#endif /* __CYGWIN__ */ - shmseg->shm_perm.mode = (shmseg->shm_perm.mode & SHMSEG_WANTED) | - (mode & ACCESSPERMS) | SHMSEG_ALLOCATED; - shmseg->shm_segsz = uap->size; - shmseg->shm_cpid = td->td_proc->p_pid; - shmseg->shm_lpid = shmseg->shm_nattch = 0; - shmseg->shm_atime = shmseg->shm_dtime = 0; - shmseg->shm_ctime = time (NULL); - shm_committed += btoc(size); - shm_nused++; - if (shmseg->shm_perm.mode & SHMSEG_WANTED) { - /* - * Somebody else wanted this key while we were asleep. Wake - * them up now. - */ - shmseg->shm_perm.mode &= ~SHMSEG_WANTED; - wakeup(shmseg); - } - td->td_retval[0] = shmid; -#ifdef __CYGWIN__ - td->td_retval[1] = - vm_object_duplicate(td, shmseg->shm_internal->shm_object); -#endif /* __CYGWIN__ */ - return (0); -} - -/* - * MPSAFE - */ -int -shmget(struct thread *td, struct shmget_args *uap) -{ - int segnum, mode; - int error; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - mtx_lock(&Giant); - mode = uap->shmflg & ACCESSPERMS; - if (uap->key != IPC_PRIVATE) { - again: -#ifdef __CYGWIN__ - if (uap->shmflg & IPC_KEY_IS_SHMID) - segnum = shm_find_segment_by_shmid ((int) uap->key) ? - IPCID_TO_IX((int) uap->key) : -1; - else -#endif - segnum = shm_find_segment_by_key(uap->key); - if (segnum >= 0) { - error = shmget_existing(td, uap, mode, segnum); - if (error == EAGAIN) - goto again; - goto done2; - } - if ((uap->shmflg & IPC_CREAT) == 0) { - error = ENOENT; - goto done2; - } - } - error = shmget_allocate_segment(td, uap, mode); -done2: -#ifdef __CYGWIN__ - if (!error) - ipcexit_creat_hookthread (td); - else - td->td_retval[0] = -1; -#endif - mtx_unlock(&Giant); - return (error); -} - -#ifndef __CYGWIN__ -/* - * MPSAFE - */ -int -shmsys(td, uap) - struct thread *td; - /* XXX actually varargs. */ - struct shmsys_args /* { - int which; - int a2; - int a3; - int a4; - } */ *uap; -{ - int error; - - if (!jail_sysvipc_allowed && jailed(td->td_ucred)) - return (ENOSYS); - if (uap->which < 0 || - uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0])) - return (EINVAL); - mtx_lock(&Giant); - error = (*shmcalls[uap->which])(td, &uap->a2); - mtx_unlock(&Giant); - return (error); -} -#endif /* __CYGWIN__ */ - -static void -shmfork_myhook(struct proc *p1, struct proc *p2) -{ - struct shmmap_state *shmmap_s; - size_t size; - int i; - - size = shminfo.shmseg * sizeof(struct shmmap_state); - shmmap_s = (struct shmmap_state *) sys_malloc(size, M_SHM, M_WAITOK); - bcopy(p1->p_vmspace->vm_shm, shmmap_s, size); - p2->p_vmspace->vm_shm = shmmap_s; - for (i = 0; i < shminfo.shmseg; i++, shmmap_s++) - if (shmmap_s->shmid != -1) { - shm_nattch++; - shmsegs[IPCID_TO_IX(shmmap_s->shmid)].shm_nattch++; - } -} - -#ifdef __CYGWIN__ -int cygwin_shmfork_myhook (struct thread *td, struct proc *parent) -{ - ipcexit_creat_hookthread (td); - ipc_p_vmspace (td->ipcblk); - ipc_p_vmspace (parent); - shmfork_myhook (parent, td->ipcblk); - return 0; -} -#endif - -void -shmexit_myhook(struct vmspace *vm) -{ - struct shmmap_state *base, *shm; - int i; - - GIANT_REQUIRED; - - if ((base = vm->vm_shm) != NULL) { - vm->vm_shm = NULL; - for (i = 0, shm = base; i < shminfo.shmseg; i++, shm++) { - if (shm->shmid != -1) - shm_delete_mapping(vm, shm); - } - sys_free(base, M_SHM); - } -} - -static void -shmrealloc(void) -{ - int i; - struct shmid_ds *newsegs; - - if (shmalloced >= shminfo.shmmni) - return; - - newsegs = (struct shmid_ds *) sys_malloc(shminfo.shmmni * sizeof(*newsegs), M_SHM, M_WAITOK); - if (newsegs == NULL) - return; - for (i = 0; i < shmalloced; i++) - bcopy(&shmsegs[i], &newsegs[i], sizeof(newsegs[0])); - for (; i < shminfo.shmmni; i++) { - shmsegs[i].shm_perm.mode = SHMSEG_FREE; - shmsegs[i].shm_perm.seq = 0; - } - sys_free(shmsegs, M_SHM); - shmsegs = newsegs; - shmalloced = shminfo.shmmni; -} - -void -shminit(void) -{ - int i; - tun_bool_t shm_ar; - - TUNABLE_INT_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall); - for (i = PAGE_SIZE; i > 0; i--) { - shminfo.shmmax = shminfo.shmall * i; - if (shminfo.shmmax >= shminfo.shmall) - break; - } - TUNABLE_INT_FETCH("kern.ipc.shmmin", &shminfo.shmmin); - TUNABLE_INT_FETCH("kern.ipc.shmmni", &shminfo.shmmni); - TUNABLE_INT_FETCH("kern.ipc.shmseg", &shminfo.shmseg); - TUNABLE_BOOL_FETCH("kern.ipc.shm_allow_removed", &shm_ar); - if (shm_ar == TUN_TRUE) - shm_allow_removed = 1; - shmalloced = shminfo.shmmni; - shmsegs = (struct shmid_ds *) sys_malloc(shmalloced * sizeof(shmsegs[0]), M_SHM, M_WAITOK); - if (shmsegs == NULL) - panic("cannot allocate initial memory for sysvshm"); - for (i = 0; i < shmalloced; i++) { - shmsegs[i].shm_perm.mode = SHMSEG_FREE; - shmsegs[i].shm_perm.seq = 0; - } - shm_last_free = 0; - shm_nused = 0; - shm_committed = 0; -#ifndef __CYGWIN__ - shmexit_hook = &shmexit_myhook; - shmfork_hook = &shmfork_myhook; -#endif /* __CYGWIN__ */ -} - -int -shmunload(void) -{ - - if (shm_nused > 0) - return (EBUSY); - - sys_free(shmsegs, M_SHM); -#ifndef __CYGWIN__ - shmexit_hook = NULL; - shmfork_hook = NULL; -#endif /* __CYGWIN__ */ - return (0); -} - -#ifndef __CYGWIN__ -static int -sysctl_shmsegs(SYSCTL_HANDLER_ARGS) -{ - - return (SYSCTL_OUT(req, shmsegs, shmalloced * sizeof(shmsegs[0]))); -} - -static int -sysvshm_modload(struct module *module, int cmd, void *arg) -{ - int error = 0; - - switch (cmd) { - case MOD_LOAD: - shminit(); - break; - case MOD_UNLOAD: - error = shmunload(); - break; - case MOD_SHUTDOWN: - break; - default: - error = EINVAL; - break; - } - return (error); -} - -static moduledata_t sysvshm_mod = { - "sysvshm", - &sysvshm_modload, - NULL -}; - -SYSCALL_MODULE_HELPER(shmsys); -SYSCALL_MODULE_HELPER(shmat); -SYSCALL_MODULE_HELPER(shmctl); -SYSCALL_MODULE_HELPER(shmdt); -SYSCALL_MODULE_HELPER(shmget); - -DECLARE_MODULE(sysvshm, sysvshm_mod, - SI_SUB_SYSV_SHM, SI_ORDER_FIRST); -MODULE_VERSION(sysvshm, 1); -#endif /* __CYGWIN__ */ -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/threaded_queue.cc b/winsup/cygserver/threaded_queue.cc deleted file mode 100644 index ba69e1a82..000000000 --- a/winsup/cygserver/threaded_queue.cc +++ /dev/null @@ -1,410 +0,0 @@ -/* threaded_queue.cc - - Copyright 2001, 2002, 2003, 2014 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" - -#include <assert.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> -#include <sys/types.h> -#include <stdlib.h> -#include "threaded_queue.h" - -/*****************************************************************************/ - -/* queue_request */ - -queue_request::~queue_request () -{} - -/*****************************************************************************/ - -/* threaded_queue */ - -threaded_queue::threaded_queue (const size_t initial_workers) - : _workers_count (0), - _running (false), - _submitters_head (NULL), - _requests_count (0), - _requests_head (NULL), - _requests_sem (NULL) -{ - InitializeCriticalSection (&_queue_lock); - - // This semaphore's count is the number of requests on the queue. - // The maximum count (129792) is calculated as MAXIMUM_WAIT_OBJECTS - // multiplied by max. threads per process (2028?), which is (a few) - // more requests than could ever be pending with the current design. - - _requests_sem = CreateSemaphore (NULL, // SECURITY_ATTRIBUTES - 0, // Initial count - 129792, // Maximum count - NULL); // Anonymous - - if (!_requests_sem) - { - system_printf (("failed to create the request queue semaphore, " - "error = %u"), - GetLastError ()); - abort (); - } - - create_workers (initial_workers); -} - -threaded_queue::~threaded_queue () -{ - if (_running) - stop (); - - debug_printf ("deleting all pending queue requests"); - queue_request *reqptr = _requests_head; - while (reqptr) - { - queue_request *const ptr = reqptr; - reqptr = reqptr->_next; - delete ptr; - } - - DeleteCriticalSection (&_queue_lock); - if (_requests_sem) - (void) CloseHandle (_requests_sem); -} - -/* FIXME: return success or failure rather than quitting */ -void -threaded_queue::add_submission_loop (queue_submission_loop *const submitter) -{ - assert (this); - assert (submitter); - assert (submitter->_queue == this); - assert (!submitter->_next); - - submitter->_next = - TInterlockedExchangePointer (&_submitters_head, submitter); - - if (_running) - submitter->start (); -} - -bool -threaded_queue::start () -{ - EnterCriticalSection (&_queue_lock); - const bool was_running = _running; - _running = true; - queue_submission_loop *loopptr = _submitters_head; - LeaveCriticalSection (&_queue_lock); - - if (!was_running) - { - debug_printf ("starting all queue submission loops"); - - while (loopptr) - { - queue_submission_loop *const ptr = loopptr; - loopptr = loopptr->_next; - ptr->start (); - } - } - - return was_running; -} - -bool -threaded_queue::stop () -{ - EnterCriticalSection (&_queue_lock); - const bool was_running = _running; - _running = false; - queue_submission_loop *loopptr = _submitters_head; - LeaveCriticalSection (&_queue_lock); - - if (was_running) - { - debug_printf ("stopping all queue submission loops"); - while (loopptr) - { - queue_submission_loop *const ptr = loopptr; - loopptr = loopptr->_next; - ptr->stop (); - } - - ReleaseSemaphore (_requests_sem, _workers_count, NULL); - while (_workers_count) - { - debug_printf (("waiting for worker threads to terminate: " - "%u still running"), - _workers_count); - Sleep (1000); - } - debug_printf ("all worker threads have terminated"); - } - - return was_running; -} - -/* FIXME: return success or failure */ -void -threaded_queue::add (queue_request *const therequest) -{ - assert (this); - assert (therequest); - assert (!therequest->_next); - - if (!_workers_count) - { - system_printf ("warning: no worker threads to handle request!"); - // FIXME: And then what? - } - - EnterCriticalSection (&_queue_lock); - if (!_requests_head) - _requests_head = therequest; - else - { - /* Add to the queue end. */ - queue_request *reqptr = _requests_head; - for (; reqptr->_next; reqptr = reqptr->_next) - {} - assert (reqptr); - assert (!reqptr->_next); - reqptr->_next = therequest; - } - - _requests_count += 1; - assert (_requests_count > 0); - LeaveCriticalSection (&_queue_lock); - - (void) ReleaseSemaphore (_requests_sem, 1, NULL); -} - -/*static*/ DWORD WINAPI -threaded_queue::start_routine (const LPVOID lpParam) -{ - class threaded_queue *const queue = (class threaded_queue *) lpParam; - assert (queue); - - queue->worker_loop (); - - const long count = InterlockedDecrement (&queue->_workers_count); - assert (count >= 0); - - if (queue->_running) - debug_printf ("worker loop has exited; thread about to terminate"); - - return 0; -} - -/* Called from the constructor: so no need to be thread-safe until the - * worker threads start to be created; thus the interlocked increment - * of the `_workers_count' field. - */ - -void -threaded_queue::create_workers (const size_t initial_workers) -{ - assert (initial_workers > 0); - - for (unsigned int i = 0; i != initial_workers; i++) - { - const long count = InterlockedIncrement (&_workers_count); - assert (count > 0); - - DWORD tid; - const HANDLE hThread = - CreateThread (NULL, 0, start_routine, this, 0, &tid); - - if (!hThread) - { - system_printf ("failed to create thread, error = %u", - GetLastError ()); - abort (); - } - - (void) CloseHandle (hThread); - } -} - -void -threaded_queue::worker_loop () -{ - while (true) - { - const DWORD rc = WaitForSingleObject (_requests_sem, INFINITE); - if (rc == WAIT_FAILED) - { - system_printf ("wait for request semaphore failed, error = %u", - GetLastError ()); - return; - } - assert (rc == WAIT_OBJECT_0); - - EnterCriticalSection (&_queue_lock); - if (!_running) - { - LeaveCriticalSection (&_queue_lock); - return; - } - - assert (_requests_head); - queue_request *const reqptr = _requests_head; - _requests_head = reqptr->_next; - - _requests_count -= 1; - assert (_requests_count >= 0); - LeaveCriticalSection (&_queue_lock); - - assert (reqptr); - reqptr->process (); - delete reqptr; - } -} - -/*****************************************************************************/ - -/* queue_submission_loop */ - -queue_submission_loop::queue_submission_loop (threaded_queue *const queue, - const bool ninterruptible) - : _running (false), - _interrupt_event (NULL), - _queue (queue), - _interruptible (ninterruptible), - _hThread (NULL), - _tid (0), - _next (NULL) -{ - if (_interruptible) - { - // verbose: debug_printf ("creating an interruptible processing thread"); - - _interrupt_event = CreateEvent (NULL, // SECURITY_ATTRIBUTES - FALSE, // Auto-reset - FALSE, // Initially non-signalled - NULL); // Anonymous - - if (!_interrupt_event) - { - system_printf ("failed to create interrupt event, error = %u", - GetLastError ()); - abort (); - } - } -} - -queue_submission_loop::~queue_submission_loop () -{ - if (_running) - stop (); - if (_interrupt_event) - (void) CloseHandle (_interrupt_event); - if (_hThread) - (void) CloseHandle (_hThread); -} - -bool -queue_submission_loop::start () -{ - assert (this); - assert (!_hThread); - - const bool was_running = _running; - - if (!was_running) - { - _running = true; - - _hThread = CreateThread (NULL, 0, start_routine, this, 0, &_tid); - if (!_hThread) - { - system_printf ("failed to create thread, error = %u", - GetLastError ()); - abort (); - } - } - - return was_running; -} - -bool -queue_submission_loop::stop () -{ - assert (this); - assert (_hThread && _hThread != INVALID_HANDLE_VALUE); - - const bool was_running = _running; - - if (_running) - { - _running = false; - - if (_interruptible) - { - assert (_interrupt_event - && _interrupt_event != INVALID_HANDLE_VALUE); - - SetEvent (_interrupt_event); - - if (WaitForSingleObject (_hThread, 1000) == WAIT_TIMEOUT) - { - system_printf (("request loop thread %u failed to shutdown " - "when asked politely: about to get heavy"), - _tid); - - if (!TerminateThread (_hThread, 0)) - { - system_printf (("failed to kill request loop thread %u" - ", error = %u"), - _tid, GetLastError ()); - abort (); - } - } - } - else - { - // FIXME: could wait to see if the request loop notices that - // the submission loop is no longer running and shuts down - // voluntarily. - - debug_printf ("killing request loop thread %u", _tid); - - if (!TerminateThread (_hThread, 0)) - system_printf (("failed to kill request loop thread %u" - ", error = %u"), - _tid, GetLastError ()); - } - } - - return was_running; -} - -/*static*/ DWORD WINAPI -queue_submission_loop::start_routine (const LPVOID lpParam) -{ - class queue_submission_loop *const submission_loop = - (class queue_submission_loop *) lpParam; - assert (submission_loop); - - submission_loop->request_loop (); - - debug_printf ("submission loop has exited; thread about to terminate"); - - submission_loop->stop (); - - return 0; -} - -/*****************************************************************************/ -#endif /* __OUTSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/threaded_queue.h b/winsup/cygserver/threaded_queue.h deleted file mode 100644 index e17f90434..000000000 --- a/winsup/cygserver/threaded_queue.h +++ /dev/null @@ -1,127 +0,0 @@ -/* threaded_queue.h - - Copyright 2001, 2002, 2003, 2012 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _THREADED_QUEUE_ -#define _THREADED_QUEUE_ - -/*****************************************************************************/ - -/* a specific request */ - -class queue_request -{ -public: - queue_request *_next; - - queue_request () : _next (NULL) {} - virtual ~queue_request (); - - virtual void process () = 0; -}; - -/*****************************************************************************/ - -/* a queue to allocate requests from n submission loops to x worker threads */ - -class queue_submission_loop; - -class threaded_queue -{ -public: - threaded_queue (size_t initial_workers = 1); - ~threaded_queue (); - - void add_submission_loop (queue_submission_loop *); - - bool running () const { return _running; } - - bool start (); - bool stop (); - - void add (queue_request *); - -private: - LONG _workers_count; - bool _running; - - queue_submission_loop *_submitters_head; - - long _requests_count; // Informational only. - queue_request *_requests_head; - - CRITICAL_SECTION _queue_lock; - HANDLE _requests_sem; // == _requests_count - - static DWORD WINAPI start_routine (LPVOID /* this */); - - void create_workers (size_t initial_workers); - void worker_loop (); -}; - -/*****************************************************************************/ - -/* parameters for a request finding and submitting loop */ - -class queue_submission_loop -{ - friend class threaded_queue; - -public: - queue_submission_loop (threaded_queue *, bool ninterruptible); - virtual ~queue_submission_loop (); - - bool start (); - bool stop (); - - threaded_queue *queue () { return _queue; }; - -protected: - bool _running; - HANDLE _interrupt_event; - threaded_queue *const _queue; - -private: - bool _interruptible; - HANDLE _hThread; - DWORD _tid; - queue_submission_loop *_next; - - static DWORD WINAPI start_routine (LPVOID /* this */); - virtual void request_loop () = 0; -}; - -#ifdef __cplusplus - -/*---------------------------------------------------------------------------* - * Some type-safe versions of the various interlocked functions. - *---------------------------------------------------------------------------*/ - -template <typename T> T * -TInterlockedExchangePointer (T **lvalue, T *rvalue) -{ - return reinterpret_cast<T *> - (InterlockedExchangePointer (reinterpret_cast<void **> (lvalue), - reinterpret_cast<void *> (rvalue))); -} - -template <typename T> T * -TInterlockedCompareExchangePointer (T **lvalue, T *rvalue1, T *rvalue2) -{ - return reinterpret_cast<T *> - (InterlockedCompareExchangePointer (reinterpret_cast<void **> (lvalue), - reinterpret_cast<void *> (rvalue1), - reinterpret_cast<void *> (rvalue2))); -} - -#endif /* __cplusplus */ - -#endif /* _THREADED_QUEUE_ */ diff --git a/winsup/cygserver/transport.cc b/winsup/cygserver/transport.cc deleted file mode 100644 index ff9ce8d80..000000000 --- a/winsup/cygserver/transport.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* transport.cc - - Copyright 2001, 2002, 2003, 2004, 2007 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* to allow this to link into cygwin and the .dll, a little magic is needed. */ -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#else -#include "winsup.h" -#endif - -#include <sys/socket.h> - -#include "transport.h" -#include "transport_pipes.h" - -/* The factory */ -transport_layer_base * -create_server_transport () -{ - return new transport_layer_pipes; -} - -#ifndef __INSIDE_CYGWIN__ - -bool -transport_layer_base::impersonate_client () -{ - return true; -} - -bool -transport_layer_base::revert_to_self () -{ - return true; -} - -#endif /* !__INSIDE_CYGWIN__ */ - -transport_layer_base::~transport_layer_base () -{} diff --git a/winsup/cygserver/transport.h b/winsup/cygserver/transport.h deleted file mode 100644 index 80f50fd06..000000000 --- a/winsup/cygserver/transport.h +++ /dev/null @@ -1,39 +0,0 @@ -/* transport.h - - Copyright 2001, 2002, 2003, 2004 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _TRANSPORT_H -#define _TRANSPORT_H - -class transport_layer_base *create_server_transport (); - -class transport_layer_base -{ -public: -#ifndef __INSIDE_CYGWIN__ - virtual int listen () = 0; - virtual class transport_layer_base *accept (bool *recoverable) = 0; -#endif - - virtual void close () = 0; - virtual ssize_t read (void *buf, size_t len) = 0; - virtual ssize_t write (void *buf, size_t len) = 0; - virtual int connect () = 0; - -#ifndef __INSIDE_CYGWIN__ - virtual bool impersonate_client (); - virtual bool revert_to_self (); -#endif - - virtual ~transport_layer_base (); -}; - -#endif /* _TRANSPORT_H */ diff --git a/winsup/cygserver/transport_pipes.cc b/winsup/cygserver/transport_pipes.cc deleted file mode 100644 index fd5ef0914..000000000 --- a/winsup/cygserver/transport_pipes.cc +++ /dev/null @@ -1,342 +0,0 @@ -/* transport_pipes.cc - - Copyright 2001, 2002, 2003, 2004, 2009, 2012, 2014 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* to allow this to link into cygwin and the .dll, a little magic is needed. */ -#ifdef __OUTSIDE_CYGWIN__ -#include "woutsup.h" -#include <ntdef.h> -#else -#include "winsup.h" -#endif - -#include <sys/types.h> - -#include <assert.h> -#include <netdb.h> -#include <pthread.h> -#include <unistd.h> -#include <wchar.h> -#include <sys/cygwin.h> - -#include "cygerrno.h" -#include "transport.h" -#include "transport_pipes.h" - -#ifndef __INSIDE_CYGWIN__ -#include "cygserver.h" -#include "cygserver_ipc.h" -#else -#include "security.h" -#endif - -#ifdef __INSIDE_CYGWIN__ -#define SET_ERRNO(err) set_errno (err) -#else -#define SET_ERRNO(err) errno = (err) -#endif - -enum - { - MAX_WAIT_NAMED_PIPE_RETRY = 64, - WAIT_NAMED_PIPE_TIMEOUT = 10 // milliseconds - }; - -#ifndef __INSIDE_CYGWIN__ - -transport_layer_pipes::transport_layer_pipes (const HANDLE hPipe) - : _hPipe (hPipe), - _is_accepted_endpoint (true), - _is_listening_endpoint (false) -{ - assert (_hPipe); - assert (_hPipe != INVALID_HANDLE_VALUE); - _pipe_name[0] = L'\0'; -} - -#endif /* !__INSIDE_CYGWIN__ */ - -transport_layer_pipes::transport_layer_pipes () - : _hPipe (NULL), - _is_accepted_endpoint (false), - _is_listening_endpoint (false) -{ - wchar_t cyg_instkey[18]; - - wchar_t *p = wcpcpy (_pipe_name, PIPE_NAME_PREFIX); - if (!cygwin_internal (CW_GET_INSTKEY, cyg_instkey)) - wcpcpy (wcpcpy (p, cyg_instkey), PIPE_NAME_SUFFIX); -} - -transport_layer_pipes::~transport_layer_pipes () -{ - close (); -} - -#ifndef __INSIDE_CYGWIN__ - -static HANDLE listen_pipe; -static HANDLE connect_pipe; - -int -transport_layer_pipes::listen () -{ - assert (!_hPipe); - assert (!_is_accepted_endpoint); - assert (!_is_listening_endpoint); - - _is_listening_endpoint = true; - - debug ("Try to create named pipe: %ls", _pipe_name); - - /* We have to create the first instance of the listening pipe here, and - we also have to create at least one instance of the client side to avoid - a race condition. - See https://cygwin.com/ml/cygwin/2012-11/threads.html#00144 */ - listen_pipe = - CreateNamedPipeW (_pipe_name, - PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE, - PIPE_TYPE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, - 0, 0, 1000, &sec_all_nih); - if (listen_pipe != INVALID_HANDLE_VALUE) - { - connect_pipe = CreateFileW (_pipe_name, GENERIC_READ | GENERIC_WRITE, 0, - &sec_all_nih, OPEN_EXISTING, 0, NULL); - if (connect_pipe == INVALID_HANDLE_VALUE) - { - CloseHandle (listen_pipe); - listen_pipe = INVALID_HANDLE_VALUE; - } - } - - if (listen_pipe == INVALID_HANDLE_VALUE) - { - system_printf ("failed to create named pipe: " - "is the daemon already running?"); - return -1; - } - - return 0; -} - -class transport_layer_pipes * -transport_layer_pipes::accept (bool *const recoverable) -{ - assert (!_hPipe); - assert (!_is_accepted_endpoint); - assert (_is_listening_endpoint); - - debug ("Try to create named pipe instance: %ls", _pipe_name); - - const HANDLE accept_pipe = - CreateNamedPipeW (_pipe_name, PIPE_ACCESS_DUPLEX, - PIPE_TYPE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, - 0, 0, 1000, &sec_all_nih); - - if (accept_pipe == INVALID_HANDLE_VALUE) - { - debug_printf ("error creating pipe (%u).", GetLastError ()); - *recoverable = true; // FIXME: case analysis? - return NULL; - } - - if (!ConnectNamedPipe (accept_pipe, NULL) - && GetLastError () != ERROR_PIPE_CONNECTED) - { - debug_printf ("error connecting to pipe (%u)", GetLastError ()); - (void) CloseHandle (accept_pipe); - *recoverable = true; // FIXME: case analysis? - return NULL; - } - - return new transport_layer_pipes (accept_pipe); -} - -#endif /* !__INSIDE_CYGWIN__ */ - -void -transport_layer_pipes::close () -{ - // verbose: debug_printf ("closing pipe %p", _hPipe); - - if (_hPipe) - { - assert (_hPipe != INVALID_HANDLE_VALUE); - -#ifndef __INSIDE_CYGWIN__ - - if (_is_accepted_endpoint) - { - (void) FlushFileBuffers (_hPipe); // Blocks until client reads. - (void) DisconnectNamedPipe (_hPipe); - (void) CloseHandle (_hPipe); - } - else - (void) CloseHandle (_hPipe); - -#else /* __INSIDE_CYGWIN__ */ - - assert (!_is_accepted_endpoint); - (void) ForceCloseHandle (_hPipe); - -#endif /* __INSIDE_CYGWIN__ */ - - _hPipe = NULL; - } -} - -ssize_t -transport_layer_pipes::read (void *const buf, const size_t len) -{ - // verbose: debug_printf ("reading from pipe %p", _hPipe); - - assert (_hPipe); - assert (_hPipe != INVALID_HANDLE_VALUE); - assert (!_is_listening_endpoint); - - DWORD count; - if (!ReadFile (_hPipe, buf, len, &count, NULL)) - { - debug_printf ("error reading from pipe (%u)", GetLastError ()); - SET_ERRNO (EINVAL); // FIXME? - return -1; - } - - return count; -} - -ssize_t -transport_layer_pipes::write (void *const buf, const size_t len) -{ - // verbose: debug_printf ("writing to pipe %p", _hPipe); - - assert (_hPipe); - assert (_hPipe != INVALID_HANDLE_VALUE); - assert (!_is_listening_endpoint); - - DWORD count; - if (!WriteFile (_hPipe, buf, len, &count, NULL)) - { - debug_printf ("error writing to pipe, error = %u", GetLastError ()); - SET_ERRNO (EINVAL); // FIXME? - return -1; - } - - return count; -} - -/* - * This routine holds a static variable, assume_cygserver, that is set - * if the transport has good reason to think that cygserver is - * running, i.e. if if successfully connected to it with the previous - * attempt. If this is set, the code tries a lot harder to get a - * connection, making the assumption that any failures are just - * congestion and overloading problems. - */ - -int -transport_layer_pipes::connect () -{ - assert (!_hPipe); - assert (!_is_accepted_endpoint); - assert (!_is_listening_endpoint); - - static bool assume_cygserver = false; - - BOOL rc = TRUE; - int retries = 0; - - debug_printf ("Try to connect to named pipe: %W", _pipe_name); - while (rc) - { - _hPipe = CreateFileW (_pipe_name, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sec_all_nih, - OPEN_EXISTING, - SECURITY_IMPERSONATION, - NULL); - - if (_hPipe != INVALID_HANDLE_VALUE) - { - assert (_hPipe); -#ifdef __INSIDE_CYGWIN__ - ProtectHandle (_hPipe); -#endif - assume_cygserver = true; - return 0; - } - - _hPipe = NULL; - - if (!assume_cygserver && GetLastError () != ERROR_PIPE_BUSY) - { - debug_printf ("Error opening the pipe (%u)", GetLastError ()); - return -1; - } - - /* Note: `If no instances of the specified named pipe exist, the - * WaitNamedPipe function returns immediately, regardless of the - * time-out value.' Thus the explicit Sleep if the call fails - * with ERROR_FILE_NOT_FOUND. - */ - while (retries != MAX_WAIT_NAMED_PIPE_RETRY - && !(rc = WaitNamedPipeW (_pipe_name, WAIT_NAMED_PIPE_TIMEOUT))) - { - if (GetLastError () == ERROR_FILE_NOT_FOUND) - Sleep (0); // Give the server a chance. - - retries += 1; - } - } - - assert (retries == MAX_WAIT_NAMED_PIPE_RETRY); - - system_printf ("lost connection to cygserver, error = %u", - GetLastError ()); - - assume_cygserver = false; - - return -1; -} - -#ifndef __INSIDE_CYGWIN__ - -bool -transport_layer_pipes::impersonate_client () -{ - assert (_hPipe); - assert (_hPipe != INVALID_HANDLE_VALUE); - assert (_is_accepted_endpoint); - - if (_hPipe && !ImpersonateNamedPipeClient (_hPipe)) - { - debug_printf ("Failed to Impersonate client, (%u)", GetLastError ()); - return false; - } - - return true; -} - -bool -transport_layer_pipes::revert_to_self () -{ - assert (_is_accepted_endpoint); - - if (!RevertToSelf ()) - { - debug_printf ("Failed to RevertToSelf, (%u)", GetLastError ()); - return false; - } - return true; -} - -#endif /* !__INSIDE_CYGWIN__ */ diff --git a/winsup/cygserver/transport_pipes.h b/winsup/cygserver/transport_pipes.h deleted file mode 100644 index 136812106..000000000 --- a/winsup/cygserver/transport_pipes.h +++ /dev/null @@ -1,50 +0,0 @@ -/* transport_pipes.h - - Copyright 2001, 2002, 2003 Red Hat Inc. - - Written by Robert Collins <rbtcollins@hotmail.com> - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _TRANSPORT_PIPES_H -#define _TRANSPORT_PIPES_H - -#define PIPE_NAME_PREFIX L"\\\\.\\pipe\\cygwin-" -#define PIPE_NAME_SUFFIX L"-lpc" - -/* Named pipes based transport, for security on NT */ -class transport_layer_pipes : public transport_layer_base -{ -public: -#ifndef __INSIDE_CYGWIN__ - virtual int listen (); - virtual class transport_layer_pipes *accept (bool *recoverable); -#endif - - virtual void close (); - virtual ssize_t read (void *buf, size_t len); - virtual ssize_t write (void *buf, size_t len); - virtual int connect (); - -#ifndef __INSIDE_CYGWIN__ - virtual bool impersonate_client (); - virtual bool revert_to_self (); -#endif - - transport_layer_pipes (); - virtual ~transport_layer_pipes (); - -private: - wchar_t _pipe_name[40]; - HANDLE _hPipe; - const bool _is_accepted_endpoint; - bool _is_listening_endpoint; - - transport_layer_pipes (HANDLE hPipe); -}; - -#endif /* _TRANSPORT_PIPES_H */ diff --git a/winsup/cygserver/woutsup.h b/winsup/cygserver/woutsup.h deleted file mode 100644 index 5598c11c2..000000000 --- a/winsup/cygserver/woutsup.h +++ /dev/null @@ -1,56 +0,0 @@ -/* woutsup.h: for Cygwin code compiled outside the DLL (i.e. cygserver). - - Copyright 2002, 2003, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define _MT_SAFE 1 - -#ifdef __INSIDE_CYGWIN__ -#error "woutsup.h is not for code being compiled inside the dll" -#endif - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 -#endif - -#if _WIN32_WINNT < 0x0500 -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 -#endif - -#include "winlean.h" - -#include "bsd_helper.h" -#include "bsd_log.h" -#include "bsd_mutex.h" - -/* The one function we use from winuser.h most of the time */ -extern "C" DWORD WINAPI GetLastError (void); - -extern int cygserver_running; - -#define SIGHANDLE(SIG) \ - do \ - { \ - struct sigaction act; \ - \ - act.sa_handler = &handle_signal; \ - act.sa_mask = 0; \ - act.sa_flags = 0; \ - \ - if (sigaction (SIG, &act, NULL) == -1) \ - { \ - panic ("failed to install handler for " #SIG ": %s", \ - strerror (errno)); \ - exit (1); \ - } \ - } while (false) - -#define debug_printf(f,...) debug((f),##__VA_ARGS__) -#define syscall_printf(f,...) log(LOG_ERR,(f),##__VA_ARGS__) -#define system_printf(f,...) log(LOG_ERR,(f),##__VA_ARGS__) |