018b0a
diff -up ksh20120801/src/cmd/ksh93/sh/subshell.c.orig ksh20120801/src/cmd/ksh93/sh/subshell.c
018b0a
--- ksh20120801/src/cmd/ksh93/sh/subshell.c.orig	2012-07-17 23:54:21.000000000 +0200
018b0a
+++ ksh20120801/src/cmd/ksh93/sh/subshell.c	2012-10-24 15:03:44.436870792 +0200
018b0a
@@ -40,14 +40,6 @@
018b0a
 #   define PIPE_BUF	512
018b0a
 #endif
018b0a
 
018b0a
-#ifndef O_SEARCH
018b0a
-#   ifdef O_PATH
018b0a
-#	define O_SEARCH	O_PATH
018b0a
-#   else
018b0a
-#	define O_SEARCH	0
018b0a
-#   endif
018b0a
-#endif
018b0a
-
018b0a
 /*
018b0a
  * Note that the following structure must be the same
018b0a
  * size as the Dtlink_t structure
018b0a
@@ -84,7 +76,7 @@ static struct subshell
018b0a
 	char		*pwd;	/* present working directory */
018b0a
 	const char	*shpwd;	/* saved pointer to sh.pwd */
018b0a
 	void		*jobs;	/* save job info */
018b0a
-	int		pwdfd;	/* file descritor for pwd */
018b0a
+	int		shpwdfd;/* fd for present working directory */
018b0a
 	mode_t		mask;	/* saved umask */
018b0a
 	short		tmpfd;	/* saved tmp file descriptor */
018b0a
 	short		pipefd;	/* read fd if pipe is created */
018b0a
@@ -101,7 +93,6 @@ static struct subshell
018b0a
 	int		subdup;
018b0a
 	char		subshare;
018b0a
 	char		comsub;
018b0a
-	char		pwdclose;
018b0a
 #if SHOPT_COSHELL
018b0a
 	void		*coshell;
018b0a
 #endif /* SHOPT_COSHELL */
018b0a
@@ -518,7 +509,6 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
018b0a
 		shp->pathinit = 0;
018b0a
 	}
018b0a
 	sp->pathlist = path_dup((Pathcomp_t*)shp->pathlist);
018b0a
-	sp->pwdfd = -1;
018b0a
 	if(!shp->pwd)
018b0a
 		path_pwd(shp,0);
018b0a
 	sp->bckpid = shp->bckpid;
018b0a
@@ -531,39 +521,14 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
018b0a
 	shp->subshare = comsub==2 ||  (comsub==1 && sh_isoption(SH_SUBSHARE));
018b0a
 	if(comsub)
018b0a
 		shp->comsub = comsub;
018b0a
+	sp->shpwdfd=-1;
018b0a
 	if(!comsub || !shp->subshare)
018b0a
 	{
018b0a
-		struct subshell *xp;
018b0a
 		sp->shpwd = shp->pwd;
018b0a
-#ifdef _lib_fchdir
018b0a
-		for(xp=sp->prev; xp; xp=xp->prev) 
018b0a
-		{
018b0a
-			if(xp->pwdfd>0 && strcmp(xp->pwd,shp->pwd)==0)
018b0a
-			{
018b0a
-				sp->pwdfd = xp->pwdfd;
018b0a
-				break;
018b0a
-			}
018b0a
-		}
018b0a
-		if(sp->pwdfd<0)
018b0a
-		{
018b0a
-			int n = open(".",O_RDONLY);
018b0a
-			if(O_SEARCH && errno==EACCES)
018b0a
-				n =  open(".",O_RDONLY);
018b0a
-			if(n>=0)
018b0a
-			{
018b0a
-				sp->pwdfd = n;
018b0a
-				if(n<10)
018b0a
-				{
ebf9b3
-					sp->pwdfd = sh_fcntl(n,F_DUPFD,10);
018b0a
-					close(n);
018b0a
-				}
018b0a
-				if(sp->pwdfd>0)
018b0a
-				{
018b0a
-					fcntl(sp->pwdfd,F_SETFD,FD_CLOEXEC);
018b0a
-					sp->pwdclose = 1;
018b0a
-				}
018b0a
-			}
018b0a
-		}
018b0a
+		sp->shpwdfd=((shp->pwdfd >= 0))?sh_fcntl(shp->pwdfd, F_dupfd_cloexec, 10):-1;
018b0a
+#ifdef O_SEARCH
018b0a
+		if(sp->shpwdfd<0)
018b0a
+			errormsg(SH_DICT,ERROR_system(1), "Can't obtain directory fd.");
018b0a
 #endif
018b0a
 		sp->pwd = (shp->pwd?strdup(shp->pwd):0);
018b0a
 		sp->mask = shp->mask;
018b0a
@@ -741,14 +706,11 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
018b0a
 			Namval_t *pwdnod = sh_scoped(shp,PWDNOD);
018b0a
 			if(shp->pwd)
018b0a
 			{
018b0a
-				if(sp->pwdfd >=0)
018b0a
-				{
018b0a
-					if(fchdir(sp->pwdfd)<0)
018b0a
-						chdir(sp->pwd);
018b0a
-				}
018b0a
-				else
018b0a
-					chdir(sp->pwd);
018b0a
 				shp->pwd=sp->pwd;
018b0a
+#ifndef O_SEARCH
018b0a
+				if (sp->shpwdfd < 0)
018b0a
+					chdir(shp->pwd);
018b0a
+#endif
018b0a
 				path_newdir(shp,shp->pathlist);
018b0a
 			}
018b0a
 			if(nv_isattr(pwdnod,NV_NOFREE))
018b0a
@@ -762,8 +724,6 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
018b0a
 		}
018b0a
 		else
018b0a
 			free((void*)sp->pwd);
018b0a
-		if(sp->pwdclose)
018b0a
-			close(sp->pwdfd);
018b0a
 		if(sp->mask!=shp->mask)
018b0a
 			umask(shp->mask=sp->mask);
018b0a
 		if(shp->coutpipe!=sp->coutpipe)
018b0a
@@ -775,6 +735,13 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
018b0a
 		shp->cpipe[1] = sp->cpipe;
018b0a
 		shp->coutpipe = sp->coutpipe;
018b0a
 	}
018b0a
+	if(sp->shpwdfd >=0)
018b0a
+	{
018b0a
+		if(shp->pwdfd >=0)
018b0a
+			sh_close(shp->pwdfd);
018b0a
+		shp->pwdfd=sp->shpwdfd;
018b0a
+		fchdir(shp->pwdfd);
018b0a
+	}
018b0a
 	shp->subshare = sp->subshare;
018b0a
 	shp->comsub = sp->comsub;
018b0a
 	shp->subdup = sp->subdup;
018b0a
diff -up ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c.orig ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c
018b0a
--- ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c.orig	2012-08-02 16:50:40.000000000 +0200
018b0a
+++ ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c	2012-10-24 15:37:46.814469045 +0200
018b0a
@@ -38,6 +38,10 @@
018b0a
 #include	"builtins.h"
018b0a
 #include	<ls.h>
018b0a
 
018b0a
+#ifndef EINTR_REPEAT
018b0a
+#   define EINTR_REPEAT(expr) while((expr) && (errno == EINTR)) errno=0;
018b0a
+#endif
018b0a
+
018b0a
 /*
018b0a
  * Invalidate path name bindings to relative paths
018b0a
  */
018b0a
@@ -49,6 +53,95 @@ static void rehash(register Namval_t *np
018b0a
 		_nv_unset(np,0);
018b0a
 }
018b0a
 
018b0a
+/*
018b0a
+ * Obtain a file handle to the directory "path" relative to directory
018b0a
+ * "dir", or open a NFSv4 xattr directory handle for file dir/path.
018b0a
+ */
018b0a
+int sh_diropenat(Shell_t *shp, int dir, const char *path, bool xattr)
018b0a
+{
018b0a
+	int fd,shfd;
018b0a
+	int savederrno=errno;
018b0a
+#ifndef AT_FDCWD
018b0a
+	NOT_USED(dir);
018b0a
+#endif
018b0a
+#ifndef O_XATTR
018b0a
+	NOT_USED(xattr);
018b0a
+#endif
018b0a
+
018b0a
+#ifdef O_XATTR
018b0a
+	if(xattr)
018b0a
+	{
018b0a
+		int apfd; /* attribute parent fd */
018b0a
+		/* open parent node... */
018b0a
+		EINTR_REPEAT((apfd = openat(dir, path, O_RDONLY|O_NONBLOCK|O_cloexec)) < 0);
018b0a
+		if(apfd < 0)
018b0a
+			return -1;
018b0a
+
018b0a
+		/* ... and then open a fd to the attribute directory */
018b0a
+		 EINTR_REPEAT((fd = openat(apfd, e_dot, O_XATTR|O_cloexec)) < 0);
018b0a
+
018b0a
+		savederrno = errno;
018b0a
+		EINTR_REPEAT(close(apfd) < 0);
018b0a
+		errno = savederrno;
018b0a
+	}
018b0a
+	else
018b0a
+#endif
018b0a
+	{
018b0a
+#ifdef AT_FDCWD
018b0a
+		/*
018b0a
+		 * Open directory. First we try without |O_SEARCH| and
018b0a
+		 * if this fails with EACCESS we try with |O_SEARCH|
018b0a
+		 * again.
018b0a
+		 * This is required ...
018b0a
+		 * - ... because some platforms may require that it can
018b0a
+		 * only be used for directories while some filesystems
018b0a
+		 * (e.g. Reiser4 or HSM systems) allow a |fchdir()| into
018b0a
+		 * files, too)
018b0a
+		 * - ... to preserve the semantics of "cd", e.g.
018b0a
+		 * otherwise "cd" would return [No access] instead of
018b0a
+		 * [Not a directory] for files on filesystems which do
018b0a
+		 * not allow a "cd" into files.
018b0a
+		 * - ... to allow that a
018b0a
+		 * $ redirect {n}
018b0a
+		 * platforms.
018b0a
+		 */
018b0a
+		EINTR_REPEAT((fd = openat(dir, path, O_RDONLY|O_NONBLOCK|O_cloexec)) < 0);
018b0a
+#   ifdef O_SEARCH
018b0a
+		if((fd < 0) && (errno == EACCES))
018b0a
+		{
018b0a
+			EINTR_REPEAT((fd = openat(dir, path, O_SEARCH|O_cloexec)) < 0)
018b0a
+		}
018b0a
+#   endif
018b0a
+#else
018b0a
+		/*
018b0a
+		 * Version of openat() call above for systems without
018b0a
+		 * openat API. This only works because we basically
018b0a
+		 * gurantee that |dir| is always the same place as
018b0a
+		 * |cwd| on such machines (but this won't be the case
018b0a
+		 * in the future).
018b0a
+		 */
018b0a
+		/*
018b0a
+		 * This |fchdir()| call is not needed (yet) since
018b0a
+		 * all consumers do not use |dir| when |AT_FDCWD|
018b0a
+		 * is not available.
018b0a
+		 *
018b0a
+		 * fchdir(dir);
018b0a
+		 */
018b0a
+		EINTR_REPEAT((fd = open(path, O_cloexec)) < 0);
018b0a
+#endif
018b0a
+	}
018b0a
+
018b0a
+	if(fd < 0)
018b0a
+		return fd;
018b0a
+
018b0a
+	/* Move fd to a number > 10 and *register* the fd number with the shell */
018b0a
+	shfd = sh_fcntl(fd, F_dupfd_cloexec, 10);
018b0a
+	savederrno=errno;
018b0a
+	sh_close(fd);
018b0a
+	errno=savederrno;
018b0a
+	return(shfd);
018b0a
+}
018b0a
+
018b0a
 int	b_cd(int argc, char *argv[],Shbltin_t *context)
018b0a
 {
018b0a
 	register char *dir;
018b0a
@@ -56,18 +149,20 @@ int	b_cd(int argc, char *argv[],Shbltin_
018b0a
 	register const char *dp;
018b0a
 	register Shell_t *shp = context->shp;
018b0a
 	int saverrno=0;
018b0a
-	int rval,flag=0;
018b0a
+	int rval;
018b0a
+	bool flag=false,xattr=false;
018b0a
 	char *oldpwd;
018b0a
+	int newdirfd;
018b0a
 	Namval_t *opwdnod, *pwdnod;
018b0a
 	if(sh_isoption(SH_RESTRICTED))
018b0a
 		errormsg(SH_DICT,ERROR_exit(1),e_restricted+4);
018b0a
 	while((rval = optget(argv,sh_optcd))) switch(rval)
018b0a
 	{
018b0a
 		case 'L':
018b0a
-			flag = 0;
018b0a
+			flag = false;
018b0a
 			break;
018b0a
 		case 'P':
018b0a
-			flag = 1;
018b0a
+			flag = true;
018b0a
 			break;
018b0a
 		case ':':
018b0a
 			errormsg(SH_DICT,2, "%s", opt_info.arg);
018b0a
@@ -179,14 +274,72 @@ int	b_cd(int argc, char *argv[],Shbltin_
018b0a
 					continue;
018b0a
 #endif /* SHOPT_FS_3D */
018b0a
 		}
018b0a
+		rval = newdirfd = sh_diropenat(shp, shp->pwdfd,
018b0a
+			path_relative(shp,stakptr(PATH_OFFSET)), xattr);
018b0a
+		if(newdirfd >=0)
018b0a
+		{
018b0a
+			/* chdir for directories on HSM/tapeworms may take minutes */
018b0a
+			if(fchdir(newdirfd) >= 0)
018b0a
+			{
018b0a
+				if(shp->pwdfd >= 0)
018b0a
+					sh_close(shp->pwdfd);
018b0a
+				shp->pwdfd=newdirfd;
018b0a
+				goto success;
018b0a
+			}
018b0a
+		}
018b0a
+#ifndef O_SEARCH
018b0a
+		else
018b0a
+		{
018b0a
 		if((rval=chdir(path_relative(shp,stakptr(PATH_OFFSET)))) >= 0)
018b0a
-			goto success;
018b0a
-		if(errno!=ENOENT && saverrno==0)
018b0a
+			{
018b0a
+				if(shp->pwdfd >= 0)
018b0a
+				{
018b0a
+					sh_close(shp->pwdfd);
018b0a
+#ifdef AT_FDCWD
018b0a
+					shp->pwdfd = AT_FDCWD;
018b0a
+#else
018b0a
+					shp->pwdfd = -1;
018b0a
+#endif
018b0a
+				}
018b0a
+			}
018b0a
+		}
018b0a
+#endif
018b0a
+		if(saverrno==0)
018b0a
 			saverrno=errno;
018b0a
+		if(newdirfd >=0)
018b0a
+			sh_close(newdirfd);
018b0a
 	}
018b0a
 	while(cdpath);
018b0a
 	if(rval<0 && *dir=='/' && *(path_relative(shp,stakptr(PATH_OFFSET)))!='/')
018b0a
-		rval = chdir(dir);
018b0a
+	{
018b0a
+		rval = newdirfd = sh_diropenat(shp,
018b0a
+			shp->pwdfd,
018b0a
+			dir, xattr);
018b0a
+		if(newdirfd >=0)
018b0a
+		{
018b0a
+			/* chdir for directories on HSM/tapeworms may take minutes */
018b0a
+			if(fchdir(newdirfd) >= 0)
018b0a
+			{
018b0a
+				if(shp->pwdfd >= 0)
018b0a
+					sh_close(shp->pwdfd);
018b0a
+				shp->pwdfd=newdirfd;
018b0a
+				goto success;
018b0a
+			}
018b0a
+		}
018b0a
+#ifndef O_SEARCH
018b0a
+		else
018b0a
+		{
018b0a
+			if(chdir(dir) >=0)
018b0a
+			{
018b0a
+				if(shp->pwdfd >= 0)
018b0a
+				{
018b0a
+					sh_close(shp->pwdfd);
018b0a
+					shp->pwdfd=-1;
018b0a
+				}
018b0a
+			}
018b0a
+		}
018b0a
+#endif
018b0a
+	}
018b0a
 	/* use absolute chdir() if relative chdir() fails */
018b0a
 	if(rval<0)
018b0a
 	{
018b0a
@@ -213,7 +366,7 @@ success:
018b0a
 	if(*dir != '/')
018b0a
 		return(0);
018b0a
 	nv_putval(opwdnod,oldpwd,NV_RDONLY);
018b0a
-	flag = strlen(dir);
018b0a
+	flag = (strlen(dir)>0)?true:false;
018b0a
 	/* delete trailing '/' */
018b0a
 	while(--flag>0 && dir[flag]=='/')
018b0a
 		dir[flag] = 0;
018b0a
diff -up ksh-20120801/src/cmd/ksh93/include/shell.h.orig ksh-20120801/src/cmd/ksh93/include/shell.h
018b0a
--- ksh-20120801/src/cmd/ksh93/include/shell.h.orig	2012-07-17 22:07:40.000000000 +0200
018b0a
+++ ksh-20120801/src/cmd/ksh93/include/shell.h	2012-10-24 15:42:10.756987230 +0200
018b0a
@@ -145,6 +145,7 @@ struct Shell_s
018b0a
 	unsigned char	trapnote;	/* set when trap/signal is pending */
018b0a
 	char		shcomp;		/* set when runing shcomp */
018b0a
 	short		subshell;	/* set for virtual subshell */
018b0a
+	int		pwdfd;		/* file descriptor for pwd */
018b0a
 #ifdef _SH_PRIVATE
018b0a
 	_SH_PRIVATE
018b0a
 #endif /* _SH_PRIVATE */
018b0a
diff -up ksh-20120801/src/cmd/ksh93/sh/init.c.orig ksh-20120801/src/cmd/ksh93/sh/init.c
018b0a
--- ksh-20120801/src/cmd/ksh93/sh/init.c.orig	2012-05-11 19:19:10.000000000 +0200
018b0a
+++ ksh-20120801/src/cmd/ksh93/sh/init.c	2012-10-24 15:31:59.659485151 +0200
018b0a
@@ -1365,6 +1365,18 @@ Shell_t *sh_init(register int argc,regis
018b0a
 		}
018b0a
 	}
018b0a
 	sh_ioinit(shp);
018b0a
+#ifdef AT_FDCWD
018b0a
+       shp->pwdfd = sh_diropenat(shp, AT_FDCWD, e_dot, false);
018b0a
+#else
018b0a
+       /* Systems without AT_FDCWD/openat() do not use the |dir| argument */
018b0a
+       shp->pwdfd = sh_diropenat(shp, -1, e_dot, false);
018b0a
+#endif
018b0a
+#ifdef O_SEARCH
018b0a
+       /* This should _never_ happen, guranteed by design and goat sacrifice */
018b0a
+       if(shp->pwdfd < 0)
018b0a
+               errormsg(SH_DICT,ERROR_system(1), "Can't obtain directory fd.");
018b0a
+#endif
018b0a
+
018b0a
 	/* initialize signal handling */
018b0a
 	sh_siginit(shp);
018b0a
 	stakinstall(NIL(Stak_t*),nospace);
018b0a
diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.orig ksh-20120801/src/cmd/ksh93/sh/xec.c
018b0a
--- ksh-20120801/src/cmd/ksh93/sh/xec.c.orig	2012-07-23 16:49:32.000000000 +0200
018b0a
+++ ksh-20120801/src/cmd/ksh93/sh/xec.c	2012-10-24 15:35:02.209539671 +0200
018b0a
@@ -1348,8 +1348,12 @@ int sh_exec(register const Shnode_t *t,
018b0a
 						{
018b0a
 							if(!shp->pwd)
018b0a
 								path_pwd(shp,0);
018b0a
-							if(shp->pwd)
018b0a
-								stat(".",&statb);
018b0a
+#ifndef O_SEARCH
018b0a
+							else if (shp->pwdfd>=0)
018b0a
+								fstat(shp->pwdfd,&statb);
018b0a
+							else if (shp->pwd)
018b0a
+								stat(e_dot,&statb);
018b0a
+#endif
018b0a
 							sfsync(NULL);
018b0a
 							share = sfset(sfstdin,SF_SHARE,0);
018b0a
 							sh_onstate(SH_STOPOK);
018b0a
@@ -1428,14 +1432,32 @@ int sh_exec(register const Shnode_t *t,
018b0a
 						sh_offstate(SH_NOFORK);
018b0a
 					if(!(nv_isattr(np,BLT_ENV)))
018b0a
 					{
018b0a
-						if(shp->pwd)
018b0a
+#ifdef O_SEARCH
018b0a
+						while((fchdir(shp->pwdfd) < 0) && errno==EINTR)
018b0a
+							errno = 0;
018b0a
+#else
018b0a
+						if(shp->pwd || (shp->pwdfd >= 0))
018b0a
 						{
018b0a
 							struct stat stata;
018b0a
 							stat(".",&stata);
018b0a
 							/* restore directory changed */
018b0a
 							if(statb.st_ino!=stata.st_ino || statb.st_dev!=stata.st_dev)
018b0a
-								chdir(shp->pwd);
018b0a
+							{
018b0a
+								/* chdir for directories on HSM/tapeworms may take minutes */
018b0a
+								int err=errno;
018b0a
+								if(shp->pwdfd >= 0)
018b0a
+								{
018b0a
+									 while((fchdir(shp->pwdfd) < 0) && errno==EINTR)
018b0a
+										errno = err;
018b0a
+								}
018b0a
+								else
018b0a
+								{
018b0a
+									 while((chdir(shp->pwd) < 0) && errno==EINTR)
018b0a
+										errno = err;
018b0a
+								}
018b0a
+							}
018b0a
 						}
018b0a
+#endif /* O_SEARCH */
018b0a
 						sh_offstate(SH_STOPOK);
018b0a
 						if(share&SF_SHARE)
018b0a
 							sfset(sfstdin,SF_PUBLIC|SF_SHARE,1);
018b0a
diff -up ksh-20120801/src/lib/libast/features/common.orig ksh-20120801/src/lib/libast/features/common
018b0a
--- ksh-20120801/src/lib/libast/features/common.orig	2011-12-12 20:55:33.000000000 +0100
018b0a
+++ ksh-20120801/src/lib/libast/features/common	2012-10-24 15:54:35.433885131 +0200
018b0a
@@ -463,6 +463,66 @@ typ uintptr_t stdint.h inttypes.h no{
018b0a
 	typedef unsigned _ast_int4_t uintptr_t;
018b0a
 	#endif
018b0a
 }end
018b0a
+typ _Bool = uint8_t
018b0a
+cat{
018b0a
+	#if defined(_STDC_C99) || __STDC_VERSION__ >= 199901L
018b0a
+	#include <stdbool.h>
018b0a
+	#else
018b0a
+	#define bool	_Bool
018b0a
+	#define false	0
018b0a
+	#define true	1
018b0a
+	#endif
018b0a
+}end
018b0a
+tst key __thread -lpthread note{ __thread keyword exists and works with -lpthread }end execute{
018b0a
+	#include	<pthread.h>
018b0a
+	
018b0a
+	#define INITIAL		1
018b0a
+	#define LOOP		100
018b0a
+	
018b0a
+	static __thread int	specific = INITIAL;
018b0a
+	static int		global = 0;
018b0a
+	
018b0a
+	static void* worker(void* arg)
018b0a
+	{
018b0a
+		int	k;
018b0a
+		int	v;
018b0a
+		v = (int)(arg - 0);
018b0a
+		for (k = 0; k < LOOP; ++k)
018b0a
+		{	
018b0a
+			specific += v;
018b0a
+			usleep(1);
018b0a
+		}
018b0a
+		if (specific != (INITIAL + LOOP * v)) 
018b0a
+			global = 1;
018b0a
+		return 0;
018b0a
+	}
018b0a
+	int main()
018b0a
+	{
018b0a
+		pthread_t	th[2];
018b0a
+	
018b0a
+		if (pthread_create(&th[0], 0, worker, (void*)0 + 5) ||
018b0a
+		    pthread_create(&th[1], 0, worker, (void*)0 + 7))
018b0a
+		{
018b0a
+			NOTE("pthread_create failed");
018b0a
+			return 1;
018b0a
+		}
018b0a
+		pthread_join(th[0], 0);
018b0a
+		pthread_join(th[1], 0);
018b0a
+		if (global)
018b0a
+		{
018b0a
+			NOTE("__thread variable not thread specific");
018b0a
+			return 1;
018b0a
+		}
018b0a
+		if (specific != INITIAL)
018b0a
+		{
018b0a
+			NOTE("main __thread variable changed by another thread");
018b0a
+			return 1;
018b0a
+		}
018b0a
+		return 0;
018b0a
+	}
018b0a
+}end no{
018b0a
+	#define __thread		/* __thread keyword does not exist or does not work with -lpthread */
018b0a
+}end
018b0a
 
018b0a
 tst	- -DTRY=1 - -DTRY=1 -Dvoid=char - -DTRY=2 - -DTRY=3 - -DTRY=4 output{
018b0a
 	#if _STD_ && _hdr_stdarg