Blame SOURCES/ksh-20120801-rmdirfix.patch

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