|
|
1.1 root 1: char xstr[];
2: #line 1 "sh.time.c"
3:
4: static char sccsid[] = (&xstr[4268]);
5:
6:
7:
8: #line 1 "./sh.h"
9:
10:
11:
12: #line 1 "./sh.local.h"
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59: #line 51 "./sh.local.h"
60:
61: #line 4 "./sh.h"
62:
1.1.1.2 ! root 63: #line 1 "/DIST/usr/include/sys/time.h"
1.1 root 64:
65:
66:
67:
68:
69:
70: struct timeval {
71: long tv_sec;
72: long tv_usec;
73: };
74:
75: struct timezone {
76: int tz_minuteswest;
77: int tz_dsttime;
78: };
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105: struct itimerval {
106: struct timeval it_interval;
107: struct timeval it_value;
108: };
109:
110:
111:
112:
113: struct tm {
114: int tm_sec;
115: int tm_min;
116: int tm_hour;
117: int tm_mday;
118: int tm_mon;
119: int tm_year;
120: int tm_wday;
121: int tm_yday;
122: int tm_isdst;
123: };
124:
125:
126: extern struct tm *gmtime(), *localtime();
127: extern char *asctime(), *ctime();
128:
129: #line 5 "./sh.h"
130:
1.1.1.2 ! root 131: #line 1 "/DIST/usr/include/sys/resource.h"
1.1 root 132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151: struct rusage {
152: struct timeval ru_utime;
153: struct timeval ru_stime;
154: long ru_maxrss;
155:
156: long ru_ixrss;
157: long ru_idrss;
158: long ru_isrss;
159: long ru_minflt;
160: long ru_majflt;
161: long ru_nswap;
162: long ru_inblock;
163: long ru_oublock;
164: long ru_msgsnd;
165: long ru_msgrcv;
166: long ru_nsignals;
167: long ru_nvcsw;
168: long ru_nivcsw;
169:
170: };
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186: struct rlimit {
187: int rlim_cur;
188: int rlim_max;
189: };
190: #line 6 "./sh.h"
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
1.1.1.2 ! root 202: #line 1 "/DIST/usr/include/sys/param.h"
1.1 root 203:
204:
205:
206:
207:
1.1.1.2 ! root 208: #line 8 "/DIST/usr/include/sys/param.h"
! 209:
! 210:
! 211: #line 1 "/DIST/usr/include/machine/param.h"
! 212:
! 213:
1.1 root 214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
1.1.1.2 ! root 262:
! 263:
! 264:
! 265:
! 266:
! 267:
! 268:
! 269:
! 270: #line 10 "/DIST/usr/include/sys/param.h"
! 271:
1.1 root 272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
1.1.1.2 ! root 311:
! 312:
! 313:
! 314:
! 315:
! 316: #line 57 "/DIST/usr/include/sys/param.h"
! 317:
! 318:
! 319: #line 1 "/DIST/usr/include/signal.h"
1.1 root 320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368: int (*signal())();
369:
370:
371:
372:
373:
374: struct sigvec {
375: int (*sv_handler)();
376: int sv_mask;
377: int sv_onstack;
378: };
379:
380:
381:
382:
383: struct sigstack {
384: char *ss_sp;
385: int ss_onstack;
386: };
387:
388:
389:
390:
391:
392:
393:
394:
395: struct sigcontext {
396: int sc_onstack;
397: int sc_mask;
398: int sc_sp;
399: int sc_pc;
400: int sc_ps;
401: };
402:
403:
404:
405:
406:
1.1.1.2 ! root 407: #line 91 "/DIST/usr/include/signal.h"
1.1 root 408:
409:
1.1.1.2 ! root 410: #line 59 "/DIST/usr/include/sys/param.h"
1.1 root 411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
1.1.1.2 ! root 450: #line 103 "/DIST/usr/include/sys/param.h"
1.1 root 451:
452:
453:
454:
455:
456:
457:
458:
1.1.1.2 ! root 459:
! 460:
! 461:
! 462:
! 463:
! 464: #line 1 "/DIST/usr/include/sys/types.h"
1.1 root 465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480: typedef unsigned char u_char;
481: typedef unsigned short u_short;
482: typedef unsigned int u_int;
483: typedef unsigned long u_long;
484: typedef unsigned short ushort;
1.1.1.2 ! root 485: typedef unsigned int uint;
! 486: typedef unsigned long ulong;
1.1 root 487:
488: typedef struct _physadr { int r[1]; } *physadr;
489: typedef struct label_t {
490: int val[14];
491: } label_t;
492:
493: typedef struct _quad { long val[2]; } quad;
494: typedef long daddr_t;
495: typedef char * caddr_t;
496: typedef u_long ino_t;
497: typedef long swblk_t;
498: typedef int size_t;
499: typedef int time_t;
500: typedef short dev_t;
501: typedef int off_t;
502:
503: typedef struct fd_set { int fds_bits[1]; } fd_set;
1.1.1.2 ! root 504: #line 116 "/DIST/usr/include/sys/param.h"
! 505: #line 120 "/DIST/usr/include/sys/param.h"
1.1 root 506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579: #line 17 "./sh.h"
580:
1.1.1.2 ! root 581: #line 1 "/DIST/usr/include/sys/stat.h"
1.1 root 582:
583:
584: struct stat
585: {
586: dev_t st_dev;
587: ino_t st_ino;
588: unsigned short st_mode;
589: short st_nlink;
590: short st_uid;
591: short st_gid;
592: dev_t st_rdev;
593: off_t st_size;
594: time_t st_atime;
595: int st_spare1;
596: time_t st_mtime;
597: int st_spare2;
598: time_t st_ctime;
599: int st_spare3;
600: long st_blksize;
601: long st_blocks;
602: long st_spare4[2];
603: };
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618: #line 18 "./sh.h"
619:
620:
621:
622:
1.1.1.2 ! root 623: #line 1 "/DIST/usr/include/errno.h"
1.1 root 624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714: #line 22 "./sh.h"
715:
1.1.1.2 ! root 716: #line 1 "/DIST/usr/include/setjmp.h"
1.1 root 717:
718:
719: typedef int jmp_buf[14];
720: #line 23 "./sh.h"
721:
1.1.1.2 ! root 722: #line 1 "/DIST/usr/include/signal.h"
1.1 root 723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
1.1.1.2 ! root 735: #line 92 "/DIST/usr/include/signal.h"
1.1 root 736:
737: #line 24 "./sh.h"
738:
1.1.1.2 ! root 739: #line 1 "/DIST/usr/include/sys/times.h"
1.1 root 740:
741:
742:
743:
744:
745: struct tms {
746: time_t tms_utime;
747: time_t tms_stime;
748: time_t tms_cutime;
749: time_t tms_cstime;
750: };
751: #line 25 "./sh.h"
752:
753: typedef char bool;
754:
755:
756:
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767: bool chkstop;
768: bool didcch;
769: bool didfds;
770: bool doneinp;
771: bool exiterr;
772: bool child;
773: bool haderr;
774: bool intty;
775: bool intact;
776: bool justpr;
777: bool loginsh;
778: bool neednote;
779: bool noexec;
780: bool pjobs;
781: bool setintr;
782: bool timflg;
783:
784:
785:
786:
787: char *arginp;
788: int onelflg;
789: char *file;
790:
791: char *err;
792: int errno;
793: char *shtemp;
794: struct timeval time0;
795: struct rusage ru0;
796:
797:
798:
799:
800: char *doldol;
801: int uid;
802: time_t chktim;
803: int shpgrp;
804: int tpgrp;
805:
806: int opgrp;
807: int oldisc;
808: struct tms shtimes;
809:
810:
811:
812:
813:
814:
815: struct biltins {
816: char *bname;
817: int (*bfunct)();
818: short minargs, maxargs;
819: } bfunc[];
820:
821:
822:
823: struct srch {
824: char *s_name;
825: short s_value;
826: } srchn[];
827:
828:
829:
830:
831:
832:
833:
834:
835:
836: short SHIN;
837: short SHOUT;
838: short SHDIAG;
839: short OLDSTD;
840:
841:
842:
843:
844:
845:
846:
847:
848:
849: jmp_buf reslab;
850:
851:
852:
853:
854:
855:
856:
857: char *gointr;
858: int (*parintr)();
859: int (*parterm)();
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873:
874:
875:
876:
877:
878: struct Bin {
879: off_t Bfseekp;
880: off_t Bfbobp;
881: off_t Bfeobp;
882: short Bfblocks;
883: char **Bfbuf;
884: } B;
885:
886:
887:
888:
889:
890:
891:
892: off_t btell();
893:
894:
895:
896:
897:
898:
899: off_t lineloc;
900:
901:
902: off_t tell();
903: bool cantell;
904:
905:
906:
907:
908:
909:
910: struct wordent {
911: char *word;
912: struct wordent *prev;
913: struct wordent *next;
914: };
915:
916:
917:
918:
919:
920:
921:
922:
923:
924:
925:
926:
927:
928:
929:
930:
931:
932:
933:
934:
935:
936: char labuf[1024 ];
937:
938: char *lap;
939:
940:
941:
942:
943:
944:
945:
946:
947: struct command {
948: short t_dtyp;
949: short t_dflg;
950: union {
951: char *T_dlef;
952: struct command *T_dcar;
953: } L;
954: union {
955: char *T_drit;
956: struct command *T_dcdr;
957: } R;
958:
959:
960:
961:
962: char **t_dcom;
963: struct command *t_dspr;
964: short t_nice;
965: };
966:
967:
968:
969:
970:
971:
972:
973:
974:
975:
976:
977:
978:
979:
980:
981:
982:
983:
984:
985:
986:
987:
988:
989:
990:
991:
992:
993:
994:
995:
996:
997:
998:
999:
1000:
1001:
1002:
1003:
1004:
1005:
1006:
1007:
1008:
1009:
1010:
1011:
1012:
1013:
1014:
1015:
1016:
1017:
1018:
1019: struct whyle {
1020: off_t w_start;
1021: off_t w_end;
1022: char **w_fe, **w_fe0;
1023: char *w_fename;
1024: struct whyle *w_next;
1025: } *whyles;
1026:
1027:
1028:
1029:
1030:
1031:
1032: struct varent {
1033: char **vec;
1034: char *name;
1035: struct varent *link;
1036: } shvhed, aliases;
1037:
1038:
1039:
1040:
1041:
1042: struct wordent *alhistp;
1043: struct wordent *alhistt;
1044: char **alvec;
1045:
1046:
1047:
1048:
1049: short gflag;
1050:
1051:
1052:
1053:
1054:
1055:
1056:
1057:
1058:
1059:
1060: char **gargv;
1061: short gargc;
1062: short gnleft;
1063:
1064:
1065:
1066:
1067: char **pargv;
1068: char *pargs;
1069: short pargc;
1070: short pnleft;
1071: char *pargcp;
1072:
1073:
1074:
1075:
1076:
1077:
1078:
1079:
1080:
1081:
1082:
1083:
1084: struct Hist {
1085: struct wordent Hlex;
1086: int Hnum;
1087: int Href;
1088: struct Hist *Hnext;
1089: } Histlist;
1090:
1091: struct wordent paraml;
1092: int eventno;
1093: int lastev;
1094:
1095: char HIST;
1096: char HISTSUB;
1097:
1098: char *Dfix1();
1099: struct varent *adrof(), *adrof1();
1100: char **blkcat();
1101: char **blkcpy();
1102: char **blkend();
1103: char **blkspl();
1104: char *calloc();
1105: char *cname();
1106: char **copyblk();
1107: char **dobackp();
1108: char *domod();
1109: struct wordent *dosub();
1110: char *exp3();
1111: char *exp3a();
1112: char *exp4();
1113: char *exp5();
1114: char *exp6();
1115: struct Hist *enthist();
1116: struct Hist *findev();
1117: struct wordent *freenod();
1118: char *getenv();
1119: char *getinx();
1120: struct varent *getvx();
1121: struct passwd *getpwnam();
1122: struct wordent *gethent();
1123: struct wordent *getsub();
1124: char *getwd();
1125: char *globone();
1126: struct biltins *isbfunc();
1127: char **glob();
1128: char *operate();
1129: int phup();
1130: int pintr();
1131: int pchild();
1132: char *putn();
1133: char **saveblk();
1134: char *savestr();
1135: char *strcat();
1136: char *strcpy();
1137: char *strend();
1138: char *strings();
1139: char *strip();
1140: char *strspl();
1141: char *subword();
1142: struct command *syntax();
1143: struct command *syn0();
1144: struct command *syn1();
1145: struct command *syn1a();
1146: struct command *syn1b();
1147: struct command *syn2();
1148: struct command *syn3();
1149: int tglob();
1150: int trim();
1151: char *value(), *value1();
1152: char *xhome();
1153: char *xname();
1154: char *xset();
1155:
1156:
1157:
1158:
1159:
1160:
1161: char *bname;
1162:
1163:
1164:
1165: char *Vsav;
1166: char **Vav;
1167: char *Vdp;
1168:
1169:
1170: char **evalvec;
1171: char *evalp;
1172:
1173: struct mesg {
1174: char *iname;
1175: char *pname;
1176: } mesg[];
1177: #line 6 "sh.time.c"
1178:
1179:
1180:
1181:
1182: struct tms times0;
1183: struct tms timesdol;
1184:
1185: settimes()
1186: {
1187: struct rusage ruch;
1188:
1189: gettimeofday(&time0, (struct timezone *)0);
1190: getrusage(0, &ru0);
1191: getrusage(-1, &ruch);
1192: ruadd(&ru0, &ruch);
1193: }
1194:
1195:
1196:
1197:
1198:
1199: dotime()
1200: {
1201: struct timeval timedol;
1202: struct rusage ru1, ruch;
1203:
1204: getrusage(0, &ru1);
1205: getrusage(-1, &ruch);
1206: ruadd(&ru1, &ruch);
1207: gettimeofday(&timedol, (struct timezone *)0);
1208: prusage(&ru0, &ru1, &timedol, &time0);
1209: }
1210:
1211:
1212:
1213:
1214: donice(v)
1215: register char **v;
1216: {
1217: register char *cp;
1218:
1219: v++, cp = *v++;
1220: if (cp == 0) {
1221:
1222: nice(20);
1223: nice(-10);
1224:
1225: nice(4);
1226: } else if (*v == 0 && any(cp[0], (&xstr[1099]))) {
1227:
1228: nice(20);
1229: nice(-10);
1230:
1231: nice(getn(cp));
1232: }
1233: }
1234:
1235: ruadd(ru, ru2)
1236: register struct rusage *ru, *ru2;
1237: {
1238: register long *lp, *lp2;
1239: register int cnt;
1240:
1241: tvadd(&ru->ru_utime, &ru2->ru_utime);
1242: tvadd(&ru->ru_stime, &ru2->ru_stime);
1243: if (ru2->ru_maxrss > ru->ru_maxrss)
1244: ru->ru_maxrss = ru2->ru_maxrss;
1245: cnt = &ru-> ru_nivcsw - &ru->ru_ixrss + 1;
1246: lp = &ru->ru_ixrss; lp2 = &ru2->ru_ixrss;
1247: do
1248: *lp++ += *lp2++;
1249: while (--cnt > 0);
1250: }
1251:
1252: prusage(r0, r1, e, b)
1253: register struct rusage *r0, *r1;
1254: struct timeval *e, *b;
1255: {
1256: register time_t t =
1257: (r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+
1258: (r1->ru_utime.tv_usec-r0->ru_utime.tv_usec)/10000+
1259: (r1->ru_stime.tv_sec-r0->ru_stime.tv_sec)*100+
1260: (r1->ru_stime.tv_usec-r0->ru_stime.tv_usec)/10000;
1261: register char *cp;
1262: register int i;
1263: register struct varent *vp = adrof((&xstr[1493]));
1264: int ms =
1265: (e->tv_sec-b->tv_sec)*100 + (e->tv_usec-b->tv_usec)/10000;
1266:
1267: cp = (&xstr[4305]);
1268: if (vp && vp->vec[0] && vp->vec[1])
1269: cp = vp->vec[1];
1270: for (; *cp; cp++)
1271: if (*cp != '%')
1272: putchar(*cp);
1273: else if (cp[1]) switch(*++cp) {
1274:
1275: case 'U':
1276: pdeltat(&r1->ru_utime, &r0->ru_utime);
1277: break;
1278:
1279: case 'S':
1280: pdeltat(&r1->ru_stime, &r0->ru_stime);
1281: break;
1282:
1283: case 'E':
1284: psecs(ms / 100);
1285: break;
1286:
1287: case 'P':
1288: printf((&xstr[4343]), (int) (t*100 / ((ms ? ms : 1))));
1289: break;
1290:
1291: case 'W':
1292: i = r1->ru_nswap - r0->ru_nswap;
1293: printf((&xstr[3573]), i);
1294: break;
1295:
1296: case 'X':
1297: printf((&xstr[3573]), t == 0 ? 0 : (r1->ru_ixrss-r0->ru_ixrss)/t);
1298: break;
1299:
1300: case 'D':
1301: printf((&xstr[3573]), t == 0 ? 0 :
1302: (r1->ru_idrss+r1->ru_isrss-(r0->ru_idrss+r0->ru_isrss))/t);
1303: break;
1304:
1305: case 'K':
1306: printf((&xstr[3573]), t == 0 ? 0 :
1307: ((r1->ru_ixrss+r1->ru_isrss+r1->ru_idrss) -
1308: (r0->ru_ixrss+r0->ru_idrss+r0->ru_isrss))/t);
1309: break;
1310:
1311: case 'M':
1312: printf((&xstr[3573]), r1->ru_maxrss/2);
1313: break;
1314:
1315: case 'F':
1316: printf((&xstr[3573]), r1->ru_majflt-r0->ru_majflt);
1317: break;
1318:
1319: case 'R':
1320: printf((&xstr[3573]), r1->ru_minflt-r0->ru_minflt);
1321: break;
1322:
1323: case 'I':
1324: printf((&xstr[3573]), r1->ru_inblock-r0->ru_inblock);
1325: break;
1326:
1327: case 'O':
1328: printf((&xstr[3573]), r1->ru_oublock-r0->ru_oublock);
1329: break;
1330: }
1331: putchar('\n');
1332: }
1333:
1334: pdeltat(t1, t0)
1335: struct timeval *t1, *t0;
1336: {
1337: struct timeval td;
1338:
1339: tvsub(&td, t1, t0);
1340: printf((&xstr[4348]), td.tv_sec, td.tv_usec/100000);
1341: }
1342:
1343: tvadd(tsum, t0)
1344: struct timeval *tsum, *t0;
1345: {
1346:
1347: tsum->tv_sec += t0->tv_sec;
1348: tsum->tv_usec += t0->tv_usec;
1349: if (tsum->tv_usec > 1000000)
1350: tsum->tv_sec++, tsum->tv_usec -= 1000000;
1351: }
1352:
1353: tvsub(tdiff, t1, t0)
1354: struct timeval *tdiff, *t1, *t0;
1355: {
1356:
1357: tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
1358: tdiff->tv_usec = t1->tv_usec - t0->tv_usec;
1359: if (tdiff->tv_usec < 0)
1360: tdiff->tv_sec--, tdiff->tv_usec += 1000000;
1361: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.