C++ (Cpp) ARRAY_SIZE Examples

C++ (Cpp) ARRAY_SIZE - 30 examples found. These are the top rated real world C++ (Cpp) examples of ARRAY_SIZE extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
File: ini.c Project: LordJZ/altdrag
int main(int argc, char *argv[]) {
    if (argc < 4) {
        printf("Not enough arguments\n");
        printf("Usage: ini <file> <section> <key> [new value]\n");
        return 0;
    }

    // Get path
    char path[MAX_PATH];
    if (PathIsRelative(argv[1])) {
        GetCurrentDirectory(ARRAY_SIZE(path), path);
        PathAddBackslash(path);
        strcat(path, argv[1]);
    }
    else {
        strcpy(path, argv[1]);
    }

    // Write/Read
    if (argc == 4) {
        char txt[1000];
        GetPrivateProfileString(argv[2], argv[3], NULL, txt, ARRAY_SIZE(txt), path); // No error detection possible
        printf(txt);
    }
    else if (WritePrivateProfileString(argv[2],argv[3],argv[4],path) == 0) {
        int errorcode = GetLastError();
        char *errormsg;
        int length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorcode, 0, (char*)&errormsg, 0, NULL);
        errormsg[length-2] = '\0'; // Remove that damn newline at the end of the formatted error message
        printf("WritePrivateProfileString() failed in file %s, line %d.\nError: %s (%d)", TEXT(__FILE__), __LINE__, errormsg, errorcode);
        LocalFree(errormsg);
        return 1;
    }
    return 0;
}
Example #2
0
/*
 * ipipeif_try_format() - Handle try format by pad subdev method
 * @ipipeif: VPFE ipipeif device.
 * @fh: V4L2 subdev file handle.
 * @pad: pad num.
 * @fmt: pointer to v4l2 format structure.
 * @which : wanted subdev format
 */
static void
ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif,
                   struct v4l2_subdev_fh *fh, unsigned int pad,
                   struct v4l2_mbus_framefmt *fmt,
                   enum v4l2_subdev_format_whence which)
{
    unsigned int max_out_height;
    unsigned int max_out_width;
    unsigned int i;

    max_out_width = IPIPE_MAX_OUTPUT_WIDTH_A;
    max_out_height = IPIPE_MAX_OUTPUT_HEIGHT_A;

    if (pad == IPIPEIF_PAD_SINK) {
        for (i = 0; i < ARRAY_SIZE(ipipeif_input_fmts); i++)
            if (fmt->code == ipipeif_input_fmts[i])
                break;

        /* If not found, use SBGGR10 as default */
        if (i >= ARRAY_SIZE(ipipeif_input_fmts))
            fmt->code = V4L2_MBUS_FMT_SGRBG12_1X12;
    } else if (pad == IPIPEIF_PAD_SOURCE) {
        for (i = 0; i < ARRAY_SIZE(ipipeif_output_fmts); i++)
            if (fmt->code == ipipeif_output_fmts[i])
                break;

        /* If not found, use UYVY as default */
        if (i >= ARRAY_SIZE(ipipeif_output_fmts))
            fmt->code = V4L2_MBUS_FMT_UYVY8_2X8;
    }

    fmt->width = clamp_t(u32, fmt->width, MIN_OUT_HEIGHT, max_out_width);
    fmt->height = clamp_t(u32, fmt->height, MIN_OUT_WIDTH, max_out_height);
}
Example #3
0
static void mx53_clocks_ipu_init(void __iomem *regs)
{
    clks[IMX5_CLK_LDB_DI1_DIV_3_5]	= imx_clk_fixed_factor("ldb_di1_div_3_5", "ldb_di1_sel", 2, 7);
    clks[IMX5_CLK_LDB_DI1_DIV]	= imx_clk_divider("ldb_di1_div", "ldb_di1_div_3_5", regs + CCM_CSCMR2, 11, 1);
    clks[IMX5_CLK_LDB_DI1_SEL]	= imx_clk_mux_p("ldb_di1_sel", regs + CCM_CSCMR2, 9, 1,
                                  mx53_ldb_di1_sel, ARRAY_SIZE(mx53_ldb_di1_sel));
    clks[IMX5_CLK_DI_PLL4_PODF]	= imx_clk_divider("di_pll4_podf", "pll4_sw", regs + CCM_CDCDR, 16, 3);
    clks[IMX5_CLK_LDB_DI0_DIV_3_5]	= imx_clk_fixed_factor("ldb_di0_div_3_5", "ldb_di0_sel", 2, 7);
    clks[IMX5_CLK_LDB_DI0_DIV]	= imx_clk_divider("ldb_di0_div", "ldb_di0_div_3_5", regs + CCM_CSCMR2, 10, 1);
    clks[IMX5_CLK_LDB_DI0_SEL]	= imx_clk_mux_p("ldb_di0_sel", regs + CCM_CSCMR2, 8, 1,
                                  mx53_ldb_di0_sel, ARRAY_SIZE(mx53_ldb_di0_sel));
    clks[IMX5_CLK_IPU_DI0_SEL]	= imx_clk_mux_p("ipu_di0_sel", regs + CCM_CSCMR2, 26, 3,
                                  mx53_ipu_di0_sel, ARRAY_SIZE(mx53_ipu_di0_sel));
    clks[IMX5_CLK_IPU_DI1_SEL]	= imx_clk_mux_p("ipu_di1_sel", regs + CCM_CSCMR2, 29, 3,
                                  mx53_ipu_di1_sel, ARRAY_SIZE(mx53_ipu_di1_sel));
    clks[IMX5_CLK_TVE_EXT_SEL]	= imx_clk_mux_p("tve_ext_sel", regs + CCM_CSCMR1, 6, 1,
                                  mx53_tve_ext_sel, ARRAY_SIZE(mx53_tve_ext_sel));
    clks[IMX5_CLK_TVE_PRED]		= imx_clk_divider("tve_pred", "tve_ext_sel", regs + CCM_CDCDR, 28, 3);

    mx5_clocks_ipu_init(regs);

    clkdev_add_physbase(clks[IMX5_CLK_IPU_SEL], MX53_IPU_BASE_ADDR, "bus");
    clkdev_add_physbase(clks[IMX5_CLK_IPU_DI0_SEL], MX53_IPU_BASE_ADDR, "di0");
    clkdev_add_physbase(clks[IMX5_CLK_IPU_DI1_SEL], MX53_IPU_BASE_ADDR, "di1");
}
/*
 * Fix up regulator consumer data that moves to a different regulator based on
 * the current target.
 */
void __init configure_msm8960_power_grid(void)
{
    static struct rpm_regulator_init_data *rpm_data;
    int i;

    if (machine_is_msm8960_cdp() || cpu_is_msm8960ab()) {
        /* Only modify LVS6 consumers for CDP targets. */
        for (i = 0; i < ARRAY_SIZE(msm_rpm_regulator_init_data); i++) {
            rpm_data = &msm_rpm_regulator_init_data[i];
            if (machine_is_msm8960_cdp() &&
                    rpm_data->id == RPM_VREG_ID_PM8921_LVS6) {
                rpm_data->init_data.consumer_supplies
                    = vreg_consumers_CDP_LVS6;
                rpm_data->init_data.num_consumer_supplies
                    = ARRAY_SIZE(vreg_consumers_CDP_LVS6);
            }
            if (cpu_is_msm8960ab() &&
                    rpm_data->id == RPM_VREG_ID_PM8921_S7) {
                rpm_data->init_data.constraints.min_uV =
                    1275000;
                rpm_data->init_data.constraints.max_uV =
                    1275000;
                rpm_data->init_data.constraints.input_uV =
                    1275000;
                rpm_data->default_uV = 1275000;
            }
        }
    }

    if (msm8960_oem_funcs.msm_regulator_init)
        msm8960_oem_funcs.msm_regulator_init(&msm8960_oem_funcs);
}
Example #5
0
/*
 * ipipeif_enum_mbus_code() - Handle pixel format enumeration
 * @sd: pointer to v4l2 subdev structure
 * @fh: V4L2 subdev file handle
 * @code: pointer to v4l2_subdev_mbus_code_enum structure
 * return -EINVAL or zero on success
 */
static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd,
                                  struct v4l2_subdev_fh *fh,
                                  struct v4l2_subdev_mbus_code_enum *code)
{
    switch (code->pad) {
    case IPIPEIF_PAD_SINK:
        if (code->index >= ARRAY_SIZE(ipipeif_input_fmts))
            return -EINVAL;

        code->code = ipipeif_input_fmts[code->index];
        break;

    case IPIPEIF_PAD_SOURCE:
        if (code->index >= ARRAY_SIZE(ipipeif_output_fmts))
            return -EINVAL;

        code->code = ipipeif_output_fmts[code->index];
        break;

    default:
        return -EINVAL;
    }

    return 0;
}
Example #6
0
void __init at91sam9261_initialize(unsigned long main_clock)
{
    /* Map peripherals */
    iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc));

    if (cpu_is_at91sam9g10())
        iotable_init(at91sam9g10_sram_desc, ARRAY_SIZE(at91sam9g10_sram_desc));
    else
        iotable_init(at91sam9261_sram_desc, ARRAY_SIZE(at91sam9261_sram_desc));


    at91_arch_reset = at91sam9_alt_reset;
    pm_power_off = at91sam9261_poweroff;
    at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
                      | (1 << AT91SAM9261_ID_IRQ2);

    /* Init clock subsystem */
    at91_clock_init(main_clock);

    /* Register the processor-specific clocks */
    at91sam9261_register_clocks();

    /* Register GPIO subsystem */
    at91_gpio_init(at91sam9261_gpio, 3);
}