mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 13:01:28 +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
|
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,
|
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
|
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,
|
In every case, the created file contains two versions of the wordcode,
|
||||||
one for big-endian machines and one for small-endian machines. The
|
one for big-endian machines and one for small-endian machines. The
|
||||||
|
|
|
@ -191,7 +191,7 @@ struct lexstack {
|
||||||
void (*hwend) _((void));
|
void (*hwend) _((void));
|
||||||
void (*addtoline) _((int));
|
void (*addtoline) _((int));
|
||||||
|
|
||||||
int eclen, ecused, ecfree, ecnpats;
|
int eclen, ecused, ecnpats;
|
||||||
Wordcode ecbuf;
|
Wordcode ecbuf;
|
||||||
Eccstr ecstrs;
|
Eccstr ecstrs;
|
||||||
int ecsoffs, ecssub, ecnfunc;
|
int ecsoffs, ecssub, ecnfunc;
|
||||||
|
@ -250,7 +250,6 @@ lexsave(void)
|
||||||
ls->addtoline = addtoline;
|
ls->addtoline = addtoline;
|
||||||
ls->eclen = eclen;
|
ls->eclen = eclen;
|
||||||
ls->ecused = ecused;
|
ls->ecused = ecused;
|
||||||
ls->ecfree = ecfree;
|
|
||||||
ls->ecnpats = ecnpats;
|
ls->ecnpats = ecnpats;
|
||||||
ls->ecbuf = ecbuf;
|
ls->ecbuf = ecbuf;
|
||||||
ls->ecstrs = ecstrs;
|
ls->ecstrs = ecstrs;
|
||||||
|
@ -311,7 +310,6 @@ lexrestore(void)
|
||||||
addtoline = lstack->addtoline;
|
addtoline = lstack->addtoline;
|
||||||
eclen = lstack->eclen;
|
eclen = lstack->eclen;
|
||||||
ecused = lstack->ecused;
|
ecused = lstack->ecused;
|
||||||
ecfree = lstack->ecfree;
|
|
||||||
ecnpats = lstack->ecnpats;
|
ecnpats = lstack->ecnpats;
|
||||||
ecbuf = lstack->ecbuf;
|
ecbuf = lstack->ecbuf;
|
||||||
ecstrs = lstack->ecstrs;
|
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;
|
Wordcode ecbuf;
|
||||||
/**/
|
/**/
|
||||||
|
@ -240,13 +240,12 @@ ecispace(int p, int n)
|
||||||
{
|
{
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
if (ecfree < n) {
|
if ((eclen - ecused) < n) {
|
||||||
int a = (n > 256 ? n : 256);
|
int a = (n > 256 ? n : 256);
|
||||||
|
|
||||||
ecbuf = (Wordcode) hrealloc((char *) ecbuf, eclen * sizeof(wordcode),
|
ecbuf = (Wordcode) hrealloc((char *) ecbuf, eclen * sizeof(wordcode),
|
||||||
(eclen + a) * sizeof(wordcode));
|
(eclen + a) * sizeof(wordcode));
|
||||||
eclen += a;
|
eclen += a;
|
||||||
ecfree += a;
|
|
||||||
}
|
}
|
||||||
if ((m = ecused - p) > 0)
|
if ((m = ecused - p) > 0)
|
||||||
memmove(ecbuf + p + n, ecbuf + p, m * sizeof(wordcode));
|
memmove(ecbuf + p + n, ecbuf + p, m * sizeof(wordcode));
|
||||||
|
@ -258,15 +257,13 @@ ecispace(int p, int n)
|
||||||
static int
|
static int
|
||||||
ecadd(wordcode c)
|
ecadd(wordcode c)
|
||||||
{
|
{
|
||||||
if (ecfree < 1) {
|
if ((eclen - ecused) < 1) {
|
||||||
ecbuf = (Wordcode) hrealloc((char *) ecbuf, eclen * sizeof(wordcode),
|
ecbuf = (Wordcode) hrealloc((char *) ecbuf, eclen * sizeof(wordcode),
|
||||||
(eclen + 256) * sizeof(wordcode));
|
(eclen + 256) * sizeof(wordcode));
|
||||||
eclen += 256;
|
eclen += 256;
|
||||||
ecfree += 256;
|
|
||||||
}
|
}
|
||||||
ecbuf[ecused] = c;
|
ecbuf[ecused] = c;
|
||||||
ecused++;
|
ecused++;
|
||||||
ecfree--;
|
|
||||||
|
|
||||||
return ecused - 1;
|
return ecused - 1;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +344,7 @@ ecstr(char *s)
|
||||||
static void
|
static void
|
||||||
init_parse(void)
|
init_parse(void)
|
||||||
{
|
{
|
||||||
ecbuf = (Wordcode) zhalloc((eclen = ecfree = 256) * sizeof(wordcode));
|
ecbuf = (Wordcode) zhalloc((eclen = 256) * sizeof(wordcode));
|
||||||
ecused = 0;
|
ecused = 0;
|
||||||
ecstrs = NULL;
|
ecstrs = NULL;
|
||||||
ecsoffs = ecnpats = 0;
|
ecsoffs = ecnpats = 0;
|
||||||
|
@ -2209,14 +2206,17 @@ struct fdhead {
|
||||||
#define fdheaderlen(f) (((Wordcode) (f))[FD_PRELEN])
|
#define fdheaderlen(f) (((Wordcode) (f))[FD_PRELEN])
|
||||||
|
|
||||||
#define fdmagic(f) (((Wordcode) (f))[0])
|
#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 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 fdother(f) (fdbyte(f, 1) + (fdbyte(f, 2) << 8) + (fdbyte(f, 3) << 16))
|
||||||
#define fdsetother(f, o) \
|
#define fdsetother(f, o) \
|
||||||
do { \
|
do { \
|
||||||
fdbyte(f, 1) = (o & 0xff); \
|
fdsetbyte(f, 1, ((o) & 0xff)); \
|
||||||
fdbyte(f, 2) = (o >> 8) & 0xff; \
|
fdsetbyte(f, 2, (((o) >> 8) & 0xff)); \
|
||||||
fdbyte(f, 3) = (o >> 16) & 0xff; \
|
fdsetbyte(f, 3, (((o) >> 16) & 0xff)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define fdversion(f) ((char *) ((f) + 2))
|
#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) {
|
for (ohlen = hlen; ; hlen = ohlen) {
|
||||||
fdmagic(pre) = (other ? FD_OMAGIC : FD_MAGIC);
|
fdmagic(pre) = (other ? FD_OMAGIC : FD_MAGIC);
|
||||||
fdflags(pre) = (map ? FDF_MAP : 0) | other;
|
fdsetflags(pre, ((map ? FDF_MAP : 0) | other));
|
||||||
fdsetother(pre, tlen);
|
fdsetother(pre, tlen);
|
||||||
strcpy(fdversion(pre), ZSH_VERSION);
|
strcpy(fdversion(pre), ZSH_VERSION);
|
||||||
write(dfd, pre, FD_PRELEN * sizeof(wordcode));
|
write(dfd, pre, FD_PRELEN * sizeof(wordcode));
|
||||||
|
@ -2536,6 +2536,8 @@ load_dump_file(char *dump, int other, int len)
|
||||||
d->count = 0;
|
d->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* See if `dump' is the name of a dump file and it has the definition
|
/* 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. */
|
* 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));
|
file = (strsfx(FD_EXT, dump) ? dump : dyncat(dump, FD_EXT));
|
||||||
|
|
||||||
|
#ifdef USE_MMAP
|
||||||
|
|
||||||
rec:
|
rec:
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
d = NULL;
|
d = NULL;
|
||||||
|
|
||||||
|
#ifdef USE_MMAP
|
||||||
|
|
||||||
for (f = dumps; f; f = f->next)
|
for (f = dumps; f; f = f->next)
|
||||||
if (!strcmp(file, f->name)) {
|
if (!strcmp(file, f->name)) {
|
||||||
d = f->map;
|
d = f->map;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
f = NULL;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!f && (isrec || !(d = load_dump_header(file)))) {
|
if (!f && (isrec || !(d = load_dump_header(file)))) {
|
||||||
if (!isrec) {
|
if (!isrec) {
|
||||||
struct stat stc, stn;
|
struct stat stc, stn;
|
||||||
|
@ -2580,6 +2596,9 @@ try_dump_file(char *dump, char *name, char *func)
|
||||||
if ((h = dump_find_func(d, name))) {
|
if ((h = dump_find_func(d, name))) {
|
||||||
/* Found the name. If the file is already mapped, return the eprog,
|
/* Found the name. If the file is already mapped, return the eprog,
|
||||||
* otherwise map it and just go up. */
|
* otherwise map it and just go up. */
|
||||||
|
|
||||||
|
#ifdef USE_MMAP
|
||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
Eprog prog = (Eprog) zalloc(sizeof(*prog));
|
Eprog prog = (Eprog) zalloc(sizeof(*prog));
|
||||||
Patprog *pp;
|
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));
|
load_dump_file(file, (fdflags(d) & FDF_OTHER), fdother(d));
|
||||||
isrec = 1;
|
isrec = 1;
|
||||||
goto rec;
|
goto rec;
|
||||||
} else {
|
} else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
Eprog prog;
|
Eprog prog;
|
||||||
Patprog *pp;
|
Patprog *pp;
|
||||||
int np, fd, po = h->npats * sizeof(Patprog);
|
int np, fd, po = h->npats * sizeof(Patprog);
|
||||||
|
@ -2646,6 +2669,8 @@ try_dump_file(char *dump, char *name, char *func)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_MMAP
|
||||||
|
|
||||||
/* Increment the reference counter for a dump file. */
|
/* Increment the reference counter for a dump file. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -2680,12 +2705,6 @@ decrdumpcount(FuncDump f)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
Eprog
|
|
||||||
try_dump_file(char *dump, char *name, char *func)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
incrdumpcount(FuncDump f)
|
incrdumpcount(FuncDump f)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue