Annotation of MiNT/src/genmagic.c, revision 1.1.1.3

1.1       root        1: #include "mint.h"
                      2: 
                      3: #include <stdio.h>
                      4: 
                      5: #include <stdlib.h>
                      6: 
                      7: #include <stddef.h>
                      8: 
                      9: 
                     10: 
                     11: static void usage P_((void));
                     12: 
1.1.1.3 ! root       13: int main(int argc, char **argv);
        !            14: 
1.1       root       15: 
                     16: 
                     17: static void
                     18: 
                     19: usage()
                     20: 
                     21: {
                     22: 
                     23:        fprintf(stderr, "Usage: genmagic outputfile\n");
                     24: 
                     25:        exit(2);
                     26: 
                     27: }
                     28: 
                     29: 
                     30: 
                     31: /* conventions:
                     32: 
                     33:  * C_XXX is offset of XXX in CONTEXT struct
                     34: 
                     35:  * P_XXX is offset of XXX in PROC struct
                     36: 
                     37:  */
                     38: 
                     39: 
                     40: 
                     41: struct magics {
                     42: 
                     43:        const char *name;
                     44: 
                     45:        long value;
                     46: 
                     47: } magics[] = {
                     48: 
                     49:        { "C_PTRACE", offsetof(CONTEXT, ptrace)},
                     50: 
                     51:        { "C_SFMT", offsetof(CONTEXT, sfmt)},
                     52: 
                     53:        { "C_INTERNAL", offsetof(CONTEXT, internal)},
                     54: 
                     55:        { "C_SR", offsetof(CONTEXT, sr)},
                     56: 
                     57:        { "C_PC", offsetof(CONTEXT, pc)},
                     58: 
                     59:        { "C_FSTATE", offsetof(CONTEXT, fstate)},
                     60: 
                     61:        { "C_FREGS", offsetof(CONTEXT, fregs)},
                     62: 
                     63:        { "C_FCTRL", offsetof(CONTEXT, fctrl)},
                     64: 
                     65:        { "C_USP", offsetof(CONTEXT, usp)},
                     66: 
                     67:        { "C_SSP", offsetof(CONTEXT, ssp)},
                     68: 
                     69:        { "C_TERM", offsetof(CONTEXT, term_vec)},
                     70: 
                     71:        { "C_D0", offsetof(CONTEXT, regs)},
                     72: 
                     73:        { "C_A0", offsetof(CONTEXT, regs)+32},
                     74: 
1.1.1.2   root       75:        { "C_CRP", offsetof(CONTEXT, crp)},
                     76: 
                     77:        { "C_TC", offsetof(CONTEXT, tc)},
                     78: 
                     79:        { "P_CTXT0", offsetof(PROC, ctxt)},
                     80: 
1.1       root       81:        { "P_SYSTIME", offsetof(PROC, systime)},
                     82: 
                     83:        { "P_USRTIME", offsetof(PROC, usrtime)},
                     84: 
                     85:        { "P_PTRACER", offsetof(PROC, ptracer)},
                     86: 
                     87:        { "P_SYSCTXT", offsetof(PROC, ctxt)},
                     88: 
1.1.1.2   root       89:        { "P_EXCPC", offsetof(PROC, exception_pc)},
                     90: 
                     91:        { "P_EXCSSP", offsetof(PROC, exception_ssp)},
                     92: 
                     93:        { "P_EXCADDR", offsetof(PROC, exception_addr)},
                     94: 
                     95:        { "P_EXCTBL", offsetof(PROC, exception_tbl)},
                     96: 
                     97:        { "P_EXCMMUSR", offsetof(PROC, exception_mmusr)},
                     98: 
1.1       root       99:        { (char *)0, 0 }
                    100: 
                    101: };
                    102: 
                    103: 
                    104: 
                    105: int
                    106: 
                    107: main(argc, argv)
                    108: 
                    109:        int argc;
                    110: 
                    111:        char **argv;
                    112: 
                    113: {
                    114: 
                    115:        FILE *f;
                    116: 
                    117:        int i;
                    118: 
                    119: 
                    120: 
                    121:        if (argc != 2)
                    122: 
                    123:                usage();
                    124: 
                    125:        f = fopen(argv[1], "w");
                    126: 
                    127:        if (!f) {
                    128: 
                    129:                perror(argv[1]);
                    130: 
                    131:                exit(1);
                    132: 
                    133:        }
                    134: 
                    135: 
                    136: 
                    137:        for (i = 0; magics[i].name; i++) {
                    138: 
                    139:                fprintf(f, "%%define %s %ld\n", magics[i].name,
                    140: 
                    141:                                magics[i].value);
                    142: 
                    143:        }
                    144: 
                    145:        fclose(f);
                    146: 
                    147:        return 0;
                    148: 
                    149: }
                    150: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.