content
stringlengths
19
48.2k
/* DO NOT EDIT THIS FILE * Automatically generated by toolchain/trunk/proc-defs/sh/create-arch-headers.sh * DO NOT EDIT THIS FILE */ #ifndef __MACH_CDEF_BLACKFIN__ #define __MACH_CDEF_BLACKFIN__ #ifdef __ADSPBF504__ # include "mach-bf506/BF504_cdef.h" #endif #ifdef __ADSPBF506__ # include "mach-bf506/BF506_cdef.h" #endif #ifdef __ADSPBF512__ # include "mach-bf518/BF512_cdef.h" #endif #ifdef __ADSPBF514__ # include "mach-bf518/BF514_cdef.h" #endif #ifdef __ADSPBF516__ # include "mach-bf518/BF516_cdef.h" #endif #ifdef __ADSPBF518__ # include "mach-bf518/BF518_cdef.h" #endif #ifdef __ADSPBF522__ # include "mach-bf527/BF522_cdef.h" #endif #ifdef __ADSPBF523__ # include "mach-bf527/BF523_cdef.h" #endif #ifdef __ADSPBF524__ # include "mach-bf527/BF524_cdef.h" #endif #ifdef __ADSPBF525__ # include "mach-bf527/BF525_cdef.h" #endif #ifdef __ADSPBF526__ # include "mach-bf527/BF526_cdef.h" #endif #ifdef __ADSPBF527__ # include "mach-bf527/BF527_cdef.h" #endif #ifdef __ADSPBF531__ # include "mach-bf533/BF531_cdef.h" #endif #ifdef __ADSPBF532__ # include "mach-bf533/BF532_cdef.h" #endif #ifdef __ADSPBF533__ # include "mach-bf533/BF533_cdef.h" #endif #ifdef __ADSPBF534__ # include "mach-bf537/BF534_cdef.h" #endif #ifdef __ADSPBF536__ # include "mach-bf537/BF536_cdef.h" #endif #ifdef __ADSPBF537__ # include "mach-bf537/BF537_cdef.h" #endif #ifdef __ADSPBF538__ # include "mach-bf538/BF538_cdef.h" #endif #ifdef __ADSPBF539__ # include "mach-bf538/BF539_cdef.h" #endif #ifdef __ADSPBF542__ # include "mach-bf548/BF542_cdef.h" #endif #ifdef __ADSPBF544__ # include "mach-bf548/BF544_cdef.h" #endif #ifdef __ADSPBF547__ # include "mach-bf548/BF547_cdef.h" #endif #ifdef __ADSPBF548__ # include "mach-bf548/BF548_cdef.h" #endif #ifdef __ADSPBF549__ # include "mach-bf548/BF549_cdef.h" #endif #ifdef __ADSPBF561__ # include "mach-bf561/BF561_cdef.h" #endif #ifdef __ADSPBF609__ # include "mach-bf609/BF609_cdef.h" #endif #endif /* __MACH_CDEF_BLACKFIN__ */
/* * Write a list of register settings; */ static int sensor_write_array(struct v4l2_subdev *sd, struct regval_list *regs, int array_size) { int i=0; if(!regs) return -EINVAL; while(i<array_size) { if(regs->addr == REG_DLY) { msleep(regs->data); } else { LOG_ERR_RET(sensor_write(sd, regs->addr, regs->data)) } i++; regs++; } return 0; }
/* * Show the BPST of this device. * * Calculated from the receive time of the device's beacon and it's * slot number. */ static ssize_t uwb_dev_BPST_show(struct device *dev, struct device_attribute *attr, char *buf) { struct uwb_dev *uwb_dev = to_uwb_dev(dev); struct uwb_beca_e *bce; struct uwb_beacon_frame *bf; u16 bpst; bce = uwb_dev->bce; mutex_lock(&bce->mutex); bf = (struct uwb_beacon_frame *)bce->be->BeaconInfo; bpst = bce->be->wBPSTOffset - (u16)(bf->Beacon_Slot_Number * UWB_BEACON_SLOT_LENGTH_US); mutex_unlock(&bce->mutex); return sprintf(buf, "%d\n", bpst); }
// we divide polynomial p1 by the lm of p2 static Polynomial * divide_lm(Polynomial * p1, Polynomial * p2){ assert(!num_mstack); Term * lm = p2->lm->term; Polynomial * tmp = p1; while(tmp){ Monomial * lm_tmp = tmp->lm; if(contained(lm, lm_tmp->term)){ Term * m = term_remainder(lm_tmp->term, lm); mpz_t ctmp; mpz_init(ctmp); mpz_cdiv_q(ctmp, lm_tmp->coeff, p2->lm->coeff); mpz_mul_si(ctmp, ctmp, -1); push_mstack_sorted(new_monomial(ctmp, copy_term(m))); mpz_clear(ctmp); } tmp = tmp->rest; } Polynomial * p = build_polynomial_from_stack(); return p; }
/* * Somewhat useful debug utility to dump the contents of a BIO to a file. * Note that a memory BIO will have its contents eliminated after they * are read so this will break the next step. */ static void dump_bio_to_file(BIO *in, char *filename) { char iobuf[4096]; int len; BIO *out; out = BIO_new_file(filename, "w"); if(out){ if(BIO_method_type(in) != BIO_TYPE_MEM) BIO_reset(in); while((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) BIO_write(out, iobuf, len); BIO_free(out); } BIO_reset(in); }
// SPDX-License-Identifier: GPL-2.0-only /* * i2c-stm32.c * * Copyright (C) M'boumba Cedric Madianga 2017 * Author: M'boumba Cedric Madianga <cedric.madianga@gmail.com> */ #include "i2c-stm32.h" /* Functions for DMA support */ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, dma_addr_t phy_addr, u32 txdr_offset, u32 rxdr_offset) { struct stm32_i2c_dma *dma; struct dma_slave_config dma_sconfig; int ret; dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); if (!dma) return ERR_PTR(-ENOMEM); /* Request and configure I2C TX dma channel */ dma->chan_tx = dma_request_chan(dev, "tx"); if (IS_ERR(dma->chan_tx)) { ret = PTR_ERR(dma->chan_tx); if (ret != -ENODEV) ret = dev_err_probe(dev, ret, "can't request DMA tx channel\n"); goto fail_al; } memset(&dma_sconfig, 0, sizeof(dma_sconfig)); dma_sconfig.dst_addr = phy_addr + txdr_offset; dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; dma_sconfig.dst_maxburst = 1; dma_sconfig.direction = DMA_MEM_TO_DEV; ret = dmaengine_slave_config(dma->chan_tx, &dma_sconfig); if (ret < 0) { dev_err(dev, "can't configure tx channel\n"); goto fail_tx; } /* Request and configure I2C RX dma channel */ dma->chan_rx = dma_request_chan(dev, "rx"); if (IS_ERR(dma->chan_rx)) { ret = PTR_ERR(dma->chan_rx); if (ret != -ENODEV) ret = dev_err_probe(dev, ret, "can't request DMA rx channel\n"); goto fail_tx; } memset(&dma_sconfig, 0, sizeof(dma_sconfig)); dma_sconfig.src_addr = phy_addr + rxdr_offset; dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; dma_sconfig.src_maxburst = 1; dma_sconfig.direction = DMA_DEV_TO_MEM; ret = dmaengine_slave_config(dma->chan_rx, &dma_sconfig); if (ret < 0) { dev_err(dev, "can't configure rx channel\n"); goto fail_rx; } init_completion(&dma->dma_complete); dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n", dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx)); return dma; fail_rx: dma_release_channel(dma->chan_rx); fail_tx: dma_release_channel(dma->chan_tx); fail_al: devm_kfree(dev, dma); return ERR_PTR(ret); } void stm32_i2c_dma_free(struct stm32_i2c_dma *dma) { dma->dma_buf = 0; dma->dma_len = 0; dma_release_channel(dma->chan_tx); dma->chan_tx = NULL; dma_release_channel(dma->chan_rx); dma->chan_rx = NULL; dma->chan_using = NULL; } int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma, bool rd_wr, u32 len, u8 *buf, dma_async_tx_callback callback, void *dma_async_param) { struct dma_async_tx_descriptor *txdesc; struct device *chan_dev; int ret; if (rd_wr) { dma->chan_using = dma->chan_rx; dma->dma_transfer_dir = DMA_DEV_TO_MEM; dma->dma_data_dir = DMA_FROM_DEVICE; } else { dma->chan_using = dma->chan_tx; dma->dma_transfer_dir = DMA_MEM_TO_DEV; dma->dma_data_dir = DMA_TO_DEVICE; } dma->dma_len = len; chan_dev = dma->chan_using->device->dev; dma->dma_buf = dma_map_single(chan_dev, buf, dma->dma_len, dma->dma_data_dir); if (dma_mapping_error(chan_dev, dma->dma_buf)) { dev_err(dev, "DMA mapping failed\n"); return -EINVAL; } txdesc = dmaengine_prep_slave_single(dma->chan_using, dma->dma_buf, dma->dma_len, dma->dma_transfer_dir, DMA_PREP_INTERRUPT); if (!txdesc) { dev_err(dev, "Not able to get desc for DMA xfer\n"); ret = -EINVAL; goto err; } reinit_completion(&dma->dma_complete); txdesc->callback = callback; txdesc->callback_param = dma_async_param; ret = dma_submit_error(dmaengine_submit(txdesc)); if (ret < 0) { dev_err(dev, "DMA submit failed\n"); goto err; } dma_async_issue_pending(dma->chan_using); return 0; err: dma_unmap_single(chan_dev, dma->dma_buf, dma->dma_len, dma->dma_data_dir); return ret; }
/* * Analog Devices ADM1272 High Voltage Positive Hot Swap Controller and Digital * Power Monitor with PMBus * * Copyright 2021 Google LLC * * SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" #include <string.h> #include "hw/i2c/pmbus_device.h" #include "hw/irq.h" #include "migration/vmstate.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "qemu/log.h" #include "qemu/module.h" #define TYPE_ADM1272 "adm1272" #define ADM1272(obj) OBJECT_CHECK(ADM1272State, (obj), TYPE_ADM1272) #define ADM1272_RESTART_TIME 0xCC #define ADM1272_MFR_PEAK_IOUT 0xD0 #define ADM1272_MFR_PEAK_VIN 0xD1 #define ADM1272_MFR_PEAK_VOUT 0xD2 #define ADM1272_MFR_PMON_CONTROL 0xD3 #define ADM1272_MFR_PMON_CONFIG 0xD4 #define ADM1272_MFR_ALERT1_CONFIG 0xD5 #define ADM1272_MFR_ALERT2_CONFIG 0xD6 #define ADM1272_MFR_PEAK_TEMPERATURE 0xD7 #define ADM1272_MFR_DEVICE_CONFIG 0xD8 #define ADM1272_MFR_POWER_CYCLE 0xD9 #define ADM1272_MFR_PEAK_PIN 0xDA #define ADM1272_MFR_READ_PIN_EXT 0xDB #define ADM1272_MFR_READ_EIN_EXT 0xDC #define ADM1272_HYSTERESIS_LOW 0xF2 #define ADM1272_HYSTERESIS_HIGH 0xF3 #define ADM1272_STATUS_HYSTERESIS 0xF4 #define ADM1272_STATUS_GPIO 0xF5 #define ADM1272_STRT_UP_IOUT_LIM 0xF6 /* Defaults */ #define ADM1272_OPERATION_DEFAULT 0x80 #define ADM1272_CAPABILITY_DEFAULT 0xB0 #define ADM1272_CAPABILITY_NO_PEC 0x30 #define ADM1272_DIRECT_MODE 0x40 #define ADM1272_HIGH_LIMIT_DEFAULT 0x0FFF #define ADM1272_PIN_OP_DEFAULT 0x7FFF #define ADM1272_PMBUS_REVISION_DEFAULT 0x22 #define ADM1272_MFR_ID_DEFAULT "ADI" #define ADM1272_MODEL_DEFAULT "ADM1272-A1" #define ADM1272_MFR_DEFAULT_REVISION "25" #define ADM1272_DEFAULT_DATE "160301" #define ADM1272_RESTART_TIME_DEFAULT 0x64 #define ADM1272_PMON_CONTROL_DEFAULT 0x1 #define ADM1272_PMON_CONFIG_DEFAULT 0x3F35 #define ADM1272_DEVICE_CONFIG_DEFAULT 0x8 #define ADM1272_HYSTERESIS_HIGH_DEFAULT 0xFFFF #define ADM1272_STRT_UP_IOUT_LIM_DEFAULT 0x000F #define ADM1272_VOLT_DEFAULT 12000 #define ADM1272_IOUT_DEFAULT 25000 #define ADM1272_PWR_DEFAULT 300 /* 12V 25A */ #define ADM1272_SHUNT 300 /* micro-ohms */ #define ADM1272_VOLTAGE_COEFF_DEFAULT 1 #define ADM1272_CURRENT_COEFF_DEFAULT 3 #define ADM1272_PWR_COEFF_DEFAULT 7 #define ADM1272_IOUT_OFFSET 0x5000 #define ADM1272_IOUT_OFFSET 0x5000 typedef struct ADM1272State { PMBusDevice parent; uint64_t ein_ext; uint32_t pin_ext; uint8_t restart_time; uint16_t peak_vin; uint16_t peak_vout; uint16_t peak_iout; uint16_t peak_temperature; uint16_t peak_pin; uint8_t pmon_control; uint16_t pmon_config; uint16_t alert1_config; uint16_t alert2_config; uint16_t device_config; uint16_t hysteresis_low; uint16_t hysteresis_high; uint8_t status_hysteresis; uint8_t status_gpio; uint16_t strt_up_iout_lim; } ADM1272State; static const PMBusCoefficients adm1272_coefficients[] = { [0] = { 6770, 0, -2 }, /* voltage, vrange 60V */ [1] = { 4062, 0, -2 }, /* voltage, vrange 100V */ [2] = { 1326, 20480, -1 }, /* current, vsense range 15mV */ [3] = { 663, 20480, -1 }, /* current, vsense range 30mV */ [4] = { 3512, 0, -2 }, /* power, vrange 60V, irange 15mV */ [5] = { 21071, 0, -3 }, /* power, vrange 100V, irange 15mV */ [6] = { 17561, 0, -3 }, /* power, vrange 60V, irange 30mV */ [7] = { 10535, 0, -3 }, /* power, vrange 100V, irange 30mV */ [8] = { 42, 31871, -1 }, /* temperature */ }; static void adm1272_check_limits(ADM1272State *s) { PMBusDevice *pmdev = PMBUS_DEVICE(s); pmbus_check_limits(pmdev); if (pmdev->pages[0].read_vout > s->peak_vout) { s->peak_vout = pmdev->pages[0].read_vout; } if (pmdev->pages[0].read_vin > s->peak_vin) { s->peak_vin = pmdev->pages[0].read_vin; } if (pmdev->pages[0].read_iout > s->peak_iout) { s->peak_iout = pmdev->pages[0].read_iout; } if (pmdev->pages[0].read_temperature_1 > s->peak_temperature) { s->peak_temperature = pmdev->pages[0].read_temperature_1; } if (pmdev->pages[0].read_pin > s->peak_pin) { s->peak_pin = pmdev->pages[0].read_pin; } } static uint16_t adm1272_millivolts_to_direct(uint32_t value) { PMBusCoefficients c = adm1272_coefficients[ADM1272_VOLTAGE_COEFF_DEFAULT]; c.b = c.b * 1000; c.R = c.R - 3; return pmbus_data2direct_mode(c, value); } static uint32_t adm1272_direct_to_millivolts(uint16_t value) { PMBusCoefficients c = adm1272_coefficients[ADM1272_VOLTAGE_COEFF_DEFAULT]; c.b = c.b * 1000; c.R = c.R - 3; return pmbus_direct_mode2data(c, value); } static uint16_t adm1272_milliamps_to_direct(uint32_t value) { PMBusCoefficients c = adm1272_coefficients[ADM1272_CURRENT_COEFF_DEFAULT]; /* Y = (m * r_sense * x - b) * 10^R */ c.m = c.m * ADM1272_SHUNT / 1000; /* micro-ohms */ c.b = c.b * 1000; c.R = c.R - 3; return pmbus_data2direct_mode(c, value); } static uint32_t adm1272_direct_to_milliamps(uint16_t value) { PMBusCoefficients c = adm1272_coefficients[ADM1272_CURRENT_COEFF_DEFAULT]; c.m = c.m * ADM1272_SHUNT / 1000; c.b = c.b * 1000; c.R = c.R - 3; return pmbus_direct_mode2data(c, value); } static uint16_t adm1272_watts_to_direct(uint32_t value) { PMBusCoefficients c = adm1272_coefficients[ADM1272_PWR_COEFF_DEFAULT]; c.m = c.m * ADM1272_SHUNT / 1000; return pmbus_data2direct_mode(c, value); } static uint32_t adm1272_direct_to_watts(uint16_t value) { PMBusCoefficients c = adm1272_coefficients[ADM1272_PWR_COEFF_DEFAULT]; c.m = c.m * ADM1272_SHUNT / 1000; return pmbus_direct_mode2data(c, value); } static void adm1272_exit_reset(Object *obj) { ADM1272State *s = ADM1272(obj); PMBusDevice *pmdev = PMBUS_DEVICE(obj); pmdev->page = 0; pmdev->pages[0].operation = ADM1272_OPERATION_DEFAULT; pmdev->capability = ADM1272_CAPABILITY_NO_PEC; pmdev->pages[0].revision = ADM1272_PMBUS_REVISION_DEFAULT; pmdev->pages[0].vout_mode = ADM1272_DIRECT_MODE; pmdev->pages[0].vout_ov_warn_limit = ADM1272_HIGH_LIMIT_DEFAULT; pmdev->pages[0].vout_uv_warn_limit = 0; pmdev->pages[0].iout_oc_warn_limit = ADM1272_HIGH_LIMIT_DEFAULT; pmdev->pages[0].ot_fault_limit = ADM1272_HIGH_LIMIT_DEFAULT; pmdev->pages[0].ot_warn_limit = ADM1272_HIGH_LIMIT_DEFAULT; pmdev->pages[0].vin_ov_warn_limit = ADM1272_HIGH_LIMIT_DEFAULT; pmdev->pages[0].vin_uv_warn_limit = 0; pmdev->pages[0].pin_op_warn_limit = ADM1272_PIN_OP_DEFAULT; pmdev->pages[0].status_word = 0; pmdev->pages[0].status_vout = 0; pmdev->pages[0].status_iout = 0; pmdev->pages[0].status_input = 0; pmdev->pages[0].status_temperature = 0; pmdev->pages[0].status_mfr_specific = 0; pmdev->pages[0].read_vin = adm1272_millivolts_to_direct(ADM1272_VOLT_DEFAULT); pmdev->pages[0].read_vout = adm1272_millivolts_to_direct(ADM1272_VOLT_DEFAULT); pmdev->pages[0].read_iout = adm1272_milliamps_to_direct(ADM1272_IOUT_DEFAULT); pmdev->pages[0].read_temperature_1 = 0; pmdev->pages[0].read_pin = adm1272_watts_to_direct(ADM1272_PWR_DEFAULT); pmdev->pages[0].revision = ADM1272_PMBUS_REVISION_DEFAULT; pmdev->pages[0].mfr_id = ADM1272_MFR_ID_DEFAULT; pmdev->pages[0].mfr_model = ADM1272_MODEL_DEFAULT; pmdev->pages[0].mfr_revision = ADM1272_MFR_DEFAULT_REVISION; pmdev->pages[0].mfr_date = ADM1272_DEFAULT_DATE; s->pin_ext = 0; s->ein_ext = 0; s->restart_time = ADM1272_RESTART_TIME_DEFAULT; s->peak_vin = 0; s->peak_vout = 0; s->peak_iout = 0; s->peak_temperature = 0; s->peak_pin = 0; s->pmon_control = ADM1272_PMON_CONTROL_DEFAULT; s->pmon_config = ADM1272_PMON_CONFIG_DEFAULT; s->alert1_config = 0; s->alert2_config = 0; s->device_config = ADM1272_DEVICE_CONFIG_DEFAULT; s->hysteresis_low = 0; s->hysteresis_high = ADM1272_HYSTERESIS_HIGH_DEFAULT; s->status_hysteresis = 0; s->status_gpio = 0; s->strt_up_iout_lim = ADM1272_STRT_UP_IOUT_LIM_DEFAULT; } static uint8_t adm1272_read_byte(PMBusDevice *pmdev) { ADM1272State *s = ADM1272(pmdev); switch (pmdev->code) { case ADM1272_RESTART_TIME: pmbus_send8(pmdev, s->restart_time); break; case ADM1272_MFR_PEAK_IOUT: pmbus_send16(pmdev, s->peak_iout); break; case ADM1272_MFR_PEAK_VIN: pmbus_send16(pmdev, s->peak_vin); break; case ADM1272_MFR_PEAK_VOUT: pmbus_send16(pmdev, s->peak_vout); break; case ADM1272_MFR_PMON_CONTROL: pmbus_send8(pmdev, s->pmon_control); break; case ADM1272_MFR_PMON_CONFIG: pmbus_send16(pmdev, s->pmon_config); break; case ADM1272_MFR_ALERT1_CONFIG: pmbus_send16(pmdev, s->alert1_config); break; case ADM1272_MFR_ALERT2_CONFIG: pmbus_send16(pmdev, s->alert2_config); break; case ADM1272_MFR_PEAK_TEMPERATURE: pmbus_send16(pmdev, s->peak_temperature); break; case ADM1272_MFR_DEVICE_CONFIG: pmbus_send16(pmdev, s->device_config); break; case ADM1272_MFR_PEAK_PIN: pmbus_send16(pmdev, s->peak_pin); break; case ADM1272_MFR_READ_PIN_EXT: pmbus_send32(pmdev, s->pin_ext); break; case ADM1272_MFR_READ_EIN_EXT: pmbus_send64(pmdev, s->ein_ext); break; case ADM1272_HYSTERESIS_LOW: pmbus_send16(pmdev, s->hysteresis_low); break; case ADM1272_HYSTERESIS_HIGH: pmbus_send16(pmdev, s->hysteresis_high); break; case ADM1272_STATUS_HYSTERESIS: pmbus_send16(pmdev, s->status_hysteresis); break; case ADM1272_STATUS_GPIO: pmbus_send16(pmdev, s->status_gpio); break; case ADM1272_STRT_UP_IOUT_LIM: pmbus_send16(pmdev, s->strt_up_iout_lim); break; default: qemu_log_mask(LOG_GUEST_ERROR, "%s: reading from unsupported register: 0x%02x\n", __func__, pmdev->code); return 0xFF; break; } return 0; } static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf, uint8_t len) { ADM1272State *s = ADM1272(pmdev); if (len == 0) { qemu_log_mask(LOG_GUEST_ERROR, "%s: writing empty data\n", __func__); return -1; } pmdev->code = buf[0]; /* PMBus command code */ if (len == 1) { return 0; } /* Exclude command code from buffer */ buf++; len--; switch (pmdev->code) { case ADM1272_RESTART_TIME: s->restart_time = pmbus_receive8(pmdev); break; case ADM1272_MFR_PMON_CONTROL: s->pmon_control = pmbus_receive8(pmdev); break; case ADM1272_MFR_PMON_CONFIG: s->pmon_config = pmbus_receive16(pmdev); break; case ADM1272_MFR_ALERT1_CONFIG: s->alert1_config = pmbus_receive16(pmdev); break; case ADM1272_MFR_ALERT2_CONFIG: s->alert2_config = pmbus_receive16(pmdev); break; case ADM1272_MFR_DEVICE_CONFIG: s->device_config = pmbus_receive16(pmdev); break; case ADM1272_MFR_POWER_CYCLE: adm1272_exit_reset((Object *)s); break; case ADM1272_HYSTERESIS_LOW: s->hysteresis_low = pmbus_receive16(pmdev); break; case ADM1272_HYSTERESIS_HIGH: s->hysteresis_high = pmbus_receive16(pmdev); break; case ADM1272_STRT_UP_IOUT_LIM: s->strt_up_iout_lim = pmbus_receive16(pmdev); adm1272_check_limits(s); break; default: qemu_log_mask(LOG_GUEST_ERROR, "%s: writing to unsupported register: 0x%02x\n", __func__, pmdev->code); break; } return 0; } static void adm1272_get(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { uint16_t value; if (strcmp(name, "vin") == 0 || strcmp(name, "vout") == 0) { value = adm1272_direct_to_millivolts(*(uint16_t *)opaque); } else if (strcmp(name, "iout") == 0) { value = adm1272_direct_to_milliamps(*(uint16_t *)opaque); } else if (strcmp(name, "pin") == 0) { value = adm1272_direct_to_watts(*(uint16_t *)opaque); } else { value = *(uint16_t *)opaque; } visit_type_uint16(v, name, &value, errp); } static void adm1272_set(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { ADM1272State *s = ADM1272(obj); uint16_t *internal = opaque; uint16_t value; if (!visit_type_uint16(v, name, &value, errp)) { return; } if (strcmp(name, "vin") == 0 || strcmp(name, "vout") == 0) { *internal = adm1272_millivolts_to_direct(value); } else if (strcmp(name, "iout") == 0) { *internal = adm1272_milliamps_to_direct(value); } else if (strcmp(name, "pin") == 0) { *internal = adm1272_watts_to_direct(value); } else { *internal = value; } adm1272_check_limits(s); } static const VMStateDescription vmstate_adm1272 = { .name = "ADM1272", .version_id = 0, .minimum_version_id = 0, .fields = (VMStateField[]){ VMSTATE_PMBUS_DEVICE(parent, ADM1272State), VMSTATE_UINT64(ein_ext, ADM1272State), VMSTATE_UINT32(pin_ext, ADM1272State), VMSTATE_UINT8(restart_time, ADM1272State), VMSTATE_UINT16(peak_vin, ADM1272State), VMSTATE_UINT16(peak_vout, ADM1272State), VMSTATE_UINT16(peak_iout, ADM1272State), VMSTATE_UINT16(peak_temperature, ADM1272State), VMSTATE_UINT16(peak_pin, ADM1272State), VMSTATE_UINT8(pmon_control, ADM1272State), VMSTATE_UINT16(pmon_config, ADM1272State), VMSTATE_UINT16(alert1_config, ADM1272State), VMSTATE_UINT16(alert2_config, ADM1272State), VMSTATE_UINT16(device_config, ADM1272State), VMSTATE_UINT16(hysteresis_low, ADM1272State), VMSTATE_UINT16(hysteresis_high, ADM1272State), VMSTATE_UINT8(status_hysteresis, ADM1272State), VMSTATE_UINT8(status_gpio, ADM1272State), VMSTATE_UINT16(strt_up_iout_lim, ADM1272State), VMSTATE_END_OF_LIST() } }; static void adm1272_init(Object *obj) { PMBusDevice *pmdev = PMBUS_DEVICE(obj); uint64_t flags = PB_HAS_VOUT_MODE | PB_HAS_VOUT | PB_HAS_VIN | PB_HAS_IOUT | PB_HAS_PIN | PB_HAS_TEMPERATURE | PB_HAS_MFR_INFO; pmbus_page_config(pmdev, 0, flags); object_property_add(obj, "vin", "uint16", adm1272_get, adm1272_set, NULL, &pmdev->pages[0].read_vin); object_property_add(obj, "vout", "uint16", adm1272_get, adm1272_set, NULL, &pmdev->pages[0].read_vout); object_property_add(obj, "iout", "uint16", adm1272_get, adm1272_set, NULL, &pmdev->pages[0].read_iout); object_property_add(obj, "pin", "uint16", adm1272_get, adm1272_set, NULL, &pmdev->pages[0].read_pin); } static void adm1272_class_init(ObjectClass *klass, void *data) { ResettableClass *rc = RESETTABLE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass); dc->desc = "Analog Devices ADM1272 Hot Swap controller"; dc->vmsd = &vmstate_adm1272; k->write_data = adm1272_write_data; k->receive_byte = adm1272_read_byte; k->device_num_pages = 1; rc->phases.exit = adm1272_exit_reset; } static const TypeInfo adm1272_info = { .name = TYPE_ADM1272, .parent = TYPE_PMBUS_DEVICE, .instance_size = sizeof(ADM1272State), .instance_init = adm1272_init, .class_init = adm1272_class_init, }; static void adm1272_register_types(void) { type_register_static(&adm1272_info); } type_init(adm1272_register_types)
/* Display the current game state to the user. */ int drawscreen(int index) { return displaygame(state.map, state.game->ysize, state.game->xsize, state.game->seriesname, state.game->name, index + 1, state.game->colors, state.currblock, state.ycurrpos, state.xcurrpos, !!stack, state.movecount, state.stepcount, state.game->beststepcount, state.game->answer.count, state.game->beststepknown); }
/******************************************************************/ /* wimax_security_negotiation_parameters_decoder() */ /* decode and display the WiMax Security Negotiation Parameters */ /* parameter: */ /* tvb - pointer of the tvb of service flow encodings */ /* tree - pointer of Wireshark display tree */ /* pinfo - pointer of Wireshark packet information structure */ /******************************************************************/ void wimax_security_negotiation_parameters_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset; guint tvb_len, tlv_len, tlv_value_offset; gint tlv_type; proto_tree *tlv_tree; proto_item *tlv_item; tlv_info_t tlv_info; tvb_len = tvb_reported_length(tvb); if(!tvb_len) return; if(tvb_len < 2) { col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Security Negotiation Parameters"); return; } for(offset = 0; offset < tvb_len; ) { init_tlv_info(&tlv_info, tvb, offset); tlv_type = get_tlv_type(&tlv_info); tlv_len = get_tlv_length(&tlv_info); if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1) { col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Security Negotiation Params TLV error"); proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA); break; } tlv_value_offset = get_tlv_value_offset(&tlv_info); #ifdef DEBUG proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Security Negotiation Parameters Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len); #endif offset += tlv_value_offset; switch (tlv_type) { case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_PKM_VERSION_SUPPORT: tlv_item = add_tlv_subtree(&tlv_info, tree, hf_snp_pkm_version_support, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); tlv_tree = proto_item_add_subtree(tlv_item, ett_security_negotiation_parameters); proto_tree_add_item(tlv_tree, hf_snp_pkm_version_support_bit0, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_pkm_version_support_bit1, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_pkm_version_support_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); break; case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_AUTHORIZATION_POLICY_SUPPORT: tlv_item = add_tlv_subtree(&tlv_info, tree, hf_snp_auth_policy_support, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); tlv_tree = proto_item_add_subtree(tlv_item, ett_security_negotiation_parameters); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit0, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit1, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit2, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit3, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit4, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit5, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit6, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit7, tvb, offset, 1, ENC_BIG_ENDIAN); break; case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_MESSAGE_AUTHENTICATION_CODE: tlv_item = add_tlv_subtree(&tlv_info, tree, hf_snp_mac_mode, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); tlv_tree = proto_item_add_subtree(tlv_item, ett_security_negotiation_parameters); proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit0, tvb, offset, 1, ENC_BIG_ENDIAN); if (include_cor2_changes) { proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit1_rsvd, tvb, offset, 1, ENC_BIG_ENDIAN); } else { proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit1, tvb, offset, 1, ENC_BIG_ENDIAN); } proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit2, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit3, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit4, tvb, offset, 1, ENC_BIG_ENDIAN); if (include_cor2_changes) { proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit5, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_snp_mac_mode_reserved1, tvb, offset, 1, ENC_BIG_ENDIAN); } else { proto_tree_add_item(tlv_tree, hf_snp_mac_mode_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); } break; case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_PN_WINDOW_SIZE: add_tlv_subtree(&tlv_info, tree, hf_snp_pn_window_size, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); break; case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_PKM_FLOW_CONTROL: add_tlv_subtree(&tlv_info, tree, hf_snp_max_conc_transactions, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); break; case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_MAX_SUPPT_SECURITY_ASSNS: add_tlv_subtree(&tlv_info, tree, hf_snp_max_suppt_sec_assns, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); break; default: add_tlv_subtree(&tlv_info, tree, hf_snp_unknown_type, tvb, offset-tlv_value_offset, ENC_NA); break; } offset += tlv_len; } }
/*! * This function configures input path. * * @param input index of input select register as defined in \b * #iomux_input_select_t * @param config the binary value of elements defined in \b * #iomux_input_config_t */ void mxc_iomux_set_input(iomux_input_select_t input, u32 config) { void *reg = IOMUXSW_INPUT_CTL + (input << 2); BUG_ON(input >= MUX_INPUT_NUM_MUX); __raw_writel(config, reg); }
/* Check if the number of available inputs/outputs for a pin class is sufficient for speculatively packed blocks */ static boolean check_lookahead_pins_used(t_pb *cur_pb) { int i, j; int ipin; const t_pb_type *pb_type = cur_pb->pb_graph_node->pb_type; boolean success; success = TRUE; if (pb_type->num_modes > 0 && cur_pb->name != NULL) { for (i = 0; i < cur_pb->pb_graph_node->num_input_pin_class && success; i++) { ipin = 0; for (j = 0; j < cur_pb->pb_graph_node->input_pin_class_size[i] * AAPACK_MAX_OVERUSE_LOOKAHEAD_PINS_FAC + AAPACK_MAX_OVERUSE_LOOKAHEAD_PINS_CONST; j++) { if (cur_pb->pb_stats->lookahead_input_pins_used[i][j] != OPEN) { ipin++; } } if (ipin > cur_pb->pb_graph_node->input_pin_class_size[i]) { success = FALSE; } } for (i = 0; i < cur_pb->pb_graph_node->num_output_pin_class && success; i++) { ipin = 0; for (j = 0; j < cur_pb->pb_graph_node->output_pin_class_size[i] * AAPACK_MAX_OVERUSE_LOOKAHEAD_PINS_FAC + AAPACK_MAX_OVERUSE_LOOKAHEAD_PINS_CONST; j++) { if (cur_pb->pb_stats->lookahead_output_pins_used[i][j] != OPEN) { ipin++; } } if (ipin > cur_pb->pb_graph_node->output_pin_class_size[i]) { success = FALSE; } } if (success && cur_pb->child_pbs != NULL) { for (i = 0; success && i < pb_type->modes[cur_pb->mode].num_pb_type_children; i++) { if (cur_pb->child_pbs[i] != NULL) { for (j = 0; success && j < pb_type->modes[cur_pb->mode].pb_type_children[i].num_pb; j++) { success = check_lookahead_pins_used( &cur_pb->child_pbs[i][j]); } } } } } return success; }
/** * @brief The core state machine of this sample application. * @param event The event that triggered the call of AppStateManager. */ void AppStateManager(EVENT_APP event) { DPRINTF("AppStateManager St: %d, Ev: 0x%02x\r\n", currentState, event); notAppStateDependentActivity(event); switch(currentState) { case STATE_APP_STARTUP: if(EVENT_APP_FLUSHMEM_READY == event) { AppResetNvm(); } if (EVENT_APP_INIT == event) { doRemainingInitialization(); break; } ChangeState(STATE_APP_IDLE); break; case STATE_APP_IDLE: if(EVENT_APP_FLUSHMEM_READY == event) { AppResetNvm(); LoadConfiguration(); } if (EVENT_APP_SMARTSTART_IN_PROGRESS == event) { ChangeState(STATE_APP_LEARN_MODE); } if ((EVENT_APP_BUTTON_LEARN_RESET_SHORT_PRESS == event) || (EVENT_SYSTEM_LEARNMODE_START == (EVENT_SYSTEM)event)) { if (EINCLUSIONSTATE_EXCLUDED != g_pAppHandles->pNetworkInfo->eInclusionState){ DPRINT("\r\nLEARN_MODE_EXCLUSION"); ZAF_setNetworkLearnMode(E_NETWORK_LEARN_MODE_EXCLUSION_NWE); } else{ DPRINT("\r\nLEARN_MODE_INCLUSION"); ZAF_setNetworkLearnMode(E_NETWORK_LEARN_MODE_INCLUSION); } Board_IndicateStatus(BOARD_STATUS_LEARNMODE_ACTIVE); ChangeState(STATE_APP_LEARN_MODE); } if (EVENT_APP_TRANSITION_TO_ACTIVE == event) { zpal_pm_stay_awake(radio_power_lock, 0); DPRINT("\r\n"); DPRINT("\r\n *!*!**!*!**!*!**!*!**!*!**!*!**!*!**!*!*"); DPRINT("\r\n *!*!* PIR EVENT ACTIVE *!*!*"); DPRINT("\r\n *!*!**!*!**!*!**!*!**!*!**!*!**!*!**!*!*"); DPRINT("\r\n"); ChangeState(STATE_APP_TRANSMIT_DATA); if (false == ZAF_EventHelperEventEnqueue(EVENT_APP_NEXT_EVENT_JOB)) { DPRINT("\r\n** EVENT_APP_NEXT_EVENT_JOB fail\r\n"); } ZAF_JobHelperJobEnqueue(EVENT_APP_BASIC_START_JOB); ZAF_JobHelperJobEnqueue(EVENT_APP_NOTIFICATION_START_JOB); ZAF_JobHelperJobEnqueue(EVENT_APP_START_TIMER_EVENTJOB_STOP); } if (EVENT_APP_BUTTON_BATTERY_REPORT == event) { DPRINT("\r\nBattery Level report transmit (keypress trig)\r\n"); ChangeState(STATE_APP_TRANSMIT_DATA); if (false == ZAF_EventHelperEventEnqueue(EVENT_APP_NEXT_EVENT_JOB)) { DPRINT("\r\n** EVENT_APP_NEXT_EVENT_JOB fail\r\n"); } ZAF_JobHelperJobEnqueue(EVENT_APP_SEND_BATTERY_LEVEL_REPORT); } break; case STATE_APP_LEARN_MODE: if(EVENT_APP_FLUSHMEM_READY == event) { AppResetNvm(); LoadConfiguration(); } if ((EVENT_APP_BUTTON_LEARN_RESET_SHORT_PRESS == event) || (EVENT_SYSTEM_LEARNMODE_STOP == (EVENT_SYSTEM)event)) { ZAF_setNetworkLearnMode(E_NETWORK_LEARN_MODE_DISABLE); ZAF_setNetworkLearnMode(E_NETWORK_LEARN_MODE_INCLUSION_SMARTSTART); Board_IndicateStatus(BOARD_STATUS_IDLE); ChangeState(STATE_APP_IDLE); if (!Board_IsIndicatorActive()) { CC_Indicator_RefreshIndicatorProperties(); } ZAF_TSE_Trigger(CC_Indicator_report_stx, (void *)&ZAF_TSE_localActuationIdentifyData, true); } if (EVENT_SYSTEM_LEARNMODE_FINISHED == (EVENT_SYSTEM)event) { CC_WakeUp_stayAwake10s(); CC_WakeUp_AutoStayAwakeAfterInclusion(); ZAF_setNetworkLearnMode(E_NETWORK_LEARN_MODE_INCLUSION_SMARTSTART); Board_IndicateStatus(BOARD_STATUS_IDLE); ChangeState(STATE_APP_IDLE); if (!Board_IsIndicatorActive()) { CC_Indicator_RefreshIndicatorProperties(); } ZAF_TSE_Trigger(CC_Indicator_report_stx, (void *)&ZAF_TSE_localActuationIdentifyData, true); if (EINCLUSIONSTATE_EXCLUDED != g_pAppHandles->pNetworkInfo->eInclusionState) { CC_WakeUp_startWakeUpNotificationTimer(); } } break; case STATE_APP_RESET: if(EVENT_APP_FLUSHMEM_READY == event) { AppResetNvm(); zpal_reboot(); } break; case STATE_APP_POWERDOWN: break; case STATE_APP_TRANSMIT_DATA: if(EVENT_APP_FLUSHMEM_READY == event) { AppResetNvm(); LoadConfiguration(); } if (EVENT_APP_NEXT_EVENT_JOB == event) { uint8_t event; if (true == ZAF_JobHelperJobDequeue(&event)) { ZAF_EventHelperEventEnqueue(event); } else { DPRINT(" Enqueuing event: EVENT_APP_FINISH_EVENT_JOB"); ZAF_EventHelperEventEnqueue(EVENT_APP_FINISH_EVENT_JOB); } } if (EVENT_APP_BASIC_START_JOB == event) { if (JOB_STATUS_SUCCESS != CC_Basic_Set_tx( &agiTableRootDeviceGroups[0].profile, ENDPOINT_ROOT, BASIC_SET_TRIGGER_VALUE, ZCB_JobStatus)) { DPRINT("\r\nEVENT_APP_BASIC_START_JOB failed"); basicValue = BASIC_SET_TRIGGER_VALUE; ZAF_EventHelperEventEnqueue(EVENT_APP_NEXT_EVENT_JOB); } } if (EVENT_APP_BASIC_STOP_JOB == event) { if (JOB_STATUS_SUCCESS != CC_Basic_Set_tx( &agiTableRootDeviceGroups[0].profile, ENDPOINT_ROOT, 0, ZCB_JobStatus)) { DPRINT("\r\nEVENT_APP_BASIC_STOP_JOB failed"); basicValue = 0; ZAF_EventHelperEventEnqueue(EVENT_APP_NEXT_EVENT_JOB); } } if (EVENT_APP_NOTIFICATION_START_JOB == event) { DPRINT("\r\nEVENT_APP_NOTIFICATION_START_JOB"); NotificationEventTrigger(&lifelineProfile, NOTIFICATION_TYPE_HOME_SECURITY, supportedEvents, NULL, 0, ENDPOINT_ROOT); if (JOB_STATUS_SUCCESS != UnsolicitedNotificationAction(&lifelineProfile, ENDPOINT_ROOT, ZCB_JobStatus)) { ZAF_EventHelperEventEnqueue(EVENT_APP_NEXT_EVENT_JOB); } } if (EVENT_APP_NOTIFICATION_STOP_JOB == event) { DPRINT("\r\nEVENT_APP_NOTIFICATION_STOP_JOB"); NotificationEventTrigger(&lifelineProfile, NOTIFICATION_TYPE_HOME_SECURITY, 0, &supportedEvents, 1, ENDPOINT_ROOT); if (JOB_STATUS_SUCCESS != UnsolicitedNotificationAction(&lifelineProfile, ENDPOINT_ROOT, ZCB_JobStatus)) { ZAF_EventHelperEventEnqueue(EVENT_APP_NEXT_EVENT_JOB); } } if (EVENT_APP_START_TIMER_EVENTJOB_STOP== event) { DPRINT("\r\n#EVENT_APP_START_TIMER_EVENTJOB_STOP\r\n"); AppTimerDeepSleepPersistentStart(&EventJobsTimer, BASIC_SET_TIMEOUT); } if (EVENT_APP_SEND_BATTERY_LEVEL_REPORT == event) { ReportBatteryLevel(); } if (EVENT_APP_FINISH_EVENT_JOB == event) { ChangeState(STATE_APP_IDLE); } DPRINTF("\r\nSTATE_APP_TRANSMIT_DATA done (state: %d)", currentState); break; default: DPRINT("\r\nAppStateHandler(): Case is not handled!!!"); break; } }
/* This file has been autogenerated by Ivory * Compiler version 0.1.0.2 */ #ifndef __SEQUENCE_NUMBERED_CONTROL_LAW_TYPES_H__ #define __SEQUENCE_NUMBERED_CONTROL_LAW_TYPES_H__ #ifdef __cplusplus extern "C" { #endif #include "control_law_types.h" #include "ivory.h" #include "ivory_serialize.h" #include "sequence_num_types.h" typedef struct sequence_numbered_control_law { uint32_t seqnum; struct control_law val; } sequence_numbered_control_law; void sequence_numbered_control_law_get_le (const uint8_t * n_var0, uint32_t n_var1, struct sequence_numbered_control_law * n_var2); void sequence_numbered_control_law_get_be (const uint8_t * n_var0, uint32_t n_var1, struct sequence_numbered_control_law * n_var2); void sequence_numbered_control_law_set_le (uint8_t * n_var0, uint32_t n_var1, const struct sequence_numbered_control_law * n_var2); void sequence_numbered_control_law_set_be (uint8_t * n_var0, uint32_t n_var1, const struct sequence_numbered_control_law * n_var2); #ifdef __cplusplus } #endif #endif /* __SEQUENCE_NUMBERED_CONTROL_LAW_TYPES_H__ */
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_MISC_IMAGE_H #define EIGEN_MISC_IMAGE_H namespace Eigen { namespace internal { /** \class image_retval_base * */ template<typename DecompositionType> struct traits<image_retval_base<DecompositionType> > { typedef typename DecompositionType::MatrixType MatrixType; typedef Matrix< typename MatrixType::Scalar, MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose // dimension is the number of rows of the original matrix Dynamic, // we don't know at compile time the dimension of the image (the rank) MatrixType::Options, MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix, MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns. > ReturnType; }; template<typename _DecompositionType> struct image_retval_base : public ReturnByValue<image_retval_base<_DecompositionType> > { typedef _DecompositionType DecompositionType; typedef typename DecompositionType::MatrixType MatrixType; typedef ReturnByValue<image_retval_base> Base; image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) : m_dec(dec), m_rank(dec.rank()), m_cols(m_rank == 0 ? 1 : m_rank), m_originalMatrix(originalMatrix) {} inline Index rows() const { return m_dec.rows(); } inline Index cols() const { return m_cols; } inline Index rank() const { return m_rank; } inline const DecompositionType& dec() const { return m_dec; } inline const MatrixType& originalMatrix() const { return m_originalMatrix; } template<typename Dest> inline void evalTo(Dest& dst) const { static_cast<const image_retval<DecompositionType>*>(this)->evalTo(dst); } protected: const DecompositionType& m_dec; Index m_rank, m_cols; const MatrixType& m_originalMatrix; }; } // end namespace internal #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ typedef typename DecompositionType::MatrixType MatrixType; \ typedef typename MatrixType::Scalar Scalar; \ typedef typename MatrixType::RealScalar RealScalar; \ typedef Eigen::internal::image_retval_base<DecompositionType> Base; \ using Base::dec; \ using Base::originalMatrix; \ using Base::rank; \ using Base::rows; \ using Base::cols; \ image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ : Base(dec, originalMatrix) {} } // end namespace Eigen #endif // EIGEN_MISC_IMAGE_H
/* * Expand explanation for literal l * - l was implied with expl as antecedent * - expl is a null-terminated array of literals stored in the arena. * - v = vector where the explanation is to be added */ void rdl_expand_explanation(rdl_solver_t *solver, literal_t l, literal_t *expl, ivector_t *v) { literal_t x; for (;;) { x = *expl ++; if (x == null_literal) break; ivector_push(v, x); } }
// Searching Global/Local Variable types // If the variable is local, that returns 1 // If the variable is global, that returns 2 static int find_var_types(char *str) { if (map_find(var_types, str)) return 1; if (map_find(gvar_types, str)) return 2; return 0; }
/* * Create special expldev for ZFS private use. * Can't use standard expldev since it doesn't do * what we want. The standard expldev() takes a * dev32_t in LP64 and expands it to a long dev_t. * We need an interface that takes a dev32_t in ILP32 * and expands it to a long dev_t. */ static uint64_t zfs_expldev(dev_t dev) { return (((uint64_t)major(dev) << NBITSMINOR64) | minor(dev)); }
/** * @brief Add additional data to instance information * * We are leaking some additional data to the module instances to help modules * making decissions about reasonable behavior and values. * * @param db database entry * @param mi instance data buffer */ static void rat_rad_fill_mi_additional (struct rat_db *db, struct rat_mod_instance *mi) { if (!db || !mi) goto exit; mi->mi_maxadvint = db->db_maxadvint; switch (db->db_state) { case RAT_DB_STATE_FADEOUT1: case RAT_DB_STATE_FADEOUT2: case RAT_DB_STATE_FADEOUT3: mi->mi_fadingout = 1; break; default: mi->mi_fadingout = 0; break; } mi->mi_mtu = db->db_mtu; memcpy(&mi->mi_hwaddr, &db->db_hwaddr, sizeof(mi->mi_hwaddr)); exit: return; }
/* Private: Allocate memory to store list item pointers. * * this - The list to resize. * capacity - The number of items to accomodate in the list. * * Returns false if memory allocation failed. */ bool vector_resize(struct vector *this, size_t capacity) { void **items = realloc(this->items, capacity * sizeof(void *)); if (!items) { return false; } this->items = items; this->capacity = capacity; return true; }
/// All init_omap3_gpn functions end up here. int init_omap3_gptimer(size_t n, inthandler_t irqhandler) { assert(n < sizeof gptimer_phys); if(n > 0) { per_clocksel(n, CLOCK_SYS); per_funcclock(n, 1); per_ifaceclock(n, 1); } gptimer[n] = (volatile uint32_t *) mmiopool_alloc(PAGE_SIZE, gptimer_phys[n]); uint8_t rev = gptimer[n][TIDR] & 0xFF; dprintf("ARMv7 OMAP3 GP Timer %d Revision %d.%d\n", n, (rev >> 4), (rev & 0xF)); gptimer[n][TIOCP_CFG] = 0x2; gptimer[n][TSICR] = 0x2; while((gptimer[n][TISTAT] & 1) == 0); if(n > 0) { per_clocksel(n, CLOCK_32K); } gptimer[n][TPIR] = 232000; gptimer[n][TNIR] = (uint32_t) -768000; gptimer[n][TLDR] = 0xFFFFFFE0; gptimer[n][TTGR] = 1; gptimer[n][TISR] = 0x7; interrupts_irq_reg(37 + (int) n, 1, irqhandler, 0); gptimer[n][TIER] = 0x2; gptimer[n][TCLR] = 0x3; return 0; }
/* Table 198 - Definition of TPM2B_NV_PUBLIC Structure */ TPM_RC TSS_TPM2B_NV_PUBLIC_Marshalu(const TPM2B_NV_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size) { TPM_RC rc = 0; uint16_t sizeWritten = 0; BYTE *sizePtr; if (buffer != NULL) { sizePtr = *buffer; *buffer += sizeof(uint16_t); } if (rc == 0) { rc = TSS_TPMS_NV_PUBLIC_Marshalu(&source->nvPublic, &sizeWritten, buffer, size); } if (rc == 0) { *written += sizeWritten; if (buffer != NULL) { rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size); } else { *written += sizeof(uint16_t); } } return rc; }
/* * Check if an incoming request is "ok" * * It takes packets, not requests. It sees if the packet looks * OK. If so, it does a number of sanity checks on it. */ static int auth_socket_recv(rad_listen_t *listener, RAD_REQUEST_FUNP *pfun, REQUEST **prequest) { ssize_t rcode; int code, src_port; RADIUS_PACKET *packet; RAD_REQUEST_FUNP fun = NULL; RADCLIENT *client; fr_ipaddr_t src_ipaddr; rcode = rad_recv_header(listener->fd, &src_ipaddr, &src_port, &code); if (rcode < 0) return 0; RAD_STATS_TYPE_INC(listener, total_requests); if (rcode < 20) { RAD_STATS_TYPE_INC(listener, total_malformed_requests); return 0; } if ((client = client_listener_find(listener, &src_ipaddr, src_port)) == NULL) { rad_recv_discard(listener->fd); RAD_STATS_TYPE_INC(listener, total_invalid_requests); return 0; } switch(code) { case PW_AUTHENTICATION_REQUEST: RAD_STATS_CLIENT_INC(listener, client, total_requests); fun = rad_authenticate; break; case PW_STATUS_SERVER: if (!mainconfig.status_server) { rad_recv_discard(listener->fd); RAD_STATS_TYPE_INC(listener, total_packets_dropped); RAD_STATS_CLIENT_INC(listener, client, total_packets_dropped); DEBUG("WARNING: Ignoring Status-Server request due to security configuration"); return 0; } fun = rad_status_server; break; default: rad_recv_discard(listener->fd); RAD_STATS_INC(radius_auth_stats.total_unknown_types); RAD_STATS_CLIENT_INC(listener, client, total_unknown_types); DEBUG("Invalid packet code %d sent to authentication port from client %s port %d : IGNORED", code, client->shortname, src_port); return 0; break; } packet = rad_recv(listener->fd, client->message_authenticator); if (!packet) { RAD_STATS_TYPE_INC(listener, total_malformed_requests); DEBUG("%s", fr_strerror()); return 0; } if (!received_request(listener, packet, prequest, client)) { RAD_STATS_TYPE_INC(listener, total_packets_dropped); RAD_STATS_CLIENT_INC(listener, client, total_packets_dropped); rad_free(&packet); return 0; } *pfun = fun; return 1; }
/* (C) 2015 Pengutronix, Alexander Aring <aar@pengutronix.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Authors: * Alexander Aring <aar@pengutronix.de> * Eric Anholt <eric@anholt.net> */ #include <linux/module.h> #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> #include <dt-bindings/power/raspberrypi-power.h> #include <soc/bcm2835/raspberrypi-firmware.h> /* * Firmware indices for the old power domains interface. Only a few * of them were actually implemented. */ #define RPI_OLD_POWER_DOMAIN_USB 3 #define RPI_OLD_POWER_DOMAIN_V3D 10 struct rpi_power_domain { u32 domain; bool enabled; bool old_interface; struct generic_pm_domain base; struct rpi_firmware *fw; }; struct rpi_power_domains { bool has_new_interface; struct genpd_onecell_data xlate; struct rpi_firmware *fw; struct rpi_power_domain domains[RPI_POWER_DOMAIN_COUNT]; }; /* * Packet definition used by RPI_FIRMWARE_SET_POWER_STATE and * RPI_FIRMWARE_SET_DOMAIN_STATE */ struct rpi_power_domain_packet { u32 domain; u32 on; } __packet; /* * Asks the firmware to enable or disable power on a specific power * domain. */ static int rpi_firmware_set_power(struct rpi_power_domain *rpi_domain, bool on) { struct rpi_power_domain_packet packet; packet.domain = rpi_domain->domain; packet.on = on; return rpi_firmware_property(rpi_domain->fw, rpi_domain->old_interface ? RPI_FIRMWARE_SET_POWER_STATE : RPI_FIRMWARE_SET_DOMAIN_STATE, &packet, sizeof(packet)); } static int rpi_domain_off(struct generic_pm_domain *domain) { struct rpi_power_domain *rpi_domain = container_of(domain, struct rpi_power_domain, base); return rpi_firmware_set_power(rpi_domain, false); } static int rpi_domain_on(struct generic_pm_domain *domain) { struct rpi_power_domain *rpi_domain = container_of(domain, struct rpi_power_domain, base); return rpi_firmware_set_power(rpi_domain, true); } static void rpi_common_init_power_domain(struct rpi_power_domains *rpi_domains, int xlate_index, const char *name) { struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index]; dom->fw = rpi_domains->fw; dom->base.name = name; dom->base.power_on = rpi_domain_on; dom->base.power_off = rpi_domain_off; /* * Treat all power domains as off at boot. * * The firmware itself may be keeping some domains on, but * from Linux's perspective all we control is the refcounts * that we give to the firmware, and we can't ask the firmware * to turn off something that we haven't ourselves turned on. */ pm_genpd_init(&dom->base, NULL, true); rpi_domains->xlate.domains[xlate_index] = &dom->base; } static void rpi_init_power_domain(struct rpi_power_domains *rpi_domains, int xlate_index, const char *name) { struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index]; if (!rpi_domains->has_new_interface) return; /* The DT binding index is the firmware's domain index minus one. */ dom->domain = xlate_index + 1; rpi_common_init_power_domain(rpi_domains, xlate_index, name); } static void rpi_init_old_power_domain(struct rpi_power_domains *rpi_domains, int xlate_index, int domain, const char *name) { struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index]; dom->old_interface = true; dom->domain = domain; rpi_common_init_power_domain(rpi_domains, xlate_index, name); } /* * Detects whether the firmware supports the new power domains interface. * * The firmware doesn't actually return an error on an unknown tag, * and just skips over it, so we do the detection by putting an * unexpected value in the return field and checking if it was * unchanged. */ static bool rpi_has_new_domain_support(struct rpi_power_domains *rpi_domains) { struct rpi_power_domain_packet packet; int ret; packet.domain = RPI_POWER_DOMAIN_ARM; packet.on = ~0; ret = rpi_firmware_property(rpi_domains->fw, RPI_FIRMWARE_GET_DOMAIN_STATE, &packet, sizeof(packet)); return ret == 0 && packet.on != ~0; } static int rpi_power_probe(struct platform_device *pdev) { struct device_node *fw_np; struct device *dev = &pdev->dev; struct rpi_power_domains *rpi_domains; rpi_domains = devm_kzalloc(dev, sizeof(*rpi_domains), GFP_KERNEL); if (!rpi_domains) return -ENOMEM; rpi_domains->xlate.domains = devm_kzalloc(dev, sizeof(*rpi_domains->xlate.domains) * RPI_POWER_DOMAIN_COUNT, GFP_KERNEL); if (!rpi_domains->xlate.domains) return -ENOMEM; rpi_domains->xlate.num_domains = RPI_POWER_DOMAIN_COUNT; fw_np = of_parse_phandle(pdev->dev.of_node, "firmware", 0); if (!fw_np) { dev_err(&pdev->dev, "no firmware node\n"); return -ENODEV; } rpi_domains->fw = rpi_firmware_get(fw_np); of_node_put(fw_np); if (!rpi_domains->fw) return -EPROBE_DEFER; rpi_domains->has_new_interface = rpi_has_new_domain_support(rpi_domains); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_I2C0, "I2C0"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_I2C1, "I2C1"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_I2C2, "I2C2"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_VIDEO_SCALER, "VIDEO_SCALER"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_VPU1, "VPU1"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_HDMI, "HDMI"); /* * Use the old firmware interface for USB power, so that we * can turn it on even if the firmware hasn't been updated. */ rpi_init_old_power_domain(rpi_domains, RPI_POWER_DOMAIN_USB, RPI_OLD_POWER_DOMAIN_USB, "USB"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_VEC, "VEC"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_JPEG, "JPEG"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_H264, "H264"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_V3D, "V3D"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_ISP, "ISP"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_UNICAM0, "UNICAM0"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_UNICAM1, "UNICAM1"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CCP2RX, "CCP2RX"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CSI2, "CSI2"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CPI, "CPI"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_DSI0, "DSI0"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_DSI1, "DSI1"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_TRANSPOSER, "TRANSPOSER"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CCP2TX, "CCP2TX"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CDP, "CDP"); rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_ARM, "ARM"); of_genpd_add_provider_onecell(dev->of_node, &rpi_domains->xlate); platform_set_drvdata(pdev, rpi_domains); return 0; } static const struct of_device_id rpi_power_of_match[] = { { .compatible = "raspberrypi,bcm2835-power", }, {}, }; MODULE_DEVICE_TABLE(of, rpi_power_of_match); static struct platform_driver rpi_power_driver = { .driver = { .name = "raspberrypi-power", .of_match_table = rpi_power_of_match, }, .probe = rpi_power_probe, }; builtin_platform_driver(rpi_power_driver); MODULE_AUTHOR("Alexander Aring <aar@pengutronix.de>"); MODULE_AUTHOR("Eric Anholt <eric@anholt.net>"); MODULE_DESCRIPTION("Raspberry Pi power domain driver"); MODULE_LICENSE("GPL v2");
//PAGEBREAK: 21 // Free the page of physical memory pointed at by v, // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) void kfree(char *v) { struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) panic("kfree"); if(kmem.use_lock) acquire(&kmem.lock); if (kmem.references_count[V2P(v) >> PGSHIFT] > 0) { kmem.references_count[V2P(v) >> PGSHIFT] --; } kmem.free_pages++; if (kmem.references_count[V2P(v) >> PGSHIFT] != 0) { if(kmem.use_lock) release(&kmem.lock); return; } memset(v, 1, PGSIZE); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); }
// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QXMLSTREAM_H #define QXMLSTREAM_H #include <QtCore/qiodevice.h> QT_REQUIRE_CONFIG(xmlstream); #include <QtCore/qlist.h> #include <QtCore/qscopedpointer.h> #include <QtCore/qstring.h> QT_BEGIN_NAMESPACE namespace QtPrivate { class QXmlString { QStringPrivate m_string; public: QXmlString(QStringPrivate &&d) : m_string(std::move(d)) {} QXmlString(const QString &s) : m_string(s.data_ptr()) {} QXmlString & operator=(const QString &s) { m_string = s.data_ptr(); return *this; } QXmlString & operator=(QString &&s) { m_string.swap(s.data_ptr()); return *this; } inline constexpr QXmlString() {} void swap(QXmlString &other) noexcept { m_string.swap(other.m_string); } inline operator QStringView() const { return QStringView(m_string.data(), m_string.size); } inline qsizetype size() const { return m_string.size; } }; } Q_DECLARE_SHARED(QtPrivate::QXmlString) class QXmlStreamReaderPrivate; class QXmlStreamAttributes; class Q_CORE_EXPORT QXmlStreamAttribute { QtPrivate::QXmlString m_name, m_namespaceUri, m_qualifiedName, m_value; uint m_isDefault : 1; friend class QXmlStreamReaderPrivate; friend class QXmlStreamAttributes; public: QXmlStreamAttribute(); QXmlStreamAttribute(const QString &qualifiedName, const QString &value); QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value); inline QStringView namespaceUri() const { return m_namespaceUri; } inline QStringView name() const { return m_name; } inline QStringView qualifiedName() const { return m_qualifiedName; } inline QStringView prefix() const { return QStringView(m_qualifiedName).left(qMax(0, m_qualifiedName.size() - m_name.size() - 1)); } inline QStringView value() const { return m_value; } inline bool isDefault() const { return m_isDefault; } inline bool operator==(const QXmlStreamAttribute &other) const { return (value() == other.value() && (namespaceUri().isNull() ? (qualifiedName() == other.qualifiedName()) : (namespaceUri() == other.namespaceUri() && name() == other.name()))); } inline bool operator!=(const QXmlStreamAttribute &other) const { return !operator==(other); } }; Q_DECLARE_TYPEINFO(QXmlStreamAttribute, Q_RELOCATABLE_TYPE); // We export each out-of-line method individually to prevent MSVC from // exporting the whole QList class. class QXmlStreamAttributes : public QList<QXmlStreamAttribute> { public: inline QXmlStreamAttributes() {} #if QT_CORE_REMOVED_SINCE(6, 6) Q_CORE_EXPORT QStringView value(const QString &namespaceUri, const QString &name) const; Q_CORE_EXPORT QStringView value(const QString &namespaceUri, QLatin1StringView name) const; Q_CORE_EXPORT QStringView value(QLatin1StringView namespaceUri, QLatin1StringView name) const; Q_CORE_EXPORT QStringView value(const QString &qualifiedName) const; Q_CORE_EXPORT QStringView value(QLatin1StringView qualifiedName) const; #endif Q_CORE_EXPORT QStringView value(QAnyStringView namespaceUri, QAnyStringView name) const noexcept; Q_CORE_EXPORT QStringView value(QAnyStringView qualifiedName) const noexcept; Q_CORE_EXPORT void append(const QString &namespaceUri, const QString &name, const QString &value); Q_CORE_EXPORT void append(const QString &qualifiedName, const QString &value); bool hasAttribute(QAnyStringView qualifiedName) const { return !value(qualifiedName).isNull(); } bool hasAttribute(QAnyStringView namespaceUri, QAnyStringView name) const { return !value(namespaceUri, name).isNull(); } using QList<QXmlStreamAttribute>::append; }; class Q_CORE_EXPORT QXmlStreamNamespaceDeclaration { QtPrivate::QXmlString m_prefix, m_namespaceUri; friend class QXmlStreamReaderPrivate; public: QXmlStreamNamespaceDeclaration(); QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri); inline QStringView prefix() const { return m_prefix; } inline QStringView namespaceUri() const { return m_namespaceUri; } inline bool operator==(const QXmlStreamNamespaceDeclaration &other) const { return (prefix() == other.prefix() && namespaceUri() == other.namespaceUri()); } inline bool operator!=(const QXmlStreamNamespaceDeclaration &other) const { return !operator==(other); } }; Q_DECLARE_TYPEINFO(QXmlStreamNamespaceDeclaration, Q_RELOCATABLE_TYPE); typedef QList<QXmlStreamNamespaceDeclaration> QXmlStreamNamespaceDeclarations; class Q_CORE_EXPORT QXmlStreamNotationDeclaration { QtPrivate::QXmlString m_name, m_systemId, m_publicId; friend class QXmlStreamReaderPrivate; public: QXmlStreamNotationDeclaration(); inline QStringView name() const { return m_name; } inline QStringView systemId() const { return m_systemId; } inline QStringView publicId() const { return m_publicId; } inline bool operator==(const QXmlStreamNotationDeclaration &other) const { return (name() == other.name() && systemId() == other.systemId() && publicId() == other.publicId()); } inline bool operator!=(const QXmlStreamNotationDeclaration &other) const { return !operator==(other); } }; Q_DECLARE_TYPEINFO(QXmlStreamNotationDeclaration, Q_RELOCATABLE_TYPE); typedef QList<QXmlStreamNotationDeclaration> QXmlStreamNotationDeclarations; class Q_CORE_EXPORT QXmlStreamEntityDeclaration { QtPrivate::QXmlString m_name, m_notationName, m_systemId, m_publicId, m_value; friend class QXmlStreamReaderPrivate; public: QXmlStreamEntityDeclaration(); inline QStringView name() const { return m_name; } inline QStringView notationName() const { return m_notationName; } inline QStringView systemId() const { return m_systemId; } inline QStringView publicId() const { return m_publicId; } inline QStringView value() const { return m_value; } inline bool operator==(const QXmlStreamEntityDeclaration &other) const { return (name() == other.name() && notationName() == other.notationName() && systemId() == other.systemId() && publicId() == other.publicId() && value() == other.value()); } inline bool operator!=(const QXmlStreamEntityDeclaration &other) const { return !operator==(other); } }; Q_DECLARE_TYPEINFO(QXmlStreamEntityDeclaration, Q_RELOCATABLE_TYPE); typedef QList<QXmlStreamEntityDeclaration> QXmlStreamEntityDeclarations; class Q_CORE_EXPORT QXmlStreamEntityResolver { public: virtual ~QXmlStreamEntityResolver(); virtual QString resolveEntity(const QString& publicId, const QString& systemId); virtual QString resolveUndeclaredEntity(const QString &name); }; #if QT_CONFIG(xmlstreamreader) class Q_CORE_EXPORT QXmlStreamReader { QDOC_PROPERTY(bool namespaceProcessing READ namespaceProcessing WRITE setNamespaceProcessing) public: enum TokenType { NoToken = 0, Invalid, StartDocument, EndDocument, StartElement, EndElement, Characters, Comment, DTD, EntityReference, ProcessingInstruction }; QXmlStreamReader(); explicit QXmlStreamReader(QIODevice *device); #if QT_CORE_REMOVED_SINCE(6, 5) explicit QXmlStreamReader(const QByteArray &data); explicit QXmlStreamReader(const QString &data); explicit QXmlStreamReader(const char * data); #endif // QT_CORE_REMOVED_SINCE(6, 5) Q_WEAK_OVERLOAD explicit QXmlStreamReader(const QByteArray &data) : QXmlStreamReader(data, PrivateConstructorTag{}) { } explicit QXmlStreamReader(QAnyStringView data); ~QXmlStreamReader(); void setDevice(QIODevice *device); QIODevice *device() const; #if QT_CORE_REMOVED_SINCE(6, 5) void addData(const QByteArray &data); void addData(const QString &data); void addData(const char *data); #endif // QT_CORE_REMOVED_SINCE(6, 5) Q_WEAK_OVERLOAD void addData(const QByteArray &data) { addDataImpl(data); } void addData(QAnyStringView data); void clear(); bool atEnd() const; TokenType readNext(); bool readNextStartElement(); void skipCurrentElement(); TokenType tokenType() const; QString tokenString() const; void setNamespaceProcessing(bool); bool namespaceProcessing() const; inline bool isStartDocument() const { return tokenType() == StartDocument; } inline bool isEndDocument() const { return tokenType() == EndDocument; } inline bool isStartElement() const { return tokenType() == StartElement; } inline bool isEndElement() const { return tokenType() == EndElement; } inline bool isCharacters() const { return tokenType() == Characters; } bool isWhitespace() const; bool isCDATA() const; inline bool isComment() const { return tokenType() == Comment; } inline bool isDTD() const { return tokenType() == DTD; } inline bool isEntityReference() const { return tokenType() == EntityReference; } inline bool isProcessingInstruction() const { return tokenType() == ProcessingInstruction; } bool isStandaloneDocument() const; bool hasStandaloneDeclaration() const; QStringView documentVersion() const; QStringView documentEncoding() const; qint64 lineNumber() const; qint64 columnNumber() const; qint64 characterOffset() const; QXmlStreamAttributes attributes() const; enum ReadElementTextBehaviour { ErrorOnUnexpectedElement, IncludeChildElements, SkipChildElements }; QString readElementText(ReadElementTextBehaviour behaviour = ErrorOnUnexpectedElement); QStringView name() const; QStringView namespaceUri() const; QStringView qualifiedName() const; QStringView prefix() const; QStringView processingInstructionTarget() const; QStringView processingInstructionData() const; QStringView text() const; QXmlStreamNamespaceDeclarations namespaceDeclarations() const; void addExtraNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaraction); void addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclaractions); QXmlStreamNotationDeclarations notationDeclarations() const; QXmlStreamEntityDeclarations entityDeclarations() const; QStringView dtdName() const; QStringView dtdPublicId() const; QStringView dtdSystemId() const; int entityExpansionLimit() const; void setEntityExpansionLimit(int limit); enum Error { NoError, UnexpectedElementError, CustomError, NotWellFormedError, PrematureEndOfDocumentError }; void raiseError(const QString& message = QString()); QString errorString() const; Error error() const; inline bool hasError() const { return error() != NoError; } void setEntityResolver(QXmlStreamEntityResolver *resolver); QXmlStreamEntityResolver *entityResolver() const; private: struct PrivateConstructorTag { }; QXmlStreamReader(const QByteArray &data, PrivateConstructorTag); void addDataImpl(const QByteArray &data); Q_DISABLE_COPY(QXmlStreamReader) Q_DECLARE_PRIVATE(QXmlStreamReader) QScopedPointer<QXmlStreamReaderPrivate> d_ptr; }; #endif // feature xmlstreamreader #if QT_CONFIG(xmlstreamwriter) class QXmlStreamWriterPrivate; class Q_CORE_EXPORT QXmlStreamWriter { QDOC_PROPERTY(bool autoFormatting READ autoFormatting WRITE setAutoFormatting) QDOC_PROPERTY(int autoFormattingIndent READ autoFormattingIndent WRITE setAutoFormattingIndent) public: QXmlStreamWriter(); explicit QXmlStreamWriter(QIODevice *device); explicit QXmlStreamWriter(QByteArray *array); explicit QXmlStreamWriter(QString *string); ~QXmlStreamWriter(); void setDevice(QIODevice *device); QIODevice *device() const; void setAutoFormatting(bool); bool autoFormatting() const; void setAutoFormattingIndent(int spacesOrTabs); int autoFormattingIndent() const; #if QT_CORE_REMOVED_SINCE(6,5) void writeAttribute(const QString &qualifiedName, const QString &value); void writeAttribute(const QString &namespaceUri, const QString &name, const QString &value); #endif void writeAttribute(QAnyStringView qualifiedName, QAnyStringView value); void writeAttribute(QAnyStringView namespaceUri, QAnyStringView name, QAnyStringView value); void writeAttribute(const QXmlStreamAttribute& attribute); void writeAttributes(const QXmlStreamAttributes& attributes); #if QT_CORE_REMOVED_SINCE(6,5) void writeCDATA(const QString &text); void writeCharacters(const QString &text); void writeComment(const QString &text); void writeDTD(const QString &dtd); void writeEmptyElement(const QString &qualifiedName); void writeEmptyElement(const QString &namespaceUri, const QString &name); void writeTextElement(const QString &qualifiedName, const QString &text); void writeTextElement(const QString &namespaceUri, const QString &name, const QString &text); #endif void writeCDATA(QAnyStringView text); void writeCharacters(QAnyStringView text); void writeComment(QAnyStringView text); void writeDTD(QAnyStringView dtd); void writeEmptyElement(QAnyStringView qualifiedName); void writeEmptyElement(QAnyStringView namespaceUri, QAnyStringView name); void writeTextElement(QAnyStringView qualifiedName, QAnyStringView text); void writeTextElement(QAnyStringView namespaceUri, QAnyStringView name, QAnyStringView text); void writeEndDocument(); void writeEndElement(); #if QT_CORE_REMOVED_SINCE(6,5) void writeEntityReference(const QString &name); void writeNamespace(const QString &namespaceUri, const QString &prefix); void writeDefaultNamespace(const QString &namespaceUri); void writeProcessingInstruction(const QString &target, const QString &data); #endif void writeEntityReference(QAnyStringView name); void writeNamespace(QAnyStringView namespaceUri, QAnyStringView prefix = {}); void writeDefaultNamespace(QAnyStringView namespaceUri); void writeProcessingInstruction(QAnyStringView target, QAnyStringView data = {}); void writeStartDocument(); #if QT_CORE_REMOVED_SINCE(6,5) void writeStartDocument(const QString &version); void writeStartDocument(const QString &version, bool standalone); void writeStartElement(const QString &qualifiedName); void writeStartElement(const QString &namespaceUri, const QString &name); #endif void writeStartDocument(QAnyStringView version); void writeStartDocument(QAnyStringView version, bool standalone); void writeStartElement(QAnyStringView qualifiedName); void writeStartElement(QAnyStringView namespaceUri, QAnyStringView name); #if QT_CONFIG(xmlstreamreader) void writeCurrentToken(const QXmlStreamReader &reader); #endif bool hasError() const; private: Q_DISABLE_COPY(QXmlStreamWriter) Q_DECLARE_PRIVATE(QXmlStreamWriter) QScopedPointer<QXmlStreamWriterPrivate> d_ptr; }; #endif // feature xmlstreamwriter QT_END_NAMESPACE #endif // QXMLSTREAM_H
/* Initialise the RFFE pins and prepare the timer. */ void RFFE_Init(uint8_t slave_addr, GPIO_TypeDef *gpio_port, uint16_t sck_pin, uint16_t sda_pin) { rffe.slave_addr = slave_addr; rffe.sda = sda_pin; rffe.sck = sck_pin; rffe.port = gpio_port; SetPinOutput(gpio_port, sck_pin); SetPinOutput(gpio_port, sda_pin); RFFE_TIMER_ENABLE(); RFFE_SetSpeed(RFFE_DEFAULT_PRESCALER, RFFE_DEFAULT_PERIOD, RFFE_DEFAULT_CLKDIV); }
#include<stdio.h> int main(void) { int h1,h2,k1,k2,a,b,c,d,x,y; x=0; y=0; scanf("%d %d",&h1,&h2); scanf("%d %d",&k1,&k2); scanf("%d %d %d %d",&a,&b,&c,&d); x=h1*a+h2*b; y=k1*a+k2*b; if(h1>=10){ h1/=10; x+=h1*c; } if(h2>=20){ h2/=20; x+=h2*d; } if(k1>=10){ k1/=10; y+=k1*c; } if(k2>=20){ k2/=20; y+=k2*d; } if(x>y){ printf("hiroshi\n"); } else if(x<y){ printf("kenjiro\n"); } else{ printf("even\n"); } return 0; }
/* write closes for the local close records in the LML */ int presto_complete_lml(struct presto_file_set *fset) { __u32 groups[NGROUPS_MAX]; loff_t lml_offset; loff_t read_offset; char *buffer; void *handle; struct rec_info rec; struct close_rec { struct presto_version new_file_ver; __u64 ino; __u32 generation; __u32 pathlen; __u64 remote_ino; __u32 remote_generation; __u32 remote_version; __u64 lml_offset; } close_rec; struct file *file = fset->fset_lml.fd_file; struct kml_prefix_hdr prefix; int rc = 0; ENTRY; lml_offset = 0; again: if (lml_offset >= file->f_dentry->d_inode->i_size) { EXIT; return rc; } read_offset = lml_offset; rc = presto_fread(file, (char *)&prefix, sizeof(prefix), &read_offset); if ( rc != sizeof(prefix) ) { EXIT; CERROR("presto_complete_lml: ioerror - 1, tell Peter\n"); return -EIO; } if ( prefix.opcode == KML_OPCODE_NOOP ) { lml_offset += prefix.len; goto again; } rc = presto_fread(file, (char *)groups, prefix.ngroups * sizeof(__u32), &read_offset); if ( rc != prefix.ngroups * sizeof(__u32) ) { EXIT; CERROR("presto_complete_lml: ioerror - 2, tell Peter\n"); return -EIO; } rc = presto_fread(file, (char *)&close_rec, sizeof(close_rec), &read_offset); if ( rc != sizeof(close_rec) ) { EXIT; CERROR("presto_complete_lml: ioerror - 3, tell Peter\n"); return -EIO; } if ( le64_to_cpu(close_rec.remote_ino) != 0 ) { lml_offset += prefix.len; goto again; } BUFF_ALLOC(buffer, NULL); rc = presto_fread(file, (char *)buffer, le32_to_cpu(close_rec.pathlen), &read_offset); if ( rc != le32_to_cpu(close_rec.pathlen) ) { EXIT; CERROR("presto_complete_lml: ioerror - 4, tell Peter\n"); return -EIO; } handle = presto_trans_start(fset, file->f_dentry->d_inode, KML_OPCODE_RELEASE); if ( IS_ERR(handle) ) { EXIT; return -ENOMEM; } rc = presto_clear_lml_close(fset, lml_offset); if ( rc ) { CERROR("error during clearing: %d\n", rc); presto_trans_commit(fset, handle); EXIT; return rc; } rc = presto_rewrite_close(&rec, fset, buffer, close_rec.pathlen, prefix.ngroups, groups, close_rec.ino, close_rec.generation, &close_rec.new_file_ver); if ( rc ) { CERROR("error during rewrite close: %d\n", rc); presto_trans_commit(fset, handle); EXIT; return rc; } presto_trans_commit(fset, handle); if ( rc ) { CERROR("error during truncation: %d\n", rc); EXIT; return rc; } lml_offset += prefix.len; CDEBUG(D_JOURNAL, "next LML record at: %ld\n", (long)lml_offset); goto again; EXIT; return -EINVAL; }
/**CFile**************************************************************** FileName [ifData2.c] SystemName [ABC: Logic synthesis and verification system.] PackageName [FPGA mapping based on priority cuts.] Synopsis [Precomputed data.] Author [Alan Mishchenko] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - September 1, 2009.] Revision [$Id: ifData2.c,v 1.00 2009/09/01 00:00:00 alanmi Exp $] ***********************************************************************/ #include "if.h" ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// ABC_NAMESPACE_IMPL_END
/** * reassign_resources_sorted() - satisfy any additional resource requests * * @realloc_head : head of the list tracking requests requiring additional * resources * @head : head of the list tracking requests with allocated * resources * * Walk through each element of the realloc_head and try to procure * additional resources for the element, provided the element * is in the head list. */ static void reassign_resources_sorted(struct list_head *realloc_head, struct list_head *head) { struct resource *res; struct pci_dev_resource *add_res, *tmp; struct pci_dev_resource *dev_res; resource_size_t add_size; int idx; list_for_each_entry_safe(add_res, tmp, realloc_head, list) { bool found_match = false; res = add_res->res; if (!res->flags) goto out; list_for_each_entry(dev_res, head, list) { if (dev_res->res == res) { found_match = true; break; } } if (!found_match) continue; idx = res - &add_res->dev->resource[0]; add_size = add_res->add_size; if (!resource_size(res)) { res->start = add_res->start; res->end = res->start + add_size - 1; if (pci_assign_resource(add_res->dev, idx)) reset_resource(res); } else { resource_size_t align = add_res->min_align; res->flags |= add_res->flags & (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); if (pci_reassign_resource(add_res->dev, idx, add_size, align)) dev_printk(KERN_DEBUG, &add_res->dev->dev, "failed to add %llx res[%d]=%pR\n", (unsigned long long)add_size, idx, res); } out: list_del(&add_res->list); kfree(add_res); } }
/*++++++++++++++++++++++++++++++ Work through the tree and eliminate any nodes that only have single children, by raising their children up to their status. However, particular types of node are not compressed - those which are required for producing particular formatted outputs. ++++++++++++++++++++++++++++++*/ void compress_singletons_but_preserve(TreeNode *x) { int i, n; TreeNode *child, *grandchild; if (x->type == N_NONTERM) { n = x->data.nonterm.nchildren; for (i=0; i<n; i++) { child = x->data.nonterm.children[i]; while ((child->type == N_NONTERM) && (child->data.nonterm.nchildren == 1)) { grandchild = child->data.nonterm.children[0]; free_node(child); child = x->data.nonterm.children[i] = grandchild; } compress_singletons(child); } } }
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int main() { int i,n; scanf("%d",&n); for (i=0;i<n ;i++ ) { int mbx,mby; scanf("%d%d",&mbx,&mby); char ss[100000]; scanf("%s",ss); int u=0,d=0,r=0,l=0; int ii,len=strlen(ss); for(ii=0;ii<len;ii++) { if(ss[ii]=='U')u++; if(ss[ii]=='D')d++; if(ss[ii]=='R')r++; if(ss[ii]=='L')l++; } int a=0,b=0; if(mbx>0) { a=(r>=mbx)?1:0; } if(mbx<0) { a=(l>=-mbx)?1:0; } a=mbx==0?1:a; if(mby>0) { b=(u>=mby)?1:0; } if(mby<0) { b=(d>=-mby)?1:0; } b=mby==0?1:b; if(a==1&&b==1)printf("YES\n"); else printf("NO\n"); } return 0; }
/* * GetBackendOidFromRelPersistence * Returns backend oid for the given type of relation persistence. */ Oid GetBackendOidFromRelPersistence(char relpersistence) { switch (relpersistence) { case RELPERSISTENCE_TEMP: return BackendIdForTempRelations(); case RELPERSISTENCE_UNLOGGED: case RELPERSISTENCE_PERMANENT: return InvalidBackendId; default: elog(ERROR, "invalid relpersistence: %c", relpersistence); return InvalidOid; } }
// Writes a bstring to a file as a MessagePack formatted raw bytes element. // // file - The file stream to write to. // str - The bstring to write. // // Returns 0 if successful, otherwise returns -1. int sky_minipack_fwrite_bstring(FILE *file, bstring str) { size_t sz; uint32_t length = (uint32_t)blength(str); int rc = minipack_fwrite_raw(file, length, &sz); check(rc == 0, "Unable to write raw bytes header"); if(str) { sz = fwrite(bdata(str), sizeof(char), length, file); check(sz == (size_t)length, "Attempted to write %d bytes, only wrote %ld bytes", length, sz); } return 0; error: return -1; }
/*************************************************************************************************** * Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used * to endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * **************************************************************************************************/ /*! \file \brief Kernel performing a reduction over densely packed tensors in global memory */ #pragma once #include "cutlass/device_kernel.h" #include "cutlass/reduction/kernel/reduce_split_k.h" ///////////////////////////////////////////////////////////////////////////////////////////////// namespace cutlass { namespace reduction { namespace device { ///////////////////////////////////////////////////////////////////////////////////////////////// template < typename ReductionKernel_ > class ReduceSplitK { public: using ReductionKernel = ReductionKernel_; using Shape = typename ReductionKernel::Shape; using ReductionOp = typename ReductionKernel::ReductionOp; using OutputOp = typename ReductionKernel::OutputOp; using ElementWorkspace = typename ReductionKernel::ElementWorkspace; using ElementAccumulator = typename ReductionKernel::ElementAccumulator; using ElementOutput = typename ReductionKernel::ElementOutput; using WorkspaceTensorRef = typename ReductionKernel::WorkspaceTensorRef; using OutputTensorRef = typename ReductionKernel::OutputTensorRef; /// Argument structure struct Arguments { // // Data members // MatrixCoord problem_size; int partitions; size_t partition_stride; WorkspaceTensorRef workspace; OutputTensorRef destination; OutputTensorRef source; typename OutputOp::Params output; typename ReductionOp::Params reduction; // // Methods // /// Default ctor CUTLASS_HOST_DEVICE Arguments() : problem_size(0, 0), partitions(1), partition_stride(0) { } CUTLASS_HOST_DEVICE Arguments( MatrixCoord const & problem_size ): problem_size(problem_size) { } CUTLASS_HOST_DEVICE Arguments( MatrixCoord problem_size_, int partitions_, size_t partition_stride_, WorkspaceTensorRef workspace_, OutputTensorRef destination_, OutputTensorRef source_, typename OutputOp::Params output_ = typename OutputOp::Params(), typename ReductionOp::Params reduction_ = typename ReductionOp::Params() ): problem_size(problem_size_), partitions(partitions_), partition_stride(partition_stride_), workspace(workspace_), destination(destination_), source(source_), output(output_), reduction(reduction_) { } }; private: /// Kernel parameters object typename ReductionKernel::Params params_; public: /// Constructs Reduction SplitK ReduceSplitK() { } /// Determines whether the ReduceSplitK can execute the given problem. static Status can_implement(Arguments const &args) { return Status::kSuccess; } /// Gets the workspace size static size_t get_workspace_size(Arguments const &args) { // needs no additional workspace return 0; } /// Initializes Reduction state from arguments. Status initialize( Arguments const &args, void *workspace = nullptr, cudaStream_t stream = nullptr) { // initialize the params structure from the arguments params_ = typename ReductionKernel::Params( args.problem_size, args.partitions, args.partition_stride, args.workspace, args.destination, args.source, args.output, args.reduction ); return Status::kSuccess; } /// Initializes Reduction kernel state from arguments. Status update(Arguments const &args, void *workspace = nullptr) { // update the params structure from the arguments params_.workspace.reset(args.workspace.non_const_ref().data()); params_.destination.reset(args.destination.non_const_ref().data()); params_.source.reset(args.source.non_const_ref().data()); params_.output = args.output; params_.reduction = args.reduction; return Status::kSuccess; } /// Runs the kernel using initialized state. Status run(cudaStream_t stream = nullptr) { // // Launch reduction kernel // dim3 block = ReductionKernel::block_shape(); dim3 grid = ReductionKernel::grid_shape(params_.problem_size); Kernel<ReductionKernel><<< grid, block, 0, stream >>>(params_); cudaError_t result = cudaGetLastError(); return result == cudaSuccess ? Status::kSuccess : Status::kErrorInternal; } /// Runs the kernel using initialized state. Status operator()(cudaStream_t stream = nullptr) { return run(stream); } /// Runs the kernel using initialized state. Status operator()( Arguments const &args, void *workspace = nullptr, cudaStream_t stream = nullptr) { Status status = initialize(args, workspace); if (status == Status::kSuccess) { status = run(stream); } return status; } }; ///////////////////////////////////////////////////////////////////////////////////////////////// } // namespace kernel } // namespace reduction } // namespace cutlass
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2019, Intel Corporation */ /* * libpmemlog.h -- definitions of libpmemlog entry points * * This library provides support for programming with persistent memory (pmem). * * libpmemlog provides support for pmem-resident log files. * * See libpmemlog(7) for details. */ #ifndef LIBPMEMLOG_H #define LIBPMEMLOG_H 1 #include <sys/types.h> #ifdef _WIN32 #include <pmemcompat.h> #ifndef PMDK_UTF8_API #define pmemlog_open pmemlog_openW #define pmemlog_create pmemlog_createW #define pmemlog_check pmemlog_checkW #define pmemlog_check_version pmemlog_check_versionW #define pmemlog_errormsg pmemlog_errormsgW #define pmemlog_ctl_get pmemlog_ctl_getW #define pmemlog_ctl_set pmemlog_ctl_setW #define pmemlog_ctl_exec pmemlog_ctl_execW #else #define pmemlog_open pmemlog_openU #define pmemlog_create pmemlog_createU #define pmemlog_check pmemlog_checkU #define pmemlog_check_version pmemlog_check_versionU #define pmemlog_errormsg pmemlog_errormsgU #define pmemlog_ctl_get pmemlog_ctl_getU #define pmemlog_ctl_set pmemlog_ctl_setU #define pmemlog_ctl_exec pmemlog_ctl_execU #endif #else #include <sys/uio.h> #endif #ifdef __cplusplus extern "C" { #endif /* * opaque type, internal to libpmemlog */ typedef struct pmemlog PMEMlogpool; /* * PMEMLOG_MAJOR_VERSION and PMEMLOG_MINOR_VERSION provide the current * version of the libpmemlog API as provided by this header file. * Applications can verify that the version available at run-time * is compatible with the version used at compile-time by passing * these defines to pmemlog_check_version(). */ #define PMEMLOG_MAJOR_VERSION 1 #define PMEMLOG_MINOR_VERSION 1 #ifndef _WIN32 const char *pmemlog_check_version(unsigned major_required, unsigned minor_required); #else const char *pmemlog_check_versionU(unsigned major_required, unsigned minor_required); const wchar_t *pmemlog_check_versionW(unsigned major_required, unsigned minor_required); #endif /* * support for PMEM-resident log files... */ #define PMEMLOG_MIN_POOL ((size_t)(1024 * 1024 * 2)) /* min pool size: 2MiB */ /* * This limit is set arbitrary to incorporate a pool header and required * alignment plus supply. */ #define PMEMLOG_MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */ #ifndef _WIN32 PMEMlogpool *pmemlog_open(const char *path); #else PMEMlogpool *pmemlog_openU(const char *path); PMEMlogpool *pmemlog_openW(const wchar_t *path); #endif #ifndef _WIN32 PMEMlogpool *pmemlog_create(const char *path, size_t poolsize, mode_t mode); #else PMEMlogpool *pmemlog_createU(const char *path, size_t poolsize, mode_t mode); PMEMlogpool *pmemlog_createW(const wchar_t *path, size_t poolsize, mode_t mode); #endif #ifndef _WIN32 int pmemlog_check(const char *path); #else int pmemlog_checkU(const char *path); int pmemlog_checkW(const wchar_t *path); #endif void pmemlog_close(PMEMlogpool *plp); size_t pmemlog_nbyte(PMEMlogpool *plp); int pmemlog_append(PMEMlogpool *plp, const void *buf, size_t count); int pmemlog_appendv(PMEMlogpool *plp, const struct iovec *iov, int iovcnt); long long pmemlog_tell(PMEMlogpool *plp); void pmemlog_rewind(PMEMlogpool *plp); void pmemlog_walk(PMEMlogpool *plp, size_t chunksize, int (*process_chunk)(const void *buf, size_t len, void *arg), void *arg); /* * Passing NULL to pmemlog_set_funcs() tells libpmemlog to continue to use the * default for that function. The replacement functions must not make calls * back into libpmemlog. */ void pmemlog_set_funcs( void *(*malloc_func)(size_t size), void (*free_func)(void *ptr), void *(*realloc_func)(void *ptr, size_t size), char *(*strdup_func)(const char *s)); #ifndef _WIN32 const char *pmemlog_errormsg(void); #else const char *pmemlog_errormsgU(void); const wchar_t *pmemlog_errormsgW(void); #endif #ifndef _WIN32 /* EXPERIMENTAL */ int pmemlog_ctl_get(PMEMlogpool *plp, const char *name, void *arg); int pmemlog_ctl_set(PMEMlogpool *plp, const char *name, void *arg); int pmemlog_ctl_exec(PMEMlogpool *plp, const char *name, void *arg); #else int pmemlog_ctl_getU(PMEMlogpool *plp, const char *name, void *arg); int pmemlog_ctl_getW(PMEMlogpool *plp, const wchar_t *name, void *arg); int pmemlog_ctl_setU(PMEMlogpool *plp, const char *name, void *arg); int pmemlog_ctl_setW(PMEMlogpool *plp, const wchar_t *name, void *arg); int pmemlog_ctl_execU(PMEMlogpool *plp, const char *name, void *arg); int pmemlog_ctl_execW(PMEMlogpool *plp, const wchar_t *name, void *arg); #endif #ifdef __cplusplus } #endif #endif /* libpmemlog.h */
//This function moves the stairs back and forth. void moveStairs() { static int choose_call = 0; if (choose_call % 1 == 0) { if (stair4.direction == 0) { stair4.x++; stair4.x++; if (stair4.x >= 1390) { stair4.direction = 1; } if (move_intro_player == 4) { intro_player.x++; intro_player.x++; } } else if (stair4.direction == 1) { stair4.x--; stair4.x--; if (stair4.x <= 0) { stair4.direction = 0; } if (move_intro_player == 4) { intro_player.x--; intro_player.x--; } } } if (choose_call % 2 == 0) { if (stair3.direction == 0) { stair3.x++; stair3.x++; stair3.x++; if (stair3.x >= 1390) { stair3.direction = 1; } if (move_intro_player == 3) { intro_player.x++; intro_player.x++; intro_player.x++; } } else if (stair3.direction == 1) { stair3.x--; stair3.x--; stair3.x--; if (stair3.x <= 0) { stair3.direction = 0; } if (move_intro_player == 3) { intro_player.x--; intro_player.x--; intro_player.x--; } } } if (choose_call % 2 == 0) { if (stair2.direction == 0) { stair2.x++; stair2.x++; if (stair2.x >= 1390) { stair2.direction = 1; } if (move_intro_player == 2) { intro_player.x++; intro_player.x++; } } else if (stair2.direction == 1) { stair2.x--; stair2.x--; if (stair2.x <= 0) { stair2.direction = 0; } if (move_intro_player == 2) { intro_player.x--; intro_player.x--; } } } if (choose_call % 2 == 0) { if (stair1.direction == 0) { stair1.x++; stair1.x++; stair1.x++; if (stair1.x >= 1390) { stair1.direction = 1; } if (move_intro_player == 1) { intro_player.x++; intro_player.x++; intro_player.x++; } } else if (stair1.direction == 1) { stair1.x--; stair1.x--; stair1.x--; if (stair1.x <= 0) { stair1.direction = 0; } if (move_intro_player == 1) { intro_player.x--; intro_player.x--; intro_player.x--; } } } choose_call++; if (choose_call >= 2520) { choose_call = 0; } }
// Returns number of bits set; result is in most significatnt byte inline ui64 ByteSums(ui64 x) { ui64 byteSums = x - ((x & 0xAAAAAAAAAAAAAAAAULL) >> 1); byteSums = (byteSums & 0x3333333333333333ULL) + ((byteSums >> 2) & 0x3333333333333333ULL); byteSums = (byteSums + (byteSums >> 4)) & 0x0F0F0F0F0F0F0F0FULL; return byteSums * 0x0101010101010101ULL; }
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo * This benchmark is part of SWSC */ #include <assert.h> #include <stdint.h> #include <stdatomic.h> #include <pthread.h> atomic_int vars[6]; atomic_int atom_0_r1_1; atomic_int atom_1_r1_1; void *t0(void *arg){ label_1:; int v2_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst); int v3_r3 = v2_r1 ^ v2_r1; int v4_r3 = v3_r3 + 1; atomic_store_explicit(&vars[1], v4_r3, memory_order_seq_cst); int v23 = (v2_r1 == 1); atomic_store_explicit(&atom_0_r1_1, v23, memory_order_seq_cst); return NULL; } void *t1(void *arg){ label_2:; int v6_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst); int v7_r3 = v6_r1 ^ v6_r1; int v10_r4 = atomic_load_explicit(&vars[2+v7_r3], memory_order_seq_cst); int v11_r6 = v10_r4 ^ v10_r4; int v12_r6 = v11_r6 + 1; atomic_store_explicit(&vars[3], v12_r6, memory_order_seq_cst); int v14_r8 = atomic_load_explicit(&vars[3], memory_order_seq_cst); int v15_r9 = v14_r8 ^ v14_r8; int v18_r10 = atomic_load_explicit(&vars[4+v15_r9], memory_order_seq_cst); int v19_cmpeq = (v18_r10 == v18_r10); if (v19_cmpeq) goto lbl_LC00; else goto lbl_LC00; lbl_LC00:; atomic_store_explicit(&vars[5], 1, memory_order_seq_cst); atomic_store_explicit(&vars[0], 1, memory_order_seq_cst); int v24 = (v6_r1 == 1); atomic_store_explicit(&atom_1_r1_1, v24, memory_order_seq_cst); return NULL; } int main(int argc, char *argv[]){ pthread_t thr0; pthread_t thr1; atomic_init(&vars[2], 0); atomic_init(&vars[0], 0); atomic_init(&vars[5], 0); atomic_init(&vars[1], 0); atomic_init(&vars[3], 0); atomic_init(&vars[4], 0); atomic_init(&atom_0_r1_1, 0); atomic_init(&atom_1_r1_1, 0); pthread_create(&thr0, NULL, t0, NULL); pthread_create(&thr1, NULL, t1, NULL); pthread_join(thr0, NULL); pthread_join(thr1, NULL); int v20 = atomic_load_explicit(&atom_0_r1_1, memory_order_seq_cst); int v21 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst); int v22_conj = v20 & v21; if (v22_conj == 1) assert(0); return 0; }
#include <math.h> /* number of segments for the curve */ #define N_SEG 20 #define plot(x, y) put_pixel_clip(img, x, y, r, g, b) #define line(x0,y0,x1,y1) draw_line(img, x0,y0,x1,y1, r,g,b) void cubic_bezier( image img, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int x3, unsigned int y3, unsigned int x4, unsigned int y4, color_component r, color_component g, color_component b ) { unsigned int i; double pts[N_SEG+1][2]; for (i=0; i <= N_SEG; ++i) { double t = (double)i / (double)N_SEG; double a = pow((1.0 - t), 3.0); double b = 3.0 * t * pow((1.0 - t), 2.0); double c = 3.0 * pow(t, 2.0) * (1.0 - t); double d = pow(t, 3.0); double x = a * x1 + b * x2 + c * x3 + d * x4; double y = a * y1 + b * y2 + c * y3 + d * y4; pts[i][0] = x; pts[i][1] = y; } #if 0 /* draw only points */ for (i=0; i <= N_SEG; ++i) { plot( pts[i][0], pts[i][1] ); } #else /* draw segments */ for (i=0; i < N_SEG; ++i) { int j = i + 1; line( pts[i][0], pts[i][1], pts[j][0], pts[j][1] ); } #endif } #undef plot #undef line
/* MIFauto_partial This function is called by MIFload() when a code model requests that partial derivatives be computed automatically. It calls the code model additional times with an individual input to the model varied by a small amount at each call. Partial derivatives of each output with respect to the varied input are then computed by divided differences. */ static void MIFauto_partial( MIFinstance *here, void (*cm_func) (Mif_Private_t *), Mif_Private_t *cm_data) { Mif_Port_Data_t *fast; Mif_Port_Data_t *out_fast; Mif_Port_Type_t type; Mif_Port_Type_t out_type; int num_conn; int num_port; int num_port_k; int i; int j; int k; int l; double epsilon; double nominal_input; cm_data->circuit.init = MIF_FALSE; g_mif_info.circuit.init = MIF_FALSE; cm_data->circuit.anal_init = MIF_FALSE; g_mif_info.circuit.anal_init = MIF_FALSE; num_conn = here->num_conn; for(i = 0; i < num_conn; i++) { if(here->conn[i]->is_null || (! here->conn[i]->is_output)) continue; num_port = here->conn[i]->size; for(j = 0; j < num_port; j++) { fast = here->conn[i]->port[j]; if(fast->is_null) continue; type = fast->type; if((type == MIF_DIGITAL) || (type == MIF_USER_DEFINED)) continue; fast->nominal_output = fast->output.rvalue; } } num_conn = here->num_conn; for(i = 0; i < num_conn; i++) { if(here->conn[i]->is_null) continue; if(! here->conn[i]->is_input) continue; num_port = here->conn[i]->size; for(j = 0; j < num_port; j++) { fast = here->conn[i]->port[j]; if(fast->is_null) continue; type = fast->type; if((type == MIF_DIGITAL) || (type == MIF_USER_DEFINED)) continue; switch(type) { case MIF_VOLTAGE: case MIF_DIFF_VOLTAGE: case MIF_CONDUCTANCE: case MIF_DIFF_CONDUCTANCE: epsilon = 1.0e-6; break; case MIF_CURRENT: case MIF_DIFF_CURRENT: case MIF_VSOURCE_CURRENT: case MIF_RESISTANCE: case MIF_DIFF_RESISTANCE: epsilon = 1.0e-12; break; default: printf("INTERNAL ERROR - MIFauto_partial. Invalid port type\n"); epsilon = 1.0e-30; break; } nominal_input = fast->input.rvalue; fast->input.rvalue += epsilon; cm_func (cm_data); for(k = 0; k < num_conn; k++) { if((here->conn[k]->is_null) || (! here->conn[k]->is_output)) continue; num_port_k = here->conn[k]->size; for(l = 0; l < num_port_k; l++) { out_fast = here->conn[k]->port[l]; if(out_fast->is_null) continue; out_type = out_fast->type; if((out_type == MIF_DIGITAL) || (out_type == MIF_USER_DEFINED)) continue; out_fast->partial[i].port[j] = (out_fast->output.rvalue - out_fast->nominal_output) / epsilon; out_fast->output.rvalue = 0.0; } } fast->input.rvalue = nominal_input; } } cm_func (cm_data); }
/******************************************************************** * * sifproxyarp - Make a proxy ARP entry for the peer. */ int sifproxyarp(ppp_pcb *pcb, u32_t his_adr) { LWIP_UNUSED_ARG(pcb); LWIP_UNUSED_ARG(his_adr); return 0; }
#include<stdio.h> int main(void){ long long n,max=0,sum=0,d,t,cnt, max1 = 0, max2 = 0; scanf("%lld", &n); int khobz[n],khobza[n]; for(cnt=0;cnt<n;cnt++){ scanf("%lld", &khobz[cnt]); sum+=khobz[cnt]; } for(cnt=0;cnt<n;cnt++){ scanf("%lld", &t); if(t > max1){ max2=max1; max1=t; } else if(t>=max2 && t<=max1){ max2=t; } } //printf("%lld %lld", max1, max2); if(max1+max2>=sum) printf("YES"); else printf("NO"); return 0; }
/** **************************************************************************** * @name update_user_param * @brief writes user data into user configuration structure, validates data if * required, updates system parameters * @param [in] pointer to userData payload in the packet * @retval N/A ******************************************************************************/ BOOL update_user_param(userParamPayload *pld, uint8_t *payloadLen) { uint8_t ret = 0; int32_t result = 0; if (pld->paramNum < USER_MAX_PARAM) { ret = update_user_parameter(pld->paramNum, pld->parameter, false); if (ret > 0) { update_ethnet_config(pld->paramNum); } else { result = INVALID_VALUE; } } else { result = INVALID_PARAM; } pld->paramNum = result; *payloadLen = 4; return TRUE; }
#include <stdio.h> #define N 1000 int search(int d, int n, int x[], int y[], int a[], int b[], int t_x, int t_y) { if (d == 0) return 1; int i; for (i = 0; i < n; i++) { if (x[0] + a[i] == t_x && y[0] + b[i] == t_y) { int res = search(d - 1, n, x + 1, y + 1, a, b, t_x, t_y); if (res) return 1; } } return 0; } int main(int argc, char *argv[]) { int n; scanf("%d", &n); int x[N]; int y[N]; int a[N]; int b[N]; int i; for (i = 0; i < n; i++) scanf("%d %d", &x[i], &y[i]); for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]); for (i = 0; i < n; i++) { int t_x = x[0] + a[i]; int t_y = y[0] + b[i]; if (search(n - 1, n, x + 1, y + 1, a, b, t_x, t_y)) { printf("%d %d\n", t_x, t_y); return 0; } } return 0; }
/* count denotes the number of new completions we have seen */ static void bnx2x_cnic_sp_post(struct bnx2x *bp, int count) { struct eth_spe *spe; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return; #endif spin_lock_bh(&bp->spq_lock); bp->cnic_spq_pending -= count; for (; bp->cnic_spq_pending < bp->cnic_eth_dev.max_kwqe_pending; bp->cnic_spq_pending++) { if (!bp->cnic_kwq_pending) break; spe = bnx2x_sp_get_next(bp); *spe = *bp->cnic_kwq_cons; bp->cnic_kwq_pending--; DP(NETIF_MSG_TIMER, "pending on SPQ %d, on KWQ %d count %d\n", bp->cnic_spq_pending, bp->cnic_kwq_pending, count); if (bp->cnic_kwq_cons == bp->cnic_kwq_last) bp->cnic_kwq_cons = bp->cnic_kwq; else bp->cnic_kwq_cons++; } bnx2x_sp_prod_update(bp); spin_unlock_bh(&bp->spq_lock); }
/* _pico_load_file: * wrapper around the loadfile function pointer */ void _pico_load_file( char *name, unsigned char **buffer, int *bufSize ){ if ( name == NULL ) { *bufSize = -1; return; } if ( _pico_ptr_load_file == NULL ) { *bufSize = -1; return; } _pico_ptr_load_file( name,buffer,bufSize ); }
/** * return bytes read, zero or less in failure */ int readProperty(Property_PTR property, uint8_t size, unsigned char *buf) { if (property == NULL || property->readf == NULL) { return -1; } else if (buf == NULL) { return -2; } else { return property->readf(property, size, buf); } }
/* OS layer functions implementations */ /** * \brief Return current count value for OS timer. * * \param CounterID Counter ID. * \param Value Pointer to variable to return count value. * * \retval 0U Counter read is successful. */ int32_t GetCounterValue(CounterType CounterID, TickRefType Value) { *Value = HW_RD_REG32(SOC_COUNTER_32K_BASE + COUNTER_32K_CR); *Value = *Value; return (int32_t) 0U; }
// Ponto de partida do executavel Multiboot void _start() { asm("cmp eax, 0x2badb002"); asm("jne __cancela"); asm("mov esp, pilha_topo"); asm("push eax"); asm("push ebx"); asm("call _es_inicial"); asm("__cancela:"); }
/******************************************************************************** ** Form generated from reading UI file 'Main_Window.ui' ** ** Created by: Qt User Interface Compiler version 6.0.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef MAIN_WINDOW_H #define MAIN_WINDOW_H #include <QtCore/QVariant> #include <QtWidgets/QApplication> #include <QtWidgets/QMainWindow> #include <QtWidgets/QMenuBar> #include <QtWidgets/QStatusBar> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_MainWindow { public: QMenuBar *menubar; QWidget *centralwidget; QStatusBar *statusbar; void setupUi(QMainWindow *MainWindow) { if (MainWindow->objectName().isEmpty()) MainWindow->setObjectName("MainWindow"); MainWindow->resize(800, 600); menubar = new QMenuBar(MainWindow); menubar->setObjectName("menubar"); MainWindow->setMenuBar(menubar); centralwidget = new QWidget(MainWindow); centralwidget->setObjectName("centralwidget"); MainWindow->setCentralWidget(centralwidget); statusbar = new QStatusBar(MainWindow); statusbar->setObjectName("statusbar"); MainWindow->setStatusBar(statusbar); retranslateUi(MainWindow); QMetaObject::connectSlotsByName(MainWindow); } // setupUi void retranslateUi(QMainWindow *MainWindow) { MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr)); } // retranslateUi }; namespace Ui { class MainWindow: public Ui_MainWindow {}; } // namespace Ui QT_END_NAMESPACE #endif // MAIN_WINDOW_H
/******************************************************************************* * * FUNCTION: HxReadAmlOutputFile * * PARAMETERS: Buffer - Where to return data * * RETURN: None * * DESCRIPTION: Read a line of the AML output prior to formatting the data * ******************************************************************************/ static UINT32 HxReadAmlOutputFile ( UINT8 *Buffer) { UINT32 Actual; Actual = fread (Buffer, 1, HEX_TABLE_LINE_SIZE, AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle); if (ferror (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle)) { FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); AslAbort (); } return (Actual); }
/* Get the current read error flag */ UINT16 rtp_errno(RTP *rtp) { UINT16 retval; MUTEX_LOCK(&rtp->rcv.mutex); retval = rtp->rcv.error; MUTEX_UNLOCK(&rtp->rcv.mutex); return retval; }
/* * void method_remove_contract() * Remove any non-permanent contracts from internal structures and * the repository, then abandon them. * Returns * 0 - success * ECANCELED - inst was deleted from the repository * * If the repository connection was broken, it is rebound. */ void method_remove_contract(restarter_inst_t *inst, boolean_t primary, boolean_t abandon) { ctid_t * const ctidp = primary ? &inst->ri_i.i_primary_ctid : &inst->ri_i.i_transient_ctid; int r; assert(*ctidp != 0); log_framework(LOG_DEBUG, "Removing %s contract %lu for %s.\n", primary ? "primary" : "transient", *ctidp, inst->ri_i.i_fmri); if (abandon) contract_abandon(*ctidp); again: if (inst->ri_mi_deleted) { r = ECANCELED; goto out; } r = restarter_remove_contract(inst->ri_m_inst, *ctidp, primary ? RESTARTER_CONTRACT_PRIMARY : RESTARTER_CONTRACT_TRANSIENT); switch (r) { case 0: break; case ECANCELED: inst->ri_mi_deleted = B_TRUE; break; case ECONNABORTED: libscf_handle_rebind(scf_instance_handle(inst->ri_m_inst)); case EBADF: libscf_reget_instance(inst); goto again; case ENOMEM: case EPERM: case EACCES: case EROFS: log_error(LOG_INFO, "%s: Couldn't remove contract id %ld: " "%s.\n", inst->ri_i.i_fmri, *ctidp, strerror(r)); break; case EINVAL: default: bad_error("restarter_remove_contract", r); } out: if (primary) contract_hash_remove(*ctidp); *ctidp = 0; }
/* The MessageHeader is expected to have been already parsed */ static int biop_parse_file_message(struct biop_file_message *msg, const char *buf, uint32_t len) { struct biop_file_message_body *msg_body = &msg->message_body; struct biop_message_sub_header *sub_header = &msg->sub_header; int retval, j = 0; j += biop_parse_message_sub_header(sub_header, &buf[j], len-j); msg->message_body_length = CONVERT_TO_32(buf[j], buf[j+1], buf[j+2], buf[j+3]); msg_body->content_length = CONVERT_TO_32(buf[j+4], buf[j+5], buf[j+6], buf[j+7]); retval = msg->message_body_length + j + 4; if (msg_body->content_length) { msg_body->contents = &buf[j+8]; } j += 8 + msg_body->content_length; if (retval != j) dprintf("Parsed %d elements, but message_body_length is %d", j, retval); return retval; }
/* * Send an ICMPv4 packet with the unreach type and the needfrag code * to the node specidied by the remote_addrp parameter. The source * address is the IPv4 address related to the final IPv6 node of the * original packet that caused this ICMPv4 error. */ int icmpsub_send_icmp4_unreach_needfrag(int tun_fd, void *in_pktp, const struct in_addr *local_addrp, const struct in_addr *remote_addrp, int mtu) { assert(in_pktp != NULL); assert(local_addrp != NULL); assert(remote_addrp != NULL); if (icmpsub_check_sending_rate()) { warnx("ICMP rate limit over."); return (0); } struct ip ip4_hdr; struct icmp icmp4_hdr; if (icmpsub_create_icmp4_unreach_needfrag(&ip4_hdr, &icmp4_hdr, local_addrp, remote_addrp, mtu) == -1) { warnx("ICMP unreach needfrag packet creation failed."); return (-1); } ip4_hdr.ip_sum = cksum_calc_ip4_header(&ip4_hdr); struct iovec iov[5]; uint32_t af; tun_set_af(&af, AF_INET); iov[0].iov_base = &af; iov[0].iov_len = sizeof(uint32_t); iov[1].iov_base = &ip4_hdr; iov[1].iov_len = sizeof(struct ip); iov[2].iov_base = NULL; iov[2].iov_len = 0; iov[3].iov_base = &icmp4_hdr; iov[3].iov_len = ICMP_MINLEN; iov[4].iov_base = in_pktp; iov[4].iov_len = sizeof(struct ip); cksum_calc_ulp(IPPROTO_ICMP, iov); if (writev(tun_fd, iov, 5) == -1) { warn("failed to write ICMP unreach needfrag packet to the tun device."); return (-1); } return (0); }
/*++ Copyright (c) 2012 Microsoft Corporation Module Name: fpa2bv_converter.h Abstract: Conversion routines for Floating Point -> Bit-Vector Author: Christoph (cwinter) 2012-02-09 Notes: --*/ #ifndef FPA2BV_CONVERTER_H_ #define FPA2BV_CONVERTER_H_ #include "ast/ast.h" #include "util/obj_hashtable.h" #include "util/ref_util.h" #include "ast/fpa_decl_plugin.h" #include "ast/bv_decl_plugin.h" #include "ast/array_decl_plugin.h" #include "ast/datatype_decl_plugin.h" #include "ast/dl_decl_plugin.h" #include "ast/pb_decl_plugin.h" #include "ast/seq_decl_plugin.h" #include "ast/rewriter/bool_rewriter.h" class fpa2bv_converter { public: typedef obj_map<func_decl, std::pair<app *, app *> > special_t; typedef obj_map<func_decl, expr*> const2bv_t; typedef obj_map<func_decl, func_decl*> uf2bvuf_t; protected: ast_manager & m; bool_rewriter m_simp; fpa_util m_util; bv_util m_bv_util; arith_util m_arith_util; datatype_util m_dt_util; seq_util m_seq_util; mpf_manager & m_mpf_manager; unsynch_mpz_manager & m_mpz_manager; fpa_decl_plugin * m_plugin; bool m_hi_fp_unspecified; const2bv_t m_const2bv; const2bv_t m_rm_const2bv; uf2bvuf_t m_uf2bvuf; special_t m_min_max_ufs; friend class fpa2bv_model_converter; friend class bv2fpa_converter; public: fpa2bv_converter(ast_manager & m); ~fpa2bv_converter(); fpa_util & fu() { return m_util; } bv_util & bu() { return m_bv_util; } arith_util & au() { return m_arith_util; } bool is_float(sort * s) { return m_util.is_float(s); } bool is_float(expr * e) { return is_app(e) && m_util.is_float(to_app(e)->get_decl()->get_range()); } bool is_rm(expr * e) { return is_app(e) && m_util.is_rm(e); } bool is_rm(sort * s) { return m_util.is_rm(s); } bool is_float_family(func_decl * f) { return f->get_family_id() == m_util.get_family_id(); } void mk_fp(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void split_fp(expr * e, expr * & sgn, expr * & exp, expr * & sig) const; void split_fp(expr * e, expr_ref & sgn, expr_ref & exp, expr_ref & sig) const; void join_fp(expr * e, expr_ref & res); void mk_eq(expr * a, expr * b, expr_ref & result); void mk_ite(expr * c, expr * t, expr * f, expr_ref & result); void mk_distinct(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_rounding_mode(decl_kind k, expr_ref & result); void mk_numeral(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_numeral(sort * s, mpf const & v, expr_ref & result); virtual void mk_const(func_decl * f, expr_ref & result); virtual void mk_rm_const(func_decl * f, expr_ref & result); virtual void mk_uf(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_var(unsigned base_inx, sort * srt, expr_ref & result); void mk_pinf(func_decl * f, expr_ref & result); void mk_ninf(func_decl * f, expr_ref & result); void mk_nan(func_decl * f, expr_ref & result); void mk_nzero(func_decl *f, expr_ref & result); void mk_pzero(func_decl *f, expr_ref & result); void mk_add(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_sub(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_neg(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_mul(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_div(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_rem(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_abs(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_fma(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_sqrt(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_round_to_integral(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_abs(sort * s, expr_ref & x, expr_ref & result); void mk_float_eq(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_float_lt(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_float_gt(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_float_le(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_float_ge(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_float_eq(sort * s, expr_ref & x, expr_ref & y, expr_ref & result); void mk_float_lt(sort * s, expr_ref & x, expr_ref & y, expr_ref & result); void mk_float_gt(sort *, expr_ref & x, expr_ref & y, expr_ref & result); void mk_float_le(sort * s, expr_ref & x, expr_ref & y, expr_ref & result); void mk_float_ge(sort * s, expr_ref & x, expr_ref & y, expr_ref & result); void mk_is_zero(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_nzero(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_pzero(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_negative(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_positive(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_nan(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_inf(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_normal(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_is_subnormal(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_fp(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_fp_float(func_decl * f, sort * s, expr * rm, expr * x, expr_ref & result); void mk_to_fp_signed(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_fp_unsigned(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_ieee_bv(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_ieee_bv_unspecified(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_fp_real(func_decl * f, sort * s, expr * rm, expr * x, expr_ref & result); void mk_to_fp_real_int(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_ubv(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_sbv(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_bv_unspecified(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_real(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_real_unspecified(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void set_unspecified_fp_hi(bool v) { m_hi_fp_unspecified = v; } void mk_min(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_max(func_decl * f, unsigned num, expr * const * args, expr_ref & result); expr_ref mk_min_max_unspecified(func_decl * f, expr * x, expr * y); void reset(); void dbg_decouple(const char * prefix, expr_ref & e); expr_ref_vector m_extra_assertions; special_t const & get_min_max_specials() const { return m_min_max_ufs; }; const2bv_t const & get_const2bv() const { return m_const2bv; }; const2bv_t const & get_rm_const2bv() const { return m_rm_const2bv; }; uf2bvuf_t const & get_uf2bvuf() const { return m_uf2bvuf; }; protected: void mk_one(func_decl *f, expr_ref & sign, expr_ref & result); void mk_is_nan(expr * e, expr_ref & result); void mk_is_inf(expr * e, expr_ref & result); void mk_is_pinf(expr * e, expr_ref & result); void mk_is_ninf(expr * e, expr_ref & result); void mk_is_pos(expr * e, expr_ref & result); void mk_is_neg(expr * e, expr_ref & result); void mk_is_zero(expr * e, expr_ref & result); void mk_is_nzero(expr * e, expr_ref & result); void mk_is_pzero(expr * e, expr_ref & result); void mk_is_denormal(expr * e, expr_ref & result); void mk_is_normal(expr * e, expr_ref & result); void mk_is_rm(expr * e, BV_RM_VAL rm, expr_ref & result); void mk_top_exp(unsigned sz, expr_ref & result); void mk_bot_exp(unsigned sz, expr_ref & result); void mk_min_exp(unsigned ebits, expr_ref & result); void mk_max_exp(unsigned ebits, expr_ref & result); void mk_leading_zeros(expr * e, unsigned max_bits, expr_ref & result); void mk_bias(expr * e, expr_ref & result); void mk_unbias(expr * e, expr_ref & result); void unpack(expr * e, expr_ref & sgn, expr_ref & sig, expr_ref & exp, expr_ref & lz, bool normalize); void round(sort * s, expr_ref & rm, expr_ref & sgn, expr_ref & sig, expr_ref & exp, expr_ref & result); expr_ref mk_rounding_decision(expr * rm, expr * sgn, expr * last, expr * round, expr * sticky); void add_core(unsigned sbits, unsigned ebits, expr_ref & c_sgn, expr_ref & c_sig, expr_ref & c_exp, expr_ref & d_sgn, expr_ref & d_sig, expr_ref & d_exp, expr_ref & res_sgn, expr_ref & res_sig, expr_ref & res_exp); app * mk_fresh_const(char const * prefix, unsigned sz); void mk_to_bv(func_decl * f, unsigned num, expr * const * args, bool is_signed, expr_ref & result); private: void mk_nan(sort * s, expr_ref & result); void mk_nzero(sort * s, expr_ref & result); void mk_pzero(sort * s, expr_ref & result); void mk_zero(sort * s, expr_ref & sgn, expr_ref & result); void mk_ninf(sort * s, expr_ref & result); void mk_pinf(sort * s, expr_ref & result); void mk_one(sort * s, expr_ref & sign, expr_ref & result); void mk_neg(sort * s, expr_ref & x, expr_ref & result); void mk_add(sort * s, expr_ref & bv_rm, expr_ref & x, expr_ref & y, expr_ref & result); void mk_sub(sort * s, expr_ref & bv_rm, expr_ref & x, expr_ref & y, expr_ref & result); void mk_mul(sort * s, expr_ref & bv_rm, expr_ref & x, expr_ref & y, expr_ref & result); void mk_div(sort * s, expr_ref & bv_rm, expr_ref & x, expr_ref & y, expr_ref & result); void mk_rem(sort * s, expr_ref & x, expr_ref & y, expr_ref & result); void mk_round_to_integral(sort * s, expr_ref & rm, expr_ref & x, expr_ref & result); void mk_to_fp_float(sort * s, expr * rm, expr * x, expr_ref & result); func_decl * mk_bv_uf(func_decl * f, sort * const * domain, sort * range); expr_ref nan_wrap(expr * n); expr_ref extra_quantify(expr * e); }; #endif
//------------------------------------------------------------------------ // Performs mapping from element to mortar when the nonconforming // edges are shared by two conforming faces of an element. //------------------------------------------------------------------------ void transfb_nc0(double tmor[LX1][LX1], double tx[LX1][LX1][LX1]) { int i, j; r_init((double *)tmor, LX1 * LX1, 0.0); for (j = 0; j < LX1; j++) { for (i = 1; i < LX1 - 1; i++) { tmor[0][j] = tmor[0][j] + qbnew[0][j][i - 1] * tx[0][0][i]; } } }
/******************************************************************** * FUNCTION resolve_minmax * * Resolve the min and max keywords in the rangeQ if present * * Error messages are printed by this function!! * Do not duplicate error messages upon error return * * INPUTS: * tkc == token chain * mod == module in progress * rangeQ == rangeQ to process * simple == TRUE if this is a NCX_CL_SIMPLE typedef * == FALSE if this is a NCX_CL_NAMED typedef * rbtyp == range builtin type * * RETURNS: * status of the operation *********************************************************************/ static status_t resolve_minmax (tk_chain_t *tkc, ncx_module_t *mod, typ_def_t *typdef, boolean simple, ncx_btype_t rbtyp) { dlq_hdr_t *rangeQ, *parentQ; typ_rangedef_t *rv, *pfirstrv, *plastrv; typ_def_t *parentdef, *rangedef; status_t res; rangeQ = typ_get_rangeQ_con(typdef); if (!rangeQ || dlq_empty(rangeQ)) { return ERR_NCX_SKIPPED; } res = NO_ERR; pfirstrv = NULL; plastrv = NULL; if (!simple) { parentdef = typ_get_parent_typdef(typdef); rangedef = typ_get_qual_typdef(parentdef, NCX_SQUAL_RANGE); if (rangedef) { parentQ = typ_get_rangeQ_con(rangedef); if (!parentQ || dlq_empty(parentQ)) { return SET_ERROR(ERR_INTERNAL_VAL); } pfirstrv = (typ_rangedef_t *)dlq_firstEntry(parentQ); plastrv = (typ_rangedef_t *)dlq_lastEntry(parentQ); } } for (rv = (typ_rangedef_t *)dlq_firstEntry(rangeQ); rv != NULL && res==NO_ERR; rv = (typ_rangedef_t *)dlq_nextEntry(rv)) { if (rv->btyp ==NCX_BT_NONE) { rv->btyp = rbtyp; } else if (rv->btyp != rbtyp) { res = ERR_NCX_WRONG_DATATYP; } if (rv->flags & TYP_FL_LBMIN) { if (pfirstrv) { if (pfirstrv->flags & TYP_FL_LBINF) { rv->flags |= TYP_FL_LBINF; } else if (pfirstrv->flags & TYP_FL_LBINF2) { rv->flags |= TYP_FL_LBINF2; } else { res = ncx_copy_num(&pfirstrv->lb, &rv->lb, rbtyp); } } else { if (rbtyp==NCX_BT_FLOAT64) { rv->flags |= TYP_FL_LBINF; } else { ncx_set_num_min(&rv->lb, rbtyp); } } } else if (rv->flags & TYP_FL_LBMAX) { if (plastrv) { if (plastrv->flags & TYP_FL_UBINF) { rv->flags |= TYP_FL_LBINF2; } else if (plastrv->flags & TYP_FL_UBINF2) { rv->flags |= TYP_FL_LBINF; } else { res = ncx_copy_num(&plastrv->ub, &rv->lb, rbtyp); } } else { if (rbtyp==NCX_BT_FLOAT64) { rv->flags |= TYP_FL_LBINF2; } else { ncx_set_num_max(&rv->lb, rbtyp); } } } else if (rv->lbstr) { res = ncx_decode_num(rv->lbstr, rbtyp, &rv->lb); } if (res != NO_ERR) { continue; } if (rv->flags & TYP_FL_UBMAX) { if (plastrv) { if (plastrv->flags & TYP_FL_UBINF) { rv->flags |= TYP_FL_UBINF; } else if (plastrv->flags & TYP_FL_UBINF2) { rv->flags |= TYP_FL_UBINF2; } else { res = ncx_copy_num(&plastrv->ub, &rv->ub, rbtyp); } } else { if (rbtyp==NCX_BT_FLOAT64) { rv->flags |= TYP_FL_UBINF; } else { ncx_set_num_max(&rv->ub, rbtyp); } } } else if (rv->flags & TYP_FL_UBMIN) { if (pfirstrv) { if (pfirstrv->flags & TYP_FL_LBINF) { rv->flags |= TYP_FL_UBINF2; } else if (pfirstrv->flags & TYP_FL_LBINF2) { rv->flags |= TYP_FL_UBINF; } else { res = ncx_copy_num(&pfirstrv->lb, &rv->ub, rbtyp); } } else { if (rbtyp==NCX_BT_FLOAT64) { rv->flags |= TYP_FL_UBINF2; } else { ncx_set_num_min(&rv->ub, rbtyp); } } } else if (rv->ubstr) { res = ncx_decode_num(rv->ubstr, rbtyp, &rv->ub); } } if (res != NO_ERR) { if (simple) { tkc->curerr = &typdef->def.simple.range.tkerr; } else { tkc->curerr = &typdef->tkerr; } ncx_print_errormsg(tkc, mod, res); } else { rv = (typ_rangedef_t *)dlq_firstEntry(rangeQ); if (rv && ncx_is_min(&rv->lb, rbtyp)) { rv->flags |= TYP_FL_LBMIN; } rv = (typ_rangedef_t *)dlq_lastEntry(rangeQ); if (rv && ncx_is_max(&rv->ub, rbtyp)) { rv->flags |= TYP_FL_UBMAX; } } return res; }
/* Allocated buffer is needed by all non-primitive types (which have non-fixed length) */ static bool mysql_field_needs_allocated_buffer(MYSQL_FIELD *field) { if (mysql_type_needs_allocated_buffer(field->type) || mysql_field_needs_string_type(field)) return TRUE; else return FALSE; }
/* * Copyright (c) 2021 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr/drivers/pinctrl.h> #include <hal/nrf_gpio.h> BUILD_ASSERT(((NRF_PULL_NONE == NRF_GPIO_PIN_NOPULL) && (NRF_PULL_DOWN == NRF_GPIO_PIN_PULLDOWN) && (NRF_PULL_UP == NRF_GPIO_PIN_PULLUP)), "nRF pinctrl pull settings do not match HAL values"); BUILD_ASSERT(((NRF_DRIVE_S0S1 == NRF_GPIO_PIN_S0S1) && (NRF_DRIVE_H0S1 == NRF_GPIO_PIN_H0S1) && (NRF_DRIVE_S0H1 == NRF_GPIO_PIN_S0H1) && (NRF_DRIVE_H0H1 == NRF_GPIO_PIN_H0H1) && (NRF_DRIVE_D0S1 == NRF_GPIO_PIN_D0S1) && (NRF_DRIVE_D0H1 == NRF_GPIO_PIN_D0H1) && (NRF_DRIVE_S0D1 == NRF_GPIO_PIN_S0D1) && (NRF_DRIVE_H0D1 == NRF_GPIO_PIN_H0D1) && #if defined(GPIO_PIN_CNF_DRIVE_E0E1) (NRF_DRIVE_E0E1 == NRF_GPIO_PIN_E0E1) && #endif /* defined(GPIO_PIN_CNF_DRIVE_E0E1) */ (1U)), "nRF pinctrl drive settings do not match HAL values"); /* value to indicate pin level doesn't need initialization */ #define NO_WRITE UINT32_MAX #define PSEL_DISCONNECTED 0xFFFFFFFFUL #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_uart) #define NRF_PSEL_UART(reg, line) ((NRF_UART_Type *)reg)->PSEL##line #elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_uarte) #define NRF_PSEL_UART(reg, line) ((NRF_UARTE_Type *)reg)->PSEL.line #endif #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spi) #define NRF_PSEL_SPIM(reg, line) ((NRF_SPI_Type *)reg)->PSEL##line #elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spim) #define NRF_PSEL_SPIM(reg, line) ((NRF_SPIM_Type *)reg)->PSEL.line #endif #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spis) #if defined(NRF51) #define NRF_PSEL_SPIS(reg, line) ((NRF_SPIS_Type *)reg)->PSEL##line #else #define NRF_PSEL_SPIS(reg, line) ((NRF_SPIS_Type *)reg)->PSEL.line #endif #endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spis) */ #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_twi) #if !defined(TWI_PSEL_SCL_CONNECT_Pos) #define NRF_PSEL_TWIM(reg, line) ((NRF_TWI_Type *)reg)->PSEL##line #else #define NRF_PSEL_TWIM(reg, line) ((NRF_TWI_Type *)reg)->PSEL.line #endif #elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_twim) #define NRF_PSEL_TWIM(reg, line) ((NRF_TWIM_Type *)reg)->PSEL.line #endif #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_i2s) #define NRF_PSEL_I2S(reg, line) ((NRF_I2S_Type *)reg)->PSEL.line #endif #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_pdm) #define NRF_PSEL_PDM(reg, line) ((NRF_PDM_Type *)reg)->PSEL.line #endif #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_pwm) #define NRF_PSEL_PWM(reg, line) ((NRF_PWM_Type *)reg)->PSEL.line #endif #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_qdec) #define NRF_PSEL_QDEC(reg, line) ((NRF_QDEC_Type *)reg)->PSEL.line #endif #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_qspi) #define NRF_PSEL_QSPI(reg, line) ((NRF_QSPI_Type *)reg)->PSEL.line #endif int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg) { for (uint8_t i = 0U; i < pin_cnt; i++) { nrf_gpio_pin_drive_t drive = NRF_GET_DRIVE(pins[i]); uint32_t psel = NRF_GET_PIN(pins[i]); uint32_t write = NO_WRITE; nrf_gpio_pin_dir_t dir; nrf_gpio_pin_input_t input; if (psel == NRF_PIN_DISCONNECTED) { psel = PSEL_DISCONNECTED; } switch (NRF_GET_FUN(pins[i])) { #if defined(NRF_PSEL_UART) case NRF_FUN_UART_TX: NRF_PSEL_UART(reg, TXD) = psel; write = 1U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_UART_RX: NRF_PSEL_UART(reg, RXD) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_UART_RTS: NRF_PSEL_UART(reg, RTS) = psel; write = 1U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_UART_CTS: NRF_PSEL_UART(reg, CTS) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* defined(NRF_PSEL_UART) */ #if defined(NRF_PSEL_SPIM) case NRF_FUN_SPIM_SCK: NRF_PSEL_SPIM(reg, SCK) = psel; write = 0U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_SPIM_MOSI: NRF_PSEL_SPIM(reg, MOSI) = psel; write = 0U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_SPIM_MISO: NRF_PSEL_SPIM(reg, MISO) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* defined(NRF_PSEL_SPIM) */ #if defined(NRF_PSEL_SPIS) case NRF_FUN_SPIS_SCK: NRF_PSEL_SPIS(reg, SCK) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_SPIS_MOSI: NRF_PSEL_SPIS(reg, MOSI) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_SPIS_MISO: NRF_PSEL_SPIS(reg, MISO) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_SPIS_CSN: NRF_PSEL_SPIS(reg, CSN) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* defined(NRF_PSEL_SPIS) */ #if defined(NRF_PSEL_TWIM) case NRF_FUN_TWIM_SCL: NRF_PSEL_TWIM(reg, SCL) = psel; if (drive == NRF_DRIVE_S0S1) { /* Override the default drive setting with one * suitable for TWI/TWIM peripherals (S0D1). * This drive cannot be used always so that * users are able to select e.g. H0D1 or E0E1 * in devicetree. */ drive = NRF_DRIVE_S0D1; } dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_TWIM_SDA: NRF_PSEL_TWIM(reg, SDA) = psel; if (drive == NRF_DRIVE_S0S1) { drive = NRF_DRIVE_S0D1; } dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* defined(NRF_PSEL_TWIM) */ #if defined(NRF_PSEL_I2S) case NRF_FUN_I2S_SCK_M: NRF_PSEL_I2S(reg, SCK) = psel; write = 0U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_I2S_SCK_S: NRF_PSEL_I2S(reg, SCK) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_I2S_LRCK_M: NRF_PSEL_I2S(reg, LRCK) = psel; write = 0U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_I2S_LRCK_S: NRF_PSEL_I2S(reg, LRCK) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_I2S_SDIN: NRF_PSEL_I2S(reg, SDIN) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_I2S_SDOUT: NRF_PSEL_I2S(reg, SDOUT) = psel; write = 0U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_I2S_MCK: NRF_PSEL_I2S(reg, MCK) = psel; write = 0U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; #endif /* defined(NRF_PSEL_I2S) */ #if defined(NRF_PSEL_PDM) case NRF_FUN_PDM_CLK: NRF_PSEL_PDM(reg, CLK) = psel; write = 0U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_PDM_DIN: NRF_PSEL_PDM(reg, DIN) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* defined(NRF_PSEL_PDM) */ #if defined(NRF_PSEL_PWM) case NRF_FUN_PWM_OUT0: NRF_PSEL_PWM(reg, OUT[0]) = psel; write = NRF_GET_INVERT(pins[i]); dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_PWM_OUT1: NRF_PSEL_PWM(reg, OUT[1]) = psel; write = NRF_GET_INVERT(pins[i]); dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_PWM_OUT2: NRF_PSEL_PWM(reg, OUT[2]) = psel; write = NRF_GET_INVERT(pins[i]); dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_PWM_OUT3: NRF_PSEL_PWM(reg, OUT[3]) = psel; write = NRF_GET_INVERT(pins[i]); dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; #endif /* defined(NRF_PSEL_PWM) */ #if defined(NRF_PSEL_QDEC) case NRF_FUN_QDEC_A: NRF_PSEL_QDEC(reg, A) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_QDEC_B: NRF_PSEL_QDEC(reg, B) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; case NRF_FUN_QDEC_LED: NRF_PSEL_QDEC(reg, LED) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* defined(NRF_PSEL_QDEC) */ #if defined(NRF_PSEL_QSPI) case NRF_FUN_QSPI_SCK: NRF_PSEL_QSPI(reg, SCK) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_QSPI_CSN: NRF_PSEL_QSPI(reg, CSN) = psel; write = 1U; dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_QSPI_IO0: NRF_PSEL_QSPI(reg, IO0) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_QSPI_IO1: NRF_PSEL_QSPI(reg, IO1) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_QSPI_IO2: NRF_PSEL_QSPI(reg, IO2) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; case NRF_FUN_QSPI_IO3: NRF_PSEL_QSPI(reg, IO3) = psel; dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; #endif /* defined(NRF_PSEL_QSPI) */ default: return -ENOTSUP; } /* configure GPIO properties */ if (psel != PSEL_DISCONNECTED) { uint32_t pin = psel; if (write != NO_WRITE) { nrf_gpio_pin_write(pin, write); } /* force input and disconnected buffer for low power */ if (NRF_GET_LP(pins[i]) == NRF_LP_ENABLE) { dir = NRF_GPIO_PIN_DIR_INPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; } nrf_gpio_cfg(pin, dir, input, NRF_GET_PULL(pins[i]), drive, NRF_GPIO_PIN_NOSENSE); } } return 0; }
#pragma once #ifndef SFMT_PARAMS19937_H #define SFMT_PARAMS19937_H #define SFMT_POS1 122 #define SFMT_SL1 18 #define SFMT_SL2 1 #define SFMT_SR1 11 #define SFMT_SR2 1 #define SFMT_MSK1 0xdfffffefU #define SFMT_MSK2 0xddfecb7fU #define SFMT_MSK3 0xbffaffffU #define SFMT_MSK4 0xbffffff6U #define SFMT_PARITY1 0x00000001U #define SFMT_PARITY2 0x00000000U #define SFMT_PARITY3 0x00000000U #define SFMT_PARITY4 0x13c9e684U /* PARAMETERS FOR ALTIVEC */ #if defined(__APPLE__) /* For OSX */ #define SFMT_ALTI_SL1 \ (vector unsigned int)(SFMT_SL1, SFMT_SL1, SFMT_SL1, SFMT_SL1) #define SFMT_ALTI_SR1 \ (vector unsigned int)(SFMT_SR1, SFMT_SR1, SFMT_SR1, SFMT_SR1) #define SFMT_ALTI_MSK \ (vector unsigned int)(SFMT_MSK1, SFMT_MSK2, SFMT_MSK3, SFMT_MSK4) #define SFMT_ALTI_MSK64 \ (vector unsigned int)(SFMT_MSK2, SFMT_MSK1, SFMT_MSK4, SFMT_MSK3) #define SFMT_ALTI_SL2_PERM \ (vector unsigned char)(1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8) #define SFMT_ALTI_SL2_PERM64 \ (vector unsigned char)(1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0) #define SFMT_ALTI_SR2_PERM \ (vector unsigned char)(7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14) #define SFMT_ALTI_SR2_PERM64 \ (vector unsigned char)(15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14) #else /* For OTHER OSs(Linux?) */ #define SFMT_ALTI_SL1 {SFMT_SL1, SFMT_SL1, SFMT_SL1, SFMT_SL1} #define SFMT_ALTI_SR1 {SFMT_SR1, SFMT_SR1, SFMT_SR1, SFMT_SR1} #define SFMT_ALTI_MSK {SFMT_MSK1, SFMT_MSK2, SFMT_MSK3, SFMT_MSK4} #define SFMT_ALTI_MSK64 {SFMT_MSK2, SFMT_MSK1, SFMT_MSK4, SFMT_MSK3} #define SFMT_ALTI_SL2_PERM {1,2,3,23,5,6,7,0,9,10,11,4,13,14,15,8} #define SFMT_ALTI_SL2_PERM64 {1,2,3,4,5,6,7,31,9,10,11,12,13,14,15,0} #define SFMT_ALTI_SR2_PERM {7,0,1,2,11,4,5,6,15,8,9,10,17,12,13,14} #define SFMT_ALTI_SR2_PERM64 {15,0,1,2,3,4,5,6,17,8,9,10,11,12,13,14} #endif /* For OSX */ #define SFMT_IDSTR "SFMT-19937:122-18-1-11-1:dfffffef-ddfecb7f-bffaffff-bffffff6" #endif /* SFMT_PARAMS19937_H */
/* start the copy function on the SP */ static int start_copy_on_sp(struct ia_css_pipe *pipe, struct ia_css_frame *out_frame) { (void)out_frame; if ((!pipe) || (!pipe->stream)) return -EINVAL; #if !defined(ISP2401) if (pipe->stream->reconfigure_css_rx) ia_css_isys_rx_disable(); #endif if (pipe->stream->config.input_config.format != ATOMISP_INPUT_FORMAT_BINARY_8) return -EINVAL; sh_css_sp_start_binary_copy(ia_css_pipe_get_pipe_num(pipe), out_frame, pipe->stream->config.pixels_per_clock == 2); #if !defined(ISP2401) if (pipe->stream->reconfigure_css_rx) { ia_css_isys_rx_configure(&pipe->stream->csi_rx_config, pipe->stream->config.mode); pipe->stream->reconfigure_css_rx = false; } #endif return 0; }
/* SymbolicC++ : An object oriented computer algebra system written in C++ Copyright (C) 2008 Yorick Hardy and Willi-Hans Steeb This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ // multinomial.h #ifndef _MULTINOMIAL #define _MULTINOMIAL #include <cassert> #include <iostream> #include <list> #include <sstream> #include <string> #include <utility> // for pair #include <vector> #include "identity.h" using namespace std; // Assumption : T has typecasts defined and can act as a numeric data type // Multinomial class template <class T> class Multinomial { public: Multinomial(): type(number),n(zero(T())) {} Multinomial(T); Multinomial(string x); Multinomial(const Multinomial<T> &p): variable(p.variable),type(p.type),n(p.n),u(p.u),m(p.m) {} Multinomial<T>& operator=(const T&); Multinomial<T>& operator=(const Multinomial<T>&); Multinomial<T> operator+() const; Multinomial<T> operator-() const; Multinomial<T> operator+(const Multinomial<T>&) const; Multinomial<T> operator-(const Multinomial<T>&) const; Multinomial<T> operator*(const Multinomial<T>&) const; Multinomial<T> operator+(const T&) const; Multinomial<T> operator-(const T&) const; Multinomial<T> operator*(const T&) const; Multinomial<T> operator^(unsigned int) const; Multinomial<T>& operator+=(const Multinomial<T>&); Multinomial<T>& operator-=(const Multinomial<T>&); Multinomial<T>& operator*=(const Multinomial<T>&); Multinomial<T>& operator+=(const T&); Multinomial<T>& operator-=(const T&); Multinomial<T>& operator*=(const T&); int operator==(const Multinomial<T>&) const; int operator!=(const Multinomial<T>&) const; int operator==(const T&) const; int operator!=(const T&) const; Multinomial<T> Diff(const string &) const; ostream &output(ostream &) const; protected: void remove_zeros(void); pair<Multinomial<T>,Multinomial<T> > reconcile(const Multinomial<T>&,const Multinomial<T>&) const; vector<string> toarray(void) const; string variable; enum { number, univariate, multivariate } type; T n; //number list<pair<T,int> > u; //univariate list<pair<Multinomial<T>,int> > m; //multivariate }; // additional functions that are not members of the class template <class T> Multinomial<T> operator+(const T&,const Multinomial<T>&); template <class T> Multinomial<T> operator-(const T&,const Multinomial<T>&); template <class T> Multinomial<T> operator*(const T&,const Multinomial<T>&); template <class T> int operator==(T,const Multinomial<T>&); template <class T> int operator!=(T,const Multinomial<T>&); // implementation template <class T> Multinomial<T>::Multinomial(T c) : variable(""), type(number), n(c) {} template <class T> Multinomial<T>::Multinomial(string x): variable(x),type(univariate) {u.push_back(pair<T,int>(one(T()),1));} template <class T> Multinomial<T>& Multinomial<T>::operator=(const T &c) {return *this = Multinomial<T>(c);} template <class T> Multinomial<T>& Multinomial<T>::operator=(const Multinomial<T> &p) { if(this == &p) return *this; variable = p.variable; type = p.type; u = p.u; m = p.m; return *this; } template <class T> Multinomial<T> Multinomial<T>::operator+() const {return *this;} template <class T> Multinomial<T> Multinomial<T>::operator-() const { Multinomial<T> p2(*this); typename list<pair<T,int> >::iterator i = p2.u.begin(); typename list<pair<T,int> >::iterator j = p2.m.begin(); for(;i!= p2.u.end();i++) i->first = -(i->first); for(;j!= p2.v.end();j++) j->first = -(j->first); return p2; } template <class T> list <pair<T,int> > merge(const list <pair<T,int> > &l1,const list <pair<T,int> > &l2) { list <pair<T,int> > l; typename list<pair<T,int> >::const_iterator i = l1.begin(); typename list<pair<T,int> >::const_iterator j = l2.begin(); while(i!=l1.end() && j!=l2.end()) { if (i->second<j->second) l.push_back(*(j++)); else if(i->second>j->second) l.push_back(*(i++)); else // i->second==j->second { l.push_back(make_pair(i->first + j->first,i->second)); i++; j++; } } while(i!=l1.end()) l.push_back(*(i++)); while(j!=l2.end()) l.push_back(*(j++)); return l; } template <class T> Multinomial<T> Multinomial<T>::operator+(const Multinomial<T> &p) const { Multinomial<T> p2; pair<Multinomial<T>,Multinomial<T> > xy = reconcile(*this,p); switch(xy.first.type) { case number: p2.type = number; p2.n = xy.first.n + xy.second.n; break; case univariate: p2.type = univariate; p2.variable = xy.first.variable; p2.u = merge(xy.first.u,xy.second.u); break; case multivariate: p2.type = multivariate; p2.variable = xy.first.variable; p2.m = merge(xy.first.m,xy.second.m); break; } p2.remove_zeros(); return p2; } template <class T> Multinomial<T> Multinomial<T>::operator-(const Multinomial<T> &p) const { return (*this) + (-p); } template <class T> list <pair<T,int> > distribute(const list <pair<T,int> > &l1,const list <pair<T,int> > &l2) { list <pair<T,int> > l; typename list<pair<T,int> >::const_iterator i; typename list<pair<T,int> >::const_iterator j; for(i=l1.begin();i!=l1.end();i++) { list <pair<T,int> > t; for(j=l2.begin();j!=l2.end();j++) t.push_back(make_pair(i->first * j->first,i->second + j->second)); l = merge(l,t); } return l; } template <class T> Multinomial<T> Multinomial<T>::operator*(const Multinomial<T> &p) const { Multinomial<T> p2; typename list<pair<T,int> >::const_iterator i, j; pair<Multinomial<T>,Multinomial<T> > xy = reconcile(*this,p); switch(xy.first.type) { case number: p2.type = number; p2.n = xy.first.n * xy.second.n; break; case univariate: p2.type = univariate; p2.variable = xy.first.variable; p2.u = distribute(xy.first.u,xy.second.u); break; case multivariate: p2.type = multivariate; p2.variable = xy.first.variable; p2.m = distribute(xy.first.m,xy.second.m); break; } p2.remove_zeros(); return p2; } template <class T> Multinomial<T> Multinomial<T>::operator^(unsigned int n) const { Multinomial<T> result(one(T())), factor(*this); while(n>0) { if(n%2 == 1) result *= factor; factor *= factor; n /= 2; } return result; } template <class T> Multinomial<T> Multinomial<T>::operator+(const T &c) const {return (*this) + Multinomial<T>(c);} template <class T> Multinomial<T> Multinomial<T>::operator-(const T &c) const {return (*this) - Multinomial<T>(c);} template <class T> Multinomial<T> Multinomial<T>::operator*(const T &c) const {return (*this) * Multinomial<T>(c);} template <class T> Multinomial<T>& Multinomial<T>::operator+=(const Multinomial<T> &p) {return *this = *this + p;} template <class T> Multinomial<T>& Multinomial<T>::operator-=(const Multinomial<T> &p) {return *this = *this - p;} template <class T> Multinomial<T>& Multinomial<T>::operator*=(const Multinomial<T> &p) {return *this = *this * p;} template <class T> Multinomial<T> &Multinomial<T>::operator+=(const T &c) {*this += Multinomial<T>(c);} template <class T> Multinomial<T> &Multinomial<T>::operator-=(const T &c) {*this -= Multinomial<T>(c);} template <class T> Multinomial<T> &Multinomial<T>::operator*=(const T &c) {*this *= Multinomial<T>(c);} template <class T> T Diff(const T &t,const string &x) {return zero(T());} // partial template specialization for polynomials template <class T> Multinomial<T> Diff(const Multinomial<T>&p,const string &x) {return p.Diff(x);} template <class T> Multinomial<T> Multinomial<T>::Diff(const string &x) const { Multinomial<T> p2; typename list<pair<T,int> >::const_iterator i = u.begin(); typename list<pair<Multinomial<T>,int> >::const_iterator j = m.begin(); if(type==number) return Multinomial<T>(zero(T())); if(type==univariate) { if(variable!=x) return Multinomial<T>(zero(T())); p2.variable = variable; p2.type = univariate; for(;i!=u.end();i++) p2.u.push_back(make_pair(i->first * T(i->second),i->second-1)); } if(type == multivariate) { p2.variable = variable; p2.type = multivariate; if(variable==x) for(;j!=m.end();j++) p2.m.push_back(make_pair(j->first * T(j->second),j->second-1)); else for(;j!=m.end();j++) p2.m.push_back(make_pair(j->first.Diff(x),j->second)); } p2.remove_zeros(); return p2; } template <class T> int Multinomial<T>::operator==(const Multinomial<T> &p) const { pair<Multinomial<T>,Multinomial<T> > xy = reconcile(*this,p); xy.first.remove_zeros(); xy.second.remove_zeros(); switch(xy.first.type) { case number: return xy.first.n == xy.second.n; break; case univariate: return xy.first.u == xy.second.u; break; case multivariate: return xy.first.m == xy.second.m; break; } return 0; } template <class T> int Multinomial<T>::operator!=(const Multinomial<T> &p) const {return !(*this == p);} template <class T> int Multinomial<T>::operator==(const T &c) const {return *this == Multinomial<T>(c);} template <class T> int Multinomial<T>::operator!=(const T &c) const {return !(*this == c);} template <class T> vector<string> Multinomial<T>::toarray(void) const { ostringstream o; vector<string> v; typename list<pair<T,int> >::const_iterator i = u.begin(); typename list<pair<Multinomial<T>,int> >::const_iterator j = m.begin(); switch(type) { case number: o << n; v.push_back(o.str()); break; case univariate: if(i==u.end()) v.push_back("0"); while(i!=u.end()) { if(i->first!=one(T()) || i->second==0) o << "(" << i->first << ")"; if(i->second>0) o << variable; if(i->second>1) o << "^" << i->second; v.push_back(o.str()); o.str(""); i++; } break; case multivariate: if(j==m.end()) v.push_back("0"); while(j!=m.end()) { if(j->second>0) o << variable; if(j->second>1) o << "^" << j->second; if(j->first!=one(T()) || j->second==0) { vector<string> v1 = j->first.toarray(); for(int k=0;k<int(v1.size());k++) v.push_back(v1[k] + o.str()); } o.str(""); j++; } break; } return v; } template <class T> ostream &Multinomial<T>::output(ostream &o) const { int k; typename list<pair<T,int> >::const_iterator i = u.begin(); switch(type) { case number: o << n; break; case univariate: if(i==u.end()) o << "0"; while(i!=u.end()) { if(i->first!=one(T()) || i->second==0) o << "(" << i->first << ")"; if(i->second>0) o << variable; if(i->second>1) o << "^" << i->second; if(!(++i==u.end())) o << " + "; } break; case multivariate: vector<string> v = toarray(); for(k=0;k<int(v.size())-1;k++) o << v[k] << " + "; if(k<int(v.size())) o << v[k]; else o << "0"; break; } return o; } template <class T> ostream &operator<<(ostream &o,const Multinomial<T> &p) {return p.output(o);} template <class T> void Multinomial<T>::remove_zeros(void) { { typename list<pair<T,int> >::iterator i, j; for(i=j=u.begin();i!=u.end();) { j++; if(i->first==zero(T())) u.erase(i); i=j; } } { typename list<pair<Multinomial<T>,int> >::iterator i, j; for(i=j=m.begin();i!=m.end();) { j++; i->first.remove_zeros(); if(i->first==zero(T())) m.erase(i); i=j; } } } template <class T> pair<Multinomial<T>,Multinomial<T> > Multinomial<T>::reconcile(const Multinomial<T> &x, const Multinomial<T> &y) const { if(x.type==number && y.type==number) return make_pair(x,y); if(x.type==number && y.type==univariate) { if(y.u.empty()) return make_pair(x,Multinomial<T>(zero(T()))); Multinomial<T> t(y.variable); t.u.clear(); t.u.push_back(make_pair(x.n,0)); return make_pair(t,y); } if(x.type==number && y.type==multivariate) { if(y.m.empty()) return make_pair(x,Multinomial<T>(zero(T()))); Multinomial<T> t(y.variable); t.u.clear(); t.u.push_back(make_pair(x.n,0)); return reconcile(t,y); } if(x.type==univariate && y.type==univariate) { if(x.variable==y.variable) return make_pair(x,y); if(x.variable< y.variable) { Multinomial<T> t1(y.variable); Multinomial<T> t2(y.variable); t1.type = t2.type = multivariate; t1.u.clear(); t1.m.push_back(make_pair(x,0)); typename list<pair<T,int> >::const_iterator i = y.u.begin(); for(;i!=y.u.end();i++) { Multinomial<T> t3(x.variable); t3.u.clear(); t3.u.push_back(make_pair(i->first,0)); t2.m.push_back(make_pair(t3,i->second)); } return make_pair(t1,t2); } else { Multinomial<T> t1(x.variable); Multinomial<T> t2(x.variable); t1.type = t2.type = multivariate; t2.u.clear(); t2.m.push_back(make_pair(y,0)); typename list<pair<T,int> >::const_iterator i = x.u.begin(); for(;i!=x.u.end();i++) { Multinomial<T> t3(y.variable); t3.u.clear(); t3.u.push_back(make_pair(i->first,0)); t1.m.push_back(make_pair(t3,i->second)); } return make_pair(t1,t2); } } if(x.type==univariate && y.type==multivariate) { if(y.m.empty()) { Multinomial<T> t(x.variable); t.u.clear(); return make_pair(x,t); } if(x.variable==y.variable) return make_pair(reconcile(x,y.m.front().first).first,y); if(x.variable< y.variable) { Multinomial<T> t(y.variable); t.type = multivariate; t.u.clear(); t.m.push_back(make_pair(x,0)); return make_pair(t,y); } else { Multinomial<T> t(x.variable); t.type = multivariate; t.u.clear(); typename list<pair<T,int> >::const_iterator i = x.u.begin(); for(;i!=x.u.end();i++) { Multinomial<T> t3(y.m.front().first.variable); t3.u.clear(); t3.u.push_back(make_pair(i->first,0)); t.m.push_back(make_pair(t3,i->second)); } return reconcile(t,y); } } if(x.type==multivariate && y.type==multivariate) { if(x.variable==y.variable) return make_pair(x,y); if(x.variable< y.variable) { Multinomial<T> t(y.variable); t.type = multivariate; t.u.clear(); t.m.push_back(make_pair(x,0)); return make_pair(t,y); } else { Multinomial<T> t(x.variable); t.type = multivariate; t.u.clear(); t.m.push_back(make_pair(y,0)); return make_pair(x,t); } } pair<Multinomial<T>,Multinomial<T> > p; p = reconcile(y,x); return make_pair(p.second,p.first); } // additional functions that are not members of the class template <class T> Multinomial<T> operator+(const T &c,const Multinomial<T> &p) {return Multinomial<T>(c) + p;} template <class T> Multinomial<T> operator-(const T &c,const Multinomial<T> &p) {return Multinomial<T>(c) - p;} template <class T> Multinomial<T> operator*(const T &c,const Multinomial<T> &p) {return Multinomial<T>(c) * p;} template <class T> int operator==(const T &c,const Multinomial<T> &p) {return p == c;} template <class T> int operator!=(const T &c,const Multinomial<T> &p) {return p != c;} template <class T> Multinomial<T> zero(Multinomial<T>) {return Multinomial<T>(zero(T()));} template <class T> Multinomial<T> one(Multinomial<T>) {return Multinomial<T>(one(T()));} #endif
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. */ #include <stdio.h> #define import_spp #define import_kernel #include <iraf.h> #include "osproto.h" #define SZ_PROCNAME 256 /* Allocate ZFD, the global data structure for the kernel file i/o system. * Also allocate a buffer for the process name, used by the error handling * code to identify the process generating an abort. */ struct fiodes zfd[MAXOFILES]; char os_process_name[SZ_PROCNAME]; PKCHAR osfn_bkgfile[SZ_PATHNAME/sizeof(PKCHAR)+1]; int save_prtype = 0; char oscwd[SZ_PATHNAME+1] = "";
/** checks all cumulative constraints for infeasibility and add branching candidates to storage */ static SCIP_RETCODE collectBranchingCands( SCIP* scip, SCIP_CONS** conss, int nconss, SCIP_SOL* sol, int* nbranchcands ) { SCIP_HASHTABLE* collectedvars; int c; assert(scip != NULL); assert(conss != NULL); SCIP_CALL( SCIPhashtableCreate(&collectedvars, SCIPblkmem(scip), SCIPgetNVars(scip), SCIPvarGetHashkey, SCIPvarIsHashkeyEq, SCIPvarGetHashkeyVal, NULL) ); assert(scip != NULL); assert(conss != NULL); for( c = 0; c < nconss; ++c ) { SCIP_CONS* cons; SCIP_CONSDATA* consdata; int curtime; int j; cons = conss[c]; assert(cons != NULL); if( !SCIPconsIsActive(cons) ) continue; consdata = SCIPconsGetData(cons); assert(consdata != NULL); SCIP_CALL( computePeak(scip, consdata, sol, &curtime) ); if( curtime < consdata->hmin || curtime >= consdata->hmax ) continue; for( j = 0; j < consdata->nvars; ++j ) { SCIP_VAR* var; int lb; int ub; var = consdata->vars[j]; assert(var != NULL); if( SCIPhashtableExists(collectedvars, (void*)var) ) continue; lb = SCIPconvertRealToInt(scip, SCIPvarGetLbLocal(var)); ub = SCIPconvertRealToInt(scip, SCIPvarGetUbLocal(var)); if( lb <= curtime && ub + consdata->durations[j] > curtime && lb < ub ) { SCIP_Real solval; SCIP_Real score; solval = SCIPgetSolVal(scip, sol, var); score = MIN(solval - lb, ub - solval) / ((SCIP_Real)ub-lb); SCIPdebugMsg(scip, "add var <%s> to branch cand storage\n", SCIPvarGetName(var)); SCIP_CALL( SCIPaddExternBranchCand(scip, var, score, lb + (ub - lb) / 2.0 + 0.2) ); (*nbranchcands)++; SCIP_CALL( SCIPhashtableInsert(collectedvars, var) ); } } } SCIPhashtableFree(&collectedvars); SCIPdebugMsg(scip, "found %d branching candidates\n", *nbranchcands); return SCIP_OKAY; }
/* Delete one file or link - Internal method */ int zapFileM(const char *path, int iMode, zapOpts *pzo) { int iFlags = pzo->iFlags; char *pszSuffix = ""; int iErr = 0; DEBUG_ENTER(("zapFileM(\"%s\", 0x%04X);\n", path, iMode)); if (S_ISDIR(iMode)) { errno = EISDIR; iErr = 1; goto cleanup_and_return; } #if defined(S_ISLNK) && S_ISLNK(S_IFLNK) if (S_ISLNK(iMode)) { pszSuffix = ">"; } #endif if (iFlags & FLAG_VERBOSE) printf("%s%s%s\n", pzo->pszPrefix, path, pszSuffix); if (iFlags & FLAG_NOEXEC) RETURN_INT(0); if (iFlags & FLAG_FORCE) { if (!(iMode & S_IWRITE)) { iMode |= S_IWRITE; DEBUG_PRINTF(("chmod(%p, 0x%X);\n", path, iMode)); iErr = -chmod(path, iMode); DEBUG_PRINTF((" return %d; // errno = %d\n", iErr, errno)); } if (iErr) goto cleanup_and_return; } iErr = -unlink(path); cleanup_and_return: if (iErr) { printError("Error deleting \"%s\": %s", path, strerror(errno)); } else { if (pzo->pNDeleted) *(pzo->pNDeleted) += 1; } RETURN_INT(iErr); }
/* * PCM timer handling on ctxfi * * This source file is released under GPL v2 license (no other versions). * See the COPYING file included in the main directory of this source * distribution for the license terms and conditions. */ #include <linux/slab.h> #include <linux/math64.h> #include <linux/moduleparam.h> #include <sound/core.h> #include <sound/pcm.h> #include "ctatc.h" #include "cthardware.h" #include "cttimer.h" static bool use_system_timer; MODULE_PARM_DESC(use_system_timer, "Force to use system-timer"); module_param(use_system_timer, bool, S_IRUGO); struct ct_timer_ops { void (*init)(struct ct_timer_instance *); void (*prepare)(struct ct_timer_instance *); void (*start)(struct ct_timer_instance *); void (*stop)(struct ct_timer_instance *); void (*free_instance)(struct ct_timer_instance *); void (*interrupt)(struct ct_timer *); void (*free_global)(struct ct_timer *); }; /* timer instance -- assigned to each PCM stream */ struct ct_timer_instance { spinlock_t lock; struct ct_timer *timer_base; struct ct_atc_pcm *apcm; struct snd_pcm_substream *substream; struct timer_list timer; struct list_head instance_list; struct list_head running_list; unsigned int position; unsigned int frag_count; unsigned int running:1; unsigned int need_update:1; }; /* timer instance manager */ struct ct_timer { spinlock_t lock; /* global timer lock (for xfitimer) */ spinlock_t list_lock; /* lock for instance list */ struct ct_atc *atc; struct ct_timer_ops *ops; struct list_head instance_head; struct list_head running_head; unsigned int wc; /* current wallclock */ unsigned int irq_handling:1; /* in IRQ handling */ unsigned int reprogram:1; /* need to reprogram the internval */ unsigned int running:1; /* global timer running */ }; /* * system-timer-based updates */ static void ct_systimer_callback(unsigned long data) { struct ct_timer_instance *ti = (struct ct_timer_instance *)data; struct snd_pcm_substream *substream = ti->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct ct_atc_pcm *apcm = ti->apcm; unsigned int period_size = runtime->period_size; unsigned int buffer_size = runtime->buffer_size; unsigned long flags; unsigned int position, dist, interval; position = substream->ops->pointer(substream); dist = (position + buffer_size - ti->position) % buffer_size; if (dist >= period_size || position / period_size != ti->position / period_size) { apcm->interrupt(apcm); ti->position = position; } /* Add extra HZ*5/1000 to avoid overrun issue when recording * at 8kHz in 8-bit format or at 88kHz in 24-bit format. */ interval = ((period_size - (position % period_size)) * HZ + (runtime->rate - 1)) / runtime->rate + HZ * 5 / 1000; spin_lock_irqsave(&ti->lock, flags); if (ti->running) mod_timer(&ti->timer, jiffies + interval); spin_unlock_irqrestore(&ti->lock, flags); } static void ct_systimer_init(struct ct_timer_instance *ti) { setup_timer(&ti->timer, ct_systimer_callback, (unsigned long)ti); } static void ct_systimer_start(struct ct_timer_instance *ti) { struct snd_pcm_runtime *runtime = ti->substream->runtime; unsigned long flags; spin_lock_irqsave(&ti->lock, flags); ti->running = 1; mod_timer(&ti->timer, jiffies + (runtime->period_size * HZ + (runtime->rate - 1)) / runtime->rate); spin_unlock_irqrestore(&ti->lock, flags); } static void ct_systimer_stop(struct ct_timer_instance *ti) { unsigned long flags; spin_lock_irqsave(&ti->lock, flags); ti->running = 0; del_timer(&ti->timer); spin_unlock_irqrestore(&ti->lock, flags); } static void ct_systimer_prepare(struct ct_timer_instance *ti) { ct_systimer_stop(ti); try_to_del_timer_sync(&ti->timer); } #define ct_systimer_free ct_systimer_prepare static struct ct_timer_ops ct_systimer_ops = { .init = ct_systimer_init, .free_instance = ct_systimer_free, .prepare = ct_systimer_prepare, .start = ct_systimer_start, .stop = ct_systimer_stop, }; /* * Handling multiple streams using a global emu20k1 timer irq */ #define CT_TIMER_FREQ 48000 #define MIN_TICKS 1 #define MAX_TICKS ((1 << 13) - 1) static void ct_xfitimer_irq_rearm(struct ct_timer *atimer, int ticks) { struct hw *hw = atimer->atc->hw; if (ticks > MAX_TICKS) ticks = MAX_TICKS; hw->set_timer_tick(hw, ticks); if (!atimer->running) hw->set_timer_irq(hw, 1); atimer->running = 1; } static void ct_xfitimer_irq_stop(struct ct_timer *atimer) { if (atimer->running) { struct hw *hw = atimer->atc->hw; hw->set_timer_irq(hw, 0); hw->set_timer_tick(hw, 0); atimer->running = 0; } } static inline unsigned int ct_xfitimer_get_wc(struct ct_timer *atimer) { struct hw *hw = atimer->atc->hw; return hw->get_wc(hw); } /* * reprogram the timer interval; * checks the running instance list and determines the next timer interval. * also updates the each stream position, returns the number of streams * to call snd_pcm_period_elapsed() appropriately * * call this inside the lock and irq disabled */ static int ct_xfitimer_reprogram(struct ct_timer *atimer, int can_update) { struct ct_timer_instance *ti; unsigned int min_intr = (unsigned int)-1; int updates = 0; unsigned int wc, diff; if (list_empty(&atimer->running_head)) { ct_xfitimer_irq_stop(atimer); atimer->reprogram = 0; /* clear flag */ return 0; } wc = ct_xfitimer_get_wc(atimer); diff = wc - atimer->wc; atimer->wc = wc; list_for_each_entry(ti, &atimer->running_head, running_list) { if (ti->frag_count > diff) ti->frag_count -= diff; else { unsigned int pos; unsigned int period_size, rate; period_size = ti->substream->runtime->period_size; rate = ti->substream->runtime->rate; pos = ti->substream->ops->pointer(ti->substream); if (pos / period_size != ti->position / period_size) { ti->need_update = 1; ti->position = pos; updates++; } pos %= period_size; pos = period_size - pos; ti->frag_count = div_u64((u64)pos * CT_TIMER_FREQ + rate - 1, rate); } if (ti->need_update && !can_update) min_intr = 0; /* pending to the next irq */ if (ti->frag_count < min_intr) min_intr = ti->frag_count; } if (min_intr < MIN_TICKS) min_intr = MIN_TICKS; ct_xfitimer_irq_rearm(atimer, min_intr); atimer->reprogram = 0; /* clear flag */ return updates; } /* look through the instance list and call period_elapsed if needed */ static void ct_xfitimer_check_period(struct ct_timer *atimer) { struct ct_timer_instance *ti; unsigned long flags; spin_lock_irqsave(&atimer->list_lock, flags); list_for_each_entry(ti, &atimer->instance_head, instance_list) { if (ti->running && ti->need_update) { ti->need_update = 0; ti->apcm->interrupt(ti->apcm); } } spin_unlock_irqrestore(&atimer->list_lock, flags); } /* Handle timer-interrupt */ static void ct_xfitimer_callback(struct ct_timer *atimer) { int update; unsigned long flags; spin_lock_irqsave(&atimer->lock, flags); atimer->irq_handling = 1; do { update = ct_xfitimer_reprogram(atimer, 1); spin_unlock(&atimer->lock); if (update) ct_xfitimer_check_period(atimer); spin_lock(&atimer->lock); } while (atimer->reprogram); atimer->irq_handling = 0; spin_unlock_irqrestore(&atimer->lock, flags); } static void ct_xfitimer_prepare(struct ct_timer_instance *ti) { ti->frag_count = ti->substream->runtime->period_size; ti->running = 0; ti->need_update = 0; } /* start/stop the timer */ static void ct_xfitimer_update(struct ct_timer *atimer) { unsigned long flags; spin_lock_irqsave(&atimer->lock, flags); if (atimer->irq_handling) { /* reached from IRQ handler; let it handle later */ atimer->reprogram = 1; spin_unlock_irqrestore(&atimer->lock, flags); return; } ct_xfitimer_irq_stop(atimer); ct_xfitimer_reprogram(atimer, 0); spin_unlock_irqrestore(&atimer->lock, flags); } static void ct_xfitimer_start(struct ct_timer_instance *ti) { struct ct_timer *atimer = ti->timer_base; unsigned long flags; spin_lock_irqsave(&atimer->lock, flags); if (list_empty(&ti->running_list)) atimer->wc = ct_xfitimer_get_wc(atimer); ti->running = 1; ti->need_update = 0; list_add(&ti->running_list, &atimer->running_head); spin_unlock_irqrestore(&atimer->lock, flags); ct_xfitimer_update(atimer); } static void ct_xfitimer_stop(struct ct_timer_instance *ti) { struct ct_timer *atimer = ti->timer_base; unsigned long flags; spin_lock_irqsave(&atimer->lock, flags); list_del_init(&ti->running_list); ti->running = 0; spin_unlock_irqrestore(&atimer->lock, flags); ct_xfitimer_update(atimer); } static void ct_xfitimer_free_global(struct ct_timer *atimer) { ct_xfitimer_irq_stop(atimer); } static struct ct_timer_ops ct_xfitimer_ops = { .prepare = ct_xfitimer_prepare, .start = ct_xfitimer_start, .stop = ct_xfitimer_stop, .interrupt = ct_xfitimer_callback, .free_global = ct_xfitimer_free_global, }; /* * timer instance */ struct ct_timer_instance * ct_timer_instance_new(struct ct_timer *atimer, struct ct_atc_pcm *apcm) { struct ct_timer_instance *ti; ti = kzalloc(sizeof(*ti), GFP_KERNEL); if (!ti) return NULL; spin_lock_init(&ti->lock); INIT_LIST_HEAD(&ti->instance_list); INIT_LIST_HEAD(&ti->running_list); ti->timer_base = atimer; ti->apcm = apcm; ti->substream = apcm->substream; if (atimer->ops->init) atimer->ops->init(ti); spin_lock_irq(&atimer->list_lock); list_add(&ti->instance_list, &atimer->instance_head); spin_unlock_irq(&atimer->list_lock); return ti; } void ct_timer_prepare(struct ct_timer_instance *ti) { if (ti->timer_base->ops->prepare) ti->timer_base->ops->prepare(ti); ti->position = 0; ti->running = 0; } void ct_timer_start(struct ct_timer_instance *ti) { struct ct_timer *atimer = ti->timer_base; atimer->ops->start(ti); } void ct_timer_stop(struct ct_timer_instance *ti) { struct ct_timer *atimer = ti->timer_base; atimer->ops->stop(ti); } void ct_timer_instance_free(struct ct_timer_instance *ti) { struct ct_timer *atimer = ti->timer_base; atimer->ops->stop(ti); /* to be sure */ if (atimer->ops->free_instance) atimer->ops->free_instance(ti); spin_lock_irq(&atimer->list_lock); list_del(&ti->instance_list); spin_unlock_irq(&atimer->list_lock); kfree(ti); } /* * timer manager */ static void ct_timer_interrupt(void *data, unsigned int status) { struct ct_timer *timer = data; /* Interval timer interrupt */ if ((status & IT_INT) && timer->ops->interrupt) timer->ops->interrupt(timer); } struct ct_timer *ct_timer_new(struct ct_atc *atc) { struct ct_timer *atimer; struct hw *hw; atimer = kzalloc(sizeof(*atimer), GFP_KERNEL); if (!atimer) return NULL; spin_lock_init(&atimer->lock); spin_lock_init(&atimer->list_lock); INIT_LIST_HEAD(&atimer->instance_head); INIT_LIST_HEAD(&atimer->running_head); atimer->atc = atc; hw = atc->hw; if (!use_system_timer && hw->set_timer_irq) { snd_printd(KERN_INFO "ctxfi: Use xfi-native timer\n"); atimer->ops = &ct_xfitimer_ops; hw->irq_callback_data = atimer; hw->irq_callback = ct_timer_interrupt; } else { snd_printd(KERN_INFO "ctxfi: Use system timer\n"); atimer->ops = &ct_systimer_ops; } return atimer; } void ct_timer_free(struct ct_timer *atimer) { struct hw *hw = atimer->atc->hw; hw->irq_callback = NULL; if (atimer->ops->free_global) atimer->ops->free_global(atimer); kfree(atimer); }
/* source: xio-termios.h */ /* Copyright Gerhard Rieger */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __xio_termios_h_included #define __xio_termios_h_included 1 extern const struct optdesc opt_tiocsctty; extern const struct optdesc opt_brkint; extern const struct optdesc opt_icrnl; extern const struct optdesc opt_ignbrk; extern const struct optdesc opt_igncr; extern const struct optdesc opt_ignpar; extern const struct optdesc opt_imaxbel; extern const struct optdesc opt_inlcr; extern const struct optdesc opt_inpck; extern const struct optdesc opt_istrip; extern const struct optdesc opt_iuclc; extern const struct optdesc opt_ixany; extern const struct optdesc opt_ixoff; extern const struct optdesc opt_ixon; extern const struct optdesc opt_parmrk; extern const struct optdesc opt_cr0; extern const struct optdesc opt_cr1; extern const struct optdesc opt_cr2; extern const struct optdesc opt_cr3; extern const struct optdesc opt_crdly; extern const struct optdesc opt_nl0; extern const struct optdesc opt_nl1; extern const struct optdesc opt_nldly; extern const struct optdesc opt_ocrnl; extern const struct optdesc opt_ofdel; extern const struct optdesc opt_ofill; extern const struct optdesc opt_opost; extern const struct optdesc opt_olcuc; extern const struct optdesc opt_onlcr; extern const struct optdesc opt_onlret; extern const struct optdesc opt_onocr; extern const struct optdesc opt_tab0; extern const struct optdesc opt_tab1; extern const struct optdesc opt_tab2; extern const struct optdesc opt_tab3; extern const struct optdesc opt_xtabs; extern const struct optdesc opt_tabdly; extern const struct optdesc opt_bs0; extern const struct optdesc opt_bs1; extern const struct optdesc opt_bsdly; extern const struct optdesc opt_vt0; extern const struct optdesc opt_vt1; extern const struct optdesc opt_vtdly; extern const struct optdesc opt_ff0; extern const struct optdesc opt_ff1; extern const struct optdesc opt_ffdly; extern const struct optdesc opt_b0; extern const struct optdesc opt_b50; extern const struct optdesc opt_b75; extern const struct optdesc opt_b110; extern const struct optdesc opt_b134; extern const struct optdesc opt_b150; extern const struct optdesc opt_b200; extern const struct optdesc opt_b300; extern const struct optdesc opt_b600; extern const struct optdesc opt_b900; extern const struct optdesc opt_b1200; extern const struct optdesc opt_b1800; extern const struct optdesc opt_b2400; extern const struct optdesc opt_b3600; extern const struct optdesc opt_b4800; extern const struct optdesc opt_b7200; extern const struct optdesc opt_b9600; extern const struct optdesc opt_b19200; extern const struct optdesc opt_b38400; extern const struct optdesc opt_b57600; extern const struct optdesc opt_b115200; extern const struct optdesc opt_b230400; extern const struct optdesc opt_b460800; extern const struct optdesc opt_b500000; extern const struct optdesc opt_b576000; extern const struct optdesc opt_b921600; extern const struct optdesc opt_b1000000; extern const struct optdesc opt_b1152000; extern const struct optdesc opt_b1500000; extern const struct optdesc opt_b2000000; extern const struct optdesc opt_b2500000; extern const struct optdesc opt_b3000000; extern const struct optdesc opt_b3500000; extern const struct optdesc opt_b4000000; extern const struct optdesc opt_cs5; extern const struct optdesc opt_cs6; extern const struct optdesc opt_cs7; extern const struct optdesc opt_cs8; extern const struct optdesc opt_csize; extern const struct optdesc opt_cstopb; extern const struct optdesc opt_cread; extern const struct optdesc opt_parenb; extern const struct optdesc opt_parodd; extern const struct optdesc opt_hupcl; extern const struct optdesc opt_clocal; /*extern const struct optdesc opt_cibaud*/ extern const struct optdesc opt_crtscts; extern const struct optdesc opt_isig; extern const struct optdesc opt_icanon; extern const struct optdesc opt_xcase; extern const struct optdesc opt_echo; extern const struct optdesc opt_echoe; extern const struct optdesc opt_echok; extern const struct optdesc opt_echonl; extern const struct optdesc opt_echoctl; extern const struct optdesc opt_echoprt; extern const struct optdesc opt_echoke; extern const struct optdesc opt_flusho; extern const struct optdesc opt_noflsh; extern const struct optdesc opt_tostop; extern const struct optdesc opt_pendin; extern const struct optdesc opt_iexten; extern const struct optdesc opt_vintr; extern const struct optdesc opt_vquit; extern const struct optdesc opt_verase; extern const struct optdesc opt_vkill; extern const struct optdesc opt_veof; extern const struct optdesc opt_vtime; extern const struct optdesc opt_vmin; extern const struct optdesc opt_vswtc; extern const struct optdesc opt_vstart; extern const struct optdesc opt_vstop; extern const struct optdesc opt_vsusp; extern const struct optdesc opt_vdsusp; extern const struct optdesc opt_veol; extern const struct optdesc opt_vreprint; extern const struct optdesc opt_vdiscard; extern const struct optdesc opt_vwerase; extern const struct optdesc opt_vlnext; extern const struct optdesc opt_veol2; extern const struct optdesc opt_raw; extern const struct optdesc opt_sane; extern const struct optdesc opt_ispeed; extern const struct optdesc opt_ospeed; extern const struct optdesc opt_termios_rawer; extern const struct optdesc opt_termios_cfmakeraw; #if _WITH_TERMIOS /* otherwise tcflag_t might be reported undefined */ extern int xiotermios_setflag(int fd, int word, tcflag_t mask); extern int xiotermios_clrflag(int fd, int word, tcflag_t mask); extern int xiotermiosflag_applyopt(int fd, struct opt *opt); #endif /* _WITH_TERMIOS */ #endif /* !defined(__xio_termios_h_included) */
/* <command acl="ppad" helptopics="printer"> <name><word>deffiltopts</word></name> <desc>update a printer's default filter options</desc> <args> <arg><name>printer</name><desc>printer to update</desc></arg> </args> </command> */ int command_deffiltopts(const char *argv[]) { const char *printer = argv[0]; struct CONF_OBJ *obj; if(!(obj = conf_open(QUEUE_TYPE_PRINTER, printer, CONF_MODIFY | CONF_ENOENT_PRINT))) return EXIT_BADDEST; { void *qobj = NULL; char *line; gu_Try { if(!(qobj = queueinfo_new_load_config(QUEUEINFO_PRINTER, printer))) gu_Throw(_("Printer \"%s\" does not exist."), printer); queueinfo_set_warnings_file(qobj, stderr); queueinfo_set_debug_level(qobj, debug_level); while((line = conf_getline(obj))) { if(lmatch(line, "DefFiltOpts:")) continue; conf_printf(obj, "%s\n", line); } { const char *p; if((p = queueinfo_computedDefaultFilterOptions(qobj))) conf_printf(obj, "DefFiltOpts: %s\n", p); } conf_close(obj); } gu_Final { if(qobj) queueinfo_free(qobj); } gu_Catch { conf_abort(obj); gu_utf8_fprintf(stderr, "%s: %s\n", myname, gu_exception); return exception_to_exitcode(gu_exception_code); } } return EXIT_OK; }
#include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct{ int idx; int width; }cell; int stack[200001]; char str[400001]; cell arr[200001]; int top=0; void push(int val) { stack[top++]=val; } int pop() { return stack[--top]; } int comparator(const void* p,const void* q) { cell* l=(cell *)p; cell* r=(cell *)q; return l->width-r->width; } int main() { //freopen("program.txt","r",stdin); int num; scanf("%d",&num); int i,j=0,k; for(i=0;i<num;i++) { scanf("%d",&arr[i].width); arr[i].idx=i+1; } qsort(arr,num,sizeof(cell),comparator); /*for(i=0;i<num;i++) printf("%d ",arr[i].width); printf("\n");*/ char c; getchar(); for(i=0;i<num+num;i++) { scanf("%c",&c); if(c=='0') { printf("%d ",arr[j].idx); push(arr[j].idx); j++; } else if(c=='1') { printf("%d ",pop()); } } return 0; }
/* Converts a string to an integer. Returns a pointer to the first character not processed. Stores the resulting value in *VAL. If there was an error during conversion, *valPtr is AError and t contains the exception. */ unsigned char *AStrToInt(AThread *t, const unsigned char *beg, const unsigned char *end, AValue *valPtr) { AValue num; ABool isNeg; const unsigned char *str; num = 0; isNeg = FALSE; while (beg != end && (*beg == ' ' || *beg == '\t')) beg++; if (beg < end - 1) { if (*beg == '-') { isNeg = TRUE; beg++; } else if (*beg == '+') beg++; } for (str = beg; str != end && AIsDigit(*str); str++) { int digit = *str - '0'; if (num >= (A_SHORT_INT_MAX + 1) / 10 && (num > (A_SHORT_INT_MAX + 1) / 10 || digit > ((A_SHORT_INT_MAX + 1) - ((A_SHORT_INT_MAX + 1) / 10) * 10))) goto ConvertLongInt; num = num * 10 + digit; } if (str == beg) *valPtr = ARaiseValueErrorND(t, NULL); else if (isNeg) *valPtr = AIntToValue(-num); else if (num == A_SHORT_INT_MAX + 1) *valPtr = ACreateLongIntFromIntND(t, num); else *valPtr = AIntToValue(num); return (unsigned char *)str; ConvertLongInt: { ALongInt *li; AValue val; val = ACreateLongIntFromIntND(t, num); if (AIsError(val)) goto Error; li = AValueToLongInt(val); do { li = AMulAddSingle(t, li, 10, *str - '0'); if (li == NULL) goto Error; str++; } while (str != end && AIsDigit(*str)); *valPtr = ALongIntToValue(li); return (unsigned char *)str; } Error: while (str != end && AIsDigit(*str)) str++; *valPtr = AError; return (unsigned char *)str; }
/******************************************************************************* ** ** Function btu_hcif_flush_cmd_queue ** ** Description Flush the HCI command complete queue and transmit queue when ** needed. ** ** Returns void ** *******************************************************************************/ void btu_hcif_flush_cmd_queue(void) { BT_HDR *p_cmd; btu_cb.hci_cmd_cb[0].cmd_window = 0; while((p_cmd = (BT_HDR *) GKI_dequeue(&btu_cb.hci_cmd_cb[0].cmd_cmpl_q)) != NULL) { HCI_TRACE_ERROR("cmd_cmpl_q not null\r\n"); GKI_freebuf(p_cmd); } while((p_cmd = (BT_HDR *) GKI_dequeue(&btu_cb.hci_cmd_cb[0].cmd_xmit_q)) != NULL) { HCI_TRACE_ERROR("cmd_xmit_q not null\r\n"); GKI_freebuf(p_cmd); } }
/*! * \file expression.h * * \brief Declarations for expression and related classes. * * The expression classes represent affine expressions with * uninterpreted function calls as terms allowed. * * \date Started: 3/18/2012 * * \authors Michelle Strout and Joe Strout * * Copyright (c) 2012, Colorado State University <br> * Copyright (c) 2015, University of Arizona <br> * All rights reserved. <br> * See ../../COPYING for details. <br> */ #ifndef EXPRESSION_H_ #define EXPRESSION_H_ #include <string> #include <list> #include <vector> #include <sstream> #include <stdlib.h> #include <iostream> #include "environment.h" #include "TupleDecl.h" #include "SubMap.h" class Visitor; #include <util/util.h> namespace iegenlib{ class Exp; /*! * \class Term * * \brief A coefficient multiplied by one. Subclasses are multiplied by * other entities. * */ class Term { public: //! Default constructor inline Term(int coeff) : mCoeff(coeff), mTermType(ConstVal) {} //! Copy constructor Term(const Term& other); //! Copy assignment virtual Term& operator=(const Term& other); //! Destructor virtual ~Term() {} //! Comparison operator -- lexicographic order virtual bool operator<(const Term& other) const; //! equality operator bool operator==(const Term& other) const { return ( (((*this)<other) == false) && ((other<(*this)) == false) ); } //! Create a copy of this Term (and of the same subclass) virtual Term* clone() const; //! Creates a compact string to help with debugging. //! \param absValue Will use absolute value of coeff if true. virtual std::string toString(bool absValue = false) const; //! Creates a compact string, pretty printed. //! \param aTupleDecl name or constant for each tuple var //! \param absValue Will use absolute value of coeff if true. virtual std::string prettyPrintString(const TupleDecl & aTupleDecl, bool absValue = false) const; //! Creates a brief compact string to help with DOT output. //! \param absValue Will use absolute value of coeff if true. virtual std::string toDotString(bool absValue = false) const; //! Get the coefficient of this term. int coefficient() const { return mCoeff; } //! Set the coefficient of this term. void setCoefficient(int coeff) { mCoeff = coeff; } //! Returns true if the Term is really a UFCallTerm. virtual bool isUFCall() const { return false; } //! Returns true if the Term is really a TupleExpTerm. virtual bool isTupleExp() const { return false; } //! Returns true if the Term is a const virtual bool isConst() const { return true; } // MMS, FIXME: don't want the below. Can I get rid of above? // maybe not, using to do recursion, hmmm //! Returns true if the Term is a VarTerm // virtual bool isVar() const { return false; } //! Returns true if the Term is a TupleVarTerm // virtual bool isTupleVar() const { return false; } //! Multiply the coefficient by a constant. void multiplyBy(int constant); //! Divide the coefficient by a constant. void divideBy(int divisor); //--------------------- methods for the use in expression //! Returns true if this term can be combined with the given term. virtual bool factorMatches(const Term& other) const; /*! Combine another term into this one, if possible, by ** adding coefficients of corresponding factors. ** ** \param other -- term to attempt to combine with this one.(adopt) ** \return true if other was combined with this one; false otherwise */ virtual bool combine(Term* other); //! Returns string of subclass type. virtual std::string type() const; //! Return a new Exp with all nested functions such as //! f ( f_inv ( i ) ) changed to i. virtual Exp* collapseNestedInvertibleFunctions() const; //! Visitor design pattern, see Visitor.h for usage virtual void acceptVisitor(Visitor *v); protected: typedef enum {TupleVar, SymConst, UFCall, ConstVal, TupleExp} termtype; inline termtype getTermType() const { return mTermType; } inline void setTermType(termtype tt) { mTermType = tt; } int compareTermTypes(const Term& other) const; //! \param absValue Will use absolute value of coeff if true. void coeffToStream(std::stringstream& ss, bool absValue) const; private: int mCoeff; termtype mTermType; }; /*! * \class UFCallTerm * * \brief Represents a coefficient multiplied by an uninterpreted function call. */ class UFCallTerm : public Term { public: /*! Constructor ** ** Memory management: this object assumes ownership of the ** passed-in Exp objects. The caller must not destroy them, ** and should not assume they survive destruction of this ** UFCallTerm. ** ** \param coeff -- coefficient for the call ** \param funcName -- function to call ** \param num_args -- number of arguments the function call will have ** \param args -- arguments for the function call ** (adopted) ** \param tuple_loc -- index value if function returns a tuple ** and is being indexed, ** so term is still of type integer. If value ** is -1 assuming not in use. ** ** If a tuple_loc is not specified and the function returns a tuple, ** then the UFCallTerm type is a tuple. size() will indicate size ** of tuple being returned. */ UFCallTerm(int coeff, std::string funcName, unsigned int num_args, int tuple_loc=-1); //! Convenience constructor, assumes coeff = 1 UFCallTerm(std::string funcName, unsigned int num_args, int tuple_loc=-1); //! Copy constructor UFCallTerm(const UFCallTerm& other); //! Copy assignment UFCallTerm& operator=(const UFCallTerm& other); //! Destructor void reset(); ~UFCallTerm(); //! Comparison operator -- lexicographic order bool operator<(const Term& other) const; //! Create a copy of this Term (and of the same subclass) Term* clone() const; //! Creates a compact string to help with debugging. //! \param absValue Will use absolute value of coeff if true. std::string toString(bool absValue = false) const; //! Replaces any tuple var instances with given tuple var decl. //! \param aTupleDecl name or constant for each tuple var //! \param absValue Will use absolute value of coeff if true. std::string prettyPrintString(const TupleDecl & aTupleDecl, bool absValue = false) const; //! Creates a brief compact string to help with DOT output. //! \param absValue Will use absolute value of coeff if true. std::string toDotString(bool absValue = false) const; //! Returns string of subclass type. std::string type() const; //! Returns true if the Term is really a UFCallTerm. bool isUFCall() const { return true; } //! Returns true if the Term is a const bool isConst() const { return false; } //--------------------- UFCallTerm specific methods //! Returns the number of arguments for the call. unsigned int numArgs() const; //! Set the ith parameter expression to the given pointer. //! This UFCallTerm becomes owner of the expression. void setParamExp(unsigned int i, Exp* param_exp); //! Returns a pointer to the ith parameter expression. //! This UFCallTerm still owns the pointer. Exp* getParamExp(unsigned int i) const; //! Indicate if the function return value is being //! indexed. bool isIndexed() const; //! Returns a UFCallTerm that is identical except it is //! not indexed. UFCallTerm* nonIndexedClone() const; //! Returns the index in a tuple that the return //! value is. For functions that return tuples //! of size 1, this is always 0. //! If the function return is not being indexed this //! will also be zero. Use in coordination with isIndexed(). int tupleIndex() const; //! Enables the tuple index to be set. void setTupleIndex(unsigned int idx); // Number of entries in the returned tuple. // The size will be one if the function returns // a tuple but is being indexed. unsigned int size() const; //! Returns the function name as a string. std::string name() const { return mFuncName; } //! Enables the function name to be set. void setName(std::string n) { mFuncName = n; } //! Return a new Exp with all nested functions such as //! f ( f_inv ( i ) ) changed to i. Exp* collapseNestedInvertibleFunctions() const; //--------------------- methods for the use in expression //! Returns true if this term can be combined with the given term. bool factorMatches(const Term& other) const; //! Visitor design pattern, see Visitor.h for usage void acceptVisitor(Visitor *v); private: void argsToStream(std::stringstream& ss) const; void argsToStreamPrettyPrint(const TupleDecl & aTupleDecl, std::stringstream& ss) const; std::string mFuncName; unsigned int mNumArgs; std::vector<Exp*> mArgs; int mTupleIndex; }; /*! * \class TupleVarTerm * * \brief Represents a coefficient multiplied by a tuple variable. */ class TupleVarTerm : public Term { public: //! Constructor inline TupleVarTerm(int coeff, int location) : Term(coeff), mLocation(location) { setTermType(TupleVar); } //! Convenience constructor, assumes coeff = 1 inline TupleVarTerm(int location) : Term(1), mLocation(location) { setTermType(TupleVar); } //! Copy constructor TupleVarTerm(const TupleVarTerm& other); //! Copy assignment TupleVarTerm& operator=(const TupleVarTerm& other); //! Comparison operator -- lexicographic order bool operator<(const Term& other) const; //! Create a copy of this Term (and of the same subclass) Term* clone() const; //! Creates a compact string to help with debugging. //! \param absValue Will use absolute value of coeff if true. std::string toString(bool absValue = false) const; //! Creates a compact string, pretty printed. //! \param aTupleDecl name or constant for each tuple var //! \param absValue Will use absolute value of coeff if true. std::string prettyPrintString(const TupleDecl & aTupleDecl, bool absValue = false) const; //! Returns string of subclass type. std::string type() const; //! Returns true if the Term is a const bool isConst() const { return false; } // Returns location of TV int tvloc(){return mLocation;} //--------------------- methods for the use in expression //! Returns true if this term has the same factor (i.e. everything //! except the coefficient) as the given other term. bool factorMatches(const Term& other) const; //! Remap our location according to the given map vector. //! See Exp::remapTupleVars for more detail. void remapLocation(const std::vector<int>& oldToNewLocs); //! Visitor design pattern, see Visitor.h for usage void acceptVisitor(Visitor *v); private: int mLocation; }; /*! * \class VarTerm * * \brief Represents a coefficient multiplied by a variable or symbolic constant. */ class VarTerm : public Term { public: //! Constructor inline VarTerm(int coeff, std::string symbol) : Term(coeff), mSymbol(symbol) { setTermType(SymConst); } //! Convenience constructor, assumes coeff = 1 inline VarTerm(std::string symbol) : Term(1), mSymbol(symbol) { setTermType(SymConst); } //! Copy constructor VarTerm(const VarTerm& other); //! Copy assignment VarTerm& operator=(const VarTerm& other); //! Comparison operator -- lexicographic order bool operator<(const Term& other) const; //! Create a copy of this Term (and of the same subclass) Term* clone() const; //! Creates a compact string to help with debugging. //! \param absValue Will use absolute value of coeff if true. std::string toString(bool absValue = false) const; //! Creates a compact string, pretty printed. //! \param aTupleDecl name or constant for each tuple var //! \param absValue Will use absolute value of coeff if true. std::string prettyPrintString(const TupleDecl & aTupleDecl, bool absValue = false) const; //! Return the variable string std::string symbol() const { return mSymbol; } //! Returns string of subclass type. //! Used by toDotString() only. Might want to refactor. std::string type() const; //! Returns true if the Term is a const bool isConst() const { return false; } //--------------------- methods for the use in expression //! Returns true if this term can be combined with the given term. bool factorMatches(const Term& other) const; //! Visitor design pattern, see Visitor.h for usage void acceptVisitor(Visitor *v); private: std::string mSymbol; }; /*! * \class TupleExpTerm * * \brief A tuple of expressions. * * Modeled somewhat off of UFCallTerm but also off TupleDecl in * terms of not exposing how expressions are stored. * * Memory management: the TupleExpTerm assumes ownership of any * expressions it contains, * copies those when the TupleExpTerm itself is copied, * and deletes them when the TupleExpTerm is destroyed. */ class TupleExpTerm : public Term { public: /*! Constructor ** ** Memory management: this object assumes ownership of the ** passed-in Exp objects. The caller must not destroy them, ** and should not assume they survive destruction of this ** UFCallTerm. ** ** \param coeff -- coefficient for the call */ TupleExpTerm(int coeff, unsigned int size); void reset(); ~TupleExpTerm(); //! Convenience constructor, assumes coeff = 1 TupleExpTerm(unsigned int size); //! Copy constructor. TupleExpTerm( const TupleExpTerm& other ); //! Copy assignment operator. TupleExpTerm& operator=( const TupleExpTerm& other); //! Less than operator. bool operator<( const Term& other) const; //! Equality operator. //bool operator==( const TupleExpTerm& other) const; /*! Combine another tuple expression term ** into this one, if possible, by ** adding sub expressions pointwise. ** ** \param other -- term to attempt to combine with this one.(adopt) ** \return true if other was combined with this one; false otherwise */ bool combine(Term* other); //! Create a copy of this Term (and of the same subclass) Term* clone() const; //! Creates a comma separated list of expressions. //! \param absValue Will use absolute value of coeff if true. std::string toString(bool absValue = false) const; //! In comma-separated list of expressions, //! replaces any tuple var instances with given tuple var decl. std::string prettyPrintString(const TupleDecl & aTupleDecl, bool absValue = false) const; //! Creates a brief compact string to help with DOT output. std::string toDotString(bool absValue = false) const; //! Returns string of subclass type. std::string type() const; //! Returns true if the Term is really a UFCallTerm. bool isTupleExp() const { return true; } //! Returns true if the Term is a const bool isConst() const { return false; } //--------------------- UFCallTerm specific methods //! Setting individual expressions. Indexing starts at 0. //! Becomes owner of passed in expression. void setExpElem(unsigned int exp_index, Exp* exp); //! Returns pointer to individual expression. Indexing starts at 0. Exp* getExpElem(unsigned int exp_index); //! Returns a clone of the specified expression. Exp* cloneExp(unsigned int exp_index) const; // Number of entries in the tuple. unsigned int size() const; //--------------------- methods for the use in expression //! Returns true if this term can be combined with the given term. bool factorMatches(const Term& other) const; //! Visitor design pattern, see Visitor.h for usage void acceptVisitor(Visitor *v); private: unsigned int mSize; std::vector<Exp*> mExps; }; /*! * \class Exp * * \brief An affine expression that allows uninterpreted function call terms. * * Memory management: the Exp manages its own copies of any terms it contains, * copies those when the Exp itself is copied, and deletes them when the Exp * is destroyed. */ class Exp { public: //! Default constructor inline Exp() {setExpression();} //! Copy constructor. Performs a deep copy. Exp(const Exp& other); //! Copy assignment Exp& operator=(const Exp& other); //! Destructor void reset(); virtual ~Exp(); //! Create a copy of this Exp (and of the same subclass) virtual Exp* clone() const; //! Creates a compact string to help with debugging. virtual std::string toString() const; //! Convert to a human-readable string (substitute in tuple vars). virtual std::string prettyPrintString(const TupleDecl & aTupleDecl) const; //! Add a term to this expression. //! /param term (adopted) void addTerm(Term* term); //! Add another expression to this one. //! /param term (adopted) void addExp(Exp* exp); //! Multiply all terms in this expression by a constant. void multiplyBy(int constant); //! Return whether all coefficients in this expression are //! evenly divisible by the given integer. bool isDivisible(int divisor) const; //! Divide all coefficients and the constant term by the given divisor. void divideBy(int divisor); //! Assumes the equality Exp=0 and solves for the given factor. //! FIXME: should only work on equality expressions. Really? //! /param factor (adopted) Exp* solveForFactor(Term* factor) const; /*! Search this expression for the given factor and invert a function to expose the factor. Return a new expression (which is an equality constraint, exp=0, that exposes the term with the factor. Returns NULL if can't do this. */ //! FIXME: should only work on equality expressions. Really? Exp* invertFuncToExposeFactor(Term * factor) const; //! Substitute each expression for the factor (i.e. the non-coefficient //! part of a term), which is its key. //void substitute(const std::map<Term*,Exp*>& searchTermToSubExp); void substitute(SubMap& searchTermToSubExp); /*! Normalize this expression for use in an equality expression. ** This is called when we know this expression is equal to zero; ** in that case, it's valid to multiply the whole expression by ** -1. So we do so, in order to ensure the first term has a ** positive coefficient, so that equivalent expressions can be ** reliably compared. */ //! FIXME: should only work on equality expressions. void normalizeForEquality(); //! Return a new Exp with all nested functions such as //! f ( f_inv ( i ) ) changed to i. Exp* collapseNestedInvertibleFunctions() const; /*! Search for the given factor anywhere in this expression ** (including within UFCallTerm arguments, recursively). */ bool dependsOn(const Term& factor) const; /*! Returns true if this expression contains a UFCallTerm ** that is being indexed. */ bool hasIndexedUFCall() const; /*! Returns a clone of the single indexed UFCall in expression. ** If there are none or more than one then an exception is thrown. */ UFCallTerm* cloneIndexedUFCallTerm() const; /*! Return true iff this expression has no terms, or has ** only a constant term equal to 0. */ bool equalsZero() const; //! Returns true if this expression equals the given term. bool operator==(const Term& other) const; //! Less than operator. bool operator<( const Exp& other) const; //! Equality operator. bool operator==( const Exp& other) const; /*! Find any TupleVarTerms in this expression (and subexpressions) ** and remap the locations according to the oldToNewLocs vector, ** where oldToNewLocs[i] = j means that old location i becomes new ** location j (i.e. __tvi -> __tvj). Throws an exception if an ** old location is out of range for the given oldToNewLocs. ** The new location will be -1 for old locations that are not being ** remapped. */ void remapTupleVars(const std::vector<int>& oldToNewLocs); //! Calls the ExpCase for the visitor design pattern //void apply(SRVisitor* visitor) const { } //! Sets mExpType to Expression, for a simple expression inline void setExpression() { mExpType = Expression; } //! Sets mExpType to Inequality, to indicate Exp >= 0 inline void setInequality() { mExpType = Inequality; } //! Sets mExpType to Equality, to indicate Exp == 0 inline void setEquality() { mExpType = Equality; } //! Returns true if the Exp is a simple expression, not a constraint //! Does not mean it is a UFCall param. inline bool isExpression() { return (getExpType() == Expression); } //! Returns true if the Exp is an inequality, ie expression >= 0 inline bool isInequality() { return (getExpType() == Inequality); } //! Returns true if the Exp is an equality, ie expression == 0 inline bool isEquality() { return (getExpType() == Equality); } //! Returns true if only have a constant term bool isConst() const; //! Returns true if we have something like: 2 = 0 bool isContradiction() const; //! Return Term* if the expression has only one Term. //! Otherwise returns NULL. //! this still owns Term. Term* getTerm() const; //! Return Term* for constant term if there is one. //! Otherwise return NULL. //! This expression still owns the Term. Term* getConstTerm() const; //! Output the Exp in dot format. //! Note here, we still need to provide "digraph name {" and "}" //! Pass in the parent node id and the next node id. //! The next node id will be set upon exit from this routine. //! If no parent id is given then will not draw edge from parent to self. std::string toDotString(int & next_id) const; std::string toDotString(int parent_id, int & next_id) const; //! Returns an iterator over symbolic constant variables. //! Assumes all VarTerm's are symbolic constants. StringIterator* getSymbolIterator() const; //! Visitor design pattern, see Visitor.h for usage void acceptVisitor(Visitor *v); //! Get a list of pointers to the terms in this expression. //! All pointers in this list are still owned by the expression. //! Caller should NOT modify expressions or delete them. std::list<Term*> getTermList() const; protected: typedef enum {Expression, Inequality, Equality} exptype; inline exptype getExpType() const { return mExpType; } private: /*! Search this Exp for the given factor. The cloned Term that is returned can have a coefficient other than 1. The factor param should have a coefficient of 1. Returns NULL if a matching Term is not found. */ Term* findMatchingFactor(const Term & factor) const; std::list<Term*> mTerms; exptype mExpType; }; }//end namespace iegenlib #endif /* EXPRESSION_H_ */
/*! * \ingroup mptConnection * \brief get connection property * * Get property for connection or included outdata. * * \param con connection descriptor * \param pr property to query * * \return state of property */ extern int mpt_connection_get(const MPT_STRUCT(connection) *con, MPT_STRUCT(property) *pr) { const char *name; intptr_t pos = -1, id; if (!pr) { return MPT_ENUM(TypeOutputPtr); } if (!(name = pr->name)) { pos = (intptr_t) pr->desc; } else if (!*name) { pr->name = "connection"; pr->desc = "interface to output data"; if (MPT_socket_active(&con->out.sock)) { static const uint8_t fmt[] = { MPT_ENUM(TypeUnixSocket), 0 }; pr->val.fmt = fmt; pr->val.ptr = &con->out.sock; return 1; } if (con->out.buf._buf) { pr->val.fmt = (uint8_t *) ""; pr->val.ptr = con->out.buf._buf; return 1; } return 0; } id = 0; if (name ? !strcmp(name, "color") : pos == id++) { pr->name = "color"; pr->desc = MPT_tr("colorized message output"); pr->val.fmt = 0; if (con->out.state & MPT_OUTFLAG(PrintColor)) { pr->val.ptr = "true"; return 1; } else { pr->val.ptr = "false"; return 0; } } return mpt_outdata_get(&con->out, pr); }
/* Test to see if the packet in card memory at packet_loc has a valid CRC It doesn't matter that this is slow: it is only used to proble the first few packets. */ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size) { int i = msdu_size - 4; u32 netcrc, crc = 0xffffffff; if (msdu_size < 4) return 0; atmel_copy_to_host(priv->dev, (void *)&netcrc, packet_loc + i, 4); atmel_writeAR(priv->dev, packet_loc); while (i--) { u8 octet = atmel_read8(priv->dev, DR); crc = crc32_le(crc, &octet, 1); } return (crc ^ 0xffffffff) == netcrc; }
/* freeze/thaw all pools belonging to client cli_id (all domains if -1) */ static int tmemc_freeze_pools(cli_id_t cli_id, int arg) { client_t *client; bool_t freeze = (arg == TMEMC_FREEZE) ? 1 : 0; bool_t destroy = (arg == TMEMC_DESTROY) ? 1 : 0; char *s; s = destroy ? "destroyed" : ( freeze ? "frozen" : "thawed" ); if ( cli_id == CLI_ID_NULL ) { list_for_each_entry(client,&global_client_list,client_list) client_freeze(client,freeze); tmh_client_info("tmem: all pools %s for all %ss\n", s, client_str); } else { if ( (client = tmh_client_from_cli_id(cli_id)) == NULL) return -1; client_freeze(client,freeze); tmh_client_info("tmem: all pools %s for %s=%d\n", s, cli_id_str, cli_id); } return 0; }
/* Copyright (c) 2003-2008 Jean-Marc Valin Copyright (c) 2007-2008 CSIRO Copyright (c) 2007-2009 Xiph.Org Foundation Written by Jean-Marc Valin */ /** @file arch.h @brief Various architecture definitions for CELT */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Modified by Patrick Lumban Tobing (Nagoya University) on Sep. 2021, marked by PLT_Sep21 */ #ifndef ARCH_H #define ARCH_H #include "opus_types.h" #include "common.h" //PLT_Sep21 #if defined(_MSC_VER) #define WINDOWS_SYS #include <windows.h> #include <bcrypt.h> #pragma comment(lib, "Bcrypt") #else #if !defined(__CYGWIN__) && defined(__GNUC__ ) #define GNU_EXT #define NRAND48_MAX 2147483647 #endif #include <stdlib.h> #endif # if !defined(__GNUC_PREREQ) # if defined(__GNUC__)&&defined(__GNUC_MINOR__) # define __GNUC_PREREQ(_maj,_min) \ ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) # else # define __GNUC_PREREQ(_maj,_min) 0 # endif # endif #define CELT_SIG_SCALE 32768.f #define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__); #ifdef ENABLE_ASSERTIONS #include <stdio.h> #include <stdlib.h> #ifdef __GNUC__ __attribute__((noreturn)) #endif static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line) { fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); abort(); } #define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);}} #define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed: " #cond "\n" message);}} #else #define celt_assert(cond) #define celt_assert2(cond, message) #endif #define IMUL32(a,b) ((a)*(b)) #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ #define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ #define UADD32(a,b) ((a)+(b)) #define USUB32(a,b) ((a)-(b)) /* Set this if opus_int64 is a native type of the CPU. */ /* Assume that all LP64 architectures have fast 64-bit types; also x86_64 (which can be ILP32 for x32) and Win64 (which is LLP64). */ #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) #define OPUS_FAST_INT64 1 #else #define OPUS_FAST_INT64 0 #endif #define PRINT_MIPS(file) #ifdef FIXED_POINT typedef opus_int16 opus_val16; typedef opus_int32 opus_val32; typedef opus_int64 opus_val64; typedef opus_val32 celt_sig; typedef opus_val16 celt_norm; typedef opus_val32 celt_ener; #define Q15ONE 32767 #define SIG_SHIFT 12 /* Safe saturation value for 32-bit signals. Should be less than 2^31*(1-0.85) to avoid blowing up on DC at deemphasis.*/ #define SIG_SAT (300000000) #define NORM_SCALING 16384 #define DB_SHIFT 10 #define EPSILON 1 #define VERY_SMALL 0 #define VERY_LARGE16 ((opus_val16)32767) #define Q15_ONE ((opus_val16)32767) #define SCALEIN(a) (a) #define SCALEOUT(a) (a) #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; } #ifdef FIXED_DEBUG #include "fixed_debug.h" #else #include "fixed_generic.h" #ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR #include "arm/fixed_arm64.h" #elif OPUS_ARM_INLINE_EDSP #include "arm/fixed_armv5e.h" #elif defined (OPUS_ARM_INLINE_ASM) #include "arm/fixed_armv4.h" #elif defined (BFIN_ASM) #include "fixed_bfin.h" #elif defined (TI_C5X_ASM) #include "fixed_c5x.h" #elif defined (TI_C6X_ASM) #include "fixed_c6x.h" #endif #endif #else /* FIXED_POINT */ typedef float opus_val16; typedef float opus_val32; typedef float opus_val64; typedef float celt_sig; typedef float celt_norm; typedef float celt_ener; #define Q15ONE 1.0f #define NORM_SCALING 1.f #define EPSILON 1e-15f #define VERY_SMALL 1e-30f #define VERY_LARGE16 1e15f #define Q15_ONE ((opus_val16)1.f) /* This appears to be the same speed as C99's fabsf() but it's more portable. */ #define ABS16(x) ((float)fabs(x)) #define ABS32(x) ((float)fabs(x)) #define QCONST16(x,bits) (x) #define QCONST32(x,bits) (x) #define NEG16(x) (-(x)) #define NEG32(x) (-(x)) #define NEG32_ovflw(x) (-(x)) #define EXTRACT16(x) (x) #define EXTEND32(x) (x) #define SHR16(a,shift) (a) #define SHL16(a,shift) (a) #define SHR32(a,shift) (a) #define SHL32(a,shift) (a) #define PSHR32(a,shift) (a) #define VSHR32(a,shift) (a) #define PSHR(a,shift) (a) #define SHR(a,shift) (a) #define SHL(a,shift) (a) #define SATURATE(x,a) (x) #define SATURATE16(x) (x) #define ROUND16(a,shift) (a) #define SROUND16(a,shift) (a) #define HALF16(x) (.5f*(x)) #define HALF32(x) (.5f*(x)) #define ADD16(a,b) ((a)+(b)) #define SUB16(a,b) ((a)-(b)) #define ADD32(a,b) ((a)+(b)) #define SUB32(a,b) ((a)-(b)) #define ADD32_ovflw(a,b) ((a)+(b)) #define SUB32_ovflw(a,b) ((a)-(b)) #define MULT16_16_16(a,b) ((a)*(b)) #define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) #define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) #define MULT16_32_Q15(a,b) ((a)*(b)) #define MULT16_32_Q16(a,b) ((a)*(b)) #define MULT32_32_Q31(a,b) ((a)*(b)) #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) #define MAC16_32_Q16(c,a,b) ((c)+(a)*(b)) #define MULT16_16_Q11_32(a,b) ((a)*(b)) #define MULT16_16_Q11(a,b) ((a)*(b)) #define MULT16_16_Q13(a,b) ((a)*(b)) #define MULT16_16_Q14(a,b) ((a)*(b)) #define MULT16_16_Q15(a,b) ((a)*(b)) #define MULT16_16_P15(a,b) ((a)*(b)) #define MULT16_16_P13(a,b) ((a)*(b)) #define MULT16_16_P14(a,b) ((a)*(b)) #define MULT16_32_P16(a,b) ((a)*(b)) #define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) #define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) #define SCALEIN(a) ((a)*CELT_SIG_SCALE) #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) #define SIG2WORD16(x) (x) #endif /* !FIXED_POINT */ #ifndef GLOBAL_STACK_SIZE #ifdef FIXED_POINT #define GLOBAL_STACK_SIZE 120000 #else #define GLOBAL_STACK_SIZE 120000 #endif #endif #endif /* ARCH_H */
/* * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * Miscellaneous system-dependent types. */ #ifndef ASN_SYSTEM_H #define ASN_SYSTEM_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE 1 #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE /* for snprintf() on some linux systems */ #endif #include <stdio.h> /* For snprintf(3) */ #include <stdlib.h> /* For *alloc(3) */ #include <string.h> /* For memcpy(3) */ #include <sys/types.h> /* For size_t */ #include <limits.h> /* For LONG_MAX */ #include <stdarg.h> /* For va_start */ #include <stddef.h> /* for offsetof and ptrdiff_t */ #ifdef _WIN32 #include <malloc.h> #define snprintf _snprintf #define vsnprintf _vsnprintf /* To avoid linking with ws2_32.lib, here's the definition of ntohl() */ #define sys_ntohl(l) ((((l) << 24) & 0xff000000) \ | (((l) << 8) & 0xff0000) \ | (((l) >> 8) & 0xff00) \ | ((l >> 24) & 0xff)) #ifdef _MSC_VER /* MSVS.Net */ #ifndef __cplusplus #define inline __inline #endif #ifndef ASSUMESTDTYPES /* Standard types have been defined elsewhere */ #define ssize_t SSIZE_T #if _MSC_VER < 1600 typedef char int8_t; typedef short int16_t; typedef int int32_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #else /* _MSC_VER >= 1600 */ #include <stdint.h> #endif /* _MSC_VER < 1600 */ #endif /* ASSUMESTDTYPES */ #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <float.h> #define isnan _isnan #define finite _finite #define copysign _copysign #define ilogb _logb #else /* !_MSC_VER */ #include <stdint.h> #endif /* _MSC_VER */ #else /* !_WIN32 */ #if defined(__vxworks) #include <types/vxTypes.h> #else /* !defined(__vxworks) */ #include <inttypes.h> /* C99 specifies this file */ #include <netinet/in.h> /* for ntohl() */ #define sys_ntohl(foo) ntohl(foo) #endif /* defined(__vxworks) */ #endif /* _WIN32 */ #if __GNUC__ >= 3 || defined(__clang__) #define CC_ATTRIBUTE(attr) __attribute__((attr)) #else #define CC_ATTRIBUTE(attr) #endif #define CC_PRINTFLIKE(fmt, var) CC_ATTRIBUTE(format(printf, fmt, var)) #define CC_NOTUSED CC_ATTRIBUTE(unused) #ifndef CC_ATTR_NO_SANITIZE #define CC_ATTR_NO_SANITIZE(what) CC_ATTRIBUTE(no_sanitize(what)) #endif /* Figure out if thread safety is requested */ #if !defined(ASN_THREAD_SAFE) && (defined(THREAD_SAFE) || defined(_REENTRANT)) #define ASN_THREAD_SAFE #endif /* Thread safety */ #ifndef offsetof /* If not defined by <stddef.h> */ #define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0)) #endif /* offsetof */ #ifndef MIN /* Suitable for comparing primitive types (integers) */ #if defined(__GNUC__) #define MIN(a,b) ({ __typeof a _a = a; __typeof b _b = b; \ ((_a)<(_b)?(_a):(_b)); }) #else /* !__GNUC__ */ #define MIN(a,b) ((a)<(b)?(a):(b)) /* Unsafe variant */ #endif /* __GNUC__ */ #endif /* MIN */ #if __STDC_VERSION__ >= 199901L #ifndef SIZE_MAX #define SIZE_MAX ((~((size_t)0)) >> 1) #endif #ifndef RSIZE_MAX /* C11, Annex K */ #define RSIZE_MAX (SIZE_MAX >> 1) #endif #ifndef RSSIZE_MAX /* Halve signed size even further than unsigned */ #define RSSIZE_MAX ((ssize_t)(RSIZE_MAX >> 1)) #endif #else /* Old compiler */ #undef SIZE_MAX #undef RSIZE_MAX #undef RSSIZE_MAX #define SIZE_MAX ((~((size_t)0)) >> 1) #define RSIZE_MAX (SIZE_MAX >> 1) #define RSSIZE_MAX ((ssize_t)(RSIZE_MAX >> 1)) #endif #if __STDC_VERSION__ >= 199901L #define ASN_PRI_SIZE "zu" #define ASN_PRI_SSIZE "zd" #define ASN_PRIuMAX PRIuMAX #define ASN_PRIdMAX PRIdMAX #else #define ASN_PRI_SIZE "lu" #define ASN_PRI_SSIZE "ld" #if LLONG_MAX > LONG_MAX #define ASN_PRIuMAX "llu" #define ASN_PRIdMAX "lld" #else #define ASN_PRIuMAX "lu" #define ASN_PRIdMAX "ld" #endif #endif #endif /* ASN_SYSTEM_H */
/** * Add a capture filter to the global recent capture filter list or * the recent capture filter list for an interface. * * @param ifname interface name; NULL refers to the global list. * @param s text of capture filter */ void recent_add_cfilter(const gchar *ifname, const gchar *s) { GList *cfilter_list; GList *li; gchar *li_filter, *newfilter = NULL; if (s[0] == '\0') return; if (ifname == NULL) cfilter_list = recent_cfilter_list; else { if (per_interface_cfilter_lists_hash == NULL) per_interface_cfilter_lists_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); cfilter_list = (GList *)g_hash_table_lookup(per_interface_cfilter_lists_hash, ifname); } li = g_list_first(cfilter_list); while (li) { li_filter = (char *)li->data; if (strcmp(s, li_filter) == 0) { newfilter = li_filter; cfilter_list = g_list_remove(cfilter_list, li->data); break; } li = li->next; } if (newfilter == NULL) { newfilter = g_strdup(s); } cfilter_list = g_list_append(cfilter_list, newfilter); if (ifname == NULL) recent_cfilter_list = cfilter_list; else g_hash_table_insert(per_interface_cfilter_lists_hash, g_strdup(ifname), cfilter_list); }
/* Helper function to parse the mouse DPI tag from udev. * The tag is of the form: * MOUSE_DPI=400 *1000 2000 * or * MOUSE_DPI=400@125 *1000@125 2000@125 * Where the * indicates the default value and @number indicates device poll * rate. * Numbers should be in ascending order, and if rates are present they should * be present for all entries. * * When parsing the mouse DPI property, if we find an error we just return 0 * since it's obviously invalid, the caller will treat that as an error and * use a reasonable default instead. If the property contains multiple DPI * settings but none flagged as default, we return the last because we're * lazy and that's a silly way to set the property anyway. * * @param prop The value of the udev property (without the MOUSE_DPI=) * @return The default dpi value on success, 0 on error */ int parse_mouse_dpi_property(const char *prop) { bool is_default = false; int nread, dpi = 0, rate; if (!prop) return 0; while (*prop != 0) { if (*prop == ' ') { prop++; continue; } if (*prop == '*') { prop++; is_default = true; if (!isdigit(prop[0])) return 0; } rate = 1; nread = 0; sscanf(prop, "%d@%d%n", &dpi, &rate, &nread); if (!nread) sscanf(prop, "%d%n", &dpi, &nread); if (!nread || dpi <= 0 || rate <= 0 || prop[nread] == '@') return 0; if (is_default) break; prop += nread; } return dpi; }
#include <stdio.h> int smallest(int x, int y, int z) { int c = 0; while ( x && y && z ) { x--; y--; z--; c++; } return c; } int main(void) { int i,j,k,l; scanf("%d%d%d%d",&i,&j,&k,&l); int sum=0; // scanf("%s",s); int min=0; min=smallest(i,k,l); sum=min*256; i-=min; min=0; if(i<=0 || j<=0)printf("%d\n",sum); else{ min=smallest(i,j,1e7); sum+=min*32; printf("%d\n",sum);} return 0; }
/* Convert between user ABI and register values */ static u64 arm_spe_event_to_pmscr(struct perf_event *event) { struct perf_event_attr *attr = &event->attr; u64 reg = 0; reg |= ATTR_CFG_GET_FLD(attr, ts_enable) << SYS_PMSCR_EL1_TS_SHIFT; reg |= ATTR_CFG_GET_FLD(attr, pa_enable) << SYS_PMSCR_EL1_PA_SHIFT; reg |= ATTR_CFG_GET_FLD(attr, pct_enable) << SYS_PMSCR_EL1_PCT_SHIFT; if (!attr->exclude_user) reg |= BIT(SYS_PMSCR_EL1_E0SPE_SHIFT); if (!attr->exclude_kernel) reg |= BIT(SYS_PMSCR_EL1_E1SPE_SHIFT); if (IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR) && perfmon_capable()) reg |= BIT(SYS_PMSCR_EL1_CX_SHIFT); return reg; }
//***************************************************************************** // //! Turns off the backlight. //! //! This function turns off the backlight on the display. //! //! \return None. // //***************************************************************************** void Formike128x128x16BacklightOff(void) { HWREG(LCD_BL_BASE + GPIO_O_DATA + (LCD_BL_PIN << 2)) = 0; }
/****************************************************************************/ /** * Converts the string into the equivalent Hex buffer. * Ex: "abc123" -> {0xab, 0xc1, 0x23} * * @param Str is a Input String. Will support the lower and upper * case values. Value should be between 0-9, a-f and A-F * * @param Buf is Output buffer. * @param Len of the input string. Should have even values * * @return * - XST_SUCCESS no errors occured. * - ERROR when input parameters are not valid * - an error when input buffer has invalid values * * @note None. * *****************************************************************************/ static u32 XilSKey_Puf_ConvertStringToHexBE(const char * Str, u8 * Buf, u32 Len) { u32 ConvertedLen = 0; u8 LowerNibble, UpperNibble; if (Str == NULL) return XPUF_PARAMETER_NULL_ERROR; if (Buf == NULL) return XPUF_PARAMETER_NULL_ERROR; if ((Len == 0) || (Len % 2 == 1)) return XPUF_PARAMETER_NULL_ERROR; ConvertedLen = 0; while (ConvertedLen < Len) { if (XilSKey_Puf_ConvertCharToNibble(Str[ConvertedLen], &UpperNibble) ==XST_SUCCESS) { if (XilSKey_Puf_ConvertCharToNibble( Str[ConvertedLen + 1], &LowerNibble) == XST_SUCCESS) { Buf[ConvertedLen / 2] = (UpperNibble << 4) | LowerNibble; } else { return XPUF_STRING_INVALID_ERROR; } } else { return XPUF_STRING_INVALID_ERROR; } ConvertedLen += 2; } return XST_SUCCESS; }
// Write the .wav file header to disk // Returns non-zero in case of error, otherwise 0 static int writeWaveHeader(FILE *fp, int sampleRate) { long fileSize; struct WaveHeader hdr; if ( fseek(fp, 0L, SEEK_END) ) { perror("writeWaveHeader: Unable to write header"); return 1; } fileSize = ftell(fp); #ifdef DEBUG printf("Filesize: %ld\n", fileSize); #endif strncpy(hdr.riff, "RIFF", (size_t)4); hdr.fileSize = swap_int((int)fileSize - 8); strncpy(hdr.fileTypeHeader, "WAVE", (size_t)4); strncpy(hdr.format, "fmt ", (size_t)4); hdr.formatDataLen = swap_int(16); hdr.audioFormat = swap_short(1); hdr.numChannels = swap_short(1); hdr.sampleRate = swap_int(sampleRate); hdr.sampleBits = swap_int(16); hdr.byteRate = swap_int((hdr.sampleRate * (int)hdr.sampleBits * (int)hdr.numChannels) / 8); hdr.blockAlign = swap_short((hdr.sampleBits * hdr.numChannels) / 8); strncpy(hdr.dataHeader, "data", (size_t)4); hdr.dataSize = swap_int((int)fileSize - 44); rewind(fp); if ( fwrite((void *)&hdr, sizeof(struct WaveHeader), 1, fp) != 1 ) { perror("writeWaveHeader: Unable to write header"); return 1; } return 0; }
/* Ported to U-Boot by Christian Pellegrin <chri@ascensit.com> Based on sources from the Linux kernel (pcnet_cs.c, 8390.h) and eCOS(if_dp83902a.c, if_dp83902a.h). Both of these 2 wonderful world are GPL, so this is, of course, GPL. ========================================================================== dev/dp83902a.h National Semiconductor DP83902a ethernet chip ========================================================================== ####ECOSGPLCOPYRIGHTBEGIN#### ------------------------------------------- This file is part of eCos, the Embedded Configurable Operating System. Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. eCos is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 or (at your option) any later version. eCos is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with eCos; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. at http://sources.redhat.com/ecos/ecos-license/ ------------------------------------------- ####ECOSGPLCOPYRIGHTEND#### ####BSDCOPYRIGHTBEGIN#### ------------------------------------------- Portions of this software may have been derived from OpenBSD or other sources, and are covered by the appropriate copyright disclaimers included herein. ------------------------------------------- ####BSDCOPYRIGHTEND#### ========================================================================== #####DESCRIPTIONBEGIN#### Author(s): gthomas Contributors: gthomas, jskov Date: 2001-06-13 Purpose: Description: ####DESCRIPTIONEND#### ========================================================================== */ /* * NE2000 support header file. * Created by Nobuhiro Iwamatsu <iwamatsu@nigauri.org> */ #ifndef __DRIVERS_NE2000_H__ #define __DRIVERS_NE2000_H__ /* Enable NE2000 basic init function */ #define NE2000_BASIC_INIT #define DP_DATA 0x10 #define START_PG 0x50 /* First page of TX buffer */ #define START_PG2 0x48 #define STOP_PG 0x80 /* Last page +1 of RX ring */ #define RX_START 0x50 #define RX_END 0x80 #define DP_IN(_b_, _o_, _d_) (_d_) = *( (vu_char *) ((_b_)+(_o_))) #define DP_OUT(_b_, _o_, _d_) *( (vu_char *) ((_b_)+(_o_))) = (_d_) #define DP_IN_DATA(_b_, _d_) (_d_) = *( (vu_char *) ((_b_))) #define DP_OUT_DATA(_b_, _d_) *( (vu_char *) ((_b_))) = (_d_) #endif /* __DRIVERS_NE2000_H__ */
/** * s2io_get_stats - Updates the device statistics structure. * @dev : pointer to the device structure. * Description: * This function updates the device statistics structure in the s2io_nic * structure and returns a pointer to the same. * Return value: * pointer to the updated net_device_stats structure. */ static struct net_device_stats *s2io_get_stats(struct net_device *dev) { nic_t *sp = dev->priv; mac_info_t *mac_control; struct config_param *config; mac_control = &sp->mac_control; config = &sp->config; s2io_updt_stats(sp); sp->stats.tx_packets = le32_to_cpu(mac_control->stats_info->tmac_frms); sp->stats.tx_errors = le32_to_cpu(mac_control->stats_info->tmac_any_err_frms); sp->stats.rx_errors = le32_to_cpu(mac_control->stats_info->rmac_drop_frms); sp->stats.multicast = le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms); sp->stats.rx_length_errors = le32_to_cpu(mac_control->stats_info->rmac_long_frms); return (&sp->stats); }
/* Finds the candidates for the induction variables. */ static void find_iv_candidates (struct ivopts_data *data) { add_standard_iv_candidates (data); add_old_ivs_candidates (data); add_derived_ivs_candidates (data); set_autoinc_for_original_candidates (data); record_important_candidates (data); }
/* * Initialize the precomputed transaction reservation values * in the mount structure. */ void xfs_trans_init( xfs_mount_t *mp) { xfs_trans_reservations_t *resp; resp = &(mp->m_reservations); resp->tr_write = (uint)(XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_itruncate = (uint)(XFS_CALC_ITRUNCATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_rename = (uint)(XFS_CALC_RENAME_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_link = (uint)XFS_CALC_LINK_LOG_RES(mp); resp->tr_remove = (uint)(XFS_CALC_REMOVE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_symlink = (uint)(XFS_CALC_SYMLINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_create = (uint)(XFS_CALC_CREATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_mkdir = (uint)(XFS_CALC_MKDIR_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_ifree = (uint)(XFS_CALC_IFREE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_ichange = (uint)(XFS_CALC_ICHANGE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_growdata = (uint)XFS_CALC_GROWDATA_LOG_RES(mp); resp->tr_swrite = (uint)XFS_CALC_SWRITE_LOG_RES(mp); resp->tr_writeid = (uint)XFS_CALC_WRITEID_LOG_RES(mp); resp->tr_addafork = (uint)(XFS_CALC_ADDAFORK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_attrinval = (uint)XFS_CALC_ATTRINVAL_LOG_RES(mp); resp->tr_attrset = (uint)(XFS_CALC_ATTRSET_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_attrrm = (uint)(XFS_CALC_ATTRRM_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); resp->tr_clearagi = (uint)XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp); resp->tr_growrtalloc = (uint)XFS_CALC_GROWRTALLOC_LOG_RES(mp); resp->tr_growrtzero = (uint)XFS_CALC_GROWRTZERO_LOG_RES(mp); resp->tr_growrtfree = (uint)XFS_CALC_GROWRTFREE_LOG_RES(mp); }
/* * dumpProcLang * writes out to fout the queries to recreate a user-defined * procedural language */ static void dumpProcLang(Archive *fout, ProcLangInfo *plang) { PQExpBuffer defqry; PQExpBuffer delqry; PQExpBuffer labelq; bool useParams; char *qlanname; char *lanschema; FuncInfo *funcInfo; FuncInfo *inlineInfo = NULL; FuncInfo *validatorInfo = NULL; if (!plang->dobj.dump || dataOnly) return; funcInfo = findFuncByOid(plang->lanplcallfoid); if (funcInfo != NULL && !funcInfo->dobj.dump) funcInfo = NULL; if (OidIsValid(plang->laninline)) { inlineInfo = findFuncByOid(plang->laninline); if (inlineInfo != NULL && !inlineInfo->dobj.dump) inlineInfo = NULL; } if (OidIsValid(plang->lanvalidator)) { validatorInfo = findFuncByOid(plang->lanvalidator); if (validatorInfo != NULL && !validatorInfo->dobj.dump) validatorInfo = NULL; } useParams = (funcInfo != NULL && (inlineInfo != NULL || !OidIsValid(plang->laninline)) && (validatorInfo != NULL || !OidIsValid(plang->lanvalidator))); if (!plang->dobj.ext_member) { if (!useParams && !shouldDumpProcLangs()) return; } defqry = createPQExpBuffer(); delqry = createPQExpBuffer(); labelq = createPQExpBuffer(); qlanname = pg_strdup(fmtId(plang->dobj.name)); if (useParams) lanschema = funcInfo->dobj.namespace->dobj.name; else lanschema = NULL; appendPQExpBuffer(delqry, "DROP PROCEDURAL LANGUAGE %s;\n", qlanname); if (useParams) { appendPQExpBuffer(defqry, "CREATE %sPROCEDURAL LANGUAGE %s", plang->lanpltrusted ? "TRUSTED " : "", qlanname); appendPQExpBuffer(defqry, " HANDLER %s", fmtId(funcInfo->dobj.name)); if (OidIsValid(plang->laninline)) { appendPQExpBuffer(defqry, " INLINE "); if (inlineInfo->dobj.namespace != funcInfo->dobj.namespace) appendPQExpBuffer(defqry, "%s.", fmtId(inlineInfo->dobj.namespace->dobj.name)); appendPQExpBuffer(defqry, "%s", fmtId(inlineInfo->dobj.name)); } if (OidIsValid(plang->lanvalidator)) { appendPQExpBuffer(defqry, " VALIDATOR "); if (validatorInfo->dobj.namespace != funcInfo->dobj.namespace) appendPQExpBuffer(defqry, "%s.", fmtId(validatorInfo->dobj.namespace->dobj.name)); appendPQExpBuffer(defqry, "%s", fmtId(validatorInfo->dobj.name)); } } else { appendPQExpBuffer(defqry, "CREATE OR REPLACE PROCEDURAL LANGUAGE %s", qlanname); } appendPQExpBuffer(defqry, ";\n"); appendPQExpBuffer(labelq, "LANGUAGE %s", qlanname); if (binary_upgrade) binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data); ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId, plang->dobj.name, lanschema, NULL, plang->lanowner, false, "PROCEDURAL LANGUAGE", SECTION_PRE_DATA, defqry->data, delqry->data, NULL, NULL, 0, NULL, NULL); dumpComment(fout, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); dumpSecLabel(fout, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); if (plang->lanpltrusted) dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE", qlanname, NULL, plang->dobj.name, lanschema, plang->lanowner, plang->lanacl); free(qlanname); destroyPQExpBuffer(defqry); destroyPQExpBuffer(delqry); destroyPQExpBuffer(labelq); }
/* * Call a C function that returns an int */ static int intcall(void *f, long *a, double *d) { int (*func)() = f; int res = 0; res = (*func)( a[ 0], a[ 1], a[ 2], a[ 3], a[ 4], a[ 5], a[ 6], a[ 7], a[ 8], a[ 9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20], a[21], a[22], a[23], a[24], a[25], a[26], a[27], a[28], a[29], a[30], a[31], a[32], a[33], a[34], a[35], a[36], a[37], a[38], a[39], d[ 0], d[ 1], d[ 2], d[ 3], d[ 4], d[ 5], d[ 6], d[ 7], d[ 8], d[ 9], d[10], d[11], d[12], d[13], d[14], d[15], d[16], d[17], d[18], d[19] ); return res; }
/* Create a vector of short int with length n */ mve_sivectr mve_Sivectr ( long int n) { mve_sivectr v; v = (short int *) calloc ((n + 2), sizeof (short int)); if (v == NULL) fprintf (stderr, "mve_Sivectr unable to allocate memory."); v += 2; mve_svdim (v) = n; return v; }
/** Initialize internal structures for CD device. */ bool init_win32ioctl (_img_private_t *env) { #ifdef WIN32 OSVERSIONINFO ov; #endif #ifdef _XBOX ANSI_STRING filename; OBJECT_ATTRIBUTES attributes; IO_STATUS_BLOCK status; HANDLE hDevice; NTSTATUS error; #else unsigned int len=strlen(env->gen.source_name); char psz_win32_drive[7]; DWORD dw_access_flags; #endif cdio_debug("using winNT/2K/XP ioctl layer"); #ifdef WIN32 memset(&ov,0,sizeof(OSVERSIONINFO)); ov.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); GetVersionEx(&ov); if((ov.dwPlatformId==VER_PLATFORM_WIN32_NT) && (ov.dwMajorVersion>4)) dw_access_flags = GENERIC_READ|GENERIC_WRITE; else dw_access_flags = GENERIC_READ; #endif if (cdio_is_device_win32(env->gen.source_name)) { #ifdef _XBOX RtlInitAnsiString(&filename,"\\Device\\Cdrom0"); InitializeObjectAttributes(&attributes, &filename, OBJ_CASE_INSENSITIVE, NULL); error = NtCreateFile( &hDevice, GENERIC_READ |SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attributes, &status, NULL, 0, FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ); if (!NT_SUCCESS(error)) { return false; } env->h_device_handle = hDevice; #else snprintf( psz_win32_drive, sizeof(psz_win32_drive), "\\\\.\\%c:", env->gen.source_name[len-2] ); env->h_device_handle = CreateFileA( psz_win32_drive, dw_access_flags, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); if( env->h_device_handle == INVALID_HANDLE_VALUE ) { dw_access_flags ^= GENERIC_WRITE; env->h_device_handle = CreateFileA( psz_win32_drive, dw_access_flags, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ); if (env->h_device_handle == NULL) return false; } #endif env->b_ioctl_init = true; set_scsi_tuple_win32ioctl(env); return true; } return false; }
/* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once typedef struct Path Path; typedef struct PathSpec PathSpec; typedef struct ActivationDetailsPath ActivationDetailsPath; #include "unit.h" typedef enum PathType { PATH_EXISTS, PATH_EXISTS_GLOB, PATH_DIRECTORY_NOT_EMPTY, PATH_CHANGED, PATH_MODIFIED, _PATH_TYPE_MAX, _PATH_TYPE_INVALID = -EINVAL, } PathType; typedef struct PathSpec { Unit *unit; char *path; sd_event_source *event_source; LIST_FIELDS(struct PathSpec, spec); PathType type; int inotify_fd; int primary_wd; bool previous_exists; } PathSpec; int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler); void path_spec_unwatch(PathSpec *s); int path_spec_fd_event(PathSpec *s, uint32_t events); void path_spec_done(PathSpec *s); static inline bool path_spec_owns_inotify_fd(PathSpec *s, int fd) { return s->inotify_fd == fd; } typedef enum PathResult { PATH_SUCCESS, PATH_FAILURE_RESOURCES, PATH_FAILURE_START_LIMIT_HIT, PATH_FAILURE_UNIT_START_LIMIT_HIT, PATH_FAILURE_TRIGGER_LIMIT_HIT, _PATH_RESULT_MAX, _PATH_RESULT_INVALID = -EINVAL, } PathResult; struct Path { Unit meta; LIST_HEAD(PathSpec, specs); PathState state, deserialized_state; bool make_directory; mode_t directory_mode; PathResult result; RateLimit trigger_limit; sd_event_source *trigger_notify_event_source; }; struct ActivationDetailsPath { ActivationDetails meta; char *trigger_path_filename; }; void path_free_specs(Path *p); extern const UnitVTable path_vtable; extern const ActivationDetailsVTable activation_details_path_vtable; const char* path_type_to_string(PathType i) _const_; PathType path_type_from_string(const char *s) _pure_; const char* path_result_to_string(PathResult i) _const_; PathResult path_result_from_string(const char *s) _pure_; DEFINE_CAST(PATH, Path); DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_PATH, ActivationDetailsPath, PATH);
/* Return true if the one of outgoing edges is already predicted by PREDICTOR. */ bool tree_predicted_by_p (basic_block bb, enum br_predictor predictor) { struct edge_prediction *i; for (i = bb->predictions; i; i = i->ep_next) if (i->ep_predictor == predictor) return true; return false; }
#include<stdio.h> #include<string.h> int main() { int n; scanf("%d",&n); int faces=0; char shape[13]; for(int i=0;i<n;i++) { scanf("%s",shape); if(shape[0]=='T') faces+=4; if(shape[0]=='C') faces+=6; if(shape[0]=='O') faces+=8; if(shape[0]=='D') faces+=12; if(shape[0]=='I') faces+=20; //printf("%s\n%d\n",shape,faces); } printf("%d",faces); }
/* * l2_allocate * * Allocate a new l2 entry in the file. If l1_index points to an already * used entry in the L2 table (i.e. we are doing a copy on write for the L2 * table) copy the contents of the old L2 table into the newly allocated one. * Otherwise the new table is initialized with zeros. * */ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) { BDRVQcowState *s = bs->opaque; uint64_t old_l2_offset; uint64_t *l2_table; int64_t l2_offset; int ret; old_l2_offset = s->l1_table[l1_index]; l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t)); if (l2_offset < 0) { return l2_offset; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail; } ret = qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void**) table); if (ret < 0) { return ret; } l2_table = *table; if (old_l2_offset == 0) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); } else { uint64_t* old_table; BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ); ret = qcow2_cache_get(bs, s->l2_table_cache, old_l2_offset, (void**) &old_table); if (ret < 0) { goto fail; } memcpy(l2_table, old_table, s->cluster_size); ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &old_table); if (ret < 0) { goto fail; } } BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); ret = qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { goto fail; } s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED; ret = write_l1_entry(bs, l1_index); if (ret < 0) { goto fail; } *table = l2_table; return 0; fail: qcow2_cache_put(bs, s->l2_table_cache, (void**) table); s->l1_table[l1_index] = old_l2_offset; return ret; }
/** * spi_nor_init_erase_cmd_list() - initialize erase command list * @nor: pointer to a 'struct spi_nor' * @erase_list: list of erase commands to be executed once we validate that the * erase can be performed * @addr: offset in the serial flash memory * @len: number of bytes to erase * * Builds the list of best fitted erase commands and verifies if the erase can * be performed. * * Return: 0 on success, -errno otherwise. */ static int spi_nor_init_erase_cmd_list(struct spi_nor *nor, struct list_head *erase_list, u64 addr, u32 len) { const struct spi_nor_erase_map *map = &nor->params->erase_map; const struct spi_nor_erase_type *erase, *prev_erase = NULL; struct spi_nor_erase_region *region; struct spi_nor_erase_command *cmd = NULL; u64 region_end; int ret = -EINVAL; region = spi_nor_find_erase_region(map, addr); if (IS_ERR(region)) return PTR_ERR(region); region_end = spi_nor_region_end(region); while (len) { erase = spi_nor_find_best_erase_type(map, region, addr, len); if (!erase) goto destroy_erase_cmd_list; if (prev_erase != erase || erase->size != cmd->size || region->offset & SNOR_OVERLAID_REGION) { cmd = spi_nor_init_erase_cmd(region, erase); if (IS_ERR(cmd)) { ret = PTR_ERR(cmd); goto destroy_erase_cmd_list; } list_add_tail(&cmd->list, erase_list); } else { cmd->count++; } addr += cmd->size; len -= cmd->size; if (len && addr >= region_end) { region = spi_nor_region_next(region); if (!region) goto destroy_erase_cmd_list; region_end = spi_nor_region_end(region); } prev_erase = erase; } return 0; destroy_erase_cmd_list: spi_nor_destroy_erase_cmd_list(erase_list); return ret; }
/* * Parse device options. This includes: * bus=number * dev=number * func=number * bank=number * config * bar0 * bar1 * bar2 * bar3 * bar4 * bar5 * rom * * input is what the user specified for the options on the commandline, * flags_arg is modified with the options set, and the rest of the args return * their respective values. */ static int parse_device_opts( char *input, uint64_t *flags_arg, uint8_t *bus_arg, uint8_t *device_arg, uint8_t *func_arg, uint8_t *bank_arg) { enum bdf_opts_index { bus = 0, dev = 1, func = 2, bdf = 3, bank = 4, config = 5, bar0 = 6, bar1 = 7, bar2 = 8, bar3 = 9, bar4 = 10, bar5 = 11, rom = 12 }; static char *bdf_opts[] = { "bus", "dev", "func", "bdf", "bank", "config", "bar0", "bar1", "bar2", "bar3", "bar4", "bar5", "rom", NULL }; char *value; uint64_t recv64; static char bank_err[] = {"The bank or bar arg is specified more than once.\n"}; int rval = SUCCESS; while ((*input != '\0') && (rval == SUCCESS)) { switch (getsubopt(&input, bdf_opts, &value)) { case bdf: { char *bvalue, *dvalue, *fvalue; if ((rval = extract_bdf(value, &bvalue, &dvalue, &fvalue)) != SUCCESS) { break; } if (!bvalue | !dvalue | !fvalue) { break; } if ((rval = extract_bdf_arg(bvalue, "bus", BUS_SPEC_FLAG, flags_arg, bus_arg)) != SUCCESS) { break; } if ((rval = extract_bdf_arg(dvalue, "dev", DEV_SPEC_FLAG, flags_arg, device_arg)) != SUCCESS) { break; } rval = extract_bdf_arg(fvalue, "func", FUNC_SPEC_FLAG, flags_arg, func_arg); break; } case bus: rval = extract_bdf_arg(value, "bus", BUS_SPEC_FLAG, flags_arg, bus_arg); break; case dev: rval = extract_bdf_arg(value, "dev", DEV_SPEC_FLAG, flags_arg, device_arg); break; case func: rval = extract_bdf_arg(value, "func", FUNC_SPEC_FLAG, flags_arg, func_arg); break; case bank: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } if ((rval = get_value64(value, &recv64, HEX_ONLY)) != SUCCESS) { break; } *bank_arg = (uint8_t)recv64; if (rval || (*bank_arg != recv64)) { (void) fprintf(stderr, "Bank argument must" " fit into 8 bits.\n"); rval = FAILURE; break; } *flags_arg |= BANK_SPEC_FLAG; break; case config: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_CONFIG; *flags_arg |= BANK_SPEC_FLAG; break; case bar0: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_BAR0; *flags_arg |= BANK_SPEC_FLAG; break; case bar1: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_BAR1; *flags_arg |= BANK_SPEC_FLAG; break; case bar2: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_BAR2; *flags_arg |= BANK_SPEC_FLAG; break; case bar3: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_BAR3; *flags_arg |= BANK_SPEC_FLAG; break; case bar4: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_BAR4; *flags_arg |= BANK_SPEC_FLAG; break; case bar5: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_BAR5; *flags_arg |= BANK_SPEC_FLAG; break; case rom: if (*flags_arg & BANK_SPEC_FLAG) { (void) fprintf(stderr, bank_err); rval = FAILURE; break; } *bank_arg = PCITOOL_ROM; *flags_arg |= BANK_SPEC_FLAG; break; default: (void) fprintf(stderr, "Unrecognized option for -d\n"); rval = FAILURE; break; } } if ((*flags_arg & (BUS_SPEC_FLAG | DEV_SPEC_FLAG | FUNC_SPEC_FLAG)) != (BUS_SPEC_FLAG | DEV_SPEC_FLAG | FUNC_SPEC_FLAG)) { rval = FAILURE; } else if ((*flags_arg & BANK_SPEC_FLAG) == 0) { *flags_arg |= BANK_SPEC_FLAG; *bank_arg = PCITOOL_CONFIG; } return (rval); }