diff -urpN cygwin.org/include/sys/_types.h cygwin/include/sys/_types.h --- cygwin.org/include/sys/_types.h 1970-01-01 01:00:00.000000000 +0100 +++ cygwin/include/sys/_types.h 2004-01-12 08:02:01.775041600 +0100 @@ -0,0 +1,37 @@ +/* ANSI C namespace clean utility typedefs */ + +/* This file defines various typedefs needed by the system calls that support + the C library. Basically, they're just the POSIX versions with an '_' + prepended. This file lives in the `sys' directory so targets can provide + their own if desired (or they can put target dependant conditionals here). +*/ + +#ifndef _SYS__TYPES_H +#define _SYS__TYPES_H + +typedef long _off_t; +__extension__ typedef long long _off64_t; + +#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647 +typedef int _ssize_t; +#else +typedef long _ssize_t; +#endif + +#define __need_wint_t +#include + +/* Conversion state information. */ +typedef struct +{ + int __count; + union + { + wint_t __wch; + unsigned char __wchb[4]; + } __value; /* Value so far. */ +} _mbstate_t; + +typedef void *_flock_t; + +#endif /* _SYS__TYPES_H */ diff -urpN cygwin.org/include/sys/lock.h cygwin/include/sys/lock.h --- cygwin.org/include/sys/lock.h 1970-01-01 01:00:00.000000000 +0100 +++ cygwin/include/sys/lock.h 2004-01-12 08:11:50.050940800 +0100 @@ -0,0 +1,21 @@ +/* sys/lock.h + + Copyright 2004 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 _SYS_LOCK_H_ +#define _SYS_LOCK_H_ + +typedef void *_LOCK_RECURSIVE_T; + +#define __lock_init_recursive(__lock) __cygwin_lock_init_recursive(&__lock) +#define __lock_acquire_recursive(__lock) __cygwin_lock_lock_recursive(&__lock) +#define __lock_release_recursive(__lock) __cygwin_lock_unlock_recursive(&__lock) +#define __lock_close_recursive(__lock) __cygwin_lock_fini_recursive(&__lock) + +#endif diff -urpN cygwin.org/include/sys/stdio.h cygwin/include/sys/stdio.h --- cygwin.org/include/sys/stdio.h 1970-01-01 01:00:00.000000000 +0100 +++ cygwin/include/sys/stdio.h 2004-01-09 15:34:16.245785600 +0100 @@ -0,0 +1,23 @@ +/* sys/stdio.h + + Copyright 2004 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 _SYS_STDIO_H_ +#define _SYS_STDIO_H_ + +#if !defined(__SINGLE_THREAD__) +# if !defined(_flockfile) +# define _flockfile(fp) __cygwin_flockfile(fp) +# endif +# if !defined(_funlockfile) +# define _funlockfile(fp) __cygwin_funlockfile(fp) +# endif +#endif + +#endif diff -urpN cygwin.org/thread.cc cygwin/thread.cc --- cygwin.org/thread.cc 2003-12-23 17:27:53.000000000 +0100 +++ cygwin/thread.cc 2004-01-12 10:38:03.501873600 +0100 @@ -44,6 +44,7 @@ details. */ #include #include #include +#include extern int threadsafe; @@ -54,6 +55,43 @@ __getreent () return &_my_tls.local_clib; } +extern "C" void +__cygwin_lock_init_recursive (_LOCK_RECURSIVE_T *lock) +{ + if (!pthread_mutex_init ((pthread_mutex_t*) lock, NULL)) + (*(pthread_mutex_t*)lock)->type = PTHREAD_MUTEX_RECURSIVE; +} + +extern "C" void +__cygwin_lock_fini_recursive (_LOCK_RECURSIVE_T *lock) +{ + pthread_mutex_destroy ((pthread_mutex_t*) lock); +} + +extern "C" void +__cygwin_lock_lock_recursive (_LOCK_RECURSIVE_T *lock) +{ + pthread_mutex_lock ((pthread_mutex_t*) lock); +} + +extern "C" void +__cygwin_lock_unlock_recursive (_LOCK_RECURSIVE_T *lock) +{ + pthread_mutex_unlock ((pthread_mutex_t*) lock); +} + +extern "C" void +__cygwin_flockfile (FILE *stream) +{ + __cygwin_lock_lock_recursive ((_LOCK_RECURSIVE_T *)&stream->_lock); +} + +extern "C" void +__cygwin_funlockfile (FILE *stream) +{ + __cygwin_lock_unlock_recursive ((_LOCK_RECURSIVE_T *)&stream->_lock); +} + inline LPCRITICAL_SECTION ResourceLocks::Lock (int _resid) {