mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
zsh-workers/10017
This commit is contained in:
parent
da55261a17
commit
bbd3406523
3 changed files with 43 additions and 23 deletions
|
@ -1317,7 +1317,10 @@ will be mapped into the shell's memory. This is done in such a way
|
|||
that multiple instances of the shell running on the same host will
|
||||
share this mapped function. If neither tt(-r) nor tt(-m) are given,
|
||||
the tt(zcompile) builtin decides which style is used based on the size
|
||||
of the resulting wordcode file.
|
||||
of the resulting wordcode file. On some systems it is impossible to
|
||||
map wordcode files into memory. On such systems, the functions will
|
||||
only be read from the files, independent on the mode selected when the
|
||||
file was created.
|
||||
|
||||
In every case, the created file contains two versions of the wordcode,
|
||||
one for big-endian machines and one for small-endian machines. The
|
||||
|
|
|
@ -191,7 +191,7 @@ struct lexstack {
|
|||
void (*hwend) _((void));
|
||||
void (*addtoline) _((int));
|
||||
|
||||
int eclen, ecused, ecfree, ecnpats;
|
||||
int eclen, ecused, ecnpats;
|
||||
Wordcode ecbuf;
|
||||
Eccstr ecstrs;
|
||||
int ecsoffs, ecssub, ecnfunc;
|
||||
|
@ -250,7 +250,6 @@ lexsave(void)
|
|||
ls->addtoline = addtoline;
|
||||
ls->eclen = eclen;
|
||||
ls->ecused = ecused;
|
||||
ls->ecfree = ecfree;
|
||||
ls->ecnpats = ecnpats;
|
||||
ls->ecbuf = ecbuf;
|
||||
ls->ecstrs = ecstrs;
|
||||
|
@ -311,7 +310,6 @@ lexrestore(void)
|
|||
addtoline = lstack->addtoline;
|
||||
eclen = lstack->eclen;
|
||||
ecused = lstack->ecused;
|
||||
ecfree = lstack->ecfree;
|
||||
ecnpats = lstack->ecnpats;
|
||||
ecbuf = lstack->ecbuf;
|
||||
ecstrs = lstack->ecstrs;
|
||||
|
|
57
Src/parse.c
57
Src/parse.c
|
@ -225,7 +225,7 @@ struct heredocs *hdocs;
|
|||
*/
|
||||
|
||||
/**/
|
||||
int eclen, ecused, ecfree, ecnpats;
|
||||
int eclen, ecused, ecnpats;
|
||||
/**/
|
||||
Wordcode ecbuf;
|
||||
/**/
|
||||
|
@ -240,13 +240,12 @@ ecispace(int p, int n)
|
|||
{
|
||||
int m;
|
||||
|
||||
if (ecfree < n) {
|
||||
if ((eclen - ecused) < n) {
|
||||
int a = (n > 256 ? n : 256);
|
||||
|
||||
ecbuf = (Wordcode) hrealloc((char *) ecbuf, eclen * sizeof(wordcode),
|
||||
(eclen + a) * sizeof(wordcode));
|
||||
eclen += a;
|
||||
ecfree += a;
|
||||
}
|
||||
if ((m = ecused - p) > 0)
|
||||
memmove(ecbuf + p + n, ecbuf + p, m * sizeof(wordcode));
|
||||
|
@ -258,15 +257,13 @@ ecispace(int p, int n)
|
|||
static int
|
||||
ecadd(wordcode c)
|
||||
{
|
||||
if (ecfree < 1) {
|
||||
if ((eclen - ecused) < 1) {
|
||||
ecbuf = (Wordcode) hrealloc((char *) ecbuf, eclen * sizeof(wordcode),
|
||||
(eclen + 256) * sizeof(wordcode));
|
||||
eclen += 256;
|
||||
ecfree += 256;
|
||||
}
|
||||
ecbuf[ecused] = c;
|
||||
ecused++;
|
||||
ecfree--;
|
||||
|
||||
return ecused - 1;
|
||||
}
|
||||
|
@ -347,7 +344,7 @@ ecstr(char *s)
|
|||
static void
|
||||
init_parse(void)
|
||||
{
|
||||
ecbuf = (Wordcode) zhalloc((eclen = ecfree = 256) * sizeof(wordcode));
|
||||
ecbuf = (Wordcode) zhalloc((eclen = 256) * sizeof(wordcode));
|
||||
ecused = 0;
|
||||
ecstrs = NULL;
|
||||
ecsoffs = ecnpats = 0;
|
||||
|
@ -2209,14 +2206,17 @@ struct fdhead {
|
|||
#define fdheaderlen(f) (((Wordcode) (f))[FD_PRELEN])
|
||||
|
||||
#define fdmagic(f) (((Wordcode) (f))[0])
|
||||
#define fdbyte(f, i) ((wordcode) (((unsigned char *) (((Wordcode) (f)) + 1))[i]))
|
||||
#define fdsetbyte(f,i,v) \
|
||||
((((unsigned char *) (((Wordcode) (f)) + 1))[i]) = ((unsigned char) (v)))
|
||||
#define fdbyte(f,i) ((wordcode) (((unsigned char *) (((Wordcode) (f)) + 1))[i]))
|
||||
#define fdflags(f) fdbyte(f, 0)
|
||||
#define fdsetflags(f,v) fdsetbyte(f, 0, v)
|
||||
#define fdother(f) (fdbyte(f, 1) + (fdbyte(f, 2) << 8) + (fdbyte(f, 3) << 16))
|
||||
#define fdsetother(f, o) \
|
||||
do { \
|
||||
fdbyte(f, 1) = (o & 0xff); \
|
||||
fdbyte(f, 2) = (o >> 8) & 0xff; \
|
||||
fdbyte(f, 3) = (o >> 16) & 0xff; \
|
||||
fdsetbyte(f, 1, ((o) & 0xff)); \
|
||||
fdsetbyte(f, 2, (((o) >> 8) & 0xff)); \
|
||||
fdsetbyte(f, 3, (((o) >> 16) & 0xff)); \
|
||||
} while (0)
|
||||
#define fdversion(f) ((char *) ((f) + 2))
|
||||
|
||||
|
@ -2423,7 +2423,7 @@ build_dump(char *nam, char *dump, char **files, int ali, int map)
|
|||
|
||||
for (ohlen = hlen; ; hlen = ohlen) {
|
||||
fdmagic(pre) = (other ? FD_OMAGIC : FD_MAGIC);
|
||||
fdflags(pre) = (map ? FDF_MAP : 0) | other;
|
||||
fdsetflags(pre, ((map ? FDF_MAP : 0) | other));
|
||||
fdsetother(pre, tlen);
|
||||
strcpy(fdversion(pre), ZSH_VERSION);
|
||||
write(dfd, pre, FD_PRELEN * sizeof(wordcode));
|
||||
|
@ -2536,6 +2536,8 @@ load_dump_file(char *dump, int other, int len)
|
|||
d->count = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* See if `dump' is the name of a dump file and it has the definition
|
||||
* for the function `name'. If so, return an eprog for it. */
|
||||
|
||||
|
@ -2551,14 +2553,28 @@ try_dump_file(char *dump, char *name, char *func)
|
|||
|
||||
file = (strsfx(FD_EXT, dump) ? dump : dyncat(dump, FD_EXT));
|
||||
|
||||
#ifdef USE_MMAP
|
||||
|
||||
rec:
|
||||
|
||||
#endif
|
||||
|
||||
d = NULL;
|
||||
|
||||
#ifdef USE_MMAP
|
||||
|
||||
for (f = dumps; f; f = f->next)
|
||||
if (!strcmp(file, f->name)) {
|
||||
d = f->map;
|
||||
break;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
f = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
if (!f && (isrec || !(d = load_dump_header(file)))) {
|
||||
if (!isrec) {
|
||||
struct stat stc, stn;
|
||||
|
@ -2580,6 +2596,9 @@ try_dump_file(char *dump, char *name, char *func)
|
|||
if ((h = dump_find_func(d, name))) {
|
||||
/* Found the name. If the file is already mapped, return the eprog,
|
||||
* otherwise map it and just go up. */
|
||||
|
||||
#ifdef USE_MMAP
|
||||
|
||||
if (f) {
|
||||
Eprog prog = (Eprog) zalloc(sizeof(*prog));
|
||||
Patprog *pp;
|
||||
|
@ -2604,7 +2623,11 @@ try_dump_file(char *dump, char *name, char *func)
|
|||
load_dump_file(file, (fdflags(d) & FDF_OTHER), fdother(d));
|
||||
isrec = 1;
|
||||
goto rec;
|
||||
} else {
|
||||
} else
|
||||
|
||||
#endif
|
||||
|
||||
{
|
||||
Eprog prog;
|
||||
Patprog *pp;
|
||||
int np, fd, po = h->npats * sizeof(Patprog);
|
||||
|
@ -2646,6 +2669,8 @@ try_dump_file(char *dump, char *name, char *func)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef USE_MMAP
|
||||
|
||||
/* Increment the reference counter for a dump file. */
|
||||
|
||||
/**/
|
||||
|
@ -2680,12 +2705,6 @@ decrdumpcount(FuncDump f)
|
|||
|
||||
#else
|
||||
|
||||
Eprog
|
||||
try_dump_file(char *dump, char *name, char *func)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
incrdumpcount(FuncDump f)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue