(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) \
<= CYGWIN_VERSION_DLL_MALLOC_ENV)
-
/* List of names which are converted from dos to unix
on the way in and back again on the way out.
-
+
PATH needs to be here because CreateProcess uses it and gdb uses
CreateProcess. HOME is here because most shells use it and would be
confused by Windows style path names. */
if (!buf || !*buf)
return;
- if (strcmp (buf, "oem")== 0 )
+ if (strcmp (buf, "oem")== 0)
{
current_codepage = oem_cp;
SetFileApisToOEM ();
- debug_printf ("File APIs set to OEM" );
+ debug_printf ("File APIs set to OEM");
}
- else if (strcmp (buf, "ansi")== 0 )
+ else if (strcmp (buf, "ansi")== 0)
{
current_codepage = ansi_cp;
SetFileApisToANSI ();
- debug_printf ("File APIs set to ANSI" );
+ debug_printf ("File APIs set to ANSI");
}
else
{
- debug_printf ("Wrong codepage name: %s", buf );
+ debug_printf ("Wrong codepage name: %s", buf);
}
}
/* pthread.cc: posix pthread interface for Cygwin
- Copyright 1998 Cygnus Solutions.
+ Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
- Written by Marco Fuykschot <marco@ddi.nl>
+ Originally written by Marco Fuykschot <marco@ddi.nl>
This file is part of Cygwin.
}
int
-pthread_join(pthread_t thread, void **return_val)
+pthread_join (pthread_t thread, void **return_val)
{
- return __pthread_join(&thread, (void **)return_val);
+ return __pthread_join (&thread, (void **)return_val);
}
int
-pthread_detach(pthread_t thread)
+pthread_detach (pthread_t thread)
{
- return __pthread_detach(&thread);
+ return __pthread_detach (&thread);
}
int
-pthread_suspend(pthread_t thread)
+pthread_suspend (pthread_t thread)
{
- return __pthread_suspend(&thread);
+ return __pthread_suspend (&thread);
}
int
-pthread_continue(pthread_t thread)
+pthread_continue (pthread_t thread)
{
- return __pthread_continue(&thread);
+ return __pthread_continue (&thread);
}
unsigned long
/* Synchronisation */
int
-pthread_cond_destroy(pthread_cond_t *cond)
+pthread_cond_destroy (pthread_cond_t *cond)
{
return __pthread_cond_destroy (cond);
}
int
-pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
+pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
{
return __pthread_cond_init (cond, attr);
}
int
-pthread_cond_signal(pthread_cond_t *cond)
+pthread_cond_signal (pthread_cond_t *cond)
{
return __pthread_cond_signal (cond);
}
-int pthread_cond_broadcast(pthread_cond_t *cond)
+int
+pthread_cond_broadcast (pthread_cond_t *cond)
{
return __pthread_cond_broadcast (cond);
}
int
-pthread_cond_timedwait(pthread_cond_t *cond,
+pthread_cond_timedwait (pthread_cond_t *cond,
pthread_mutex_t *mutex, const struct timespec *abstime)
{
return __pthread_cond_timedwait (cond, mutex, abstime);
}
int
-pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
{
return __pthread_cond_wait (cond, mutex);
}
int
-pthread_condattr_init(pthread_condattr_t *condattr)
+pthread_condattr_init (pthread_condattr_t *condattr)
{
return __pthread_condattr_init (condattr);
}
int
-pthread_condattr_destroy(pthread_condattr_t *condattr)
+pthread_condattr_destroy (pthread_condattr_t *condattr)
{
return __pthread_condattr_destroy (condattr);
}
return __pthread_condattr_getpshared (attr, pshared);
}
-int pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
+int
+pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
{
return __pthread_condattr_setpshared (attr, pshared);
}
case WAIT_OBJECT_0 + 1:
return 1;
case WAIT_FAILED:
- select_printf ( "wait failed %E" );
+ select_printf ("wait failed %E");
case WAIT_OBJECT_0:
case WAIT_TIMEOUT:
default:
char envbuf[6];
__small_sprintf (buf, "%s.%s.%d", cygwin_version.shared_id, str, num);
- if (GetEnvironmentVariable("CYGWIN_TESTING", envbuf, 5))
- strcat(buf, cygwin_version.dll_build_date);
+ if (GetEnvironmentVariable ("CYGWIN_TESTING", envbuf, 5))
+ strcat (buf, cygwin_version.dll_build_date);
return buf;
}
+ GetLengthSid (sid2);
if (! InitializeAcl (acl, acl_len, ACL_REVISION))
- debug_printf("InitializeAcl %E");
+ debug_printf ("InitializeAcl %E");
if (! AddAccessAllowedAce (acl, ACL_REVISION,
SPECIFIC_RIGHTS_ALL | STANDARD_RIGHTS_ALL,
sid))
- debug_printf("AddAccessAllowedAce(%s) %E", getlogin());
+ debug_printf ("AddAccessAllowedAce(%s) %E", getlogin ());
if (! AddAccessAllowedAce (acl, ACL_REVISION,
SPECIFIC_RIGHTS_ALL | STANDARD_RIGHTS_ALL,
get_admin_sid ()))
- debug_printf("AddAccessAllowedAce(admin) %E");
+ debug_printf ("AddAccessAllowedAce(admin) %E");
if (! AddAccessAllowedAce (acl, ACL_REVISION,
SPECIFIC_RIGHTS_ALL | STANDARD_RIGHTS_ALL,
get_system_sid ()))
- debug_printf("AddAccessAllowedAce(system) %E");
+ debug_printf ("AddAccessAllowedAce(system) %E");
if (! AddAccessAllowedAce (acl, ACL_REVISION,
SPECIFIC_RIGHTS_ALL | STANDARD_RIGHTS_ALL,
get_creator_owner_sid ()))
- debug_printf("AddAccessAllowedAce(creator_owner) %E");
+ debug_printf ("AddAccessAllowedAce(creator_owner) %E");
if (sid2)
if (! AddAccessAllowedAce (acl, ACL_REVISION,
SPECIFIC_RIGHTS_ALL | STANDARD_RIGHTS_ALL,
sid2))
- debug_printf("AddAccessAllowedAce(sid2) %E");
+ debug_printf ("AddAccessAllowedAce(sid2) %E");
if (! InitializeSecurityDescriptor (psd,
SECURITY_DESCRIPTOR_REVISION))
- debug_printf("InitializeSecurityDescriptor %E");
+ debug_printf ("InitializeSecurityDescriptor %E");
/*
* Setting the owner lets the created security attribute not work
*/
#if 0
if (! SetSecurityDescriptorOwner (psd, sid, FALSE))
- debug_printf("SetSecurityDescriptorOwner %E");
+ debug_printf ("SetSecurityDescriptorOwner %E");
#endif
if (! SetSecurityDescriptorDacl (psd, TRUE, acl, FALSE))
- debug_printf("SetSecurityDescriptorDacl %E");
+ debug_printf ("SetSecurityDescriptorDacl %E");
psa->nLength = sizeof (SECURITY_ATTRIBUTES);
psa->lpSecurityDescriptor = psd;
fhandler_base *fh;
for (int i = 0; i < (int) fdtab.size; i++)
- if ( (fh = fdtab[i]) != NULL)
+ if ((fh = fdtab[i]) != NULL)
{
fh->close ();
fdtab.release (i);
if (fd < 0)
set_errno (ENMFILE);
- else if ( (fh = fdtab.build_fhandler (fd, unix_path, NULL)) == NULL)
+ else if ((fh = fdtab.build_fhandler (fd, unix_path, NULL)) == NULL)
res = -1; // errno already set
else if (!fh->open (unix_path, flags, (mode & 0777) & ~cygheap->umask))
{
fdtab.release (fd);
res = -1;
}
- else if ( (res = fd) <= 2)
+ else if ((res = fd) <= 2)
set_std_handle (res);
ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," open");
}
count ++;
while (FindNextFileA (handle, &buf))
{
- if ( (buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ if ((buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
count ++;
}
FindClose (handle);
strcpy (root, real_path.get_win32 ());
dtype = GetDriveType (rootdir (root));
- if ( (atts == -1 || ! (atts & FILE_ATTRIBUTE_DIRECTORY) ||
+ if ((atts == -1 || ! (atts & FILE_ATTRIBUTE_DIRECTORY) ||
(os_being_run == winNT
&& dtype != DRIVE_NO_ROOT_DIR
&& dtype != DRIVE_UNKNOWN)))
&buf->st_mode, &buf->st_uid, &buf->st_gid))
{
buf->st_mode |= STD_RBITS | STD_XBITS;
- if ( (atts & FILE_ATTRIBUTE_READONLY) == 0)
+ if ((atts & FILE_ATTRIBUTE_READONLY) == 0)
buf->st_mode |= STD_WBITS;
if (real_path.issymlink ())
buf->st_mode |= S_IRWXU | S_IRWXG | S_IRWXO;
get_file_attribute (FALSE, real_path.get_win32 (),
NULL, &buf->st_uid, &buf->st_gid);
}
- if ( (handle = FindFirstFile (real_path.get_win32 (), &wfd))
+ if ((handle = FindFirstFile (real_path.get_win32 (), &wfd))
!= INVALID_HANDLE_VALUE)
{
buf->st_atime = to_time_t (&wfd.ftLastAccessTime);
buf->st_ctime = to_time_t (&wfd.ftCreationTime);
buf->st_size = wfd.nFileSizeLow;
buf->st_blksize = S_BLKSIZE;
- buf->st_blocks = ( (unsigned long) buf->st_size +
+ buf->st_blocks = ((unsigned long) buf->st_size +
S_BLKSIZE-1) / S_BLKSIZE;
FindClose (handle);
}
command[2] = cmdstring;
command[3] = (const char *) NULL;
- if ( (res = spawnvp (_P_WAIT, "sh", command)) == -1)
+ if ((res = spawnvp (_P_WAIT, "sh", command)) == -1)
{
// when exec fails, return value should be as if shell
// executed exit (127)
(void) write (fd, (char *) ut, sizeof (struct utmp));
(void) close (fd);
}
- if ( (fd = open (_PATH_WTMP, O_WRONLY | O_APPEND | O_BINARY, 0)) >= 0)
+ if ((fd = open (_PATH_WTMP, O_WRONLY | O_APPEND | O_BINARY, 0)) >= 0)
{
(void) write (fd, (char *) ut, sizeof (struct utmp));
(void) close (fd);
while (!res && ReadFile (ut_fd, ut_buf, sizeof ut_buf, &rd, NULL)
&& rd != 0)
{
- struct utmp *ut_end = (struct utmp *) ( (char *) ut_buf + rd);
+ struct utmp *ut_end = (struct utmp *) ((char *) ut_buf + rd);
for (ut = ut_buf; ut < ut_end; ut++, pos += sizeof (*ut))
if (ut->ut_name[0]
/* Now seek back to the position in utmp at which UT occured,
and write the new version of UT there. */
- if ( (SetFilePointer (ut_fd, pos, 0, FILE_BEGIN) != 0xFFFFFFFF)
+ if ((SetFilePointer (ut_fd, pos, 0, FILE_BEGIN) != 0xFFFFFFFF)
&& (WriteFile (ut_fd, (char *) ut, sizeof (*ut),
&rd, NULL)))
{
Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
- Written by Marco Fuykschot <marco@ddi.nl>
+ Originally written by Marco Fuykschot <marco@ddi.nl>
This file is part of Cygwin.
}
}
-
// Thread interface
void
#endif
reent_index = TlsAlloc ();
-
reents._clib = _impure_ptr;
reents._winsup = &winsup_reent;
item->mutexitem=NULL;
item->waiting=0;
- item->win32_obj_id = ::CreateEvent (&sec_none_nih,
+ item->win32_obj_id = ::CreateEvent (&sec_none_nih,
false, /* auto signal reset - which I think is pthreads like ? */
false, /* start non signaled */
- NULL /* no name */ );
-
+ NULL /* no name */);
CHECKHANDLE (NULL, 1);
int
CondItem::Signal ()
{
- return !PulseEvent(win32_obj_id);
+ return !PulseEvent (win32_obj_id);
}
int
{
if (!mutexitem)
return 0;
- PulseEvent(win32_obj_id);
- while (InterlockedDecrement(&waiting)!=0)
- PulseEvent(win32_obj_id);
+ PulseEvent (win32_obj_id);
+ while (InterlockedDecrement (&waiting)!=0)
+ PulseEvent (win32_obj_id);
mutexitem=NULL;
return 0;
}
-////////////////////////// Pthreads
+/* Pthreads */
void *
thread_init_wrapper (void *_arg)
{
-// Setup the local/global storage of this thread
+ // Setup the local/global storage of this thread
ThreadItem *thread = (ThreadItem *) _arg;
struct __reent_t local_reent;
sigset_t _sig_mask; /* one set for everything to ignore. */
LONG _sigtodo[NSIG + __SIGOFFSET];
-// setup signal structures
+ // setup signal structures
thread->sigs = _sigs;
thread->sigmask = &_sig_mask;
thread->sigtodo = _sigtodo;
local_winsup._process_logmask = LOG_UPTO (LOG_DEBUG);
-
if (!TlsSetValue (MT_INTERFACE->reent_index, &local_reent))
system_printf ("local storage for thread couldn't be set");
system_printf ("local storage for thread isn't setup correctly");
#endif
-
thread_printf ("started thread %p %p %p %p %p %p", _arg, &local_clib, _impure_ptr, thread, thread->function, thread->arg);
-
-// call the user's thread
+ // call the user's thread
void *ret = thread->function (thread->arg);
-// FIX ME : cleanup code
+ // FIXME : cleanup code
-// thread->used = false; // release thread entry
+ // thread->used = false; // release thread entry
thread->return_ptr = ret;
ExitThread (0);
}
return 0;
}
-
-
-
unsigned long
__pthread_getsequence_np (pthread_t * thread)
{
/* Thread synchronisation */
int
-__pthread_cond_destroy(pthread_cond_t *cond)
+__pthread_cond_destroy (pthread_cond_t *cond)
{
SetResourceLock (LOCK_COND_LIST, READ_LOCK | WRITE_LOCK, "__pthread_cond_destroy");
}
int
-__pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
+__pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
{
if (attr && (attr->valid != 0xf341))
return EINVAL;
}
-int __pthread_cond_broadcast(pthread_cond_t *cond)
+int
+__pthread_cond_broadcast (pthread_cond_t *cond)
{
GETCOND("_pthread_cond_lock");
-
- item->BroadCast();
+
+ item->BroadCast ();
return 0;
}
-int __pthread_cond_signal(pthread_cond_t *cond)
+int
+__pthread_cond_signal (pthread_cond_t *cond)
{
GETCOND("_pthread_cond_lock");
- item->Signal();
+ item->Signal ();
return 0;
}
-int __pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
+int
+__pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
{
int rv;
if (!abstime)
return EINVAL;
item->mutexitem=mutexitem;
- InterlockedIncrement(&item->waiting);
- rv = item->TimedWait(abstime->tv_sec*1000);
- mutexitem->Lock();
- if (InterlockedDecrement(&item->waiting)==0)
+ InterlockedIncrement (&item->waiting);
+ rv = item->TimedWait (abstime->tv_sec*1000);
+ mutexitem->Lock ();
+ if (InterlockedDecrement (&item->waiting)==0)
item->mutexitem=NULL;
return rv;
}
-int __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
-{
+int
+__pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
int rv;
- SetResourceLock (LOCK_MUTEX_LIST, READ_LOCK, "_ptherad_mutex_lock");
- MutexItem* mutexitem=user_data->threadinterface->GetMutex (mutex);
- ReleaseResourceLock (LOCK_MUTEX_LIST, READ_LOCK, "_ptherad_mutex_lock");
- if (!mutexitem) return EINVAL;
+ SetResourceLock (LOCK_MUTEX_LIST, READ_LOCK, "_ptherad_mutex_lock");
+ MutexItem* mutexitem=user_data->threadinterface->GetMutex (mutex);
+ ReleaseResourceLock (LOCK_MUTEX_LIST, READ_LOCK, "_ptherad_mutex_lock");
+ if (!mutexitem) return EINVAL;
if (!mutexitem->HandleOke ())
- {
- return EINVAL;
+ {
+ return EINVAL;
}
GETCOND("_pthread_cond_lock");
if (item->mutexitem && (item->mutexitem != mutexitem))
return EINVAL;
-
+
item->mutexitem=mutexitem;
- InterlockedIncrement(&item->waiting);
- rv = item->Wait();
- mutexitem->Lock();
- if (InterlockedDecrement(&item->waiting)==0)
+ InterlockedIncrement (&item->waiting);
+ rv = item->Wait ();
+ mutexitem->Lock ();
+ if (InterlockedDecrement (&item->waiting)==0)
item->mutexitem=NULL;
-
+
return rv;
}
int
__pthread_condattr_setpshared (pthread_condattr_t * attr, int pshared)
{
- if (!attr || (attr->valid != 0xf341) || (pshared <0) || (pshared > 1 ))
+ if (!attr || (attr->valid != 0xf341) || (pshared <0) || (pshared > 1))
return EINVAL;
attr->shared = pshared;
return 0;
int
__pthread_kill (pthread_t * thread, int sig)
{
-// lock myself, for the use of thread2signal
- // two differ kills might clash: FIX ME
+ // lock myself, for the use of thread2signal
+ // two differ kills might clash: FIXME
GETTHREAD ("__pthread_kill");
if (item->sigs)
int rval = _kill (myself->pid, sig);
-// unlock myself
+ // unlock myself
return rval;
}
ThreadItem *item = MT_INTERFACE->GetCallingThread ();
ReleaseResourceLock (LOCK_THREAD_LIST, READ_LOCK, "__pthread_sigmask");
-// lock this myself, for the use of thread2signal
- // two differt kills might clash: FIX ME
+ // lock this myself, for the use of thread2signal
+ // two differt kills might clash: FIXME
if (item->sigs)
myself->setthread2signal (item);
int rval = sigprocmask (operation, set, old_set);
-// unlock this myself
+ // unlock this myself
return rval;
}
{
return -1;
}
- int __pthread_cond_destroy(pthread_cond_t *)
+ int __pthread_cond_destroy (pthread_cond_t *)
{
return -1;
}
- int __pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *)
+ int __pthread_cond_init (pthread_cond_t *, const pthread_condattr_t *)
{
return -1;
}
- int __pthread_cond_signal(pthread_cond_t *)
+ int __pthread_cond_signal (pthread_cond_t *)
{
return -1;
}
- int __pthread_cond_broadcast(pthread_cond_t *)
+ int __pthread_cond_broadcast (pthread_cond_t *)
{
return -1;
}
- int __pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, const struct timespec *)
+ int __pthread_cond_timedwait (pthread_cond_t *, pthread_mutex_t *, const struct timespec *)
{
return -1;
}
- int __pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *)
+ int __pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *)
{
return -1;
}
winsize.ws_col = 80;
winsize.ws_row = 25;
- termios_printf("tty%d opened", ntty);
+ termios_printf ("tty%d opened", ntty);
return TRUE;
}
/* If that failes, too, as a last resort try to get the SID from
the logon server. */
- if (!ret && !(ret = lookup_name(user.name (), user.logsrv (),
+ if (!ret && !(ret = lookup_name (user.name (), user.logsrv (),
user.sid ())))
debug_printf ("Couldn't retrieve SID from '%s'!", user.logsrv ());
getlogin (void)
{
#ifdef _MT_SAFE
- char *this_username=_reent_winsup()->_username;
+ char *this_username=_reent_winsup ()->_username;
#else
static NO_COPY char this_username[MAX_USER_NAME];
#endif
w->pid = intpid;
w->options = options;
w->rusage = r;
- sigproc_printf("calling proc_subproc, pid %d, options %d",
+ sigproc_printf ("calling proc_subproc, pid %d, options %d",
w->pid, w->options);
- if (!proc_subproc(PROC_WAIT, (DWORD)w))
+ if (!proc_subproc (PROC_WAIT, (DWORD)w))
{
set_errno (ENOSYS);
paranoid_printf ("proc_subproc returned 0");
intpid, status, w->status, options, res);
w->status = -1;
if (res < 0)
- sigproc_printf("*** errno = %d", get_errno());
+ sigproc_printf ("*** errno = %d", get_errno ());
return res;
}
start_time = GetTickCount ();
itv.it_value = itv.it_interval;
}
- raise(SIGALRM);
+ raise (SIGALRM);
}
return 0;
case WM_ASYNCIO:
}
if (timer_active)
{
- KillTimer (gethwnd(), timer_active);
+ KillTimer (gethwnd (), timer_active);
timer_active = 0;
}
if (oldvalue)
elapse = 1;
else
return 0;
- if (!(timer_active = SetTimer (gethwnd(), 1, elapse, NULL)))
+ if (!(timer_active = SetTimer (gethwnd (), 1, elapse, NULL)))
{
__seterrno ();
return -1;