atlas: patch out usage of deprecated tmpnam on darwin

+278 -1
+2 -1
pkgs/development/libraries/science/math/atlas/default.nix
··· 63 63 # performance timings. We ignore that check, however, because with binaries 64 64 # being pre-built on Hydra those timings aren't accurate for the local 65 65 # machine in the first place. 66 - patches = optional tolerateCpuTimingInaccuracy ./disable-timing-accuracy-check.patch; 66 + patches = optional tolerateCpuTimingInaccuracy ./disable-timing-accuracy-check.patch 67 + ++ optional stdenv.isDarwin ./tmpdir.patch; 67 68 68 69 # Configure outside of the source directory. 69 70 preConfigure = ''
+276
pkgs/development/libraries/science/math/atlas/tmpdir.patch
··· 1 + diff --git a/CONFIG/ARCHS/negflt.c b/CONFIG/ARCHS/negflt.c 2 + index e5b7871..d45e387 100644 3 + --- a/CONFIG/ARCHS/negflt.c 4 + +++ b/CONFIG/ARCHS/negflt.c 5 + @@ -239,7 +239,7 @@ void NegFile(char *fnam, int N, int *cols) 6 + FILE *fpin, *fpout; 7 + WORDS *wp0, *wp; 8 + 9 + - tnam = tmpnam(NULL); 10 + + tnam = tempnam(NULL, NULL); 11 + fpin = fopen(fnam, "r"); 12 + assert(fpin); 13 + fpout = fopen(tnam, "w"); 14 + diff --git a/CONFIG/include/atlas_sys.h b/CONFIG/include/atlas_sys.h 15 + index b83a749..8902d38 100644 16 + --- a/CONFIG/include/atlas_sys.h 17 + +++ b/CONFIG/include/atlas_sys.h 18 + @@ -216,12 +216,13 @@ static char *ATL_fgets_CWS(char *sout, int *plen, FILE *fpin) 19 + 20 + static char *ATL_tmpnam(void) 21 + { 22 + - static char tnam[L_tmpnam]; 23 + + static char *tnam; 24 + static char FirstTime=1; 25 + if (FirstTime) 26 + { 27 + FirstTime = 0; 28 + - assert(tmpnam(tnam)); 29 + + tnam = tempnam(NULL, NULL); 30 + + assert(tnam); 31 + } 32 + return(tnam); 33 + } 34 + diff --git a/bin/atlas_install.c b/bin/atlas_install.c 35 + index 2753cbf..e49cc3e 100644 36 + --- a/bin/atlas_install.c 37 + +++ b/bin/atlas_install.c 38 + @@ -662,7 +662,8 @@ void GoToTown(int ARCHDEF, int L1DEF, int TuneLA) 39 + { 40 + const char TR[2] = {'N','T'}; 41 + char prec[4] = {'d', 's', 'z', 'c'}, pre, upre, *typ; 42 + - char ln[1024], tnam[256], ln2[512], ln3[512], fnam[128]; 43 + + char ln[1024], ln2[512], ln3[512], fnam[128]; 44 + + char *tnam; 45 + char *mulinst, *peakstr, *peakstr2; 46 + int nprec=4; 47 + int iL1, lat, muladd, maused, latuse, lbnreg; 48 + @@ -681,7 +682,7 @@ void GoToTown(int ARCHDEF, int L1DEF, int TuneLA) 49 + fpsum = fopen("INSTALL_LOG/SUMMARY.LOG", "a"); 50 + ATL_Cassert(fpsum, "OPENING INSTALL_LOG/SUMMARY.LOG", NULL); 51 + 52 + - ATL_Cassert(tmpnam(tnam), "GETTING TEMPFILE", NULL); 53 + + ATL_Cassert((tnam = tempnam(NULL, NULL)), "GETTING TEMPFILE", NULL); 54 + 55 + if (L1DEF) 56 + { 57 + diff --git a/bin/extract.c b/bin/extract.c 58 + index 7a5a926..53fb8bf 100644 59 + --- a/bin/extract.c 60 + +++ b/bin/extract.c 61 + @@ -3378,7 +3378,7 @@ void PushProc0(EXTENV *EE, EXTPROC **basep, EXTPROC **myfuncs, char *ln) 62 + pp->argnams = KillWord(wp, wp); 63 + pp->nargs = CountWords(pp->argnams); 64 + 65 + - cp = tmpnam(NULL); 66 + + cp = tempnam(NULL, NULL); 67 + if (cp == NULL) ExtErr(EE, "Out of tmpnams!!!"); 68 + i = Wstrlen(cp) + 1; 69 + pp->FileNam = malloc(i*sizeof(char)); 70 + diff --git a/include/atlas_mvtesttime.h b/include/atlas_mvtesttime.h 71 + index 9147fcb..ab6a99f 100644 72 + --- a/include/atlas_mvtesttime.h 73 + +++ b/include/atlas_mvtesttime.h 74 + @@ -105,14 +105,15 @@ static int MVKernelFailsTest 75 + char ln[4096]; 76 + char *sp; 77 + int i, lda0; 78 + - static char outnam[L_tmpnam]; 79 + + static char* outnam; 80 + static int FirstTime=1; 81 + 82 + if (FirstTime) 83 + { 84 + 85 + FirstTime = 0; 86 + - assert(tmpnam(outnam)); 87 + + outnam = tempnam(NULL, NULL); 88 + + assert(outnam); 89 + } 90 + /* 91 + * If the file is generated, call generator to create it 92 + @@ -221,14 +222,15 @@ static double TimeMVKernel 93 + char ln[2048], resf[256], *sp; 94 + double *dp, mf; 95 + int i, align = pre2size(pre); 96 + - static char outnam[L_tmpnam]; 97 + + static char* outnam; 98 + static int FirstTime=1; 99 + 100 + if (FirstTime) 101 + { 102 + 103 + FirstTime = 0; 104 + - assert(tmpnam(outnam)); 105 + + outnam = tempnam(NULL, NULL); 106 + + assert(outnam); 107 + } 108 + /* 109 + * If the file is generated, call generator to create it 110 + diff --git a/include/atlas_r1testtime.h b/include/atlas_r1testtime.h 111 + index b33213a..f27ee25 100644 112 + --- a/include/atlas_r1testtime.h 113 + +++ b/include/atlas_r1testtime.h 114 + @@ -76,14 +76,15 @@ static int R1KernelFailsTest 115 + char ln[4096]; 116 + char *sp; 117 + int i, lda0; 118 + - static char outnam[L_tmpnam]; 119 + + static char* outnam; 120 + static int FirstTime=1; 121 + 122 + if (FirstTime) 123 + { 124 + 125 + FirstTime = 0; 126 + - assert(tmpnam(outnam)); 127 + + outnam = tempnam(NULL, NULL); 128 + + assert(outnam); 129 + } 130 + /* 131 + * If the file is generated, call generator to create it 132 + @@ -187,14 +188,15 @@ static double TimeR1Kernel 133 + char ln[2048], resf[256], *sp; 134 + double *dp, mf; 135 + int i, align = pre2size(pre); 136 + - static char outnam[L_tmpnam]; 137 + + static char* outnam; 138 + static int FirstTime=1; 139 + 140 + if (FirstTime) 141 + { 142 + 143 + FirstTime = 0; 144 + - assert(tmpnam(outnam)); 145 + + outnam = tempnam(NULL, NULL); 146 + + assert(outnam); 147 + } 148 + /* 149 + * If the file is generated, call generator to create it 150 + diff --git a/include/atlas_r2testtime.h b/include/atlas_r2testtime.h 151 + index facc66d..c638dce 100644 152 + --- a/include/atlas_r2testtime.h 153 + +++ b/include/atlas_r2testtime.h 154 + @@ -76,14 +76,15 @@ static int R2KernelFailsTest 155 + char ln[4096]; 156 + char *sp; 157 + int i, lda0; 158 + - static char outnam[L_tmpnam]; 159 + + static char* outnam; 160 + static int FirstTime=1; 161 + 162 + if (FirstTime) 163 + { 164 + 165 + FirstTime = 0; 166 + - assert(tmpnam(outnam)); 167 + + outnam = tempnam(NULL, NULL); 168 + + assert(outnam); 169 + } 170 + /* 171 + * If the file is generated, call generator to create it 172 + @@ -187,14 +188,15 @@ static double TimeR2Kernel 173 + char ln[2048], resf[256], *sp; 174 + double *dp, mf; 175 + int i, align = pre2size(pre); 176 + - static char outnam[L_tmpnam]; 177 + + static char* outnam; 178 + static int FirstTime=1; 179 + 180 + if (FirstTime) 181 + { 182 + 183 + FirstTime = 0; 184 + - assert(tmpnam(outnam)); 185 + + outnam = tempnam(NULL, NULL); 186 + + assert(outnam); 187 + } 188 + /* 189 + * If the file is generated, call generator to create it 190 + diff --git a/include/atlas_sys.h b/include/atlas_sys.h 191 + index b83a749..b3f88d2 100644 192 + --- a/include/atlas_sys.h 193 + +++ b/include/atlas_sys.h 194 + @@ -216,12 +216,13 @@ static char *ATL_fgets_CWS(char *sout, int *plen, FILE *fpin) 195 + 196 + static char *ATL_tmpnam(void) 197 + { 198 + - static char tnam[L_tmpnam]; 199 + + static char* tnam; 200 + static char FirstTime=1; 201 + if (FirstTime) 202 + { 203 + FirstTime = 0; 204 + - assert(tmpnam(tnam)); 205 + + tnam = tempnam(NULL, NULL); 206 + + assert(tnam); 207 + } 208 + return(tnam); 209 + } 210 + diff --git a/tune/blas/gemm/usercomb.c b/tune/blas/gemm/usercomb.c 211 + index 59a7cd4..eb3eb05 100644 212 + --- a/tune/blas/gemm/usercomb.c 213 + +++ b/tune/blas/gemm/usercomb.c 214 + @@ -138,11 +138,13 @@ int GetUserCase(char pre, int icase, int *iflag, int *mb, int *nb, int *kb, 215 + 216 + void CombineFiles(char *fout, int nfiles, char **fnams) 217 + { 218 + - char tnam[256], ln[512]; 219 + + char ln[512]; 220 + + char *tnam; 221 + int i, j, n, nn; 222 + FILE *fpout, *fpin; 223 + 224 + - assert(tmpnam(tnam)); 225 + + tnam = tempnam(NULL, NULL); 226 + + assert(tnam); 227 + for (n=i=0; i < nfiles; i++) n += NumUserCases0(fnams[i]); 228 + 229 + fpout = fopen(tnam, "w"); 230 + diff --git a/tune/blas/gemm/userflag.c b/tune/blas/gemm/userflag.c 231 + index c3983e4..b7dd70b 100644 232 + --- a/tune/blas/gemm/userflag.c 233 + +++ b/tune/blas/gemm/userflag.c 234 + @@ -139,8 +139,8 @@ int GetUserCase(char pre, int icase, int *iflag, int *mb, int *nb, int *kb, 235 + 236 + void GoGetThem(char *infile, char *outfile) 237 + { 238 + - char ln[512], ln2[512], tnam[256], MCC[256], MMFLAGS[256]; 239 + - char *chkfile = "FlagCheck.c", *sp, *sp2; 240 + + char ln[512], ln2[512], MCC[256], MMFLAGS[256]; 241 + + char *chkfile = "FlagCheck.c", *sp, *sp2, *tnam; 242 + FILE *fpin, *fpout; 243 + int i, j, n, nmin=0, good; 244 + int wass; 245 + @@ -152,7 +152,8 @@ void GoGetThem(char *infile, char *outfile) 246 + n = NumUserCases0(infile); 247 + fpin = fopen(infile, "r"); 248 + assert(fpin); 249 + - assert(tmpnam(tnam)); 250 + + tnam = tempnam(NULL, NULL); 251 + + assert(tnam); 252 + fpout = fopen(tnam, "w"); 253 + assert(fpout); 254 + assert(fgets(ln, 512, fpin)); 255 + diff --git a/tune/sysinfo/emit_buildinfo.c b/tune/sysinfo/emit_buildinfo.c 256 + index 309c06a..3feaea7 100644 257 + --- a/tune/sysinfo/emit_buildinfo.c 258 + +++ b/tune/sysinfo/emit_buildinfo.c 259 + @@ -41,14 +41,15 @@ static char SMCVERS[LNLEN], DMCVERS[LNLEN], SKCVERS[LNLEN], DKCVERS[LNLEN]; 260 + static char UNAM[64], DATE[128]; 261 + char *CmndResults(char *cmnd) 262 + { 263 + - static char tnam[128]; 264 + + static char* tnam; 265 + static int FirstTime=1; 266 + char ln[512]; 267 + 268 + if (FirstTime) 269 + { 270 + FirstTime = 0; 271 + - assert(tmpnam(tnam)); 272 + + tnam = tempnam(NULL, NULL); 273 + + assert(tnam); 274 + } 275 + sprintf(ln, "%s > %s\n", cmnd, tnam); 276 + fprintf(stderr, "system: %s", ln);