mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-19 10:01:24 +00:00
Add function to get the id of the current thread
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@38989 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4a62b60976
commit
459a10c172
5 changed files with 1637 additions and 2224 deletions
|
@ -171,6 +171,11 @@ extern NSString* cmdLogName();
|
||||||
extern NSString* cmdLogFormat(EcLogType t, NSString *fmt);
|
extern NSString* cmdLogFormat(EcLogType t, NSString *fmt);
|
||||||
extern void ecSetLogsSubdirectory(NSString *pathComponent);
|
extern void ecSetLogsSubdirectory(NSString *pathComponent);
|
||||||
|
|
||||||
|
/** Return the native thread ID of the current thread, or NSNotFound if
|
||||||
|
* that is not available.
|
||||||
|
*/
|
||||||
|
extern NSUInteger ecNativeThreadID();
|
||||||
|
|
||||||
/* Set/get version/compilation date.
|
/* Set/get version/compilation date.
|
||||||
*/
|
*/
|
||||||
extern NSString* cmdVersion(NSString *ver);
|
extern NSString* cmdVersion(NSString *ver);
|
||||||
|
|
18
EcProcess.m
18
EcProcess.m
|
@ -84,6 +84,13 @@
|
||||||
#ifdef HAVE_SYS_RESOURCE_H
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_GETTID)
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <sys/syscall.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +105,17 @@
|
||||||
#define EC_EFFECTIVE_USER nil
|
#define EC_EFFECTIVE_USER nil
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
NSUInteger
|
||||||
|
ecNativeThreadID()
|
||||||
|
{
|
||||||
|
#if defined(__MINGW__)
|
||||||
|
return (NSUInteger)GetCurrentThreadId();
|
||||||
|
#elif defined(HAVE_GETTID)
|
||||||
|
return (NSUInteger)syscall(SYS_gettid);
|
||||||
|
#else
|
||||||
|
return NSNotFound;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@interface EcDefaultRegistration : NSObject
|
@interface EcDefaultRegistration : NSObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
/* Define to 1 if you have the `getpid' function. */
|
/* Define to 1 if you have the `getpid' function. */
|
||||||
#undef HAVE_GETPID
|
#undef HAVE_GETPID
|
||||||
|
|
||||||
|
/* Define if you have gettid() */
|
||||||
|
#undef HAVE_GETTID
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
@ -97,6 +100,9 @@
|
||||||
/* Define to the one symbol short name of this package. */
|
/* Define to the one symbol short name of this package. */
|
||||||
#undef PACKAGE_TARNAME
|
#undef PACKAGE_TARNAME
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#undef PACKAGE_URL
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
/* Define to the version of this package. */
|
||||||
#undef PACKAGE_VERSION
|
#undef PACKAGE_VERSION
|
||||||
|
|
||||||
|
|
12
configure.ac
12
configure.ac
|
@ -23,6 +23,18 @@ AC_CHECK_FUNCS(getpid setpgid)
|
||||||
|
|
||||||
AC_CHECK_LIB([malloc],[mallinfo])
|
AC_CHECK_LIB([malloc],[mallinfo])
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
|
||||||
|
[AC_TRY_RUN(#define _GNU_SOURCE
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
pid_t t = syscall(SYS_gettid); return t == -1 ? 1 : 0; },
|
||||||
|
[ac_cv_gettid=yes], [ac_cv_gettid=no], [ac_cv_gettid=no])])
|
||||||
|
if test "$ac_cv_gettid" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_GETTID, 1, [Define if you have gettid()])
|
||||||
|
fi
|
||||||
|
|
||||||
AC_ARG_WITH([readline],
|
AC_ARG_WITH([readline],
|
||||||
[AS_HELP_STRING([--with-readline],
|
[AS_HELP_STRING([--with-readline],
|
||||||
[support fancy command line editing @<:@default=check@:>@])],
|
[support fancy command line editing @<:@default=check@:>@])],
|
||||||
|
|
Loading…
Reference in a new issue