Ejemplo n.º 1
0
void
UnusedVars_run(void) 
{
    ConfWriter_start_module("UnusedVars");
    
    /* Write the macros (no test, these are the same everywhere). */
    ConfWriter_append_conf("#define CHY_UNUSED_VAR(x) ((void)x)\n");
    ConfWriter_append_conf("#define CHY_UNREACHABLE_RETURN(type) return (type)0\n");

    /* Shorten. */
    ConfWriter_start_short_names();
    ConfWriter_shorten_macro("UNUSED_VAR");
    ConfWriter_shorten_macro("UNREACHABLE_RETURN");
    ConfWriter_end_short_names();

    ConfWriter_end_module();
}
Ejemplo n.º 2
0
void
LargeFiles_run(void) {
    int found_off64_t = false;
    int found_stdio64 = false;
    int found_lseek   = false;
    int found_pread64 = false;
    unsigned i;
    const char *stat_includes = "#include <stdio.h>\n#include <sys/stat.h>";

    ConfWriter_start_module("LargeFiles");

    /* Find off64_t or equivalent. */
    found_off64_t = S_probe_off64();
    if (found_off64_t) {
        ConfWriter_add_def("HAS_64BIT_OFFSET_TYPE", NULL);
        ConfWriter_add_def("off64_t",  off64_type);
    }

    /* See if stdio variants with 64-bit support exist. */
    for (i = 0; stdio64_combos[i].includes != NULL; i++) {
        stdio64_combo combo = stdio64_combos[i];
        if (S_probe_stdio64(&combo)) {
            found_stdio64 = true;
            ConfWriter_add_def("HAS_64BIT_STDIO", NULL);
            strcpy(fopen_command, combo.fopen_command);
            strcpy(fseek_command, combo.fseek_command);
            strcpy(ftell_command, combo.ftell_command);
            ConfWriter_add_def("fopen64",  fopen_command);
            ConfWriter_add_def("ftello64", ftell_command);
            ConfWriter_add_def("fseeko64", fseek_command);
            break;
        }
    }

    /* Probe for 64-bit versions of lseek and pread (if we have an off64_t). */
    if (found_off64_t) {
        for (i = 0; unbuff_combos[i].lseek_command != NULL; i++) {
            unbuff_combo combo = unbuff_combos[i];
            found_lseek = S_probe_lseek(&combo);
            if (found_lseek) {
                ConfWriter_add_def("HAS_64BIT_LSEEK", NULL);
                strcpy(lseek_command, combo.lseek_command);
                ConfWriter_add_def("lseek64", lseek_command);
                break;
            }
        }
        for (i = 0; unbuff_combos[i].pread64_command != NULL; i++) {
            unbuff_combo combo = unbuff_combos[i];
            found_pread64 = S_probe_pread64(&combo);
            if (found_pread64) {
                ConfWriter_add_def("HAS_64BIT_PREAD", NULL);
                strcpy(pread64_command, combo.pread64_command);
                ConfWriter_add_def("pread64", pread64_command);
                found_pread64 = true;
                break;
            }
        }
    }

    /* Make checks needed for testing. */
    if (HeadCheck_check_header("sys/stat.h")) {
        ConfWriter_append_conf("#define CHAZ_HAS_SYS_STAT_H\n");
    }
    if (HeadCheck_check_header("io.h")) {
        ConfWriter_append_conf("#define CHAZ_HAS_IO_H\n");
    }
    if (HeadCheck_check_header("fcntl.h")) {
        ConfWriter_append_conf("#define CHAZ_HAS_FCNTL_H\n");
    }
    if (HeadCheck_contains_member("struct stat", "st_size", stat_includes)) {
        ConfWriter_append_conf("#define CHAZ_HAS_STAT_ST_SIZE\n");
    }
    if (HeadCheck_contains_member("struct stat", "st_blocks", stat_includes)) {
        ConfWriter_append_conf("#define CHAZ_HAS_STAT_ST_BLOCKS\n");
    }

    ConfWriter_end_module();
}