file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/193894474.c
/** ****************************************************************************** * @file stm32l1xx_ll_comp.c * @author MCD Application Team * @brief COMP LL module driver ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32l1xx_ll_comp.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32L1xx_LL_Driver * @{ */ #if defined (COMP1) || defined (COMP2) /** @addtogroup COMP_LL COMP * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup COMP_LL_Private_Macros * @{ */ /* Check of parameters for configuration of COMP hierarchical scope: */ /* COMP instance. */ #define IS_LL_COMP_POWER_MODE(__POWER_MODE__) \ ( ((__POWER_MODE__) == LL_COMP_POWERMODE_MEDIUMSPEED) \ || ((__POWER_MODE__) == LL_COMP_POWERMODE_ULTRALOWPOWER) \ ) /* Note: On this STM32 serie, comparator input plus parameters are */ /* the different depending on COMP instances. */ #if defined(RI_ASCR1_CH_31) #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \ (((__COMP_INSTANCE__) == COMP1) \ ? ( \ ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO6) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO7) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO8) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO9) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO10) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO11) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO12) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO13) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO14) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO15) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO16) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO17) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO18) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO19) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO20) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO21) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO22) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO23) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO24) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO25) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO26) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO27) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO28) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO29) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO30) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO31) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO32) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO33) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_NONE) \ ) \ : \ ( \ ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO3) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO4) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_NONE) \ ) \ ) #else #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \ (((__COMP_INSTANCE__) == COMP1) \ ? ( \ ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO6) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO7) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO8) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO9) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO10) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO11) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO12) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO13) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO14) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO15) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO16) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO17) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO18) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO19) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO20) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO21) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO22) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO23) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO24) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO25) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO26) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO27) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO28) \ ) \ : \ ( \ ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \ || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \ ) \ ) #endif /* Note: On this STM32 serie, comparator input minus parameters are */ /* the different depending on COMP instances. */ #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \ (((__COMP_INSTANCE__) == COMP1) \ ? ( \ ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \ ) \ : \ ( \ ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \ || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \ || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \ || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \ || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \ || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2) \ || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \ ) \ ) #define IS_LL_COMP_OUTPUT_SELECTION(__OUTPUT_SELECTION__) \ ( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \ || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4) \ || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCREFCLR) \ || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC4) \ || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCREFCLR) \ || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC4) \ || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_OCREFCLR) \ || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM10_IC1) \ ) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup COMP_LL_Exported_Functions * @{ */ /** @addtogroup COMP_LL_EF_Init * @{ */ /** * @brief De-initialize registers of the selected COMP instance * to their default reset values. * @note If comparator is locked, de-initialization by software is * not possible. * The only way to unlock the comparator is a device hardware reset. * @param COMPx COMP instance * @retval An ErrorStatus enumeration value: * - SUCCESS: COMP registers are de-initialized * - ERROR: COMP registers are not de-initialized */ ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_COMP_ALL_INSTANCE(COMPx)); /* Note: On this STM32 serie, only COMP instance COMP2 has */ /* features settables: power mode, input minus selection */ /* and output selection. */ /* Note: On this STM32 serie, setting COMP instance COMP2 input minus */ /* is enabling the comparator. */ /* Reset COMP2 input minus also disable the comparator. */ /* Note: In case of de-initialization of COMP instance COMP1: */ /* Switch COMP_CSR_SW1 is not modified because can be used */ /* to connect OPAMP3 to ADC. */ /* Switches RI_ASCR1_VCOMP, RI_ASCR1_SCM are reset: let routing */ /* interface under control of ADC. */ if(COMPx == COMP1) { CLEAR_BIT(COMP->CSR, ( COMP_CSR_CMP1EN | COMP_CSR_10KPU | COMP_CSR_400KPU | COMP_CSR_10KPD | COMP_CSR_400KPD ) ); } else { CLEAR_BIT(COMP->CSR, ( COMP_CSR_SPEED | COMP_CSR_INSEL | COMP_CSR_OUTSEL ) ); } /* Set comparator input plus */ LL_COMP_SetInputPlus(COMPx, LL_COMP_INPUT_PLUS_NONE); return status; } /** * @brief Initialize some features of COMP instance. * @note This function configures features of the selected COMP instance. * Some features are also available at scope COMP common instance * (common to several COMP instances). * Refer to functions having argument "COMPxy_COMMON" as parameter. * @param COMPx COMP instance * @param COMP_InitStruct Pointer to a @ref LL_COMP_InitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: COMP registers are initialized * - ERROR: COMP registers are not initialized */ ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_COMP_ALL_INSTANCE(COMPx)); if(COMPx == COMP2) { assert_param(IS_LL_COMP_POWER_MODE(COMP_InitStruct->PowerMode)); assert_param(IS_LL_COMP_INPUT_MINUS(COMPx, COMP_InitStruct->InputMinus)); assert_param(IS_LL_COMP_OUTPUT_SELECTION(COMP_InitStruct->OutputSelection)); } assert_param(IS_LL_COMP_INPUT_PLUS(COMPx, COMP_InitStruct->InputPlus)); /* Configuration of comparator instance : */ /* - PowerMode */ /* - InputPlus */ /* - InputMinus */ /* - OutputSelection */ /* Note: On this STM32 serie, only COMP instance COMP2 has */ /* features settables: power mode, input minus selection */ /* and output selection. */ /* Note: On this STM32 serie, setting COMP instance COMP2 input minus */ /* is enabling the comparator. */ if(COMPx == COMP2) { MODIFY_REG(COMP->CSR, COMP_CSR_SPEED | COMP_CSR_INSEL | COMP_CSR_OUTSEL , COMP_InitStruct->PowerMode | COMP_InitStruct->InputMinus | COMP_InitStruct->OutputSelection ); /* Set comparator input plus */ LL_COMP_SetInputPlus(COMPx, COMP_InitStruct->InputPlus); } else /* COMPx == COMP1 */ { /* If window mode is enabled, COMP1 input plus is not used and therefore not modified */ if(READ_BIT(COMP12_COMMON->CSR, COMP_CSR_WNDWE) == COMP_CSR_WNDWE) { /* Set comparator input plus */ LL_COMP_SetInputPlus(COMPx, COMP_InitStruct->InputPlus); } } return status; } /** * @brief Set each @ref LL_COMP_InitTypeDef field to default value. * @param COMP_InitStruct: pointer to a @ref LL_COMP_InitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct) { /* Set COMP_InitStruct fields to default values */ COMP_InitStruct->PowerMode = LL_COMP_POWERMODE_ULTRALOWPOWER; COMP_InitStruct->InputPlus = LL_COMP_INPUT_PLUS_IO1; COMP_InitStruct->InputMinus = LL_COMP_INPUT_MINUS_VREFINT; COMP_InitStruct->OutputSelection = LL_COMP_OUTPUT_NONE; } /** * @} */ /** * @} */ /** * @} */ #endif /* COMP1 || COMP2 */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/155441.c
/* ************************************************************************** * vdm.cpp * * An example implementation of the VDM functionality API. * ************************************************************************** */ #ifdef FSC_HAVE_VDM #ifdef FSC_HAVE_DP #include "display_port.h" #endif /* FSC_HAVE_DP */ #include "port.h" /* Port class */ #include "timer.h" /* Timer values */ #include "vdm_types.h" #include "vdm.h" #include "vendor_info.h" #include "protocol.h" #include "policy.h" #include <huawei_platform/log/hw_log.h> #define HWLOG_TAG FUSB3601_TAG HWLOG_REGIST(); #define IN_FUNCTION hwlog_info("%s ++\n", __func__); #define OUT_FUNCTION hwlog_info("%s --\n", __func__); #define VDM_ARRAY_LEN 1 /* Public interface used by the policy engine */ /* Hostcomm functions */ void FUSB3601_ConfigureVdmResponses(struct Port *port, FSC_U8* bytes) { FSC_U16 _svid = 0; FSC_U32 _mode = 0; IN_FUNCTION /* TODO - Replace/explain magic numbers */ if (*(bytes + 2)) { port->svid_enable_ = TRUE; } else { port->svid_enable_ = FALSE; } _svid |= *(bytes + 2 + 4 + 1); /* TODO - Replace/explain magic numbers */ _svid <<= 8; /* TODO - Replace/explain magic numbers */ _svid |= *(bytes + 2 + 4 + 0); /* TODO - Replace/explain magic numbers */ port->my_svid_ = _svid; /* TODO - Replace/explain magic numbers */ if (*(bytes + 2 + 8)) { port->mode_enable_ = TRUE; } else { port->mode_enable_ = FALSE; } _mode = _mode | *(bytes + 2 + 12 + 3); /* TODO - Replace/explain magic numbers */ _mode = _mode << 8; _mode = _mode | *(bytes + 2 + 12 + 2); /* TODO - Replace/explain magic numbers */ _mode = _mode << 8; _mode = _mode | *(bytes + 2 + 12 + 1); /* TODO - Replace/explain magic numbers */ _mode = _mode << 8; _mode = _mode | *(bytes + 2 + 12 + 0); /* TODO - Replace/explain magic numbers */ port->my_mode_ = _mode; port->mode_entered_ = FALSE; } void FUSB3601_ReadVdmConfiguration(struct Port *port, FSC_U8* data) { /* TODO - Replace/explain magic numbers in this entire function */ IN_FUNCTION if (port->svid_enable_) { *(data + 0 + 0) = 1; } else { *(data + 0 + 1) = 0; } *(data + 0 + 1) = 0; *(data + 0 + 2) = 0; *(data + 0 + 3) = 0; *(data + 4 + 0) = (port->my_svid_ & 0xFF); *(data + 4 + 1) = ((port->my_svid_ >> 8) & 0xFF); *(data + 4 + 2) = 0; *(data + 4 + 3) = 0; if (port->mode_enable_) { *(data + 8 + 0) = 1; } else { *(data + 8 + 0) = 0; } *(data + 8 + 1) = 0; *(data + 8 + 2) = 0; *(data + 8 + 3) = 0; *(data + 12 + 0) = (port->my_mode_ & 0xFF); *(data + 12 + 1) = ((port->my_mode_ >> 8) & 0xFF); *(data + 12 + 2) = ((port->my_mode_ >> 16) & 0xFF); *(data + 12 + 3) = ((port->my_mode_ >> 24) & 0xFF); /* add in mode entry status */ if (port->mode_entered_) { *(data + 16 + 0) = 1; } else { *(data + 16 + 0) = 0; } *(data + 16 + 1) = 0; *(data + 16 + 2) = 0; *(data + 16 + 3) = 0; } /* End hostcomm functions */ void FUSB3601_AutoVdmDiscovery(struct Port *port) { switch (port->auto_vdm_state_) { case AUTO_VDM_INIT: case AUTO_VDM_DISCOVER_ID_PP: FUSB3601_PolicySendVDM(port, DISCOVER_IDENTITY, 0xFF00, SOP_TYPE_SOP, 0); //RequestDiscoverIdentity(port, SOP_TYPE_SOP); break; case AUTO_VDM_DISCOVER_SVIDS_PP: FUSB3601_PolicySendVDM(port, DISCOVER_SVIDS, 0xFF00, SOP_TYPE_SOP, 0); //RequestDiscoverSvids(port, SOP_TYPE_SOP); break; case AUTO_VDM_DISCOVER_MODES_PP: FUSB3601_platform_log(port->port_id_, "FUSB Send DiscMode, auto_mode_disc_tracker_: ", port->auto_mode_disc_tracker_); FUSB3601_PolicySendVDM(port, DISCOVER_MODES, port->core_svid_info_.svids[port->auto_mode_disc_tracker_], SOP_TYPE_SOP, 0); break; #ifdef FSC_HAVE_DP case AUTO_VDM_ENTER_MODE_PP: if (port->display_port_data_.AutoModeEntryObjPos > 0) { FUSB3601_PolicySendVDM(port, ENTER_MODE, 0xFF01, SOP_TYPE_SOP, port->display_port_data_.AutoModeEntryObjPos); } else { port->auto_vdm_state_ = AUTO_VDM_DONE; } break; case AUTO_VDM_DP_GET_STATUS: if (port->display_port_data_.DpModeEntered) { FUSB3601_requestDpStatus(port); } else { port->auto_vdm_state_ = AUTO_VDM_DONE; } break; case AUTO_VDM_DP_SET_CONFIG: FUSB3601_requestDpConfig(port); break; #endif /* FSC_HAVE_DP */ default: port->auto_vdm_state_ = AUTO_VDM_DONE; break; } } /* Receiving end VDM functionality */ FSC_S32 FUSB3601_ProcessVdmMessage(struct Port *port) { port->expecting_vdm_response_ = FALSE; if (port->policy_rx_data_obj_[0].SVDM.VDMType == STRUCTURED_VDM) { switch (port->policy_rx_data_obj_[0].SVDM.Command) { case DISCOVER_IDENTITY: return FUSB3601_ProcessDiscoverIdentity(port, port->protocol_msg_rx_sop_); case DISCOVER_SVIDS: return FUSB3601_ProcessDiscoverSvids(port, port->protocol_msg_rx_sop_); case DISCOVER_MODES: return FUSB3601_ProcessDiscoverModes(port, port->protocol_msg_rx_sop_); case ENTER_MODE: return FUSB3601_ProcessEnterMode(port, port->protocol_msg_rx_sop_); case EXIT_MODE: return FUSB3601_ProcessExitMode(port, port->protocol_msg_rx_sop_); case ATTENTION: return FUSB3601_ProcessAttention(port, port->protocol_msg_rx_sop_); default: /* SVID-Specific commands go here */ return FUSB3601_ProcessSvidSpecific(port, port->protocol_msg_rx_sop_); } } else { /* Unstructured messages */ return 1; } } //TODO: AMA Support FSC_S32 FUSB3601_ProcessDiscoverIdentity(struct Port *port, SopType sop) { doDataObject_t vdm_out[7] = {{0}}; FSC_U8 num_data_obj = 4; IN_FUNCTION /* Must NAK or not respond to Discover ID with wrong SVID */ if (port->policy_rx_data_obj_[0].SVDM.SVID != PD_SID) return -1; if (port->policy_rx_data_obj_[0].SVDM.CommandType == INITIATOR) { vdm_out[0].SVDM.SVID = PD_SID; vdm_out[0].SVDM.VDMType = STRUCTURED_VDM; vdm_out[0].SVDM.Version = Structured_VDM_Version_SOP; vdm_out[0].SVDM.ObjPos = 0; vdm_out[0].SVDM.CommandType = RESPONDER_ACK; vdm_out[0].SVDM.Command = DISCOVER_IDENTITY; vdm_out[1].ID_HEADER_VDO.ModalOperationSupported = Modal_Operation_Supported_SOP; vdm_out[1].ID_HEADER_VDO.ProductType = Product_Type_SOP; vdm_out[1].ID_HEADER_VDO.USBDeviceCapable = Data_Capable_as_USB_Device_SOP; vdm_out[1].ID_HEADER_VDO.USBHostCapable = Data_Capable_as_USB_Host_SOP; vdm_out[1].ID_HEADER_VDO.VID = USB_VID_SOP; vdm_out[2].CERT_STAT_VDO.XID = XID_SOP; vdm_out[3].PRODUCT_VDO.PID = PID_SOP; vdm_out[3].PRODUCT_VDO.bcdDevice = bcdDevice_SOP; if (vdm_out[1].ID_HEADER_VDO.ProductType == AMA) { vdm_out[4].AMA_VDO.USBSuperSpeed = AMA_Superspeed_Support; vdm_out[4].AMA_VDO.VbusRequired = AMA_VBUS_reqd; vdm_out[4].AMA_VDO.VconnRequired = AMA_VCONN_reqd; vdm_out[4].AMA_VDO.VconnPower = AMA_VCONN_power; vdm_out[4].AMA_VDO.VDOVersion = 0x0; vdm_out[4].AMA_VDO.FirmwareVersion = AMA_FW_Vers; vdm_out[4].AMA_VDO.HWVersion = AMA_HW_Vers; num_data_obj++; } //TODO: set correct softreset for power role FUSB3601_ProtocolSendData(port, DMTVendorDefined, num_data_obj, vdm_out, 0, peSinkSendSoftReset, FALSE, sop); } else { /* Incoming responses, ACKs, NAKs, BUSYs */ if (port->policy_rx_data_obj_[0].SVDM.CommandType == RESPONDER_ACK) { port->partner_id_header_vdo = port->policy_rx_data_obj_[1]; port->partner_cert_stat_vdo = port->policy_rx_data_obj_[2]; port->partner_product_vdo = port->policy_rx_data_obj_[3]; if ((port->policy_rx_header_.NumDataObjects == 5)) { port->partner_product_type_vdo = port->policy_rx_data_obj_[4]; } //TODO: platform callback for success if(port->auto_vdm_state_ == AUTO_VDM_DISCOVER_ID_PP || port->auto_vdm_state_ == AUTO_VDM_INIT) { port->auto_vdm_state_ = AUTO_VDM_DISCOVER_SVIDS_PP; } } else { port->auto_vdm_state_ = AUTO_VDM_DONE; } return 0; } return 0; } FSC_S32 FUSB3601_ProcessDiscoverSvids(struct Port *port, SopType sop) { doDataObject_t vdm_out[(Num_SVIDs_min_SOP >> 1) + 2] = {{0}}; FSC_U8 i; FSC_U8 num_svids; FSC_U8 max_data_obj; FSC_U8 length = 1; IN_FUNCTION /* Must NAK or not respond to Discover SVIDs with wrong SVID */ if (port->policy_rx_data_obj_[0].SVDM.SVID != PD_SID) return -1; if (port->policy_rx_data_obj_[0].SVDM.CommandType == INITIATOR) { vdm_out[0].SVDM.SVID = PD_SID; vdm_out[0].SVDM.VDMType = STRUCTURED_VDM; vdm_out[0].SVDM.Version = Structured_VDM_Version_SOP; vdm_out[0].SVDM.ObjPos = 0; vdm_out[0].SVDM.Command = DISCOVER_SVIDS; if(Num_SVIDs_min_SOP != 0) { vdm_out[0].SVDM.CommandType = RESPONDER_ACK; //TODO: Implement #SVIDS from vendor_info.h vdm_out[1].SVID_VDO.SVID0 = port->my_svid_; vdm_out[1].SVID_VDO.SVID1 = 0x0000; length = 2; } else { vdm_out[0].SVDM.CommandType = RESPONDER_NAK; } FUSB3601_ProtocolSendData(port, DMTVendorDefined, length, vdm_out, 0, peSinkSendSoftReset, FALSE, sop); } else { /* Incoming responses, ACKs, NAKs, BUSYs */ num_svids = 0; max_data_obj = (MAX_NUM_SVIDS >> 1) + 2; if (port->policy_rx_data_obj_[0].SVDM.CommandType == RESPONDER_ACK) { if(max_data_obj < port->policy_rx_header_.NumDataObjects) { port->policy_rx_header_.NumDataObjects = max_data_obj; } for(i = 1; i < port->policy_rx_header_.NumDataObjects; i++) { if(port->policy_rx_data_obj_[i].SVID_VDO.SVID0 != 0) { port->core_svid_info_.svids[num_svids] = port->policy_rx_data_obj_[i].SVID_VDO.SVID0; num_svids++; } if(port->policy_rx_data_obj_[i].SVID_VDO.SVID1 != 0){ port->core_svid_info_.svids[num_svids] = port->policy_rx_data_obj_[i].SVID_VDO.SVID1; num_svids++; } } port->core_svid_info_.num_svids = num_svids; FUSB3601_platform_log(port->port_id_, "FUSB SVIDS ACK, Num: ", num_svids); if(port->auto_vdm_state_ == AUTO_VDM_DISCOVER_SVIDS_PP) { port->auto_vdm_state_ = AUTO_VDM_DISCOVER_MODES_PP; } if(num_svids == 12) { FUSB3601_PolicySendVDM(port, DISCOVER_SVIDS, 0xFF00, SOP_TYPE_SOP, 0); } } else { port->auto_vdm_state_ = AUTO_VDM_DONE; } return 0; } return 0; } FSC_S32 FUSB3601_ProcessDiscoverModes(struct Port *port, SopType sop) { doDataObject_t vdm_out[SVID1_num_modes_min_SOP + 1] = {{0}}; ModesInfo modes_info; FSC_U8 i; FSC_U8 length = 1; IN_FUNCTION FUSB3601_platform_log(port->port_id_, "FUSB Discover Modes", -1); if (port->policy_rx_data_obj_[0].SVDM.CommandType == INITIATOR) { vdm_out[0].SVDM.SVID = port->policy_rx_data_obj_[0].SVDM.SVID; vdm_out[0].SVDM.VDMType = STRUCTURED_VDM; vdm_out[0].SVDM.Version = Structured_VDM_Version_SOP; vdm_out[0].SVDM.ObjPos = 0; vdm_out[0].SVDM.Command = DISCOVER_MODES; if((SVID1_num_modes_min_SOP != 0) && (port->policy_rx_data_obj_[0].SVDM.SVID == port->my_svid_)) { vdm_out[0].SVDM.CommandType = RESPONDER_ACK; //TODO: Implement #Modes from vendor_info.h vdm_out[1].object = port->my_mode_; length = 2; } else { vdm_out[0].SVDM.CommandType = RESPONDER_NAK; } FUSB3601_ProtocolSendData(port, DMTVendorDefined, length, vdm_out, 0, peSinkSendSoftReset, FALSE, sop); return 0; } else { port->auto_mode_disc_tracker_++; /* Incoming responses, ACKs, NAKs, BUSYs */ if (port->policy_rx_data_obj_[0].SVDM.CommandType == RESPONDER_ACK) { FUSB3601_platform_log(port->port_id_, "FUSB Discover Modes ACK", -1); modes_info.svid = port->policy_rx_data_obj_[0].SVDM.SVID; modes_info.num_modes = port->policy_rx_header_.NumDataObjects - 1; if(modes_info.num_modes > MAX_MODES_PER_SVID) { modes_info.num_modes = MAX_MODES_PER_SVID; } for (i = 0; i < modes_info.num_modes; i++) { modes_info.modes[i] = port->policy_rx_data_obj_[i + 1].object; } modes_info.nack = FALSE; if(port->auto_mode_disc_tracker_ == (port->core_svid_info_.num_svids)) { FUSB3601_platform_log(port->port_id_, "FUSB Discover Modes: All Modes Discovered", -1); port->auto_vdm_state_ = AUTO_VDM_ENTER_MODE_PP; } } else { modes_info.nack = TRUE; port->auto_vdm_state_ = AUTO_VDM_ENTER_MODE_PP; } FUSB3601_VdmInformModes(port, sop, modes_info); } return 0; } FSC_S32 FUSB3601_ProcessEnterMode(struct Port *port, SopType sop) { doDataObject_t vdm_out[1] = {{0}}; FSC_BOOL mode_entered; IN_FUNCTION if (port->policy_rx_data_obj_[0].SVDM.CommandType == INITIATOR) { mode_entered = FUSB3601_VdmModeEntryRequest(port, port->policy_rx_data_obj_[0].SVDM.SVID, port->policy_rx_data_obj_[0].SVDM.ObjPos); /* if DPM says OK, respond with ACK */ if (mode_entered) { /* entered mode successfully */ vdm_out[0].SVDM.CommandType = RESPONDER_ACK; } else { /* NAK if mode not entered */ vdm_out[0].SVDM.CommandType = RESPONDER_NAK; } /* most of the message response will be the same whether we entered the mode or not */ vdm_out[0].SVDM.SVID = port->policy_rx_data_obj_[0].SVDM.SVID; vdm_out[0].SVDM.VDMType = STRUCTURED_VDM; vdm_out[0].SVDM.Version = Structured_VDM_Version_SOP; vdm_out[0].SVDM.ObjPos = port->policy_rx_data_obj_[0].SVDM.ObjPos; vdm_out[0].SVDM.Command = ENTER_MODE; FUSB3601_ProtocolSendData(port, DMTVendorDefined, 1, vdm_out, 0, peSinkSendSoftReset, FALSE, sop); return 0; } else { /* Incoming responses, ACKs, NAKs, BUSYs */ if (port->policy_rx_data_obj_[0].SVDM.CommandType != RESPONDER_ACK) { FUSB3601_VdmEnterModeResult(port, FALSE, port->policy_rx_data_obj_[0].SVDM.SVID, port->policy_rx_data_obj_[0].SVDM.ObjPos); FUSB3601_AutoVdmDiscovery(port); } else { FUSB3601_VdmEnterModeResult(port, TRUE, port->policy_rx_data_obj_[0].SVDM.SVID, port->policy_rx_data_obj_[0].SVDM.ObjPos); if(port->auto_vdm_state_ == AUTO_VDM_ENTER_MODE_PP) { port->auto_vdm_state_ = AUTO_VDM_DP_GET_STATUS; } port->mode_entered_ = TRUE; } } return 0; } FSC_S32 FUSB3601_ProcessExitMode(struct Port *port, SopType sop) { doDataObject_t vdm_out[1] = {{0}}; FSC_BOOL mode_exited; IN_FUNCTION if (port->policy_rx_data_obj_[0].SVDM.CommandType == INITIATOR) { mode_exited = FUSB3601_VdmModeExitRequest(port, port->policy_rx_data_obj_[0].SVDM.SVID, port->policy_rx_data_obj_[0].SVDM.ObjPos); /* if DPM says OK, respond with ACK */ if (mode_exited) { vdm_out[0].SVDM.CommandType = RESPONDER_ACK; } else { /* NAK if mode not exited */ vdm_out[0].SVDM.CommandType = RESPONDER_NAK; } vdm_out[0].SVDM.SVID = port->policy_rx_data_obj_[0].SVDM.SVID; vdm_out[0].SVDM.VDMType = STRUCTURED_VDM; vdm_out[0].SVDM.Version = Structured_VDM_Version_SOP;\ vdm_out[0].SVDM.ObjPos = port->policy_rx_data_obj_[0].SVDM.ObjPos; vdm_out[0].SVDM.Command = EXIT_MODE; FUSB3601_ProtocolSendData(port, DMTVendorDefined, 1, vdm_out, 0, peSinkSendSoftReset, FALSE, sop); return 0; } else { if (port->policy_rx_data_obj_[0].SVDM.CommandType != RESPONDER_ACK) { FUSB3601_VdmExitModeResult(port, FALSE, port->policy_rx_data_obj_[0].SVDM.SVID, port->policy_rx_data_obj_[0].SVDM.ObjPos); /* when exit mode not ACKed, go to hard reset state! */ FUSB3601_ProtocolSendHardReset(port); } else { FUSB3601_VdmExitModeResult(port, TRUE, port->policy_rx_data_obj_[0].SVDM.SVID, port->policy_rx_data_obj_[0].SVDM.ObjPos); } return 0; } return 0; } FSC_S32 FUSB3601_ProcessAttention(struct Port *port, SopType sop) { DisplayPortStatus_t __attention_status; IN_FUNCTION FUSB3601_platform_log(port->port_id_, "FUSB Process Attention, DpPpConfig: ", port->display_port_data_.DpPpConfig.word); if (!port->mode_entered_) { /* Unexpected message */ FUSB3601_set_policy_state(port, peSourceSoftReset); FUSB3601_PolicySourceSendSoftReset(port); return 0; } if ((port->policy_rx_data_obj_[0].SVDM.SVID == DP_SID) && (port->policy_rx_header_.NumDataObjects == 2)) { FUSB3601_platform_log(port->port_id_, "FUSB Process Attention, AutoVdm: ", port->auto_vdm_state_); __attention_status.word = port->policy_rx_data_obj_[1].object; FUSB3601_informStatus(port, __attention_status); if((port->display_port_data_.DpPpConfig.word == 0)) { FUSB3601_requestDpConfig(port); } } return 0; } FSC_S32 FUSB3601_ProcessSvidSpecific(struct Port *port, SopType sop) { doDataObject_t vdm_out[1] = {{0}}; IN_FUNCTION #ifdef FSC_HAVE_DP if (port->policy_rx_data_obj_[0].SVDM.SVID == DP_SID) { if (!FUSB3601_processDpCommand(port, &port->policy_rx_data_obj_[0].object)) { return 0; /* DP code will send response, so return */ } } #endif /* FSC_HAVE_DP */ /* in this case the command is unrecognized. Reply with a NAK. */ vdm_out[0].SVDM.SVID = port->policy_rx_data_obj_[0].SVDM.SVID; vdm_out[0].SVDM.VDMType = STRUCTURED_VDM; vdm_out[0].SVDM.Version = Structured_VDM_Version_SOP; vdm_out[0].SVDM.ObjPos = 0; vdm_out[0].SVDM.CommandType = RESPONDER_NAK; vdm_out[0].SVDM.Command = port->policy_rx_data_obj_[0].SVDM.Command; FUSB3601_ProtocolSendData(port, DMTVendorDefined, 0, vdm_out, 0, peSinkSendSoftReset, FALSE, sop); return 0; } FSC_U32 FUSB3601_GetVdmTimer(Command command) { FSC_U32 timer; IN_FUNCTION /* start the appropriate timer */ switch (command) { case DISCOVER_IDENTITY: case DISCOVER_SVIDS: case DISCOVER_MODES: case ATTENTION: timer = ktVDMSenderResponse; break; case ENTER_MODE: timer = ktVDMWaitModeEntry; break; case EXIT_MODE: timer = ktVDMWaitModeExit; break; default: timer = 0; break; } return timer; } void FUSB3601_ResetPolicyState(struct Port *port) { // Need a callback that informs that a vdm request failed IN_FUNCTION port->expecting_vdm_response_ = FALSE; } FSC_BOOL FUSB3601_VdmModeEntryRequest(struct Port *port, FSC_U16 svid, FSC_U32 mode_index) { IN_FUNCTION if ((port->svid_enable_ == TRUE) && (port->mode_enable_ == TRUE) && (svid == port->my_svid_) && (mode_index == 1)) { port->mode_entered_ = TRUE; #ifdef FSC_HAVE_DP if (port->my_svid_ == DP_SID) { port->display_port_data_.DpModeEntered = mode_index; } #endif /* FSC_HAVE_DP */ return TRUE; } return FALSE; } FSC_BOOL FUSB3601_VdmModeExitRequest(struct Port *port, FSC_U16 svid, FSC_U32 mode_index) { IN_FUNCTION if (port->mode_entered_ == TRUE && svid == port->my_svid_ && mode_index == 1) { port->mode_entered_ = FALSE; #ifdef FSC_HAVE_DP if (port->display_port_data_.DpModeEntered && (port->display_port_data_.DpModeEntered == mode_index) && (svid == DP_SID)) { port->display_port_data_.DpModeEntered = 0; } #endif /* FSC_HAVE_DP */ return TRUE; } return FALSE; } FSC_BOOL FUSB3601_VdmEnterModeResult(struct Port *port, FSC_BOOL success, FSC_U16 svid, FSC_U32 mode_index) { IN_FUNCTION #ifdef FSC_HAVE_DP if (port->display_port_data_.AutoModeEntryObjPos > 0) { port->display_port_data_.AutoModeEntryObjPos = 0; } if (svid == DP_SID) { port->display_port_data_.DpModeEntered = mode_index; } #endif /* FSC_HAVE_DP */ return TRUE; } void FUSB3601_VdmExitModeResult(struct Port *port, FSC_BOOL success, FSC_U16 svid, FSC_U32 mode_index) { IN_FUNCTION #ifdef FSC_HAVE_DP if (svid == DP_SID && port->display_port_data_.DpModeEntered == mode_index) { port->display_port_data_.DpModeEntered = 0; } #endif /* FSC_HAVE_DP */ } void FUSB3601_VdmInformModes(struct Port *port, SopType sop, ModesInfo modes_info) { #ifdef FSC_HAVE_DP FSC_U32 i; if (modes_info.svid == DP_SID && modes_info.nack == FALSE) { FUSB3601_platform_log(port->port_id_, "FUSB DP Detected", -1); for (i = 0; i < modes_info.num_modes; ++i) { if (FUSB3601_dpEvaluateModeEntry(port, modes_info.modes[i])) { FUSB3601_platform_log(port->port_id_, "FUSB DP Accepted", -1); port->display_port_data_.AutoModeEntryObjPos = i + 1; } } } #endif /* FSC_HAVE_DP */ IN_FUNCTION } void FUSB3601_VdmInitDpm(struct Port *port) { IN_FUNCTION port->svid_enable_ = TRUE; port->mode_enable_ = TRUE; port->my_svid_ = SVID_DEFAULT; port->my_mode_ = MODE_DEFAULT; port->mode_entered_ = FALSE; } #endif /* FSC_HAVE_VDM */
the_stack_data/150139596.c
#include <stdio.h> int main(){ int n; int m; int k; scanf("%d", &n); scanf("%d", &m); scanf("%d", &k); float discount = 0.0; int total = 0, b = k; for(int i = 0; i < n; i++){ if(i == k){ discount += 0.02; k += b; } total += m - (discount * m); } printf("%d\n", total); return 0; }
the_stack_data/105809.c
#include<stdio.h> //printf #include<string.h> //memset #include<stdlib.h> //for exit(0); #include<sys/socket.h> #include<errno.h> //For errno - the error number #include<netdb.h> //hostent #include<arpa/inet.h> int hostname_to_ip(char * , char *); int main(int argc , char *argv[]) { if(argc <2) { printf("Please provide a hostname to resolve"); exit(1); } char *hostname = argv[1]; char ip[100]; hostname_to_ip(hostname , ip); printf("%s resolved to %s" , hostname , ip); printf("\n"); } /* Get ip from domain name */ int hostname_to_ip(char *hostname , char *ip) { int sockfd; struct addrinfo hints, *servinfo, *p; struct sockaddr_in *h; int rv; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; // use AF_INET6 to force IPv6 hints.ai_socktype = SOCK_STREAM; if ( (rv = getaddrinfo( hostname , "http" , &hints , &servinfo)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); return 1; } // loop through all the results and connect to the first we can for(p = servinfo; p != NULL; p = p->ai_next) { h = (struct sockaddr_in *) p->ai_addr; strcpy(ip , inet_ntoa( h->sin_addr ) ); } freeaddrinfo(servinfo); // all done with this structure return 0; }
the_stack_data/48575952.c
/* * Author : Jacob Samro * 02-12-2014 : 12:17 AM * Print 1 to 10 without looping * */ #include<stdio.h> int j=0; void print(int); int main() { int a[10] ={1,2,3,4,5,6,7,8,9,10}; print(a[j]); ++j; } void print(int a) { if(j<10) { printf("%d\t",a); j++; main(); } }
the_stack_data/43334.c
#include <stdio.h> int main() { double salario; scanf("%lf", &salario); if (salario >= 0 && salario <= 2000) { printf("Isento\n"); } if(salario >= 2000.01 && salario <= 3000){ printf("R$ %.2lf\n",(salario - 2000) * 0.08); } if(salario >= 3000.01 && salario <= 4500){ printf("R$ %.2lf\n",((salario - 3000) * 0.18) + (salario - (salario - 3000)-2000) * 0.08); } if(salario > 4500){ printf("R$ %.2lf\n",((salario - 4500) * 0.28) + ((salario -3000-(salario-4500)) * 0.18) + (salario - 2000 - (salario-4500)-(salario-(salario - 4500)-3000))* 0.08); } return 0; }
the_stack_data/64472.c
#include <stdio.h> unsigned int factorial(unsigned int n) { int fact = 1, i; for (i = 2; i <= n; i++) fact *= i; return fact; } int main() { int num; printf("Enter a non-negative number: "); scanf("%d",&num); if(num<0){ printf("Factorial of a negative integer cannot be found"); } else{ printf("Factorial of %d is %d", num , factorial(num)); } return 0; }
the_stack_data/231393991.c
#include <stdio.h> int main() { int n; printf("Enter the number of rows"); scanf("%d",&n); for(int i=n;i>=1;i--) { for(int j=1;j<=i-1;j++) { printf(" "); } for(int k=1;k<=n;k++) { printf("*"); } printf("\n"); } return 0; }
the_stack_data/9511608.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> #include <errno.h> #include <mqueue.h> #define QUEUE_NAME "/sharedqueue" #define BUFFER_SIZE 1024 #define EXIT_MSG_SIGNAL "done" #define MODE "-producer" int main(int argc, char *argv[]) { if (argc < 2) { producer(); } else if (argc >= 2 && 0 == strncmp(argv[1], MODE, strlen(MODE))) { producer(); } else { consumer(); } } int producer() { mqd_t mq; struct mq_attr attr; char buffer[BUFFER_SIZE]; int msg, i; attr.mq_flags = 0; attr.mq_maxmsg = 10; attr.mq_msgsize = BUFFER_SIZE; attr.mq_curmsgs = 0; mq = mq_open(QUEUE_NAME, O_CREAT | O_WRONLY, 0644, &attr); // seed random srand(time(NULL)); i = 0; while (i < 500) { msg = rand() % 256; memset(buffer, 0, BUFFER_SIZE); sprintf(buffer, "%x", msg); printf("Written to Queue: %s\n", buffer); fflush(stdout); mq_send(mq, buffer, BUFFER_SIZE, 0); i=i+1; } memset(buffer, 0, BUFFER_SIZE); sprintf(buffer, EXIT_MSG_SIGNAL); mq_send(mq, buffer, BUFFER_SIZE, 0); mq_close(mq); mq_unlink(QUEUE_NAME); return 0; } int consumer() { struct mq_attr attr; char buffer[BUFFER_SIZE + 1]; ssize_t bytes_read; mqd_t mq = mq_open(QUEUE_NAME, O_RDONLY); if ((mqd_t)-1 == mq) { printf("Queue is inaccessible or empty...\n"); exit(1); } do { bytes_read = mq_receive(mq, buffer, BUFFER_SIZE, NULL); buffer[bytes_read] = '\0'; printf("Read from Queue: %s\n", buffer); } while (0 != strncmp(buffer, EXIT_MSG_SIGNAL, strlen(EXIT_MSG_SIGNAL))); mq_close(mq); return 0; }
the_stack_data/84134.c
#include <stdio.h> #define MAXLINE 1000 /* maximum input line size */ #define UP 60 /* print lines beyond this number */ int getLine(char line[], int maxline); /* print all input lines are longer than 80 characters */ int main() { int i, len; /* current line length */ char line[MAXLINE]; /* current input line */ while ((len = getLine(line, MAXLINE)) > 0) if (len > UP) { printf("%s", line); /* clear line */ while (len>0) line[len--] = ' '; } return 0; } /* getline: read a line into s, return length */ int getLine(char s[], int lim) { int c,i; // 最大只会获取 lim 长度的文本 for (i=0; i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i) s[i] = c; if (c == '\n') { s[i] = c; ++i; } s[i] = '\0'; /* end of line */ return i; }
the_stack_data/61076164.c
#include <stdio.h> #define NL "\n" int main(){ printf("Line1%s",NL); printf("line2%s",NL); return 0; }
the_stack_data/24960.c
#include <stdio.h> int test() { struct T { int x; } s1; s1.x = 1; { struct T { int y; } s2; s2.y = 1; if (s1.x - s2.y != 0) return 1; } return 0; } int main () { int x; x = test(); printf("%d\n", x); return 0; }
the_stack_data/26701685.c
/** * @file launch_processes.c * @author your name ([email protected]) * @brief * @version 0.1 * @date 2020-02-03 * * @copyright Copyright (c) 2020 * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { int pid_button, pid_led; int button_status, led_status; pid_button = fork(); if(pid_button == 0) { //start button process char *args[] = {"./button_process", NULL}; button_status = execvp(args[0], args); printf("Error to start button process, status = %d\n", button_status); abort(); } pid_led = fork(); if(pid_led == 0) { //Start led process char *args[] = {"./led_process", NULL}; led_status = execvp(args[0], args); printf("Error to start led process, status = %d\n", led_status); abort(); } return EXIT_SUCCESS; }
the_stack_data/67324177.c
/* * i386 signal handling routines * * Copyright 1999 Alexandre Julliard * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #if 0 #pragma makedep unix #endif #ifdef __i386__ #include "config.h" #include "wine/port.h" #include <errno.h> #include <signal.h> #include <stdlib.h> #include <stdarg.h> #include <stdio.h> #include <sys/types.h> #include <assert.h> #ifdef HAVE_UNISTD_H # include <unistd.h> #endif #ifdef HAVE_SYS_PARAM_H # include <sys/param.h> #endif #ifdef HAVE_SYSCALL_H # include <syscall.h> #else # ifdef HAVE_SYS_SYSCALL_H # include <sys/syscall.h> # endif #endif #ifdef HAVE_SYS_SIGNAL_H # include <sys/signal.h> #endif #ifdef HAVE_SYS_UCONTEXT_H # include <sys/ucontext.h> #endif #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" #include "winternl.h" #include "ddk/wdm.h" #include "wine/asm.h" #include "wine/exception.h" #include "unix_private.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(seh); #undef ERR /* Solaris needs to define this */ /*********************************************************************** * signal context platform-specific definitions */ #ifdef __linux__ #ifndef HAVE_SYS_UCONTEXT_H enum { REG_GS, REG_FS, REG_ES, REG_DS, REG_EDI, REG_ESI, REG_EBP, REG_ESP, REG_EBX, REG_EDX, REG_ECX, REG_EAX, REG_TRAPNO, REG_ERR, REG_EIP, REG_CS, REG_EFL, REG_UESP, REG_SS, NGREG }; typedef int greg_t; typedef greg_t gregset_t[NGREG]; struct _libc_fpreg { unsigned short significand[4]; unsigned short exponent; }; struct _libc_fpstate { unsigned long cw; unsigned long sw; unsigned long tag; unsigned long ipoff; unsigned long cssel; unsigned long dataoff; unsigned long datasel; struct _libc_fpreg _st[8]; unsigned long status; }; typedef struct _libc_fpstate* fpregset_t; typedef struct { gregset_t gregs; fpregset_t fpregs; unsigned long oldmask; unsigned long cr2; } mcontext_t; typedef struct ucontext { unsigned long uc_flags; struct ucontext *uc_link; stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; } ucontext_t; #endif /* HAVE_SYS_UCONTEXT_H */ #ifndef FP_XSTATE_MAGIC1 #define FP_XSTATE_MAGIC1 0x46505853 #endif #define EAX_sig(context) ((context)->uc_mcontext.gregs[REG_EAX]) #define EBX_sig(context) ((context)->uc_mcontext.gregs[REG_EBX]) #define ECX_sig(context) ((context)->uc_mcontext.gregs[REG_ECX]) #define EDX_sig(context) ((context)->uc_mcontext.gregs[REG_EDX]) #define ESI_sig(context) ((context)->uc_mcontext.gregs[REG_ESI]) #define EDI_sig(context) ((context)->uc_mcontext.gregs[REG_EDI]) #define EBP_sig(context) ((context)->uc_mcontext.gregs[REG_EBP]) #define ESP_sig(context) ((context)->uc_mcontext.gregs[REG_ESP]) #define CS_sig(context) ((context)->uc_mcontext.gregs[REG_CS]) #define DS_sig(context) ((context)->uc_mcontext.gregs[REG_DS]) #define ES_sig(context) ((context)->uc_mcontext.gregs[REG_ES]) #define SS_sig(context) ((context)->uc_mcontext.gregs[REG_SS]) #define FS_sig(context) ((context)->uc_mcontext.gregs[REG_FS]) #define GS_sig(context) ((context)->uc_mcontext.gregs[REG_GS]) #define EFL_sig(context) ((context)->uc_mcontext.gregs[REG_EFL]) #define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP]) #define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) #define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR]) #define FPU_sig(context) ((FLOATING_SAVE_AREA*)((context)->uc_mcontext.fpregs)) #define FPUX_sig(context) (FPU_sig(context) && !((context)->uc_mcontext.fpregs->status >> 16) ? (XSAVE_FORMAT *)(FPU_sig(context) + 1) : NULL) #define XState_sig(fpu) (((unsigned int *)fpu->Reserved4)[12] == FP_XSTATE_MAGIC1 ? (XSTATE *)(fpu + 1) : NULL) #ifdef __ANDROID__ /* custom signal restorer since we may have unmapped the one in vdso, and bionic doesn't check for that */ void rt_sigreturn(void); __ASM_GLOBAL_FUNC( rt_sigreturn, "movl $173,%eax\n\t" /* NR_rt_sigreturn */ "int $0x80" ); #endif struct modify_ldt_s { unsigned int entry_number; void *base_addr; unsigned int limit; unsigned int seg_32bit : 1; unsigned int contents : 2; unsigned int read_exec_only : 1; unsigned int limit_in_pages : 1; unsigned int seg_not_present : 1; unsigned int usable : 1; unsigned int garbage : 25; }; static inline int modify_ldt( int func, struct modify_ldt_s *ptr, unsigned long count ) { return syscall( 123 /* SYS_modify_ldt */, func, ptr, count ); } static inline int set_thread_area( struct modify_ldt_s *ptr ) { return syscall( 243 /* SYS_set_thread_area */, ptr ); } #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #include <machine/trap.h> #include <machine/segments.h> #include <machine/sysarch.h> #define EAX_sig(context) ((context)->uc_mcontext.mc_eax) #define EBX_sig(context) ((context)->uc_mcontext.mc_ebx) #define ECX_sig(context) ((context)->uc_mcontext.mc_ecx) #define EDX_sig(context) ((context)->uc_mcontext.mc_edx) #define ESI_sig(context) ((context)->uc_mcontext.mc_esi) #define EDI_sig(context) ((context)->uc_mcontext.mc_edi) #define EBP_sig(context) ((context)->uc_mcontext.mc_ebp) #define CS_sig(context) ((context)->uc_mcontext.mc_cs) #define DS_sig(context) ((context)->uc_mcontext.mc_ds) #define ES_sig(context) ((context)->uc_mcontext.mc_es) #define FS_sig(context) ((context)->uc_mcontext.mc_fs) #define GS_sig(context) ((context)->uc_mcontext.mc_gs) #define SS_sig(context) ((context)->uc_mcontext.mc_ss) #define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno) #define ERROR_sig(context) ((context)->uc_mcontext.mc_err) #define EFL_sig(context) ((context)->uc_mcontext.mc_eflags) #define EIP_sig(context) ((context)->uc_mcontext.mc_eip) #define ESP_sig(context) ((context)->uc_mcontext.mc_esp) #define FPU_sig(context) NULL /* FIXME */ #define FPUX_sig(context) NULL /* FIXME */ #define XState_sig(context) NULL /* FIXME */ #elif defined (__OpenBSD__) #include <machine/segments.h> #include <machine/sysarch.h> #define EAX_sig(context) ((context)->sc_eax) #define EBX_sig(context) ((context)->sc_ebx) #define ECX_sig(context) ((context)->sc_ecx) #define EDX_sig(context) ((context)->sc_edx) #define ESI_sig(context) ((context)->sc_esi) #define EDI_sig(context) ((context)->sc_edi) #define EBP_sig(context) ((context)->sc_ebp) #define CS_sig(context) ((context)->sc_cs) #define DS_sig(context) ((context)->sc_ds) #define ES_sig(context) ((context)->sc_es) #define FS_sig(context) ((context)->sc_fs) #define GS_sig(context) ((context)->sc_gs) #define SS_sig(context) ((context)->sc_ss) #define TRAP_sig(context) ((context)->sc_trapno) #define ERROR_sig(context) ((context)->sc_err) #define EFL_sig(context) ((context)->sc_eflags) #define EIP_sig(context) ((context)->sc_eip) #define ESP_sig(context) ((context)->sc_esp) #define FPU_sig(context) NULL /* FIXME */ #define FPUX_sig(context) NULL /* FIXME */ #define XState_sig(context) NULL /* FIXME */ #define T_MCHK T_MACHK #define T_XMMFLT T_XFTRAP #elif defined(__svr4__) || defined(_SCO_DS) || defined(__sun) #if defined(_SCO_DS) || defined(__sun) #include <sys/regset.h> #endif #ifdef _SCO_DS #define gregs regs #endif #define EAX_sig(context) ((context)->uc_mcontext.gregs[EAX]) #define EBX_sig(context) ((context)->uc_mcontext.gregs[EBX]) #define ECX_sig(context) ((context)->uc_mcontext.gregs[ECX]) #define EDX_sig(context) ((context)->uc_mcontext.gregs[EDX]) #define ESI_sig(context) ((context)->uc_mcontext.gregs[ESI]) #define EDI_sig(context) ((context)->uc_mcontext.gregs[EDI]) #define EBP_sig(context) ((context)->uc_mcontext.gregs[EBP]) #define CS_sig(context) ((context)->uc_mcontext.gregs[CS]) #define DS_sig(context) ((context)->uc_mcontext.gregs[DS]) #define ES_sig(context) ((context)->uc_mcontext.gregs[ES]) #define SS_sig(context) ((context)->uc_mcontext.gregs[SS]) #define FS_sig(context) ((context)->uc_mcontext.gregs[FS]) #define GS_sig(context) ((context)->uc_mcontext.gregs[GS]) #define EFL_sig(context) ((context)->uc_mcontext.gregs[EFL]) #define EIP_sig(context) ((context)->uc_mcontext.gregs[EIP]) #ifdef UESP #define ESP_sig(context) ((context)->uc_mcontext.gregs[UESP]) #elif defined(R_ESP) #define ESP_sig(context) ((context)->uc_mcontext.gregs[R_ESP]) #else #define ESP_sig(context) ((context)->uc_mcontext.gregs[ESP]) #endif #define ERROR_sig(context) ((context)->uc_mcontext.gregs[ERR]) #define TRAP_sig(context) ((context)->uc_mcontext.gregs[TRAPNO]) #define FPU_sig(context) NULL /* FIXME */ #define FPUX_sig(context) NULL /* FIXME */ #define XState_sig(context) NULL /* FIXME */ #elif defined (__APPLE__) #include <i386/user_ldt.h> /* work around silly renaming of struct members in OS X 10.5 */ #if __DARWIN_UNIX03 && defined(_STRUCT_X86_EXCEPTION_STATE32) #define EAX_sig(context) ((context)->uc_mcontext->__ss.__eax) #define EBX_sig(context) ((context)->uc_mcontext->__ss.__ebx) #define ECX_sig(context) ((context)->uc_mcontext->__ss.__ecx) #define EDX_sig(context) ((context)->uc_mcontext->__ss.__edx) #define ESI_sig(context) ((context)->uc_mcontext->__ss.__esi) #define EDI_sig(context) ((context)->uc_mcontext->__ss.__edi) #define EBP_sig(context) ((context)->uc_mcontext->__ss.__ebp) #define CS_sig(context) ((context)->uc_mcontext->__ss.__cs) #define DS_sig(context) ((context)->uc_mcontext->__ss.__ds) #define ES_sig(context) ((context)->uc_mcontext->__ss.__es) #define FS_sig(context) ((context)->uc_mcontext->__ss.__fs) #define GS_sig(context) ((context)->uc_mcontext->__ss.__gs) #define SS_sig(context) ((context)->uc_mcontext->__ss.__ss) #define EFL_sig(context) ((context)->uc_mcontext->__ss.__eflags) #define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->__ss.__eip)) #define ESP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->__ss.__esp)) #define TRAP_sig(context) ((context)->uc_mcontext->__es.__trapno) #define ERROR_sig(context) ((context)->uc_mcontext->__es.__err) #define FPU_sig(context) NULL #define FPUX_sig(context) ((XSAVE_FORMAT *)&(context)->uc_mcontext->__fs.__fpu_fcw) #define XState_sig(context) NULL /* FIXME */ #else #define EAX_sig(context) ((context)->uc_mcontext->ss.eax) #define EBX_sig(context) ((context)->uc_mcontext->ss.ebx) #define ECX_sig(context) ((context)->uc_mcontext->ss.ecx) #define EDX_sig(context) ((context)->uc_mcontext->ss.edx) #define ESI_sig(context) ((context)->uc_mcontext->ss.esi) #define EDI_sig(context) ((context)->uc_mcontext->ss.edi) #define EBP_sig(context) ((context)->uc_mcontext->ss.ebp) #define CS_sig(context) ((context)->uc_mcontext->ss.cs) #define DS_sig(context) ((context)->uc_mcontext->ss.ds) #define ES_sig(context) ((context)->uc_mcontext->ss.es) #define FS_sig(context) ((context)->uc_mcontext->ss.fs) #define GS_sig(context) ((context)->uc_mcontext->ss.gs) #define SS_sig(context) ((context)->uc_mcontext->ss.ss) #define EFL_sig(context) ((context)->uc_mcontext->ss.eflags) #define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->ss.eip)) #define ESP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->ss.esp)) #define TRAP_sig(context) ((context)->uc_mcontext->es.trapno) #define ERROR_sig(context) ((context)->uc_mcontext->es.err) #define FPU_sig(context) NULL #define FPUX_sig(context) ((XSAVE_FORMAT *)&(context)->uc_mcontext->fs.fpu_fcw) #define XState_sig(context) NULL /* FIXME */ #endif #elif defined(__NetBSD__) #include <machine/segments.h> #include <machine/sysarch.h> #define EAX_sig(context) ((context)->uc_mcontext.__gregs[_REG_EAX]) #define EBX_sig(context) ((context)->uc_mcontext.__gregs[_REG_EBX]) #define ECX_sig(context) ((context)->uc_mcontext.__gregs[_REG_ECX]) #define EDX_sig(context) ((context)->uc_mcontext.__gregs[_REG_EDX]) #define ESI_sig(context) ((context)->uc_mcontext.__gregs[_REG_ESI]) #define EDI_sig(context) ((context)->uc_mcontext.__gregs[_REG_EDI]) #define EBP_sig(context) ((context)->uc_mcontext.__gregs[_REG_EBP]) #define ESP_sig(context) _UC_MACHINE_SP(context) #define CS_sig(context) ((context)->uc_mcontext.__gregs[_REG_CS]) #define DS_sig(context) ((context)->uc_mcontext.__gregs[_REG_DS]) #define ES_sig(context) ((context)->uc_mcontext.__gregs[_REG_ES]) #define SS_sig(context) ((context)->uc_mcontext.__gregs[_REG_SS]) #define FS_sig(context) ((context)->uc_mcontext.__gregs[_REG_FS]) #define GS_sig(context) ((context)->uc_mcontext.__gregs[_REG_GS]) #define EFL_sig(context) ((context)->uc_mcontext.__gregs[_REG_EFL]) #define EIP_sig(context) _UC_MACHINE_PC(context) #define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) #define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR]) #define FPU_sig(context) NULL #define FPUX_sig(context) ((XSAVE_FORMAT *)&((context)->uc_mcontext.__fpregs)) #define XState_sig(context) NULL /* FIXME */ #define T_MCHK T_MCA #define T_XMMFLT T_XMM #elif defined(__GNU__) #include <mach/i386/mach_i386.h> #include <mach/mach_traps.h> #define EAX_sig(context) ((context)->uc_mcontext.gregs[REG_EAX]) #define EBX_sig(context) ((context)->uc_mcontext.gregs[REG_EBX]) #define ECX_sig(context) ((context)->uc_mcontext.gregs[REG_ECX]) #define EDX_sig(context) ((context)->uc_mcontext.gregs[REG_EDX]) #define ESI_sig(context) ((context)->uc_mcontext.gregs[REG_ESI]) #define EDI_sig(context) ((context)->uc_mcontext.gregs[REG_EDI]) #define EBP_sig(context) ((context)->uc_mcontext.gregs[REG_EBP]) #define ESP_sig(context) ((context)->uc_mcontext.gregs[REG_ESP]) #define CS_sig(context) ((context)->uc_mcontext.gregs[REG_CS]) #define DS_sig(context) ((context)->uc_mcontext.gregs[REG_DS]) #define ES_sig(context) ((context)->uc_mcontext.gregs[REG_ES]) #define SS_sig(context) ((context)->uc_mcontext.gregs[REG_SS]) #define FS_sig(context) ((context)->uc_mcontext.gregs[REG_FS]) #define GS_sig(context) ((context)->uc_mcontext.gregs[REG_GS]) #define EFL_sig(context) ((context)->uc_mcontext.gregs[REG_EFL]) #define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP]) #define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) #define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR]) #define FPU_sig(context) ((FLOATING_SAVE_AREA *)&(context)->uc_mcontext.fpregs.fp_reg_set.fpchip_state) #define FPUX_sig(context) NULL #define XState_sig(context) NULL /* FIXME */ #else #error You must define the signal context functions for your platform #endif /* linux */ static ULONG first_ldt_entry = 32; enum i386_trap_code { #if defined(__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) TRAP_x86_DIVIDE = T_DIVIDE, /* Division by zero exception */ TRAP_x86_TRCTRAP = T_TRCTRAP, /* Single-step exception */ TRAP_x86_NMI = T_NMI, /* NMI interrupt */ TRAP_x86_BPTFLT = T_BPTFLT, /* Breakpoint exception */ TRAP_x86_OFLOW = T_OFLOW, /* Overflow exception */ TRAP_x86_BOUND = T_BOUND, /* Bound range exception */ TRAP_x86_PRIVINFLT = T_PRIVINFLT, /* Invalid opcode exception */ TRAP_x86_DNA = T_DNA, /* Device not available exception */ TRAP_x86_DOUBLEFLT = T_DOUBLEFLT, /* Double fault exception */ TRAP_x86_FPOPFLT = T_FPOPFLT, /* Coprocessor segment overrun */ TRAP_x86_TSSFLT = T_TSSFLT, /* Invalid TSS exception */ TRAP_x86_SEGNPFLT = T_SEGNPFLT, /* Segment not present exception */ TRAP_x86_STKFLT = T_STKFLT, /* Stack fault */ TRAP_x86_PROTFLT = T_PROTFLT, /* General protection fault */ TRAP_x86_PAGEFLT = T_PAGEFLT, /* Page fault */ TRAP_x86_ARITHTRAP = T_ARITHTRAP, /* Floating point exception */ TRAP_x86_ALIGNFLT = T_ALIGNFLT, /* Alignment check exception */ TRAP_x86_MCHK = T_MCHK, /* Machine check exception */ TRAP_x86_CACHEFLT = T_XMMFLT /* Cache flush exception */ #else TRAP_x86_DIVIDE = 0, /* Division by zero exception */ TRAP_x86_TRCTRAP = 1, /* Single-step exception */ TRAP_x86_NMI = 2, /* NMI interrupt */ TRAP_x86_BPTFLT = 3, /* Breakpoint exception */ TRAP_x86_OFLOW = 4, /* Overflow exception */ TRAP_x86_BOUND = 5, /* Bound range exception */ TRAP_x86_PRIVINFLT = 6, /* Invalid opcode exception */ TRAP_x86_DNA = 7, /* Device not available exception */ TRAP_x86_DOUBLEFLT = 8, /* Double fault exception */ TRAP_x86_FPOPFLT = 9, /* Coprocessor segment overrun */ TRAP_x86_TSSFLT = 10, /* Invalid TSS exception */ TRAP_x86_SEGNPFLT = 11, /* Segment not present exception */ TRAP_x86_STKFLT = 12, /* Stack fault */ TRAP_x86_PROTFLT = 13, /* General protection fault */ TRAP_x86_PAGEFLT = 14, /* Page fault */ TRAP_x86_ARITHTRAP = 16, /* Floating point exception */ TRAP_x86_ALIGNFLT = 17, /* Alignment check exception */ TRAP_x86_MCHK = 18, /* Machine check exception */ TRAP_x86_CACHEFLT = 19 /* SIMD exception (via SIGFPE) if CPU is SSE capable otherwise Cache flush exception (via SIGSEV) */ #endif }; struct syscall_frame { DWORD restore_flags; /* 000 */ DWORD eflags; /* 004 */ DWORD eip; /* 008 */ DWORD esp; /* 00c */ WORD cs; /* 010 */ WORD ss; /* 012 */ WORD ds; /* 014 */ WORD es; /* 016 */ WORD fs; /* 018 */ WORD gs; /* 01a */ DWORD eax; /* 01c */ DWORD ebx; /* 020 */ DWORD ecx; /* 024 */ DWORD edx; /* 028 */ DWORD edi; /* 02c */ DWORD esi; /* 030 */ DWORD ebp; /* 034 */ DWORD align[2]; /* 038 */ union /* 040 */ { XSAVE_FORMAT xsave; FLOATING_SAVE_AREA fsave; } u; /* Leave space for the whole set of YMM registers. They're not used in * 32-bit mode, but some processors fault if they're not in writable memory. */ XSTATE xstate; /* 240 */ }; C_ASSERT( sizeof(struct syscall_frame) == 0x380 ); struct x86_thread_data { DWORD fs; /* 1d4 TEB selector */ DWORD gs; /* 1d8 libc selector; update winebuild if you move this! */ DWORD dr0; /* 1dc debug registers */ DWORD dr1; /* 1e0 */ DWORD dr2; /* 1e4 */ DWORD dr3; /* 1e8 */ DWORD dr6; /* 1ec */ DWORD dr7; /* 1f0 */ void *exit_frame; /* 1f4 exit frame pointer */ struct syscall_frame *syscall_frame; /* 1f8 frame pointer on syscall entry */ }; C_ASSERT( sizeof(struct x86_thread_data) <= sizeof(((struct ntdll_thread_data *)0)->cpu_data) ); C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, gs ) == 0x1d8 ); C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, exit_frame ) == 0x1f4 ); C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct x86_thread_data, syscall_frame ) == 0x1f8 ); /* flags to control the behavior of the syscall dispatcher */ #define SYSCALL_HAVE_XSAVE 1 #define SYSCALL_HAVE_XSAVEC 2 #define SYSCALL_HAVE_FXSAVE 4 static inline struct x86_thread_data *x86_thread_data(void) { return (struct x86_thread_data *)ntdll_get_thread_data()->cpu_data; } static inline WORD get_cs(void) { WORD res; __asm__( "movw %%cs,%0" : "=r" (res) ); return res; } static inline WORD get_ds(void) { WORD res; __asm__( "movw %%ds,%0" : "=r" (res) ); return res; } static inline WORD get_fs(void) { WORD res; __asm__( "movw %%fs,%0" : "=r" (res) ); return res; } static inline WORD get_gs(void) { WORD res; __asm__( "movw %%gs,%0" : "=r" (res) ); return res; } static inline void set_fs( WORD val ) { __asm__( "mov %0,%%fs" :: "r" (val)); } static inline void set_gs( WORD val ) { __asm__( "mov %0,%%gs" :: "r" (val)); } /*********************************************************************** * unwind_builtin_dll */ NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch, CONTEXT *context ) { return STATUS_UNSUCCESSFUL; } /*********************************************************************** * is_gdt_sel */ static inline int is_gdt_sel( WORD sel ) { return !(sel & 4); } /*********************************************************************** * ldt_is_system */ static inline int ldt_is_system( WORD sel ) { return is_gdt_sel( sel ) || ((sel >> 3) < first_ldt_entry); } /*********************************************************************** * get_current_teb * * Get the current teb based on the stack pointer. */ static inline TEB *get_current_teb(void) { unsigned long esp; __asm__("movl %%esp,%0" : "=g" (esp) ); return (TEB *)((esp & ~signal_stack_mask) + teb_offset); } /*********************************************************************** * is_inside_syscall */ static BOOL is_inside_syscall( ucontext_t *sigcontext ) { return ((char *)ESP_sig(sigcontext) >= (char *)ntdll_get_thread_data()->kernel_stack && (char *)ESP_sig(sigcontext) <= (char *)x86_thread_data()->syscall_frame); } struct xcontext { CONTEXT c; CONTEXT_EX c_ex; ULONG64 host_compaction_mask; }; extern BOOL xstate_compaction_enabled DECLSPEC_HIDDEN; static inline XSTATE *xstate_from_context( const CONTEXT *context ) { CONTEXT_EX *xctx = (CONTEXT_EX *)(context + 1); if ((context->ContextFlags & CONTEXT_XSTATE) != CONTEXT_XSTATE) return NULL; return (XSTATE *)((char *)xctx + xctx->XState.Offset); } static inline void context_init_xstate( CONTEXT *context, void *xstate_buffer ) { CONTEXT_EX *xctx; xctx = (CONTEXT_EX *)(context + 1); xctx->Legacy.Length = sizeof(CONTEXT); xctx->Legacy.Offset = -(LONG)sizeof(CONTEXT); xctx->XState.Length = sizeof(XSTATE); xctx->XState.Offset = (BYTE *)xstate_buffer - (BYTE *)xctx; xctx->All.Length = sizeof(CONTEXT) + xctx->XState.Offset + xctx->XState.Length; xctx->All.Offset = -(LONG)sizeof(CONTEXT); context->ContextFlags |= CONTEXT_XSTATE; } #ifdef __sun /* We have to workaround two Solaris breakages: * - Solaris doesn't restore %ds and %es before calling the signal handler so exceptions in 16-bit * code crash badly. * - Solaris inserts a libc trampoline to call our handler, but the trampoline expects that registers * are setup correctly. So we need to insert our own trampoline below the libc trampoline to set %gs. */ extern int sigaction_syscall( int sig, const struct sigaction *new, struct sigaction *old ); __ASM_GLOBAL_FUNC( sigaction_syscall, "movl $0x62,%eax\n\t" "int $0x91\n\t" "ret" ) /* assume the same libc handler is used for all signals */ static void (*libc_sigacthandler)( int signal, siginfo_t *siginfo, void *context ); static void wine_sigacthandler( int signal, siginfo_t *siginfo, void *sigcontext ) { struct x86_thread_data *thread_data; __asm__ __volatile__("mov %ss,%ax; mov %ax,%ds; mov %ax,%es"); thread_data = (struct x86_thread_data *)get_current_teb()->GdiTebBatch; set_fs( thread_data->fs ); set_gs( thread_data->gs ); libc_sigacthandler( signal, siginfo, sigcontext ); } static int solaris_sigaction( int sig, const struct sigaction *new, struct sigaction *old ) { struct sigaction real_act; if (sigaction( sig, new, old ) == -1) return -1; /* retrieve the real handler and flags with a direct syscall */ sigaction_syscall( sig, NULL, &real_act ); libc_sigacthandler = real_act.sa_sigaction; real_act.sa_sigaction = wine_sigacthandler; sigaction_syscall( sig, &real_act, NULL ); return 0; } #define sigaction(sig,new,old) solaris_sigaction(sig,new,old) #endif extern void clear_alignment_flag(void) DECLSPEC_HIDDEN; __ASM_GLOBAL_FUNC( clear_alignment_flag, "pushfl\n\t" __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") "andl $~0x40000,(%esp)\n\t" "popfl\n\t" __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t") "ret" ) /*********************************************************************** * init_handler * * Handler initialization when the full context is not needed. * Return the stack pointer to use for pushing the exception data. */ static inline void *init_handler( const ucontext_t *sigcontext ) { TEB *teb = get_current_teb(); clear_alignment_flag(); #ifndef __sun /* see above for Solaris handling */ { struct x86_thread_data *thread_data = (struct x86_thread_data *)&teb->GdiTebBatch; set_fs( thread_data->fs ); set_gs( thread_data->gs ); } #endif if (!ldt_is_system(CS_sig(sigcontext)) || !ldt_is_system(SS_sig(sigcontext))) /* 16-bit mode */ { /* * Win16 or DOS protected mode. Note that during switch * from 16-bit mode to linear mode, CS may be set to system * segment before FS is restored. Fortunately, in this case * SS is still non-system segment. This is why both CS and SS * are checked. */ return teb->SystemReserved1[0]; } return (void *)(ESP_sig(sigcontext) & ~3); } /*********************************************************************** * save_fpu * * Save the thread FPU context. */ static inline void save_fpu( CONTEXT *context ) { struct { DWORD ControlWord; DWORD StatusWord; DWORD TagWord; DWORD ErrorOffset; DWORD ErrorSelector; DWORD DataOffset; DWORD DataSelector; } float_status; context->ContextFlags |= CONTEXT_FLOATING_POINT; __asm__ __volatile__( "fnsave %0; fwait" : "=m" (context->FloatSave) ); /* Reset unmasked exceptions status to avoid firing an exception. */ memcpy(&float_status, &context->FloatSave, sizeof(float_status)); float_status.StatusWord &= float_status.ControlWord | 0xffffff80; __asm__ __volatile__( "fldenv %0" : : "m" (float_status) ); } /*********************************************************************** * restore_fpu * * Restore the x87 FPU context */ static inline void restore_fpu( const CONTEXT *context ) { FLOATING_SAVE_AREA float_status = context->FloatSave; /* reset the current interrupt status */ float_status.StatusWord &= float_status.ControlWord | 0xffffff80; __asm__ __volatile__( "frstor %0; fwait" : : "m" (float_status) ); } /*********************************************************************** * fpux_to_fpu * * Build a standard FPU context from an extended one. */ static void fpux_to_fpu( FLOATING_SAVE_AREA *fpu, const XSAVE_FORMAT *fpux ) { unsigned int i, tag, stack_top; fpu->ControlWord = fpux->ControlWord | 0xffff0000; fpu->StatusWord = fpux->StatusWord | 0xffff0000; fpu->ErrorOffset = fpux->ErrorOffset; fpu->ErrorSelector = fpux->ErrorSelector | (fpux->ErrorOpcode << 16); fpu->DataOffset = fpux->DataOffset; fpu->DataSelector = fpux->DataSelector; fpu->Cr0NpxState = fpux->StatusWord | 0xffff0000; stack_top = (fpux->StatusWord >> 11) & 7; fpu->TagWord = 0xffff0000; for (i = 0; i < 8; i++) { memcpy( &fpu->RegisterArea[10 * i], &fpux->FloatRegisters[i], 10 ); if (!(fpux->TagWord & (1 << i))) tag = 3; /* empty */ else { const M128A *reg = &fpux->FloatRegisters[(i - stack_top) & 7]; if ((reg->High & 0x7fff) == 0x7fff) /* exponent all ones */ { tag = 2; /* special */ } else if (!(reg->High & 0x7fff)) /* exponent all zeroes */ { if (reg->Low) tag = 2; /* special */ else tag = 1; /* zero */ } else { if (reg->Low >> 63) tag = 0; /* valid */ else tag = 2; /* special */ } } fpu->TagWord |= tag << (2 * i); } } /*********************************************************************** * fpu_to_fpux * * Fill extended FPU context from standard one. */ static void fpu_to_fpux( XSAVE_FORMAT *fpux, const FLOATING_SAVE_AREA *fpu ) { unsigned int i; fpux->ControlWord = fpu->ControlWord; fpux->StatusWord = fpu->StatusWord; fpux->ErrorOffset = fpu->ErrorOffset; fpux->ErrorSelector = fpu->ErrorSelector; fpux->ErrorOpcode = fpu->ErrorSelector >> 16; fpux->DataOffset = fpu->DataOffset; fpux->DataSelector = fpu->DataSelector; fpux->TagWord = 0; for (i = 0; i < 8; i++) { if (((fpu->TagWord >> (i * 2)) & 3) != 3) fpux->TagWord |= 1 << i; memcpy( &fpux->FloatRegisters[i], &fpu->RegisterArea[10 * i], 10 ); } } /*********************************************************************** * save_context * * Build a context structure from the signal info. */ static inline void save_context( struct xcontext *xcontext, const ucontext_t *sigcontext ) { FLOATING_SAVE_AREA *fpu = FPU_sig(sigcontext); XSAVE_FORMAT *fpux = FPUX_sig(sigcontext); CONTEXT *context = &xcontext->c; memset(context, 0, sizeof(*context)); context->ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS; context->Eax = EAX_sig(sigcontext); context->Ebx = EBX_sig(sigcontext); context->Ecx = ECX_sig(sigcontext); context->Edx = EDX_sig(sigcontext); context->Esi = ESI_sig(sigcontext); context->Edi = EDI_sig(sigcontext); context->Ebp = EBP_sig(sigcontext); context->EFlags = EFL_sig(sigcontext); context->Eip = EIP_sig(sigcontext); context->Esp = ESP_sig(sigcontext); context->SegCs = LOWORD(CS_sig(sigcontext)); context->SegDs = LOWORD(DS_sig(sigcontext)); context->SegEs = LOWORD(ES_sig(sigcontext)); context->SegFs = LOWORD(FS_sig(sigcontext)); context->SegGs = LOWORD(GS_sig(sigcontext)); context->SegSs = LOWORD(SS_sig(sigcontext)); context->Dr0 = x86_thread_data()->dr0; context->Dr1 = x86_thread_data()->dr1; context->Dr2 = x86_thread_data()->dr2; context->Dr3 = x86_thread_data()->dr3; context->Dr6 = x86_thread_data()->dr6; context->Dr7 = x86_thread_data()->dr7; if (fpu) { context->ContextFlags |= CONTEXT_FLOATING_POINT; context->FloatSave = *fpu; } if (fpux) { XSTATE *xs; context->ContextFlags |= CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS; memcpy( context->ExtendedRegisters, fpux, sizeof(*fpux) ); if (!fpu) fpux_to_fpu( &context->FloatSave, fpux ); if ((cpu_info.ProcessorFeatureBits & CPU_FEATURE_AVX) && (xs = XState_sig(fpux))) { context_init_xstate( context, xs ); xcontext->host_compaction_mask = xs->CompactionMask; } } if (!fpu && !fpux) save_fpu( context ); } /*********************************************************************** * restore_context * * Restore the signal info from the context. */ static inline void restore_context( const struct xcontext *xcontext, ucontext_t *sigcontext ) { FLOATING_SAVE_AREA *fpu = FPU_sig(sigcontext); XSAVE_FORMAT *fpux = FPUX_sig(sigcontext); const CONTEXT *context = &xcontext->c; x86_thread_data()->dr0 = context->Dr0; x86_thread_data()->dr1 = context->Dr1; x86_thread_data()->dr2 = context->Dr2; x86_thread_data()->dr3 = context->Dr3; x86_thread_data()->dr6 = context->Dr6; x86_thread_data()->dr7 = context->Dr7; EAX_sig(sigcontext) = context->Eax; EBX_sig(sigcontext) = context->Ebx; ECX_sig(sigcontext) = context->Ecx; EDX_sig(sigcontext) = context->Edx; ESI_sig(sigcontext) = context->Esi; EDI_sig(sigcontext) = context->Edi; EBP_sig(sigcontext) = context->Ebp; EFL_sig(sigcontext) = context->EFlags; EIP_sig(sigcontext) = context->Eip; ESP_sig(sigcontext) = context->Esp; CS_sig(sigcontext) = context->SegCs; DS_sig(sigcontext) = context->SegDs; ES_sig(sigcontext) = context->SegEs; FS_sig(sigcontext) = context->SegFs; GS_sig(sigcontext) = context->SegGs; SS_sig(sigcontext) = context->SegSs; if (fpu) *fpu = context->FloatSave; if (fpux) { XSTATE *src_xs, *dst_xs; memcpy( fpux, context->ExtendedRegisters, sizeof(*fpux) ); if ((dst_xs = XState_sig(fpux)) && (src_xs = xstate_from_context( context ))) { memcpy( &dst_xs->YmmContext, &src_xs->YmmContext, sizeof(dst_xs->YmmContext) ); dst_xs->Mask |= src_xs->Mask; dst_xs->CompactionMask = xcontext->host_compaction_mask; } } if (!fpu && !fpux) restore_fpu( context ); } /*********************************************************************** * signal_set_full_context */ NTSTATUS signal_set_full_context( CONTEXT *context ) { NTSTATUS status = NtSetContextThread( GetCurrentThread(), context ); if (!status && (context->ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER) x86_thread_data()->syscall_frame->restore_flags |= CONTEXT_INTEGER; return status; } /*********************************************************************** * NtSetContextThread (NTDLL.@) * ZwSetContextThread (NTDLL.@) */ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) { NTSTATUS ret = STATUS_SUCCESS; struct syscall_frame *frame = x86_thread_data()->syscall_frame; DWORD flags = context->ContextFlags & ~CONTEXT_i386; BOOL self = (handle == GetCurrentThread()); if ((flags & CONTEXT_XSTATE) && (cpu_info.ProcessorFeatureBits & CPU_FEATURE_AVX)) { CONTEXT_EX *context_ex = (CONTEXT_EX *)(context + 1); XSTATE *xs = (XSTATE *)((char *)context_ex + context_ex->XState.Offset); if (context_ex->XState.Length < offsetof(XSTATE, YmmContext) || context_ex->XState.Length > sizeof(XSTATE)) return STATUS_INVALID_PARAMETER; if ((xs->Mask & XSTATE_MASK_GSSE) && (context_ex->XState.Length < sizeof(XSTATE))) return STATUS_BUFFER_OVERFLOW; } else flags &= ~CONTEXT_XSTATE; /* debug registers require a server call */ if (self && (flags & CONTEXT_DEBUG_REGISTERS)) self = (x86_thread_data()->dr0 == context->Dr0 && x86_thread_data()->dr1 == context->Dr1 && x86_thread_data()->dr2 == context->Dr2 && x86_thread_data()->dr3 == context->Dr3 && x86_thread_data()->dr6 == context->Dr6 && x86_thread_data()->dr7 == context->Dr7); if (!self) { ret = set_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_I386 ); if (ret || !self) return ret; if (flags & CONTEXT_DEBUG_REGISTERS) { x86_thread_data()->dr0 = context->Dr0; x86_thread_data()->dr1 = context->Dr1; x86_thread_data()->dr2 = context->Dr2; x86_thread_data()->dr3 = context->Dr3; x86_thread_data()->dr6 = context->Dr6; x86_thread_data()->dr7 = context->Dr7; } } if (flags & CONTEXT_INTEGER) { frame->eax = context->Eax; frame->ebx = context->Ebx; frame->ecx = context->Ecx; frame->edx = context->Edx; frame->esi = context->Esi; frame->edi = context->Edi; } if (flags & CONTEXT_CONTROL) { frame->esp = context->Esp; frame->ebp = context->Ebp; frame->eip = context->Eip; frame->eflags = context->EFlags; frame->cs = context->SegCs; frame->ss = context->SegSs; } if (flags & CONTEXT_SEGMENTS) { frame->ds = context->SegDs; frame->es = context->SegEs; frame->fs = context->SegFs; frame->gs = context->SegGs; } if (flags & CONTEXT_EXTENDED_REGISTERS) { memcpy( &frame->u.xsave, context->ExtendedRegisters, sizeof(frame->u.xsave) ); /* reset the current interrupt status */ frame->u.xsave.StatusWord &= frame->u.xsave.ControlWord | 0xff80; frame->xstate.Mask |= XSTATE_MASK_LEGACY; } else if (flags & CONTEXT_FLOATING_POINT) { if (cpu_info.ProcessorFeatureBits & CPU_FEATURE_FXSR) { fpu_to_fpux( &frame->u.xsave, &context->FloatSave ); } else { frame->u.fsave = context->FloatSave; } frame->xstate.Mask |= XSTATE_MASK_LEGACY_FLOATING_POINT; } if (flags & CONTEXT_XSTATE) { CONTEXT_EX *context_ex = (CONTEXT_EX *)(context + 1); XSTATE *xs = (XSTATE *)((char *)context_ex + context_ex->XState.Offset); if (xs->Mask & XSTATE_MASK_GSSE) { frame->xstate.Mask |= XSTATE_MASK_GSSE; frame->xstate.YmmContext = xs->YmmContext; } else frame->xstate.Mask &= ~XSTATE_MASK_GSSE; } frame->restore_flags |= flags & ~CONTEXT_INTEGER; return STATUS_SUCCESS; } /*********************************************************************** * NtGetContextThread (NTDLL.@) * ZwGetContextThread (NTDLL.@) * * Note: we use a small assembly wrapper to save the necessary registers * in case we are fetching the context of the current thread. */ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context ) { struct syscall_frame *frame = x86_thread_data()->syscall_frame; DWORD needed_flags = context->ContextFlags & ~CONTEXT_i386; BOOL self = (handle == GetCurrentThread()); NTSTATUS ret; /* debug registers require a server call */ if (needed_flags & CONTEXT_DEBUG_REGISTERS) self = FALSE; if (!self) { if ((ret = get_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_I386 ))) return ret; needed_flags &= ~context->ContextFlags; } if (self) { if (needed_flags & CONTEXT_INTEGER) { context->Eax = frame->eax; context->Ebx = frame->ebx; context->Ecx = frame->ecx; context->Edx = frame->edx; context->Esi = frame->esi; context->Edi = frame->edi; context->ContextFlags |= CONTEXT_INTEGER; } if (needed_flags & CONTEXT_CONTROL) { context->Esp = frame->esp; context->Ebp = frame->ebp; context->Eip = frame->eip; context->EFlags = frame->eflags; context->SegCs = frame->cs; context->SegSs = frame->ss; context->ContextFlags |= CONTEXT_CONTROL; } if (needed_flags & CONTEXT_SEGMENTS) { context->SegDs = frame->ds; context->SegEs = frame->es; context->SegFs = frame->fs; context->SegGs = frame->gs; context->ContextFlags |= CONTEXT_SEGMENTS; } if (needed_flags & CONTEXT_FLOATING_POINT) { if (!(cpu_info.ProcessorFeatureBits & CPU_FEATURE_FXSR)) { context->FloatSave = frame->u.fsave; } else if (!xstate_compaction_enabled || (frame->xstate.Mask & XSTATE_MASK_LEGACY_FLOATING_POINT)) { fpux_to_fpu( &context->FloatSave, &frame->u.xsave ); } else { memset( &context->FloatSave, 0, sizeof(context->FloatSave) ); context->FloatSave.ControlWord = 0x37f; } context->ContextFlags |= CONTEXT_FLOATING_POINT; } if (needed_flags & CONTEXT_EXTENDED_REGISTERS) { XSAVE_FORMAT *xs = (XSAVE_FORMAT *)context->ExtendedRegisters; if (!xstate_compaction_enabled || (frame->xstate.Mask & XSTATE_MASK_LEGACY_FLOATING_POINT)) { memcpy( xs, &frame->u.xsave, FIELD_OFFSET( XSAVE_FORMAT, MxCsr )); memcpy( xs->FloatRegisters, frame->u.xsave.FloatRegisters, sizeof( xs->FloatRegisters )); } else { memset( xs, 0, FIELD_OFFSET( XSAVE_FORMAT, MxCsr )); memset( xs->FloatRegisters, 0, sizeof( xs->FloatRegisters )); xs->ControlWord = 0x37f; } if (!xstate_compaction_enabled || (frame->xstate.Mask & XSTATE_MASK_LEGACY_SSE)) { memcpy( xs->XmmRegisters, frame->u.xsave.XmmRegisters, sizeof( xs->XmmRegisters )); xs->MxCsr = frame->u.xsave.MxCsr; xs->MxCsr_Mask = frame->u.xsave.MxCsr_Mask; } else { memset( xs->XmmRegisters, 0, sizeof( xs->XmmRegisters )); xs->MxCsr = 0x1f80; xs->MxCsr_Mask = 0x2ffff; } context->ContextFlags |= CONTEXT_EXTENDED_REGISTERS; } if ((needed_flags & CONTEXT_XSTATE) && (cpu_info.ProcessorFeatureBits & CPU_FEATURE_AVX)) { CONTEXT_EX *context_ex = (CONTEXT_EX *)(context + 1); XSTATE *xstate = (XSTATE *)((char *)context_ex + context_ex->XState.Offset); unsigned int mask; if (context_ex->XState.Length < offsetof(XSTATE, YmmContext) || context_ex->XState.Length > sizeof(XSTATE)) return STATUS_INVALID_PARAMETER; mask = (xstate_compaction_enabled ? xstate->CompactionMask : xstate->Mask) & XSTATE_MASK_GSSE; xstate->Mask = frame->xstate.Mask & mask; xstate->CompactionMask = xstate_compaction_enabled ? (0x8000000000000000 | mask) : 0; memset( xstate->Reserved, 0, sizeof(xstate->Reserved) ); if (xstate->Mask) { if (context_ex->XState.Length < sizeof(XSTATE)) return STATUS_BUFFER_OVERFLOW; xstate->YmmContext = frame->xstate.YmmContext; } } /* update the cached version of the debug registers */ if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386)) { x86_thread_data()->dr0 = context->Dr0; x86_thread_data()->dr1 = context->Dr1; x86_thread_data()->dr2 = context->Dr2; x86_thread_data()->dr3 = context->Dr3; x86_thread_data()->dr6 = context->Dr6; x86_thread_data()->dr7 = context->Dr7; } } if (context->ContextFlags & (CONTEXT_INTEGER & ~CONTEXT_i386)) TRACE( "%p: eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n", handle, context->Eax, context->Ebx, context->Ecx, context->Edx, context->Esi, context->Edi ); if (context->ContextFlags & (CONTEXT_CONTROL & ~CONTEXT_i386)) TRACE( "%p: ebp=%08x esp=%08x eip=%08x cs=%04x ss=%04x flags=%08x\n", handle, context->Ebp, context->Esp, context->Eip, context->SegCs, context->SegSs, context->EFlags ); if (context->ContextFlags & (CONTEXT_SEGMENTS & ~CONTEXT_i386)) TRACE( "%p: ds=%04x es=%04x fs=%04x gs=%04x\n", handle, context->SegDs, context->SegEs, context->SegFs, context->SegGs ); if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386)) TRACE( "%p: dr0=%08x dr1=%08x dr2=%08x dr3=%08x dr6=%08x dr7=%08x\n", handle, context->Dr0, context->Dr1, context->Dr2, context->Dr3, context->Dr6, context->Dr7 ); return STATUS_SUCCESS; } /*********************************************************************** * set_thread_wow64_context */ NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size ) { return STATUS_INVALID_INFO_CLASS; } /*********************************************************************** * get_thread_wow64_context */ NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size ) { return STATUS_INVALID_INFO_CLASS; } /*********************************************************************** * is_privileged_instr * * Check if the fault location is a privileged instruction. * Based on the instruction emulation code in dlls/kernel/instr.c. */ static inline DWORD is_privileged_instr( CONTEXT *context ) { BYTE instr[16]; unsigned int i, len, prefix_count = 0; if (!ldt_is_system( context->SegCs )) return 0; len = virtual_uninterrupted_read_memory( (BYTE *)context->Eip, instr, sizeof(instr) ); for (i = 0; i < len; i++) switch (instr[i]) { /* instruction prefixes */ case 0x2e: /* %cs: */ case 0x36: /* %ss: */ case 0x3e: /* %ds: */ case 0x26: /* %es: */ case 0x64: /* %fs: */ case 0x65: /* %gs: */ case 0x66: /* opcode size */ case 0x67: /* addr size */ case 0xf0: /* lock */ case 0xf2: /* repne */ case 0xf3: /* repe */ if (++prefix_count >= 15) return EXCEPTION_ILLEGAL_INSTRUCTION; continue; case 0x0f: /* extended instruction */ if (i == len - 1) return 0; switch(instr[i + 1]) { case 0x20: /* mov crX, reg */ case 0x21: /* mov drX, reg */ case 0x22: /* mov reg, crX */ case 0x23: /* mov reg drX */ return EXCEPTION_PRIV_INSTRUCTION; } return 0; case 0x6c: /* insb (%dx) */ case 0x6d: /* insl (%dx) */ case 0x6e: /* outsb (%dx) */ case 0x6f: /* outsl (%dx) */ case 0xcd: /* int $xx */ case 0xe4: /* inb al,XX */ case 0xe5: /* in (e)ax,XX */ case 0xe6: /* outb XX,al */ case 0xe7: /* out XX,(e)ax */ case 0xec: /* inb (%dx),%al */ case 0xed: /* inl (%dx),%eax */ case 0xee: /* outb %al,(%dx) */ case 0xef: /* outl %eax,(%dx) */ case 0xf4: /* hlt */ case 0xfa: /* cli */ case 0xfb: /* sti */ return EXCEPTION_PRIV_INSTRUCTION; default: return 0; } return 0; } /*********************************************************************** * check_invalid_gs * * Check for fault caused by invalid %gs value (some copy protection schemes mess with it). */ static inline BOOL check_invalid_gs( ucontext_t *sigcontext, CONTEXT *context ) { unsigned int prefix_count = 0; const BYTE *instr = (BYTE *)context->Eip; WORD system_gs = x86_thread_data()->gs; if (context->SegGs == system_gs) return FALSE; if (!ldt_is_system( context->SegCs )) return FALSE; /* only handle faults in system libraries */ if (virtual_is_valid_code_address( instr, 1 )) return FALSE; for (;;) switch(*instr) { /* instruction prefixes */ case 0x2e: /* %cs: */ case 0x36: /* %ss: */ case 0x3e: /* %ds: */ case 0x26: /* %es: */ case 0x64: /* %fs: */ case 0x66: /* opcode size */ case 0x67: /* addr size */ case 0xf0: /* lock */ case 0xf2: /* repne */ case 0xf3: /* repe */ if (++prefix_count >= 15) return FALSE; instr++; continue; case 0x65: /* %gs: */ TRACE( "%04x/%04x at %p, fixing up\n", context->SegGs, system_gs, instr ); GS_sig(sigcontext) = system_gs; return TRUE; default: return FALSE; } } #include "pshpack1.h" union atl_thunk { struct { DWORD movl; /* movl this,4(%esp) */ DWORD this; BYTE jmp; /* jmp func */ int func; } t1; struct { BYTE movl; /* movl this,ecx */ DWORD this; BYTE jmp; /* jmp func */ int func; } t2; struct { BYTE movl1; /* movl this,edx */ DWORD this; BYTE movl2; /* movl func,ecx */ DWORD func; WORD jmp; /* jmp ecx */ } t3; struct { BYTE movl1; /* movl this,ecx */ DWORD this; BYTE movl2; /* movl func,eax */ DWORD func; WORD jmp; /* jmp eax */ } t4; struct { DWORD inst1; /* pop ecx * pop eax * push ecx * jmp 4(%eax) */ WORD inst2; } t5; }; #include "poppack.h" /********************************************************************** * check_atl_thunk * * Check if code destination is an ATL thunk, and emulate it if so. */ static BOOL check_atl_thunk( ucontext_t *sigcontext, EXCEPTION_RECORD *rec, CONTEXT *context ) { const union atl_thunk *thunk = (const union atl_thunk *)rec->ExceptionInformation[1]; union atl_thunk thunk_copy; SIZE_T thunk_len; thunk_len = virtual_uninterrupted_read_memory( thunk, &thunk_copy, sizeof(*thunk) ); if (!thunk_len) return FALSE; if (thunk_len >= sizeof(thunk_copy.t1) && thunk_copy.t1.movl == 0x042444c7 && thunk_copy.t1.jmp == 0xe9) { if (!virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, &thunk_copy.t1.this, sizeof(DWORD) )) { EIP_sig(sigcontext) = (DWORD_PTR)(&thunk->t1.func + 1) + thunk_copy.t1.func; TRACE( "emulating ATL thunk type 1 at %p, func=%08x arg=%08x\n", thunk, EIP_sig(sigcontext), thunk_copy.t1.this ); return TRUE; } } else if (thunk_len >= sizeof(thunk_copy.t2) && thunk_copy.t2.movl == 0xb9 && thunk_copy.t2.jmp == 0xe9) { ECX_sig(sigcontext) = thunk_copy.t2.this; EIP_sig(sigcontext) = (DWORD_PTR)(&thunk->t2.func + 1) + thunk_copy.t2.func; TRACE( "emulating ATL thunk type 2 at %p, func=%08x ecx=%08x\n", thunk, EIP_sig(sigcontext), ECX_sig(sigcontext) ); return TRUE; } else if (thunk_len >= sizeof(thunk_copy.t3) && thunk_copy.t3.movl1 == 0xba && thunk_copy.t3.movl2 == 0xb9 && thunk_copy.t3.jmp == 0xe1ff) { EDX_sig(sigcontext) = thunk_copy.t3.this; ECX_sig(sigcontext) = thunk_copy.t3.func; EIP_sig(sigcontext) = thunk_copy.t3.func; TRACE( "emulating ATL thunk type 3 at %p, func=%08x ecx=%08x edx=%08x\n", thunk, EIP_sig(sigcontext), ECX_sig(sigcontext), EDX_sig(sigcontext) ); return TRUE; } else if (thunk_len >= sizeof(thunk_copy.t4) && thunk_copy.t4.movl1 == 0xb9 && thunk_copy.t4.movl2 == 0xb8 && thunk_copy.t4.jmp == 0xe0ff) { ECX_sig(sigcontext) = thunk_copy.t4.this; EAX_sig(sigcontext) = thunk_copy.t4.func; EIP_sig(sigcontext) = thunk_copy.t4.func; TRACE( "emulating ATL thunk type 4 at %p, func=%08x eax=%08x ecx=%08x\n", thunk, EIP_sig(sigcontext), EAX_sig(sigcontext), ECX_sig(sigcontext) ); return TRUE; } else if (thunk_len >= sizeof(thunk_copy.t5) && thunk_copy.t5.inst1 == 0xff515859 && thunk_copy.t5.inst2 == 0x0460) { DWORD func, sp[2]; if (virtual_uninterrupted_read_memory( (DWORD *)context->Esp, sp, sizeof(sp) ) == sizeof(sp) && virtual_uninterrupted_read_memory( (DWORD *)sp[1] + 1, &func, sizeof(DWORD) ) == sizeof(DWORD) && !virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, &sp[0], sizeof(sp[0]) )) { ECX_sig(sigcontext) = sp[0]; EAX_sig(sigcontext) = sp[1]; ESP_sig(sigcontext) += sizeof(DWORD); EIP_sig(sigcontext) = func; TRACE( "emulating ATL thunk type 5 at %p, func=%08x eax=%08x ecx=%08x esp=%08x\n", thunk, EIP_sig(sigcontext), EAX_sig(sigcontext), ECX_sig(sigcontext), ESP_sig(sigcontext) ); return TRUE; } } return FALSE; } /*********************************************************************** * setup_exception_record * * Setup the exception record and context on the thread stack. */ static void *setup_exception_record( ucontext_t *sigcontext, EXCEPTION_RECORD *rec, struct xcontext *xcontext ) { void *stack = init_handler( sigcontext ); rec->ExceptionAddress = (void *)EIP_sig( sigcontext ); save_context( xcontext, sigcontext ); return stack; } /*********************************************************************** * setup_raise_exception * * Change context to setup a call to a raise exception function. */ static void setup_raise_exception( ucontext_t *sigcontext, void *stack_ptr, EXCEPTION_RECORD *rec, struct xcontext *xcontext ) { CONTEXT *context = &xcontext->c; size_t stack_size; XSTATE *src_xs; struct stack_layout { EXCEPTION_RECORD *rec_ptr; /* first arg for KiUserExceptionDispatcher */ CONTEXT *context_ptr; /* second arg for KiUserExceptionDispatcher */ CONTEXT context; CONTEXT_EX context_ex; EXCEPTION_RECORD rec; DWORD ebp; DWORD eip; char xstate[0]; } *stack; C_ASSERT( (offsetof(struct stack_layout, xstate) == sizeof(struct stack_layout)) ); NTSTATUS status = send_debug_event( rec, context, TRUE ); if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED) { restore_context( xcontext, sigcontext ); return; } /* fix up instruction pointer in context for EXCEPTION_BREAKPOINT */ if (rec->ExceptionCode == EXCEPTION_BREAKPOINT) context->Eip--; stack_size = sizeof(*stack); if ((src_xs = xstate_from_context( context ))) { stack_size += (ULONG_PTR)stack_ptr - (((ULONG_PTR)stack_ptr - sizeof(XSTATE)) & ~(ULONG_PTR)63); } stack = virtual_setup_exception( stack_ptr, stack_size, rec ); stack->rec = *rec; stack->context = *context; if (src_xs) { XSTATE *dst_xs = (XSTATE *)stack->xstate; assert(!((ULONG_PTR)dst_xs & 63)); context_init_xstate( &stack->context, stack->xstate ); memset( dst_xs, 0, offsetof(XSTATE, YmmContext) ); dst_xs->CompactionMask = xstate_compaction_enabled ? 0x8000000000000004 : 0; if (src_xs->Mask & 4) { dst_xs->Mask = 4; memcpy( &dst_xs->YmmContext, &src_xs->YmmContext, sizeof(dst_xs->YmmContext) ); } } stack->rec_ptr = &stack->rec; stack->context_ptr = &stack->context; ESP_sig(sigcontext) = (DWORD)stack; EIP_sig(sigcontext) = (DWORD)pKiUserExceptionDispatcher; /* clear single-step, direction, and align check flag */ EFL_sig(sigcontext) &= ~(0x100|0x400|0x40000); CS_sig(sigcontext) = get_cs(); DS_sig(sigcontext) = get_ds(); ES_sig(sigcontext) = get_ds(); FS_sig(sigcontext) = get_fs(); GS_sig(sigcontext) = get_gs(); SS_sig(sigcontext) = get_ds(); } /*********************************************************************** * setup_exception * * Do the full setup to raise an exception from an exception record. */ static void setup_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec ) { struct xcontext xcontext; void *stack = setup_exception_record( sigcontext, rec, &xcontext ); setup_raise_exception( sigcontext, stack, rec, &xcontext ); } /* stack layout when calling an user apc function. * FIXME: match Windows ABI. */ struct apc_stack_layout { CONTEXT *context_ptr; ULONG_PTR arg1; ULONG_PTR arg2; ULONG_PTR arg3; PNTAPCFUNC func; CONTEXT context; }; /*********************************************************************** * call_user_apc_dispatcher */ NTSTATUS call_user_apc_dispatcher( CONTEXT *context, ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, PNTAPCFUNC func, NTSTATUS status ) { struct syscall_frame *frame = x86_thread_data()->syscall_frame; ULONG esp = context ? context->Esp : frame->esp; struct apc_stack_layout *stack = (struct apc_stack_layout *)esp - 1; if (!context) { stack->context.ContextFlags = CONTEXT_FULL; NtGetContextThread( GetCurrentThread(), &stack->context ); stack->context.Eax = status; } else memmove( &stack->context, context, sizeof(stack->context) ); stack->context_ptr = &stack->context; stack->arg1 = arg1; stack->arg2 = arg2; stack->arg3 = arg3; stack->func = func; frame->ebp = stack->context.Ebp; frame->esp = (ULONG)stack - 4; frame->eip = (ULONG)pKiUserApcDispatcher; return status; } /*********************************************************************** * call_raise_user_exception_dispatcher */ void call_raise_user_exception_dispatcher(void) { x86_thread_data()->syscall_frame->eip = (DWORD)pKiRaiseUserExceptionDispatcher; } /*********************************************************************** * call_user_exception_dispatcher */ NTSTATUS call_user_exception_dispatcher( EXCEPTION_RECORD *rec, CONTEXT *context ) { struct syscall_frame *frame = x86_thread_data()->syscall_frame; void **stack = (void **)frame->esp; if (rec->ExceptionCode == EXCEPTION_BREAKPOINT) context->Eip--; *(--stack) = context; *(--stack) = rec; frame->esp = (ULONG)stack; frame->eip = (ULONG)pKiUserExceptionDispatcher; return STATUS_SUCCESS; } /********************************************************************** * get_fpu_code * * Get the FPU exception code from the FPU status. */ static inline DWORD get_fpu_code( const CONTEXT *context ) { DWORD status = context->FloatSave.StatusWord & ~(context->FloatSave.ControlWord & 0x3f); if (status & 0x01) /* IE */ { if (status & 0x40) /* SF */ return EXCEPTION_FLT_STACK_CHECK; else return EXCEPTION_FLT_INVALID_OPERATION; } if (status & 0x02) return EXCEPTION_FLT_DENORMAL_OPERAND; /* DE flag */ if (status & 0x04) return EXCEPTION_FLT_DIVIDE_BY_ZERO; /* ZE flag */ if (status & 0x08) return EXCEPTION_FLT_OVERFLOW; /* OE flag */ if (status & 0x10) return EXCEPTION_FLT_UNDERFLOW; /* UE flag */ if (status & 0x20) return EXCEPTION_FLT_INEXACT_RESULT; /* PE flag */ return EXCEPTION_FLT_INVALID_OPERATION; /* generic error */ } /*********************************************************************** * handle_interrupt * * Handle an interrupt. */ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, void *stack, EXCEPTION_RECORD *rec, struct xcontext *xcontext ) { CONTEXT *context = &xcontext->c; switch(interrupt) { case 0x2d: if (!is_wow64) { /* On Wow64, the upper DWORD of Rax contains garbage, and the debug * service is usually not recognized when called from usermode. */ switch (context->Eax) { case 1: /* BREAKPOINT_PRINT */ case 3: /* BREAKPOINT_LOAD_SYMBOLS */ case 4: /* BREAKPOINT_UNLOAD_SYMBOLS */ case 5: /* BREAKPOINT_COMMAND_STRING (>= Win2003) */ EIP_sig(sigcontext) += 3; return TRUE; } } context->Eip += 3; rec->ExceptionCode = EXCEPTION_BREAKPOINT; rec->ExceptionAddress = (void *)context->Eip; rec->NumberParameters = is_wow64 ? 1 : 3; rec->ExceptionInformation[0] = context->Eax; rec->ExceptionInformation[1] = context->Ecx; rec->ExceptionInformation[2] = context->Edx; setup_raise_exception( sigcontext, stack, rec, xcontext ); return TRUE; default: return FALSE; } } /*********************************************************************** * handle_syscall_fault * * Handle a page fault happening during a system call. */ static BOOL handle_syscall_fault( ucontext_t *sigcontext, void *stack_ptr, EXCEPTION_RECORD *rec, CONTEXT *context ) { struct syscall_frame *frame = x86_thread_data()->syscall_frame; DWORD i; if (!is_inside_syscall( sigcontext )) return FALSE; TRACE( "code=%x flags=%x addr=%p ip=%08x tid=%04x\n", rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress, context->Eip, GetCurrentThreadId() ); for (i = 0; i < rec->NumberParameters; i++) TRACE( " info[%d]=%08lx\n", i, rec->ExceptionInformation[i] ); TRACE(" eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n", context->Eax, context->Ebx, context->Ecx, context->Edx, context->Esi, context->Edi ); TRACE(" ebp=%08x esp=%08x cs=%04x ds=%04x es=%04x fs=%04x gs=%04x flags=%08x\n", context->Ebp, context->Esp, context->SegCs, context->SegDs, context->SegEs, context->SegFs, context->SegGs, context->EFlags ); if (ntdll_get_thread_data()->jmp_buf) { DWORD *stack = stack_ptr; TRACE( "returning to handler\n" ); /* push stack frame for calling __wine_longjmp */ *(--stack) = 1; *(--stack) = (DWORD)ntdll_get_thread_data()->jmp_buf; *(--stack) = 0xdeadbabe; /* return address */ ESP_sig(sigcontext) = (DWORD)stack; EIP_sig(sigcontext) = (DWORD)__wine_longjmp; ntdll_get_thread_data()->jmp_buf = NULL; } else { TRACE( "returning to user mode ip=%08x ret=%08x\n", frame->eip, rec->ExceptionCode ); EAX_sig(sigcontext) = rec->ExceptionCode; EBX_sig(sigcontext) = frame->ebx; ESI_sig(sigcontext) = frame->esi; EDI_sig(sigcontext) = frame->edi; EBP_sig(sigcontext) = frame->ebp; ESP_sig(sigcontext) = frame->esp; EIP_sig(sigcontext) = frame->eip; } return TRUE; } /*********************************************************************** * handle_syscall_trap * * Handle a trap exception during a system call. */ static BOOL handle_syscall_trap( ucontext_t *sigcontext ) { extern void __wine_syscall_dispatcher_prolog_end(void); struct syscall_frame *frame = x86_thread_data()->syscall_frame; /* disallow single-stepping through a syscall */ if ((void *)EIP_sig( sigcontext ) != __wine_syscall_dispatcher) return FALSE; TRACE( "ignoring trap in syscall eip=%08x eflags=%08x\n", EIP_sig(sigcontext), EFL_sig(sigcontext) ); frame->eip = *(ULONG *)ESP_sig( sigcontext ); frame->eflags = EFL_sig(sigcontext); frame->restore_flags = CONTEXT_CONTROL; EIP_sig( sigcontext ) = (ULONG)__wine_syscall_dispatcher_prolog_end; ECX_sig( sigcontext ) = (ULONG)frame; ESP_sig( sigcontext ) += sizeof(ULONG); EFL_sig( sigcontext ) &= ~0x100; /* clear single-step flag */ return TRUE; } /********************************************************************** * segv_handler * * Handler for SIGSEGV and related errors. */ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { EXCEPTION_RECORD rec = { 0 }; struct xcontext xcontext; ucontext_t *ucontext = sigcontext; void *stack = setup_exception_record( sigcontext, &rec, &xcontext ); switch (TRAP_sig(ucontext)) { case TRAP_x86_OFLOW: /* Overflow exception */ rec.ExceptionCode = EXCEPTION_INT_OVERFLOW; break; case TRAP_x86_BOUND: /* Bound range exception */ rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED; break; case TRAP_x86_PRIVINFLT: /* Invalid opcode exception */ rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; break; case TRAP_x86_STKFLT: /* Stack fault */ rec.ExceptionCode = EXCEPTION_STACK_OVERFLOW; break; case TRAP_x86_SEGNPFLT: /* Segment not present exception */ case TRAP_x86_PROTFLT: /* General protection fault */ { WORD err = ERROR_sig(ucontext); if (!err && (rec.ExceptionCode = is_privileged_instr( &xcontext.c ))) break; if ((err & 7) == 2 && handle_interrupt( err >> 3, ucontext, stack, &rec, &xcontext )) return; rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION; rec.NumberParameters = 2; rec.ExceptionInformation[0] = 0; /* if error contains a LDT selector, use that as fault address */ if ((err & 7) == 4 && !ldt_is_system( err | 7 )) rec.ExceptionInformation[1] = err & ~7; else { rec.ExceptionInformation[1] = 0xffffffff; if (check_invalid_gs( ucontext, &xcontext.c )) return; } } break; case TRAP_x86_PAGEFLT: /* Page fault */ rec.NumberParameters = 2; rec.ExceptionInformation[0] = (ERROR_sig(ucontext) >> 1) & 0x09; rec.ExceptionInformation[1] = (ULONG_PTR)siginfo->si_addr; rec.ExceptionCode = virtual_handle_fault( siginfo->si_addr, rec.ExceptionInformation[0], stack ); if (!rec.ExceptionCode) return; if (rec.ExceptionCode == EXCEPTION_ACCESS_VIOLATION && rec.ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT) { ULONG flags; NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags), NULL ); if (!(flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION) && check_atl_thunk( ucontext, &rec, &xcontext.c )) return; /* send EXCEPTION_EXECUTE_FAULT only if data execution prevention is enabled */ if (!(flags & MEM_EXECUTE_OPTION_DISABLE)) rec.ExceptionInformation[0] = EXCEPTION_READ_FAULT; } break; case TRAP_x86_ALIGNFLT: /* Alignment check exception */ /* FIXME: pass through exception handler first? */ if (xcontext.c.EFlags & 0x00040000) { EFL_sig(ucontext) &= ~0x00040000; /* disable AC flag */ return; } rec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT; break; default: WINE_ERR( "Got unexpected trap %d\n", TRAP_sig(ucontext) ); /* fall through */ case TRAP_x86_NMI: /* NMI interrupt */ case TRAP_x86_DNA: /* Device not available exception */ case TRAP_x86_DOUBLEFLT: /* Double fault exception */ case TRAP_x86_TSSFLT: /* Invalid TSS exception */ case TRAP_x86_MCHK: /* Machine check exception */ case TRAP_x86_CACHEFLT: /* Cache flush exception */ rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; break; } if (handle_syscall_fault( ucontext, stack, &rec, &xcontext.c )) return; setup_raise_exception( ucontext, stack, &rec, &xcontext ); } /********************************************************************** * trap_handler * * Handler for SIGTRAP. */ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { EXCEPTION_RECORD rec = { 0 }; struct xcontext xcontext; ucontext_t *ucontext = sigcontext; void *stack = setup_exception_record( sigcontext, &rec, &xcontext ); if (handle_syscall_trap( ucontext )) return; switch (TRAP_sig(ucontext)) { case TRAP_x86_TRCTRAP: /* Single-step exception */ rec.ExceptionCode = EXCEPTION_SINGLE_STEP; /* when single stepping can't tell whether this is a hw bp or a * single step interrupt. try to avoid as much overhead as possible * and only do a server call if there is any hw bp enabled. */ if (!(xcontext.c.EFlags & 0x100) || (xcontext.c.Dr7 & 0xff)) { /* (possible) hardware breakpoint, fetch the debug registers */ DWORD saved_flags = xcontext.c.ContextFlags; xcontext.c.ContextFlags = CONTEXT_DEBUG_REGISTERS; NtGetContextThread( GetCurrentThread(), &xcontext.c ); xcontext.c.ContextFlags |= saved_flags; /* restore flags */ } xcontext.c.EFlags &= ~0x100; /* clear single-step flag */ break; case TRAP_x86_BPTFLT: /* Breakpoint exception */ rec.ExceptionAddress = (char *)rec.ExceptionAddress - 1; /* back up over the int3 instruction */ /* fall through */ default: rec.ExceptionCode = EXCEPTION_BREAKPOINT; rec.NumberParameters = is_wow64 ? 1 : 3; rec.ExceptionInformation[0] = 0; rec.ExceptionInformation[1] = 0; /* FIXME */ rec.ExceptionInformation[2] = 0; /* FIXME */ break; } setup_raise_exception( sigcontext, stack, &rec, &xcontext ); } /********************************************************************** * fpe_handler * * Handler for SIGFPE. */ static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { EXCEPTION_RECORD rec = { 0 }; struct xcontext xcontext; ucontext_t *ucontext = sigcontext; void *stack = setup_exception_record( sigcontext, &rec, &xcontext ); switch (TRAP_sig(ucontext)) { case TRAP_x86_DIVIDE: /* Division by zero exception */ rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO; break; case TRAP_x86_FPOPFLT: /* Coprocessor segment overrun */ rec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION; break; case TRAP_x86_ARITHTRAP: /* Floating point exception */ rec.ExceptionCode = get_fpu_code( &xcontext.c ); rec.ExceptionAddress = (void *)xcontext.c.FloatSave.ErrorOffset; break; case TRAP_x86_CACHEFLT: /* SIMD exception */ /* TODO: * Behaviour only tested for divide-by-zero exceptions * Check for other SIMD exceptions as well */ if(siginfo->si_code != FPE_FLTDIV && siginfo->si_code != FPE_FLTINV) FIXME("untested SIMD exception: %#x. Might not work correctly\n", siginfo->si_code); rec.ExceptionCode = STATUS_FLOAT_MULTIPLE_TRAPS; rec.NumberParameters = 1; /* no idea what meaning is actually behind this but that's what native does */ rec.ExceptionInformation[0] = 0; break; default: WINE_ERR( "Got unexpected trap %d\n", TRAP_sig(ucontext) ); rec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION; break; } setup_raise_exception( sigcontext, stack, &rec, &xcontext ); } /********************************************************************** * int_handler * * Handler for SIGINT. */ static void int_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { HANDLE handle; init_handler( sigcontext ); if (!p__wine_ctrl_routine) return; if (!NtCreateThreadEx( &handle, THREAD_ALL_ACCESS, NULL, NtCurrentProcess(), p__wine_ctrl_routine, 0 /* CTRL_C_EVENT */, 0, 0, 0, 0, NULL )) NtClose( handle ); } /********************************************************************** * abrt_handler * * Handler for SIGABRT. */ static void abrt_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { EXCEPTION_RECORD rec = { EXCEPTION_WINE_ASSERTION, EH_NONCONTINUABLE }; setup_exception( sigcontext, &rec ); } /********************************************************************** * quit_handler * * Handler for SIGQUIT. */ static void quit_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { init_handler( sigcontext ); abort_thread(0); } /********************************************************************** * usr1_handler * * Handler for SIGUSR1, used to signal a thread that it got suspended. */ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { struct xcontext xcontext; init_handler( sigcontext ); if (is_inside_syscall( sigcontext )) { DECLSPEC_ALIGN(64) XSTATE xs; xcontext.c.ContextFlags = CONTEXT_FULL; context_init_xstate( &xcontext.c, &xs ); NtGetContextThread( GetCurrentThread(), &xcontext.c ); wait_suspend( &xcontext.c ); NtSetContextThread( GetCurrentThread(), &xcontext.c ); } else { save_context( &xcontext, sigcontext ); wait_suspend( &xcontext.c ); restore_context( &xcontext, sigcontext ); } } /*********************************************************************** * LDT support */ #define LDT_SIZE 8192 #define LDT_FLAGS_DATA 0x13 /* Data segment */ #define LDT_FLAGS_CODE 0x1b /* Code segment */ #define LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */ #define LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated */ struct ldt_copy { void *base[LDT_SIZE]; unsigned int limit[LDT_SIZE]; unsigned char flags[LDT_SIZE]; } __wine_ldt_copy; static WORD gdt_fs_sel; static pthread_mutex_t ldt_mutex = PTHREAD_MUTEX_INITIALIZER; static const LDT_ENTRY null_entry; static inline void *ldt_get_base( LDT_ENTRY ent ) { return (void *)(ent.BaseLow | (ULONG_PTR)ent.HighWord.Bits.BaseMid << 16 | (ULONG_PTR)ent.HighWord.Bits.BaseHi << 24); } static inline unsigned int ldt_get_limit( LDT_ENTRY ent ) { unsigned int limit = ent.LimitLow | (ent.HighWord.Bits.LimitHi << 16); if (ent.HighWord.Bits.Granularity) limit = (limit << 12) | 0xfff; return limit; } static LDT_ENTRY ldt_make_entry( void *base, unsigned int limit, unsigned char flags ) { LDT_ENTRY entry; entry.BaseLow = (WORD)(ULONG_PTR)base; entry.HighWord.Bits.BaseMid = (BYTE)((ULONG_PTR)base >> 16); entry.HighWord.Bits.BaseHi = (BYTE)((ULONG_PTR)base >> 24); if ((entry.HighWord.Bits.Granularity = (limit >= 0x100000))) limit >>= 12; entry.LimitLow = (WORD)limit; entry.HighWord.Bits.LimitHi = limit >> 16; entry.HighWord.Bits.Dpl = 3; entry.HighWord.Bits.Pres = 1; entry.HighWord.Bits.Type = flags; entry.HighWord.Bits.Sys = 0; entry.HighWord.Bits.Reserved_0 = 0; entry.HighWord.Bits.Default_Big = (flags & LDT_FLAGS_32BIT) != 0; return entry; } static void ldt_set_entry( WORD sel, LDT_ENTRY entry ) { int index = sel >> 3; #ifdef linux struct modify_ldt_s ldt_info = { index }; ldt_info.base_addr = ldt_get_base( entry ); ldt_info.limit = entry.LimitLow | (entry.HighWord.Bits.LimitHi << 16); ldt_info.seg_32bit = entry.HighWord.Bits.Default_Big; ldt_info.contents = (entry.HighWord.Bits.Type >> 2) & 3; ldt_info.read_exec_only = !(entry.HighWord.Bits.Type & 2); ldt_info.limit_in_pages = entry.HighWord.Bits.Granularity; ldt_info.seg_not_present = !entry.HighWord.Bits.Pres; ldt_info.usable = entry.HighWord.Bits.Sys; if (modify_ldt( 0x11, &ldt_info, sizeof(ldt_info) ) < 0) perror( "modify_ldt" ); #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) /* The kernel will only let us set LDTs with user priority level */ if (entry.HighWord.Bits.Pres && entry.HighWord.Bits.Dpl != 3) entry.HighWord.Bits.Dpl = 3; if (i386_set_ldt(index, (union descriptor *)&entry, 1) < 0) { perror("i386_set_ldt"); fprintf( stderr, "Did you reconfigure the kernel with \"options USER_LDT\"?\n" ); exit(1); } #elif defined(__svr4__) || defined(_SCO_DS) struct ssd ldt_mod; ldt_mod.sel = sel; ldt_mod.bo = (unsigned long)ldt_get_base( entry ); ldt_mod.ls = entry.LimitLow | (entry.HighWord.Bits.LimitHi << 16); ldt_mod.acc1 = entry.HighWord.Bytes.Flags1; ldt_mod.acc2 = entry.HighWord.Bytes.Flags2 >> 4; if (sysi86(SI86DSCR, &ldt_mod) == -1) perror("sysi86"); #elif defined(__APPLE__) if (i386_set_ldt(index, (union ldt_entry *)&entry, 1) < 0) perror("i386_set_ldt"); #elif defined(__GNU__) if (i386_set_ldt(mach_thread_self(), sel, (descriptor_list_t)&entry, 1) != KERN_SUCCESS) perror("i386_set_ldt"); #else fprintf( stderr, "No LDT support on this platform\n" ); exit(1); #endif __wine_ldt_copy.base[index] = ldt_get_base( entry ); __wine_ldt_copy.limit[index] = ldt_get_limit( entry ); __wine_ldt_copy.flags[index] = (entry.HighWord.Bits.Type | (entry.HighWord.Bits.Default_Big ? LDT_FLAGS_32BIT : 0) | LDT_FLAGS_ALLOCATED); } static void ldt_set_fs( WORD sel, TEB *teb ) { if (sel == gdt_fs_sel) { #ifdef __linux__ struct modify_ldt_s ldt_info = { sel >> 3 }; ldt_info.base_addr = teb; ldt_info.limit = page_size - 1; ldt_info.seg_32bit = 1; if (set_thread_area( &ldt_info ) < 0) perror( "set_thread_area" ); #elif defined(__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__) i386_set_fsbase( teb ); #endif } set_fs( sel ); } /********************************************************************** * get_thread_ldt_entry */ NTSTATUS get_thread_ldt_entry( HANDLE handle, void *data, ULONG len, ULONG *ret_len ) { THREAD_DESCRIPTOR_INFORMATION *info = data; NTSTATUS status = STATUS_SUCCESS; if (len < sizeof(*info)) return STATUS_INFO_LENGTH_MISMATCH; if (info->Selector >> 16) return STATUS_UNSUCCESSFUL; if (is_gdt_sel( info->Selector )) { if (!(info->Selector & ~3)) info->Entry = null_entry; else if ((info->Selector | 3) == get_cs()) info->Entry = ldt_make_entry( 0, ~0u, LDT_FLAGS_CODE | LDT_FLAGS_32BIT ); else if ((info->Selector | 3) == get_ds()) info->Entry = ldt_make_entry( 0, ~0u, LDT_FLAGS_DATA | LDT_FLAGS_32BIT ); else if ((info->Selector | 3) == get_fs()) info->Entry = ldt_make_entry( NtCurrentTeb(), 0xfff, LDT_FLAGS_DATA | LDT_FLAGS_32BIT ); else return STATUS_UNSUCCESSFUL; } else { SERVER_START_REQ( get_selector_entry ) { req->handle = wine_server_obj_handle( handle ); req->entry = info->Selector >> 3; status = wine_server_call( req ); if (!status) { if (reply->flags) info->Entry = ldt_make_entry( (void *)reply->base, reply->limit, reply->flags ); else status = STATUS_UNSUCCESSFUL; } } SERVER_END_REQ; } if (status == STATUS_SUCCESS && ret_len) /* yes, that's a bit strange, but it's the way it is */ *ret_len = sizeof(info->Entry); return status; } /****************************************************************************** * NtSetLdtEntries (NTDLL.@) * ZwSetLdtEntries (NTDLL.@) */ NTSTATUS WINAPI NtSetLdtEntries( ULONG sel1, LDT_ENTRY entry1, ULONG sel2, LDT_ENTRY entry2 ) { sigset_t sigset; if (sel1 >> 16 || sel2 >> 16) return STATUS_INVALID_LDT_DESCRIPTOR; if (sel1 && (sel1 >> 3) < first_ldt_entry) return STATUS_INVALID_LDT_DESCRIPTOR; if (sel2 && (sel2 >> 3) < first_ldt_entry) return STATUS_INVALID_LDT_DESCRIPTOR; server_enter_uninterrupted_section( &ldt_mutex, &sigset ); if (sel1) ldt_set_entry( sel1, entry1 ); if (sel2) ldt_set_entry( sel2, entry2 ); server_leave_uninterrupted_section( &ldt_mutex, &sigset ); return STATUS_SUCCESS; } /********************************************************************** * signal_init_threading */ void signal_init_threading(void) { #ifdef __linux__ /* the preloader may have allocated it already */ gdt_fs_sel = get_fs(); if (!gdt_fs_sel || !is_gdt_sel( gdt_fs_sel )) { struct modify_ldt_s ldt_info = { -1 }; ldt_info.seg_32bit = 1; ldt_info.usable = 1; if (set_thread_area( &ldt_info ) >= 0) gdt_fs_sel = (ldt_info.entry_number << 3) | 3; else gdt_fs_sel = 0; } #elif defined(__FreeBSD__) || defined (__FreeBSD_kernel__) gdt_fs_sel = GSEL( GUFS_SEL, SEL_UPL ); #endif } /********************************************************************** * signal_alloc_thread */ NTSTATUS signal_alloc_thread( TEB *teb ) { struct x86_thread_data *thread_data = (struct x86_thread_data *)&teb->GdiTebBatch; if (!gdt_fs_sel) { static int first_thread = 1; sigset_t sigset; int idx; LDT_ENTRY entry = ldt_make_entry( teb, page_size - 1, LDT_FLAGS_DATA | LDT_FLAGS_32BIT ); if (first_thread) /* no locking for first thread */ { /* leave some space if libc is using the LDT for %gs */ if (!is_gdt_sel( get_gs() )) first_ldt_entry = 512; idx = first_ldt_entry; ldt_set_entry( (idx << 3) | 7, entry ); first_thread = 0; } else { server_enter_uninterrupted_section( &ldt_mutex, &sigset ); for (idx = first_ldt_entry; idx < LDT_SIZE; idx++) { if (__wine_ldt_copy.flags[idx]) continue; ldt_set_entry( (idx << 3) | 7, entry ); break; } server_leave_uninterrupted_section( &ldt_mutex, &sigset ); if (idx == LDT_SIZE) return STATUS_TOO_MANY_THREADS; } thread_data->fs = (idx << 3) | 7; } else thread_data->fs = gdt_fs_sel; teb->WOW32Reserved = __wine_syscall_dispatcher; return STATUS_SUCCESS; } /********************************************************************** * signal_free_thread */ void signal_free_thread( TEB *teb ) { struct x86_thread_data *thread_data = (struct x86_thread_data *)&teb->GdiTebBatch; sigset_t sigset; if (gdt_fs_sel) return; server_enter_uninterrupted_section( &ldt_mutex, &sigset ); __wine_ldt_copy.flags[thread_data->fs >> 3] = 0; server_leave_uninterrupted_section( &ldt_mutex, &sigset ); } /********************************************************************** * signal_init_thread */ void signal_init_thread( TEB *teb ) { const WORD fpu_cw = 0x27f; struct x86_thread_data *thread_data = (struct x86_thread_data *)&teb->GdiTebBatch; ldt_set_fs( thread_data->fs, teb ); thread_data->gs = get_gs(); __asm__ volatile ("fninit; fldcw %0" : : "m" (fpu_cw)); } /********************************************************************** * signal_init_process */ void signal_init_process(void) { struct sigaction sig_act; void *kernel_stack = (char *)ntdll_get_thread_data()->kernel_stack + kernel_stack_size; x86_thread_data()->syscall_frame = (struct syscall_frame *)kernel_stack - 1; if (cpu_info.ProcessorFeatureBits & CPU_FEATURE_FXSR) __wine_syscall_flags |= SYSCALL_HAVE_FXSAVE; if (cpu_info.ProcessorFeatureBits & CPU_FEATURE_XSAVE) __wine_syscall_flags |= SYSCALL_HAVE_XSAVE; if (xstate_compaction_enabled) __wine_syscall_flags |= SYSCALL_HAVE_XSAVEC; sig_act.sa_mask = server_block_set; sig_act.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK; #ifdef __ANDROID__ sig_act.sa_flags |= SA_RESTORER; sig_act.sa_restorer = rt_sigreturn; #endif sig_act.sa_sigaction = int_handler; if (sigaction( SIGINT, &sig_act, NULL ) == -1) goto error; sig_act.sa_sigaction = fpe_handler; if (sigaction( SIGFPE, &sig_act, NULL ) == -1) goto error; sig_act.sa_sigaction = abrt_handler; if (sigaction( SIGABRT, &sig_act, NULL ) == -1) goto error; sig_act.sa_sigaction = quit_handler; if (sigaction( SIGQUIT, &sig_act, NULL ) == -1) goto error; sig_act.sa_sigaction = usr1_handler; if (sigaction( SIGUSR1, &sig_act, NULL ) == -1) goto error; sig_act.sa_sigaction = trap_handler; if (sigaction( SIGTRAP, &sig_act, NULL ) == -1) goto error; sig_act.sa_sigaction = segv_handler; if (sigaction( SIGSEGV, &sig_act, NULL ) == -1) goto error; if (sigaction( SIGILL, &sig_act, NULL ) == -1) goto error; if (sigaction( SIGBUS, &sig_act, NULL ) == -1) goto error; return; error: perror("sigaction"); exit(1); } /*********************************************************************** * init_thread_context */ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg, TEB *teb ) { context->SegCs = get_cs(); context->SegDs = get_ds(); context->SegEs = get_ds(); context->SegFs = get_fs(); context->SegGs = get_gs(); context->SegSs = get_ds(); context->EFlags = 0x202; context->Eax = (DWORD)entry; context->Ebx = (DWORD)arg; context->Esp = (DWORD)teb->Tib.StackBase - 16; context->Eip = (DWORD)pRtlUserThreadStart; context->FloatSave.ControlWord = 0x27f; ((XSAVE_FORMAT *)context->ExtendedRegisters)->ControlWord = 0x27f; ((XSAVE_FORMAT *)context->ExtendedRegisters)->MxCsr = 0x1f80; if (NtCurrentTeb64()) { WOW64_CPURESERVED *cpu = ULongToPtr( NtCurrentTeb64()->TlsSlots[WOW64_TLS_CPURESERVED] ); memcpy( cpu + 1, context, sizeof(*context) ); } } /*********************************************************************** * get_initial_context */ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend, TEB *teb ) { CONTEXT *ctx; if (suspend) { CONTEXT context = { CONTEXT_ALL }; init_thread_context( &context, entry, arg, teb ); wait_suspend( &context ); ctx = (CONTEXT *)((ULONG_PTR)context.Esp & ~15) - 1; *ctx = context; } else { ctx = (CONTEXT *)((char *)teb->Tib.StackBase - 16) - 1; init_thread_context( ctx, entry, arg, teb ); } pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL ); ctx->ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS; return ctx; } /*********************************************************************** * signal_start_thread */ __ASM_GLOBAL_FUNC( signal_start_thread, "pushl %ebp\n\t" __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") __ASM_CFI(".cfi_rel_offset %ebp,0\n\t") "movl %esp,%ebp\n\t" __ASM_CFI(".cfi_def_cfa_register %ebp\n\t") "pushl %ebx\n\t" __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t") "pushl %esi\n\t" __ASM_CFI(".cfi_rel_offset %esi,-8\n\t") "pushl %edi\n\t" __ASM_CFI(".cfi_rel_offset %edi,-12\n\t") /* store exit frame */ "movl 24(%ebp),%ecx\n\t" /* teb */ "movl %ebp,0x1f4(%ecx)\n\t" /* x86_thread_data()->exit_frame */ /* set syscall frame */ "cmpl $0,0x1f8(%ecx)\n\t" /* x86_thread_data()->syscall_frame */ "jnz 1f\n\t" "leal -0x380(%esp),%eax\n\t" /* sizeof(struct syscall_frame) */ "andl $~63,%eax\n\t" "movl %eax,0x1f8(%ecx)\n" /* x86_thread_data()->syscall_frame */ /* switch to thread stack */ "1:\tmovl 4(%ecx),%eax\n\t" /* teb->StackBase */ "leal -0x1000(%eax),%esp\n\t" /* attach dlls */ "pushl %ecx\n\t" /* teb */ "pushl 16(%ebp)\n\t" /* suspend */ "pushl 12(%ebp)\n\t" /* arg */ "pushl 8(%ebp)\n\t" /* entry */ "call " __ASM_NAME("get_initial_context") "\n\t" "movl %eax,(%esp)\n\t" /* context */ "movl 20(%ebp),%edx\n\t" /* thunk */ "xorl %ebp,%ebp\n\t" "pushl $0\n\t" "jmp *%edx" ) /*********************************************************************** * signal_exit_thread */ __ASM_GLOBAL_FUNC( signal_exit_thread, "movl 8(%esp),%ecx\n\t" "movl 12(%esp),%esi\n\t" "xorl %edx,%edx\n\t" /* fetch exit frame */ "xchgl %edx,0x1f4(%esi)\n\t" /* x86_thread_data()->exit_frame */ "testl %edx,%edx\n\t" "jnz 1f\n\t" "jmp *%ecx\n\t" /* switch to exit frame stack */ "1:\tmovl 4(%esp),%eax\n\t" "movl %edx,%ebp\n\t" __ASM_CFI(".cfi_def_cfa %ebp,4\n\t") __ASM_CFI(".cfi_rel_offset %ebp,0\n\t") __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t") __ASM_CFI(".cfi_rel_offset %esi,-8\n\t") __ASM_CFI(".cfi_rel_offset %edi,-12\n\t") "leal -20(%ebp),%esp\n\t" "pushl %eax\n\t" "call *%ecx" ) /********************************************************************** * NtCurrentTeb (NTDLL.@) */ __ASM_STDCALL_FUNC( NtCurrentTeb, 0, ".byte 0x64\n\tmovl 0x18,%eax\n\tret" ) #endif /* __i386__ */
the_stack_data/165769549.c
/** * 指向结构体指针 * */ #include <stdio.h> #define LEN 20 struct names { char first[LEN]; char last[LEN]; }; struct guy { struct names handle; char favfood[LEN]; char job[LEN]; float income; }; int main(void) { struct guy fellow[2] = { { {"Bwen", "Villard"}, "grilled salmon", "personality coach", 58112.00 } , { {"Rodney", "Swillbelly"}, "tripe", "tabloid editor", 232400.00 } }; struct guy *him; printf("address #1: %p #2: %p\n", &fellow[0], &fellow[1]); him = &fellow[0]; printf("pointer #1: %p #2: %p\n", him, him + 1); //(*). 相当于 -> printf("him->income is %.2f:(*him).income is $.2f\n", him->income, (*him).income); //him++ 偏移一个结构体 him ++; printf("him->favfood is %s:him->handle.last is %s\n", him->favfood, him->handle.last); return 0; }
the_stack_data/144693.c
double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size) { int total_size = nums1Size + nums2Size; if(total_size == 0) return 0; int middle = total_size / 2; int medians[2] = {0, 0}; for(int i1 = 0, i2 = 0; i1 + i2 < middle + 1;) { if(i1 == nums1Size) { medians[(i1 + i2) % 2] = nums2[i2++]; continue; } if(i2 == nums2Size) { medians[(i1 + i2) % 2] = nums1[i1++]; continue; } if(nums1[i1] <= nums2[i2]) medians[(i1 + i2) % 2] = nums1[i1++]; else medians[(i1 + i2) % 2] = nums2[i2++]; } if(total_size % 2 == 0) return (double) (medians[0] + medians[1]) / 2; else if(middle % 2 == 0) return medians[0]; else return medians[1]; }
the_stack_data/156393264.c
struct A { int p; }; struct B { struct A n; struct A m; int x; int y; int z; }; extern int g1, g2; static void __attribute__((noinline)) foo (struct B *b) { int t; t = b->n.p; g1 = t; b->n.p = t+1; g2 = b->m.p; b->m = b->n; } void bar (struct B *b) { foo (b); }
the_stack_data/869045.c
#include <stdio.h> #include <stdlib.h> int main(void) { FILE* fp=fopen("test.txt","r"); if (fp!=NULL){ } return EXIT_SUCCESS; }
the_stack_data/74528.c
#include <stdlib.h> #include <time.h> #include <stdio.h> size_t get_ct_size(int d) { int rem = d % 16; if (rem == 0) { return d; } // round_up to nearest 16 if not divisible return d + (16 - rem); } unsigned char *gen_rdm_bytestream(size_t num_bytes) { unsigned char *stream = malloc(num_bytes + 1); size_t i; for (i = 0; i < num_bytes; i++) { stream[i] = rand(); } stream[i] = '\0'; return stream; } int main() { srand((unsigned int) time(NULL)); FILE *outf = fopen("./mykey", "w+"); printf("%d %d", get_ct_size(256), get_ct_size(1024)); char *str = gen_rdm_bytestream(16); for (int i = 0; i < 32; i++) { fprintf(outf, "%02X ", str[i] & 0xFF); } return 0; }
the_stack_data/947776.c
// RUN: clang-cc %s -emit-llvm -o %t // PR2910 struct sockaddr_un { unsigned char sun_len; char sun_path[104]; }; int test(int len) { return __builtin_offsetof(struct sockaddr_un, sun_path[len+1]); }
the_stack_data/43886547.c
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { system("cls"); int contagem = 0, salario_menor_q_100 = 0, filhos = 0, total_filhos = 0, percentual_menor_q_100 = 0; float salarios = 0, media_salarios = 0, media_filhos = 0, total_salarios = 0, maior_salario = 0; printf("\n\n///---Pesquisa de salarios---///"); for (contagem = 0; contagem < 3; contagem++) { printf("\n\nPor favor insira o salario: "); scanf("%f", &salarios); printf("\n\nPor favor insira o numero de filhos: "); scanf("%i", &filhos); if (salarios < 100) { salario_menor_q_100 = salario_menor_q_100 + 1; } if (salarios > maior_salario) { maior_salario = salarios; } total_salarios = total_salarios + salarios; total_filhos = total_filhos + filhos; } media_salarios = total_salarios / contagem; media_filhos = total_filhos / contagem; percentual_menor_q_100 = (salario_menor_q_100 * 100) / contagem; printf("\n\nA media do salario da populacao eh de :R$%0.2f", media_salarios); printf("\n\nA media de filhos da populacao eh de :%0.2f", media_filhos); printf("\n\nO maior salario eh de :%0.2f", maior_salario); printf("\n\nO percentual de pessoas com salario ate R$100 eh de :%i %%", percentual_menor_q_100); printf("\n\nO numero de pessoas com salario ate R$100 eh de :%i\n\n", salario_menor_q_100); return 0; }
the_stack_data/115953.c
#include<stdio.h> #include<stdlib.h> #define MAX 3 typedef struct { char nome[50]; int idade; float peso; char time[50]; }jogador; void inserir(jogador *j){ printf("Digite o Nome: "); scanf("%s", j->nome); printf("Digite a Idade: "); scanf("%d", &j->idade); printf("Digite o Peso: "); scanf("%f", &j->peso); printf("Digite o Time: "); scanf("%s", j->time); } void exibir(jogador *j){ printf("Nome: %s\n", j->nome); printf("Idade: %d\n", j->idade); printf("Peso: %.2f\n", j->peso); printf("Time: %s\n\n", j->time); } int main(void){ jogador p[MAX]; for (int i = 0; i < MAX; i++) { printf("Jogador %d\n", i+1); inserir(&p[i]); system ("cls"); } system ("cls"); printf("Lista de Jogadores!\n\n"); for (int i = 0; i < MAX; i++) { printf("Jogador %d\n", i+1); exibir(&p[i]); } return 0; }
the_stack_data/158904.c
#include<stdio.h> int c(int m,int n) { if(n==0) return 1; if(n==m) return 1; return c(m-1,n)+c(m-1,n-1); } int main() { int m,n; scanf("%d %d",&m,&n); printf("%d",c(m,n)); return 0; }
the_stack_data/116788.c
#include <stdio.h> #define ys(x,y) x%y int main(){ int x,y; scanf("%d %d",&x,&y); int yy = ys(x,y); printf("%d",yy); return 0; }
the_stack_data/23575175.c
#include <stdio.h> int main() { int tentative; scanf("%d", &tentative); if (tentative == 64741) { printf("Bon festin !\n"); } else { printf("Allez-vous-en !\n"); } }
the_stack_data/803754.c
#include <stdio.h> void abc() { printf("This is abc\n"); } // int main() { // printf(" Hello Hi\n"); // return 0; // }
the_stack_data/130346.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isspace.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mscot <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/11/03 17:44:06 by mscot #+# #+# */ /* Updated: 2020/11/03 17:44:10 by mscot ### ########.fr */ /* */ /* ************************************************************************** */ int ft_isspace(char c) { return ((c >= 9 && c <= 13) || c == 32); }
the_stack_data/117400.c
#include <stdio.h> int main (){ int N; scanf("%d", &N); if(N == 61){ printf("Brasilia\n"); } else if(N == 71){ printf("Salvador\n"); } else if(N == 11){ printf("Sao Paulo\n"); } else if(N == 21){ printf("Rio de Janeiro\n"); } else if(N == 32){ printf("Juiz de Fora\n"); } else if(N == 19){ printf("Campinas\n"); } else if(N == 27){ printf("Vitoria\n"); } else if(N == 31){ printf("Belo Horizonte\n"); } else{ printf("DDD nao cadastrado\n"); } return 0; }
the_stack_data/62636846.c
#include <stdio.h> #include <stdlib.h> typedef int elemType; struct sNode{ /* 值域 */ elemType data; /* 链接指针 */ struct sNode *next; }; struct queueLK{ /* 队首指针 */ struct sNode *front; /* 队尾指针 */ struct sNode *rear; }; /* 1.初始化链队 */ void initQueue(struct queueLK *hq) { /* 把队首和队尾指针置空 */ hq->front = hq->rear = NULL; return; } /* 2.向链队中插入一个元素x */ void enQueue(struct queueLK *hq, elemType x) { /* 得到一个由newP指针所指向的新结点 */ struct sNode *newP; newP = (struct sNode *)malloc(sizeof(struct sNode)); if(newP == NULL){ printf("内存空间分配失败! "); exit(1); } /* 把x的值赋给新结点的值域,把新结点的指针域置空 */ newP->data = x; newP->next = NULL; /* 若链队为空,则新结点即是队首结点又是队尾结点 */ if(hq->rear == NULL){ hq->front = hq->rear = newP; }else{ /* 若链队非空,则依次修改队尾结点的指针域和队尾指针,使之指向新的队尾结点 */ /* 注意赋值顺序哦 */ hq->rear = hq->rear->next = newP; } return; } /* 3.从队列中删除一个元素 */ elemType outQueue(struct queueLK *hq) { struct sNode *p; elemType temp; /* 若链队为空则停止运行 */ if(hq->front == NULL){ printf("队列为空,无法删除! "); exit(1); } /* 暂存队尾元素以便返回 */ temp = hq->front->data; /* 暂存队尾指针以便回收队尾结点 */ p = hq->front; /* 使队首指针指向下一个结点 */ hq->front = p->next; /* 若删除后链队为空,则需同时使队尾指针为空 */ if(hq->front == NULL){ hq->rear = NULL; } /* 回收原队首结点 */ free(p); /* 返回被删除的队首元素值 */ return temp; } /* 4.读取队首元素 */ elemType peekQueue(struct queueLK *hq) { /* 若链队为空则停止运行 */ if(hq->front == NULL){ printf("队列为空,无法删除! "); exit(1); } /* 返回队首元素 */ return hq->front->data; } /* 5.检查链队是否为空,若为空则返回1, 否则返回0 */ int emptyQueue(struct queueLK *hq) { /* 判断队首或队尾任一个指针是否为空即可 */ if(hq->front == NULL){ return 1; }else{ return 0; } } /* 6.清除链队中的所有元素 */ void clearQueue(struct queueLK *hq) { /* 队首指针赋给p */ struct sNode *p = hq->front; /* 依次删除队列中的每一个结点,最后使队首指针为空 */ while(p != NULL){ hq->front = hq->front->next; free(p); p = hq->front; }/* 循环结束后队首指针已经为空 */ /* 置队尾指针为空 */ hq->rear = NULL; return; } int main(int argc, char* argv[]) { struct queueLK q; int a[8] = {3, 8, 5, 17, 9, 30, 15, 22}; int i; initQueue(&q); for(i = 0; i < 8; i++){ enQueue(&q, a[i]); } printf("%d ", outQueue(&q)); printf("%d ", outQueue(&q)); enQueue(&q, 68); printf("%d ", peekQueue(&q)); printf("%d ", outQueue(&q)); while(!emptyQueue(&q)){ printf("%d ", outQueue(&q)); } printf(" "); clearQueue(&q); }
the_stack_data/1168459.c
#include <stdio.h> int platform1D(int ar[], int size); int main() { int i,b[50],size; printf("Enter array size: \n"); scanf("%d", &size); printf("Enter %d data: \n", size); for (i=0; i<size; i++) scanf("%d",&b[i]); printf("platform1D(): %d\n", platform1D(b,size)); return 0; } int platform1D(int ar[], int size) { /* Write your program code here */ int pos, length_max = 1, length = 1; for (pos=0; pos<size; pos++){ if (ar[pos] == ar[pos-1]) { length++; } else { if (length_max < length){ length_max = length; } length = 1; } } return length_max; }
the_stack_data/212642052.c
#include<stdio.h> #include<math.h> int main() { int a,n,sum=0,num=0; scanf("%d%d",&a,&n); while(n!=0) { sum+=(n%10)*pow(a,num); num++; n/=10; } printf("%d\n",sum); return 0; }
the_stack_data/150142055.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_eight_queens_puzzle_2.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: evgenkarlson <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 12:33:14 by evgenkarlson #+# #+# */ /* Updated: 2020/02/15 10:51:23 by evgenkarlson ### ########.fr */ /* */ /* ************************************************************************** */ /* команда для компиляции и одновременного запуска */ /* */ /* gcc -Wall -Werror -Wextra test.c && chmod +x ./a.out && ./a.out */ /* ************************************************************************** */ #include <unistd.h> #define ABS(a, b) ((a >= b) ? (a - b) : (b - a)) /* ************************************************************************** */ /* ************************************************************************** */ /* ************************************************************************** */ void ft_putchar(char c) { write(1, &c, 1); } /* ************************************************************************** */ /* ************************************************************************** */ /* ************************************************************************** */ static void solve_queens_puzzle(int queens, int col, int *board) { int i; int j; if (col == queens) { i = -1; while (++i < queens) { j = 0; while (j < queens) (j++ == board[i]) ? ft_putchar(j + '0') : 0; } ft_putchar('\n'); } i = 0; while (i < queens) { j = 0; while (j < col && !(board[j] == i || ABS(board[j], i) == col - j)) j += 1; if (j < col && i++ < queens) continue ; board[col] = i++; solve_queens_puzzle(queens, col + 1, board); } } void ft_eight_queens_puzzle_2(void) { int board[8]; int queens; int pos; queens = 8; pos = 0; solve_queens_puzzle(queens, pos, board); } /* ************************************************************************** */ /* ************************************************************************** */ /* ************************************************************************** */ int main(void) { ft_eight_queens_puzzle_2(); return (0); } /* ************************************************************************** */
the_stack_data/736438.c
// Check for upper triangular matrix. #include <stdio.h> void main() { int r, c, f = 1; printf("Enter the number of rows: "); scanf("%d", &r); printf("\nEnter the number of columns: "); scanf("%d", &c); int a[r][c], i, j; for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { printf("\nEnter the array element for %d, %d: ", i, j); scanf("%d", &a[i][j]); } } if (r == c) { for (i = 0; i < r; i++) { for (j = i; j < c; j++) { if (a[i][j] == 0) f = 0; } } for (i = 1; i < r; i++) { for (j = 0; j < i; j++) { if (a[i][j] != 0) f = 0; } } printf("\nThe array is:\n\n"); for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { printf("%d \t", a[i][j]); } printf("\n"); } if (f == 1) { printf("\nIt is an upper triangular matrix.\n"); } else { printf("\nIt is not an upper triangular matrix.\n"); } } else { printf("It is not a square matrix.\n"); } }
the_stack_data/147848.c
#include <stdio.h> #include <stdlib.h> #include <dlfcn.h> void * vdlopen(const char *filename, int flag) { void *dl_handle; dl_handle = dlopen(filename, RTLD_LAZY); if (!dl_handle) { printf("Load %s library, error: %s\n", filename, dlerror()); exit(EXIT_FAILURE); } else { printf("Load %s library, success!\n", filename); } return dl_handle; } void * vdlsym(void *handle, const char *symbol) { double (*func)(double); /* Yep ... this is only for double */ func = dlsym(handle, symbol); if (!func) { printf("Load %s symbol, error: %s\n", symbol, dlerror()); exit(EXIT_FAILURE); } else { printf("Load %s symbol, success!\n", symbol); } return func; } int vdlclose(void *handle) { int i; i = dlclose(handle); if (i) { printf("Unload error %i: %s\n", i, dlerror()); exit(EXIT_FAILURE); } else { printf("Unload, success!\n"); } return i; } int main() { double x, y; x = 60.0; char *lib = "libm.so"; char *method = "sin"; void *dl_handle; double (*func)(double); dl_handle = vdlopen(lib, RTLD_LAZY); func = vdlsym(dl_handle, method); y = (*func)(x * 3.141592 / 180.0); printf("angle = %f degree, sin(angle) = %f\n", x, y); vdlclose(dl_handle); exit(0); }
the_stack_data/26433.c
/* $KAME: altq_blue.c,v 1.14 2003/09/05 22:40:36 itojun Exp $ */ /* * Copyright (C) 1997-2002 * Sony Computer Science Laboratories Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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 SONY CSL 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 SONY CSL 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. * */ /* * Copyright (c) 1990-1994 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Computer Systems * Engineering Group at Lawrence Berkeley Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. */ #if defined(__FreeBSD__) || defined(__NetBSD__) #include "opt_altq.h" #if (__FreeBSD__ != 2) #include "opt_inet.h" #ifdef __FreeBSD__ #include "opt_inet6.h" #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ #ifdef ALTQ_BLUE /* blue is enabled by ALTQ_BLUE option in opt_altq.h */ #include <sys/param.h> #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/sockio.h> #include <sys/systm.h> #include <sys/proc.h> #include <sys/errno.h> #include <sys/kernel.h> #include <net/if.h> #include <net/if_types.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #ifdef INET6 #include <netinet/ip6.h> #endif #include <altq/altq.h> #include <altq/altq_conf.h> #include <altq/altq_blue.h> #ifdef ALTQ3_COMPAT /* * Blue is proposed and implemented by Wu-chang Feng <[email protected]>. * more information on Blue is available from * http://www.eecs.umich.edu/~wuchang/blue/ */ /* fixed-point uses 12-bit decimal places */ #define FP_SHIFT 12 /* fixed-point shift */ #define BLUE_LIMIT 200 /* default max queue lenght */ #define BLUE_STATS /* collect statistics */ /* blue_list keeps all blue_state_t's allocated. */ static blue_queue_t *blue_list = NULL; /* internal function prototypes */ static int blue_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *); static struct mbuf *blue_dequeue(struct ifaltq *, int); static int drop_early(blue_t *); static int mark_ecn(struct mbuf *, struct altq_pktattr *, int); static int blue_detach(blue_queue_t *); static int blue_request(struct ifaltq *, int, void *); /* * blue device interface */ altqdev_decl(blue); int blueopen(dev, flag, fmt, p) dev_t dev; int flag, fmt; #if (__FreeBSD_version > 500000) struct thread *p; #else struct proc *p; #endif { /* everything will be done when the queueing scheme is attached. */ return 0; } int blueclose(dev, flag, fmt, p) dev_t dev; int flag, fmt; #if (__FreeBSD_version > 500000) struct thread *p; #else struct proc *p; #endif { blue_queue_t *rqp; int err, error = 0; while ((rqp = blue_list) != NULL) { /* destroy all */ err = blue_detach(rqp); if (err != 0 && error == 0) error = err; } return error; } int blueioctl(dev, cmd, addr, flag, p) dev_t dev; ioctlcmd_t cmd; caddr_t addr; int flag; #if (__FreeBSD_version > 500000) struct thread *p; #else struct proc *p; #endif { blue_queue_t *rqp; struct blue_interface *ifacep; struct ifnet *ifp; int error = 0; /* check super-user privilege */ switch (cmd) { case BLUE_GETSTATS: break; default: #if (__FreeBSD_version > 400000) if ((error = suser(p)) != 0) return (error); #else if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return (error); #endif break; } switch (cmd) { case BLUE_ENABLE: ifacep = (struct blue_interface *)addr; if ((rqp = altq_lookup(ifacep->blue_ifname, ALTQT_BLUE)) == NULL) { error = EBADF; break; } error = altq_enable(rqp->rq_ifq); break; case BLUE_DISABLE: ifacep = (struct blue_interface *)addr; if ((rqp = altq_lookup(ifacep->blue_ifname, ALTQT_BLUE)) == NULL) { error = EBADF; break; } error = altq_disable(rqp->rq_ifq); break; case BLUE_IF_ATTACH: ifp = ifunit(((struct blue_interface *)addr)->blue_ifname); if (ifp == NULL) { error = ENXIO; break; } /* allocate and initialize blue_state_t */ MALLOC(rqp, blue_queue_t *, sizeof(blue_queue_t), M_DEVBUF, M_WAITOK); bzero(rqp, sizeof(blue_queue_t)); MALLOC(rqp->rq_q, class_queue_t *, sizeof(class_queue_t), M_DEVBUF, M_WAITOK); bzero(rqp->rq_q, sizeof(class_queue_t)); MALLOC(rqp->rq_blue, blue_t *, sizeof(blue_t), M_DEVBUF, M_WAITOK); bzero(rqp->rq_blue, sizeof(blue_t)); rqp->rq_ifq = &ifp->if_snd; qtail(rqp->rq_q) = NULL; qlen(rqp->rq_q) = 0; qlimit(rqp->rq_q) = BLUE_LIMIT; /* default packet time: 1000 bytes / 10Mbps * 8 * 1000000 */ blue_init(rqp->rq_blue, 0, 800, 1000, 50000); /* * set BLUE to this ifnet structure. */ error = altq_attach(rqp->rq_ifq, ALTQT_BLUE, rqp, blue_enqueue, blue_dequeue, blue_request, NULL, NULL); if (error) { FREE(rqp->rq_blue, M_DEVBUF); FREE(rqp->rq_q, M_DEVBUF); FREE(rqp, M_DEVBUF); break; } /* add this state to the blue list */ rqp->rq_next = blue_list; blue_list = rqp; break; case BLUE_IF_DETACH: ifacep = (struct blue_interface *)addr; if ((rqp = altq_lookup(ifacep->blue_ifname, ALTQT_BLUE)) == NULL) { error = EBADF; break; } error = blue_detach(rqp); break; case BLUE_GETSTATS: do { struct blue_stats *q_stats; blue_t *rp; q_stats = (struct blue_stats *)addr; if ((rqp = altq_lookup(q_stats->iface.blue_ifname, ALTQT_BLUE)) == NULL) { error = EBADF; break; } q_stats->q_len = qlen(rqp->rq_q); q_stats->q_limit = qlimit(rqp->rq_q); rp = rqp->rq_blue; q_stats->q_pmark = rp->blue_pmark; q_stats->xmit_packets = rp->blue_stats.xmit_packets; q_stats->xmit_bytes = rp->blue_stats.xmit_bytes; q_stats->drop_packets = rp->blue_stats.drop_packets; q_stats->drop_bytes = rp->blue_stats.drop_bytes; q_stats->drop_forced = rp->blue_stats.drop_forced; q_stats->drop_unforced = rp->blue_stats.drop_unforced; q_stats->marked_packets = rp->blue_stats.marked_packets; } while (/*CONSTCOND*/ 0); break; case BLUE_CONFIG: do { struct blue_conf *fc; int limit; fc = (struct blue_conf *)addr; if ((rqp = altq_lookup(fc->iface.blue_ifname, ALTQT_BLUE)) == NULL) { error = EBADF; break; } limit = fc->blue_limit; qlimit(rqp->rq_q) = limit; fc->blue_limit = limit; /* write back the new value */ if (fc->blue_pkttime > 0) rqp->rq_blue->blue_pkttime = fc->blue_pkttime; if (fc->blue_max_pmark > 0) rqp->rq_blue->blue_max_pmark = fc->blue_max_pmark; if (fc->blue_hold_time > 0) rqp->rq_blue->blue_hold_time = fc->blue_hold_time; rqp->rq_blue->blue_flags = fc->blue_flags; blue_init(rqp->rq_blue, rqp->rq_blue->blue_flags, rqp->rq_blue->blue_pkttime, rqp->rq_blue->blue_max_pmark, rqp->rq_blue->blue_hold_time); } while (/*CONSTCOND*/ 0); break; default: error = EINVAL; break; } return error; } static int blue_detach(rqp) blue_queue_t *rqp; { blue_queue_t *tmp; int error = 0; if (ALTQ_IS_ENABLED(rqp->rq_ifq)) altq_disable(rqp->rq_ifq); if ((error = altq_detach(rqp->rq_ifq))) return (error); if (blue_list == rqp) blue_list = rqp->rq_next; else { for (tmp = blue_list; tmp != NULL; tmp = tmp->rq_next) if (tmp->rq_next == rqp) { tmp->rq_next = rqp->rq_next; break; } if (tmp == NULL) printf("blue_detach: no state found in blue_list!\n"); } FREE(rqp->rq_q, M_DEVBUF); FREE(rqp->rq_blue, M_DEVBUF); FREE(rqp, M_DEVBUF); return (error); } /* * blue support routines */ int blue_init(rp, flags, pkttime, blue_max_pmark, blue_hold_time) blue_t *rp; int flags; int pkttime; int blue_max_pmark; int blue_hold_time; { int npkts_per_sec; rp->blue_idle = 1; rp->blue_flags = flags; rp->blue_pkttime = pkttime; rp->blue_max_pmark = blue_max_pmark; rp->blue_hold_time = blue_hold_time; if (pkttime == 0) rp->blue_pkttime = 1; /* when the link is very slow, adjust blue parameters */ npkts_per_sec = 1000000 / rp->blue_pkttime; if (npkts_per_sec < 50) { } else if (npkts_per_sec < 300) { } microtime(&rp->blue_last); return (0); } /* * enqueue routine: * * returns: 0 when successfully queued. * ENOBUFS when drop occurs. */ static int blue_enqueue(ifq, m, pktattr) struct ifaltq *ifq; struct mbuf *m; struct altq_pktattr *pktattr; { blue_queue_t *rqp = (blue_queue_t *)ifq->altq_disc; int error = 0; if (blue_addq(rqp->rq_blue, rqp->rq_q, m, pktattr) == 0) ifq->ifq_len++; else error = ENOBUFS; return error; } #define DTYPE_NODROP 0 /* no drop */ #define DTYPE_FORCED 1 /* a "forced" drop */ #define DTYPE_EARLY 2 /* an "unforced" (early) drop */ int blue_addq(rp, q, m, pktattr) blue_t *rp; class_queue_t *q; struct mbuf *m; struct altq_pktattr *pktattr; { int droptype; /* * if we were idle, this is an enqueue onto an empty queue * and we should decrement marking probability * */ if (rp->blue_idle) { struct timeval now; int t; rp->blue_idle = 0; microtime(&now); t = (now.tv_sec - rp->blue_last.tv_sec); if ( t > 1) { rp->blue_pmark = 1; microtime(&rp->blue_last); } else { t = t * 1000000 + (now.tv_usec - rp->blue_last.tv_usec); if (t > rp->blue_hold_time) { rp->blue_pmark--; if (rp->blue_pmark < 0) rp->blue_pmark = 0; microtime(&rp->blue_last); } } } /* see if we drop early */ droptype = DTYPE_NODROP; if (drop_early(rp) && qlen(q) > 1) { /* mark or drop by blue */ if ((rp->blue_flags & BLUEF_ECN) && mark_ecn(m, pktattr, rp->blue_flags)) { /* successfully marked. do not drop. */ #ifdef BLUE_STATS rp->blue_stats.marked_packets++; #endif } else { /* unforced drop by blue */ droptype = DTYPE_EARLY; } } /* * if the queue length hits the hard limit, it's a forced drop. */ if (droptype == DTYPE_NODROP && qlen(q) >= qlimit(q)) droptype = DTYPE_FORCED; /* if successful or forced drop, enqueue this packet. */ if (droptype != DTYPE_EARLY) _addq(q, m); if (droptype != DTYPE_NODROP) { if (droptype == DTYPE_EARLY) { /* drop the incoming packet */ #ifdef BLUE_STATS rp->blue_stats.drop_unforced++; #endif } else { struct timeval now; int t; /* forced drop, select a victim packet in the queue. */ m = _getq_random(q); microtime(&now); t = (now.tv_sec - rp->blue_last.tv_sec); t = t * 1000000 + (now.tv_usec - rp->blue_last.tv_usec); if (t > rp->blue_hold_time) { rp->blue_pmark += rp->blue_max_pmark >> 3; if (rp->blue_pmark > rp->blue_max_pmark) rp->blue_pmark = rp->blue_max_pmark; microtime(&rp->blue_last); } #ifdef BLUE_STATS rp->blue_stats.drop_forced++; #endif } #ifdef BLUE_STATS rp->blue_stats.drop_packets++; rp->blue_stats.drop_bytes += m->m_pkthdr.len; #endif m_freem(m); return (-1); } /* successfully queued */ return (0); } /* * early-drop probability is kept in blue_pmark * */ static int drop_early(rp) blue_t *rp; { if ((arc4random() % rp->blue_max_pmark) < rp->blue_pmark) { /* drop or mark */ return (1); } /* no drop/mark */ return (0); } /* * try to mark CE bit to the packet. * returns 1 if successfully marked, 0 otherwise. */ static int mark_ecn(m, pktattr, flags) struct mbuf *m; struct altq_pktattr *pktattr; int flags; { struct mbuf *m0; if (pktattr == NULL || (pktattr->pattr_af != AF_INET && pktattr->pattr_af != AF_INET6)) return (0); /* verify that pattr_hdr is within the mbuf data */ for (m0 = m; m0 != NULL; m0 = m0->m_next) if ((pktattr->pattr_hdr >= m0->m_data) && (pktattr->pattr_hdr < m0->m_data + m0->m_len)) break; if (m0 == NULL) { /* ick, pattr_hdr is stale */ pktattr->pattr_af = AF_UNSPEC; return (0); } switch (pktattr->pattr_af) { case AF_INET: if (flags & BLUEF_ECN4) { struct ip *ip = (struct ip *)pktattr->pattr_hdr; u_int8_t otos; int sum; if (ip->ip_v != 4) return (0); /* version mismatch! */ if ((ip->ip_tos & IPTOS_ECN_MASK) == IPTOS_ECN_NOTECT) return (0); /* not-ECT */ if ((ip->ip_tos & IPTOS_ECN_MASK) == IPTOS_ECN_CE) return (1); /* already marked */ /* * ecn-capable but not marked, * mark CE and update checksum */ otos = ip->ip_tos; ip->ip_tos |= IPTOS_ECN_CE; /* * update checksum (from RFC1624) * HC' = ~(~HC + ~m + m') */ sum = ~ntohs(ip->ip_sum) & 0xffff; sum += (~otos & 0xffff) + ip->ip_tos; sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); /* add carry */ ip->ip_sum = htons(~sum & 0xffff); return (1); } break; #ifdef INET6 case AF_INET6: if (flags & BLUEF_ECN6) { struct ip6_hdr *ip6 = (struct ip6_hdr *)pktattr->pattr_hdr; u_int32_t flowlabel; flowlabel = ntohl(ip6->ip6_flow); if ((flowlabel >> 28) != 6) return (0); /* version mismatch! */ if ((flowlabel & (IPTOS_ECN_MASK << 20)) == (IPTOS_ECN_NOTECT << 20)) return (0); /* not-ECT */ if ((flowlabel & (IPTOS_ECN_MASK << 20)) == (IPTOS_ECN_CE << 20)) return (1); /* already marked */ /* * ecn-capable but not marked, mark CE */ flowlabel |= (IPTOS_ECN_CE << 20); ip6->ip6_flow = htonl(flowlabel); return (1); } break; #endif /* INET6 */ } /* not marked */ return (0); } /* * dequeue routine: * must be called in splimp. * * returns: mbuf dequeued. * NULL when no packet is available in the queue. */ static struct mbuf * blue_dequeue(ifq, op) struct ifaltq *ifq; int op; { blue_queue_t *rqp = (blue_queue_t *)ifq->altq_disc; struct mbuf *m = NULL; if (op == ALTDQ_POLL) return (qhead(rqp->rq_q)); m = blue_getq(rqp->rq_blue, rqp->rq_q); if (m != NULL) ifq->ifq_len--; return m; } struct mbuf *blue_getq(rp, q) blue_t *rp; class_queue_t *q; { struct mbuf *m; if ((m = _getq(q)) == NULL) { if (rp->blue_idle == 0) { rp->blue_idle = 1; microtime(&rp->blue_last); } return NULL; } rp->blue_idle = 0; #ifdef BLUE_STATS rp->blue_stats.xmit_packets++; rp->blue_stats.xmit_bytes += m->m_pkthdr.len; #endif return (m); } static int blue_request(ifq, req, arg) struct ifaltq *ifq; int req; void *arg; { blue_queue_t *rqp = (blue_queue_t *)ifq->altq_disc; switch (req) { case ALTRQ_PURGE: _flushq(rqp->rq_q); if (ALTQ_IS_ENABLED(ifq)) ifq->ifq_len = 0; break; } return (0); } #ifdef KLD_MODULE static struct altqsw blue_sw = {"blue", blueopen, blueclose, blueioctl}; ALTQ_MODULE(altq_blue, ALTQT_BLUE, &blue_sw); #endif /* KLD_MODULE */ #endif /* ALTQ3_COMPAT */ #endif /* ALTQ_BLUE */
the_stack_data/1031864.c
/* ========================================================================== * setproctitle.c - Linux/Darwin setproctitle. * -------------------------------------------------------------------------- * Copyright (C) 2010 William Ahern * Copyright (C) 2013 Salvatore Sanfilippo * Copyright (C) 2013 Stam He * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to permit * persons to whom the Software is furnished to do so, subject to the * following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * ========================================================================== */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include <stddef.h> /* NULL size_t */ #include <stdarg.h> /* va_list va_start va_end */ #include <stdlib.h> /* malloc(3) setenv(3) clearenv(3) setproctitle(3) getprogname(3) */ #include <stdio.h> /* vsnprintf(3) snprintf(3) */ #include <string.h> /* strlen(3) strchr(3) strdup(3) memset(3) memcpy(3) */ #include <errno.h> /* errno program_invocation_name program_invocation_short_name */ #if !defined(HAVE_SETPROCTITLE) #define HAVE_SETPROCTITLE (defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__) #endif #if !HAVE_SETPROCTITLE #if (defined __linux || defined __APPLE__) extern char **environ; static struct { /* original value */ const char *arg0; /* title space available */ char *base, *end; /* pointer to original nul character within base */ char *nul; _Bool reset; int error; } SPT; #ifndef SPT_MIN #define SPT_MIN(a, b) (((a) < (b))? (a) : (b)) #endif static inline size_t spt_min(size_t a, size_t b) { return SPT_MIN(a, b); } /* spt_min() */ /* * For discussion on the portability of the various methods, see * http://lists.freebsd.org/pipermail/freebsd-stable/2008-June/043136.html */ static int spt_clearenv(void) { #if __GLIBC__ clearenv(); return 0; #else extern char **environ; static char **tmp; if (!(tmp = malloc(sizeof *tmp))) return errno; tmp[0] = NULL; environ = tmp; return 0; #endif } /* spt_clearenv() */ static int spt_copyenv(char *oldenv[]) { extern char **environ; char *eq; int i, error; if (environ != oldenv) return 0; if ((error = spt_clearenv())) goto error; for (i = 0; oldenv[i]; i++) { if (!(eq = strchr(oldenv[i], '='))) continue; *eq = '\0'; error = (0 != setenv(oldenv[i], eq + 1, 1))? errno : 0; *eq = '='; if (error) goto error; } return 0; error: environ = oldenv; return error; } /* spt_copyenv() */ static int spt_copyargs(int argc, char *argv[]) { char *tmp; int i; for (i = 1; i < argc || (i >= argc && argv[i]); i++) { if (!argv[i]) continue; if (!(tmp = strdup(argv[i]))) return errno; argv[i] = tmp; } return 0; } /* spt_copyargs() */ void spt_init(int argc, char *argv[]) { char **envp = environ; char *base, *end, *nul, *tmp; int i, error; if (!(base = argv[0])) return; nul = &base[strlen(base)]; end = nul + 1; for (i = 0; i < argc || (i >= argc && argv[i]); i++) { if (!argv[i] || argv[i] < end) continue; end = argv[i] + strlen(argv[i]) + 1; } for (i = 0; envp[i]; i++) { if (envp[i] < end) continue; end = envp[i] + strlen(envp[i]) + 1; } if (!(SPT.arg0 = strdup(argv[0]))) goto syerr; #if __GLIBC__ if (!(tmp = strdup(program_invocation_name))) goto syerr; program_invocation_name = tmp; if (!(tmp = strdup(program_invocation_short_name))) goto syerr; program_invocation_short_name = tmp; #elif __APPLE__ if (!(tmp = strdup(getprogname()))) goto syerr; setprogname(tmp); #endif if ((error = spt_copyenv(envp))) goto error; if ((error = spt_copyargs(argc, argv))) goto error; SPT.nul = nul; SPT.base = base; SPT.end = end; return; syerr: error = errno; error: SPT.error = error; } /* spt_init() */ #ifndef SPT_MAXTITLE #define SPT_MAXTITLE 255 #endif void setproctitle(const char *fmt, ...) { char buf[SPT_MAXTITLE + 1]; /* use buffer in case argv[0] is passed */ va_list ap; char *nul; int len, error; if (!SPT.base) return; if (fmt) { va_start(ap, fmt); len = vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); } else { len = snprintf(buf, sizeof buf, "%s", SPT.arg0); } if (len <= 0) { error = errno; goto error; } if (!SPT.reset) { memset(SPT.base, 0, SPT.end - SPT.base); SPT.reset = 1; } else { memset(SPT.base, 0, spt_min(sizeof buf, SPT.end - SPT.base)); } len = spt_min(len, spt_min(sizeof buf, SPT.end - SPT.base) - 1); memcpy(SPT.base, buf, len); nul = &SPT.base[len]; if (nul < SPT.nul) { *SPT.nul = '.'; } else if (nul == SPT.nul && &nul[1] < SPT.end) { *SPT.nul = ' '; *++nul = '\0'; } return; error: SPT.error = error; } /* setproctitle() */ #endif /* __linux || __APPLE__ */ #endif /* !HAVE_SETPROCTITLE */
the_stack_data/766870.c
//@ ltl invariant negative: ( ( ([] (<> ( AP((p0_l0 != 0)) && AP((p0_l1 != 0))))) || (! ([] (<> ( AP((p0_l0 != 0)) && (! AP((p0_l1 != 0)))))))) || (! ([] (<> AP((1.0 <= _diverge_delta)))))); extern float __VERIFIER_nondet_float(void); extern int __VERIFIER_nondet_int(void); char __VERIFIER_nondet_bool(void) { return __VERIFIER_nondet_int() != 0; } float p17_x, _x_p17_x; float p16_x, _x_p16_x; float p15_x, _x_p15_x; float p14_x, _x_p14_x; char p12_l0, _x_p12_l0; float p12_x, _x_p12_x; float _diverge_delta, _x__diverge_delta; char p17_l1, _x_p17_l1; char p11_l0, _x_p11_l0; float p11_x, _x_p11_x; char p16_l1, _x_p16_l1; char p10_l0, _x_p10_l0; float p10_x, _x_p10_x; float p9_x, _x_p9_x; char p2_l1, _x_p2_l1; char p17_l0, _x_p17_l0; float p6_x, _x_p6_x; char p8_l1, _x_p8_l1; char p2_l0, _x_p2_l0; char p13_l0, _x_p13_l0; float p2_x, _x_p2_x; char p1_l1, _x_p1_l1; float delta, _x_delta; float p13_x, _x_p13_x; char p0_l0, _x_p0_l0; char p7_l1, _x_p7_l1; float p0_x, _x_p0_x; char p12_l1, _x_p12_l1; char p6_l0, _x_p6_l0; int turn, _x_turn; int id, _x_id; char p14_l0, _x_p14_l0; float p3_x, _x_p3_x; char p15_l1, _x_p15_l1; char p9_l0, _x_p9_l0; float p1_x, _x_p1_x; char p5_l1, _x_p5_l1; char p9_l1, _x_p9_l1; char p3_l0, _x_p3_l0; char p3_l1, _x_p3_l1; char p0_l1, _x_p0_l1; float p7_x, _x_p7_x; char p15_l0, _x_p15_l0; float p4_x, _x_p4_x; char p10_l1, _x_p10_l1; char p4_l0, _x_p4_l0; char p1_l0, _x_p1_l0; char p4_l1, _x_p4_l1; float p8_x, _x_p8_x; char p16_l0, _x_p16_l0; float p5_x, _x_p5_x; char p11_l1, _x_p11_l1; char p5_l0, _x_p5_l0; char p6_l1, _x_p6_l1; char p13_l1, _x_p13_l1; char p7_l0, _x_p7_l0; char p14_l1, _x_p14_l1; char p8_l0, _x_p8_l0; int main() { p17_x = __VERIFIER_nondet_float(); p16_x = __VERIFIER_nondet_float(); p15_x = __VERIFIER_nondet_float(); p14_x = __VERIFIER_nondet_float(); p12_l0 = __VERIFIER_nondet_bool(); p12_x = __VERIFIER_nondet_float(); _diverge_delta = __VERIFIER_nondet_float(); p17_l1 = __VERIFIER_nondet_bool(); p11_l0 = __VERIFIER_nondet_bool(); p11_x = __VERIFIER_nondet_float(); p16_l1 = __VERIFIER_nondet_bool(); p10_l0 = __VERIFIER_nondet_bool(); p10_x = __VERIFIER_nondet_float(); p9_x = __VERIFIER_nondet_float(); p2_l1 = __VERIFIER_nondet_bool(); p17_l0 = __VERIFIER_nondet_bool(); p6_x = __VERIFIER_nondet_float(); p8_l1 = __VERIFIER_nondet_bool(); p2_l0 = __VERIFIER_nondet_bool(); p13_l0 = __VERIFIER_nondet_bool(); p2_x = __VERIFIER_nondet_float(); p1_l1 = __VERIFIER_nondet_bool(); delta = __VERIFIER_nondet_float(); p13_x = __VERIFIER_nondet_float(); p0_l0 = __VERIFIER_nondet_bool(); p7_l1 = __VERIFIER_nondet_bool(); p0_x = __VERIFIER_nondet_float(); p12_l1 = __VERIFIER_nondet_bool(); p6_l0 = __VERIFIER_nondet_bool(); turn = __VERIFIER_nondet_int(); id = __VERIFIER_nondet_int(); p14_l0 = __VERIFIER_nondet_bool(); p3_x = __VERIFIER_nondet_float(); p15_l1 = __VERIFIER_nondet_bool(); p9_l0 = __VERIFIER_nondet_bool(); p1_x = __VERIFIER_nondet_float(); p5_l1 = __VERIFIER_nondet_bool(); p9_l1 = __VERIFIER_nondet_bool(); p3_l0 = __VERIFIER_nondet_bool(); p3_l1 = __VERIFIER_nondet_bool(); p0_l1 = __VERIFIER_nondet_bool(); p7_x = __VERIFIER_nondet_float(); p15_l0 = __VERIFIER_nondet_bool(); p4_x = __VERIFIER_nondet_float(); p10_l1 = __VERIFIER_nondet_bool(); p4_l0 = __VERIFIER_nondet_bool(); p1_l0 = __VERIFIER_nondet_bool(); p4_l1 = __VERIFIER_nondet_bool(); p8_x = __VERIFIER_nondet_float(); p16_l0 = __VERIFIER_nondet_bool(); p5_x = __VERIFIER_nondet_float(); p11_l1 = __VERIFIER_nondet_bool(); p5_l0 = __VERIFIER_nondet_bool(); p6_l1 = __VERIFIER_nondet_bool(); p13_l1 = __VERIFIER_nondet_bool(); p7_l0 = __VERIFIER_nondet_bool(); p14_l1 = __VERIFIER_nondet_bool(); p8_l0 = __VERIFIER_nondet_bool(); int __ok = (((id == 0) && (((((( !(p17_l0 != 0)) && ( !(p17_l1 != 0))) && (p17_x == 0.0)) && (((( !(p17_l0 != 0)) && ( !(p17_l1 != 0))) || ((p17_l0 != 0) && ( !(p17_l1 != 0)))) || (((p17_l1 != 0) && ( !(p17_l0 != 0))) || ((p17_l0 != 0) && (p17_l1 != 0))))) && ((p17_x <= 2.0) || ( !((p17_l1 != 0) && ( !(p17_l0 != 0)))))) && (((((( !(p16_l0 != 0)) && ( !(p16_l1 != 0))) && (p16_x == 0.0)) && (((( !(p16_l0 != 0)) && ( !(p16_l1 != 0))) || ((p16_l0 != 0) && ( !(p16_l1 != 0)))) || (((p16_l1 != 0) && ( !(p16_l0 != 0))) || ((p16_l0 != 0) && (p16_l1 != 0))))) && ((p16_x <= 2.0) || ( !((p16_l1 != 0) && ( !(p16_l0 != 0)))))) && (((((( !(p15_l0 != 0)) && ( !(p15_l1 != 0))) && (p15_x == 0.0)) && (((( !(p15_l0 != 0)) && ( !(p15_l1 != 0))) || ((p15_l0 != 0) && ( !(p15_l1 != 0)))) || (((p15_l1 != 0) && ( !(p15_l0 != 0))) || ((p15_l0 != 0) && (p15_l1 != 0))))) && ((p15_x <= 2.0) || ( !((p15_l1 != 0) && ( !(p15_l0 != 0)))))) && (((((( !(p14_l0 != 0)) && ( !(p14_l1 != 0))) && (p14_x == 0.0)) && (((( !(p14_l0 != 0)) && ( !(p14_l1 != 0))) || ((p14_l0 != 0) && ( !(p14_l1 != 0)))) || (((p14_l1 != 0) && ( !(p14_l0 != 0))) || ((p14_l0 != 0) && (p14_l1 != 0))))) && ((p14_x <= 2.0) || ( !((p14_l1 != 0) && ( !(p14_l0 != 0)))))) && (((((( !(p13_l0 != 0)) && ( !(p13_l1 != 0))) && (p13_x == 0.0)) && (((( !(p13_l0 != 0)) && ( !(p13_l1 != 0))) || ((p13_l0 != 0) && ( !(p13_l1 != 0)))) || (((p13_l1 != 0) && ( !(p13_l0 != 0))) || ((p13_l0 != 0) && (p13_l1 != 0))))) && ((p13_x <= 2.0) || ( !((p13_l1 != 0) && ( !(p13_l0 != 0)))))) && (((((( !(p12_l0 != 0)) && ( !(p12_l1 != 0))) && (p12_x == 0.0)) && (((( !(p12_l0 != 0)) && ( !(p12_l1 != 0))) || ((p12_l0 != 0) && ( !(p12_l1 != 0)))) || (((p12_l1 != 0) && ( !(p12_l0 != 0))) || ((p12_l0 != 0) && (p12_l1 != 0))))) && ((p12_x <= 2.0) || ( !((p12_l1 != 0) && ( !(p12_l0 != 0)))))) && (((((( !(p11_l0 != 0)) && ( !(p11_l1 != 0))) && (p11_x == 0.0)) && (((( !(p11_l0 != 0)) && ( !(p11_l1 != 0))) || ((p11_l0 != 0) && ( !(p11_l1 != 0)))) || (((p11_l1 != 0) && ( !(p11_l0 != 0))) || ((p11_l0 != 0) && (p11_l1 != 0))))) && ((p11_x <= 2.0) || ( !((p11_l1 != 0) && ( !(p11_l0 != 0)))))) && (((((( !(p10_l0 != 0)) && ( !(p10_l1 != 0))) && (p10_x == 0.0)) && (((( !(p10_l0 != 0)) && ( !(p10_l1 != 0))) || ((p10_l0 != 0) && ( !(p10_l1 != 0)))) || (((p10_l1 != 0) && ( !(p10_l0 != 0))) || ((p10_l0 != 0) && (p10_l1 != 0))))) && ((p10_x <= 2.0) || ( !((p10_l1 != 0) && ( !(p10_l0 != 0)))))) && (((((( !(p9_l0 != 0)) && ( !(p9_l1 != 0))) && (p9_x == 0.0)) && (((( !(p9_l0 != 0)) && ( !(p9_l1 != 0))) || ((p9_l0 != 0) && ( !(p9_l1 != 0)))) || (((p9_l1 != 0) && ( !(p9_l0 != 0))) || ((p9_l0 != 0) && (p9_l1 != 0))))) && ((p9_x <= 2.0) || ( !((p9_l1 != 0) && ( !(p9_l0 != 0)))))) && (((((( !(p8_l0 != 0)) && ( !(p8_l1 != 0))) && (p8_x == 0.0)) && (((( !(p8_l0 != 0)) && ( !(p8_l1 != 0))) || ((p8_l0 != 0) && ( !(p8_l1 != 0)))) || (((p8_l1 != 0) && ( !(p8_l0 != 0))) || ((p8_l0 != 0) && (p8_l1 != 0))))) && ((p8_x <= 2.0) || ( !((p8_l1 != 0) && ( !(p8_l0 != 0)))))) && (((((( !(p7_l0 != 0)) && ( !(p7_l1 != 0))) && (p7_x == 0.0)) && (((( !(p7_l0 != 0)) && ( !(p7_l1 != 0))) || ((p7_l0 != 0) && ( !(p7_l1 != 0)))) || (((p7_l1 != 0) && ( !(p7_l0 != 0))) || ((p7_l0 != 0) && (p7_l1 != 0))))) && ((p7_x <= 2.0) || ( !((p7_l1 != 0) && ( !(p7_l0 != 0)))))) && (((((( !(p6_l0 != 0)) && ( !(p6_l1 != 0))) && (p6_x == 0.0)) && (((( !(p6_l0 != 0)) && ( !(p6_l1 != 0))) || ((p6_l0 != 0) && ( !(p6_l1 != 0)))) || (((p6_l1 != 0) && ( !(p6_l0 != 0))) || ((p6_l0 != 0) && (p6_l1 != 0))))) && ((p6_x <= 2.0) || ( !((p6_l1 != 0) && ( !(p6_l0 != 0)))))) && (((((( !(p5_l0 != 0)) && ( !(p5_l1 != 0))) && (p5_x == 0.0)) && (((( !(p5_l0 != 0)) && ( !(p5_l1 != 0))) || ((p5_l0 != 0) && ( !(p5_l1 != 0)))) || (((p5_l1 != 0) && ( !(p5_l0 != 0))) || ((p5_l0 != 0) && (p5_l1 != 0))))) && ((p5_x <= 2.0) || ( !((p5_l1 != 0) && ( !(p5_l0 != 0)))))) && (((((( !(p4_l0 != 0)) && ( !(p4_l1 != 0))) && (p4_x == 0.0)) && (((( !(p4_l0 != 0)) && ( !(p4_l1 != 0))) || ((p4_l0 != 0) && ( !(p4_l1 != 0)))) || (((p4_l1 != 0) && ( !(p4_l0 != 0))) || ((p4_l0 != 0) && (p4_l1 != 0))))) && ((p4_x <= 2.0) || ( !((p4_l1 != 0) && ( !(p4_l0 != 0)))))) && (((((( !(p3_l0 != 0)) && ( !(p3_l1 != 0))) && (p3_x == 0.0)) && (((( !(p3_l0 != 0)) && ( !(p3_l1 != 0))) || ((p3_l0 != 0) && ( !(p3_l1 != 0)))) || (((p3_l1 != 0) && ( !(p3_l0 != 0))) || ((p3_l0 != 0) && (p3_l1 != 0))))) && ((p3_x <= 2.0) || ( !((p3_l1 != 0) && ( !(p3_l0 != 0)))))) && (((((( !(p2_l0 != 0)) && ( !(p2_l1 != 0))) && (p2_x == 0.0)) && (((( !(p2_l0 != 0)) && ( !(p2_l1 != 0))) || ((p2_l0 != 0) && ( !(p2_l1 != 0)))) || (((p2_l1 != 0) && ( !(p2_l0 != 0))) || ((p2_l0 != 0) && (p2_l1 != 0))))) && ((p2_x <= 2.0) || ( !((p2_l1 != 0) && ( !(p2_l0 != 0)))))) && (((((( !(p1_l0 != 0)) && ( !(p1_l1 != 0))) && (p1_x == 0.0)) && (((( !(p1_l0 != 0)) && ( !(p1_l1 != 0))) || ((p1_l0 != 0) && ( !(p1_l1 != 0)))) || (((p1_l1 != 0) && ( !(p1_l0 != 0))) || ((p1_l0 != 0) && (p1_l1 != 0))))) && ((p1_x <= 2.0) || ( !((p1_l1 != 0) && ( !(p1_l0 != 0)))))) && (((((( !(p0_l0 != 0)) && ( !(p0_l1 != 0))) && (p0_x == 0.0)) && (((( !(p0_l0 != 0)) && ( !(p0_l1 != 0))) || ((p0_l0 != 0) && ( !(p0_l1 != 0)))) || (((p0_l1 != 0) && ( !(p0_l0 != 0))) || ((p0_l0 != 0) && (p0_l1 != 0))))) && ((p0_x <= 2.0) || ( !((p0_l1 != 0) && ( !(p0_l0 != 0)))))) && (((0.0 <= delta) && ((id == 18) || ((id == 17) || ((id == 16) || ((id == 15) || ((id == 14) || ((id == 13) || ((id == 12) || ((id == 11) || ((id == 10) || ((id == 9) || ((id == 8) || ((id == 7) || ((id == 6) || ((id == 5) || ((id == 4) || ((id == 3) || ((id == 2) || ((id == 0) || (id == 1)))))))))))))))))))) && ((turn == 18) || ((turn == 17) || ((turn == 16) || ((turn == 15) || ((turn == 14) || ((turn == 13) || ((turn == 12) || ((turn == 11) || ((turn == 10) || ((turn == 9) || ((turn == 8) || ((turn == 7) || ((turn == 6) || ((turn == 5) || ((turn == 4) || ((turn == 3) || ((turn == 1) || (turn == 2)))))))))))))))))))))))))))))))))))))) && (delta == _diverge_delta)); while (__ok) { _x_p17_x = __VERIFIER_nondet_float(); _x_p16_x = __VERIFIER_nondet_float(); _x_p15_x = __VERIFIER_nondet_float(); _x_p14_x = __VERIFIER_nondet_float(); _x_p12_l0 = __VERIFIER_nondet_bool(); _x_p12_x = __VERIFIER_nondet_float(); _x__diverge_delta = __VERIFIER_nondet_float(); _x_p17_l1 = __VERIFIER_nondet_bool(); _x_p11_l0 = __VERIFIER_nondet_bool(); _x_p11_x = __VERIFIER_nondet_float(); _x_p16_l1 = __VERIFIER_nondet_bool(); _x_p10_l0 = __VERIFIER_nondet_bool(); _x_p10_x = __VERIFIER_nondet_float(); _x_p9_x = __VERIFIER_nondet_float(); _x_p2_l1 = __VERIFIER_nondet_bool(); _x_p17_l0 = __VERIFIER_nondet_bool(); _x_p6_x = __VERIFIER_nondet_float(); _x_p8_l1 = __VERIFIER_nondet_bool(); _x_p2_l0 = __VERIFIER_nondet_bool(); _x_p13_l0 = __VERIFIER_nondet_bool(); _x_p2_x = __VERIFIER_nondet_float(); _x_p1_l1 = __VERIFIER_nondet_bool(); _x_delta = __VERIFIER_nondet_float(); _x_p13_x = __VERIFIER_nondet_float(); _x_p0_l0 = __VERIFIER_nondet_bool(); _x_p7_l1 = __VERIFIER_nondet_bool(); _x_p0_x = __VERIFIER_nondet_float(); _x_p12_l1 = __VERIFIER_nondet_bool(); _x_p6_l0 = __VERIFIER_nondet_bool(); _x_turn = __VERIFIER_nondet_int(); _x_id = __VERIFIER_nondet_int(); _x_p14_l0 = __VERIFIER_nondet_bool(); _x_p3_x = __VERIFIER_nondet_float(); _x_p15_l1 = __VERIFIER_nondet_bool(); _x_p9_l0 = __VERIFIER_nondet_bool(); _x_p1_x = __VERIFIER_nondet_float(); _x_p5_l1 = __VERIFIER_nondet_bool(); _x_p9_l1 = __VERIFIER_nondet_bool(); _x_p3_l0 = __VERIFIER_nondet_bool(); _x_p3_l1 = __VERIFIER_nondet_bool(); _x_p0_l1 = __VERIFIER_nondet_bool(); _x_p7_x = __VERIFIER_nondet_float(); _x_p15_l0 = __VERIFIER_nondet_bool(); _x_p4_x = __VERIFIER_nondet_float(); _x_p10_l1 = __VERIFIER_nondet_bool(); _x_p4_l0 = __VERIFIER_nondet_bool(); _x_p1_l0 = __VERIFIER_nondet_bool(); _x_p4_l1 = __VERIFIER_nondet_bool(); _x_p8_x = __VERIFIER_nondet_float(); _x_p16_l0 = __VERIFIER_nondet_bool(); _x_p5_x = __VERIFIER_nondet_float(); _x_p11_l1 = __VERIFIER_nondet_bool(); _x_p5_l0 = __VERIFIER_nondet_bool(); _x_p6_l1 = __VERIFIER_nondet_bool(); _x_p13_l1 = __VERIFIER_nondet_bool(); _x_p7_l0 = __VERIFIER_nondet_bool(); _x_p14_l1 = __VERIFIER_nondet_bool(); _x_p8_l0 = __VERIFIER_nondet_bool(); __ok = (((((((((((((( !(_x_p17_l0 != 0)) && ( !(_x_p17_l1 != 0))) || ((_x_p17_l0 != 0) && ( !(_x_p17_l1 != 0)))) || (((_x_p17_l1 != 0) && ( !(_x_p17_l0 != 0))) || ((_x_p17_l0 != 0) && (_x_p17_l1 != 0)))) && ((_x_p17_x <= 2.0) || ( !((_x_p17_l1 != 0) && ( !(_x_p17_l0 != 0)))))) && (((((p17_l0 != 0) == (_x_p17_l0 != 0)) && ((p17_l1 != 0) == (_x_p17_l1 != 0))) && ((delta + (p17_x + (-1.0 * _x_p17_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 18)))))) && ((((id == 0) && ((_x_p17_l1 != 0) && ( !(_x_p17_l0 != 0)))) && ((id == _x_id) && (_x_p17_x == 0.0))) || ( !((( !(p17_l0 != 0)) && ( !(p17_l1 != 0))) && ((delta == 0.0) && (turn == 18)))))) && (((((_x_p17_l0 != 0) && ( !(_x_p17_l1 != 0))) && (p17_x <= 2.0)) && ((_x_p17_x == 0.0) && (_x_id == 18))) || ( !(((p17_l1 != 0) && ( !(p17_l0 != 0))) && ((delta == 0.0) && (turn == 18)))))) && (((( !(_x_p17_l0 != 0)) && ( !(_x_p17_l1 != 0))) || ((_x_p17_l0 != 0) && (_x_p17_l1 != 0))) || ( !(((p17_l0 != 0) && ( !(p17_l1 != 0))) && ((delta == 0.0) && (turn == 18)))))) && ((((id == _x_id) && (_x_p17_x == 0.0)) && (( !(p17_x <= 2.0)) && ( !(id == 18)))) || ( !(((delta == 0.0) && (turn == 18)) && ((( !(_x_p17_l0 != 0)) && ( !(_x_p17_l1 != 0))) && ((p17_l0 != 0) && ( !(p17_l1 != 0)))))))) && ((((id == _x_id) && (p17_x == _x_p17_x)) && (( !(p17_x <= 2.0)) && (id == 18))) || ( !(((delta == 0.0) && (turn == 18)) && (((p17_l0 != 0) && ( !(p17_l1 != 0))) && ((_x_p17_l0 != 0) && (_x_p17_l1 != 0))))))) && (((( !(_x_p17_l0 != 0)) && ( !(_x_p17_l1 != 0))) && ((_x_id == 0) && (p17_x == _x_p17_x))) || ( !(((p17_l0 != 0) && (p17_l1 != 0)) && ((delta == 0.0) && (turn == 18)))))) && ((((((((((((( !(_x_p16_l0 != 0)) && ( !(_x_p16_l1 != 0))) || ((_x_p16_l0 != 0) && ( !(_x_p16_l1 != 0)))) || (((_x_p16_l1 != 0) && ( !(_x_p16_l0 != 0))) || ((_x_p16_l0 != 0) && (_x_p16_l1 != 0)))) && ((_x_p16_x <= 2.0) || ( !((_x_p16_l1 != 0) && ( !(_x_p16_l0 != 0)))))) && (((((p16_l0 != 0) == (_x_p16_l0 != 0)) && ((p16_l1 != 0) == (_x_p16_l1 != 0))) && ((delta + (p16_x + (-1.0 * _x_p16_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 17)))))) && ((((id == 0) && ((_x_p16_l1 != 0) && ( !(_x_p16_l0 != 0)))) && ((id == _x_id) && (_x_p16_x == 0.0))) || ( !((( !(p16_l0 != 0)) && ( !(p16_l1 != 0))) && ((delta == 0.0) && (turn == 17)))))) && (((((_x_p16_l0 != 0) && ( !(_x_p16_l1 != 0))) && (p16_x <= 2.0)) && ((_x_p16_x == 0.0) && (_x_id == 17))) || ( !(((p16_l1 != 0) && ( !(p16_l0 != 0))) && ((delta == 0.0) && (turn == 17)))))) && (((( !(_x_p16_l0 != 0)) && ( !(_x_p16_l1 != 0))) || ((_x_p16_l0 != 0) && (_x_p16_l1 != 0))) || ( !(((p16_l0 != 0) && ( !(p16_l1 != 0))) && ((delta == 0.0) && (turn == 17)))))) && ((((id == _x_id) && (_x_p16_x == 0.0)) && (( !(p16_x <= 2.0)) && ( !(id == 17)))) || ( !(((delta == 0.0) && (turn == 17)) && ((( !(_x_p16_l0 != 0)) && ( !(_x_p16_l1 != 0))) && ((p16_l0 != 0) && ( !(p16_l1 != 0)))))))) && ((((id == _x_id) && (p16_x == _x_p16_x)) && (( !(p16_x <= 2.0)) && (id == 17))) || ( !(((delta == 0.0) && (turn == 17)) && (((p16_l0 != 0) && ( !(p16_l1 != 0))) && ((_x_p16_l0 != 0) && (_x_p16_l1 != 0))))))) && (((( !(_x_p16_l0 != 0)) && ( !(_x_p16_l1 != 0))) && ((_x_id == 0) && (p16_x == _x_p16_x))) || ( !(((p16_l0 != 0) && (p16_l1 != 0)) && ((delta == 0.0) && (turn == 17)))))) && ((((((((((((( !(_x_p15_l0 != 0)) && ( !(_x_p15_l1 != 0))) || ((_x_p15_l0 != 0) && ( !(_x_p15_l1 != 0)))) || (((_x_p15_l1 != 0) && ( !(_x_p15_l0 != 0))) || ((_x_p15_l0 != 0) && (_x_p15_l1 != 0)))) && ((_x_p15_x <= 2.0) || ( !((_x_p15_l1 != 0) && ( !(_x_p15_l0 != 0)))))) && (((((p15_l0 != 0) == (_x_p15_l0 != 0)) && ((p15_l1 != 0) == (_x_p15_l1 != 0))) && ((delta + (p15_x + (-1.0 * _x_p15_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 16)))))) && ((((id == 0) && ((_x_p15_l1 != 0) && ( !(_x_p15_l0 != 0)))) && ((id == _x_id) && (_x_p15_x == 0.0))) || ( !((( !(p15_l0 != 0)) && ( !(p15_l1 != 0))) && ((delta == 0.0) && (turn == 16)))))) && (((((_x_p15_l0 != 0) && ( !(_x_p15_l1 != 0))) && (p15_x <= 2.0)) && ((_x_p15_x == 0.0) && (_x_id == 16))) || ( !(((p15_l1 != 0) && ( !(p15_l0 != 0))) && ((delta == 0.0) && (turn == 16)))))) && (((( !(_x_p15_l0 != 0)) && ( !(_x_p15_l1 != 0))) || ((_x_p15_l0 != 0) && (_x_p15_l1 != 0))) || ( !(((p15_l0 != 0) && ( !(p15_l1 != 0))) && ((delta == 0.0) && (turn == 16)))))) && ((((id == _x_id) && (_x_p15_x == 0.0)) && (( !(p15_x <= 2.0)) && ( !(id == 16)))) || ( !(((delta == 0.0) && (turn == 16)) && ((( !(_x_p15_l0 != 0)) && ( !(_x_p15_l1 != 0))) && ((p15_l0 != 0) && ( !(p15_l1 != 0)))))))) && ((((id == _x_id) && (p15_x == _x_p15_x)) && (( !(p15_x <= 2.0)) && (id == 16))) || ( !(((delta == 0.0) && (turn == 16)) && (((p15_l0 != 0) && ( !(p15_l1 != 0))) && ((_x_p15_l0 != 0) && (_x_p15_l1 != 0))))))) && (((( !(_x_p15_l0 != 0)) && ( !(_x_p15_l1 != 0))) && ((_x_id == 0) && (p15_x == _x_p15_x))) || ( !(((p15_l0 != 0) && (p15_l1 != 0)) && ((delta == 0.0) && (turn == 16)))))) && ((((((((((((( !(_x_p14_l0 != 0)) && ( !(_x_p14_l1 != 0))) || ((_x_p14_l0 != 0) && ( !(_x_p14_l1 != 0)))) || (((_x_p14_l1 != 0) && ( !(_x_p14_l0 != 0))) || ((_x_p14_l0 != 0) && (_x_p14_l1 != 0)))) && ((_x_p14_x <= 2.0) || ( !((_x_p14_l1 != 0) && ( !(_x_p14_l0 != 0)))))) && (((((p14_l0 != 0) == (_x_p14_l0 != 0)) && ((p14_l1 != 0) == (_x_p14_l1 != 0))) && ((delta + (p14_x + (-1.0 * _x_p14_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 15)))))) && ((((id == 0) && ((_x_p14_l1 != 0) && ( !(_x_p14_l0 != 0)))) && ((id == _x_id) && (_x_p14_x == 0.0))) || ( !((( !(p14_l0 != 0)) && ( !(p14_l1 != 0))) && ((delta == 0.0) && (turn == 15)))))) && (((((_x_p14_l0 != 0) && ( !(_x_p14_l1 != 0))) && (p14_x <= 2.0)) && ((_x_p14_x == 0.0) && (_x_id == 15))) || ( !(((p14_l1 != 0) && ( !(p14_l0 != 0))) && ((delta == 0.0) && (turn == 15)))))) && (((( !(_x_p14_l0 != 0)) && ( !(_x_p14_l1 != 0))) || ((_x_p14_l0 != 0) && (_x_p14_l1 != 0))) || ( !(((p14_l0 != 0) && ( !(p14_l1 != 0))) && ((delta == 0.0) && (turn == 15)))))) && ((((id == _x_id) && (_x_p14_x == 0.0)) && (( !(p14_x <= 2.0)) && ( !(id == 15)))) || ( !(((delta == 0.0) && (turn == 15)) && ((( !(_x_p14_l0 != 0)) && ( !(_x_p14_l1 != 0))) && ((p14_l0 != 0) && ( !(p14_l1 != 0)))))))) && ((((id == _x_id) && (p14_x == _x_p14_x)) && (( !(p14_x <= 2.0)) && (id == 15))) || ( !(((delta == 0.0) && (turn == 15)) && (((p14_l0 != 0) && ( !(p14_l1 != 0))) && ((_x_p14_l0 != 0) && (_x_p14_l1 != 0))))))) && (((( !(_x_p14_l0 != 0)) && ( !(_x_p14_l1 != 0))) && ((_x_id == 0) && (p14_x == _x_p14_x))) || ( !(((p14_l0 != 0) && (p14_l1 != 0)) && ((delta == 0.0) && (turn == 15)))))) && ((((((((((((( !(_x_p13_l0 != 0)) && ( !(_x_p13_l1 != 0))) || ((_x_p13_l0 != 0) && ( !(_x_p13_l1 != 0)))) || (((_x_p13_l1 != 0) && ( !(_x_p13_l0 != 0))) || ((_x_p13_l0 != 0) && (_x_p13_l1 != 0)))) && ((_x_p13_x <= 2.0) || ( !((_x_p13_l1 != 0) && ( !(_x_p13_l0 != 0)))))) && (((((p13_l0 != 0) == (_x_p13_l0 != 0)) && ((p13_l1 != 0) == (_x_p13_l1 != 0))) && ((delta + (p13_x + (-1.0 * _x_p13_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 14)))))) && ((((id == 0) && ((_x_p13_l1 != 0) && ( !(_x_p13_l0 != 0)))) && ((id == _x_id) && (_x_p13_x == 0.0))) || ( !((( !(p13_l0 != 0)) && ( !(p13_l1 != 0))) && ((delta == 0.0) && (turn == 14)))))) && (((((_x_p13_l0 != 0) && ( !(_x_p13_l1 != 0))) && (p13_x <= 2.0)) && ((_x_p13_x == 0.0) && (_x_id == 14))) || ( !(((p13_l1 != 0) && ( !(p13_l0 != 0))) && ((delta == 0.0) && (turn == 14)))))) && (((( !(_x_p13_l0 != 0)) && ( !(_x_p13_l1 != 0))) || ((_x_p13_l0 != 0) && (_x_p13_l1 != 0))) || ( !(((p13_l0 != 0) && ( !(p13_l1 != 0))) && ((delta == 0.0) && (turn == 14)))))) && ((((id == _x_id) && (_x_p13_x == 0.0)) && (( !(p13_x <= 2.0)) && ( !(id == 14)))) || ( !(((delta == 0.0) && (turn == 14)) && ((( !(_x_p13_l0 != 0)) && ( !(_x_p13_l1 != 0))) && ((p13_l0 != 0) && ( !(p13_l1 != 0)))))))) && ((((id == _x_id) && (p13_x == _x_p13_x)) && (( !(p13_x <= 2.0)) && (id == 14))) || ( !(((delta == 0.0) && (turn == 14)) && (((p13_l0 != 0) && ( !(p13_l1 != 0))) && ((_x_p13_l0 != 0) && (_x_p13_l1 != 0))))))) && (((( !(_x_p13_l0 != 0)) && ( !(_x_p13_l1 != 0))) && ((_x_id == 0) && (p13_x == _x_p13_x))) || ( !(((p13_l0 != 0) && (p13_l1 != 0)) && ((delta == 0.0) && (turn == 14)))))) && ((((((((((((( !(_x_p12_l0 != 0)) && ( !(_x_p12_l1 != 0))) || ((_x_p12_l0 != 0) && ( !(_x_p12_l1 != 0)))) || (((_x_p12_l1 != 0) && ( !(_x_p12_l0 != 0))) || ((_x_p12_l0 != 0) && (_x_p12_l1 != 0)))) && ((_x_p12_x <= 2.0) || ( !((_x_p12_l1 != 0) && ( !(_x_p12_l0 != 0)))))) && (((((p12_l0 != 0) == (_x_p12_l0 != 0)) && ((p12_l1 != 0) == (_x_p12_l1 != 0))) && ((delta + (p12_x + (-1.0 * _x_p12_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 13)))))) && ((((id == 0) && ((_x_p12_l1 != 0) && ( !(_x_p12_l0 != 0)))) && ((id == _x_id) && (_x_p12_x == 0.0))) || ( !((( !(p12_l0 != 0)) && ( !(p12_l1 != 0))) && ((delta == 0.0) && (turn == 13)))))) && (((((_x_p12_l0 != 0) && ( !(_x_p12_l1 != 0))) && (p12_x <= 2.0)) && ((_x_p12_x == 0.0) && (_x_id == 13))) || ( !(((p12_l1 != 0) && ( !(p12_l0 != 0))) && ((delta == 0.0) && (turn == 13)))))) && (((( !(_x_p12_l0 != 0)) && ( !(_x_p12_l1 != 0))) || ((_x_p12_l0 != 0) && (_x_p12_l1 != 0))) || ( !(((p12_l0 != 0) && ( !(p12_l1 != 0))) && ((delta == 0.0) && (turn == 13)))))) && ((((id == _x_id) && (_x_p12_x == 0.0)) && (( !(p12_x <= 2.0)) && ( !(id == 13)))) || ( !(((delta == 0.0) && (turn == 13)) && ((( !(_x_p12_l0 != 0)) && ( !(_x_p12_l1 != 0))) && ((p12_l0 != 0) && ( !(p12_l1 != 0)))))))) && ((((id == _x_id) && (p12_x == _x_p12_x)) && (( !(p12_x <= 2.0)) && (id == 13))) || ( !(((delta == 0.0) && (turn == 13)) && (((p12_l0 != 0) && ( !(p12_l1 != 0))) && ((_x_p12_l0 != 0) && (_x_p12_l1 != 0))))))) && (((( !(_x_p12_l0 != 0)) && ( !(_x_p12_l1 != 0))) && ((_x_id == 0) && (p12_x == _x_p12_x))) || ( !(((p12_l0 != 0) && (p12_l1 != 0)) && ((delta == 0.0) && (turn == 13)))))) && ((((((((((((( !(_x_p11_l0 != 0)) && ( !(_x_p11_l1 != 0))) || ((_x_p11_l0 != 0) && ( !(_x_p11_l1 != 0)))) || (((_x_p11_l1 != 0) && ( !(_x_p11_l0 != 0))) || ((_x_p11_l0 != 0) && (_x_p11_l1 != 0)))) && ((_x_p11_x <= 2.0) || ( !((_x_p11_l1 != 0) && ( !(_x_p11_l0 != 0)))))) && (((((p11_l0 != 0) == (_x_p11_l0 != 0)) && ((p11_l1 != 0) == (_x_p11_l1 != 0))) && ((delta + (p11_x + (-1.0 * _x_p11_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 12)))))) && ((((id == 0) && ((_x_p11_l1 != 0) && ( !(_x_p11_l0 != 0)))) && ((id == _x_id) && (_x_p11_x == 0.0))) || ( !((( !(p11_l0 != 0)) && ( !(p11_l1 != 0))) && ((delta == 0.0) && (turn == 12)))))) && (((((_x_p11_l0 != 0) && ( !(_x_p11_l1 != 0))) && (p11_x <= 2.0)) && ((_x_p11_x == 0.0) && (_x_id == 12))) || ( !(((p11_l1 != 0) && ( !(p11_l0 != 0))) && ((delta == 0.0) && (turn == 12)))))) && (((( !(_x_p11_l0 != 0)) && ( !(_x_p11_l1 != 0))) || ((_x_p11_l0 != 0) && (_x_p11_l1 != 0))) || ( !(((p11_l0 != 0) && ( !(p11_l1 != 0))) && ((delta == 0.0) && (turn == 12)))))) && ((((id == _x_id) && (_x_p11_x == 0.0)) && (( !(p11_x <= 2.0)) && ( !(id == 12)))) || ( !(((delta == 0.0) && (turn == 12)) && ((( !(_x_p11_l0 != 0)) && ( !(_x_p11_l1 != 0))) && ((p11_l0 != 0) && ( !(p11_l1 != 0)))))))) && ((((id == _x_id) && (p11_x == _x_p11_x)) && (( !(p11_x <= 2.0)) && (id == 12))) || ( !(((delta == 0.0) && (turn == 12)) && (((p11_l0 != 0) && ( !(p11_l1 != 0))) && ((_x_p11_l0 != 0) && (_x_p11_l1 != 0))))))) && (((( !(_x_p11_l0 != 0)) && ( !(_x_p11_l1 != 0))) && ((_x_id == 0) && (p11_x == _x_p11_x))) || ( !(((p11_l0 != 0) && (p11_l1 != 0)) && ((delta == 0.0) && (turn == 12)))))) && ((((((((((((( !(_x_p10_l0 != 0)) && ( !(_x_p10_l1 != 0))) || ((_x_p10_l0 != 0) && ( !(_x_p10_l1 != 0)))) || (((_x_p10_l1 != 0) && ( !(_x_p10_l0 != 0))) || ((_x_p10_l0 != 0) && (_x_p10_l1 != 0)))) && ((_x_p10_x <= 2.0) || ( !((_x_p10_l1 != 0) && ( !(_x_p10_l0 != 0)))))) && (((((p10_l0 != 0) == (_x_p10_l0 != 0)) && ((p10_l1 != 0) == (_x_p10_l1 != 0))) && ((delta + (p10_x + (-1.0 * _x_p10_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 11)))))) && ((((id == 0) && ((_x_p10_l1 != 0) && ( !(_x_p10_l0 != 0)))) && ((id == _x_id) && (_x_p10_x == 0.0))) || ( !((( !(p10_l0 != 0)) && ( !(p10_l1 != 0))) && ((delta == 0.0) && (turn == 11)))))) && (((((_x_p10_l0 != 0) && ( !(_x_p10_l1 != 0))) && (p10_x <= 2.0)) && ((_x_p10_x == 0.0) && (_x_id == 11))) || ( !(((p10_l1 != 0) && ( !(p10_l0 != 0))) && ((delta == 0.0) && (turn == 11)))))) && (((( !(_x_p10_l0 != 0)) && ( !(_x_p10_l1 != 0))) || ((_x_p10_l0 != 0) && (_x_p10_l1 != 0))) || ( !(((p10_l0 != 0) && ( !(p10_l1 != 0))) && ((delta == 0.0) && (turn == 11)))))) && ((((id == _x_id) && (_x_p10_x == 0.0)) && (( !(p10_x <= 2.0)) && ( !(id == 11)))) || ( !(((delta == 0.0) && (turn == 11)) && ((( !(_x_p10_l0 != 0)) && ( !(_x_p10_l1 != 0))) && ((p10_l0 != 0) && ( !(p10_l1 != 0)))))))) && ((((id == _x_id) && (p10_x == _x_p10_x)) && (( !(p10_x <= 2.0)) && (id == 11))) || ( !(((delta == 0.0) && (turn == 11)) && (((p10_l0 != 0) && ( !(p10_l1 != 0))) && ((_x_p10_l0 != 0) && (_x_p10_l1 != 0))))))) && (((( !(_x_p10_l0 != 0)) && ( !(_x_p10_l1 != 0))) && ((_x_id == 0) && (p10_x == _x_p10_x))) || ( !(((p10_l0 != 0) && (p10_l1 != 0)) && ((delta == 0.0) && (turn == 11)))))) && ((((((((((((( !(_x_p9_l0 != 0)) && ( !(_x_p9_l1 != 0))) || ((_x_p9_l0 != 0) && ( !(_x_p9_l1 != 0)))) || (((_x_p9_l1 != 0) && ( !(_x_p9_l0 != 0))) || ((_x_p9_l0 != 0) && (_x_p9_l1 != 0)))) && ((_x_p9_x <= 2.0) || ( !((_x_p9_l1 != 0) && ( !(_x_p9_l0 != 0)))))) && (((((p9_l0 != 0) == (_x_p9_l0 != 0)) && ((p9_l1 != 0) == (_x_p9_l1 != 0))) && ((delta + (p9_x + (-1.0 * _x_p9_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 10)))))) && ((((id == 0) && ((_x_p9_l1 != 0) && ( !(_x_p9_l0 != 0)))) && ((id == _x_id) && (_x_p9_x == 0.0))) || ( !((( !(p9_l0 != 0)) && ( !(p9_l1 != 0))) && ((delta == 0.0) && (turn == 10)))))) && (((((_x_p9_l0 != 0) && ( !(_x_p9_l1 != 0))) && (p9_x <= 2.0)) && ((_x_p9_x == 0.0) && (_x_id == 10))) || ( !(((p9_l1 != 0) && ( !(p9_l0 != 0))) && ((delta == 0.0) && (turn == 10)))))) && (((( !(_x_p9_l0 != 0)) && ( !(_x_p9_l1 != 0))) || ((_x_p9_l0 != 0) && (_x_p9_l1 != 0))) || ( !(((p9_l0 != 0) && ( !(p9_l1 != 0))) && ((delta == 0.0) && (turn == 10)))))) && ((((id == _x_id) && (_x_p9_x == 0.0)) && (( !(p9_x <= 2.0)) && ( !(id == 10)))) || ( !(((delta == 0.0) && (turn == 10)) && ((( !(_x_p9_l0 != 0)) && ( !(_x_p9_l1 != 0))) && ((p9_l0 != 0) && ( !(p9_l1 != 0)))))))) && ((((id == _x_id) && (p9_x == _x_p9_x)) && (( !(p9_x <= 2.0)) && (id == 10))) || ( !(((delta == 0.0) && (turn == 10)) && (((p9_l0 != 0) && ( !(p9_l1 != 0))) && ((_x_p9_l0 != 0) && (_x_p9_l1 != 0))))))) && (((( !(_x_p9_l0 != 0)) && ( !(_x_p9_l1 != 0))) && ((_x_id == 0) && (p9_x == _x_p9_x))) || ( !(((p9_l0 != 0) && (p9_l1 != 0)) && ((delta == 0.0) && (turn == 10)))))) && ((((((((((((( !(_x_p8_l0 != 0)) && ( !(_x_p8_l1 != 0))) || ((_x_p8_l0 != 0) && ( !(_x_p8_l1 != 0)))) || (((_x_p8_l1 != 0) && ( !(_x_p8_l0 != 0))) || ((_x_p8_l0 != 0) && (_x_p8_l1 != 0)))) && ((_x_p8_x <= 2.0) || ( !((_x_p8_l1 != 0) && ( !(_x_p8_l0 != 0)))))) && (((((p8_l0 != 0) == (_x_p8_l0 != 0)) && ((p8_l1 != 0) == (_x_p8_l1 != 0))) && ((delta + (p8_x + (-1.0 * _x_p8_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 9)))))) && ((((id == 0) && ((_x_p8_l1 != 0) && ( !(_x_p8_l0 != 0)))) && ((id == _x_id) && (_x_p8_x == 0.0))) || ( !((( !(p8_l0 != 0)) && ( !(p8_l1 != 0))) && ((delta == 0.0) && (turn == 9)))))) && (((((_x_p8_l0 != 0) && ( !(_x_p8_l1 != 0))) && (p8_x <= 2.0)) && ((_x_p8_x == 0.0) && (_x_id == 9))) || ( !(((p8_l1 != 0) && ( !(p8_l0 != 0))) && ((delta == 0.0) && (turn == 9)))))) && (((( !(_x_p8_l0 != 0)) && ( !(_x_p8_l1 != 0))) || ((_x_p8_l0 != 0) && (_x_p8_l1 != 0))) || ( !(((p8_l0 != 0) && ( !(p8_l1 != 0))) && ((delta == 0.0) && (turn == 9)))))) && ((((id == _x_id) && (_x_p8_x == 0.0)) && (( !(p8_x <= 2.0)) && ( !(id == 9)))) || ( !(((delta == 0.0) && (turn == 9)) && ((( !(_x_p8_l0 != 0)) && ( !(_x_p8_l1 != 0))) && ((p8_l0 != 0) && ( !(p8_l1 != 0)))))))) && ((((id == _x_id) && (p8_x == _x_p8_x)) && (( !(p8_x <= 2.0)) && (id == 9))) || ( !(((delta == 0.0) && (turn == 9)) && (((p8_l0 != 0) && ( !(p8_l1 != 0))) && ((_x_p8_l0 != 0) && (_x_p8_l1 != 0))))))) && (((( !(_x_p8_l0 != 0)) && ( !(_x_p8_l1 != 0))) && ((_x_id == 0) && (p8_x == _x_p8_x))) || ( !(((p8_l0 != 0) && (p8_l1 != 0)) && ((delta == 0.0) && (turn == 9)))))) && ((((((((((((( !(_x_p7_l0 != 0)) && ( !(_x_p7_l1 != 0))) || ((_x_p7_l0 != 0) && ( !(_x_p7_l1 != 0)))) || (((_x_p7_l1 != 0) && ( !(_x_p7_l0 != 0))) || ((_x_p7_l0 != 0) && (_x_p7_l1 != 0)))) && ((_x_p7_x <= 2.0) || ( !((_x_p7_l1 != 0) && ( !(_x_p7_l0 != 0)))))) && (((((p7_l0 != 0) == (_x_p7_l0 != 0)) && ((p7_l1 != 0) == (_x_p7_l1 != 0))) && ((delta + (p7_x + (-1.0 * _x_p7_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 8)))))) && ((((id == 0) && ((_x_p7_l1 != 0) && ( !(_x_p7_l0 != 0)))) && ((id == _x_id) && (_x_p7_x == 0.0))) || ( !((( !(p7_l0 != 0)) && ( !(p7_l1 != 0))) && ((delta == 0.0) && (turn == 8)))))) && (((((_x_p7_l0 != 0) && ( !(_x_p7_l1 != 0))) && (p7_x <= 2.0)) && ((_x_p7_x == 0.0) && (_x_id == 8))) || ( !(((p7_l1 != 0) && ( !(p7_l0 != 0))) && ((delta == 0.0) && (turn == 8)))))) && (((( !(_x_p7_l0 != 0)) && ( !(_x_p7_l1 != 0))) || ((_x_p7_l0 != 0) && (_x_p7_l1 != 0))) || ( !(((p7_l0 != 0) && ( !(p7_l1 != 0))) && ((delta == 0.0) && (turn == 8)))))) && ((((id == _x_id) && (_x_p7_x == 0.0)) && (( !(p7_x <= 2.0)) && ( !(id == 8)))) || ( !(((delta == 0.0) && (turn == 8)) && ((( !(_x_p7_l0 != 0)) && ( !(_x_p7_l1 != 0))) && ((p7_l0 != 0) && ( !(p7_l1 != 0)))))))) && ((((id == _x_id) && (p7_x == _x_p7_x)) && (( !(p7_x <= 2.0)) && (id == 8))) || ( !(((delta == 0.0) && (turn == 8)) && (((p7_l0 != 0) && ( !(p7_l1 != 0))) && ((_x_p7_l0 != 0) && (_x_p7_l1 != 0))))))) && (((( !(_x_p7_l0 != 0)) && ( !(_x_p7_l1 != 0))) && ((_x_id == 0) && (p7_x == _x_p7_x))) || ( !(((p7_l0 != 0) && (p7_l1 != 0)) && ((delta == 0.0) && (turn == 8)))))) && ((((((((((((( !(_x_p6_l0 != 0)) && ( !(_x_p6_l1 != 0))) || ((_x_p6_l0 != 0) && ( !(_x_p6_l1 != 0)))) || (((_x_p6_l1 != 0) && ( !(_x_p6_l0 != 0))) || ((_x_p6_l0 != 0) && (_x_p6_l1 != 0)))) && ((_x_p6_x <= 2.0) || ( !((_x_p6_l1 != 0) && ( !(_x_p6_l0 != 0)))))) && (((((p6_l0 != 0) == (_x_p6_l0 != 0)) && ((p6_l1 != 0) == (_x_p6_l1 != 0))) && ((delta + (p6_x + (-1.0 * _x_p6_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 7)))))) && ((((id == 0) && ((_x_p6_l1 != 0) && ( !(_x_p6_l0 != 0)))) && ((id == _x_id) && (_x_p6_x == 0.0))) || ( !((( !(p6_l0 != 0)) && ( !(p6_l1 != 0))) && ((delta == 0.0) && (turn == 7)))))) && (((((_x_p6_l0 != 0) && ( !(_x_p6_l1 != 0))) && (p6_x <= 2.0)) && ((_x_p6_x == 0.0) && (_x_id == 7))) || ( !(((p6_l1 != 0) && ( !(p6_l0 != 0))) && ((delta == 0.0) && (turn == 7)))))) && (((( !(_x_p6_l0 != 0)) && ( !(_x_p6_l1 != 0))) || ((_x_p6_l0 != 0) && (_x_p6_l1 != 0))) || ( !(((p6_l0 != 0) && ( !(p6_l1 != 0))) && ((delta == 0.0) && (turn == 7)))))) && ((((id == _x_id) && (_x_p6_x == 0.0)) && (( !(p6_x <= 2.0)) && ( !(id == 7)))) || ( !(((delta == 0.0) && (turn == 7)) && ((( !(_x_p6_l0 != 0)) && ( !(_x_p6_l1 != 0))) && ((p6_l0 != 0) && ( !(p6_l1 != 0)))))))) && ((((id == _x_id) && (p6_x == _x_p6_x)) && (( !(p6_x <= 2.0)) && (id == 7))) || ( !(((delta == 0.0) && (turn == 7)) && (((p6_l0 != 0) && ( !(p6_l1 != 0))) && ((_x_p6_l0 != 0) && (_x_p6_l1 != 0))))))) && (((( !(_x_p6_l0 != 0)) && ( !(_x_p6_l1 != 0))) && ((_x_id == 0) && (p6_x == _x_p6_x))) || ( !(((p6_l0 != 0) && (p6_l1 != 0)) && ((delta == 0.0) && (turn == 7)))))) && ((((((((((((( !(_x_p5_l0 != 0)) && ( !(_x_p5_l1 != 0))) || ((_x_p5_l0 != 0) && ( !(_x_p5_l1 != 0)))) || (((_x_p5_l1 != 0) && ( !(_x_p5_l0 != 0))) || ((_x_p5_l0 != 0) && (_x_p5_l1 != 0)))) && ((_x_p5_x <= 2.0) || ( !((_x_p5_l1 != 0) && ( !(_x_p5_l0 != 0)))))) && (((((p5_l0 != 0) == (_x_p5_l0 != 0)) && ((p5_l1 != 0) == (_x_p5_l1 != 0))) && ((delta + (p5_x + (-1.0 * _x_p5_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 6)))))) && ((((id == 0) && ((_x_p5_l1 != 0) && ( !(_x_p5_l0 != 0)))) && ((id == _x_id) && (_x_p5_x == 0.0))) || ( !((( !(p5_l0 != 0)) && ( !(p5_l1 != 0))) && ((delta == 0.0) && (turn == 6)))))) && (((((_x_p5_l0 != 0) && ( !(_x_p5_l1 != 0))) && (p5_x <= 2.0)) && ((_x_p5_x == 0.0) && (_x_id == 6))) || ( !(((p5_l1 != 0) && ( !(p5_l0 != 0))) && ((delta == 0.0) && (turn == 6)))))) && (((( !(_x_p5_l0 != 0)) && ( !(_x_p5_l1 != 0))) || ((_x_p5_l0 != 0) && (_x_p5_l1 != 0))) || ( !(((p5_l0 != 0) && ( !(p5_l1 != 0))) && ((delta == 0.0) && (turn == 6)))))) && ((((id == _x_id) && (_x_p5_x == 0.0)) && (( !(p5_x <= 2.0)) && ( !(id == 6)))) || ( !(((delta == 0.0) && (turn == 6)) && ((( !(_x_p5_l0 != 0)) && ( !(_x_p5_l1 != 0))) && ((p5_l0 != 0) && ( !(p5_l1 != 0)))))))) && ((((id == _x_id) && (p5_x == _x_p5_x)) && (( !(p5_x <= 2.0)) && (id == 6))) || ( !(((delta == 0.0) && (turn == 6)) && (((p5_l0 != 0) && ( !(p5_l1 != 0))) && ((_x_p5_l0 != 0) && (_x_p5_l1 != 0))))))) && (((( !(_x_p5_l0 != 0)) && ( !(_x_p5_l1 != 0))) && ((_x_id == 0) && (p5_x == _x_p5_x))) || ( !(((p5_l0 != 0) && (p5_l1 != 0)) && ((delta == 0.0) && (turn == 6)))))) && ((((((((((((( !(_x_p4_l0 != 0)) && ( !(_x_p4_l1 != 0))) || ((_x_p4_l0 != 0) && ( !(_x_p4_l1 != 0)))) || (((_x_p4_l1 != 0) && ( !(_x_p4_l0 != 0))) || ((_x_p4_l0 != 0) && (_x_p4_l1 != 0)))) && ((_x_p4_x <= 2.0) || ( !((_x_p4_l1 != 0) && ( !(_x_p4_l0 != 0)))))) && (((((p4_l0 != 0) == (_x_p4_l0 != 0)) && ((p4_l1 != 0) == (_x_p4_l1 != 0))) && ((delta + (p4_x + (-1.0 * _x_p4_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 5)))))) && ((((id == 0) && ((_x_p4_l1 != 0) && ( !(_x_p4_l0 != 0)))) && ((id == _x_id) && (_x_p4_x == 0.0))) || ( !((( !(p4_l0 != 0)) && ( !(p4_l1 != 0))) && ((delta == 0.0) && (turn == 5)))))) && (((((_x_p4_l0 != 0) && ( !(_x_p4_l1 != 0))) && (p4_x <= 2.0)) && ((_x_p4_x == 0.0) && (_x_id == 5))) || ( !(((p4_l1 != 0) && ( !(p4_l0 != 0))) && ((delta == 0.0) && (turn == 5)))))) && (((( !(_x_p4_l0 != 0)) && ( !(_x_p4_l1 != 0))) || ((_x_p4_l0 != 0) && (_x_p4_l1 != 0))) || ( !(((p4_l0 != 0) && ( !(p4_l1 != 0))) && ((delta == 0.0) && (turn == 5)))))) && ((((id == _x_id) && (_x_p4_x == 0.0)) && (( !(p4_x <= 2.0)) && ( !(id == 5)))) || ( !(((delta == 0.0) && (turn == 5)) && ((( !(_x_p4_l0 != 0)) && ( !(_x_p4_l1 != 0))) && ((p4_l0 != 0) && ( !(p4_l1 != 0)))))))) && ((((id == _x_id) && (p4_x == _x_p4_x)) && (( !(p4_x <= 2.0)) && (id == 5))) || ( !(((delta == 0.0) && (turn == 5)) && (((p4_l0 != 0) && ( !(p4_l1 != 0))) && ((_x_p4_l0 != 0) && (_x_p4_l1 != 0))))))) && (((( !(_x_p4_l0 != 0)) && ( !(_x_p4_l1 != 0))) && ((_x_id == 0) && (p4_x == _x_p4_x))) || ( !(((p4_l0 != 0) && (p4_l1 != 0)) && ((delta == 0.0) && (turn == 5)))))) && ((((((((((((( !(_x_p3_l0 != 0)) && ( !(_x_p3_l1 != 0))) || ((_x_p3_l0 != 0) && ( !(_x_p3_l1 != 0)))) || (((_x_p3_l1 != 0) && ( !(_x_p3_l0 != 0))) || ((_x_p3_l0 != 0) && (_x_p3_l1 != 0)))) && ((_x_p3_x <= 2.0) || ( !((_x_p3_l1 != 0) && ( !(_x_p3_l0 != 0)))))) && (((((p3_l0 != 0) == (_x_p3_l0 != 0)) && ((p3_l1 != 0) == (_x_p3_l1 != 0))) && ((delta + (p3_x + (-1.0 * _x_p3_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 4)))))) && ((((id == 0) && ((_x_p3_l1 != 0) && ( !(_x_p3_l0 != 0)))) && ((id == _x_id) && (_x_p3_x == 0.0))) || ( !((( !(p3_l0 != 0)) && ( !(p3_l1 != 0))) && ((delta == 0.0) && (turn == 4)))))) && (((((_x_p3_l0 != 0) && ( !(_x_p3_l1 != 0))) && (p3_x <= 2.0)) && ((_x_p3_x == 0.0) && (_x_id == 4))) || ( !(((p3_l1 != 0) && ( !(p3_l0 != 0))) && ((delta == 0.0) && (turn == 4)))))) && (((( !(_x_p3_l0 != 0)) && ( !(_x_p3_l1 != 0))) || ((_x_p3_l0 != 0) && (_x_p3_l1 != 0))) || ( !(((p3_l0 != 0) && ( !(p3_l1 != 0))) && ((delta == 0.0) && (turn == 4)))))) && ((((id == _x_id) && (_x_p3_x == 0.0)) && (( !(p3_x <= 2.0)) && ( !(id == 4)))) || ( !(((delta == 0.0) && (turn == 4)) && ((( !(_x_p3_l0 != 0)) && ( !(_x_p3_l1 != 0))) && ((p3_l0 != 0) && ( !(p3_l1 != 0)))))))) && ((((id == _x_id) && (p3_x == _x_p3_x)) && (( !(p3_x <= 2.0)) && (id == 4))) || ( !(((delta == 0.0) && (turn == 4)) && (((p3_l0 != 0) && ( !(p3_l1 != 0))) && ((_x_p3_l0 != 0) && (_x_p3_l1 != 0))))))) && (((( !(_x_p3_l0 != 0)) && ( !(_x_p3_l1 != 0))) && ((_x_id == 0) && (p3_x == _x_p3_x))) || ( !(((p3_l0 != 0) && (p3_l1 != 0)) && ((delta == 0.0) && (turn == 4)))))) && ((((((((((((( !(_x_p2_l0 != 0)) && ( !(_x_p2_l1 != 0))) || ((_x_p2_l0 != 0) && ( !(_x_p2_l1 != 0)))) || (((_x_p2_l1 != 0) && ( !(_x_p2_l0 != 0))) || ((_x_p2_l0 != 0) && (_x_p2_l1 != 0)))) && ((_x_p2_x <= 2.0) || ( !((_x_p2_l1 != 0) && ( !(_x_p2_l0 != 0)))))) && (((((p2_l0 != 0) == (_x_p2_l0 != 0)) && ((p2_l1 != 0) == (_x_p2_l1 != 0))) && ((delta + (p2_x + (-1.0 * _x_p2_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 3)))))) && ((((id == 0) && ((_x_p2_l1 != 0) && ( !(_x_p2_l0 != 0)))) && ((id == _x_id) && (_x_p2_x == 0.0))) || ( !((( !(p2_l0 != 0)) && ( !(p2_l1 != 0))) && ((delta == 0.0) && (turn == 3)))))) && (((((_x_p2_l0 != 0) && ( !(_x_p2_l1 != 0))) && (p2_x <= 2.0)) && ((_x_p2_x == 0.0) && (_x_id == 3))) || ( !(((p2_l1 != 0) && ( !(p2_l0 != 0))) && ((delta == 0.0) && (turn == 3)))))) && (((( !(_x_p2_l0 != 0)) && ( !(_x_p2_l1 != 0))) || ((_x_p2_l0 != 0) && (_x_p2_l1 != 0))) || ( !(((p2_l0 != 0) && ( !(p2_l1 != 0))) && ((delta == 0.0) && (turn == 3)))))) && ((((id == _x_id) && (_x_p2_x == 0.0)) && (( !(p2_x <= 2.0)) && ( !(id == 3)))) || ( !(((delta == 0.0) && (turn == 3)) && ((( !(_x_p2_l0 != 0)) && ( !(_x_p2_l1 != 0))) && ((p2_l0 != 0) && ( !(p2_l1 != 0)))))))) && ((((id == _x_id) && (p2_x == _x_p2_x)) && (( !(p2_x <= 2.0)) && (id == 3))) || ( !(((delta == 0.0) && (turn == 3)) && (((p2_l0 != 0) && ( !(p2_l1 != 0))) && ((_x_p2_l0 != 0) && (_x_p2_l1 != 0))))))) && (((( !(_x_p2_l0 != 0)) && ( !(_x_p2_l1 != 0))) && ((_x_id == 0) && (p2_x == _x_p2_x))) || ( !(((p2_l0 != 0) && (p2_l1 != 0)) && ((delta == 0.0) && (turn == 3)))))) && ((((((((((((( !(_x_p1_l0 != 0)) && ( !(_x_p1_l1 != 0))) || ((_x_p1_l0 != 0) && ( !(_x_p1_l1 != 0)))) || (((_x_p1_l1 != 0) && ( !(_x_p1_l0 != 0))) || ((_x_p1_l0 != 0) && (_x_p1_l1 != 0)))) && ((_x_p1_x <= 2.0) || ( !((_x_p1_l1 != 0) && ( !(_x_p1_l0 != 0)))))) && (((((p1_l0 != 0) == (_x_p1_l0 != 0)) && ((p1_l1 != 0) == (_x_p1_l1 != 0))) && ((delta + (p1_x + (-1.0 * _x_p1_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 2)))))) && ((((id == 0) && ((_x_p1_l1 != 0) && ( !(_x_p1_l0 != 0)))) && ((id == _x_id) && (_x_p1_x == 0.0))) || ( !((( !(p1_l0 != 0)) && ( !(p1_l1 != 0))) && ((delta == 0.0) && (turn == 2)))))) && (((((_x_p1_l0 != 0) && ( !(_x_p1_l1 != 0))) && (p1_x <= 2.0)) && ((_x_p1_x == 0.0) && (_x_id == 2))) || ( !(((p1_l1 != 0) && ( !(p1_l0 != 0))) && ((delta == 0.0) && (turn == 2)))))) && (((( !(_x_p1_l0 != 0)) && ( !(_x_p1_l1 != 0))) || ((_x_p1_l0 != 0) && (_x_p1_l1 != 0))) || ( !(((p1_l0 != 0) && ( !(p1_l1 != 0))) && ((delta == 0.0) && (turn == 2)))))) && ((((id == _x_id) && (_x_p1_x == 0.0)) && (( !(p1_x <= 2.0)) && ( !(id == 2)))) || ( !(((delta == 0.0) && (turn == 2)) && ((( !(_x_p1_l0 != 0)) && ( !(_x_p1_l1 != 0))) && ((p1_l0 != 0) && ( !(p1_l1 != 0)))))))) && ((((id == _x_id) && (p1_x == _x_p1_x)) && (( !(p1_x <= 2.0)) && (id == 2))) || ( !(((delta == 0.0) && (turn == 2)) && (((p1_l0 != 0) && ( !(p1_l1 != 0))) && ((_x_p1_l0 != 0) && (_x_p1_l1 != 0))))))) && (((( !(_x_p1_l0 != 0)) && ( !(_x_p1_l1 != 0))) && ((_x_id == 0) && (p1_x == _x_p1_x))) || ( !(((p1_l0 != 0) && (p1_l1 != 0)) && ((delta == 0.0) && (turn == 2)))))) && ((((((((((((( !(_x_p0_l0 != 0)) && ( !(_x_p0_l1 != 0))) || ((_x_p0_l0 != 0) && ( !(_x_p0_l1 != 0)))) || (((_x_p0_l1 != 0) && ( !(_x_p0_l0 != 0))) || ((_x_p0_l0 != 0) && (_x_p0_l1 != 0)))) && ((_x_p0_x <= 2.0) || ( !((_x_p0_l1 != 0) && ( !(_x_p0_l0 != 0)))))) && (((((p0_l0 != 0) == (_x_p0_l0 != 0)) && ((p0_l1 != 0) == (_x_p0_l1 != 0))) && ((delta + (p0_x + (-1.0 * _x_p0_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || ( !(turn == 1)))))) && (((((_x_p0_l1 != 0) && ( !(_x_p0_l0 != 0))) && (id == 0)) && ((_x_p0_x == 0.0) && (id == _x_id))) || ( !((( !(p0_l0 != 0)) && ( !(p0_l1 != 0))) && ((turn == 1) && (delta == 0.0)))))) && (((((_x_p0_l0 != 0) && ( !(_x_p0_l1 != 0))) && (p0_x <= 2.0)) && ((_x_p0_x == 0.0) && (_x_id == 1))) || ( !(((p0_l1 != 0) && ( !(p0_l0 != 0))) && ((turn == 1) && (delta == 0.0)))))) && (((( !(_x_p0_l0 != 0)) && ( !(_x_p0_l1 != 0))) || ((_x_p0_l0 != 0) && (_x_p0_l1 != 0))) || ( !(((p0_l0 != 0) && ( !(p0_l1 != 0))) && ((turn == 1) && (delta == 0.0)))))) && ((((_x_p0_x == 0.0) && (id == _x_id)) && (( !(p0_x <= 2.0)) && ( !(id == 1)))) || ( !(((turn == 1) && (delta == 0.0)) && ((( !(_x_p0_l0 != 0)) && ( !(_x_p0_l1 != 0))) && ((p0_l0 != 0) && ( !(p0_l1 != 0)))))))) && ((((id == _x_id) && (p0_x == _x_p0_x)) && (( !(p0_x <= 2.0)) && (id == 1))) || ( !(((turn == 1) && (delta == 0.0)) && (((p0_l0 != 0) && ( !(p0_l1 != 0))) && ((_x_p0_l0 != 0) && (_x_p0_l1 != 0))))))) && (((( !(_x_p0_l0 != 0)) && ( !(_x_p0_l1 != 0))) && ((p0_x == _x_p0_x) && (_x_id == 0))) || ( !(((p0_l0 != 0) && (p0_l1 != 0)) && ((turn == 1) && (delta == 0.0)))))) && (((((id == 18) || ((id == 17) || ((id == 16) || ((id == 15) || ((id == 14) || ((id == 13) || ((id == 12) || ((id == 11) || ((id == 10) || ((id == 9) || ((id == 8) || ((id == 7) || ((id == 6) || ((id == 5) || ((id == 4) || ((id == 3) || ((id == 2) || ((id == 0) || (id == 1))))))))))))))))))) && ((((((((((((((((((_x_turn == 1) || (_x_turn == 2)) || (_x_turn == 3)) || (_x_turn == 4)) || (_x_turn == 5)) || (_x_turn == 6)) || (_x_turn == 7)) || (_x_turn == 8)) || (_x_turn == 9)) || (_x_turn == 10)) || (_x_turn == 11)) || (_x_turn == 12)) || (_x_turn == 13)) || (_x_turn == 14)) || (_x_turn == 15)) || (_x_turn == 16)) || (_x_turn == 17)) || (_x_turn == 18))) && (0.0 <= _x_delta)) && ((delta <= 0.0) || ((id == _x_id) && (turn == _x_turn)))))))))))))))))))))) && (((delta == _x__diverge_delta) || ( !(1.0 <= _diverge_delta))) && ((1.0 <= _diverge_delta) || ((delta + (_diverge_delta + (-1.0 * _x__diverge_delta))) == 0.0)))); p17_x = _x_p17_x; p16_x = _x_p16_x; p15_x = _x_p15_x; p14_x = _x_p14_x; p12_l0 = _x_p12_l0; p12_x = _x_p12_x; _diverge_delta = _x__diverge_delta; p17_l1 = _x_p17_l1; p11_l0 = _x_p11_l0; p11_x = _x_p11_x; p16_l1 = _x_p16_l1; p10_l0 = _x_p10_l0; p10_x = _x_p10_x; p9_x = _x_p9_x; p2_l1 = _x_p2_l1; p17_l0 = _x_p17_l0; p6_x = _x_p6_x; p8_l1 = _x_p8_l1; p2_l0 = _x_p2_l0; p13_l0 = _x_p13_l0; p2_x = _x_p2_x; p1_l1 = _x_p1_l1; delta = _x_delta; p13_x = _x_p13_x; p0_l0 = _x_p0_l0; p7_l1 = _x_p7_l1; p0_x = _x_p0_x; p12_l1 = _x_p12_l1; p6_l0 = _x_p6_l0; turn = _x_turn; id = _x_id; p14_l0 = _x_p14_l0; p3_x = _x_p3_x; p15_l1 = _x_p15_l1; p9_l0 = _x_p9_l0; p1_x = _x_p1_x; p5_l1 = _x_p5_l1; p9_l1 = _x_p9_l1; p3_l0 = _x_p3_l0; p3_l1 = _x_p3_l1; p0_l1 = _x_p0_l1; p7_x = _x_p7_x; p15_l0 = _x_p15_l0; p4_x = _x_p4_x; p10_l1 = _x_p10_l1; p4_l0 = _x_p4_l0; p1_l0 = _x_p1_l0; p4_l1 = _x_p4_l1; p8_x = _x_p8_x; p16_l0 = _x_p16_l0; p5_x = _x_p5_x; p11_l1 = _x_p11_l1; p5_l0 = _x_p5_l0; p6_l1 = _x_p6_l1; p13_l1 = _x_p13_l1; p7_l0 = _x_p7_l0; p14_l1 = _x_p14_l1; p8_l0 = _x_p8_l0; } }
the_stack_data/31386541.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, char *argv[]) { int fd, cnt, res; ssize_t ret; fd = open(argv[1], O_WRONLY); if (fd < 0) { perror("open"); exit(1); } res = lseek(fd, 1073741824, SEEK_SET); if (res < 0) { perror("lseek"); exit(1); } cnt = 16; do { ret = write(fd, "XXXXXXXXXXXXXXXX", 16); if (ret < 0 ) { perror("write"); exit(1); } cnt -= ret; }while (cnt > 0); if (close(fd) < 0) { perror("close"); exit(1); } return 0; }
the_stack_data/69937.c
// nono.c -- DO NOT REPEAT THIS PROGRAM #include <stdio.h> int main(void) { char side_a[] = "Side A"; char dont[] = { 'W', 'O', 'W', '!' }; char side_b[] = "Side B"; puts(dont); // dont is not a string return 0; }
the_stack_data/25137721.c
#include <stdio.h> int main() { int a; int x,y,i=0,sum=0; scanf("%d %d",&x,&y); if (x>y) { for(i=y; i<x; i++) { if(i%2!=0) sum = sum+i; } } else if(y>x) { for(i=x; i<y; i++) { if(i%2!=0) sum = sum+i; } } else if(x==y) { sum=0; } printf("%d",sum); return 0; }
the_stack_data/1177515.c
#include <stdio.h> #include <stdbool.h> int main() { char * line = NULL; size_t siz = 0; int sum = 0; bool answers[26] = {0}; while (getline(&line, &siz, stdin) >= 0) { if (*line == '\n') { int group_sum = 0; for (size_t i = 0; i < 26; i++) { if (answers[i]) { group_sum++; answers[i] = false; } } sum += group_sum; } else { for (size_t i = 0; line[i] != '\n'; i++) { answers[line[i] - 'a'] = true; } } } { int group_sum = 0; for (size_t i = 0; i < 26; i++) { if (answers[i]) { group_sum++; answers[i] = false; } } sum += group_sum; } printf("%d\n", sum); return 0; }
the_stack_data/729574.c
#include <stdio.h> static int static_func(int param) { printf("static_func %d\n", param); return param; } int public_func(int param) { printf("public func %d\n", param); return static_func(param); }
the_stack_data/26700446.c
/* ** EPITECH PROJECT, 2019 ** my_strcmp ** File description: ** compare strings */ #include <stdio.h> int my_strcmp(char const *s1, char const *s2) { while (*s1) { if (*s1 != *s2) return (*s1 - *s2); s1++; s2++; } return (*s1 - *s2); }
the_stack_data/117329135.c
#include <stdio.h> #include <stdlib.h> #define n 5 int fun(int a[][n]){ int i, j; int sum = 0; if(n == 1) return a[0][0]; for(i = 0; i < n; i++){ if(i == 0 || i == n-1){ for(j = 0; j < n; j++){ sum += a[i][j]; } } else{ sum += (a[i][0] + a[i][n-1]); } } return sum; } int main() { int b[n][n]; int i, j; int s; for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ b[i][j] = rand()%9+1; } } for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ if(j != n-1) printf("%d ",b[i][j]); else printf("%d",b[i][j]); } printf("\n"); } printf("\n"); s = fun(b); printf("%d\n",s); return 0; }
the_stack_data/165769402.c
//***************************************************************************** // // startup_gcc.c - Startup code for use with GNU tools. // // Copyright (c) 2009-2013 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 10636 of the EK-LM3S9D90 Firmware Package. // //***************************************************************************** //***************************************************************************** // // Forward declaration of the default fault handlers. // //***************************************************************************** void ResetISR(void); static void NmiSR(void); static void FaultISR(void); static void IntDefaultHandler(void); //***************************************************************************** // // External declarations for the interrupt handlers used by the application. // //***************************************************************************** extern void AppForceUpdate(void); extern void USB0HostIntHandler(void); //***************************************************************************** // // The entry point for the application. // //***************************************************************************** extern int main(void); //***************************************************************************** // // Reserve space for the system stack. // //***************************************************************************** static unsigned long pulStack[256]; //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000. // //***************************************************************************** __attribute__ ((section(".isr_vector"))) void (* const g_pfnVectors[])(void) = { (void (*)(void))((unsigned long)pulStack + sizeof(pulStack)), // The initial stack pointer ResetISR, // The reset handler NmiSR, // The NMI handler FaultISR, // The hard fault handler IntDefaultHandler, // The MPU fault handler IntDefaultHandler, // The bus fault handler IntDefaultHandler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved AppForceUpdate, // SVCall handler IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler IntDefaultHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A IntDefaultHandler, // GPIO Port B IntDefaultHandler, // GPIO Port C IntDefaultHandler, // GPIO Port D IntDefaultHandler, // GPIO Port E IntDefaultHandler, // UART0 Rx and Tx IntDefaultHandler, // UART1 Rx and Tx IntDefaultHandler, // SSI0 Rx and Tx IntDefaultHandler, // I2C0 Master and Slave IntDefaultHandler, // PWM Fault IntDefaultHandler, // PWM Generator 0 IntDefaultHandler, // PWM Generator 1 IntDefaultHandler, // PWM Generator 2 IntDefaultHandler, // Quadrature Encoder 0 IntDefaultHandler, // ADC Sequence 0 IntDefaultHandler, // ADC Sequence 1 IntDefaultHandler, // ADC Sequence 2 IntDefaultHandler, // ADC Sequence 3 IntDefaultHandler, // Watchdog timer IntDefaultHandler, // Timer 0 subtimer A IntDefaultHandler, // Timer 0 subtimer B IntDefaultHandler, // Timer 1 subtimer A IntDefaultHandler, // Timer 1 subtimer B IntDefaultHandler, // Timer 2 subtimer A IntDefaultHandler, // Timer 2 subtimer B IntDefaultHandler, // Analog Comparator 0 IntDefaultHandler, // Analog Comparator 1 IntDefaultHandler, // Analog Comparator 2 IntDefaultHandler, // System Control (PLL, OSC, BO) IntDefaultHandler, // FLASH Control IntDefaultHandler, // GPIO Port F IntDefaultHandler, // GPIO Port G IntDefaultHandler, // GPIO Port H IntDefaultHandler, // UART2 Rx and Tx IntDefaultHandler, // SSI1 Rx and Tx IntDefaultHandler, // Timer 3 subtimer A IntDefaultHandler, // Timer 3 subtimer B IntDefaultHandler, // I2C1 Master and Slave IntDefaultHandler, // Quadrature Encoder 1 IntDefaultHandler, // CAN0 IntDefaultHandler, // CAN1 IntDefaultHandler, // CAN2 IntDefaultHandler, // Ethernet IntDefaultHandler, // Hibernate USB0HostIntHandler, // USB0 IntDefaultHandler, // PWM Generator 3 IntDefaultHandler, // uDMA Software Transfer IntDefaultHandler, // uDMA Error IntDefaultHandler, // ADC1 Sequence 0 IntDefaultHandler, // ADC1 Sequence 1 IntDefaultHandler, // ADC1 Sequence 2 IntDefaultHandler, // ADC1 Sequence 3 IntDefaultHandler, // I2S0 IntDefaultHandler, // External Bus Interface 0 IntDefaultHandler // GPIO Port J }; //***************************************************************************** // // The following are constructs created by the linker, indicating where the // the "data" and "bss" segments reside in memory. The initializers for the // for the "data" segment resides immediately following the "text" segment. // //***************************************************************************** extern unsigned long _etext; extern unsigned long _data; extern unsigned long _edata; extern unsigned long _bss; extern unsigned long _ebss; //***************************************************************************** // // This is the code that gets called when the processor first starts execution // following a reset event. Only the absolutely necessary set is performed, // after which the application supplied entry() routine is called. Any fancy // actions (such as making decisions based on the reset cause register, and // resetting the bits in that register) are left solely in the hands of the // application. // //***************************************************************************** void ResetISR(void) { unsigned long *pulSrc, *pulDest; // // Copy the data segment initializers from flash to SRAM. // pulSrc = &_etext; for(pulDest = &_data; pulDest < &_edata; ) { *pulDest++ = *pulSrc++; } // // Zero fill the bss segment. // __asm(" ldr r0, =_bss\n" " ldr r1, =_ebss\n" " mov r2, #0\n" " .thumb_func\n" "zero_loop:\n" " cmp r0, r1\n" " it lt\n" " strlt r2, [r0], #4\n" " blt zero_loop"); // // Call the application's entry point. // main(); } //***************************************************************************** // // This is the code that gets called when the processor receives a NMI. This // simply enters an infinite loop, preserving the system state for examination // by a debugger. // //***************************************************************************** static void NmiSR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives a fault // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void FaultISR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives an unexpected // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void IntDefaultHandler(void) { // // Go into an infinite loop. // while(1) { } }
the_stack_data/322144.c
//***************************************************************************** // +--+ // | ++----+ // +-++ | // | | // +-+--+ | // | +--+--+ // +----+ Copyright (c) 2011 Code Red Technologies Ltd. // // Microcontroller Startup code for use with Red Suite // // Version : 110307 // // Software License Agreement // // The software is owned by Code Red Technologies and/or its suppliers, and is // protected under applicable copyright laws. All rights are reserved. Any // use in violation of the foregoing restrictions may subject the user to criminal // sanctions under applicable laws, as well as to civil liability for the breach // of the terms and conditions of this license. // // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. // USE OF THIS SOFTWARE FOR COMMERCIAL DEVELOPMENT AND/OR EDUCATION IS SUBJECT // TO A CURRENT END USER LICENSE AGREEMENT (COMMERCIAL OR EDUCATIONAL) WITH // CODE RED TECHNOLOGIES LTD. // //***************************************************************************** #if defined (__cplusplus) #ifdef __REDLIB__ #error Redlib does not support C++ #else //***************************************************************************** // // The entry point for the C++ library startup // //***************************************************************************** extern "C" { extern void __libc_init_array(void); } #endif #endif #define WEAK __attribute__ ((weak)) #define ALIAS(f) __attribute__ ((weak, alias (#f))) // Code Red - if CMSIS is being used, then SystemInit() routine // will be called by startup code rather than in application's main() #if defined (__USE_CMSIS) #include "LPC122x.h" #include "system_LPC122x.h" #endif // Patch the AEABI integer divide functions to use MCU's romdivide library #ifdef __USE_ROMDIVIDE // Base address of romdivide library in MCU ROM #define DIVROM_BASE 0x1FFC0000 // Variables to store addresses of idiv and udiv functions within MCU ROM unsigned int *pDivRom_idiv; unsigned int *pDivRom_uidiv; #endif // Provide base address of WWDT (Watchdog) peripheral // Required as we cannot guarantee that CMSIS headers available to use #ifdef __DISABLE_WATCHDOG #define WATCHDOG_BASE_ADDRESS 0x40004000 #endif //***************************************************************************** #if defined (__cplusplus) extern "C" { #endif //***************************************************************************** // // Forward declaration of the default handlers. These are aliased. // When the application defines a handler (with the same name), this will // automatically take precedence over these weak definitions // //***************************************************************************** void ResetISR(void); WEAK void NMI_Handler(void); WEAK void HardFault_Handler(void); WEAK void SVCall_Handler(void); WEAK void PendSV_Handler(void); WEAK void SysTick_Handler(void); WEAK void IntDefaultHandler(void); //***************************************************************************** // // Forward declaration of the specific IRQ handlers. These are aliased // to the IntDefaultHandler, which is a 'forever' loop. When the application // defines a handler (with the same name), this will automatically take // precedence over these weak definitions // //***************************************************************************** void WAKEUP_IRQHandler (void) ALIAS(IntDefaultHandler); void I2C_IRQHandler (void) ALIAS(IntDefaultHandler); void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler); void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler); void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler); void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler); void SSP_IRQHandler (void) ALIAS(IntDefaultHandler); void UART0_IRQHandler (void) ALIAS(IntDefaultHandler); void UART1_IRQHandler (void) ALIAS(IntDefaultHandler); void COMP_IRQHandler (void) ALIAS(IntDefaultHandler); void ADC_IRQHandler (void) ALIAS(IntDefaultHandler); void WDT_IRQHandler (void) ALIAS(IntDefaultHandler); void BOD_IRQHandler (void) ALIAS(IntDefaultHandler); void PIOINT0_IRQHandler (void) ALIAS(IntDefaultHandler); void PIOINT1_IRQHandler (void) ALIAS(IntDefaultHandler); void PIOINT2_IRQHandler (void) ALIAS(IntDefaultHandler); void DMA_IRQHandler (void) ALIAS(IntDefaultHandler); void RTC_IRQHandler (void) ALIAS(IntDefaultHandler); //***************************************************************************** // // The entry point for the application. // __main() is the entry point for redlib based applications // main() is the entry point for newlib based applications // //***************************************************************************** // // The entry point for the application. // __main() is the entry point for Redlib based applications // main() is the entry point for Newlib based applications // //***************************************************************************** #if defined (__REDLIB__) extern void __main(void); #endif extern int main(void); //***************************************************************************** // // External declaration for the pointer to the stack top from the Linker Script // //***************************************************************************** extern void _vStackTop(void); //***************************************************************************** #if defined (__cplusplus) } // extern "C" #endif //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000. // //***************************************************************************** extern void (* const g_pfnVectors[])(void); __attribute__ ((section(".isr_vector"))) void (* const g_pfnVectors[])(void) = { &_vStackTop, // The initial stack pointer ResetISR, // The reset handler NMI_Handler, // The NMI handler HardFault_Handler, // The hard fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved SVCall_Handler, // SVCall handler 0, // Reserved 0, // Reserved PendSV_Handler, // The PendSV handler SysTick_Handler, // The SysTick handler // External Interrupts WAKEUP_IRQHandler, // 12 wakeup sources for all the WAKEUP_IRQHandler, // I/O pins starting from PIO0 (0:11) WAKEUP_IRQHandler, // all 40 are routed to the same ISR WAKEUP_IRQHandler, WAKEUP_IRQHandler, WAKEUP_IRQHandler, WAKEUP_IRQHandler, WAKEUP_IRQHandler, WAKEUP_IRQHandler, WAKEUP_IRQHandler, WAKEUP_IRQHandler, WAKEUP_IRQHandler, I2C_IRQHandler, // I2C TIMER16_0_IRQHandler, // 16-bit Timer0 TIMER16_1_IRQHandler, // 16-bit Timer1 TIMER32_0_IRQHandler, // 32-bit Timer0 TIMER32_1_IRQHandler, // 32-bit Timer1 SSP_IRQHandler, // SSP UART0_IRQHandler, // UART0 UART1_IRQHandler, // UART1 COMP_IRQHandler, // Comparators 0,1 ADC_IRQHandler, // A/D Converter WDT_IRQHandler, // Watchdog timer BOD_IRQHandler, // Brown Out Detect 0, // Reserved PIOINT0_IRQHandler, // PIO INT0 PIOINT1_IRQHandler, // PIO INT1 PIOINT2_IRQHandler, // PIO INT2 0, // Reserved DMA_IRQHandler, // DMA RTC_IRQHandler, // RTC }; //***************************************************************************** // Functions to carry out the initialization of RW and BSS data sections. These // are written as separate functions rather than being inlined within the // ResetISR() function in order to cope with MCUs with multiple banks of // memory. //***************************************************************************** __attribute__ ((section(".after_vectors"))) void data_init(unsigned int romstart, unsigned int start, unsigned int len) { unsigned int *pulDest = (unsigned int*) start; unsigned int *pulSrc = (unsigned int*) romstart; unsigned int loop; for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++; } __attribute__ ((section(".after_vectors"))) void bss_init(unsigned int start, unsigned int len) { unsigned int *pulDest = (unsigned int*) start; unsigned int loop; for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0; } #ifndef USE_OLD_STYLE_DATA_BSS_INIT //***************************************************************************** // The following symbols are constructs generated by the linker, indicating // the location of various points in the "Global Section Table". This table is // created by the linker via the Code Red managed linker script mechanism. It // contains the load address, execution address and length of each RW data // section and the execution and length of each BSS (zero initialized) section. //***************************************************************************** extern unsigned int __data_section_table; extern unsigned int __data_section_table_end; extern unsigned int __bss_section_table; extern unsigned int __bss_section_table_end; #else //***************************************************************************** // The following symbols are constructs generated by the linker, indicating // the load address, execution address and length of the RW data section and // the execution and length of the BSS (zero initialized) section. // Note that these symbols are not normally used by the managed linker script // mechanism in Red Suite/LPCXpresso 3.6 (Windows) and LPCXpresso 3.8 (Linux). // They are provide here simply so this startup code can be used with earlier // versions of Red Suite which do not support the more advanced managed linker // script mechanism introduced in the above version. To enable their use, // define "USE_OLD_STYLE_DATA_BSS_INIT". //***************************************************************************** extern unsigned int _etext; extern unsigned int _data; extern unsigned int _edata; extern unsigned int _bss; extern unsigned int _ebss; #endif //***************************************************************************** // Reset entry point for your code. // Sets up a simple runtime environment and initializes the C/C++ // library. //***************************************************************************** __attribute__ ((section(".after_vectors"))) void ResetISR(void) { // ************************************************************ // The LPC12xx family start up with the Windowed Watchdog timer // enabled, and if the application code does not continually // feed the WWDT, then a reset will occur. This behavior will // prevent the debug tools functioning correctly - and thus // when a debug connection is made, the tools will disable the // WWDT. However this will mean that behavior of your application // may be different depending upon whether the debugger is // connected or not. The below code will disable the WWDT in the // same way that the debugger does, so that behavior will not // depend upon whether the debugger is connected or not. // If you do not want to connect the debugger to the target and // require the default LPC12xx WWDT operation, then undefine the // symbol __DISABLE_WATCHDOG. // For more information, see the LPC12xx User Manual. // ************************************************************ #ifdef __DISABLE_WATCHDOG // Note that we do not use the CMSIS register access mechanism, // as there is no guarantee that the project has been configured // to use CMSIS. typedef struct { volatile unsigned int MOD; // Offset: 0x000 - Watchdog mode register unsigned int dummy; // Offset: 0x004 - not used by startup code volatile unsigned int FEED; // Offset: 0x008 - Watchdog feed sequence register } cr_wdt_TypeDef; volatile cr_wdt_TypeDef * watchdog_temp = (cr_wdt_TypeDef *) WATCHDOG_BASE_ADDRESS; watchdog_temp->MOD = 0x0; // CMSIS: LPC_WDT->MOD = 0x00; watchdog_temp->FEED = 0xAA; // CMSIS: LPC_WDT->FEED = 0xAA; watchdog_temp->FEED = 0x55; // CMSIS: LPC_WDT->FEED = 0x55; #endif #ifndef USE_OLD_STYLE_DATA_BSS_INIT // // Copy the data sections from flash to SRAM. // unsigned int LoadAddr, ExeAddr, SectionLen; unsigned int *SectionTableAddr; // Load base address of Global Section Table SectionTableAddr = &__data_section_table; // Copy the data sections from flash to SRAM. while (SectionTableAddr < &__data_section_table_end) { LoadAddr = *SectionTableAddr++; ExeAddr = *SectionTableAddr++; SectionLen = *SectionTableAddr++; data_init(LoadAddr, ExeAddr, SectionLen); } // At this point, SectionTableAddr = &__bss_section_table; // Zero fill the bss segment while (SectionTableAddr < &__bss_section_table_end) { ExeAddr = *SectionTableAddr++; SectionLen = *SectionTableAddr++; bss_init(ExeAddr, SectionLen); } #else // Use Old Style Data and BSS section initialization. // This will only initialize a single RAM bank. unsigned int * LoadAddr, *ExeAddr, *EndAddr, SectionLen; // Copy the data segment from flash to SRAM. LoadAddr = &_etext; ExeAddr = &_data; EndAddr = &_edata; SectionLen = (void*)EndAddr - (void*)ExeAddr; data_init((unsigned int)LoadAddr, (unsigned int)ExeAddr, SectionLen); // Zero fill the bss segment ExeAddr = &_bss; EndAddr = &_ebss; SectionLen = (void*)EndAddr - (void*)ExeAddr; bss_init ((unsigned int)ExeAddr, SectionLen); #endif // Patch the AEABI integer divide functions to use MCU's romdivide library #ifdef __USE_ROMDIVIDE // Get base address of romdivide area in MCU ROM unsigned int *pDivRom = (unsigned int *) DIVROM_BASE; // Load first word of romdivide area, which contains address of first // divide function. unsigned int *romdiv_func = (unsigned int *)*pDivRom; // Get address of first divide function (signed divide) pDivRom_idiv = (unsigned int *)*romdiv_func; // Get address of second divide function (unsigned divide) pDivRom_uidiv= (unsigned int *)*(romdiv_func+1); #endif #ifdef __USE_CMSIS SystemInit(); #endif #if defined (__cplusplus) // // Call C++ library initialisation // __libc_init_array(); #endif #if defined (__REDLIB__) // Call the Redlib library, which in turn calls main() __main() ; #else main(); #endif // // main() shouldn't return, but if it does, we'll just enter an infinite loop // while (1) { ; } } //***************************************************************************** // Default exception handlers. Override the ones here by defining your own // handler routines in your application code. //***************************************************************************** __attribute__ ((section(".after_vectors"))) void NMI_Handler(void) { while(1) { } } __attribute__ ((section(".after_vectors"))) void HardFault_Handler(void) { while(1) { } } __attribute__ ((section(".after_vectors"))) void SVCall_Handler(void) { while(1) { } } __attribute__ ((section(".after_vectors"))) void PendSV_Handler(void) { while(1) { } } __attribute__ ((section(".after_vectors"))) void SysTick_Handler(void) { while(1) { } } //***************************************************************************** // // Processor ends up here if an unexpected interrupt occurs or a specific // handler is not present in the application code. // //***************************************************************************** __attribute__ ((section(".after_vectors"))) void IntDefaultHandler(void) { while(1) { } }
the_stack_data/145450.c
#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <unistd.h> #include <fcntl.h> #include <pthread.h> #include <time.h> #include <netinet/in.h> #include <netinet/ip.h> #include <netinet/udp.h> #include <netinet/ip_icmp.h> #include <sys/select.h> #include <sys/socket.h> #include <arpa/inet.h> // global variables fd_set result; int start, end; struct sockaddr_in check_address; void* raw_socket_checker(void* args); void* udp_port_checker(void* args); void* tcp_port_checker(void* args); int main(int argc, char* argv[]) { if (argc != 3) perror("incorrect arguments\n"); // start and end ports for scan start = atoi(argv[1]); end = atoi(argv[2]); FILE* ip_file = fopen("ip_list.txt", "r"); if (ip_file == NULL) exit(EXIT_FAILURE); char* ip_string; size_t length = 0; ssize_t read; while ((read = getline(&ip_string, &length, ip_file)) != -1) { check_address.sin_family = AF_INET; check_address.sin_addr.s_addr = inet_addr(ip_string); pthread_t raw_socket_thread, udp_thread, tcp_thread; // check tcp ports int iret1 = pthread_create(&tcp_thread, NULL, tcp_port_checker, NULL); pthread_join(tcp_thread, NULL); // check udp ports // use an fd_set to maintain a list of ports to be checked // used as a cheap substitute for an array FD_ZERO(&result); int i; for (i = start; i <= end; i++) { FD_SET(i, &result); } int iret2 = pthread_create(&raw_socket_thread, NULL, raw_socket_checker, NULL); int iret3 = pthread_create(&udp_thread, NULL, udp_port_checker, NULL); pthread_join(udp_thread, NULL); // after sending all udp packets // wait for possible ICMP packets to arrive in the raw socket sleep(5); // result set has been modified by raw socket // set ports are open for (i = start; i <= end; i++) { if (FD_ISSET(i, &result)) { printf("udp port %d is open\n", i); } } } } void* udp_port_checker(void* args) { // write to ports iteratively // send port number as packet data because it is returned in ICMP error int i, send_port_val; for (i = start; i <= end; i++) { int sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); check_address.sin_port = htons(i); // send port number as data send_port_val = htonl(i); sendto(sock_fd, &send_port_val, sizeof(int), 0, (struct sockaddr*) &check_address, sizeof(struct sockaddr)); } } void* raw_socket_checker(void* args) { // declare structures to interpret received data int hlen1, hlen2, icmp_len, ret; struct ip *ip, *ip_hdr; struct icmp *icmp; struct udphdr *udp; // initialize raw socket int sock_fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); int n, error_port; char recvbuf[2000]; while (1) { n = recvfrom(sock_fd, &recvbuf, sizeof(recvbuf), 0, NULL, 0); if (n > 0) { ip = (struct ip*) recvbuf; // start of ip header hlen1 = ip->ip_hl << 2; // length of ip header icmp = (struct icmp*) (recvbuf + hlen1); // start of icmp header if ((icmp_len = n - hlen1) < 8) continue; // icmp header not arrived if (icmp->icmp_type == ICMP_UNREACH && icmp->icmp_code == ICMP_UNREACH_PORT) { if (icmp_len < 8 + sizeof(struct ip)) continue; // not enough data to look at ip ip_hdr = (struct ip*) (recvbuf + hlen1 + 8); hlen2 = ip_hdr->ip_hl << 2; if (icmp_len < 8 + hlen2 + 4) continue; // not enough to see ports udp = (struct udphdr*) (recvbuf + hlen1 + 8 + hlen2); error_port = ntohs(udp->dest); if (FD_ISSET(error_port, &result)) FD_CLR(error_port, &result); } } } } void* tcp_port_checker(void* args) { struct timeval tval; fd_set rset, wset; int i; for (i = start; i <= end; i++) { int sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); fcntl(sock_fd, F_SETFL, fcntl(sock_fd, F_GETFL, 0) | O_NONBLOCK); check_address.sin_port = htons(i); if (connect(sock_fd, (struct sockaddr*) &check_address, sizeof(struct sockaddr)) == -1) { if (errno != EINPROGRESS) { #ifdef DEBUG printf("tcp port %d not open\n", i); #endif close(sock_fd); continue; } else { FD_ZERO(&rset); FD_ZERO(&wset); FD_SET(sock_fd, &rset); FD_SET(sock_fd, &wset); tval.tv_sec = 1; tval.tv_usec = 0; if (select(sock_fd + 1, &rset, &wset, NULL, &tval) == 0) { close(sock_fd); #ifdef DEBUG printf("tcp port %d not open\n", i); #endif } else { if (FD_ISSET(sock_fd, &rset) || FD_ISSET(sock_fd, &wset)) printf("tcp port %d open\n", i); } } } else { printf("tcp port %d open\n", i); } close(sock_fd); } }
the_stack_data/178264986.c
/* * Copyright (c) 2017 Pedro Falcato * This file is part of Onyx, and is released under the terms of the MIT License * check LICENSE at the root directory for more information */ #include <stdio.h> #include <unistd.h> #include <stdbool.h> #include <sys/utsname.h> bool print_os_name = false; bool hardware_type = false; bool node = false; bool release = false; bool current_version = false; void invalid_flag() { printf("Usage: uname [-amnsv]\n"); } int main(int argc, char **argv, char **envp) { if(argc < 2) print_os_name = true; int chr; while((chr = getopt(argc, argv, "amnrsv")) != -1) { switch(chr) { case 'a': { print_os_name = true; hardware_type = true; node = true; release = true; current_version = true; break; } case 'm': { hardware_type = true; break; } case 'n': { node = true; break; } case 'r': { release = true; break; } case 's': { print_os_name = true; break; } case 'v': { current_version = true; break; } default: invalid_flag(); } } struct utsname info; if(uname(&info) < 0) { perror("uname"); return 1; } if(print_os_name) printf("%s ", info.sysname); if(node) printf("%s ", info.nodename); if(release) printf("%s ", info.release); if(current_version) printf("%s ", info.version); if(hardware_type) printf("%s ", info.machine); printf("\n"); return 0; }
the_stack_data/225144366.c
#include <stdlib.h> #include <stdarg.h> void f1(int a,int b,int c,int d,int e, int f,int g,int h,int i,int j, int k,int l,int m,int n,int o) { return; } inline void debug(const char *msg,...) { va_list ap; va_start( ap, msg ); f1(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); if ( va_arg(ap,int) != 101) abort(); if ( va_arg(ap,int) != 102) abort(); if ( va_arg(ap,int) != 103) abort(); if ( va_arg(ap,int) != 104) abort(); if ( va_arg(ap,int) != 105) abort(); if ( va_arg(ap,int) != 106) abort(); va_end( ap ); } int main(void) { debug("%d %d %d %d %d %d\n", 101, 102, 103, 104, 105, 106); exit(0); }
the_stack_data/764468.c
/* rtstat.c: A program for route cache monitoring * * Copyright 2001 by Robert Olsson <[email protected]> * Uppsala University, Sweden * * This program 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. * * Additional credits: * Martin Josefsson <[email protected]> 010828 bug fix * */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <getopt.h> #define VERSION "0.33 010829" extern char *optarg; extern int optind, opterr, optopt; FILE *fp; unsigned rt_size, in_hit[2], in_slow_tot[2], in_slow_mc[2], in_no_rt[2], in_brd[2], in_martian_dst[2], in_martian_src[2], out_hit[2], out_slow_tot[2], out_slow_mc[2]; /* Read (and summarize for SMP) the different stats vars. */ void scan_line(int i) { unsigned temp[10]; in_hit[i] = 0; in_slow_tot[i] = 0; in_slow_mc[i] = 0; in_no_rt[i] = 0; in_brd[i] = 0; in_martian_dst[i] = 0; in_martian_src[i] = 0; out_hit[i] = 0; out_slow_tot[i] = 0; out_slow_mc[i] = 0; while(!feof(fp)) { fscanf(fp, "%x %x %x %x %x %x %x %x %x %x %x\n", &rt_size, &temp[0], /* in_hit */ &temp[1], /* in_slow_tot */ &temp[2], /* in_slow_mc */ &temp[3], /* in_no_rt */ &temp[4], /* in_brd */ &temp[5], /* in_martian_dst */ &temp[6], /* in_martian_src */ &temp[7], /* out_hit */ &temp[8], /* out_slow_tot */ &temp[9] /* out_slow_mc */ ); in_hit[i] += temp[0]; in_slow_tot[i] += temp[1]; in_slow_mc[i] += temp[2]; in_no_rt[i] += temp[3]; in_brd[i] += temp[4]; in_martian_dst[i] += temp[5]; in_martian_src[i] += temp[6]; out_hit[i] += temp[7]; out_slow_tot[i] += temp[8]; out_slow_mc[i] += temp[9]; } return; } void print_hdr_line(void) { printf(" size IN: hit tot mc no_rt bcast madst masrc OUT: hit tot mc\n"); } int usage(int exit_code) { fprintf(stderr, "rtstat Version %s\n", VERSION); fprintf(stderr, " -help\n"); fprintf(stderr, " -i interval\n"); fprintf(stderr, " -s subject [0-2]\n"); fprintf(stderr, "\n"); print_hdr_line(); fprintf(stderr, "\n"); fprintf(stderr, "size == route cache size\n"); fprintf(stderr, "hit == IN: total number of cache hits per sec\n"); fprintf(stderr, "tot == IN: total number of cache misses per sec\n"); fprintf(stderr, "mc == IN: mulicast cache misses per sec\n"); fprintf(stderr, "no_rt == IN: route table misses per sec\n"); fprintf(stderr, "bcast == IN: broadcast cache misses per sec\n"); fprintf(stderr, "madst == IN: dst martians per sec\n"); fprintf(stderr, "masrc == IN: src martians per sec\n"); fprintf(stderr, "hit == OUT: total number of cache hits per sec\n"); fprintf(stderr, "tot == OUT: total number of cache misses per sec\n"); fprintf(stderr, "mc == OUT: mulicast cache misses per sec\n"); exit(exit_code); } int main(int argc, char **argv) { int c, i=1, interval=2, hdr=2; while ((c=getopt(argc, argv,"h?s:i:")) != EOF) switch (c) { case '?': case 'h': usage(0); case 'i': sscanf(optarg, "%u", &interval); break; case 's': sscanf(optarg, "%u", &hdr); break; default: usage(1); } if(interval < 1 ) interval=1; if ((fp = fopen("/proc/net/rt_cache_stat", "r"))); else { perror("fopen"); exit(-1); } if(hdr > 0) print_hdr_line(); for(;1;i++) { if(hdr > 1 && (! (i % 20))) print_hdr_line(); scan_line(0); sleep(interval); rewind(fp); scan_line(1); rewind(fp); printf("%5u %9u %7u %5u %5u %5u %5u %5u %9u %7u %6u\n", rt_size, (in_hit[1] - in_hit[0])/interval, (in_slow_tot[1] - in_slow_tot[0])/interval, (in_slow_mc[1] - in_slow_mc[0])/interval, (in_no_rt[1] - in_no_rt[0])/interval, (in_brd[1] - in_brd[0])/interval, (in_martian_dst[1] - in_martian_dst[0])/interval, (in_martian_src[1] - in_martian_src[0])/interval, (out_hit[1] - out_hit[0])/interval, (out_slow_tot[1] - out_slow_tot[0])/interval, (out_slow_mc[1] - out_slow_mc[0])/interval ); } return 1; } /* * Compile: gcc -g -O2 -Wall -o rtstat rtstat.c */
the_stack_data/284973.c
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { FILE *fd = fopen("/home/brendan/S/AoC/AoC-2021/Dec-1/input.txt", "r"); char buff[100]; int previous = 999999; int measurement; int count = 0; while (fgets(buff, 100, fd)) { measurement = atoi(buff); if (measurement > previous) { count += 1; } previous = measurement; } printf("%d\n", count); fclose(fd); return 0; }
the_stack_data/53325.c
// // thread_posix.c // AirFloat // // Copyright (c) 2013, Kristian Trenskow 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. 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 HOLDER // 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. // #if (__APPLE__) #include <stdlib.h> #include <assert.h> #include <pthread.h> #include "log.h" #include "condition.h" #include "thread.h" struct thread_t { thread_start_fnc fnc; void* ctx; pthread_t* thread; }; void* thread_pthread_head(void* ctx) { struct thread_t* t = (struct thread_t*)ctx; t->fnc(t->ctx); pthread_exit(0); } struct thread_t* thread_create_a(thread_start_fnc start_fnc, void* ctx) { struct thread_t* t = (struct thread_t*)malloc(sizeof(struct thread_t)); t->fnc = start_fnc; t->ctx = ctx; t->thread = (pthread_t*)malloc(sizeof(pthread_t)); pthread_create(t->thread, NULL, thread_pthread_head, t); return t; } void thread_destroy(struct thread_t* t) { thread_join(t); free(t); } void thread_set_name(const char* name) { pthread_setname_np(name); } void thread_join(struct thread_t* t) { if (t->thread != NULL) { pthread_join(*t->thread, NULL); free(t->thread); t->thread = NULL; } } #endif
the_stack_data/74463.c
/* * Copyright (C) 2011-2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> /* Read plain address from misc partiton and set the Wifi and BT mac addresses accordingly */ int main() { int fd1, fd2; char macbyte; char macbuf[3]; int i; fd1 = open("/dev/block/bootdevice/by-name/misc",O_RDONLY); fd2 = open("/data/misc/wifi/config",O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); write(fd2,"cur_etheraddr=",14); for (i = 0; i<6; i++) { lseek(fd1,0x3000+i,SEEK_SET); lseek(fd2,0,SEEK_END); read(fd1,&macbyte,1); sprintf(macbuf,"%02x",macbyte); write(fd2,&macbuf,2); if (i!=5) write(fd2,":",1); } write(fd2,"\n",1); close(fd2); fd2 = open("/data/misc/bluetooth/bdaddr",O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); for (i = 0; i<6; i++) { lseek(fd1,0x4000+i,SEEK_SET); lseek(fd2,0,SEEK_END); read(fd1,&macbyte,1); sprintf(macbuf,"%02x",macbyte); write(fd2,&macbuf,2); if (i!=5) write(fd2,":",1); } close(fd2); close(fd1); return 0; }
the_stack_data/179830526.c
#include <float.h> #include <math.h> #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 long double fdiml(long double x, long double y) { return fdim(x, y); } #else long double fdiml(long double x, long double y) { if (isnan(x)) return x; if (isnan(y)) return y; return x > y ? x - y : 0; } #endif
the_stack_data/115818.c
#include<stdio.h> #define N 50 #define L 20 //定义学生类 typedef struct { char name[L]; int math; int en; int total; }Student; int main(int argc, char const *argv[]) { Student arr[N]; //定义学生数组 int n=0; //学生数量 //输入人数 scanf("%d",&n); //输入学生成绩信息 for (int i = 0; i < n; i++)//学生遍历 { scanf("%s %d %d",&arr[i].name,&arr[i].math,&arr[i].en); arr[i].total=arr[i].en+arr[i].math; getchar(); } //输出 for (int i = 0; i < n; i++) { printf("%s %d",arr[i].name,arr[i].total); if (i<n-1) { printf("\n"); } } return 0; }
the_stack_data/132952867.c
/* Autor: luisicu Compilador: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Para compilar: gcc 5factorial.c -o Fecha: Fri Apr 23 17:14:35 CST 2021 Librerías: stdio.h Resumen: Calculadora del factorial de un número Entrada: Un número entero positivo n Salida: El factorial de n: 1*2*...*n=n! */ //Librerías #include <stdio.h> void main(){ int num = 0; int fact = 1; printf("---Calculadora de factorial---\n"); printf("Ingrese el número:\n"); scanf("%d",&num); for(int i = 1; i<=num; i++){ fact = i*fact;//función recursiva que multiplica desde 1 hasta n } printf("%d! = %d \n", num, fact); }
the_stack_data/94125.c
#include<stdio.h> int main(void) { printf("Olá mundo!\n"); return 0; }
the_stack_data/170451748.c
// Copyright 2011 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Simple OpenGL-based WebP file viewer. // // Author: Skal ([email protected]) #ifdef HAVE_CONFIG_H #include "webp/config.h" #endif #if defined(__unix__) || defined(__CYGWIN__) #define _POSIX_C_SOURCE 200112L // for setenv #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #if defined(WEBP_HAVE_GL) #if defined(HAVE_GLUT_GLUT_H) #include <GLUT/glut.h> #else #include <GL/glut.h> #ifdef FREEGLUT #include <GL/freeglut.h> #endif #endif #ifdef WEBP_HAVE_QCMS #include <qcms.h> #endif #include "webp/decode.h" #include "webp/demux.h" #include "../examples/example_util.h" #include "../imageio/imageio_util.h" #include "./unicode.h" #if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf #endif // Unfortunate global variables. Gathered into a struct for comfort. static struct { int has_animation; int has_color_profile; int done; int decoding_error; int print_info; int only_deltas; int use_color_profile; int draw_anim_background_color; int canvas_width, canvas_height; int loop_count; uint32_t bg_color; const char* file_name; WebPData data; WebPDecoderConfig config; const WebPDecBuffer* pic; WebPDemuxer* dmux; WebPIterator curr_frame; WebPIterator prev_frame; WebPChunkIterator iccp; int viewport_width, viewport_height; } kParams; static void ClearPreviousPic(void) { WebPFreeDecBuffer((WebPDecBuffer*)kParams.pic); kParams.pic = NULL; } static void ClearParams(void) { ClearPreviousPic(); WebPDataClear(&kParams.data); WebPDemuxReleaseIterator(&kParams.curr_frame); WebPDemuxReleaseIterator(&kParams.prev_frame); WebPDemuxReleaseChunkIterator(&kParams.iccp); WebPDemuxDelete(kParams.dmux); kParams.dmux = NULL; } // Sets the previous frame to the dimensions of the canvas and has it dispose // to background to cause the canvas to be cleared. static void ClearPreviousFrame(void) { WebPIterator* const prev = &kParams.prev_frame; prev->width = kParams.canvas_width; prev->height = kParams.canvas_height; prev->x_offset = prev->y_offset = 0; prev->dispose_method = WEBP_MUX_DISPOSE_BACKGROUND; } // ----------------------------------------------------------------------------- // Color profile handling static int ApplyColorProfile(const WebPData* const profile, WebPDecBuffer* const rgba) { #ifdef WEBP_HAVE_QCMS int i, ok = 0; uint8_t* line; uint8_t major_revision; qcms_profile* input_profile = NULL; qcms_profile* output_profile = NULL; qcms_transform* transform = NULL; const qcms_data_type input_type = QCMS_DATA_RGBA_8; const qcms_data_type output_type = QCMS_DATA_RGBA_8; const qcms_intent intent = QCMS_INTENT_DEFAULT; if (profile == NULL || rgba == NULL) return 0; if (profile->bytes == NULL || profile->size < 10) return 1; major_revision = profile->bytes[8]; qcms_enable_iccv4(); input_profile = qcms_profile_from_memory(profile->bytes, profile->size); // qcms_profile_is_bogus() is broken with ICCv4. if (input_profile == NULL || (major_revision < 4 && qcms_profile_is_bogus(input_profile))) { fprintf(stderr, "Color profile is bogus!\n"); goto Error; } output_profile = qcms_profile_sRGB(); if (output_profile == NULL) { fprintf(stderr, "Error creating output color profile!\n"); goto Error; } qcms_profile_precache_output_transform(output_profile); transform = qcms_transform_create(input_profile, input_type, output_profile, output_type, intent); if (transform == NULL) { fprintf(stderr, "Error creating color transform!\n"); goto Error; } line = rgba->u.RGBA.rgba; for (i = 0; i < rgba->height; ++i, line += rgba->u.RGBA.stride) { qcms_transform_data(transform, line, line, rgba->width); } ok = 1; Error: if (input_profile != NULL) qcms_profile_release(input_profile); if (output_profile != NULL) qcms_profile_release(output_profile); if (transform != NULL) qcms_transform_release(transform); return ok; #else (void)profile; (void)rgba; return 1; #endif // WEBP_HAVE_QCMS } //------------------------------------------------------------------------------ // File decoding static int Decode(void) { // Fills kParams.curr_frame const WebPIterator* const curr = &kParams.curr_frame; WebPDecoderConfig* const config = &kParams.config; WebPDecBuffer* const output_buffer = &config->output; int ok = 0; ClearPreviousPic(); output_buffer->colorspace = MODE_RGBA; ok = (WebPDecode(curr->fragment.bytes, curr->fragment.size, config) == VP8_STATUS_OK); if (!ok) { fprintf(stderr, "Decoding of frame #%d failed!\n", curr->frame_num); } else { kParams.pic = output_buffer; if (kParams.use_color_profile) { ok = ApplyColorProfile(&kParams.iccp.chunk, output_buffer); if (!ok) { fprintf(stderr, "Applying color profile to frame #%d failed!\n", curr->frame_num); } } } return ok; } static void decode_callback(int what) { if (what == 0 && !kParams.done) { int duration = 0; if (kParams.dmux != NULL) { WebPIterator* const curr = &kParams.curr_frame; if (!WebPDemuxNextFrame(curr)) { WebPDemuxReleaseIterator(curr); if (WebPDemuxGetFrame(kParams.dmux, 1, curr)) { --kParams.loop_count; kParams.done = (kParams.loop_count == 0); if (kParams.done) return; ClearPreviousFrame(); } else { kParams.decoding_error = 1; kParams.done = 1; return; } } duration = curr->duration; // Behavior copied from Chrome, cf: // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/ // platform/graphics/DeferredImageDecoder.cpp? // rcl=b4c33049f096cd283f32be9a58b9a9e768227c26&l=246 if (duration <= 10) duration = 100; } if (!Decode()) { kParams.decoding_error = 1; kParams.done = 1; } else { glutPostRedisplay(); glutTimerFunc(duration, decode_callback, what); } } } //------------------------------------------------------------------------------ // Callbacks static void HandleKey(unsigned char key, int pos_x, int pos_y) { // Note: rescaling the window or toggling some features during an animation // generates visual artifacts. This is not fixed because refreshing the frame // may require rendering the whole animation from start till current frame. (void)pos_x; (void)pos_y; if (key == 'q' || key == 'Q' || key == 27 /* Esc */) { #ifdef FREEGLUT glutLeaveMainLoop(); #else ClearParams(); exit(0); #endif } else if (key == 'c') { if (kParams.has_color_profile && !kParams.decoding_error) { kParams.use_color_profile = 1 - kParams.use_color_profile; if (kParams.has_animation) { // Restart the completed animation to pickup the color profile change. if (kParams.done && kParams.loop_count == 0) { kParams.loop_count = (int)WebPDemuxGetI(kParams.dmux, WEBP_FF_LOOP_COUNT) + 1; kParams.done = 0; // Start the decode loop immediately. glutTimerFunc(0, decode_callback, 0); } } else { Decode(); glutPostRedisplay(); } } } else if (key == 'b') { kParams.draw_anim_background_color = 1 - kParams.draw_anim_background_color; if (!kParams.has_animation) ClearPreviousFrame(); glutPostRedisplay(); } else if (key == 'i') { kParams.print_info = 1 - kParams.print_info; if (!kParams.has_animation) ClearPreviousFrame(); glutPostRedisplay(); } else if (key == 'd') { kParams.only_deltas = 1 - kParams.only_deltas; glutPostRedisplay(); } } static void HandleReshape(int width, int height) { // Note: reshape doesn't preserve aspect ratio, and might // be handling larger-than-screen pictures incorrectly. glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); kParams.viewport_width = width; kParams.viewport_height = height; if (!kParams.has_animation) ClearPreviousFrame(); } static void PrintString(const char* const text) { void* const font = GLUT_BITMAP_9_BY_15; int i; for (i = 0; text[i]; ++i) { glutBitmapCharacter(font, text[i]); } } static float GetColorf(uint32_t color, int shift) { return ((color >> shift) & 0xff) / 255.f; } static void DrawCheckerBoard(void) { const int square_size = 8; // must be a power of 2 int x, y; GLint viewport[4]; // x, y, width, height glPushMatrix(); glGetIntegerv(GL_VIEWPORT, viewport); // shift to integer coordinates with (0,0) being top-left. glOrtho(0, viewport[2], viewport[3], 0, -1, 1); for (y = 0; y < viewport[3]; y += square_size) { for (x = 0; x < viewport[2]; x += square_size) { const GLubyte color = 128 + 64 * (!((x + y) & square_size)); glColor3ub(color, color, color); glRecti(x, y, x + square_size, y + square_size); } } glPopMatrix(); } static void DrawBackground(void) { // Whole window cleared with clear color, checkerboard rendered on top of it. glClear(GL_COLOR_BUFFER_BIT); DrawCheckerBoard(); // ANIM background color rendered (blend) on top. Default is white for still // images (without ANIM chunk). glClear() can't be used for that (no blend). if (kParams.draw_anim_background_color) { glPushMatrix(); glLoadIdentity(); glColor4f(GetColorf(kParams.bg_color, 16), // BGRA from spec GetColorf(kParams.bg_color, 8), GetColorf(kParams.bg_color, 0), GetColorf(kParams.bg_color, 24)); glRecti(-1, -1, +1, +1); glPopMatrix(); } } // Draw background in a scissored rectangle. static void DrawBackgroundScissored(int window_x, int window_y, int frame_w, int frame_h) { // Only update the requested area, not the whole canvas. window_x = window_x * kParams.viewport_width / kParams.canvas_width; window_y = window_y * kParams.viewport_height / kParams.canvas_height; frame_w = frame_w * kParams.viewport_width / kParams.canvas_width; frame_h = frame_h * kParams.viewport_height / kParams.canvas_height; // glScissor() takes window coordinates (0,0 at bottom left). window_y = kParams.viewport_height - window_y - frame_h; glEnable(GL_SCISSOR_TEST); glScissor(window_x, window_y, frame_w, frame_h); DrawBackground(); glDisable(GL_SCISSOR_TEST); } static void HandleDisplay(void) { const WebPDecBuffer* const pic = kParams.pic; const WebPIterator* const curr = &kParams.curr_frame; WebPIterator* const prev = &kParams.prev_frame; GLfloat xoff, yoff; if (pic == NULL) return; glPushMatrix(); glPixelZoom((GLfloat)(+1. / kParams.canvas_width * kParams.viewport_width), (GLfloat)(-1. / kParams.canvas_height * kParams.viewport_height)); xoff = (GLfloat)(2. * curr->x_offset / kParams.canvas_width); yoff = (GLfloat)(2. * curr->y_offset / kParams.canvas_height); glRasterPos2f(-1.f + xoff, 1.f - yoff); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ROW_LENGTH, pic->u.RGBA.stride / 4); if (kParams.only_deltas) { DrawBackground(); } else { // The rectangle of the previous frame might be different than the current // frame, so we may need to DrawBackgroundScissored for both. if (prev->dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) { // Clear the previous frame rectangle. DrawBackgroundScissored(prev->x_offset, prev->y_offset, prev->width, prev->height); } if (curr->blend_method == WEBP_MUX_NO_BLEND) { // We simulate no-blending behavior by first clearing the current frame // rectangle and then alpha-blending against it. DrawBackgroundScissored(curr->x_offset, curr->y_offset, curr->width, curr->height); } } *prev = *curr; glDrawPixels(pic->width, pic->height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)pic->u.RGBA.rgba); if (kParams.print_info) { char tmp[32]; glColor4f(0.90f, 0.0f, 0.90f, 1.0f); glRasterPos2f(-0.95f, 0.90f); PrintString(kParams.file_name); snprintf(tmp, sizeof(tmp), "Dimension:%d x %d", pic->width, pic->height); glColor4f(0.90f, 0.0f, 0.90f, 1.0f); glRasterPos2f(-0.95f, 0.80f); PrintString(tmp); if (curr->x_offset != 0 || curr->y_offset != 0) { snprintf(tmp, sizeof(tmp), " (offset:%d,%d)", curr->x_offset, curr->y_offset); glRasterPos2f(-0.95f, 0.70f); PrintString(tmp); } } glPopMatrix(); #if defined(__APPLE__) || defined(_WIN32) glFlush(); #else glutSwapBuffers(); #endif } static void StartDisplay(void) { int width = kParams.canvas_width; int height = kParams.canvas_height; int screen_width, screen_height; // TODO(webp:365) GLUT_DOUBLE results in flickering / old frames to be // partially displayed with animated webp + alpha. #if defined(__APPLE__) || defined(_WIN32) glutInitDisplayMode(GLUT_RGBA); #else glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); #endif screen_width = glutGet(GLUT_SCREEN_WIDTH); screen_height = glutGet(GLUT_SCREEN_HEIGHT); if (width > screen_width || height > screen_height) { if (width > screen_width) { height = (height * screen_width + width - 1) / width; width = screen_width; } if (height > screen_height) { width = (width * screen_height + height - 1) / height; height = screen_height; } } glutInitWindowSize(width, height); glutCreateWindow("WebP viewer"); glutDisplayFunc(HandleDisplay); glutReshapeFunc(HandleReshape); glutIdleFunc(NULL); glutKeyboardFunc(HandleKey); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glClearColor(0, 0, 0, 0); // window will be cleared to black (no blend) DrawBackground(); } //------------------------------------------------------------------------------ // Main static void Help(void) { printf( "Usage: vwebp in_file [options]\n\n" "Decodes the WebP image file and visualize it using OpenGL\n" "Options are:\n" " -version ..... print version number and exit\n" " -noicc ....... don't use the icc profile if present\n" " -nofancy ..... don't use the fancy YUV420 upscaler\n" " -nofilter .... disable in-loop filtering\n" " -dither <int> dithering strength (0..100), default=50\n" " -noalphadither disable alpha plane dithering\n" " -usebgcolor .. display background color\n" " -mt .......... use multi-threading\n" " -info ........ print info\n" " -h ........... this help message\n" "\n" "Keyboard shortcuts:\n" " 'c' ................ toggle use of color profile\n" " 'b' ................ toggle background color display\n" " 'i' ................ overlay file information\n" " 'd' ................ disable blending & disposal (debug)\n" " 'q' / 'Q' / ESC .... quit\n"); } int main(int argc, char *argv[]) { int c; WebPDecoderConfig* const config = &kParams.config; WebPIterator* const curr = &kParams.curr_frame; INIT_WARGV(argc, argv); if (!WebPInitDecoderConfig(config)) { fprintf(stderr, "Library version mismatch!\n"); FREE_WARGV_AND_RETURN(-1); } config->options.dithering_strength = 50; config->options.alpha_dithering_strength = 100; kParams.use_color_profile = 1; // Background color hidden by default to see transparent areas. kParams.draw_anim_background_color = 0; for (c = 1; c < argc; ++c) { int parse_error = 0; if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) { Help(); FREE_WARGV_AND_RETURN(0); } else if (!strcmp(argv[c], "-noicc")) { kParams.use_color_profile = 0; } else if (!strcmp(argv[c], "-nofancy")) { config->options.no_fancy_upsampling = 1; } else if (!strcmp(argv[c], "-nofilter")) { config->options.bypass_filtering = 1; } else if (!strcmp(argv[c], "-noalphadither")) { config->options.alpha_dithering_strength = 0; } else if (!strcmp(argv[c], "-usebgcolor")) { kParams.draw_anim_background_color = 1; } else if (!strcmp(argv[c], "-dither") && c + 1 < argc) { config->options.dithering_strength = ExUtilGetInt(argv[++c], 0, &parse_error); } else if (!strcmp(argv[c], "-info")) { kParams.print_info = 1; } else if (!strcmp(argv[c], "-version")) { const int dec_version = WebPGetDecoderVersion(); const int dmux_version = WebPGetDemuxVersion(); printf("WebP Decoder version: %d.%d.%d\nWebP Demux version: %d.%d.%d\n", (dec_version >> 16) & 0xff, (dec_version >> 8) & 0xff, dec_version & 0xff, (dmux_version >> 16) & 0xff, (dmux_version >> 8) & 0xff, dmux_version & 0xff); FREE_WARGV_AND_RETURN(0); } else if (!strcmp(argv[c], "-mt")) { config->options.use_threads = 1; } else if (!strcmp(argv[c], "--")) { if (c < argc - 1) kParams.file_name = (const char*)GET_WARGV(argv, ++c); break; } else if (argv[c][0] == '-') { printf("Unknown option '%s'\n", argv[c]); Help(); FREE_WARGV_AND_RETURN(-1); } else { kParams.file_name = (const char*)GET_WARGV(argv, c); } if (parse_error) { Help(); FREE_WARGV_AND_RETURN(-1); } } if (kParams.file_name == NULL) { printf("missing input file!!\n"); Help(); FREE_WARGV_AND_RETURN(0); } if (!ImgIoUtilReadFile(kParams.file_name, &kParams.data.bytes, &kParams.data.size)) { goto Error; } if (!WebPGetInfo(kParams.data.bytes, kParams.data.size, NULL, NULL)) { fprintf(stderr, "Input file doesn't appear to be WebP format.\n"); goto Error; } kParams.dmux = WebPDemux(&kParams.data); if (kParams.dmux == NULL) { fprintf(stderr, "Could not create demuxing object!\n"); goto Error; } kParams.canvas_width = WebPDemuxGetI(kParams.dmux, WEBP_FF_CANVAS_WIDTH); kParams.canvas_height = WebPDemuxGetI(kParams.dmux, WEBP_FF_CANVAS_HEIGHT); if (kParams.print_info) { printf("Canvas: %d x %d\n", kParams.canvas_width, kParams.canvas_height); } ClearPreviousFrame(); memset(&kParams.iccp, 0, sizeof(kParams.iccp)); kParams.has_color_profile = !!(WebPDemuxGetI(kParams.dmux, WEBP_FF_FORMAT_FLAGS) & ICCP_FLAG); if (kParams.has_color_profile) { #ifdef WEBP_HAVE_QCMS if (!WebPDemuxGetChunk(kParams.dmux, "ICCP", 1, &kParams.iccp)) goto Error; printf("VP8X: Found color profile\n"); #else fprintf(stderr, "Warning: color profile present, but qcms is unavailable!\n" "Build libqcms from Mozilla or Chromium and define WEBP_HAVE_QCMS " "before building.\n"); #endif } if (!WebPDemuxGetFrame(kParams.dmux, 1, curr)) goto Error; kParams.has_animation = (curr->num_frames > 1); kParams.loop_count = (int)WebPDemuxGetI(kParams.dmux, WEBP_FF_LOOP_COUNT); kParams.bg_color = WebPDemuxGetI(kParams.dmux, WEBP_FF_BACKGROUND_COLOR); printf("VP8X: Found %d images in file (loop count = %d)\n", curr->num_frames, kParams.loop_count); // Decode first frame if (!Decode()) goto Error; // Position iterator to last frame. Next call to HandleDisplay will wrap over. // We take this into account by bumping up loop_count. WebPDemuxGetFrame(kParams.dmux, 0, curr); if (kParams.loop_count) ++kParams.loop_count; #if defined(__unix__) || defined(__CYGWIN__) // Work around GLUT compositor bug. // https://bugs.launchpad.net/ubuntu/+source/freeglut/+bug/369891 setenv("XLIB_SKIP_ARGB_VISUALS", "1", 1); #endif // Start display (and timer) glutInit(&argc, argv); #ifdef FREEGLUT glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); #endif StartDisplay(); if (kParams.has_animation) glutTimerFunc(0, decode_callback, 0); glutMainLoop(); // Should only be reached when using FREEGLUT: ClearParams(); FREE_WARGV_AND_RETURN(0); Error: ClearParams(); FREE_WARGV_AND_RETURN(-1); } #else // !WEBP_HAVE_GL int main(int argc, const char *argv[]) { fprintf(stderr, "OpenGL support not enabled in %s.\n", argv[0]); (void)argc; return 0; } #endif //------------------------------------------------------------------------------
the_stack_data/161081567.c
#include <stdio.h> int factor(int n) { int i; int cnt = 0; for (i = 1; i <= n; i++) { if (n % i == 0) { cnt++; } } return cnt; } int prime(int a) { int x; x = factor(a); { if (x == 2) { return 1; } else { return 0; } } } int Reverse(int n) { int r, sum = 0,temp; temp = n; while (n > 0) { r = n % 10; sum = (sum * 10) + r; n = n / 10; } if (temp == sum) return 1; else return 0; } int fun(int i) { int a, c; a = prime(i); if(a==1) { c = Reverse(i); if(c==1) { return 1; } } } int main() { int a, i, n; printf("Please enter the number\n"); scanf("%d", &n); for (i = 1; i <= n; ++i) { a = fun(i); if(a==1) { printf("%d ", i); } } }
the_stack_data/220454704.c
/* * write4.c * * Echo lines of input to the output. Terminate on a ".". Requires basic * functionality for both write and read. * * Invoking as "java nachos.machine.Machine -x write4.coff" will echo * the characters you type at the prompt (using the "../bin/nachos" * script turns off echo). */ #include "stdio.h" #include "stdlib.h" int main () { char buffer[80]; char prompt[4]; int i, n; prompt[0] = '-'; prompt[1] = '>'; prompt[2] = ' '; prompt[3] = '\0'; while (1) { // print the prompt puts (prompt); // read the input terminated by a newline i = 0; do { buffer[i] = getchar (); } while (buffer[i++] != '\n'); buffer[i] = '\0'; // if the input is just a period, then exit if (buffer[0] == '.' && buffer[1] == '\n') { return 0; } // echo the input to the output puts (buffer); } }
the_stack_data/43887784.c
#ifdef STM32F0xx #include "stm32f0xx_hal_rtc.c" #endif #ifdef STM32F1xx #include "stm32f1xx_hal_rtc.c" #endif #ifdef STM32F2xx #include "stm32f2xx_hal_rtc.c" #endif #ifdef STM32F3xx #include "stm32f3xx_hal_rtc.c" #endif #ifdef STM32F4xx #include "stm32f4xx_hal_rtc.c" #endif #ifdef STM32F7xx #include "stm32f7xx_hal_rtc.c" #endif #ifdef STM32G0xx #include "stm32g0xx_hal_rtc.c" #endif #ifdef STM32G4xx #include "stm32g4xx_hal_rtc.c" #endif #ifdef STM32H7xx #include "stm32h7xx_hal_rtc.c" #endif #ifdef STM32L0xx #include "stm32l0xx_hal_rtc.c" #endif #ifdef STM32L1xx #include "stm32l1xx_hal_rtc.c" #endif #ifdef STM32L4xx #include "stm32l4xx_hal_rtc.c" #endif #ifdef STM32MP1xx #include "stm32mp1xx_hal_rtc.c" #endif #ifdef STM32WBxx #include "stm32wbxx_hal_rtc.c" #endif
the_stack_data/212642119.c
/** * Meta test: This fails. Always. */
the_stack_data/1206073.c
#include <stdio.h> #define SIZE 5 int main(void) { int arr[SIZE]; int i = 0, temp; for (i = 0; i < SIZE; i++) scanf("%d", &arr[i]); for (i = 0; i < SIZE - 1; i++) { if (arr[i] > arr[i + 1]) { temp = arr[i + 1]; arr[i + 1] = arr[i]; arr[i] = temp; } } for (i = 0; i < SIZE; i++) printf("%d\n", arr[i]); return 0; }
the_stack_data/40762774.c
/* Two PD getcwd() implementations. Author: Guido van Rossum, CWI Amsterdam, Jan 1991, <[email protected]>. */ #include <stdio.h> #include <errno.h> #ifdef HAVE_GETWD /* Version for BSD systems -- use getwd() */ #ifdef HAVE_SYS_PARAM_H #include <sys/param.h> #endif #ifndef MAXPATHLEN #if defined(PATH_MAX) && PATH_MAX > 1024 #define MAXPATHLEN PATH_MAX #else #define MAXPATHLEN 1024 #endif #endif extern char *getwd(char *); char * getcwd(char *buf, int size) { char localbuf[MAXPATHLEN+1]; char *ret; if (size <= 0) { errno = EINVAL; return NULL; } ret = getwd(localbuf); if (ret != NULL && strlen(localbuf) >= (size_t)size) { errno = ERANGE; return NULL; } if (ret == NULL) { errno = EACCES; /* Most likely error */ return NULL; } strncpy(buf, localbuf, size); return buf; } #else /* !HAVE_GETWD */ /* Version for really old UNIX systems -- use pipe from pwd */ #ifndef PWD_CMD #define PWD_CMD "/bin/pwd" #endif char * getcwd(char *buf, int size) { FILE *fp; char *p; if (size <= 0) { errno = EINVAL; return NULL; } if ((fp = popen(PWD_CMD, "r")) == NULL) return NULL; if (fgets(buf, size, fp) == NULL || pclose(fp) != 0) { errno = EACCES; /* Most likely error */ return NULL; } for (p = buf; *p != '\n'; p++) { if (*p == '\0') { errno = ERANGE; return NULL; } } *p = '\0'; return buf; } #endif /* !HAVE_GETWD */
the_stack_data/319995.c
/* A lexical scanner generated by flex */ /* Scanner skeleton version: * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #include <stdio.h> /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #include <stdlib.h> #include <unistd.h> /* Use prototypes in function declarations. */ #define YY_USE_PROTOS /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define YY_USE_PROTOS #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef __TURBOC__ #pragma warn -rch #pragma warn -use #include <io.h> #include <stdlib.h> #define YY_USE_CONST #define YY_USE_PROTOS #endif #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif #ifdef YY_USE_PROTOS #define YY_PROTO(proto) proto #else #define YY_PROTO(proto) () #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #define YY_BUF_SIZE 16384 typedef struct yy_buffer_state *YY_BUFFER_STATE; extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* The funky do-while in the following #define is used to turn the definition * int a single C statement (which needs a semi-colon terminator). This * avoids problems with code like: * * if ( condition_holds ) * yyless( 5 ); * else * do_something_else(); * * Prior to using the do-while the compiler would get upset at the * "else" because it interpreted the "if" statement as being all * done when it reached the ';' after the yyless() call. */ /* Return all but the first 'n' matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ *yy_cp = yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yytext_ptr ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ typedef unsigned int yy_size_t; struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; static YY_BUFFER_STATE yy_current_buffer = 0; /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". */ #define YY_CURRENT_BUFFER yy_current_buffer /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart YY_PROTO(( FILE *input_file )); void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); void yy_load_buffer_state YY_PROTO(( void )); YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); static int yy_get_next_buffer YY_PROTO(( void )); static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yytext_ptr = yy_bp; \ yyleng = (int) (yy_cp - yy_bp); \ yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; #define YY_NUM_RULES 21 #define YY_END_OF_BUFFER 22 static yyconst short int yy_accept[148] = { 0, 0, 0, 22, 21, 21, 21, 21, 11, 21, 19, 21, 8, 20, 15, 12, 18, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 9, 10, 17, 0, 7, 0, 1, 4, 3, 8, 13, 16, 14, 5, 6, 0, 6, 6, 6, 6, 6, 6, 2, 6, 6, 6, 6, 6, 6, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0 } ; static yyconst int yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 5, 1, 1, 1, 1, 6, 7, 8, 1, 9, 1, 1, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 1, 12, 13, 14, 15, 1, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 1, 18, 1, 1, 1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 16, 28, 29, 30, 31, 32, 33, 16, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 1, 44, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst int yy_meta[45] = { 0, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1 } ; static yyconst short int yy_base[151] = { 0, 0, 0, 171, 466, 138, 146, 147, 466, 138, 466, 139, 117, 466, 112, 110, 97, 39, 40, 41, 42, 46, 54, 47, 48, 64, 67, 49, 76, 45, 83, 81, 84, 466, 466, 466, 88, 87, 65, 466, 466, 466, 39, 466, 466, 466, 466, 90, 86, 99, 100, 102, 103, 112, 115, 119, 124, 121, 125, 128, 134, 127, 140, 147, 148, 149, 156, 161, 163, 164, 178, 181, 183, 187, 181, 466, 188, 190, 196, 184, 200, 209, 217, 215, 216, 224, 223, 233, 237, 239, 238, 242, 243, 246, 247, 251, 255, 261, 264, 265, 273, 280, 281, 283, 287, 288, 295, 296, 297, 300, 302, 301, 303, 310, 323, 324, 328, 336, 337, 341, 344, 346, 350, 354, 358, 360, 359, 362, 364, 372, 380, 382, 374, 390, 394, 395, 396, 402, 408, 412, 403, 415, 416, 424, 425, 431, 434, 466, 459, 462, 46 } ; static yyconst short int yy_def[151] = { 0, 147, 1, 147, 147, 147, 148, 149, 147, 147, 147, 147, 147, 147, 147, 147, 147, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 147, 147, 147, 148, 148, 149, 147, 147, 147, 147, 147, 147, 147, 147, 150, 147, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 147, 147, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 147, 147, 147 } ; static yyconst short int yy_nxt[511] = { 0, 4, 4, 5, 6, 7, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 4, 4, 18, 19, 20, 21, 22, 23, 24, 17, 25, 17, 26, 17, 17, 17, 17, 27, 28, 29, 30, 31, 32, 17, 17, 17, 33, 34, 46, 46, 46, 46, 47, 42, 46, 46, 46, 46, 46, 48, 48, 48, 48, 46, 51, 48, 48, 48, 48, 48, 39, 52, 54, 46, 48, 65, 46, 53, 50, 59, 49, 55, 60, 61, 48, 46, 56, 48, 57, 70, 46, 62, 46, 46, 37, 37, 48, 58, 63, 46, 74, 48, 64, 48, 48, 66, 67, 75, 46, 46, 48, 46, 46, 73, 45, 68, 72, 71, 69, 48, 48, 46, 48, 48, 46, 79, 77, 44, 46, 43, 46, 42, 48, 46, 46, 48, 46, 46, 76, 48, 78, 48, 81, 46, 48, 48, 80, 48, 48, 46, 41, 40, 39, 37, 48, 35, 46, 46, 46, 82, 48, 84, 83, 86, 85, 46, 87, 48, 48, 48, 46, 62, 46, 46, 147, 147, 48, 89, 147, 147, 147, 48, 88, 48, 48, 94, 62, 46, 90, 92, 46, 91, 46, 46, 96, 74, 46, 46, 48, 46, 95, 48, 75, 48, 48, 46, 93, 48, 48, 46, 48, 98, 103, 100, 97, 101, 48, 102, 46, 99, 48, 62, 62, 62, 46, 46, 46, 147, 147, 48, 147, 106, 46, 46, 147, 48, 48, 48, 104, 105, 107, 62, 46, 48, 48, 109, 46, 46, 46, 62, 108, 46, 46, 48, 147, 46, 46, 48, 48, 48, 46, 147, 48, 48, 46, 62, 48, 48, 62, 110, 46, 48, 114, 46, 46, 48, 147, 113, 111, 112, 147, 48, 46, 147, 48, 48, 115, 118, 147, 46, 46, 116, 46, 48, 117, 120, 46, 46, 62, 119, 48, 48, 121, 48, 46, 46, 46, 48, 48, 46, 46, 46, 46, 122, 62, 48, 48, 48, 123, 46, 48, 48, 48, 48, 147, 147, 62, 147, 125, 147, 48, 147, 46, 46, 126, 124, 129, 46, 128, 62, 127, 147, 62, 48, 48, 46, 46, 147, 48, 147, 46, 147, 132, 46, 131, 46, 48, 48, 130, 46, 133, 48, 134, 46, 48, 147, 48, 46, 46, 46, 48, 46, 135, 46, 48, 62, 62, 147, 48, 48, 48, 46, 48, 46, 48, 136, 62, 147, 137, 46, 138, 46, 48, 62, 48, 147, 147, 62, 62, 46, 48, 139, 48, 46, 46, 46, 62, 62, 147, 147, 48, 46, 46, 62, 48, 48, 48, 46, 147, 62, 140, 46, 48, 48, 46, 46, 142, 147, 48, 141, 62, 147, 48, 46, 46, 48, 48, 147, 144, 147, 46, 145, 143, 46, 48, 48, 147, 62, 146, 147, 62, 48, 147, 147, 48, 147, 62, 147, 147, 147, 62, 147, 62, 36, 147, 36, 38, 38, 38, 3, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147 } ; static yyconst short int yy_chk[511] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 18, 19, 20, 150, 42, 29, 21, 23, 24, 27, 17, 18, 19, 20, 22, 20, 29, 21, 23, 24, 27, 38, 20, 21, 25, 22, 27, 26, 20, 19, 23, 18, 21, 23, 24, 25, 28, 22, 26, 22, 29, 31, 25, 30, 32, 37, 36, 28, 22, 25, 47, 48, 31, 26, 30, 32, 28, 28, 48, 49, 50, 47, 51, 52, 32, 16, 28, 31, 30, 28, 49, 50, 53, 51, 52, 54, 52, 50, 15, 55, 14, 57, 12, 53, 56, 58, 54, 61, 59, 49, 55, 51, 57, 54, 60, 56, 58, 53, 61, 59, 62, 11, 9, 7, 6, 60, 5, 63, 64, 65, 55, 62, 57, 56, 59, 58, 66, 61, 63, 64, 65, 67, 60, 68, 69, 3, 0, 66, 65, 0, 0, 0, 67, 64, 68, 69, 68, 63, 70, 65, 67, 71, 66, 72, 79, 69, 74, 73, 76, 70, 77, 68, 71, 74, 72, 79, 78, 67, 73, 76, 80, 77, 71, 77, 72, 70, 72, 78, 73, 81, 71, 80, 79, 78, 76, 83, 84, 82, 0, 0, 81, 0, 81, 86, 85, 0, 83, 84, 82, 80, 80, 82, 83, 87, 86, 85, 86, 88, 90, 89, 84, 85, 91, 92, 87, 0, 93, 94, 88, 90, 89, 95, 0, 91, 92, 96, 88, 93, 94, 87, 89, 97, 95, 93, 98, 99, 96, 0, 92, 90, 91, 0, 97, 100, 0, 98, 99, 94, 97, 0, 101, 102, 95, 103, 100, 96, 99, 104, 105, 100, 98, 101, 102, 101, 103, 106, 107, 108, 104, 105, 109, 111, 110, 112, 102, 103, 106, 107, 108, 105, 113, 109, 111, 110, 112, 0, 0, 104, 0, 107, 0, 113, 0, 114, 115, 108, 106, 113, 116, 111, 109, 110, 0, 112, 114, 115, 117, 118, 0, 116, 0, 119, 0, 116, 120, 115, 121, 117, 118, 114, 122, 117, 119, 118, 123, 120, 0, 121, 124, 126, 125, 122, 127, 120, 128, 123, 119, 122, 0, 124, 126, 125, 129, 127, 132, 128, 121, 125, 0, 123, 130, 124, 131, 129, 126, 132, 0, 0, 129, 128, 133, 130, 127, 131, 134, 135, 136, 131, 130, 0, 0, 133, 137, 140, 132, 134, 135, 136, 138, 0, 133, 134, 139, 137, 140, 141, 142, 136, 0, 138, 135, 140, 0, 139, 143, 144, 141, 142, 0, 139, 0, 145, 141, 137, 146, 143, 144, 0, 138, 142, 0, 143, 145, 0, 0, 146, 0, 145, 0, 0, 0, 146, 0, 144, 148, 0, 148, 149, 149, 149, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "C_lex_analyzer.l" #define INITIAL 0 #line 2 "C_lex_analyzer.l" int COMMENT=0; #line 524 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap YY_PROTO(( void )); #else extern int yywrap YY_PROTO(( void )); #endif #endif #ifndef YY_NO_UNPUT static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif #ifndef yytext_ptr static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen YY_PROTO(( yyconst char * )); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput YY_PROTO(( void )); #else static int input YY_PROTO(( void )); #endif #endif #if YY_STACK_USED static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; #ifndef YY_NO_PUSH_STATE static void yy_push_state YY_PROTO(( int new_state )); #endif #ifndef YY_NO_POP_STATE static void yy_pop_state YY_PROTO(( void )); #endif #ifndef YY_NO_TOP_STATE static int yy_top_state YY_PROTO(( void )); #endif #else #define YY_NO_PUSH_STATE 1 #define YY_NO_POP_STATE 1 #define YY_NO_TOP_STATE 1 #endif #ifdef YY_MALLOC_DECL YY_MALLOC_DECL #else #if __STDC__ #ifndef __cplusplus #include <stdlib.h> #endif #else /* Just try to get by without declaring the routines. This will fail * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) * or sizeof(void*) != sizeof(int). */ #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( yy_current_buffer->yy_is_interactive ) \ { \ int c = '*', n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL int yylex YY_PROTO(( void )) #endif /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 7 "C_lex_analyzer.l" #line 677 "lex.yy.c" if ( yy_init ) { yy_init = 0; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yy_start ) yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_load_buffer_state(); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yy_c_buf_p; /* Support of yytext. */ *yy_cp = yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = yy_start; yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 148 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 466 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yy_hold_char; yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP #line 8 "C_lex_analyzer.l" {printf("%sThis is a PREPROCESSOR DIRECTIVE\n",yytext);} YY_BREAK case 2: YY_RULE_SETUP #line 10 "C_lex_analyzer.l" {printf("\n%s is a KEYWORD",yytext);} YY_BREAK case 3: YY_RULE_SETUP #line 12 "C_lex_analyzer.l" {COMMENT = 1;} YY_BREAK case 4: YY_RULE_SETUP #line 13 "C_lex_analyzer.l" {COMMENT = 0;} YY_BREAK case 5: YY_RULE_SETUP #line 15 "C_lex_analyzer.l" {if(!COMMENT)printf("\nFUNCTION: \n%s",yytext);} YY_BREAK case 6: YY_RULE_SETUP #line 17 "C_lex_analyzer.l" {if(!COMMENT) printf("\n%s is an IDENTIFIER",yytext);} YY_BREAK case 7: YY_RULE_SETUP #line 19 "C_lex_analyzer.l" {if(!COMMENT)printf("\n%s is a STRING",yytext);} YY_BREAK case 8: YY_RULE_SETUP #line 21 "C_lex_analyzer.l" {if(!COMMENT) printf("\n%s is a NUMBER ",yytext);} YY_BREAK case 9: YY_RULE_SETUP #line 23 "C_lex_analyzer.l" {if(!COMMENT) printf("\nBLOCK BEGINS");} YY_BREAK case 10: YY_RULE_SETUP #line 24 "C_lex_analyzer.l" {if(!COMMENT) printf("\nBLOCK ENDS");} YY_BREAK case 11: YY_RULE_SETUP #line 26 "C_lex_analyzer.l" {if(!COMMENT);printf("\n)");} YY_BREAK case 12: YY_RULE_SETUP #line 27 "C_lex_analyzer.l" {if(!COMMENT) printf("\n%s is an ASSIGNMENT OPERATOR",yytext);} YY_BREAK case 13: #line 30 "C_lex_analyzer.l" case 14: #line 31 "C_lex_analyzer.l" case 15: #line 32 "C_lex_analyzer.l" case 16: #line 33 "C_lex_analyzer.l" case 17: #line 34 "C_lex_analyzer.l" case 18: YY_RULE_SETUP #line 34 "C_lex_analyzer.l" {if(!COMMENT) printf("\n%s is a RELATIONAL OPERATOR",yytext);} YY_BREAK case 19: #line 37 "C_lex_analyzer.l" case 20: YY_RULE_SETUP #line 37 "C_lex_analyzer.l" {if(!COMMENT) printf("\n%s is a SEPERATOR",yytext);} YY_BREAK case 21: YY_RULE_SETUP #line 39 "C_lex_analyzer.l" ECHO; YY_BREAK #line 847 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between yy_current_buffer and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yy_n_chars = yy_current_buffer->yy_n_chars; yy_current_buffer->yy_input_file = yyin; yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = yy_c_buf_p; goto yy_find_action; } } else switch ( yy_get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { yy_did_buffer_switch_on_eof = 0; if ( yywrap() ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yy_c_buf_p = &yy_current_buffer->yy_ch_buf[yy_n_chars]; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer() { register char *dest = yy_current_buffer->yy_ch_buf; register char *source = yytext_ptr; register int number_to_move, i; int ret_val; if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( yy_current_buffer->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ #ifdef YY_USES_REJECT YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = yy_current_buffer; int yy_c_buf_p_offset = (int) (yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yy_flex_realloc( (void *) b->yy_ch_buf, b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; #endif } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); yy_current_buffer->yy_n_chars = yy_n_chars; } if ( yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; yy_current_buffer->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; yy_n_chars += number_to_move; yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = yy_start; for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 148 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ #ifdef YY_USE_PROTOS static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) #else static yy_state_type yy_try_NUL_trans( yy_current_state ) yy_state_type yy_current_state; #endif { register int yy_is_jam; register char *yy_cp = yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 148 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 147); return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT #ifdef YY_USE_PROTOS static void yyunput( int c, register char *yy_bp ) #else static void yyunput( c, yy_bp ) int c; register char *yy_bp; #endif { register char *yy_cp = yy_c_buf_p; /* undo effects of setting up yytext */ *yy_cp = yy_hold_char; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = yy_n_chars + 2; register char *dest = &yy_current_buffer->yy_ch_buf[ yy_current_buffer->yy_buf_size + 2]; register char *source = &yy_current_buffer->yy_ch_buf[number_to_move]; while ( source > yy_current_buffer->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); yy_current_buffer->yy_n_chars = yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; yytext_ptr = yy_bp; yy_hold_char = *yy_cp; yy_c_buf_p = yy_cp; } #endif /* ifndef YY_NO_UNPUT */ #ifdef __cplusplus static int yyinput() #else static int input() #endif { int c; *yy_c_buf_p = yy_hold_char; if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) /* This was really a NUL. */ *yy_c_buf_p = '\0'; else { /* need more input */ int offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /* fall through */ case EOB_ACT_END_OF_FILE: { if ( yywrap() ) return EOF; if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + offset; break; } } } c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ *yy_c_buf_p = '\0'; /* preserve yytext */ yy_hold_char = *++yy_c_buf_p; return c; } #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) #else void yyrestart( input_file ) FILE *input_file; #endif { if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_init_buffer( yy_current_buffer, input_file ); yy_load_buffer_state(); } #ifdef YY_USE_PROTOS void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) #else void yy_switch_to_buffer( new_buffer ) YY_BUFFER_STATE new_buffer; #endif { if ( yy_current_buffer == new_buffer ) return; if ( yy_current_buffer ) { /* Flush out information for old buffer. */ *yy_c_buf_p = yy_hold_char; yy_current_buffer->yy_buf_pos = yy_c_buf_p; yy_current_buffer->yy_n_chars = yy_n_chars; } yy_current_buffer = new_buffer; yy_load_buffer_state(); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yy_did_buffer_switch_on_eof = 1; } #ifdef YY_USE_PROTOS void yy_load_buffer_state( void ) #else void yy_load_buffer_state() #endif { yy_n_chars = yy_current_buffer->yy_n_chars; yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; yyin = yy_current_buffer->yy_input_file; yy_hold_char = *yy_c_buf_p; } #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) #else YY_BUFFER_STATE yy_create_buffer( file, size ) FILE *file; int size; #endif { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } #ifdef YY_USE_PROTOS void yy_delete_buffer( YY_BUFFER_STATE b ) #else void yy_delete_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; if ( b == yy_current_buffer ) yy_current_buffer = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yy_flex_free( (void *) b->yy_ch_buf ); yy_flex_free( (void *) b ); } #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE extern int isatty YY_PROTO(( int )); #endif #endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) #else void yy_init_buffer( b, file ) YY_BUFFER_STATE b; FILE *file; #endif { yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; #if YY_ALWAYS_INTERACTIVE b->yy_is_interactive = 1; #else #if YY_NEVER_INTERACTIVE b->yy_is_interactive = 0; #else b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif } #ifdef YY_USE_PROTOS void yy_flush_buffer( YY_BUFFER_STATE b ) #else void yy_flush_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer ) yy_load_buffer_state(); } #ifndef YY_NO_SCAN_BUFFER #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) #else YY_BUFFER_STATE yy_scan_buffer( base, size ) char *base; yy_size_t size; #endif { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer( b ); return b; } #endif #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else YY_BUFFER_STATE yy_scan_string( yy_str ) yyconst char *yy_str; #endif { int len; for ( len = 0; yy_str[len]; ++len ) ; return yy_scan_bytes( yy_str, len ); } #endif #ifndef YY_NO_SCAN_BYTES #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) #else YY_BUFFER_STATE yy_scan_bytes( bytes, len ) yyconst char *bytes; int len; #endif { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) yy_flex_alloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < len; ++i ) buf[i] = bytes[i]; buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #endif #ifndef YY_NO_PUSH_STATE #ifdef YY_USE_PROTOS static void yy_push_state( int new_state ) #else static void yy_push_state( new_state ) int new_state; #endif { if ( yy_start_stack_ptr >= yy_start_stack_depth ) { yy_size_t new_size; yy_start_stack_depth += YY_START_STACK_INCR; new_size = yy_start_stack_depth * sizeof( int ); if ( ! yy_start_stack ) yy_start_stack = (int *) yy_flex_alloc( new_size ); else yy_start_stack = (int *) yy_flex_realloc( (void *) yy_start_stack, new_size ); if ( ! yy_start_stack ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } yy_start_stack[yy_start_stack_ptr++] = YY_START; BEGIN(new_state); } #endif #ifndef YY_NO_POP_STATE static void yy_pop_state() { if ( --yy_start_stack_ptr < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN(yy_start_stack[yy_start_stack_ptr]); } #endif #ifndef YY_NO_TOP_STATE static int yy_top_state() { return yy_start_stack[yy_start_stack_ptr - 1]; } #endif #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif #ifdef YY_USE_PROTOS static void yy_fatal_error( yyconst char msg[] ) #else static void yy_fatal_error( msg ) char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ yytext[yyleng] = yy_hold_char; \ yy_c_buf_p = yytext + n; \ yy_hold_char = *yy_c_buf_p; \ *yy_c_buf_p = '\0'; \ yyleng = n; \ } \ while ( 0 ) /* Internal utility routines. */ #ifndef yytext_ptr #ifdef YY_USE_PROTOS static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) #else static void yy_flex_strncpy( s1, s2, n ) char *s1; yyconst char *s2; int n; #endif { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN #ifdef YY_USE_PROTOS static int yy_flex_strlen( yyconst char *s ) #else static int yy_flex_strlen( s ) yyconst char *s; #endif { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif #ifdef YY_USE_PROTOS static void *yy_flex_alloc( yy_size_t size ) #else static void *yy_flex_alloc( size ) yy_size_t size; #endif { return (void *) malloc( size ); } #ifdef YY_USE_PROTOS static void *yy_flex_realloc( void *ptr, yy_size_t size ) #else static void *yy_flex_realloc( ptr, size ) void *ptr; yy_size_t size; #endif { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } #ifdef YY_USE_PROTOS static void yy_flex_free( void *ptr ) #else static void yy_flex_free( ptr ) void *ptr; #endif { free( ptr ); } #if YY_MAIN int main() { yylex(); return 0; } #endif #line 39 "C_lex_analyzer.l" int main(int argc, char **argv) { FILE *file; file=fopen("input.c","r"); if(!file) { printf("could not open the file"); exit(0); } yyin=file; yylex(); printf("\n"); return(0); } int yywrap() { return(1); }
the_stack_data/7949341.c
// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. // See gfxfont.h for newer custom bitmap font info. // Standard ASCII 5x7 font static const unsigned char font[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old // code 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP }; // allow clean compilation with [-Wunused-const-variable=] and [-Wall] static inline void avoid_unused_const_variable_compiler_warning(void) { (void)font; }
the_stack_data/76930.c
/* Code generated from eC source file: ecp.ec */ #if defined(_WIN32) #define __runtimePlatform 1 #elif defined(__APPLE__) #define __runtimePlatform 3 #else #define __runtimePlatform 2 #endif #if defined(__GNUC__) typedef long long int64; typedef unsigned long long uint64; #ifndef _WIN32 #define __declspec(x) #endif #elif defined(__TINYC__) #include <stdarg.h> #define __builtin_va_list va_list #define __builtin_va_start va_start #define __builtin_va_end va_end #ifdef _WIN32 #define strcasecmp stricmp #define strncasecmp strnicmp #define __declspec(x) __attribute__((x)) #else #define __declspec(x) #endif typedef long long int64; typedef unsigned long long uint64; #else typedef __int64 int64; typedef unsigned __int64 uint64; #endif #ifdef __BIG_ENDIAN__ #define __ENDIAN_PAD(x) (8 - (x)) #else #define __ENDIAN_PAD(x) 0 #endif #if defined(_WIN32) # if defined(__GNUC__) || defined(__TINYC__) # define ecere_stdcall __attribute__((__stdcall__)) # define ecere_gcc_struct __attribute__((gcc_struct)) # else # define ecere_stdcall __stdcall # define ecere_gcc_struct # endif #else # define ecere_stdcall # define ecere_gcc_struct #endif #include <stdint.h> #include <sys/types.h> extern int yydebug; enum yytokentype { IDENTIFIER = 258, CONSTANT = 259, STRING_LITERAL = 260, SIZEOF = 261, PTR_OP = 262, INC_OP = 263, DEC_OP = 264, LEFT_OP = 265, RIGHT_OP = 266, LE_OP = 267, GE_OP = 268, EQ_OP = 269, NE_OP = 270, AND_OP = 271, OR_OP = 272, MUL_ASSIGN = 273, DIV_ASSIGN = 274, MOD_ASSIGN = 275, ADD_ASSIGN = 276, SUB_ASSIGN = 277, LEFT_ASSIGN = 278, RIGHT_ASSIGN = 279, AND_ASSIGN = 280, XOR_ASSIGN = 281, OR_ASSIGN = 282, TYPE_NAME = 283, TYPEDEF = 284, EXTERN = 285, STATIC = 286, AUTO = 287, REGISTER = 288, CHAR = 289, SHORT = 290, INT = 291, UINT = 292, INT64 = 293, INT128 = 294, FLOAT128 = 295, LONG = 296, SIGNED = 297, UNSIGNED = 298, FLOAT = 299, DOUBLE = 300, CONST = 301, VOLATILE = 302, VOID = 303, VALIST = 304, STRUCT = 305, UNION = 306, ENUM = 307, ELLIPSIS = 308, CASE = 309, DEFAULT = 310, IF = 311, SWITCH = 312, WHILE = 313, DO = 314, FOR = 315, GOTO = 316, CONTINUE = 317, BREAK = 318, RETURN = 319, IFX = 320, ELSE = 321, CLASS = 322, THISCLASS = 323, PROPERTY = 324, SETPROP = 325, GETPROP = 326, NEWOP = 327, RENEW = 328, DELETE = 329, EXT_DECL = 330, EXT_STORAGE = 331, IMPORT = 332, DEFINE = 333, VIRTUAL = 334, ATTRIB = 335, PUBLIC = 336, PRIVATE = 337, TYPED_OBJECT = 338, ANY_OBJECT = 339, _INCREF = 340, EXTENSION = 341, ASM = 342, TYPEOF = 343, WATCH = 344, STOPWATCHING = 345, FIREWATCHERS = 346, WATCHABLE = 347, CLASS_DESIGNER = 348, CLASS_NO_EXPANSION = 349, CLASS_FIXED = 350, ISPROPSET = 351, CLASS_DEFAULT_PROPERTY = 352, PROPERTY_CATEGORY = 353, CLASS_DATA = 354, CLASS_PROPERTY = 355, SUBCLASS = 356, NAMESPACE = 357, NEW0OP = 358, RENEW0 = 359, VAARG = 360, DBTABLE = 361, DBFIELD = 362, DBINDEX = 363, DATABASE_OPEN = 364, ALIGNOF = 365, ATTRIB_DEP = 366, __ATTRIB = 367, BOOL = 368, _BOOL = 369, _COMPLEX = 370, _IMAGINARY = 371, RESTRICT = 372, THREAD = 373, WIDE_STRING_LITERAL = 374, BUILTIN_OFFSETOF = 375, PRAGMA = 376 }; int yyparse(void); static unsigned int globalInstance = 0; static struct Context * globalContext; extern struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__Platform_char__PTR_; struct __ecereNameSpace__ecere__sys__BTNode; struct __ecereNameSpace__ecere__sys__OldList { void * first; void * last; int count; unsigned int offset; unsigned int circ; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__DataValue { union { char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; void * p; float f; double d; long long i64; uint64 ui64; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__SerialBuffer { unsigned char * _buffer; size_t count; size_t _size; size_t pos; } ecere_gcc_struct; extern void * __ecereNameSpace__ecere__com__eSystem_New(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew(void * memory, unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew0(void * memory, unsigned int size); extern void __ecereNameSpace__ecere__com__eSystem_Delete(void * memory); struct Initializer; struct TypeName; struct Statement; struct Attrib; struct ExtDecl; struct Attribute; struct MembersInit; struct MemberInit; struct PropertyWatch; struct DBTableDef; struct CodePosition { int line; int charPos; int pos; int included; } ecere_gcc_struct; struct ModuleImport; struct ClassImport; extern char * __ecereNameSpace__ecere__sys__CopyString(const char * string); extern int strtol(const char * , char * * , int base); extern char * strcpy(char * , const char * ); extern char * strcat(char * , const char * ); extern void SetParsingType(unsigned int b); extern int strcmp(const char * , const char * ); extern char * PrintInt64(long long result); extern int printf(const char * , ...); extern const char * __ecereNameSpace__ecere__GetTranslatedString(const char * name, const char * string, const char * stringAndContext); struct __ecereNameSpace__ecere__com__LinkList { void * first; void * last; int count; } ecere_gcc_struct; extern void SetCurrentNameSpace(const char * s); extern void __ecereNameSpace__ecere__sys__ChangeCh(char * string, char ch1, char ch2); extern int GetRuntimeBits(void); extern size_t strlen(const char * ); extern char * PassArg(char * output, const char * input); extern const char * GetOutputFile(void); extern void SetOutputFile(const char * s); extern const char * GetSourceFile(void); extern void SetSourceFile(const char * s); extern void SetSymbolsDir(const char * s); extern void SetDefaultNameSpace(const char * s); extern void SetStrictNameSpaces(unsigned int b); extern void SetI18nModuleName(const char * s); extern const char * GetSymbolsDir(void); extern char * __ecereNameSpace__ecere__sys__PathCat(char * string, const char * addedPath); extern char * __ecereNameSpace__ecere__sys__ChangeExtension(const char * string, const char * ext, char * output); extern void SetInPreCompiler(unsigned int b); extern void SetTargetPlatform(int platform); extern void SetTargetBits(int bits); extern void SetEchoOn(unsigned int b); extern unsigned int __ecereNameSpace__ecere__sys__FileExists(const char * fileName); extern unsigned int __ecereNameSpace__ecere__sys__DeleteFile(const char * fileName); extern int snprintf(char * , size_t, const char * , ...); extern void resetScanner(void); extern void ParseEc(void); extern void SetYydebug(unsigned int b); extern void ProcessDBTableDefinitions(void); extern void FreeIncludeFiles(void); struct __ecereNameSpace__ecere__com__GlobalFunction; const char * __ecereProp___ecereNameSpace__ecere__com__Platform_Get_char__PTR_(int this); int __ecereProp___ecereNameSpace__ecere__com__Platform_Set_char__PTR_(const char * value); static struct __ecereNameSpace__ecere__sys__OldList defines, imports, precompDefines; extern struct __ecereNameSpace__ecere__sys__OldList * MkListOne(void * item); extern struct __ecereNameSpace__ecere__sys__OldList * GetAST(void); struct __ecereNameSpace__ecere__com__EnumClassData { struct __ecereNameSpace__ecere__sys__OldList values; long long largest; } ecere_gcc_struct; extern void SetExcludedSymbols(struct __ecereNameSpace__ecere__sys__OldList * list); extern void SetDefines(struct __ecereNameSpace__ecere__sys__OldList * list); extern void SetImports(struct __ecereNameSpace__ecere__sys__OldList * list); extern void SetPrecompDefines(struct __ecereNameSpace__ecere__sys__OldList * list); extern void FreeASTTree(struct __ecereNameSpace__ecere__sys__OldList * ast); extern void FreeExcludedSymbols(struct __ecereNameSpace__ecere__sys__OldList * excludedSymbols); void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(struct __ecereNameSpace__ecere__sys__OldList * this, void (* freeFn)(void * )); void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(struct __ecereNameSpace__ecere__sys__OldList * this, void * item); struct Location { struct CodePosition start; struct CodePosition end; } ecere_gcc_struct; extern void SetMainModule(struct ModuleImport * moduleImport); extern void FreeModuleImport(struct ModuleImport * imp); extern struct Location yylloc; struct Definition; struct ClassDefine { struct Definition * prev; struct Definition * next; char * name; int type; char * base; struct __ecereNameSpace__ecere__sys__OldList propertiesAndMembers; struct __ecereNameSpace__ecere__sys__OldList classProperties; struct __ecereNameSpace__ecere__sys__OldList methods; unsigned int isRemote; unsigned int isWatchable; unsigned int fixed; unsigned int noExpansion; int accessMode; } ecere_gcc_struct; struct FunctionDefine { struct Definition * prev; struct Definition * next; char * name; int type; char * dataType; } ecere_gcc_struct; struct DataDefine { struct Definition * prev; struct Definition * next; char * name; int type; char * dataType; } ecere_gcc_struct; struct Definition { struct Definition * prev; struct Definition * next; char * name; int type; } ecere_gcc_struct; extern void FreeModuleDefine(struct Definition * def); void FreeDataDefine(struct DataDefine * data) { (__ecereNameSpace__ecere__com__eSystem_Delete(data->name), data->name = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(data->dataType), data->dataType = 0); } struct MethodDefine; struct MethodDefine { struct MethodDefine * prev, * next; char * name; int memberAccess; char * type; unsigned int isVirtual; } ecere_gcc_struct; void FreeMethodDefine(struct MethodDefine * method) { (__ecereNameSpace__ecere__com__eSystem_Delete(method->name), method->name = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(method->type), method->type = 0); } struct PropertyDefine; struct PropertyDefine { struct PropertyDefine * prev, * next; char * name; int isProperty; char * type; unsigned int isWatchable; int memberAccess; unsigned int isVirtual; unsigned int hasSet, hasGet; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Class; struct __ecereNameSpace__ecere__com__Instance { void * * _vTbl; struct __ecereNameSpace__ecere__com__Class * _class; int _refCount; } ecere_gcc_struct; extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name); extern void __ecereNameSpace__ecere__com__eClass_SetProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, long long value); extern void __ecereNameSpace__ecere__com__eEnum_AddFixedValue(struct __ecereNameSpace__ecere__com__Class * _class, const char * string, long long value); extern long long __ecereNameSpace__ecere__com__eEnum_AddValue(struct __ecereNameSpace__ecere__com__Class * _class, const char * string); extern void * __ecereNameSpace__ecere__com__eInstance_New(struct __ecereNameSpace__ecere__com__Class * _class); extern void __ecereNameSpace__ecere__com__eInstance_SetMethod(struct __ecereNameSpace__ecere__com__Instance * instance, const char * name, void * function); extern void __ecereNameSpace__ecere__com__eInstance_IncRef(struct __ecereNameSpace__ecere__com__Instance * instance); extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__sys__FileOpen(const char * fileName, int mode); extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__sys__DualPipeOpen(unsigned int mode, const char * commandLine); extern void SetFileInput(struct __ecereNameSpace__ecere__com__Instance * file); int __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(struct __ecereNameSpace__ecere__com__Instance * this, const char * format, ...); int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Puts; extern void __ecereNameSpace__ecere__com__eInstance_DecRef(struct __ecereNameSpace__ecere__com__Instance * instance); int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof; int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Read; int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Write; int __ecereMethod___ecereNameSpace__ecere__sys__DualPipe_GetExitCode(); int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek; struct Declarator; extern char * StringFromSpecDecl(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl); struct TemplateDatatype { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * decl; } ecere_gcc_struct; struct Expression; struct Define { struct Definition * prev; struct Definition * next; char * name; int type; struct Expression * exp; } ecere_gcc_struct; extern void ProcessExpressionType(struct Expression * exp); extern void ComputeExpression(struct Expression * exp); extern void FreeExpression(struct Expression * exp); extern void FreeExpContents(struct Expression * exp); extern void PrintExpression(struct Expression * exp, char * string); extern void OutputExpression(struct Expression * exp, struct __ecereNameSpace__ecere__com__Instance * f); struct Type; extern struct Type * ProcessType(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl); extern void PrintType(struct Type * type, char * string, unsigned int printName, unsigned int fullName); extern void FreeType(struct Type * type); extern struct Type * ProcessTypeString(const char * string, unsigned int staticMethod); struct __ecereNameSpace__ecere__com__DataMember; extern struct __ecereNameSpace__ecere__com__DataMember * __ecereNameSpace__ecere__com__eMember_AddDataMember(struct __ecereNameSpace__ecere__com__DataMember * member, const char * name, const char * type, unsigned int size, unsigned int alignment, int declMode); extern struct __ecereNameSpace__ecere__com__DataMember * __ecereNameSpace__ecere__com__eClass_AddDataMember(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, const char * type, unsigned int size, unsigned int alignment, int declMode); extern struct __ecereNameSpace__ecere__com__DataMember * __ecereNameSpace__ecere__com__eMember_New(int type, int declMode); extern unsigned int __ecereNameSpace__ecere__com__eMember_AddMember(struct __ecereNameSpace__ecere__com__DataMember * addTo, struct __ecereNameSpace__ecere__com__DataMember * dataMember); extern unsigned int __ecereNameSpace__ecere__com__eClass_AddMember(struct __ecereNameSpace__ecere__com__Class * _class, struct __ecereNameSpace__ecere__com__DataMember * dataMember); struct __ecereNameSpace__ecere__sys__NamedLink64; struct __ecereNameSpace__ecere__sys__NamedLink64 { struct __ecereNameSpace__ecere__sys__NamedLink64 * prev; struct __ecereNameSpace__ecere__sys__NamedLink64 * next; char * name; long long data; } ecere_gcc_struct; struct Symbol; extern struct Symbol * FindClass(const char * name); struct ImportedModule; struct ImportedModule { struct ImportedModule * prev; struct ImportedModule * next; char * name; int type; int importType; unsigned int globalInstance; unsigned int dllOnly; int importAccess; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__NameSpace; extern void SetGlobalData(struct __ecereNameSpace__ecere__com__NameSpace * nameSpace); struct Context; extern void SetGlobalContext(struct Context * context); extern void SetCurrentContext(struct Context * context); extern void SetTopContext(struct Context * context); extern void FreeContext(struct Context * context); struct __ecereNameSpace__ecere__sys__BinaryTree; struct __ecereNameSpace__ecere__sys__BinaryTree { struct __ecereNameSpace__ecere__sys__BTNode * root; int count; int (* CompareKey)(struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t a, uintptr_t b); void (* FreeKey)(void * key); } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__NameSpace { const char * name; struct __ecereNameSpace__ecere__com__NameSpace * btParent; struct __ecereNameSpace__ecere__com__NameSpace * left; struct __ecereNameSpace__ecere__com__NameSpace * right; int depth; struct __ecereNameSpace__ecere__com__NameSpace * parent; struct __ecereNameSpace__ecere__sys__BinaryTree nameSpaces; struct __ecereNameSpace__ecere__sys__BinaryTree classes; struct __ecereNameSpace__ecere__sys__BinaryTree defines; struct __ecereNameSpace__ecere__sys__BinaryTree functions; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__DataMember { struct __ecereNameSpace__ecere__com__DataMember * prev; struct __ecereNameSpace__ecere__com__DataMember * next; const char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; int type; int offset; int memberID; struct __ecereNameSpace__ecere__sys__OldList members; struct __ecereNameSpace__ecere__sys__BinaryTree membersAlpha; int memberOffset; short structAlignment; short pointerAlignment; } ecere_gcc_struct; unsigned int __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(struct __ecereNameSpace__ecere__sys__BinaryTree * this, struct __ecereNameSpace__ecere__sys__BTNode * node); int __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString(struct __ecereNameSpace__ecere__sys__BinaryTree * this, const char * a, const char * b); struct __ecereNameSpace__ecere__com__Application { int argc; const char * * argv; int exitCode; unsigned int isGUIApp; struct __ecereNameSpace__ecere__sys__OldList allModules; char * parsedCommand; struct __ecereNameSpace__ecere__com__NameSpace systemNameSpace; } ecere_gcc_struct; static struct __ecereNameSpace__ecere__com__NameSpace globalData; extern void FreeGlobalData(struct __ecereNameSpace__ecere__com__NameSpace * globalDataList); extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com____ecere_COM_Initialize(unsigned int guiApp, int argc, char * argv[]); struct DataMemberDefine; struct DataMemberDefine { struct DataMemberDefine * prev, * next; char * name; int isProperty; char * type; struct __ecereNameSpace__ecere__sys__OldList dataMembers; struct __ecereNameSpace__ecere__sys__OldList classProperties; int memberAccess; int memberType; int size, bitPos; } ecere_gcc_struct; void FreeDataMemberDefine(struct DataMemberDefine * dataMember) { (__ecereNameSpace__ecere__com__eSystem_Delete(dataMember->name), dataMember->name = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(dataMember->type), dataMember->type = 0); } void FreeDefinition(struct Definition * definition) { (__ecereNameSpace__ecere__com__eSystem_Delete(definition->name), definition->name = 0); switch(definition->type) { case 1: { struct ClassDefine * classDefine = (struct ClassDefine *)definition; (__ecereNameSpace__ecere__com__eSystem_Delete(classDefine->base), classDefine->base = 0); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&classDefine->methods, (void *)(FreeMethodDefine)); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&classDefine->propertiesAndMembers, (void *)(FreeDataMemberDefine)); break; } case 3: (__ecereNameSpace__ecere__com__eSystem_Delete(((struct FunctionDefine *)definition)->dataType), ((struct FunctionDefine *)definition)->dataType = 0); break; case 4: (__ecereNameSpace__ecere__com__eSystem_Delete(((struct DataDefine *)definition)->dataType), ((struct DataDefine *)definition)->dataType = 0); break; case 2: break; } } struct ClassDef; struct __ecereNameSpace__ecere__com__BitMember; extern struct __ecereNameSpace__ecere__com__BitMember * __ecereNameSpace__ecere__com__eClass_AddBitMember(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, const char * type, int bitSize, int bitPos, int declMode); struct __ecereNameSpace__ecere__com__BitMember { struct __ecereNameSpace__ecere__com__BitMember * prev; struct __ecereNameSpace__ecere__com__BitMember * next; const char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; int type; int size; int pos; uint64 mask; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Property; struct __ecereNameSpace__ecere__com__Property { struct __ecereNameSpace__ecere__com__Property * prev; struct __ecereNameSpace__ecere__com__Property * next; const char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; void (* Set)(void * , int); int (* Get)(void * ); unsigned int (* IsSet)(void * ); void * data; void * symbol; int vid; unsigned int conversion; unsigned int watcherOffset; const char * category; unsigned int compiled; unsigned int selfWatchable; unsigned int isWatchable; } ecere_gcc_struct; extern void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property); extern void __ecereNameSpace__ecere__com__eInstance_StopWatching(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property, struct __ecereNameSpace__ecere__com__Instance * object); extern void __ecereNameSpace__ecere__com__eInstance_Watch(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property, void * object, void (* callback)(void * , void * )); extern void __ecereNameSpace__ecere__com__eInstance_FireWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property); extern struct __ecereNameSpace__ecere__com__Property * __ecereNameSpace__ecere__com__eClass_AddProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, const char * dataType, void * setStmt, void * getStmt, int declMode); struct __ecereNameSpace__ecere__com__ClassProperty; extern struct __ecereNameSpace__ecere__com__ClassProperty * __ecereNameSpace__ecere__com__eClass_AddClassProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, const char * dataType, void * setStmt, void * getStmt); struct __ecereNameSpace__ecere__com__ClassProperty { const char * name; struct __ecereNameSpace__ecere__com__ClassProperty * parent; struct __ecereNameSpace__ecere__com__ClassProperty * left; struct __ecereNameSpace__ecere__com__ClassProperty * right; int depth; void (* Set)(struct __ecereNameSpace__ecere__com__Class *, long long); long long (* Get)(struct __ecereNameSpace__ecere__com__Class *); const char * dataTypeString; struct Type * dataType; unsigned int constant; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Method; struct __ecereNameSpace__ecere__com__ClassTemplateArgument { union { struct { const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; } ecere_gcc_struct __anon1; struct __ecereNameSpace__ecere__com__DataValue expression; struct { const char * memberString; union { struct __ecereNameSpace__ecere__com__DataMember * member; struct __ecereNameSpace__ecere__com__Property * prop; struct __ecereNameSpace__ecere__com__Method * method; } ecere_gcc_struct __anon1; } ecere_gcc_struct __anon2; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Method { const char * name; struct __ecereNameSpace__ecere__com__Method * parent; struct __ecereNameSpace__ecere__com__Method * left; struct __ecereNameSpace__ecere__com__Method * right; int depth; int (* function)(); int vid; int type; struct __ecereNameSpace__ecere__com__Class * _class; void * symbol; const char * dataTypeString; struct Type * dataType; int memberAccess; } ecere_gcc_struct; extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_AddVirtualMethod(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, const char * type, void * function, int declMode); extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_AddMethod(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, const char * type, void * function, int declMode); struct __ecereNameSpace__ecere__com__Module; struct __ecereNameSpace__ecere__com__Module { struct __ecereNameSpace__ecere__com__Instance * application; struct __ecereNameSpace__ecere__sys__OldList classes; struct __ecereNameSpace__ecere__sys__OldList defines; struct __ecereNameSpace__ecere__sys__OldList functions; struct __ecereNameSpace__ecere__sys__OldList modules; struct __ecereNameSpace__ecere__com__Instance * prev; struct __ecereNameSpace__ecere__com__Instance * next; const char * name; void * library; void * Unload; int importType; int origImportType; struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace; struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Class { struct __ecereNameSpace__ecere__com__Class * prev; struct __ecereNameSpace__ecere__com__Class * next; const char * name; int offset; int structSize; void * * _vTbl; int vTblSize; unsigned int (* Constructor)(void * ); void (* Destructor)(void * ); int offsetClass; int sizeClass; struct __ecereNameSpace__ecere__com__Class * base; struct __ecereNameSpace__ecere__sys__BinaryTree methods; struct __ecereNameSpace__ecere__sys__BinaryTree members; struct __ecereNameSpace__ecere__sys__BinaryTree prop; struct __ecereNameSpace__ecere__sys__OldList membersAndProperties; struct __ecereNameSpace__ecere__sys__BinaryTree classProperties; struct __ecereNameSpace__ecere__sys__OldList derivatives; int memberID; int startMemberID; int type; struct __ecereNameSpace__ecere__com__Instance * module; struct __ecereNameSpace__ecere__com__NameSpace * nameSpace; const char * dataTypeString; struct Type * dataType; int typeSize; int defaultAlignment; void (* Initialize)(); int memberOffset; struct __ecereNameSpace__ecere__sys__OldList selfWatchers; const char * designerClass; unsigned int noExpansion; const char * defaultProperty; unsigned int comRedefinition; int count; int isRemote; unsigned int internalDecl; void * data; unsigned int computeSize; short structAlignment; short pointerAlignment; int destructionWatchOffset; unsigned int fixed; struct __ecereNameSpace__ecere__sys__OldList delayedCPValues; int inheritanceAccess; const char * fullName; void * symbol; struct __ecereNameSpace__ecere__sys__OldList conversions; struct __ecereNameSpace__ecere__sys__OldList templateParams; struct __ecereNameSpace__ecere__com__ClassTemplateArgument * templateArgs; struct __ecereNameSpace__ecere__com__Class * templateClass; struct __ecereNameSpace__ecere__sys__OldList templatized; int numParams; unsigned int isInstanceClass; unsigned int byValueSystemClass; void * bindingsClass; } ecere_gcc_struct; static struct __ecereNameSpace__ecere__com__Instance * privateModule; extern struct __ecereNameSpace__ecere__com__Property * __ecereNameSpace__ecere__com__eClass_FindProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, struct __ecereNameSpace__ecere__com__Instance * module); extern struct __ecereNameSpace__ecere__com__DataMember * __ecereNameSpace__ecere__com__eClass_FindDataMember(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, struct __ecereNameSpace__ecere__com__Instance * module, struct __ecereNameSpace__ecere__com__DataMember ** subMemberStack, int * subMemberStackPos); extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_RegisterClass(int type, const char * name, const char * baseName, int size, int sizeClass, unsigned int (* Constructor)(void * ), void (* Destructor)(void * ), struct __ecereNameSpace__ecere__com__Instance * module, int declMode, int inheritanceAccess); extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_FindMethod(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, struct __ecereNameSpace__ecere__com__Instance * module); extern struct __ecereNameSpace__ecere__com__Instance * __thisModule; extern void ComputeModuleClasses(struct __ecereNameSpace__ecere__com__Instance * module); extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_FindClass(struct __ecereNameSpace__ecere__com__Instance * module, const char * name); extern void SetPrivateModule(struct __ecereNameSpace__ecere__com__Instance * module); extern void FreeTypeData(struct __ecereNameSpace__ecere__com__Instance * privateModule); extern struct __ecereNameSpace__ecere__com__GlobalFunction * __ecereNameSpace__ecere__com__eSystem_RegisterFunction(const char * name, const char * type, void * func, struct __ecereNameSpace__ecere__com__Instance * module, int declMode); void __ecereUnregisterModule_ecp(struct __ecereNameSpace__ecere__com__Instance * module) { } static struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassDefine; static struct __ecereNameSpace__ecere__com__Class * __ecereClass_Define; static struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionDefine; static struct __ecereNameSpace__ecere__com__Class * __ecereClass_DataDefine; static struct __ecereNameSpace__ecere__com__Class * __ecereClass_MethodDefine; static struct __ecereNameSpace__ecere__com__Class * __ecereClass_PropertyDefine; static struct __ecereNameSpace__ecere__com__Class * __ecereClass_DataMemberDefine; static struct __ecereNameSpace__ecere__com__Class * __ecereClass_PrecompApp; static void OutputDataMembers(struct ClassDefine * classDefine, struct __ecereNameSpace__ecere__com__Class * _class, struct __ecereNameSpace__ecere__com__Instance * f) { if(classDefine->propertiesAndMembers.first) { struct DataMemberDefine * member = classDefine->propertiesAndMembers.first; int last = 0; for(member = classDefine->propertiesAndMembers.first; member; member = member->next) { if(member->isProperty == 1) { struct PropertyDefine * prop = (struct PropertyDefine *)member; if(last != 1) { if(last) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Defined Properties]\n"); } if(prop->name) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", prop->name); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Conversion]\n"); if(prop->memberAccess == 1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Public]\n"); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Private]\n"); if(prop->isVirtual) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Virtual]\n"); if(prop->hasSet) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Set]\n"); if(prop->hasGet) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Get]\n"); if(prop->isWatchable) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Watchable]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Type]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", prop->type ? prop->type : ""); } else { if(last != 3) { if(last) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Defined Data Members]\n"); } if(member->memberType == 0) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", member->name); if(member->memberAccess == 1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Public]\n"); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Private]\n"); if(_class && _class->type == 2) { if(member->size) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Size]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %d\n", member->size); } if(member->bitPos != -1) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Pos]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %d\n", member->bitPos); } } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Type]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", member->type ? member->type : ""); } else { if(member->memberAccess == 1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Public]\n"); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Private]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, (member->memberType == 1) ? " [Union]\n" : " [Struct]\n"); OutputDataMembers((struct ClassDefine *)member, (((void *)0)), f); } } last = member->isProperty; } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); } if(classDefine->classProperties.first) { struct PropertyDefine * prop = classDefine->propertiesAndMembers.first; __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Defined Class Properties]\n"); for(prop = classDefine->classProperties.first; prop; prop = prop->next) { if(prop->name) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", prop->name); if(prop->hasSet) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Set]\n"); if(prop->hasGet) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Get]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Type]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", prop->type ? prop->type : ""); } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); } } extern void __ecereNameSpace__ecere__com__PrintLn(struct __ecereNameSpace__ecere__com__Class * class, const void * object, ...); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Type; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Symbol; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__TempFile; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ModuleImport; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Context; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Application; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__File; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_char__PTR_; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__DualPipe; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Module; void __ecereCreateModuleInstances_ecp() { globalContext = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context); (globalData.classes.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString, globalData.defines.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString, globalData.functions.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString, globalData.nameSpaces.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString); } void __ecereDestroyModuleInstances_ecp() { ((globalContext ? __extension__ ({ void * __ecerePtrToDelete = (globalContext); __ecereClass_Context->Destructor ? __ecereClass_Context->Destructor((void *)__ecerePtrToDelete) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(__ecerePtrToDelete); }) : 0), globalContext = 0); } struct Identifier; extern struct Identifier * GetDeclId(struct Declarator * decl); extern struct Declarator * MkDeclaratorIdentifier(struct Identifier * id); struct InitDeclarator; struct InitDeclarator { struct InitDeclarator * prev; struct InitDeclarator * next; struct Location loc; struct Declarator * declarator; struct Initializer * initializer; } ecere_gcc_struct; struct Operand; struct OpTable { unsigned int (* Add)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Sub)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Mul)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Div)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Mod)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Neg)(struct Expression *, struct Operand *); unsigned int (* Inc)(struct Expression *, struct Operand *); unsigned int (* Dec)(struct Expression *, struct Operand *); unsigned int (* Asign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* AddAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* SubAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* MulAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* DivAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* ModAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitAnd)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitOr)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitXor)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* LShift)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* RShift)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitNot)(struct Expression *, struct Operand *); unsigned int (* AndAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* OrAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* XorAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* LShiftAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* RShiftAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Not)(struct Expression *, struct Operand *); unsigned int (* Equ)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Nqu)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* And)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Or)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Grt)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Sma)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* GrtEqu)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* SmaEqu)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Cond)(struct Expression *, struct Operand *, struct Operand *, struct Operand *); } ecere_gcc_struct; struct Operand { int kind; struct Type * type; unsigned int ptrSize; union { char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; float f; double d; long long i64; uint64 ui64; } ecere_gcc_struct __anon1; struct OpTable ops; } ecere_gcc_struct; extern struct Operand GetOperand(struct Expression * exp); struct Instantiation; struct ClassFunction; struct ClassFunction { struct ClassFunction * prev; struct ClassFunction * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct __ecereNameSpace__ecere__sys__OldList * declarations; struct Statement * body; struct __ecereNameSpace__ecere__com__Class * _class; struct __ecereNameSpace__ecere__sys__OldList attached; int declMode; struct Type * type; struct Symbol * propSet; unsigned int isVirtual; unsigned int isConstructor; unsigned int isDestructor; unsigned int dontMangle; int id; int idCode; } ecere_gcc_struct; struct ClassDefinition; struct Context { struct Context * parent; struct __ecereNameSpace__ecere__sys__BinaryTree types; struct __ecereNameSpace__ecere__sys__BinaryTree classes; struct __ecereNameSpace__ecere__sys__BinaryTree symbols; struct __ecereNameSpace__ecere__sys__BinaryTree structSymbols; int nextID; int simpleID; struct __ecereNameSpace__ecere__sys__BinaryTree templateTypes; struct ClassDefinition * classDef; unsigned int templateTypesOnly; unsigned int hasNameSpace; } ecere_gcc_struct; struct FunctionDefinition; struct FunctionDefinition { struct FunctionDefinition * prev; struct FunctionDefinition * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct __ecereNameSpace__ecere__sys__OldList * declarations; struct Statement * body; struct __ecereNameSpace__ecere__com__Class * _class; struct __ecereNameSpace__ecere__sys__OldList attached; int declMode; struct Type * type; struct Symbol * propSet; int tempCount; unsigned int propertyNoThis; } ecere_gcc_struct; struct External; struct Symbol { char * string; struct Symbol * parent; struct Symbol * left; struct Symbol * right; int depth; struct Type * type; union { struct __ecereNameSpace__ecere__com__Method * method; struct __ecereNameSpace__ecere__com__Property * _property; struct __ecereNameSpace__ecere__com__Class * registered; } ecere_gcc_struct __anon1; unsigned int notYetDeclared; union { struct { struct External * pointerExternal; struct External * structExternal; } ecere_gcc_struct __anon1; struct { struct External * externalGet; struct External * externalSet; struct External * externalPtr; struct External * externalIsSet; } ecere_gcc_struct __anon2; struct { struct External * methodExternal; struct External * methodCodeExternal; } ecere_gcc_struct __anon3; } ecere_gcc_struct __anon2; unsigned int imported; unsigned int declaredStructSym; struct __ecereNameSpace__ecere__com__Class * _class; unsigned int declaredStruct; unsigned int needConstructor; unsigned int needDestructor; char * constructorName; char * structName; char * className; char * destructorName; struct ModuleImport * module; struct ClassImport * _import; struct Location nameLoc; unsigned int isParam; unsigned int isRemote; unsigned int isStruct; unsigned int fireWatchersDone; int declaring; unsigned int classData; unsigned int isStatic; char * shortName; struct __ecereNameSpace__ecere__sys__OldList * templateParams; struct __ecereNameSpace__ecere__sys__OldList templatedClasses; struct Context * ctx; int isIterator; struct Expression * propCategory; unsigned int mustRegister; } ecere_gcc_struct; struct __ecereNameSpace__ecere__sys__OldList _excludedSymbols = { 0, 0, 0, (unsigned int)(uintptr_t)&((struct Symbol *)(void * )0)->left, 0 }; struct TemplateParameter; struct Type { struct Type * prev; struct Type * next; int refCount; union { struct Symbol * _class; struct { struct __ecereNameSpace__ecere__sys__OldList members; char * enumName; } ecere_gcc_struct __anon1; struct { struct Type * returnType; struct __ecereNameSpace__ecere__sys__OldList params; struct Symbol * thisClass; unsigned int staticMethod; struct TemplateParameter * thisClassTemplate; } ecere_gcc_struct __anon2; struct { struct __ecereNameSpace__ecere__com__Method * method; struct __ecereNameSpace__ecere__com__Class * methodClass; struct __ecereNameSpace__ecere__com__Class * usedClass; } ecere_gcc_struct __anon3; struct { struct Type * arrayType; int arraySize; struct Expression * arraySizeExp; unsigned int freeExp; struct Symbol * enumClass; } ecere_gcc_struct __anon4; struct Type * type; struct TemplateParameter * templateParameter; } ecere_gcc_struct __anon1; int kind; unsigned int size; char * name; char * typeName; struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int promotedFrom; int classObjectType; int alignment; unsigned int offset; int bitFieldCount; int count; int bitMemberSize; unsigned int isSigned : 1; unsigned int constant : 1; unsigned int truth : 1; unsigned int byReference : 1; unsigned int extraParam : 1; unsigned int directClassAccess : 1; unsigned int computing : 1; unsigned int keepCast : 1; unsigned int passAsTemplate : 1; unsigned int dllExport : 1; unsigned int attrStdcall : 1; unsigned int declaredWithStruct : 1; unsigned int typedByReference : 1; unsigned int casted : 1; unsigned int pointerAlignment : 1; unsigned int isLong : 1; unsigned int signedBeforePromotion : 1; unsigned int isVector : 1; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__ClassTemplateParameter; extern struct __ecereNameSpace__ecere__com__ClassTemplateParameter * __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, int type, const void * info, struct __ecereNameSpace__ecere__com__ClassTemplateArgument * defaultArg); struct __ecereNameSpace__ecere__com__ClassTemplateParameter { struct __ecereNameSpace__ecere__com__ClassTemplateParameter * prev; struct __ecereNameSpace__ecere__com__ClassTemplateParameter * next; const char * name; int type; union { const char * dataTypeString; int memberType; } ecere_gcc_struct __anon1; struct __ecereNameSpace__ecere__com__ClassTemplateArgument defaultArg; void * param; } ecere_gcc_struct; void __ecereMethod_PrecompApp_Main(struct __ecereNameSpace__ecere__com__Instance * this); struct Specifier; struct Declarator { struct Declarator * prev; struct Declarator * next; struct Location loc; int type; struct Symbol * symbol; struct Declarator * declarator; union { struct Identifier * identifier; struct { struct Expression * exp; struct Expression * posExp; struct Attrib * attrib; } ecere_gcc_struct structDecl; struct { struct Expression * exp; struct Specifier * enumClass; } ecere_gcc_struct array; struct { struct __ecereNameSpace__ecere__sys__OldList * parameters; } ecere_gcc_struct function; struct { struct __ecereNameSpace__ecere__com__Instance * pointer; } ecere_gcc_struct pointer; struct { struct ExtDecl * extended; } ecere_gcc_struct extended; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct Identifier { struct Identifier * prev; struct Identifier * next; struct Location loc; struct Symbol * classSym; struct Specifier * _class; char * string; struct Identifier * badID; } ecere_gcc_struct; struct Expression { struct Expression * prev; struct Expression * next; struct Location loc; int type; union { struct { char * constant; struct Identifier * identifier; } ecere_gcc_struct __anon1; struct Statement * compound; struct Instantiation * instance; struct { char * string; unsigned int intlString; unsigned int wideString; } ecere_gcc_struct __anon2; struct __ecereNameSpace__ecere__sys__OldList * list; struct { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * decl; } ecere_gcc_struct _classExp; struct { struct Identifier * id; } ecere_gcc_struct classData; struct { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * arguments; struct Location argLoc; } ecere_gcc_struct call; struct { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * index; } ecere_gcc_struct index; struct { struct Expression * exp; struct Identifier * member; int memberType; unsigned int thisPtr; } ecere_gcc_struct member; struct { int op; struct Expression * exp1; struct Expression * exp2; } ecere_gcc_struct op; struct TypeName * typeName; struct Specifier * _class; struct { struct TypeName * typeName; struct Expression * exp; } ecere_gcc_struct cast; struct { struct Expression * cond; struct __ecereNameSpace__ecere__sys__OldList * exp; struct Expression * elseExp; } ecere_gcc_struct cond; struct { struct TypeName * typeName; struct Expression * size; } ecere_gcc_struct _new; struct { struct TypeName * typeName; struct Expression * size; struct Expression * exp; } ecere_gcc_struct _renew; struct { char * table; struct Identifier * id; } ecere_gcc_struct db; struct { struct Expression * ds; struct Expression * name; } ecere_gcc_struct dbopen; struct { struct TypeName * typeName; struct Initializer * initializer; } ecere_gcc_struct initializer; struct { struct Expression * exp; struct TypeName * typeName; } ecere_gcc_struct vaArg; struct { struct TypeName * typeName; struct Identifier * id; } ecere_gcc_struct offset; } ecere_gcc_struct __anon1; unsigned int debugValue; struct __ecereNameSpace__ecere__com__DataValue val; uint64 address; unsigned int hasAddress; struct Type * expType; struct Type * destType; unsigned int usage; int tempCount; unsigned int byReference; unsigned int isConstant; unsigned int addedThis; unsigned int needCast; unsigned int thisPtr; unsigned int opDestType; unsigned int usedInComparison; unsigned int ambiguousUnits; unsigned int parentOpDestType; unsigned int needTemplateCast; } ecere_gcc_struct; struct Specifier { struct Specifier * prev; struct Specifier * next; struct Location loc; int type; union { int specifier; struct { struct ExtDecl * extDecl; char * name; struct Symbol * symbol; struct __ecereNameSpace__ecere__sys__OldList * templateArgs; struct Specifier * nsSpec; } ecere_gcc_struct __anon1; struct { struct Identifier * id; struct __ecereNameSpace__ecere__sys__OldList * list; struct __ecereNameSpace__ecere__sys__OldList * baseSpecs; struct __ecereNameSpace__ecere__sys__OldList * definitions; unsigned int addNameSpace; struct Context * ctx; struct ExtDecl * extDeclStruct; } ecere_gcc_struct __anon2; struct Expression * expression; struct Specifier * _class; struct TemplateParameter * templateParameter; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct Instantiation { struct Instantiation * prev; struct Instantiation * next; struct Location loc; struct Specifier * _class; struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * members; struct Symbol * symbol; unsigned int fullSet; unsigned int isConstant; unsigned char * data; struct Location nameLoc; struct Location insideLoc; unsigned int built; } ecere_gcc_struct; struct ClassDefinition { struct ClassDefinition * prev; struct ClassDefinition * next; struct Location loc; struct Specifier * _class; struct __ecereNameSpace__ecere__sys__OldList * baseSpecs; struct __ecereNameSpace__ecere__sys__OldList * definitions; struct Symbol * symbol; struct Location blockStart; struct Location nameLoc; int declMode; unsigned int deleteWatchable; } ecere_gcc_struct; struct PropertyDef; struct PropertyDef { struct PropertyDef * prev; struct PropertyDef * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct Identifier * id; struct Statement * getStmt; struct Statement * setStmt; struct Statement * issetStmt; struct Symbol * symbol; struct Expression * category; struct { unsigned int conversion : 1; unsigned int isWatchable : 1; unsigned int isDBProp : 1; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct TemplateArgument; struct TemplateParameter { struct TemplateParameter * prev; struct TemplateParameter * next; struct Location loc; int type; struct Identifier * identifier; union { struct TemplateDatatype * dataType; int memberType; } ecere_gcc_struct __anon1; struct TemplateArgument * defaultArgument; const char * dataTypeString; struct Type * baseType; } ecere_gcc_struct; struct TemplateArgument { struct TemplateArgument * prev; struct TemplateArgument * next; struct Location loc; struct Identifier * name; int type; union { struct Expression * expression; struct Identifier * identifier; struct TemplateDatatype * templateDatatype; } ecere_gcc_struct __anon1; } ecere_gcc_struct; static void OutputSymbols(const char * fileName) { struct __ecereNameSpace__ecere__com__Instance * f = __ecereNameSpace__ecere__sys__FileOpen(fileName, 2); if(f) { int lastType = (int)-1; struct Definition * definition; if(globalInstance) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Global Instance]\n"); for(definition = precompDefines.first; definition; definition = definition->next) { if(definition->type != lastType) { if(lastType != (int)-1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); if(definition->type == 0) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Imported Modules]\n"); else if(definition->type == 1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Defined Classes]\n"); else if(definition->type == 2) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Defined Expressions]\n"); else if(definition->type == 3) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Defined Functions]\n"); else if(definition->type == 4) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Defined Data]\n"); lastType = definition->type; } if(definition->type == 0) { struct ImportedModule * module = (struct ImportedModule *)definition; if(module->importType == 1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Static]\n"); else if(module->importType == 2) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Remote]\n"); if(module->importAccess == 2) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Private]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", module->name); } else if(definition->type == 1) { struct __ecereNameSpace__ecere__com__Class * _class = __ecereNameSpace__ecere__com__eSystem_FindClass(privateModule, definition->name); struct ClassDefine * classDefine = (struct ClassDefine *)definition; __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", definition->name); if(classDefine->accessMode == 3) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Static]\n"); if(classDefine->accessMode == 2) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Private]\n"); if(classDefine->fixed) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Fixed]\n"); if(classDefine->noExpansion) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [No Expansion]\n"); if(classDefine->isRemote) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Remote]\n"); if(classDefine->isWatchable) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Watchable]\n"); if(_class->type == 4) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Enum]\n"); else if(_class->type == 2) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Bit]\n"); else if(_class->type == 1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Struct]\n"); else if(_class->type == 3) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Unit]\n"); else if(_class->type == 5) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [NoHead]\n"); if(_class->inheritanceAccess == 2) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Private Base]\n"); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Base]\n"); if(classDefine->base) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", classDefine->base); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [None]\n"); if(_class->templateParams.count) { struct __ecereNameSpace__ecere__com__ClassTemplateParameter * param; struct TemplateParameter * tp; __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Template Parameters]\n"); for(tp = (*((struct Symbol *)_class->symbol)->templateParams).first, param = _class->templateParams.first; param && tp; param = param->next, tp = tp->next) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", param->name); switch(param->type) { case 0: __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Type]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", param->__anon1.dataTypeString ? param->__anon1.dataTypeString : "[None]"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", param->defaultArg.__anon1.__anon1.dataTypeString ? param->defaultArg.__anon1.__anon1.dataTypeString : "[None]"); break; case 2: __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Expression]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", param->__anon1.dataTypeString ? param->__anon1.dataTypeString : "[None]"); if(tp->defaultArgument && tp->defaultArgument->__anon1.expression) { char temp[8192]; temp[0] = 0; PrintExpression(tp->defaultArgument->__anon1.expression, temp); __ecereNameSpace__ecere__sys__ChangeCh(temp, '\n', ' '); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " "); (__extension__ ({ unsigned int (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *, const char * string); __internal_VirtualMethod = ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, const char * string))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = f; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Puts]); __internal_VirtualMethod ? __internal_VirtualMethod(f, temp) : (unsigned int)1; })); (__extension__ ({ unsigned int (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *, const char * string); __internal_VirtualMethod = ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, const char * string))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = f; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Puts]); __internal_VirtualMethod ? __internal_VirtualMethod(f, "\n") : (unsigned int)1; })); } else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [None]\n"); break; case 1: __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Identifier]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", (param->__anon1.memberType == 0) ? "[Data member]" : ((param->__anon1.memberType == 1) ? "[Method]" : "[Property]")); if(tp->defaultArgument && tp->defaultArgument->__anon1.identifier) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " "); if(tp->defaultArgument->__anon1.identifier->_class && tp->defaultArgument->__anon1.identifier->_class->type == 1 && tp->defaultArgument->__anon1.identifier->_class->__anon1.__anon1.name) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "%s::", tp->defaultArgument->__anon1.identifier->_class->__anon1.__anon1.name); } else if(tp->defaultArgument->__anon1.identifier->_class && tp->defaultArgument->__anon1.identifier->_class->type == 8 && tp->defaultArgument->__anon1.identifier->_class->__anon1.templateParameter->identifier) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "%s::", tp->defaultArgument->__anon1.identifier->_class->__anon1.templateParameter->identifier->string); } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "%s\n", tp->defaultArgument->__anon1.identifier->string); } else { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [None]\n"); } break; } } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); } if(classDefine->accessMode != 3) { if(classDefine->methods.first) { struct MethodDefine * method; __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Defined Methods]\n"); for(method = classDefine->methods.first; method; method = method->next) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", method->name); if(method->memberAccess == 1) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Public]\n"); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Private]\n"); if(method->isVirtual) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Virtual]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Type]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", method->type ? method->type : ""); } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); } OutputDataMembers(classDefine, _class, f); if(_class->type == 4) { struct __ecereNameSpace__ecere__sys__NamedLink64 * value; struct __ecereNameSpace__ecere__com__Class * enumClass = __ecereNameSpace__ecere__com__eSystem_FindClass(privateModule, "enum"); struct __ecereNameSpace__ecere__com__EnumClassData * e = (_class ? ((void *)(((char *)_class->data) + enumClass->offsetClass)) : (((void *)0))); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Enum Values]\n"); for(value = e->values.first; value; value = value->next) { __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s = ", value->name); if(_class->dataTypeString && !strcmp(_class->dataTypeString, "uint64") && *(uint64 *)&value->data > (((long long)0x7fffffffffffffffLL))) __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, ((__runtimePlatform == 1) ? "0x%I64X" : "0x%llX"), *(uint64 *)&value->data); else __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, ((__runtimePlatform == 1) ? "%I64d" : "%lld"), value->data); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "\n"); } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); } } } else if(definition->type == 2) { struct Define * defineDefine = (struct Define *)definition; __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", definition->name); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Value]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " "); OutputExpression(defineDefine->exp, f); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "\n"); } else if(definition->type == 3) { struct FunctionDefine * functionDefine = (struct FunctionDefine *)definition; __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", functionDefine->name); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Type]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", functionDefine->dataType); } else if(definition->type == 4) { struct DataDefine * dataDefine = (struct DataDefine *)definition; __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", dataDefine->name); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " [Type]\n"); __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " %s\n", dataDefine->dataType); } } __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, " .\n"); (__ecereNameSpace__ecere__com__eInstance_DecRef(f), f = 0); } } struct Enumerator; struct Enumerator { struct Enumerator * prev; struct Enumerator * next; struct Location loc; struct Identifier * id; struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * attribs; } ecere_gcc_struct; static void ProcessClassEnumValues(int classType, struct __ecereNameSpace__ecere__sys__OldList * definitions, struct Symbol * symbol, struct __ecereNameSpace__ecere__sys__OldList * baseSpecs, struct __ecereNameSpace__ecere__sys__OldList * enumValues) { struct __ecereNameSpace__ecere__com__Class * regClass = symbol->__anon1.registered; if(regClass && enumValues) { struct Enumerator * e; long long lastValue = -1; unsigned int lastValueSet = 0; for(e = enumValues->first; e; e = e->next) { if(e->exp) { struct Type * destType = (destType = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type), destType->kind = 4, destType->refCount = 1, destType); e->exp->destType = destType; SetParsingType(1); ProcessExpressionType(e->exp); SetParsingType(0); if(!e->exp->expType) { destType->kind = 8; destType->__anon1._class = symbol; ProcessExpressionType(e->exp); } if(e->exp->isConstant) { if(e->exp->type == 0 && e->exp->expType && e->exp->__anon1.__anon1.identifier && e->exp->__anon1.__anon1.identifier->string && e->exp->expType->kind == 15) { struct __ecereNameSpace__ecere__sys__NamedLink64 * l; char * string = e->exp->__anon1.__anon1.identifier->string; for(l = e->exp->expType->__anon1.__anon1.members.first; l; l = l->next) { if(!strcmp(l->name, string)) { if(l->data) { FreeExpContents(e->exp); e->exp->type = 2; e->exp->__anon1.__anon1.constant = PrintInt64(l->data); FreeType(e->exp->expType); e->exp->expType = ProcessTypeString("int64", 0); } break; } } } else ComputeExpression(e->exp); } if(e->exp->isConstant && e->exp->type == 2) { struct Operand op = GetOperand(e->exp); long long value; switch(op.kind) { case 1: value = op.type->isSigned ? (long long)op.__anon1.c : (long long)op.__anon1.uc; break; case 2: value = op.type->isSigned ? (long long)op.__anon1.s : (long long)op.__anon1.us; break; case 4: value = op.type->isSigned ? op.__anon1.i64 : (long long)op.__anon1.ui64; break; case 3: default: value = op.type->isSigned ? (long long)op.__anon1.i : (int)op.__anon1.ui; } __ecereNameSpace__ecere__com__eEnum_AddFixedValue(regClass, e->id->string, value); lastValueSet = 1; lastValue = value; } else { char expString[8192]; expString[0] = 0; PrintExpression(e->exp, expString); printf(__ecereNameSpace__ecere__GetTranslatedString("ecp", "error: could not resolve value %s for enum %s in precompiler\n", (((void *)0))), expString, regClass->name); ((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Instance *)__thisModule) + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->exitCode = 1; if(lastValueSet) __ecereNameSpace__ecere__com__eEnum_AddFixedValue(regClass, e->id->string, ++lastValue); else __ecereNameSpace__ecere__com__eEnum_AddValue(regClass, e->id->string); } } else { if(lastValueSet) __ecereNameSpace__ecere__com__eEnum_AddFixedValue(regClass, e->id->string, ++lastValue); else __ecereNameSpace__ecere__com__eEnum_AddValue(regClass, e->id->string); } } } } struct Declaration; typedef union YYSTYPE { int specifierType; int i; int declMode; struct Identifier * id; struct Expression * exp; struct Specifier * specifier; struct __ecereNameSpace__ecere__sys__OldList * list; struct Enumerator * enumerator; struct Declarator * declarator; struct __ecereNameSpace__ecere__com__Instance * pointer; struct Initializer * initializer; struct InitDeclarator * initDeclarator; struct TypeName * typeName; struct Declaration * declaration; struct Statement * stmt; struct FunctionDefinition * function; struct External * external; struct Context * context; struct __ecereNameSpace__ecere__com__Instance * asmField; struct Attrib * attrib; struct ExtDecl * extDecl; struct Attribute * attribute; struct Instantiation * instance; struct MembersInit * membersInit; struct MemberInit * memberInit; struct ClassFunction * classFunction; struct ClassDefinition * _class; struct ClassDef * classDef; struct PropertyDef * prop; char * string; struct Symbol * symbol; struct PropertyWatch * propertyWatch; struct TemplateParameter * templateParameter; struct TemplateArgument * templateArgument; struct TemplateDatatype * templateDatatype; struct __ecereNameSpace__ecere__com__Instance * dbtableEntry; struct __ecereNameSpace__ecere__com__Instance * dbindexItem; struct DBTableDef * dbtableDef; } ecere_gcc_struct YYSTYPE; extern YYSTYPE yylval; struct ClassDef { struct ClassDef * prev; struct ClassDef * next; struct Location loc; int type; union { struct Declaration * decl; struct ClassFunction * function; struct __ecereNameSpace__ecere__sys__OldList * defProperties; struct PropertyDef * propertyDef; struct PropertyWatch * propertyWatch; char * designer; struct Identifier * defaultProperty; struct { struct Identifier * id; struct Initializer * initializer; } ecere_gcc_struct __anon1; } ecere_gcc_struct __anon1; int memberAccess; void * object; } ecere_gcc_struct; struct Declaration { struct Declaration * prev; struct Declaration * next; struct Location loc; int type; union { struct { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct __ecereNameSpace__ecere__sys__OldList * declarators; } ecere_gcc_struct __anon1; struct Instantiation * inst; struct { struct Identifier * id; struct Expression * exp; } ecere_gcc_struct __anon2; } ecere_gcc_struct __anon1; struct Specifier * extStorage; struct Symbol * symbol; int declMode; } ecere_gcc_struct; struct External { struct External * prev; struct External * next; struct Location loc; int type; struct Symbol * symbol; union { struct FunctionDefinition * function; struct ClassDefinition * _class; struct Declaration * declaration; char * importString; struct Identifier * id; struct DBTableDef * table; char * pragma; } ecere_gcc_struct __anon1; int importType; struct External * fwdDecl; struct __ecereNameSpace__ecere__com__Instance * outgoing; struct __ecereNameSpace__ecere__com__Instance * incoming; int nonBreakableIncoming; } ecere_gcc_struct; static void AddDefinitions(struct ClassDefine * classDefine, struct DataMemberDefine * parentMemberDefine, struct __ecereNameSpace__ecere__com__Class * regClass, struct __ecereNameSpace__ecere__com__DataMember * member, struct __ecereNameSpace__ecere__sys__OldList * definitions) { if(definitions != (((void *)0))) { struct ClassDef * def; for(def = definitions->first; def; def = def->next) { if(def->type == 2) { struct Declaration * decl = def->__anon1.decl; struct __ecereNameSpace__ecere__com__DataMember * dataMember; struct Type * dataType; struct DataMemberDefine * dataMemberDefine; if(decl->type == 0) { struct Declarator * d; if(decl->__anon1.__anon1.declarators) { for(d = (*decl->__anon1.__anon1.declarators).first; d; d = d->next) { struct Identifier * declId = GetDeclId(d); if(declId) { dataMemberDefine = __extension__ ({ struct DataMemberDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_DataMemberDefine); __ecereInstance1->isProperty = 3, __ecereInstance1->memberType = 0, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(declId->string), __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&parentMemberDefine->dataMembers, dataMemberDefine); if(regClass && regClass->type == 2) { struct Expression * sizeExp = d->__anon1.structDecl.exp, * posExp = d->__anon1.structDecl.posExp; int bitSize = 0, bitPos = -1; char dataTypeString[1024]; dataTypeString[0] = '\0'; if(sizeExp) { ProcessExpressionType(sizeExp); ComputeExpression(sizeExp); if(sizeExp->isConstant) bitSize = strtol(sizeExp->__anon1.__anon1.constant, (((void *)0)), 0); FreeExpression(sizeExp); } if(posExp) { ProcessExpressionType(posExp); ComputeExpression(posExp); if(posExp->isConstant) bitPos = strtol(posExp->__anon1.__anon1.constant, (((void *)0)), 0); FreeExpression(posExp); } d->__anon1.structDecl.exp = (((void *)0)); d->__anon1.structDecl.posExp = (((void *)0)); dataType = ProcessType(decl->__anon1.__anon1.specifiers, d); PrintType(dataType, dataTypeString, 0, 1); { struct __ecereNameSpace__ecere__com__BitMember * member = __ecereNameSpace__ecere__com__eClass_AddBitMember(regClass, declId->string, dataTypeString, 0, 0, def->memberAccess); if(member) { member->size = bitSize; member->pos = bitPos; } dataMember = (struct __ecereNameSpace__ecere__com__DataMember *)member; } if(dataMember) dataMember->dataType = dataType; dataMemberDefine->size = bitSize; dataMemberDefine->bitPos = bitPos; dataMemberDefine->type = __ecereNameSpace__ecere__sys__CopyString(dataTypeString); } else { { char typeString[1024]; typeString[0] = '\0'; dataType = ProcessType(decl->__anon1.__anon1.specifiers, d); PrintType(dataType, typeString, 0, 1); if(member) dataMember = __ecereNameSpace__ecere__com__eMember_AddDataMember(member, declId->string, typeString, 0, 0, def->memberAccess); else dataMember = __ecereNameSpace__ecere__com__eClass_AddDataMember(regClass, declId->string, typeString, 0, 0, def->memberAccess); if(dataMember) dataMember->dataType = dataType; dataMemberDefine->type = __ecereNameSpace__ecere__sys__CopyString(typeString); } } dataMemberDefine->memberAccess = def->memberAccess; } } } else if(decl->__anon1.__anon1.specifiers) { struct Specifier * spec; for(spec = (*decl->__anon1.__anon1.specifiers).first; spec; spec = spec->next) { if(spec->type == 3 || spec->type == 4) { if(spec->__anon1.__anon2.definitions && !spec->__anon1.__anon2.id) { struct __ecereNameSpace__ecere__com__DataMember * dataMember = __ecereNameSpace__ecere__com__eMember_New((spec->type == 4) ? 1 : 2, def->memberAccess); dataMemberDefine = __extension__ ({ struct DataMemberDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_DataMemberDefine); __ecereInstance1->isProperty = 3, __ecereInstance1->memberType = (spec->type == 4) ? 1 : 2, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&parentMemberDefine->dataMembers, dataMemberDefine); AddDefinitions((((void *)0)), dataMemberDefine, (((void *)0)), dataMember, spec->__anon1.__anon2.definitions); if(member) __ecereNameSpace__ecere__com__eMember_AddMember(member, dataMember); else __ecereNameSpace__ecere__com__eClass_AddMember(regClass, dataMember); } else if(spec->__anon1.__anon2.definitions && spec->__anon1.__anon2.id && (*spec->__anon1.__anon2.definitions).count) { { struct Identifier * id = spec->__anon1.__anon2.id; char typeString[1024]; typeString[0] = '\0'; spec->__anon1.__anon2.id = (((void *)0)); decl->__anon1.__anon1.declarators = MkListOne(MkDeclaratorIdentifier(id)); dataType = ProcessType(decl->__anon1.__anon1.specifiers, (((void *)0))); PrintType(dataType, typeString, 0, 1); if(member) dataMember = __ecereNameSpace__ecere__com__eMember_AddDataMember(member, id->string, typeString, 0, 0, def->memberAccess); else dataMember = __ecereNameSpace__ecere__com__eClass_AddDataMember(regClass, id->string, typeString, 0, 0, def->memberAccess); if(dataMember) dataMember->dataType = dataType; } } } } } } else if(decl->type == 2) { struct Instantiation * inst = decl->__anon1.inst; struct Expression * exp = inst->exp; if(exp) { { char * string = exp->__anon1.__anon1.identifier->string; { struct Type * dataType = (dataType = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type), dataType->kind = 8, dataType->__anon1._class = inst->_class->__anon1.__anon1.symbol, dataType->refCount = 1, dataType); if(member) dataMember = __ecereNameSpace__ecere__com__eMember_AddDataMember(member, string, inst->_class->__anon1.__anon1.name, 0, 0, def->memberAccess); else dataMember = __ecereNameSpace__ecere__com__eClass_AddDataMember(regClass, string, inst->_class->__anon1.__anon1.name, 0, 0, def->memberAccess); if(dataMember) dataMember->dataType = dataType; } dataMemberDefine = __extension__ ({ struct DataMemberDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_DataMemberDefine); __ecereInstance1->isProperty = 3, __ecereInstance1->memberType = 0, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(string), __ecereInstance1->type = __ecereNameSpace__ecere__sys__CopyString(inst->_class->__anon1.__anon1.name), __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&parentMemberDefine->dataMembers, dataMemberDefine); } } } } else if(def->type == 3 && def->__anon1.propertyDef) { struct PropertyDef * propertyDef = def->__anon1.propertyDef; { struct __ecereNameSpace__ecere__com__Property * prop; struct PropertyDefine * propDefine; { char * dataTypeString = StringFromSpecDecl(propertyDef->specifiers, propertyDef->declarator); prop = __ecereNameSpace__ecere__com__eClass_AddProperty(regClass, propertyDef->__anon1.conversion ? (((void *)0)) : propertyDef->id->string, dataTypeString, propertyDef->setStmt, propertyDef->getStmt, def->memberAccess); if(prop) { prop->IsSet = (void *)propertyDef->issetStmt; prop->compiled = 0; } (__ecereNameSpace__ecere__com__eSystem_Delete(dataTypeString), dataTypeString = 0); } if(prop) { prop->symbol = __extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString(propertyDef->symbol->string), __ecereInstance1->type = propertyDef->symbol->type, __ecereInstance1; }); if(propertyDef->symbol->type) propertyDef->symbol->type->refCount++; propDefine = __extension__ ({ struct PropertyDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_PropertyDefine); __ecereInstance1->isProperty = 1, __ecereInstance1->name = prop->conversion ? (((void *)0)) : __ecereNameSpace__ecere__sys__CopyString(prop->name), __ecereInstance1->type = __ecereNameSpace__ecere__sys__CopyString(prop->dataTypeString), __ecereInstance1->isVirtual = 0, __ecereInstance1->memberAccess = def->memberAccess, __ecereInstance1->hasSet = propertyDef->setStmt ? 1 : 0, __ecereInstance1->hasGet = propertyDef->getStmt ? 1 : 0, __ecereInstance1->isWatchable = propertyDef->__anon1.isWatchable, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&classDefine->propertiesAndMembers, propDefine); } } } else if(def->type == 10 && def->__anon1.propertyDef) { struct PropertyDef * propertyDef = def->__anon1.propertyDef; { struct __ecereNameSpace__ecere__com__ClassProperty * prop; struct PropertyDefine * propDefine; { char * dataTypeString = StringFromSpecDecl(propertyDef->specifiers, propertyDef->declarator); prop = __ecereNameSpace__ecere__com__eClass_AddClassProperty(regClass, propertyDef->id->string, dataTypeString, propertyDef->setStmt, propertyDef->getStmt); (__ecereNameSpace__ecere__com__eSystem_Delete(dataTypeString), dataTypeString = 0); } if(prop) { propDefine = __extension__ ({ struct PropertyDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_PropertyDefine); __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(prop->name), __ecereInstance1->type = __ecereNameSpace__ecere__sys__CopyString(prop->dataTypeString), __ecereInstance1->hasSet = propertyDef->setStmt ? 1 : 0, __ecereInstance1->hasGet = propertyDef->getStmt ? 1 : 0, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&classDefine->classProperties, propDefine); } } } else if(def->type == 7) { if(classDefine) classDefine->fixed = 1; } else if(def->type == 6) { if(classDefine) classDefine->noExpansion = 1; } else if(def->type == 13) { struct __ecereNameSpace__ecere__com__DataMember * member; struct __ecereNameSpace__ecere__com__Property * prop; if((prop = __ecereNameSpace__ecere__com__eClass_FindProperty(regClass, def->__anon1.__anon1.id->string, privateModule))) { struct PropertyDefine * propDefine; prop = __ecereNameSpace__ecere__com__eClass_AddProperty(regClass, def->__anon1.__anon1.id->string, (((void *)0)), (((void *)0)), (((void *)0)), def->memberAccess); if(prop) { propDefine = __extension__ ({ struct PropertyDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_PropertyDefine); __ecereInstance1->isProperty = 1, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(prop->name), __ecereInstance1->memberAccess = def->memberAccess, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&classDefine->propertiesAndMembers, propDefine); } } else if((member = __ecereNameSpace__ecere__com__eClass_FindDataMember(regClass, def->__anon1.__anon1.id->string, privateModule, (((void *)0)), (((void *)0))))) { struct DataMemberDefine * dataMemberDefine; member = __ecereNameSpace__ecere__com__eClass_AddDataMember(regClass, def->__anon1.__anon1.id->string, (((void *)0)), 0, 0, def->memberAccess); dataMemberDefine = __extension__ ({ struct DataMemberDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_DataMemberDefine); __ecereInstance1->isProperty = 3, __ecereInstance1->memberType = 0, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(def->__anon1.__anon1.id->string), __ecereInstance1->memberAccess = def->memberAccess, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&parentMemberDefine->dataMembers, dataMemberDefine); } } } } } static void ProcessClass(int classType, struct __ecereNameSpace__ecere__sys__OldList * definitions, struct Symbol * symbol, struct __ecereNameSpace__ecere__sys__OldList * baseSpecs, struct __ecereNameSpace__ecere__sys__OldList * enumValues, unsigned int isWatchable, int declMode) { struct __ecereNameSpace__ecere__com__Class * regClass; struct ClassDef * def; struct ClassDefine * classDefine; char baseName[1024]; unsigned int unitType = 0; unsigned int wouldBeEnum = 0; int inheritanceAccess = 1; baseName[0] = '\0'; if(baseSpecs != (((void *)0))) { struct Type * baseType = ProcessType(baseSpecs, (((void *)0))); PrintType(baseType, baseName, 0, 1); if(baseType->kind == 8) { if(baseType->__anon1._class->__anon1.registered && classType == 0) { if(baseType->__anon1._class->__anon1.registered->type == 3) classType = 3; else if(baseType->__anon1._class->__anon1.registered->type == 2) classType = 2; else if(baseType->__anon1._class->__anon1.registered->type == 5) classType = 5; else if(baseType->__anon1._class->__anon1.registered->type == 4) { wouldBeEnum = 1; } } } else if(baseType->kind == 9 || baseType->kind == 10) { classType = 5; baseName[0] = '\0'; } else unitType = 1; FreeType(baseType); if(((struct Specifier *)baseSpecs->first)->type == 0 && ((struct Specifier *)baseSpecs->first)->__anon1.specifier == PRIVATE) inheritanceAccess = 2; } if(classType == 0) { if(unitType) classType = 3; if(definitions != (((void *)0))) { for(def = definitions->first; def; def = def->next) { if(def->type == 2) { struct Declaration * decl = def->__anon1.decl; if(decl->type == 0) { if(unitType) { classType = 2; break; } if(decl->__anon1.__anon1.declarators) { struct Declarator * d; for(d = (*decl->__anon1.__anon1.declarators).first; d; d = d->next) { if(d->__anon1.structDecl.exp) { classType = 2; break; } } if(d) break; } } } } } } if(classType == 0 && wouldBeEnum) classType = 4; regClass = symbol->__anon1.registered = __ecereNameSpace__ecere__com__eSystem_RegisterClass((classType == 6) ? 1 : classType, symbol->string, baseName[0] ? baseName : (((void *)0)), 0, 0, (((void *)0)), (((void *)0)), privateModule, 1, inheritanceAccess); if(regClass) regClass->symbol = symbol; classDefine = __extension__ ({ struct ClassDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ClassDefine); __ecereInstance1->type = 1, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(symbol->string), __ecereInstance1->base = baseName[0] ? __ecereNameSpace__ecere__sys__CopyString(baseName) : (((void *)0)), __ecereInstance1->accessMode = declMode, __ecereInstance1->isRemote = symbol->isRemote, __ecereInstance1->isWatchable = isWatchable, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&precompDefines, classDefine); if(classType == 6) { struct __ecereNameSpace__ecere__com__DataMember * unionMember = __ecereNameSpace__ecere__com__eMember_New(1, 1); struct DataMemberDefine * unionDefine; unionDefine = __extension__ ({ struct DataMemberDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_DataMemberDefine); __ecereInstance1->isProperty = 3, __ecereInstance1->memberType = 1, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&classDefine->propertiesAndMembers, unionDefine); AddDefinitions(classDefine, unionDefine, regClass, unionMember, definitions); __ecereNameSpace__ecere__com__eClass_AddMember(regClass, unionMember); } else if(regClass) AddDefinitions(classDefine, (struct DataMemberDefine *)classDefine, regClass, (((void *)0)), definitions); if(definitions != (((void *)0))) { for(def = definitions->first; def; def = def->next) { if(def->type == 0) { struct ClassFunction * func = def->__anon1.function; if(!func->dontMangle && func->declarator) { struct Identifier * id = GetDeclId(func->declarator); struct __ecereNameSpace__ecere__com__Method * method; struct MethodDefine * methodDefine; { char * dataTypeString = StringFromSpecDecl(func->specifiers, func->declarator); if(func->isVirtual) method = __ecereNameSpace__ecere__com__eClass_AddVirtualMethod(regClass, id->string, dataTypeString, func->declarator->symbol, def->memberAccess); else method = __ecereNameSpace__ecere__com__eClass_AddMethod(regClass, id->string, dataTypeString, func->declarator->symbol, def->memberAccess); (__ecereNameSpace__ecere__com__eSystem_Delete(dataTypeString), dataTypeString = 0); } if(method) { method->symbol = __extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString(func->declarator->symbol->string), __ecereInstance1->type = func->declarator->symbol->type, __ecereInstance1; }); if(func->declarator->symbol->type) func->declarator->symbol->type->refCount++; ((struct Symbol *)method->symbol)->__anon1.method = method; func->declarator->symbol = (((void *)0)); if(method->type != 1 || method->_class == regClass) { methodDefine = __extension__ ({ struct MethodDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_MethodDefine); __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(method->name), __ecereInstance1->type = __ecereNameSpace__ecere__sys__CopyString(method->dataTypeString), __ecereInstance1->memberAccess = def->memberAccess, __ecereInstance1->isVirtual = method->type == 1, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&classDefine->methods, methodDefine); } } } } else if(def->type == 13) { struct __ecereNameSpace__ecere__com__Method * method; if((method = __ecereNameSpace__ecere__com__eClass_FindMethod(regClass, def->__anon1.__anon1.id->string, privateModule))) { struct MethodDefine * methodDefine; method = __ecereNameSpace__ecere__com__eClass_AddMethod(regClass, def->__anon1.__anon1.id->string, (((void *)0)), (((void *)0)), def->memberAccess); methodDefine = __extension__ ({ struct MethodDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_MethodDefine); __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(method->name), __ecereInstance1->memberAccess = def->memberAccess, __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&classDefine->methods, methodDefine); } } } } if(regClass && symbol->templateParams) { struct TemplateParameter * param; for(param = (*symbol->templateParams).first; param; param = param->next) { struct __ecereNameSpace__ecere__com__ClassTemplateArgument defaultArg = { .__anon1 = { .__anon1 = { .dataTypeString = 0 } } }; if(param->defaultArgument) { switch(param->type) { case 0: defaultArg.__anon1.__anon1.dataTypeString = StringFromSpecDecl(param->defaultArgument->__anon1.templateDatatype->specifiers, param->defaultArgument->__anon1.templateDatatype->decl); break; case 1: { char memberString[1024]; memberString[0] = '\0'; if(param->defaultArgument->__anon1.identifier->_class && param->defaultArgument->__anon1.identifier->_class->__anon1.__anon1.name) { if(param->defaultArgument->__anon1.identifier->_class->type == 8) strcpy(memberString, param->defaultArgument->__anon1.identifier->_class->__anon1.templateParameter->identifier->string); else strcpy(memberString, param->defaultArgument->__anon1.identifier->_class->__anon1.__anon1.name); } if(memberString[0]) { strcat(memberString, "::"); } strcat(memberString, param->defaultArgument->__anon1.identifier->string); defaultArg.__anon1.__anon2.memberString = __ecereNameSpace__ecere__sys__CopyString(memberString); break; } case 2: { struct Operand op; ProcessExpressionType(param->defaultArgument->__anon1.expression); ComputeExpression(param->defaultArgument->__anon1.expression); op = GetOperand(param->defaultArgument->__anon1.expression); defaultArg.__anon1.expression.__anon1.ui64 = op.__anon1.ui64; break; } } } if(param->type == 1) { __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(regClass, param->identifier->string, param->type, (void *)(uintptr_t)param->__anon1.memberType, &defaultArg); } else { char * typeString = param->__anon1.dataType ? StringFromSpecDecl(param->__anon1.dataType->specifiers, param->__anon1.dataType->decl) : (((void *)0)); __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(regClass, param->identifier->string, param->type, typeString, &defaultArg); } } } } void PreCompPreProcessClassDefinitions() { struct __ecereNameSpace__ecere__sys__OldList * ast = GetAST(); struct External * external, * next; for(external = (*ast).first; external; external = next) { next = external->next; if(external->type == 2) { struct ClassDefinition * _class = external->__anon1._class; if(_class->declMode == 1 || _class->declMode == 2 || _class->declMode == 3) { if(_class->definitions) { ProcessClass(0, _class->definitions, _class->symbol, _class->baseSpecs, (((void *)0)), _class->deleteWatchable, _class->declMode); } } } else if(external->type == 1) { struct Declaration * declaration = external->__anon1.declaration; if(declaration->type == 1) { if(external->__anon1.declaration->declMode == 1 || external->__anon1.declaration->declMode == 2 || external->__anon1.declaration->declMode == 3) { if(declaration->__anon1.__anon1.specifiers) { struct Specifier * specifier; for(specifier = (*declaration->__anon1.__anon1.specifiers).first; specifier; specifier = specifier->next) { if((specifier->type == 2 || specifier->type == 3 || specifier->type == 4) && specifier->__anon1.__anon2.id && specifier->__anon1.__anon2.id->string && (declaration->declMode || specifier->__anon1.__anon2.baseSpecs || (specifier->type == 2 && specifier->__anon1.__anon2.definitions))) { struct Symbol * symbol = FindClass(specifier->__anon1.__anon2.id->string); if(symbol) { int classType; if(specifier->type == 2) classType = 4; else if(specifier->type == 4) classType = 6; else classType = 1; ProcessClass(classType, specifier->__anon1.__anon2.definitions, symbol, specifier->__anon1.__anon2.baseSpecs, specifier->__anon1.__anon2.list, 0, external->__anon1.declaration->declMode); } } } } if(external->__anon1.declaration->declMode == 1 || external->__anon1.declaration->declMode == 2) { if(declaration->__anon1.__anon1.declarators) { struct InitDeclarator * d; for(d = (*declaration->__anon1.__anon1.declarators).first; d; d = d->next) { if(d->declarator) { struct Symbol * symbol = d->declarator->symbol; if(symbol) { struct DataDefine * dataDefine; char typeString[1024]; typeString[0] = '\0'; PrintType(symbol->type, typeString, 0, 1); dataDefine = __extension__ ({ struct DataDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_DataDefine); __ecereInstance1->type = 4, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(symbol->string), __ecereInstance1->dataType = __ecereNameSpace__ecere__sys__CopyString(typeString), __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&precompDefines, dataDefine); } } } } } } } else if(declaration->type == 2) { if(external->__anon1.declaration->declMode == 1 || external->__anon1.declaration->declMode == 2) { struct Symbol * symbol = declaration->__anon1.inst->symbol; if(symbol) { struct DataDefine * dataDefine; char typeString[1024]; typeString[0] = '\0'; PrintType(symbol->type, typeString, 0, 1); dataDefine = __extension__ ({ struct DataDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_DataDefine); __ecereInstance1->type = 4, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(symbol->string), __ecereInstance1->dataType = __ecereNameSpace__ecere__sys__CopyString(typeString), __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&precompDefines, dataDefine); } } globalInstance = 1; } else if(declaration->type == 3) { if(external->__anon1.declaration->declMode == 1 || external->__anon1.declaration->declMode == 2) { struct Define * definition = (definition = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Define), definition->type = 2, definition->name = __ecereNameSpace__ecere__sys__CopyString(declaration->__anon1.__anon2.id->string), definition->exp = declaration->__anon1.__anon2.exp, definition); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&precompDefines, definition); } } } else if(external->type == 0 && (external->__anon1.function->declMode == 1 || external->__anon1.function->declMode == 2)) { struct FunctionDefinition * function = external->__anon1.function; struct FunctionDefine * functionDefine; char typeString[1024]; typeString[0] = '\0'; PrintType(function->declarator->symbol->type, typeString, 1, 1); functionDefine = __extension__ ({ struct FunctionDefine * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_FunctionDefine); __ecereInstance1->type = 3, __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(function->declarator->symbol->string), __ecereInstance1->dataType = __ecereNameSpace__ecere__sys__CopyString(typeString), __ecereInstance1; }); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&precompDefines, functionDefine); } else if(external->type == 4) { SetCurrentNameSpace(external->__anon1.id->string); } } ComputeModuleClasses(privateModule); for(external = (*ast).first; external; external = next) { next = external->next; if(external->type == 1 && (external->__anon1.declaration->declMode == 1 || external->__anon1.declaration->declMode == 2)) { struct Declaration * declaration = external->__anon1.declaration; if(declaration->type == 1) { if(declaration->__anon1.__anon1.specifiers) { struct Specifier * specifier; for(specifier = (*declaration->__anon1.__anon1.specifiers).first; specifier; specifier = specifier->next) { if((specifier->type == 2) && specifier->__anon1.__anon2.id && specifier->__anon1.__anon2.id->string && (declaration->declMode || specifier->__anon1.__anon2.baseSpecs || (specifier->type == 2 && specifier->__anon1.__anon2.definitions))) { struct Symbol * symbol = FindClass(specifier->__anon1.__anon2.id->string); if(symbol) { ProcessClassEnumValues(4, specifier->__anon1.__anon2.definitions, symbol, specifier->__anon1.__anon2.baseSpecs, specifier->__anon1.__anon2.list); } } } } } } } } void __ecereMethod_PrecompApp_Main(struct __ecereNameSpace__ecere__com__Instance * this) { int c; unsigned int valid = 1; char defaultSymFile[797]; char * cppCommand = (((void *)0)); char * cppOptions = (((void *)0)); int cppOptionsLen = 0; int targetPlatform = __runtimePlatform; int targetBits = GetRuntimeBits(); for(c = 1; c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc; c++) { const char * arg = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c]; if(arg[0] == '-') { if(!strcmp(arg + 1, "m32") || !strcmp(arg + 1, "m64")) { int newLen = cppOptionsLen + 1 + strlen(arg); cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1)); cppOptions[cppOptionsLen] = ' '; strcpy(cppOptions + cppOptionsLen + 1, arg); cppOptionsLen = newLen; targetBits = !strcmp(arg + 1, "m32") ? 32 : 64; } else if(!strcmp(arg + 1, "t32") || !strcmp(arg + 1, "t64")) { targetBits = !strcmp(arg + 1, "t32") ? 32 : 64; } else if(arg[1] == 'D' || arg[1] == 'I') { char * buf; int size = cppOptionsLen + 1 + strlen(arg) * 2 + 1; cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (size)); buf = cppOptions + cppOptionsLen; *buf++ = ' '; PassArg(buf, arg); cppOptionsLen = cppOptionsLen + 1 + strlen(buf); } else if(!strcmp(arg + 1, "t")) { if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) { targetPlatform = __ecereProp___ecereNameSpace__ecere__com__Platform_Set_char__PTR_(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c]); if(targetPlatform == 0) { __ecereNameSpace__ecere__com__PrintLn(__ecereClass_char__PTR_, "Unknown platform: ", __ecereClass_char__PTR_, ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c], (void *)0); if(!strcmp(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c], "32") || !strcmp(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c], "64")) __ecereNameSpace__ecere__com__PrintLn(__ecereClass_char__PTR_, "hint: bitness is specified with -t32 or -t64 without a space", (void *)0); valid = 0; } } else valid = 0; } else if(!strcmp(arg + 1, "cpp")) { if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) cppCommand = __ecereNameSpace__ecere__sys__CopyString(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c]); else valid = 0; } else if(!strcmp(arg + 1, "o")) { if(!GetOutputFile() && c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) { SetOutputFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c + 1]); c++; } else valid = 0; } else if(!strcmp(arg + 1, "c")) { if(!GetSourceFile() && c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) { SetSourceFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c + 1]); c++; } else valid = 0; } else if(!strcmp(arg + 1, "isystem") || !strcmp(arg + 1, "isysroot") || !strcmp(arg + 1, "s")) { if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) { char * buf; const char * arg1 = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[++c]; int size = cppOptionsLen + 1 + strlen(arg) * 2 + strlen(arg1) * 2 + 1; cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (size)); buf = cppOptions + cppOptionsLen; *buf++ = ' '; buf = PassArg(buf, arg); *buf++ = ' '; buf = PassArg(buf, arg1); cppOptionsLen = buf - cppOptions; } else valid = 0; } else if(!strcmp(arg + 1, "fno-diagnostics-show-caret")) { char * buf; int size = cppOptionsLen + 1 + strlen(arg) * 2 + 1; cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (size)); buf = cppOptions + cppOptionsLen; *buf++ = ' '; PassArg(buf, arg); cppOptionsLen = cppOptionsLen + 1 + strlen(buf); } else if(!strcmp(arg + 1, "symbols")) { if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) { SetSymbolsDir(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c + 1]); c++; } else valid = 0; } else if(!strcmp(arg + 1, "defaultns")) { if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) { SetDefaultNameSpace(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c + 1]); c++; } else valid = 0; } else if(!strcmp(arg + 1, "strictns")) { SetStrictNameSpaces(1); } else if(!strcmp(arg + 1, "module")) { if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argc) { SetI18nModuleName(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->argv[c + 1]); c++; } else valid = 0; } } else valid = 0; } if(valid) { if(!cppCommand) cppCommand = __ecereNameSpace__ecere__sys__CopyString("gcc"); if(!GetSourceFile()) valid = 0; else if(!GetOutputFile()) { strcpy(defaultSymFile, GetSymbolsDir()); __ecereNameSpace__ecere__sys__PathCat(defaultSymFile, GetSourceFile()); __ecereNameSpace__ecere__sys__ChangeExtension(defaultSymFile, "sym", defaultSymFile); SetOutputFile(defaultSymFile); } } if(!valid) { printf("%s", __ecereNameSpace__ecere__GetTranslatedString("ecp", "Syntax:\n ecp [-t <target platform>] [-cpp <c preprocessor>] [-o <output>] [-symbols <outputdir>] [-I<includedir>]* [-isystem <sysincludedir>]* [-D<definition>]* -c <input>\n", (((void *)0)))); } else { struct __ecereNameSpace__ecere__com__Instance * cppOutput; char command[3075]; SetGlobalData(&globalData); SetExcludedSymbols(&_excludedSymbols); SetGlobalContext(globalContext); SetCurrentContext(globalContext); SetTopContext(globalContext); SetDefines(&defines); SetImports(&imports); SetInPreCompiler(1); SetPrecompDefines(&precompDefines); SetTargetPlatform(targetPlatform); SetTargetBits(targetBits); SetEchoOn(0); privateModule = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com____ecere_COM_Initialize((unsigned int)(1 | (targetBits == sizeof(uintptr_t) * 8 ? (unsigned int)0 : targetBits == 64 ? 2 : targetBits == 32 ? 4 : (unsigned int)0) | 8), 1, (((void *)0))); SetPrivateModule(privateModule); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint64"), __ecereInstance1->type = ProcessTypeString("unsigned int64", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint32"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint16"), __ecereInstance1->type = ProcessTypeString("unsigned short", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("byte"), __ecereInstance1->type = ProcessTypeString("unsigned char", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("intptr_t"), __ecereInstance1->type = ProcessTypeString("intptr", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uintptr_t"), __ecereInstance1->type = ProcessTypeString("uintptr", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("ssize_t"), __ecereInstance1->type = ProcessTypeString("intsize", 0), __ecereInstance1; })); __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({ struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("size_t"), __ecereInstance1->type = ProcessTypeString("uintsize", 0), __ecereInstance1; })); { const char * outputFilePath = GetOutputFile(); if(__ecereNameSpace__ecere__sys__FileExists(outputFilePath)) __ecereNameSpace__ecere__sys__DeleteFile(outputFilePath); } snprintf(command, sizeof (command), "%s%s -x c -E \"%s\"", cppCommand, cppOptions ? cppOptions : "", GetSourceFile()); command[sizeof (command) - 1] = 0; if((cppOutput = __ecereNameSpace__ecere__sys__DualPipeOpen((((unsigned int)(1))), command))) { int exitCode; struct __ecereNameSpace__ecere__sys__OldList * ast; struct __ecereNameSpace__ecere__com__Instance * fileInput = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__sys__TempFile); struct ModuleImport * mainModule = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ModuleImport); SetFileInput(fileInput); SetMainModule(mainModule); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&imports, mainModule); resetScanner(); for(; !(__extension__ ({ unsigned int (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *); __internal_VirtualMethod = ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = cppOutput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__DualPipe->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof]); __internal_VirtualMethod ? __internal_VirtualMethod(cppOutput) : (unsigned int)1; })); ) { char junk[4096]; long long count = (__extension__ ({ size_t (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *, void * buffer, size_t size, size_t count); __internal_VirtualMethod = ((size_t (*)(struct __ecereNameSpace__ecere__com__Instance *, void * buffer, size_t size, size_t count))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = cppOutput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__DualPipe->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Read]); __internal_VirtualMethod ? __internal_VirtualMethod(cppOutput, junk, 1, 4096) : (size_t)1; })); (__extension__ ({ size_t (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *, const void * buffer, size_t size, size_t count); __internal_VirtualMethod = ((size_t (*)(struct __ecereNameSpace__ecere__com__Instance *, const void * buffer, size_t size, size_t count))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = fileInput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__TempFile->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Write]); __internal_VirtualMethod ? __internal_VirtualMethod(fileInput, junk, 1, count) : (size_t)1; })); } exitCode = __ecereMethod___ecereNameSpace__ecere__sys__DualPipe_GetExitCode(cppOutput); (__ecereNameSpace__ecere__com__eInstance_DecRef(cppOutput), cppOutput = 0); (__extension__ ({ unsigned int (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *, long long pos, int mode); __internal_VirtualMethod = ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, long long pos, int mode))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = fileInput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__TempFile->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek]); __internal_VirtualMethod ? __internal_VirtualMethod(fileInput, 0, 0) : (unsigned int)1; })); ParseEc(); SetCurrentNameSpace((((void *)0))); SetYydebug(0); (__ecereNameSpace__ecere__com__eInstance_DecRef(fileInput), fileInput = 0); SetFileInput((((void *)0))); ast = GetAST(); if(!exitCode) { if(ast) { ProcessDBTableDefinitions(); PreCompPreProcessClassDefinitions(); } if(!((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->exitCode) OutputSymbols(GetOutputFile()); } else ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->exitCode = exitCode; if(ast) { FreeASTTree(ast); } } else { __ecereNameSpace__ecere__com__PrintLn(__ecereClass_char__PTR_, "(ecp) error: failed to execute C preprocessor", (void *)0); ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + sizeof(struct __ecereNameSpace__ecere__com__Module) + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->exitCode = 1; } FreeContext(globalContext); FreeExcludedSymbols(&_excludedSymbols); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&defines, (void *)(FreeModuleDefine)); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&imports, (void *)(FreeModuleImport)); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&precompDefines, (void *)(FreeDefinition)); FreeTypeData(privateModule); FreeIncludeFiles(); FreeGlobalData(&globalData); (__ecereNameSpace__ecere__com__eInstance_DecRef(privateModule), privateModule = 0); } (__ecereNameSpace__ecere__com__eSystem_Delete(cppCommand), cppCommand = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(cppOptions), cppOptions = 0); SetSymbolsDir((((void *)0))); } void __ecereRegisterModule_ecp(struct __ecereNameSpace__ecere__com__Instance * module) { struct __ecereNameSpace__ecere__com__Class __attribute__((unused)) * class; class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "ClassDefine", "Definition", sizeof(struct ClassDefine), 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_ClassDefine = class; __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "base", "char *", sizeof(void *), 0xF000F000, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "propertiesAndMembers", "ecere::sys::OldList", sizeof(struct __ecereNameSpace__ecere__sys__OldList), 0xF000F000, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "classProperties", "ecere::sys::OldList", sizeof(struct __ecereNameSpace__ecere__sys__OldList), 0xF000F000, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "methods", "ecere::sys::OldList", sizeof(struct __ecereNameSpace__ecere__sys__OldList), 0xF000F000, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "isRemote", "bool", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "isWatchable", "bool", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "fixed", "bool", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "noExpansion", "bool", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "accessMode", "ecere::com::AccessMode", 4, 4, 1); class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "Define", "Definition", sizeof(struct Define), 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_Define = class; __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "exp", "Expression", sizeof(void *), 0xF000F000, 1); class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "FunctionDefine", "Definition", sizeof(struct FunctionDefine), 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_FunctionDefine = class; __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "dataType", "char *", sizeof(void *), 0xF000F000, 1); class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "DataDefine", "Definition", sizeof(struct DataDefine), 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_DataDefine = class; __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "dataType", "char *", sizeof(void *), 0xF000F000, 1); class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "MethodDefine", 0, sizeof(struct MethodDefine), 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_MethodDefine = class; class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "PropertyDefine", 0, sizeof(struct PropertyDefine), 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_PropertyDefine = class; class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "DataMemberDefine", 0, sizeof(struct DataMemberDefine), 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_DataMemberDefine = class; __ecereNameSpace__ecere__com__eSystem_RegisterFunction("FreeMethodDefine", "void FreeMethodDefine(MethodDefine method)", FreeMethodDefine, module, 2); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("FreeDataMemberDefine", "void FreeDataMemberDefine(DataMemberDefine dataMember)", FreeDataMemberDefine, module, 2); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("FreeDataDefine", "void FreeDataDefine(DataDefine data)", FreeDataDefine, module, 2); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("FreeDefinition", "void FreeDefinition(Definition definition)", FreeDefinition, module, 2); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("PreCompPreProcessClassDefinitions", "void PreCompPreProcessClassDefinitions(void)", PreCompPreProcessClassDefinitions, module, 2); class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(0, "PrecompApp", "ecere::com::Application", 0, 0, (void *)0, (void *)0, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_PrecompApp = class; __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Main", 0, __ecereMethod_PrecompApp_Main, 1); }
the_stack_data/170452993.c
//@ ltl invariant negative: (<> (X (X ([] AP(x_0 - x_2 >= 2))))); float x_0; float x_1; float x_2; float x_3; int main() { float x_0_; float x_1_; float x_2_; float x_3_; while(1) { x_0_ = ((14.0 + x_0) > (4.0 + x_3)? (14.0 + x_0) : (4.0 + x_3)); x_1_ = ((20.0 + x_0) > (13.0 + x_2)? (20.0 + x_0) : (13.0 + x_2)); x_2_ = ((14.0 + x_1) > (10.0 + x_2)? (14.0 + x_1) : (10.0 + x_2)); x_3_ = ((12.0 + x_2) > (1.0 + x_3)? (12.0 + x_2) : (1.0 + x_3)); x_0 = x_0_; x_1 = x_1_; x_2 = x_2_; x_3 = x_3_; } return 0; }
the_stack_data/150143296.c
#ifdef GEKKO #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include "definitions.h" #include "wiiuse_internal.h" #include "events.h" #include "io.h" #include "lwp_wkspace.h" #define MAX_COMMANDS 0x20 static vu32 *_ipcReg = (u32*)0xCD000000; extern void parse_event(struct wiimote_t *wm); extern void idle_cycle(struct wiimote_t* wm); extern void hexdump(void *d, int len); static __inline__ u32 ACR_ReadReg(u32 reg) { return _ipcReg[reg>>2]; } static __inline__ void ACR_WriteReg(u32 reg,u32 val) { _ipcReg[reg>>2] = val; } static s32 __wiiuse_disconnected(void *arg,struct bte_pcb *pcb,u8 err) { struct wiimote_listen_t *wml = (struct wiimote_listen_t*)arg; struct wiimote_t *wm = wml->wm; if(!wm) return ERR_OK; //printf("wiimote disconnected\n"); WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_IR|WIIMOTE_STATE_IR_INIT)); WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_EXP|WIIMOTE_STATE_EXP_HANDSHAKE|WIIMOTE_STATE_EXP_FAILED)); WIIMOTE_DISABLE_STATE(wm,(WIIMOTE_STATE_CONNECTED|WIIMOTE_STATE_HANDSHAKE|WIIMOTE_STATE_HANDSHAKE_COMPLETE)); while(wm->cmd_head) { __lwp_queue_append(&wm->cmdq,&wm->cmd_head->node); wm->cmd_head = wm->cmd_head->next; } wm->cmd_tail = NULL; if(wm->event_cb) wm->event_cb(wm,WIIUSE_DISCONNECT); wml->wm = NULL; return ERR_OK; } static s32 __wiiuse_receive(void *arg,void *buffer,u16 len) { struct wiimote_listen_t *wml = (struct wiimote_listen_t*)arg; struct wiimote_t *wm = wml->wm; if(!wm || !buffer || len==0) return ERR_OK; //printf("__wiiuse_receive[%02x]\n",*(char*)buffer); wm->event = WIIUSE_NONE; memcpy(wm->event_buf,buffer,len); memset(&(wm->event_buf[len]),0,(MAX_PAYLOAD - len)); parse_event(wm); if(wm->event!=WIIUSE_NONE) { if(wm->event_cb) wm->event_cb(wm,wm->event); } return ERR_OK; } static s32 __wiiuse_connected(void *arg,struct bte_pcb *pcb,u8 err) { struct wiimote_listen_t *wml = (struct wiimote_listen_t*)arg; struct wiimote_t *wm; wm = wml->assign_cb(&wml->bdaddr); if(!wm) { bte_disconnect(wml->sock); return ERR_OK; } wml->wm = wm; wm->sock = wml->sock; wm->bdaddr = wml->bdaddr; //printf("__wiiuse_connected()\n"); WIIMOTE_ENABLE_STATE(wm,(WIIMOTE_STATE_CONNECTED|WIIMOTE_STATE_HANDSHAKE)); wm->handshake_state = 0; wiiuse_handshake(wm,NULL,0); return ERR_OK; } static s32 __wiiuse_sent(void *arg,struct bte_pcb *pcb,u8 err) { struct cmd_blk_t *cmd = NULL; struct wiimote_listen_t *wml = (struct wiimote_listen_t*)arg; struct wiimote_t *wm = wml->wm; if(!wm) return ERR_OK; cmd = wm->cmd_head; if(!cmd) return ERR_OK; if(cmd->state!=CMD_SENT) return ERR_OK; //printf("__wiiuse_sent(%p,%02x)\n",cmd,cmd->data[0]); switch(cmd->data[0]) { case WM_CMD_CTRL_STATUS: case WM_CMD_WRITE_DATA: case WM_CMD_READ_DATA: case WM_CMD_STREAM_DATA: return ERR_OK; default: wm->cmd_head = cmd->next; cmd->state = CMD_DONE; if(cmd->cb) cmd->cb(wm,NULL,0); __lwp_queue_append(&wm->cmdq,&cmd->node); wiiuse_send_next_command(wm); break; } return ERR_OK; } void __wiiuse_sensorbar_enable(int enable) { u32 val; u32 level; level = IRQ_Disable(); val = (ACR_ReadReg(0xc0)&~0x100); if(enable) val |= 0x100; ACR_WriteReg(0xc0,val); IRQ_Restore(level); } int wiiuse_register(struct wiimote_listen_t *wml, struct bd_addr *bdaddr, struct wiimote_t *(*assign_cb)(struct bd_addr *bdaddr)) { s32 err; if(!wml || !bdaddr || !assign_cb) return 0; wml->wm = NULL; wml->bdaddr = *bdaddr; wml->sock = bte_new(); wml->assign_cb = assign_cb; if(wml->sock==NULL) return 0; bte_arg(wml->sock,wml); bte_received(wml->sock,__wiiuse_receive); bte_disconnected(wml->sock,__wiiuse_disconnected); err = bte_registerdeviceasync(wml->sock,bdaddr,__wiiuse_connected); if(err==ERR_OK) return 1; return 0; } void wiiuse_disconnect(struct wiimote_t *wm) { if(wm==NULL || wm->sock==NULL) return; WIIMOTE_DISABLE_STATE(wm,WIIMOTE_STATE_CONNECTED); bte_disconnect(wm->sock); } void wiiuse_sensorbar_enable(int enable) { __wiiuse_sensorbar_enable(enable); } void wiiuse_init_cmd_queue(struct wiimote_t *wm) { u8 *buffer; u32 size; size = (MAX_COMMANDS*sizeof(struct cmd_blk_t)); buffer = __lwp_wkspace_allocate(size); __lwp_queue_initialize(&wm->cmdq,buffer,MAX_COMMANDS,sizeof(struct cmd_blk_t)); } int wiiuse_io_write(struct wiimote_t *wm,ubyte *buf,int len) { if(wm->sock) return bte_sendmessageasync(wm->sock,buf,len,__wiiuse_sent); return ERR_CONN; } #endif
the_stack_data/59511655.c
#include <stdio.h> int main() { float salario, previdencia, ir; printf("Informe o salario bruto: R$ "); scanf("%f", &salario); previdencia = salario * 0.0085; ir = previdencia * 0.0275; printf("salario bruto: %.2f\n", salario); printf("salario liquido: %.2f\n", salario - previdencia - ir); printf("previdencia: %.2f\n", previdencia); printf("ir: %.2f\n", ir); return 0; }
the_stack_data/212643291.c
/** \file dnx_cint_data.c * * Expose DNX internal functions, structures, constans, ... to cint. */ /* * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. * */ #ifdef BSL_LOG_MODULE #error "BSL_LOG_MODULE redefined" #endif #define BSL_LOG_MODULE BSL_LS_APPLDNX_INITSEQDNX typedef int dnx_cint_data_not_empty; /* Make ISO compilers happy. */ #if defined(INCLUDE_LIB_CINT) && defined(BCM_DNX_SUPPORT) /* * Include files. * { */ #include <cint_config.h> #include <cint_types.h> #include <cint_porting.h> #include <appl/reference/dnx/appl_ref_dynamic_port.h> #include <appl/reference/dnx/appl_ref_e2e_scheme.h> #include <appl/reference/dnx/appl_ref_sys_ports.h> #include <src/appl/reference/dnx/appl_ref_dram_init.h> #include <appl/diag/dnx/diag_dnx_sch.h> #include <bcm/types.h> #include <bcm/cosq.h> #include <include/bcm_int/dnx/port/port.h> #include <bcm_int/dnx/tune/tune.h> #include <bcm_int/dnx/algo/port/algo_port_mgmt.h> #include <include/bcm_int/dnx/dram/buffers/buffers_quarantine_mechanism.h> #include <src/bcm/dnx/tune/egr_queuing_tune.h> #include <src/bcm/dnx/tune/scheduler_tune.h> #include <src/appl/reference/dnx/appl_ref_sys_device.h> #include <bcm_int/dnx/cosq/ingress/cosq_ingress.h> /* * } */ CINT_FWRAPPER_CREATE_RP2(int, int, 0, 0, appl_dnx_dynamic_port_create, int,int,unit,0,0, int,int,port,0,0); CINT_FWRAPPER_CREATE_RP2(int, int, 0, 0, appl_dnx_dynamic_port_destroy, int,int,unit,0,0, int,int,port,0,0); CINT_FWRAPPER_CREATE_RP4(int, int, 0, 0, appl_dnx_e2e_scheme_logical_port_to_base_voq_get, int, int, unit, 0, 0, bcm_module_t, bcm_module_t, module_id, 0, 0, bcm_port_t, bcm_port_t, port, 0, 0, int*, int, base_voq, 1, 0); CINT_FWRAPPER_CREATE_RP4(int, int, 0, 0, appl_dnx_logical_port_to_sysport_get, int, int, unit, 0, 0, bcm_module_t, bcm_module_t, module_id, 0, 0, bcm_port_t, bcm_port_t, port, 0, 0, int*, int, system_port, 1, 0); CINT_FWRAPPER_CREATE_RP4(int, int, 0, 0, appl_dnx_logical_port_to_base_voq_connector_id_get, int, int, unit, 0, 0, bcm_port_t, bcm_port_t, port, 0, 0, bcm_module_t, bcm_module_t, remote_modid, 0, 0, int*, int, base_voq_connector, 1, 0); CINT_FWRAPPER_CREATE_RP4(int, int, 0, 0, sh_dnx_scheduler_port_actual_credit_rate_get, int, int, unit, 0, 0, int, int, core, 0, 0, int, int, port_hr, 0, 0, uint32*, uint32, credit_rate_kbps, 1, 0); CINT_FWRAPPER_CREATE_RP5(int, int, 0, 0, sh_dnx_scheduler_port_current_fc_info_get, int, int, unit, 0, 0, int, int, core, 0, 0, int, int, port_hr, 0, 0, uint32*, uint32, fc_count, 1, 0, uint32*, uint32, fc_percent, 1, 0); CINT_FWRAPPER_CREATE_RP2(int, int, 0, 0, dnx_dram_buffers_quarantine_nof_free_buffers_get, int, int, unit, 0, 0, uint32*, uint32, nof_free_buffers, 1, 0); CINT_FWRAPPER_CREATE_RP3(int, int, 0, 0, dnx_dram_buffers_quarantine_buffer_to_quarantine_schedule, int, int, unit, 0, 0, bcm_core_t, bcm_core_t, core, 0, 0, uint32, uint32, nof_free_buffers, 0, 0); CINT_FWRAPPER_CREATE_RP2(int, int, 0, 0, dnx_dram_buffers_quarantine_buffer_to_quarantine_done, int, int, unit, 0, 0, bcm_core_t, bcm_core_t, core, 0, 0); CINT_FWRAPPER_CREATE_RP4(int, int, 0, 0, dnx_port_phy_measure_get, int,int,unit,0,0, bcm_port_t,bcm_port_t,port,0,0, int,int,is_rx,0,0, soc_dnxc_port_phy_measure_t*,soc_dnxc_port_phy_measure_t,phy_measure,1,0); CINT_FWRAPPER_CREATE_RP1(int, int, 0, 0, appl_dnx_dram_power_up_handle, int, int, unit, 0, 0); CINT_FWRAPPER_CREATE_RP5(int, int, 0, 0, dnx_tune_egr_ofp_rate_set, int, int, unit, 0, 0, bcm_port_t, bcm_port_t, port, 0, 0, int, int, if_speed, 0, 0, int, int, commit_changes, 0 ,0, int, int, is_remove, 0 ,0); CINT_FWRAPPER_CREATE_RP6(int, int, 0, 0, dnx_tune_scheduler_port_rates_set, int,int,unit,0,0, bcm_port_t,bcm_port_t,port,0,0, uint32,uint32,flags,0,0, int,int,if_speed,0,0, int,int,commit_changes,0,0, int, int, is_remove, 0 ,0); CINT_FWRAPPER_CREATE_RP4(int, int, 0, 0, appl_dnx_e2e_voq_profiles_get, int, int, unit, 0, 0, int, int, speed, 0, 0, int*, int, delay_tolerance_level, 1, 0, int*, int, rate_class, 1, 0); CINT_FWRAPPER_CREATE_RP1(int, int, 0, 0, appl_dnx_e2e_profiles_create, int, int, unit, 0, 0); CINT_FWRAPPER_CREATE_RP2(int, int, 0, 0, appl_dnx_sys_device_ports_get, int, int, unit, 0, 0, bcm_pbmp_t*, bcm_pbmp_t, pbmp, 1, 0); CINT_FWRAPPER_CREATE_RP4(int, int, 0, 0, dnx_algo_port_interface_rate_get, int, int, unit, 0, 0, bcm_port_t, bcm_port_t, port, 0, 0, uint32, uint32, flags, 0, 0, int*, int, rate, 1, 0); CINT_FWRAPPER_CREATE_RP6(int, int, 0, 0, dnx_cosq_ingress_receive_shaper_grant_size_and_timer_cycles_calc, int, int, unit, 0, 0, uint32, uint32, rate, 0, 0, uint32, uint32, max_nof_timer_cycles, 0, 0, uint32, uint32, max_grant_size_val, 0, 0, uint32*, uint32, best_grant_size, 1, 0, uint32*, uint32, best_timer_cycles, 1, 0); static cint_function_t __cint_dnx_functions[] = { CINT_FWRAPPER_NENTRY("appl_dnx_dynamic_port_create", appl_dnx_dynamic_port_create), CINT_FWRAPPER_NENTRY("appl_dnx_dynamic_port_destroy", appl_dnx_dynamic_port_destroy), CINT_FWRAPPER_NENTRY("appl_dnx_e2e_scheme_logical_port_to_base_voq_get", appl_dnx_e2e_scheme_logical_port_to_base_voq_get), CINT_FWRAPPER_NENTRY("appl_dnx_logical_port_to_sysport_get", appl_dnx_logical_port_to_sysport_get), CINT_FWRAPPER_NENTRY("appl_dnx_logical_port_to_base_voq_connector_id_get", appl_dnx_logical_port_to_base_voq_connector_id_get), CINT_FWRAPPER_NENTRY("sh_dnx_scheduler_port_actual_credit_rate_get", sh_dnx_scheduler_port_actual_credit_rate_get), CINT_FWRAPPER_NENTRY("sh_dnx_scheduler_port_current_fc_info_get", sh_dnx_scheduler_port_current_fc_info_get), CINT_FWRAPPER_NENTRY("dnx_dram_buffers_quarantine_nof_free_buffers_get", dnx_dram_buffers_quarantine_nof_free_buffers_get), CINT_FWRAPPER_NENTRY("dnx_dram_buffers_quarantine_buffer_to_quarantine_schedule", dnx_dram_buffers_quarantine_buffer_to_quarantine_schedule), CINT_FWRAPPER_NENTRY("dnx_dram_buffers_quarantine_buffer_to_quarantine_done", dnx_dram_buffers_quarantine_buffer_to_quarantine_done), CINT_FWRAPPER_NENTRY("dnx_port_phy_measure_get", dnx_port_phy_measure_get), CINT_FWRAPPER_NENTRY("appl_dnx_dram_power_up_handle", appl_dnx_dram_power_up_handle), CINT_FWRAPPER_NENTRY("dnx_tune_egr_ofp_rate_set", dnx_tune_egr_ofp_rate_set), CINT_FWRAPPER_NENTRY("dnx_tune_scheduler_port_rates_set", dnx_tune_scheduler_port_rates_set), CINT_FWRAPPER_NENTRY("appl_dnx_e2e_voq_profiles_get", appl_dnx_e2e_voq_profiles_get), CINT_FWRAPPER_NENTRY("appl_dnx_e2e_profiles_create", appl_dnx_e2e_profiles_create), CINT_FWRAPPER_NENTRY("appl_dnx_sys_device_ports_get", appl_dnx_sys_device_ports_get), CINT_FWRAPPER_NENTRY("dnx_algo_port_interface_rate_get", dnx_algo_port_interface_rate_get), CINT_FWRAPPER_NENTRY("dnx_cosq_ingress_receive_shaper_grant_size_and_timer_cycles_calc", dnx_cosq_ingress_receive_shaper_grant_size_and_timer_cycles_calc), CINT_ENTRY_LAST }; static cint_parameter_desc_t __cint_struct_members__soc_dnxc_port_phy_measure_t[] = { { "int", "one_clk_time_measured_int", 0, 0 }, { "int", "one_clk_time_measured_remainder", 0, 0 }, { "int", "serdes_freq_int", 0, 0 }, { "int", "serdes_freq_remainder", 0, 0 }, { "uint32", "ref_clk_int", 0, 0 }, { "uint32", "ref_clk_remainder", 0, 0 }, { "int", "lane", 0, 0 }, { NULL } }; static void* __cint_maddr__soc_dnxc_port_phy_measure_t(void* p, int mnum, cint_struct_type_t* parent) { void* rv; soc_dnxc_port_phy_measure_t* s = (soc_dnxc_port_phy_measure_t*) p; switch(mnum) { case 0: rv = &(s->one_clk_time_measured_int); break; case 1: rv = &(s->one_clk_time_measured_remainder); break; case 2: rv = &(s->serdes_freq_int); break; case 3: rv = &(s->serdes_freq_remainder); break; case 4: rv = &(s->ref_clk_int); break; case 5: rv = &(s->ref_clk_remainder); break; case 6: rv = &(s->lane); break; default: rv = NULL; break; } return rv; } static cint_struct_type_t __cint_dnx_structures[] = { { "soc_dnxc_port_phy_measure_t", sizeof(soc_dnxc_port_phy_measure_t), __cint_struct_members__soc_dnxc_port_phy_measure_t, __cint_maddr__soc_dnxc_port_phy_measure_t }, { NULL } }; /* Defines section */ static cint_constants_t __cint_dnx_constants[] = { { "DNX_ALGO_PORT_SPEED_F_MBPS", DNX_ALGO_PORT_SPEED_F_MBPS }, { "DNX_ALGO_PORT_SPEED_F_KBPS", DNX_ALGO_PORT_SPEED_F_KBPS }, { "DNX_ALGO_PORT_SPEED_F_RX", DNX_ALGO_PORT_SPEED_F_RX }, { "DNX_ALGO_PORT_SPEED_F_TX", DNX_ALGO_PORT_SPEED_F_TX }, { NULL } }; cint_data_t dnx_cint_data = { NULL, __cint_dnx_functions, __cint_dnx_structures, NULL, NULL, __cint_dnx_constants, NULL }; #endif /* INCLUDE_LIB_CINT && (BCM_DNX_SUPPORT)*/
the_stack_data/670802.c
/** * @license Apache-2.0 * * Copyright (c) 2018 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Benchmark `cis`. */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <complex.h> #include <sys/time.h> #define NAME "cis" #define ITERATIONS 1000000 #define REPEATS 3 /** * Prints the TAP version. */ void print_version() { printf( "TAP version 13\n" ); } /** * Prints the TAP summary. * * @param total total number of tests * @param passing total number of passing tests */ void print_summary( int total, int passing ) { printf( "#\n" ); printf( "1..%d\n", total ); // TAP plan printf( "# total %d\n", total ); printf( "# pass %d\n", passing ); printf( "#\n" ); printf( "# ok\n" ); } /** * Prints benchmarks results. * * @param elapsed elapsed time in seconds */ void print_results( double elapsed ) { double rate = (double)ITERATIONS / elapsed; printf( " ---\n" ); printf( " iterations: %d\n", ITERATIONS ); printf( " elapsed: %0.9f\n", elapsed ); printf( " rate: %0.9f\n", rate ); printf( " ...\n" ); } /** * Returns a clock time. * * @return clock time */ double tic() { struct timeval now; gettimeofday( &now, NULL ); return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } /** * Generates a random double on the interval [0,1]. * * @return random double */ double rand_double() { int r = rand(); return (double)r / ( (double)RAND_MAX + 1.0 ); } /** * Runs a benchmark. * * @return elapsed time in seconds */ double benchmark() { double elapsed; double re; double im; double t; int i; double complex z1; double complex z2; t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { re = ( 100.0*rand_double() ) - 50.0; im = ( 100.0*rand_double() ) - 50.0; z2 = ( cos( re ) + I * sin( re ) ) / exp( im ); if ( z2 != z2 ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; if ( z2 != z2 ) { printf( "should not return NaN\n" ); } return elapsed; } /** * Main execution sequence. */ int main( void ) { double elapsed; int i; // Use the current time to seed the random number generator: srand( time( NULL ) ); print_version(); for ( i = 0; i < REPEATS; i++ ) { printf( "# c::%s\n", NAME ); elapsed = benchmark(); print_results( elapsed ); printf( "ok %d benchmark finished\n", i+1 ); } print_summary( REPEATS, REPEATS ); }
the_stack_data/131185.c
/* check new_complete_while_loop() for a special case */ void while10() { int i = 1; i = 2; while(1) ; i = 3; }
the_stack_data/39434.c
#include <math.h> #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/time.h> #define MILLION 1000000L int main (int argc, char *argv[]){ int adder = 0; long long catcher; int i = 0; long long increase = -1; int lengthcheck; int lengthcheck2; int loop = 1; int numfind = 0; long long *primegreater; long long primeparameter; long timedif; double timedifout; struct timeval tpend; struct timeval tpstart; if ( argc < 3 ){ fprintf(stderr, " Please enter 1 integer parameter\n"); exit(-1); } else if ( argc > 3 ){ fprintf(stderr, " Please enter 1 integer parameter\n"); exit(-1); } if ( strlen(argv[1]) > 25 ) { fprintf(stderr, " Please do not try to buffer overflow\n"); exit(-1); } if ( strlen(argv[2]) > 25 ) { fprintf(stderr, " Please do not try to buffer overflow\n"); exit(-1); } lengthcheck = strlen(argv[1]); lengthcheck2 = strlen(argv[2]); for ( i = 0; i < lengthcheck; i++){ if ( isalpha(argv[1][i]) ){ fprintf(stderr, " Please only enter digits \n"); exit(-1); } else if ( isdigit(argv[1][i]) ) { } else { fprintf(stderr," Please only enter digits \n"); exit(-1); } } for ( i = 0; i < lengthcheck2; i++){ if ( isalpha(argv[2][i]) ){ fprintf(stderr, " Please only enter digits \n"); exit(-1); } else if ( isdigit(argv[2][i]) ) { } else { fprintf(stderr," Please only enter digits \n"); exit(-1); } } fprintf(stderr, "This is part 3\n"); fprintf(stderr, "Ivan Capistran\n"); fprintf(stderr, "Parameter: %s %s\n" ,argv[1], argv[2]); primeparameter = atoll(argv[1]); numfind = atoi(argv[2]); primegreater = (long long *)malloc(sizeof(long long) * numfind); if (gettimeofday(&tpstart, NULL)) { fprintf(stderr, "Failed to get start time\n"); return 1; } while(numfind > 0){ ++increase; catcher = ( primeparameter + increase ); if ( isPrimeLongLong( catcher )){ primegreater[adder] = (catcher); ++adder; --numfind; } } if (gettimeofday(&tpend, NULL)) { fprintf(stderr, "Failed to get end time\n"); return 1; } /* standard output */ printf("%lld\n", primeparameter); for (i = 0; i < (adder); i++){ printf("%lld\n",primegreater[i]); } /* standard err */ fprintf(stderr,"%lld\n", primeparameter); for (i = 0; i < (adder); i++){ fprintf(stderr,"%lld\n",primegreater[i]); } timedif = MILLION*(tpend.tv_sec - tpstart.tv_sec) + tpend.tv_usec - tpstart.tv_usec; timedifout = timedif/1000000.0; fprintf(stderr,"%.5lf\n", timedifout); free(primegreater); return 0; }
the_stack_data/86075470.c
#include <stdio.h> int main() { int a,b,sum,n,i; scanf("%d",&n); sum=0; for(i=1; i<=n; i++) { scanf("%d",&a); sum=sum+a; } printf("%d",sum); return 0; }
the_stack_data/108407.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, R. Hrbacek, Z. Vasicek and L. Sekanina, "EvoApprox8b: Library of approximate adders and multipliers for circuit design and benchmarking of approximation methods". Design, Automation & Test in Europe Conference & Exhibition (DATE), 2017, Lausanne, 2017, pp. 258-261. doi: 10.23919/DATE.2017.7926993 * This file contains a circuit from evoapprox8b dataset. Note that a new version of library was already published. ***/ #include <stdint.h> #include <stdlib.h> /// Approximate function add8_016 /// Library = EvoApprox8b /// Circuit = add8_016 /// Area (180) = 528 /// Delay (180) = 0.830 /// Power (180) = 141.90 /// Area (45) = 39 /// Delay (45) = 0.310 /// Power (45) = 13.83 /// Nodes = 7 /// HD = 190592 /// MAE = 5.31250 /// MSE = 42.50000 /// MRE = 2.83 % /// WCE = 15 /// WCRE = 700 % /// EP = 93.8 % uint16_t add8_016(uint8_t a, uint8_t b) { uint16_t c = 0; uint8_t n4 = (a >> 2) & 0x1; uint8_t n6 = (a >> 3) & 0x1; uint8_t n8 = (a >> 4) & 0x1; uint8_t n10 = (a >> 5) & 0x1; uint8_t n12 = (a >> 6) & 0x1; uint8_t n14 = (a >> 7) & 0x1; uint8_t n24 = (b >> 4) & 0x1; uint8_t n26 = (b >> 5) & 0x1; uint8_t n28 = (b >> 6) & 0x1; uint8_t n30 = (b >> 7) & 0x1; uint8_t n36; uint8_t n93; uint8_t n126; uint8_t n127; uint8_t n232; uint8_t n233; uint8_t n282; uint8_t n283; uint8_t n332; uint8_t n333; uint8_t n382; uint8_t n383; n36 = ~(n4 ^ n4); n93 = ~n36; n126 = ~n93; n127 = ~n93; n232 = n8 ^ n24; n233 = n8 & n24; n282 = (n10 ^ n26) ^ n233; n283 = (n10 & n26) | (n26 & n233) | (n10 & n233); n332 = (n12 ^ n28) ^ n283; n333 = (n12 & n28) | (n28 & n283) | (n12 & n283); n382 = (n14 ^ n30) ^ n333; n383 = (n14 & n30) | (n30 & n333) | (n14 & n333); c |= (n127 & 0x1) << 0; c |= (n126 & 0x1) << 1; c |= (n126 & 0x1) << 2; c |= (n6 & 0x1) << 3; c |= (n232 & 0x1) << 4; c |= (n282 & 0x1) << 5; c |= (n332 & 0x1) << 6; c |= (n382 & 0x1) << 7; c |= (n383 & 0x1) << 8; return c; }
the_stack_data/248581207.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #define HASHSIZE 101 struct nlist { /* table entry: */ struct nlist *next; /* next entry in chain */ char *name; /* defined name */ char *defn; /* replacement text */ }; static struct nlist *hashtab[HASHSIZE]; /* pointer table */ char *istrdup(char *); /* hash: form hash value for string s */ unsigned hash(char *s) { unsigned hashval; for (hashval = 0; *s != '\0'; s++) hashval = *s + 31 * hashval; return hashval % HASHSIZE; } /* lookup: look for s in hashtab */ void print_list() { struct nlist *np; int i; printf("\n\nPrinting actual list\n"); for (i = 0 ; i < HASHSIZE ; i++){ for (np = hashtab[i]; np != NULL; np = np->next) printf("HASH: %d Name:%s Definition:%s\n", i, np->name, np->defn); } } /* lookup: look for s in hashtab */ struct nlist *lookup(char *s) { struct nlist *np; for (np = hashtab[hash(s)]; np != NULL; np = np->next) if (strcmp(s, np->name) == 0) return np; /* found */ return NULL; /* not found */ } /* install: put (name, defn) in hashtab */ struct nlist *install(char *name, char *defn) { struct nlist *np; unsigned hashval; if ((np = lookup(name)) == NULL) { /* not found */ np = (struct nlist *) malloc(sizeof(*np)); if (np == NULL || (np->name = strdup(name)) == NULL) return NULL; hashval = hash(name); np->next = hashtab[hashval]; hashtab[hashval] = np; } else /* already there */ free((void *) np->defn); /*free previous defn */ if ((np->defn = istrdup(defn)) == NULL) return NULL; return np; } char *istrdup(char *s) /* make a duplicate of s */ { char *p; p = (char *) malloc(strlen(s)+1); /* +1 for '\0' */ if (p != NULL) strcpy(p, s); return p; } /* install: put (name, defn) in hashtab */ struct nlist *undef(char *name, char *defn) { struct nlist *np; unsigned hashval; if ((np = lookup(name)) != NULL) { if (np == hashtab[hash(name)]){ hashtab[hash(name)] = np->next; free((void *) np->defn); free(np); }else{ struct nlist *p, *prev = hashtab[hash(name)]; p = prev->next; while (p!= NULL) { if (p != np) { p = p->next; prev = prev->next; } else break; } prev->next = p->next; free((void *) np->defn); free(np); } } } int main(){ install("alex", "superman"); install("bogdan", "batman"); install("andrei", "spiderman"); print_list(); printf("Undef bogan, batman\n"); undef("bogdan", "batman"); print_list(); printf("Undef alex, superman\n"); undef("alex", "superman"); print_list(); }
the_stack_data/20450906.c
#include <stdio.h> // 你的程序要读入一个整数,范围是[-100000,100000]。然后,用汉语拼音将这个整数的每一位输出出来。 // 如输入1234,则输出: // yi er san si // 注意,每个字的拼音之间有一个空格,但是最后的字后面没有空格。当遇到负数时,在输出的开头加上“fu”,如-2341输出为: // fu er san si yi void printOneNumber(int num); void printNumber(int num, int isPrintBlank); int main(int argc, char const *argv[]) { int num; scanf("%d", &num); if (num < 0) { printf("fu "); num = -num; } printNumber(num, 0); } // 面向过程编程 // 递归 void printNumber(int num, int isPrintBlank) { int rest = num % 10; int temp = num / 10; if (temp > 0) { printNumber(temp, 1); } printOneNumber(rest); if (isPrintBlank) { printf(" "); } else { printf("\n"); } } void printOneNumber(int num) { switch (num) { case 0: printf("ling"); break; case 1: printf("yi"); break; case 2: printf("er"); break; case 3: printf("san"); break; case 4: printf("si"); break; case 5: printf("wu"); break; case 6: printf("liu"); break; case 7: printf("qi"); break; case 8: printf("ba"); break; case 9: printf("jiu"); break; default: break; } }
the_stack_data/153268770.c
/* vim: set ts=4 sw=4 tw=100 et : */ /* * MIT License * * Copyright (c) 2021 Riccardo Paolo Bestetti * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/uinput.h> #define die(str) { \ perror(str); \ exit(EXIT_FAILURE); \ }; #if 0 #define dbg(...) fprintf(stderr, __VA_ARGS__) #else #define dbg(...) #endif int key_map[] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0-7 */ 0, 0, KEY_ENTER, 0, /* 8-11 */ 0, KEY_ENTER, 0, 0, /* 12-15 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 16-23 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 24-31 */ KEY_SPACE, 0, 0, 0, 0, 0, 0, 0, /* 32-39 */ 0, 0, 0, 0, /* 40-43 */ KEY_COMMA, 0, KEY_DOT, 0, /* 44-47 */ KEY_0, KEY_1, KEY_2, KEY_3, /* 48-51 */ KEY_4, KEY_5, KEY_6, KEY_7, /* 52-55 */ KEY_8, KEY_9, 0, 0, 0, 0, 0, 0, /* 56-63 */ 0, KEY_A, KEY_B, KEY_C, /* 64-67 */ KEY_D, KEY_E, KEY_F, KEY_G, /* 68-71 */ KEY_H, KEY_I, KEY_J, KEY_K, /* 72-75 */ KEY_L, KEY_M, KEY_N, KEY_O, /* 76-79 */ KEY_P, KEY_Q, KEY_R, KEY_S, /* 80-83 */ KEY_T, KEY_U, KEY_V, KEY_W, /* 84-87 */ KEY_X, KEY_Y, KEY_Z, 0, /* 88-91 */ 0, 0, 0, 0, /* 92-95 */ 0, KEY_A, KEY_B, KEY_C, /* 96-99 */ KEY_D, KEY_E, KEY_F, KEY_G, /* 100-103 */ KEY_H, KEY_I, KEY_J, KEY_K, /* 104-107 */ KEY_L, KEY_M, KEY_N, KEY_O, /* 108-111 */ KEY_P, KEY_Q, KEY_R, KEY_S, /* 112-115 */ KEY_T, KEY_U, KEY_V, KEY_W, /* 116-119 */ KEY_X, KEY_Y, KEY_Z, 0, /* 120-123 */ 0, 0, 0, 0 /* 124-127 */ }; int mod_map[] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0-7 */ 0, 0, 0, 0, /* 8-11 */ 0, 0, 0, 0, /* 12-15 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 16-23 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 24-31 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 32-39 */ 0, 0, 0, 0, /* 40-43 */ 0, 0, 0, 0, /* 44-47 */ 0, 0, 0, 0, /* 48-51 */ 0, 0, 0, 0, /* 52-55 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 56-63 */ 0, 1, 1, 1, /* 64-67 */ 1, 1, 1, 1, /* 68-71 */ 1, 1, 1, 1, /* 72-75 */ 1, 1, 1, 1, /* 76-79 */ 1, 1, 1, 1, /* 80-83 */ 1, 1, 1, 1, /* 84-87 */ 1, 1, 1, 0, /* 88-91 */ 0, 0, 0, 0, /* 92-95 */ 0, 0, 0, 0, /* 96-99 */ 0, 0, 0, 0, /* 100-103 */ 0, 0, 0, 0, /* 104-107 */ 0, 0, 0, 0, /* 108-111 */ 0, 0, 0, 0, /* 112-115 */ 0, 0, 0, 0, /* 116-119 */ 0, 0, 0, 0, /* 120-123 */ 0, 0, 0, 0, /* 124-127 */ KEY_LEFTSHIFT /* the mod key */ }; int setup_uinput() { struct uinput_setup usetup; int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); if (fd < 0) die("error: open"); if (ioctl(fd, UI_SET_EVBIT, EV_KEY) < 0) die("error: ioctl1"); for (size_t i = 0; i < sizeof(key_map) / sizeof (key_map[0]); i++) if (ioctl(fd, UI_SET_KEYBIT, key_map[i]) < 0) die("error: ioctl2a"); if (ioctl(fd, UI_SET_KEYBIT, mod_map[128]) < 0) die("error: ioctl2b"); memset(&usetup, 0, sizeof(usetup)); usetup.id.bustype = BUS_VIRTUAL; usetup.id.vendor = 0x5697; usetup.id.product = 0x0001; strcpy(usetup.name, "bestowedge"); if (ioctl(fd, UI_DEV_SETUP, &usetup) < 0) die("error: ioctl3"); if (ioctl(fd, UI_DEV_CREATE) < 0) die("error: ioctl4"); return fd; } void emit_key(int fd, int code, int val) { struct input_event ie; ie.type = EV_KEY; ie.code = code; ie.value = val; ie.time.tv_sec = 0; ie.time.tv_usec = 0; write(fd, &ie, sizeof(ie)); } void emit_syn(int fd) { struct input_event ie; ie.type = EV_SYN; ie.code = SYN_REPORT; ie.value = 0; ie.time.tv_sec = 0; ie.time.tv_usec = 0; write(fd, &ie, sizeof(ie)); } void emit_key_event(int fd, int code, int press) { dbg("ev code %d (p? %d)", code, press); emit_key(fd, code, press); emit_syn(fd); } int main() { int fd = setup_uinput(); int ch; while ((ch = getchar()) != EOF) { dbg("proc '%c' (%d)\n", ch, ch); if (mod_map[ch]) emit_key_event(fd, mod_map[128], 1); emit_key_event(fd, key_map[ch], 1); emit_key_event(fd, key_map[ch], 0); if (mod_map[ch]) emit_key_event(fd, mod_map[128], 0); } ioctl(fd, UI_DEV_DESTROY); close(fd); }
the_stack_data/1151090.c
// 'press enter to continue' menu feature, menu numbering to be updated #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> // create the following binary files beforehand char path1[] = "data.bin"; char path2[] = "paymentInfo.bin"; // file pointer location FILE* fpl = 0; int recCount = 0; typedef struct date { int dd; int mm; int yy; } DATE_T; typedef struct paymentInfo { char cardNum[16]; DATE_T expDate; int cvv; float deduct; } PAY_T; typedef struct itemInfo { char medName[128]; DATE_T medMan; DATE_T medExp; float unitCost; int qty; int safetyStock; char refID[32]; // 8 character ID char type[32]; // eg. : tablet, syrup, injection, inhalable, etc. } ITEM_T; void clrscr() { system("@cls||clear"); } void delay(int number_of_seconds) { int milli_seconds = 1000 * number_of_seconds; clock_t start_time = clock(); while (clock() < start_time + milli_seconds); } int dateCompare(DATE_T d1, DATE_T d2) // function to accept date variables and compare - returns 1(d1 > d2), 0(d1 = d2), -1(d1 < d2) { if (d1.yy > d2.yy) return 1; else if (d1.yy < d2.yy) return -1; else { if (d1.mm > d2.mm) return 1; else if (d1.mm < d2.mm) return -1; else { if (d1.dd > d2.dd) return 1; else if (d1.dd < d2.dd) return -1; else return 0; } } } void mainMenu(int ch) { A: switch (ch) { case 1: newPurchase(); break; case 2: addItem(); break; case 3: deleteItem(); break; case 4: viewItems(); break; case 5: viewPaymentInfo(); break; case 6: reviewWarnings(); break; case 7: //changeEncryptionKey(); break; case 8: exit(0); break; default: printf("\nInvalid entry. Try again ... "); goto A; break; } } void newPurchase() { FILE* fp; FILE* fp_tmp; FILE* fp_pay; int found = 0; int purqty; float totalCost; ITEM_T myrecord; PAY_T mypayment; char searchname[16]; int i = 0; fp = fopen(path1, "r"); if (!fp) { printf("Unable to open file"); exit(0); } fp_tmp = fopen("tmp.bin", "wb"); if (!fp_tmp) { printf("Unable to open temp file"); exit(0); } fp_pay = fopen(path2, "wb"); if (!fp_pay) { printf("Unable to open payment information file"); exit(0); } do { recCount++; found = 0; printf("\n____________________________________________________________________________________\n"); printf("Input the name of the medicine to be purchased : "); scanf(" %[^\n]%*c", searchname); printf("Input the quantity to be purchased : "); scanf(" %d", &purqty); printf("Input card number : "); scanf(" %[^\n]%*c", mypayment.cardNum); printf("Input date of expiry in dd <enter> mm <enter> yy format\n"); scanf(" %d", &mypayment.expDate.dd); scanf(" %d", &mypayment.expDate.mm); scanf(" %d", &mypayment.expDate.yy); printf("Input CVV : "); scanf(" %d", &mypayment.cvv); printf("____________________________________________________________________________________\n"); while (fread(&myrecord, sizeof(ITEM_T), 1, fp) != NULL) { if (strcmp(searchname, myrecord.medName) == 0) { mypayment.deduct = purqty * myrecord.unitCost; myrecord.qty -= purqty; fwrite(&myrecord, sizeof(ITEM_T), 1, fp_tmp); fwrite(&mypayment, sizeof(PAY_T), 1, fp_pay); found = 1; } else { fwrite(&myrecord, sizeof(ITEM_T), 1, fp_tmp); } } if (!found) printf("No record(s) found with the requested name: %s\n\n", searchname); char writeAnother; int writeAnotherCounter = 0; do { printf("\nWould you like to make another purchase? (y/n) "); scanf("%s", &writeAnother); switch (writeAnother) { case 'y': i = 0; writeAnotherCounter = 1; break; case 'n': i = 1; writeAnotherCounter = 1; break; default: printf("Please enter a valid condition! \n"); break; } } while (writeAnotherCounter != 1); } while (i != 1); fclose(fp); fclose(fp_tmp); fclose(fp_pay); remove(path1); rename("tmp.bin", path1); } void addItem() { FILE* fp; ITEM_T newrecord; int i = 0; // Open for binary writing fp = fopen(path1, "wb"); if (!fp) { printf("Unable to open file!"); exit(0); } /* // test cases (old version) strcpy(newrecord.medName, "paracetamol"); newrecord.qty = 12; strcpy(newrecord.refID, "A1B2C3"); strcpy(newrecord.type, "Tablet"); fwrite(&newrecord, sizeof(ITEM_T), 1, fp); strcpy(newrecord.medName, "benadryl"); newrecord.qty = 13; strcpy(newrecord.refID, "A1B2C4"); strcpy(newrecord.type, "Syrup"); fwrite(&newrecord, sizeof(ITEM_T), 1, fp); strcpy(newrecord.medName, "asthalin"); newrecord.qty = 14; strcpy(newrecord.refID, "A1B2C5"); strcpy(newrecord.type, "Inhalable"); fwrite(&newrecord, sizeof(ITEM_T), 1, fp); strcpy(newrecord.medName, "covaxin"); newrecord.qty = 12; strcpy(newrecord.refID, "A1B2C6"); strcpy(newrecord.type, "Injection"); fwrite(&newrecord, sizeof(ITEM_T), 1, fp); */ do { recCount++; printf("\n____________________________________________________________________________________\nInput medicine details : \n____________________________________________________________________________________\n"); printf("Input name (w/ brand) : "); scanf(" %[^\n]%*c", newrecord.medName); printf("Input date of manufacture in dd <enter> mm <enter> yy format\n"); scanf(" %d", &newrecord.medMan.dd); scanf(" %d", &newrecord.medMan.mm); scanf(" %d", &newrecord.medMan.yy); printf("Input date of expiry in dd <enter> mm <enter> yy format\n"); scanf(" %d", &newrecord.medExp.dd); scanf(" %d", &newrecord.medExp.mm); scanf(" %d", &newrecord.medExp.yy); printf("Input cost per unit : "); scanf(" %f", &newrecord.unitCost); printf("Input stock quantity : "); scanf(" %d", &newrecord.qty); printf("Input safety stock quantity : "); scanf(" %d", &newrecord.safetyStock); printf("Input reference ID : "); scanf(" %[^\n]%*c", newrecord.refID); printf("Input type (manner of consumption) : "); scanf(" %[^\n]%*c", newrecord.type); printf("\n____________________________________________________________________________________\n"); fwrite(&newrecord, sizeof(ITEM_T), 1, fp); char writeAnother; int writeAnotherCounter = 0; do { printf("\nWould you like to write another record? (y/n) "); scanf("%s", &writeAnother); switch (writeAnother) { case 'y': i = 0; writeAnotherCounter = 1; break; case 'n': i = 1; writeAnotherCounter = 1; break; default: printf("Please enter a valid condition! \n"); break; } } while (writeAnotherCounter != 1); } while (i != 1); fclose(fp); } void viewItems() { FILE* fp; ITEM_T myrecord; int count = 1; fp = fopen(path1, "rb"); if (!fp) { printf("Unable to open file!"); exit(0); } printf("\n____________________________________________________________________________________\nThe following records are in the binary file: \n____________________________________________________________________________________\n"); while (fread(&myrecord, sizeof(ITEM_T), 1, fp) != NULL) { printf("\n"); printf("Serial number : %d\n", count++); printf("Name : %s\n", myrecord.medName); printf("Date of manufacture : %d / %d / %d\n", myrecord.medMan.dd, myrecord.medMan.mm, myrecord.medMan.yy); printf("Date of expiry : %d / %d / %d\n", myrecord.medExp.dd, myrecord.medExp.mm, myrecord.medExp.yy); printf("Cost per unit : %f\n", myrecord.unitCost); printf("Quantity in stock : %d\n", myrecord.qty); printf("Safety stock : %d\n", myrecord.safetyStock); printf("Reference ID : %s\n", myrecord.refID); printf("Type : %s\n", myrecord.type); printf("\n"); } fclose(fp); } void viewPaymentInfo() { FILE* fp; PAY_T myrecord; int count = 1; fp = fopen(path2, "rb"); if (!fp) { printf("Unable to open file!"); exit(0); } printf("\n____________________________________________________________________________________\nThe following records are in the binary file: \n____________________________________________________________________________________\n"); while (fread(&myrecord, sizeof(PAY_T), 1, fp) != NULL) { printf("\n"); printf("Serial number : %d\n", count++); printf("Card number : %s\n", myrecord.cardNum); printf("Date of expiry : %d / %d / %d\n", myrecord.expDate.dd, myrecord.expDate.mm, myrecord.expDate.yy); printf("CVV : %d\n", myrecord.cvv); printf("Amount deducted : %f\n", myrecord.deduct); printf("\n"); } fclose(fp); } void deleteItem() { FILE* fp; FILE* fp_tmp; int found = 0; ITEM_T myrecord; char searchname[16]; printf("\n____________________________________________________________________________________\n"); printf("Input the name of the record to be deleted : "); scanf(" %[^\n]%*c", searchname); printf("____________________________________________________________________________________\n"); fp = fopen(path1, "rb"); if (!fp) { printf("Unable to open file"); exit(0); } fp_tmp = fopen("tmp.bin", "wb"); if (!fp_tmp) { printf("Unable to open temp file"); exit(0); } while (fread(&myrecord, sizeof(ITEM_T), 1, fp) != NULL) { if (strcmp(searchname, myrecord.medName) == 0) { printf("A record with requested name found and deleted.\n\n"); found = 1; } else { fwrite(&myrecord, sizeof(ITEM_T), 1, fp_tmp); } } if (!found) { printf("No record(s) found with the requested name: %s\n\n", searchname); } fclose(fp); fclose(fp_tmp); remove(path1); rename("tmp.bin", path1); } void reviewWarnings() { FILE* fp; ITEM_T myrecord; DATE_T today; int count = 1; fp = fopen(path1, "rb"); if (!fp) { printf("Unable to open file!"); exit(0); } time_t t = time(NULL); struct tm tm = *localtime(&t); today.yy = tm.tm_year + 1900; today.mm = tm.tm_mon + 1; today.dd = tm.tm_mday; printf("\n____________________________________________________________________________________\nThe following records are in the binary file: \n____________________________________________________________________________________\n"); while (fread(&myrecord, sizeof(ITEM_T), 1, fp) != NULL) { if (myrecord.qty <= myrecord.safetyStock) { printf("\n"); printf("Serial number : %d\n", count++); printf("Name : %s\n", myrecord.medName); printf("Date of manufacture : %d / %d / %d\n", myrecord.medMan.dd, myrecord.medMan.mm, myrecord.medMan.yy); printf("Date of expiry : %d / %d / %d\n", myrecord.medExp.dd, myrecord.medExp.mm, myrecord.medExp.yy); printf("Cost per unit : %f\n", myrecord.unitCost); printf("Quantity in stock : %d\n", myrecord.qty); printf("Safety stock : %d\n", myrecord.safetyStock); printf("Reference ID : %s\n", myrecord.refID); printf("Type : %s\n", myrecord.type); printf("Warning : Inadequate safety stock. Restock immediately\n", myrecord.type); printf("\n"); } if (dateCompare(today, myrecord.medExp) > 0) { printf("\n"); printf("Serial number : %d\n", count++); printf("Name : %s\n", myrecord.medName); printf("Date of manufacture : %d / %d / %d\n", myrecord.medMan.dd, myrecord.medMan.mm, myrecord.medMan.yy); printf("Date of expiry : %d / %d / %d\n", myrecord.medExp.dd, myrecord.medExp.mm, myrecord.medExp.yy); printf("Cost per unit : %f\n", myrecord.unitCost); printf("Quantity in stock : %d\n", myrecord.qty); printf("Safety stock : %d\n", myrecord.safetyStock); printf("Reference ID : %s\n", myrecord.refID); printf("Type : %s\n", myrecord.type); printf("Warning : Stock expired. Discard immediately\n", myrecord.type); printf("\n"); } } fclose(fp); } int main() { int ch; char dummy; A: delay(4); clrscr(); printf("\n________________________________________________________________________________________\n"); printf("MENU"); printf("\n________________________________________________________________________________________\n"); printf("1. New purchase\n"); printf("2. Add items\n"); printf("3. Delete item\n"); printf("4. View items\n"); printf("5. View payment information\n"); printf("6. Review warnings\n"); printf("7. Change encryption key\n"); // function pending printf("8. Exit"); printf("\n________________________________________________________________________________________\n"); printf("Input your choice : "); scanf(" %d", &ch); printf("\n________________________________________________________________________________________\n"); switch (ch) { case 1: mainMenu(1); break; case 2: mainMenu(2); break; case 3: mainMenu(3); break; case 4: mainMenu(4); delay(10); break; case 5: mainMenu(5); break; case 6: mainMenu(6); break; case 7: mainMenu(7); break; case 8: mainMenu(8); break; default: printf("\nInvalid entry. Try again ... "); goto A; break; } // system("pause"); goto A; return 0; }
the_stack_data/147903.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned short input[1] , unsigned short output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; void megaInit(void) { { } } void RandomFunc(unsigned short input[1] , unsigned short output[1] ) { unsigned short state[1] ; unsigned short local1 ; { state[0UL] = (input[0UL] + 914778474UL) ^ (unsigned short)11; local1 = 0UL; while (local1 < 1UL) { state[local1] |= (state[local1] & (unsigned short)31) << 4UL; local1 ++; } output[0UL] = (state[0UL] >> (unsigned short)1) | (state[0UL] << (unsigned short)15); } } int main(int argc , char *argv[] ) { unsigned short input[1] ; unsigned short output[1] ; int randomFuns_i5 ; unsigned short randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = (unsigned short )strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == (unsigned short)31026) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%u\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } }
the_stack_data/26578.c
// this took me a couple of tries // there's probably a bug i didn't see when i tested this // known issues: // - lines where comments used to be do not get removed for the most part // this could be fixed by using that getline function i used about 1000 times // but i decided to not use it this time for whatever reason // i may rewrite this in the future to use getline but c99 kushblazingjudah.c // is too hard right now #include <stdio.h> #define OUT 0 #define IN 1 #define INMULTI 2 #define INSTRING 3 #define INLITERAL 4 int main(void) { int c; int last = 0; int state = OUT; int forwardslash = 0; /* This is a multiline comment on one line. */ // This is a single comment. /* Multiline * Comment */ while ((c = getchar()) != EOF) { if (state == OUT) { if (c == '/') // Comments inside of lines. forwardslash = 1; if (last != '\\' && c == '"') { state = INSTRING; /* Here's a multiline comment. */ putchar(c); } else if (last != '\\' && c == '\'') { state = INLITERAL; putchar(c); } else if (last == '/' && c == '/') { state = IN; } else if (last == '/' && c == '*') { state = INMULTI; } else { if (c == '/' && last != '/' && forwardslash) { forwardslash = 1; } else { putchar(c); } } } else if (state == IN && c == '\n') { state = OUT; putchar(c); } else if (state == INMULTI && last == '*' && c == '/') { state = OUT; } else if (state != IN && state != INMULTI) { putchar(c); } if (state == INSTRING && c == '"' && last != '\\') state = OUT; else if (state == INLITERAL && c == '\'' && last != '\\') state = OUT; last = c; } }
the_stack_data/31387782.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, L. Sekanina, Z. Vasicek "Libraries of Approximate Circuits: Automated Design and Application in CNN Accelerators" IEEE Journal on Emerging and Selected Topics in Circuits and Systems, Vol 10, No 4, 2020 * This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and mae parameters ***/ // MAE% = 0.81 % // MAE = 33 // WCE% = 2.10 % // WCE = 86 // WCRE% = 6400.00 % // EP% = 99.22 % // MRE% = 12.63 % // MSE = 1513 // PDK45_PWR = 0.023 mW // PDK45_AREA = 48.8 um2 // PDK45_DELAY = 0.43 ns #include <stdint.h> #include <stdlib.h> uint64_t add12se_5CX(const uint64_t B,const uint64_t A) { uint64_t dout_38, dout_39, dout_40, dout_41, dout_42, dout_43, dout_44, dout_45, dout_46, dout_47, dout_48, dout_58, dout_59, dout_60, dout_61, dout_62, dout_63, dout_74, dout_75, dout_76, dout_77, dout_78, dout_79, dout_88, dout_89, dout_90, dout_91, dout_92, dout_93, dout_94, dout_95, dout_96, dout_97, dout_98, dout_99, dout_100, dout_107, dout_108, dout_109, dout_110, dout_111, dout_112; uint64_t O; dout_38=((A >> 7)&1)&((B >> 7)&1); dout_39=((A >> 7)&1)^((B >> 7)&1); dout_40=((A >> 8)&1)&((B >> 8)&1); dout_41=((A >> 8)&1)^((B >> 8)&1); dout_42=((A >> 9)&1)&((B >> 9)&1); dout_43=((A >> 9)&1)^((B >> 9)&1); dout_44=((A >> 10)&1)&((B >> 10)&1); dout_45=((A >> 10)&1)^((B >> 10)&1); dout_46=((A >> 11)&1)&((B >> 11)&1); dout_47=((A >> 11)&1)^((B >> 11)&1); dout_48=((A >> 11)&1)^((B >> 11)&1); dout_58=dout_41&dout_38; dout_59=dout_41&dout_39; dout_60=dout_40|dout_58; dout_61=dout_45&dout_42; dout_62=dout_45&dout_43; dout_63=dout_44|dout_61; dout_74=dout_43&dout_60; dout_75=dout_43&dout_59; dout_76=dout_42|dout_74; dout_77=dout_62&dout_60; dout_78=dout_62&dout_59; dout_79=dout_63|dout_77; dout_88=dout_47&dout_79; dout_89=dout_47&dout_78; dout_90=dout_46|dout_88; dout_91=dout_39&((B >> 6)&1); dout_92=dout_38|dout_91; dout_93=dout_59&((B >> 6)&1); dout_94=dout_60|dout_93; dout_95=dout_75&((B >> 6)&1); dout_96=dout_76|dout_95; dout_97=dout_78&((B >> 6)&1); dout_98=dout_79|dout_97; dout_99=dout_89&((B >> 6)&1); dout_100=dout_90|dout_99; dout_107=dout_39^((B >> 6)&1); dout_108=dout_41^dout_92; dout_109=dout_43^dout_94; dout_110=dout_45^dout_96; dout_111=dout_47^dout_98; dout_112=dout_48^dout_100; O = 0; O |= (dout_111&1) << 0; O |= (0&1) << 1; O |= (0&1) << 2; O |= (((A >> 4)&1)&1) << 3; O |= (0&1) << 4; O |= (((A >> 5)&1)&1) << 5; O |= (((A >> 6)&1)&1) << 6; O |= (dout_107&1) << 7; O |= (dout_108&1) << 8; O |= (dout_109&1) << 9; O |= (dout_110&1) << 10; O |= (dout_111&1) << 11; O |= (dout_112&1) << 12; return O; }
the_stack_data/82951210.c
int frob() { return 4; }
the_stack_data/153267766.c
#include <stdbool.h> #include <stdlib.h> #include <string.h> typedef struct Trie { int val; struct Trie *node[26]; } Trie; struct Trie *createNode(int val) { Trie *node = (Trie *)malloc(sizeof(Trie)); memset(node, 0, sizeof(Trie)); node->val = val; return node; } void insert(Trie *root, char *s) { while (*s) { int index = *s - 'a'; if (!root->node[index]) root->node[index] = createNode(0); root = root->node[index]; ++s; } root->val = 1; } char **addString(char **res, int *size, char *s, int len) { res = (char **)realloc(res, sizeof(char *) * (*size + 1)); res[(*size)++] = strdup(s); return res; } void dfs(Trie *root, Trie *node, char *s, char *buff, int index, int *size, char ***res) { if (!*s) { if (node && node->val == 1) { buff[index] = '\0'; *res = addString(*res, size, buff, index); } return; } if (!node) return; if (node->val == 1) { buff[index] = ' '; dfs(root, root, s, buff, index + 1, size, res); } buff[index] = *s; int tmp = *s - 'a'; dfs(root, node->node[tmp], s + 1, buff, index + 1, size, res); } bool canBreak(char *s, char **wordDict, int wordDictSize) { if (wordDictSize == 0) return false; int N = strlen(s); bool dp[N + 1]; memset(dp, 0, sizeof(dp)); dp[0] = true; int wordDictColSize[wordDictSize]; for (int i = 0; i < wordDictSize; ++i) wordDictColSize[i] = strlen(wordDict[i]); for (int i = 0; i < N; ++i) { for (int j = i; j >= 0 && !dp[i + 1]; --j) { for (int k = 0; k < wordDictSize; ++k) { if (wordDictColSize[k] == i - j + 1 && strncmp(wordDict[k], s + j, i - j + 1) == 0) dp[i + 1] = dp[j]; } } } return dp[N]; } /** * Note: The returned array must be malloced, assume caller calls free(). */ char **wordBreak(char *s, char **wordDict, int wordDictSize, int *returnSize) { *returnSize = 0; if (!canBreak(s, wordDict, wordDictSize)) return NULL; //create Trie Trie *root = createNode(0); for (int i = 0; i < wordDictSize; ++i) insert(root, wordDict[i]); char buff[1000]; char **res = 0; dfs(root, root, s, buff, 0, returnSize, &res); return res; }
the_stack_data/31388794.c
// Write a program to list the files given as arguments, stopping every 20 lines // until a key is hit. (a simple version of more UNIX utility) #include <stdio.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { int sfd, sfd2, i = 0, j = 0, k = 0; char s[100], s2[100], c; if(argc != 3) { printf("Arguments less than 3\n"); exit(1); } if((sfd = open(argv[1], O_RDONLY)) == -1) { printf("File cannot be opened\n"); exit(1); } while((read(sfd,&c,1)) > 0) { if(c != '\n') { s[i] = c; i++; } else { j++; k++; s[i] = '\0'; i = 0; printf("Line: %d \t %s \n", k, s); if(j == 20) { // gets next character fgetc(stdin); j = 0; } } } close(sfd); if((sfd2 = open(argv[2], O_RDONLY)) == -1) { printf("File cannot be opened\n"); exit(1); } k = 0; while((read(sfd, &c, 1))>0) { if(c != '\n') { s2[i] = c; i++; } else { j++; k++; s2[i] = '\0'; i = 0; printf("l: %d \t %s \n", k, s2); if(j == 20) { fgetc(stdin); j = 0; } } } exit(0); }
the_stack_data/106799.c
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <time.h> #include <fcntl.h> #include <string.h> #include <sys/stat.h> #define ERR_EXIT(m) \ do\ {\ perror(m);\ exit(EXIT_FAILURE);\ }\ while (0);\ void creat_daemon(void); int main(void) { time_t t; int fd; if(daemon(1, 0) == -1) ERR_EXIT("daemon error"); while(1){ fd = open("daemon.log",O_WRONLY|O_CREAT|O_APPEND,0644); if(fd == -1) ERR_EXIT("open error"); t = time(0); char *buf = asctime(localtime(&t)); write(fd,buf,strlen(buf)); close(fd); sleep(60); } return 0; }
the_stack_data/173579335.c
int foo(int, int, int); int func(int n1, int n2, int n3) { int res=0;; int v1=0; while(v1<n1) { for(int v2=0; v2<n2; v2++) { int v3=0; while(v3<n3) { res+=foo(v1,v2,v3); v3++; } } v1++; } return(res); }
the_stack_data/148915.c
extern void abort (void); extern void exit (int); int foo (int x) { if (x == -2 || -x - 100 >= 0) abort (); return 0; } int main () { foo (-3); foo (-99); exit (0); }
the_stack_data/726429.c
#include <stdio.h> int nxt[200009], vis[200009]; #define check(luotianyi) do { \ if (vis[(luotianyi)]) \ goto NEXT; \ else \ vis[(luotianyi)] = 1; \ } while (0) int main(void) { int n, i, min = 0x7f7f7f7f; scanf("%d", &n); for (i = 1; i <= n; ++i) scanf("%d", nxt + i); for (i = 1; i <= n; ++i) { int pos = nxt[i], fast = nxt[nxt[i]], length = 1; check(i); while (pos != fast) { check(pos); pos = nxt[pos]; fast = nxt[nxt[fast]]; } pos = nxt[pos], length = 1; while (pos != fast) { vis[pos] = 1; ++length; pos = nxt[pos]; } if (length < min) min = length; NEXT: continue; } printf("%d\n", min); return 0; }
the_stack_data/82950198.c
#include <stdio.h> int main() { int a[1001],n,i,t; for(i=1;i<=1000;i++) a[i]=0; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&t); a[t]=1; } for(i=1;i<=1000;i++) { if(a[i]==1) printf("%d ",i); } getchar();getchar(); return 0; }
the_stack_data/165764947.c
#include <stdio.h> int solveMeFirst(int a, int b) { // Hint: Type return a+b; below return a + b; } int main() { int num1,num2; scanf("%d %d",&num1,&num2); int sum; sum = solveMeFirst(num1,num2); printf("%d",sum); return 0; }
the_stack_data/1178448.c
/* With -ffast-math, the latice value for sum2 used to change from NaN to VARYING, in turn causing the lattice value of sum1 * sum2 change from NaN to 0 (since sum1 is believed to be 0 at that moment, and 0 * VARYING = 0 with -ffast-math), which caused an ICE. */ /* { dg-do compile } */ /* { dg-options "-O2 -ffast-math" } */ int foo (float *array, int end) { int i; float sum1, sum2; sum2 = 0; for (i = 0; i < end; i++) sum2 = sum2+array[i]; sum2 = 1./sum2; sum1 = 0.; for (i = 0; i < end; i++) sum1 = sum1+array[i]; sum1 = sum1 * sum2; if (-10.0 / sum1 < 5.E-5) end = 0; return end; }
the_stack_data/9512998.c
#include <stdio.h> #include <string.h> int main() { int e, i; scanf("%d", &e); char v[e][50]; for(i = 0; i <= e; i++) { gets(v[i]); } printf("Ciencia da Computacao\n"); return 0; }
the_stack_data/120357.c
/* Read an XML document from standard input and print an element outline on standard output. Must be used with Expat compiled for UTF-8 output. __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| | __// \| |_) | (_| | |_ \___/_/\_\ .__/ \__,_|\__| |_| XML parser Copyright (c) 1997-2000 Thai Open Source Software Center Ltd Copyright (c) 2000-2017 Expat development team Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <stdio.h> #include <expat.h> #ifdef XML_LARGE_SIZE # define XML_FMT_INT_MOD "ll" #else # define XML_FMT_INT_MOD "l" #endif #ifdef XML_UNICODE_WCHAR_T # define XML_FMT_STR "ls" #else # define XML_FMT_STR "s" #endif #define BUFFSIZE 8192 char Buff[BUFFSIZE]; int Depth; static void XMLCALL start(void *data, const XML_Char *el, const XML_Char **attr) { int i; (void)data; for (i = 0; i < Depth; i++) printf(" "); printf("%" XML_FMT_STR, el); for (i = 0; attr[i]; i += 2) { printf(" %" XML_FMT_STR "='%" XML_FMT_STR "'", attr[i], attr[i + 1]); } printf("\n"); Depth++; } static void XMLCALL end(void *data, const XML_Char *el) { (void)data; (void)el; Depth--; } int main(int argc, char *argv[]) { XML_Parser p = XML_ParserCreate(NULL); (void)argc; (void)argv; if (! p) { fprintf(stderr, "Couldn't allocate memory for parser\n"); exit(-1); } XML_SetElementHandler(p, start, end); for (;;) { int done; int len; len = (int)fread(Buff, 1, BUFFSIZE, stdin); if (ferror(stdin)) { fprintf(stderr, "Read error\n"); exit(-1); } done = feof(stdin); if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) { fprintf(stderr, "Parse error at line %" XML_FMT_INT_MOD "u:\n%" XML_FMT_STR "\n", XML_GetCurrentLineNumber(p), XML_ErrorString(XML_GetErrorCode(p))); exit(-1); } if (done) break; } XML_ParserFree(p); return 0; }
the_stack_data/107411.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_sqrt.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aulopez <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/20 10:17:02 by aulopez #+# #+# */ /* Updated: 2018/11/20 10:18:40 by aulopez ### ########.fr */ /* */ /* ************************************************************************** */ static double dabs(double d) { return (d * (1 - 2 * (d < 0))); } double ft_sqrt(unsigned int i) { double d1; double d2; d1 = i / 2 + 0.0; d2 = (d1 + (i / d1)) / 2 + 0.0; while (dabs(d1 - d2) >= 0.0000000001) { d1 = d2; d2 = (d1 + (i / d1)) / 2; } return (d2); }
the_stack_data/776861.c
/* ----------------------------------------------------------------------------- * * (c) The GHC Team, 2001 * Author: Sungwoo Park * * Lag/Drag/Void profiling. * * ---------------------------------------------------------------------------*/ #ifdef PROFILING #include "PosixSource.h" #include "Rts.h" #include "Profiling.h" #include "LdvProfile.h" #include "Stats.h" #include "RtsUtils.h" #include "Schedule.h" /* -------------------------------------------------------------------------- * This function is called eventually on every object destroyed during * a garbage collection, whether it is a major garbage collection or * not. If c is an 'inherently used' closure, nothing happens. If c * is an ordinary closure, LDV_recordDead() is called on c with its * proper size which excludes the profiling header portion in the * closure. Returns the size of the closure, including the profiling * header portion, so that the caller can find the next closure. * ----------------------------------------------------------------------- */ STATIC_INLINE nat processHeapClosureForDead( StgClosure *c ) { nat size; const StgInfoTable *info; info = get_itbl(c); info = c->header.info; if (IS_FORWARDING_PTR(info)) { // The size of the evacuated closure is currently stored in // the LDV field. See SET_EVACUAEE_FOR_LDV() in // includes/StgLdvProf.h. return LDVW(c); } info = INFO_PTR_TO_STRUCT(info); ASSERT(((LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) <= era && ((LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) > 0); ASSERT(((LDVW(c) & LDV_STATE_MASK) == LDV_STATE_CREATE) || ( (LDVW(c) & LDV_LAST_MASK) <= era && (LDVW(c) & LDV_LAST_MASK) > 0 )); size = closure_sizeW(c); switch (info->type) { /* 'inherently used' cases: do nothing. */ case TSO: case STACK: case MVAR_CLEAN: case MVAR_DIRTY: case TVAR: case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_FROZEN: case MUT_ARR_PTRS_FROZEN0: case SMALL_MUT_ARR_PTRS_CLEAN: case SMALL_MUT_ARR_PTRS_DIRTY: case SMALL_MUT_ARR_PTRS_FROZEN: case SMALL_MUT_ARR_PTRS_FROZEN0: case ARR_WORDS: case WEAK: case MUT_VAR_CLEAN: case MUT_VAR_DIRTY: case BCO: case PRIM: case MUT_PRIM: case TREC_CHUNK: return size; /* ordinary cases: call LDV_recordDead(). */ case THUNK: case THUNK_1_0: case THUNK_0_1: case THUNK_SELECTOR: case THUNK_2_0: case THUNK_1_1: case THUNK_0_2: case AP: case PAP: case AP_STACK: case CONSTR: case CONSTR_1_0: case CONSTR_0_1: case CONSTR_2_0: case CONSTR_1_1: case CONSTR_0_2: case FUN: case FUN_1_0: case FUN_0_1: case FUN_2_0: case FUN_1_1: case FUN_0_2: case BLACKHOLE: case BLOCKING_QUEUE: /* 'Ingore' cases */ // Why can we ignore IND closures? We assume that // any census is preceded by a major garbage collection, which // IND closures cannot survive. Therefore, it is no // use considering IND closures in the meanwhile // because they will perish before the next census at any // rate. case IND: // Found a dead closure: record its size LDV_recordDead(c, size); return size; /* Error case */ // static objects case IND_STATIC: case CONSTR_STATIC: case FUN_STATIC: case THUNK_STATIC: case CONSTR_NOCAF_STATIC: // stack objects case UPDATE_FRAME: case CATCH_FRAME: case UNDERFLOW_FRAME: case STOP_FRAME: case RET_BCO: case RET_SMALL: case RET_BIG: // others case INVALID_OBJECT: default: barf("Invalid object in processHeapClosureForDead(): %d", info->type); return 0; } } /* -------------------------------------------------------------------------- * Calls processHeapClosureForDead() on every *dead* closures in the * heap blocks starting at bd. * ----------------------------------------------------------------------- */ static void processHeapForDead( bdescr *bd ) { StgPtr p; while (bd != NULL) { p = bd->start; while (p < bd->free) { p += processHeapClosureForDead((StgClosure *)p); while (p < bd->free && !*p) // skip slop p++; } ASSERT(p == bd->free); bd = bd->link; } } /* -------------------------------------------------------------------------- * Calls processHeapClosureForDead() on every *dead* closures in the nursery. * ----------------------------------------------------------------------- */ static void processNurseryForDead( void ) { StgPtr p; bdescr *bd; for (bd = MainCapability.r.rNursery->blocks; bd != NULL; bd = bd->link) { p = bd->start; while (p < bd->free) { while (p < bd->free && !*p) p++; // skip slop if (p >= bd->free) break; p += processHeapClosureForDead((StgClosure *)p); } } } /* -------------------------------------------------------------------------- * Calls processHeapClosureForDead() on every *dead* closures in the closure * chain. * ----------------------------------------------------------------------- */ static void processChainForDead( bdescr *bd ) { // Any object still in the chain is dead! while (bd != NULL) { if (!(bd->flags & BF_PINNED)) { processHeapClosureForDead((StgClosure *)bd->start); } bd = bd->link; } } /* -------------------------------------------------------------------------- * Start a census for *dead* closures, and calls * processHeapClosureForDead() on every closure which died in the * current garbage collection. This function is called from a garbage * collector right before tidying up, when all dead closures are still * stored in the heap and easy to identify. Generations 0 through N * have just been garbage collected. * ----------------------------------------------------------------------- */ void LdvCensusForDead( nat N ) { nat g; // ldvTime == 0 means that LDV profiling is currently turned off. if (era == 0) return; if (RtsFlags.GcFlags.generations == 1) { // // Todo: support LDV for two-space garbage collection. // barf("Lag/Drag/Void profiling not supported with -G1"); } else { processNurseryForDead(); for (g = 0; g <= N; g++) { processHeapForDead(generations[g].old_blocks); processChainForDead(generations[g].large_objects); } } } /* -------------------------------------------------------------------------- * Regard any closure in the current heap as dead or moribund and update * LDV statistics accordingly. * Called from shutdownHaskell() in RtsStartup.c. * Also, stops LDV profiling by resetting ldvTime to 0. * ----------------------------------------------------------------------- */ void LdvCensusKillAll( void ) { LdvCensusForDead(RtsFlags.GcFlags.generations - 1); } #endif /* PROFILING */
the_stack_data/842885.c
#include <stdio.h> #include <string.h> int check(char*); int main() { char input[13]; fgets(input, 13, stdin); check(input); return 0; } void ev(int); void odd(int); int check(char *input) { int yy, mm, dd, c1, c2, c3; int temp; yy = (input[0] - '0')*10 + (input[1] - '0'); mm = (input[2] - '0')*10 + (input[3] - '0'); dd = (input[4] - '0')*10 + (input[5] - '0'); c1 = input[6] - '0'; c2 = input[7] - '0'; c3 = input[8] - '0'; if(yy>=0 && yy<=16) { if((mm - 40)<=0) { printf("0"); return 0; } } if(yy>=0 && yy<=16) { mm = mm-40; } if(mm>=12) { printf("0"); return 0; } if(mm == 2) { if((yy+4)%4==0) { if(dd>29 || dd<=0) { printf("0"); return 0; } } else { if(dd>28 || dd<=0) { printf("0\n"); } } } if((mm==1) ||(mm==3) ||(mm==5) ||(mm==7) ||(mm==8) ||(mm==10) ||(mm==12) ){ if(dd>31 && dd<=0) { printf("\n0"); return 0; } } if(mm==4 ||mm==6 ||mm==9 ||mm==11 ) { if(dd>30 && dd<=0) { printf("0"); return 0; } } temp = (yy/10)*2 + (yy%10)*4 + (mm/10)*8 + (mm%10)*5 + (dd/10)*10 + (dd%10)*9 + c1*7 + c2*3 + c3*6; if(temp%11 < 10) { printf("1"); } else { printf("0"); } return 0; }
the_stack_data/140765620.c
/*Non-Canonical Input Processing*/ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <termios.h> #include <string.h> #include <unistd.h> #define BAUDRATE B38400 #define _POSIX_SOURCE 1 /* POSIX compliant source */ #define FALSE 0 #define TRUE 1 volatile int STOP = FALSE; int main(int argc, char **argv) { int fd, c, res; struct termios oldtio, newtio; char result[255]; char buf[1]; if ((argc < 2) || ((strcmp("/dev/ttyS0", argv[1]) != 0) && (strcmp("/dev/ttyS1", argv[1]) != 0))) { printf("Usage:\tnserial SerialPort\n\tex: nserial /dev/ttyS1\n"); exit(1); } /* Open serial port device for reading and writing and not as controlling tty because we don't want to get killed if linenoise sends CTRL-C. */ fd = open(argv[1], O_RDWR | O_NOCTTY); if (fd < 0) { perror(argv[1]); exit(-1); } tcgetattr(fd, &oldtio); /* save current port settings */ bzero(&newtio, sizeof(newtio)); newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD; newtio.c_iflag = IGNPAR; newtio.c_oflag = 0; /* set input mode (non-canonical, no echo,...) */ newtio.c_lflag = 0; newtio.c_cc[VTIME] = 0; /* inter-character timer unused */ newtio.c_cc[VMIN] = 1; /* blocking read until 1 chars received */ tcflush(fd, TCIFLUSH); tcsetattr(fd, TCSANOW, &newtio); printf("New termios structure set\n"); for (int i = 0; STOP == FALSE; i++) { /* loop for input */ res = read(fd, &result[i], 1); /* returns after 1 char have been input */ if (result[i] == '\0') STOP = TRUE; } printf("Message received: %s\n", result); write(fd, result, strlen(result) + 1); /* returns after 1 char have been input */ sleep(1); tcsetattr(fd, TCSANOW, &oldtio); close(fd); return 0; }
the_stack_data/36422.c
/* { dg-require-effective-target indirect_jumps } */ #include <setjmp.h> extern void abort (void); extern void exit (int); static jmp_buf env; void baz (void) { __asm__ volatile ("" : : : "memory"); } static inline int g(int x) { if (x) { baz(); return 0; } else { baz(); return 1; } } int f(int *e) { if (*e) return 1; int x = setjmp(env); int n = g(x); if (n == 0) exit(0); if (x) abort(); longjmp(env, 42); } int main(int argc, char** argv) { int v = 0; return f(&v); }