LEFT | RIGHT |
(no file at all) | |
1 // Inferno utils/iar/ar.c | 1 // Inferno utils/iar/ar.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/iar/ar.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/iar/ar.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 return 0; | 1525 return 0; |
1526 return 1; | 1526 return 1; |
1527 } | 1527 } |
1528 | 1528 |
1529 /* | 1529 /* |
1530 * Spill a member to a disk copy of a temp file | 1530 * Spill a member to a disk copy of a temp file |
1531 */ | 1531 */ |
1532 int | 1532 int |
1533 page(Arfile *ap) | 1533 page(Arfile *ap) |
1534 { | 1534 { |
1535 » Armember *bp; | 1535 » sysfatal("page"); |
1536 | |
1537 » bp = ap->head; | |
1538 » if (!ap->paged) {» » /* not yet paged - create file */ | |
1539 » » ap->fd = mkstemp(ap->fname); | |
1540 » » if (ap->fd < 0) { | |
1541 » » » fprint(2,"gopack: can't create temp file\n"); | |
1542 » » » return 0; | |
1543 » » } | |
1544 » » ap->paged = 1; | |
1545 » } | |
1546 » if (!arwrite(ap->fd, bp))» /* write member and free buffer block */ | |
1547 » » return 0; | |
1548 » ap->head = bp->next; | |
1549 » if (ap->tail == bp) | |
1550 » » ap->tail = bp->next; | |
1551 » free(bp->member); | |
1552 » free(bp); | |
1553 return 1; | 1536 return 1; |
1554 } | 1537 } |
1555 | 1538 |
1556 /* | 1539 /* |
1557 * try to reclaim space by paging. we try to spill the start, middle, | 1540 * try to reclaim space by paging. we try to spill the start, middle, |
1558 * and end files, in that order. there is no particular reason for the | 1541 * and end files, in that order. there is no particular reason for the |
1559 * ordering. | 1542 * ordering. |
1560 */ | 1543 */ |
1561 int | 1544 int |
1562 getspace(void) | 1545 getspace(void) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 } | 1708 } |
1726 } | 1709 } |
1727 bp->size = w - (char*)bp->member; | 1710 bp->size = w - (char*)bp->member; |
1728 sprint(bp->hdr.size, "%-10lld", (vlong)bp->size); | 1711 sprint(bp->hdr.size, "%-10lld", (vlong)bp->size); |
1729 strncpy(bp->hdr.fmag, ARFMAG, 2); | 1712 strncpy(bp->hdr.fmag, ARFMAG, 2); |
1730 Bseek(b, end, 0); | 1713 Bseek(b, end, 0); |
1731 if(Boffset(b)&1) | 1714 if(Boffset(b)&1) |
1732 Bgetc(b); | 1715 Bgetc(b); |
1733 return 1; | 1716 return 1; |
1734 } | 1717 } |
LEFT | RIGHT |