file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/79402.c
/** * SPDX-License-Identifier: Apache-2.0 * Copyright 2020 vorteil.io Pty Ltd */ #include <stdio.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include <stdarg.h> #include <signal.h> #include <sys/socket.h> #include <net/route.h> #include <sys/ioctl.h> #include <arpa/inet.h> #include <linux/sockios.h> #include <sys/syscall.h> static inline void set_sockaddr(struct sockaddr_in *sin, int addr) { sin->sin_family = AF_INET; sin->sin_addr.s_addr = addr; sin->sin_port = 0; } int helper_add_route(int dst, int mask, int gw, char *dev, int flags) { struct rtentry *rm; int err, fd; rm = calloc(1, sizeof(struct rtentry)); if (dev) rm->rt_dev = dev; set_sockaddr((struct sockaddr_in *)&rm->rt_dst, dst); set_sockaddr((struct sockaddr_in *)&rm->rt_genmask, mask); set_sockaddr((struct sockaddr_in *)&rm->rt_gateway, gw); rm->rt_flags = flags; fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_IP); if (fd < 0) { fprintf(stderr, "can not add route: %s\n", strerror(errno)); err = 1; goto ret; } err = ioctl(fd, SIOCADDRT, rm); if (err) { fprintf(stderr, "can not add route: %s\n", strerror(errno)); } close(fd); ret:; free(rm); return err; } void err_print(char *txt) { FILE *fp; fp = fopen("/dev/vtty", "w+"); fprintf(fp, "%s\n", txt); fclose(fp); }
the_stack_data/6243.c
#include<stdio.h> #include<stdlib.h> typedef struct student { char name[50]; int rollno; int percentage; }student; int main() { struct student s1; int n; FILE *fp; printf("Enter the no. of student you want to enter: "); scanf("%d",&n); while (n--) { printf("\nEnter the name of the student: "); fflush(stdin); scanf("%s",s1.name); printf("Enter the rollno of the student: "); scanf("%d",&s1.rollno); printf("Enter the percentage of the student: "); scanf("%d",&s1.percentage); fp=fopen("student_data.txt","a"); fwrite(&s1,sizeof(student),1,fp); fclose(fp); } fp=fopen("student_data.txt","r"); struct student s2; printf("\nFile Information:"); printf("\nName\tRollno\tPercentage\n"); while (fread(&s2,sizeof(student),1,fp)) { printf("%s\t%d\t%d\n",s2.name,s2.rollno,s2.percentage); } fclose(fp); }
the_stack_data/3262753.c
/* * Copyright 2017 Advanced Micro Devices, Inc. * * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. * * Authors: AMD * */ #ifdef CONFIG_DRM_AMD_DC_DCN2_x #include "display_mode_lib.h" #include "display_mode_vba.h" #include "dml_inline_defs.h" /* * NOTE: * This file is gcc-parsable HW gospel, coming straight from HW engineers. * * It doesn't adhere to Linux kernel style and sometimes will do things in odd * ways. Unless there is something clearly wrong with it the code should * remain as-is as it provides us with a guarantee from HW that it is correct. */ static void fetch_socbb_params(struct display_mode_lib *mode_lib); static void fetch_ip_params(struct display_mode_lib *mode_lib); static void fetch_pipe_params(struct display_mode_lib *mode_lib); static void recalculate_params( struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes); static unsigned int CursorBppEnumToBits(enum cursor_bpp ebpp); unsigned int dml_get_voltage_level( struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes) { bool need_recalculate = memcmp(&mode_lib->soc, &mode_lib->vba.soc, sizeof(mode_lib->vba.soc)) != 0 || memcmp(&mode_lib->ip, &mode_lib->vba.ip, sizeof(mode_lib->vba.ip)) != 0 || num_pipes != mode_lib->vba.cache_num_pipes || memcmp(pipes, mode_lib->vba.cache_pipes, sizeof(display_e2e_pipe_params_st) * num_pipes) != 0; mode_lib->vba.soc = mode_lib->soc; mode_lib->vba.ip = mode_lib->ip; memcpy(mode_lib->vba.cache_pipes, pipes, sizeof(*pipes) * num_pipes); mode_lib->vba.cache_num_pipes = num_pipes; if (need_recalculate && pipes[0].clks_cfg.dppclk_mhz != 0) mode_lib->funcs.recalculate(mode_lib); else { fetch_socbb_params(mode_lib); fetch_ip_params(mode_lib); fetch_pipe_params(mode_lib); PixelClockAdjustmentForProgressiveToInterlaceUnit(mode_lib); } mode_lib->funcs.validate(mode_lib); return mode_lib->vba.VoltageLevel; } #define dml_get_attr_func(attr, var) double get_##attr(struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes) \ { \ recalculate_params(mode_lib, pipes, num_pipes); \ return var; \ } dml_get_attr_func(clk_dcf_deepsleep, mode_lib->vba.DCFCLKDeepSleep); dml_get_attr_func(wm_urgent, mode_lib->vba.UrgentWatermark); dml_get_attr_func(wm_memory_trip, mode_lib->vba.UrgentLatency); dml_get_attr_func(wm_writeback_urgent, mode_lib->vba.WritebackUrgentWatermark); dml_get_attr_func(wm_stutter_exit, mode_lib->vba.StutterExitWatermark); dml_get_attr_func(wm_stutter_enter_exit, mode_lib->vba.StutterEnterPlusExitWatermark); dml_get_attr_func(wm_dram_clock_change, mode_lib->vba.DRAMClockChangeWatermark); dml_get_attr_func(wm_writeback_dram_clock_change, mode_lib->vba.WritebackDRAMClockChangeWatermark); dml_get_attr_func(stutter_efficiency, mode_lib->vba.StutterEfficiency); dml_get_attr_func(stutter_efficiency_no_vblank, mode_lib->vba.StutterEfficiencyNotIncludingVBlank); dml_get_attr_func(stutter_period, mode_lib->vba.StutterPeriod); dml_get_attr_func(urgent_latency, mode_lib->vba.UrgentLatency); dml_get_attr_func(urgent_extra_latency, mode_lib->vba.UrgentExtraLatency); dml_get_attr_func(nonurgent_latency, mode_lib->vba.NonUrgentLatencyTolerance); dml_get_attr_func(dram_clock_change_latency, mode_lib->vba.MinActiveDRAMClockChangeLatencySupported); dml_get_attr_func(dispclk_calculated, mode_lib->vba.DISPCLK_calculated); dml_get_attr_func(total_data_read_bw, mode_lib->vba.TotalDataReadBandwidth); dml_get_attr_func(return_bw, mode_lib->vba.ReturnBW); dml_get_attr_func(tcalc, mode_lib->vba.TCalc); dml_get_attr_func(fraction_of_urgent_bandwidth, mode_lib->vba.FractionOfUrgentBandwidth); dml_get_attr_func(fraction_of_urgent_bandwidth_imm_flip, mode_lib->vba.FractionOfUrgentBandwidthImmediateFlip); #define dml_get_pipe_attr_func(attr, var) double get_##attr(struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes, unsigned int which_pipe) \ {\ unsigned int which_plane; \ recalculate_params(mode_lib, pipes, num_pipes); \ which_plane = mode_lib->vba.pipe_plane[which_pipe]; \ return var[which_plane]; \ } dml_get_pipe_attr_func(dsc_delay, mode_lib->vba.DSCDelay); dml_get_pipe_attr_func(dppclk_calculated, mode_lib->vba.DPPCLK_calculated); dml_get_pipe_attr_func(dscclk_calculated, mode_lib->vba.DSCCLK_calculated); dml_get_pipe_attr_func(min_ttu_vblank, mode_lib->vba.MinTTUVBlank); dml_get_pipe_attr_func(min_ttu_vblank_in_us, mode_lib->vba.MinTTUVBlank); dml_get_pipe_attr_func(vratio_prefetch_l, mode_lib->vba.VRatioPrefetchY); dml_get_pipe_attr_func(vratio_prefetch_c, mode_lib->vba.VRatioPrefetchC); dml_get_pipe_attr_func(dst_x_after_scaler, mode_lib->vba.DSTXAfterScaler); dml_get_pipe_attr_func(dst_y_after_scaler, mode_lib->vba.DSTYAfterScaler); dml_get_pipe_attr_func(dst_y_per_vm_vblank, mode_lib->vba.DestinationLinesToRequestVMInVBlank); dml_get_pipe_attr_func(dst_y_per_row_vblank, mode_lib->vba.DestinationLinesToRequestRowInVBlank); dml_get_pipe_attr_func(dst_y_prefetch, mode_lib->vba.DestinationLinesForPrefetch); dml_get_pipe_attr_func(dst_y_per_vm_flip, mode_lib->vba.DestinationLinesToRequestVMInImmediateFlip); dml_get_pipe_attr_func(dst_y_per_row_flip, mode_lib->vba.DestinationLinesToRequestRowInImmediateFlip); dml_get_pipe_attr_func(refcyc_per_vm_group_vblank, mode_lib->vba.TimePerVMGroupVBlank); dml_get_pipe_attr_func(refcyc_per_vm_group_flip, mode_lib->vba.TimePerVMGroupFlip); dml_get_pipe_attr_func(refcyc_per_vm_req_vblank, mode_lib->vba.TimePerVMRequestVBlank); dml_get_pipe_attr_func(refcyc_per_vm_req_flip, mode_lib->vba.TimePerVMRequestFlip); dml_get_pipe_attr_func(refcyc_per_vm_group_vblank_in_us, mode_lib->vba.TimePerVMGroupVBlank); dml_get_pipe_attr_func(refcyc_per_vm_group_flip_in_us, mode_lib->vba.TimePerVMGroupFlip); dml_get_pipe_attr_func(refcyc_per_vm_req_vblank_in_us, mode_lib->vba.TimePerVMRequestVBlank); dml_get_pipe_attr_func(refcyc_per_vm_req_flip_in_us, mode_lib->vba.TimePerVMRequestFlip); dml_get_pipe_attr_func(refcyc_per_vm_dmdata_in_us, mode_lib->vba.Tdmdl_vm); dml_get_pipe_attr_func(dmdata_dl_delta_in_us, mode_lib->vba.Tdmdl); dml_get_pipe_attr_func(refcyc_per_line_delivery_l_in_us, mode_lib->vba.DisplayPipeLineDeliveryTimeLuma); dml_get_pipe_attr_func(refcyc_per_line_delivery_c_in_us, mode_lib->vba.DisplayPipeLineDeliveryTimeChroma); dml_get_pipe_attr_func(refcyc_per_line_delivery_pre_l_in_us, mode_lib->vba.DisplayPipeLineDeliveryTimeLumaPrefetch); dml_get_pipe_attr_func(refcyc_per_line_delivery_pre_c_in_us, mode_lib->vba.DisplayPipeLineDeliveryTimeChromaPrefetch); dml_get_pipe_attr_func(refcyc_per_req_delivery_l_in_us, mode_lib->vba.DisplayPipeRequestDeliveryTimeLuma); dml_get_pipe_attr_func(refcyc_per_req_delivery_c_in_us, mode_lib->vba.DisplayPipeRequestDeliveryTimeChroma); dml_get_pipe_attr_func(refcyc_per_req_delivery_pre_l_in_us, mode_lib->vba.DisplayPipeRequestDeliveryTimeLumaPrefetch); dml_get_pipe_attr_func(refcyc_per_req_delivery_pre_c_in_us, mode_lib->vba.DisplayPipeRequestDeliveryTimeChromaPrefetch); dml_get_pipe_attr_func(refcyc_per_cursor_req_delivery_in_us, mode_lib->vba.CursorRequestDeliveryTime); dml_get_pipe_attr_func(refcyc_per_cursor_req_delivery_pre_in_us, mode_lib->vba.CursorRequestDeliveryTimePrefetch); dml_get_pipe_attr_func(refcyc_per_meta_chunk_nom_l_in_us, mode_lib->vba.TimePerMetaChunkNominal); dml_get_pipe_attr_func(refcyc_per_meta_chunk_nom_c_in_us, mode_lib->vba.TimePerChromaMetaChunkNominal); dml_get_pipe_attr_func(refcyc_per_meta_chunk_vblank_l_in_us, mode_lib->vba.TimePerMetaChunkVBlank); dml_get_pipe_attr_func(refcyc_per_meta_chunk_vblank_c_in_us, mode_lib->vba.TimePerChromaMetaChunkVBlank); dml_get_pipe_attr_func(refcyc_per_meta_chunk_flip_l_in_us, mode_lib->vba.TimePerMetaChunkFlip); dml_get_pipe_attr_func(refcyc_per_meta_chunk_flip_c_in_us, mode_lib->vba.TimePerChromaMetaChunkFlip); dml_get_pipe_attr_func(vstartup, mode_lib->vba.VStartup); dml_get_pipe_attr_func(vupdate_offset, mode_lib->vba.VUpdateOffsetPix); dml_get_pipe_attr_func(vupdate_width, mode_lib->vba.VUpdateWidthPix); dml_get_pipe_attr_func(vready_offset, mode_lib->vba.VReadyOffsetPix); double get_total_immediate_flip_bytes( struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes) { recalculate_params(mode_lib, pipes, num_pipes); return mode_lib->vba.TotImmediateFlipBytes; } double get_total_immediate_flip_bw( struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes) { unsigned int k; double immediate_flip_bw = 0.0; recalculate_params(mode_lib, pipes, num_pipes); for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) immediate_flip_bw += mode_lib->vba.ImmediateFlipBW[k]; return immediate_flip_bw; } double get_total_prefetch_bw( struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes) { unsigned int k; double total_prefetch_bw = 0.0; recalculate_params(mode_lib, pipes, num_pipes); for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) total_prefetch_bw += mode_lib->vba.PrefetchBandwidth[k]; return total_prefetch_bw; } static void fetch_socbb_params(struct display_mode_lib *mode_lib) { soc_bounding_box_st *soc = &mode_lib->vba.soc; int i; // SOC Bounding Box Parameters mode_lib->vba.ReturnBusWidth = soc->return_bus_width_bytes; mode_lib->vba.NumberOfChannels = soc->num_chans; mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelDataOnly = soc->pct_ideal_dram_sdp_bw_after_urgent_pixel_only; // there's always that one bastard variable that's so long it throws everything out of alignment! mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData = soc->pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm; mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly = soc->pct_ideal_dram_sdp_bw_after_urgent_vm_only; mode_lib->vba.MaxAveragePercentOfIdealSDPPortBWDisplayCanUseInNormalSystemOperation = soc->max_avg_sdp_bw_use_normal_percent; mode_lib->vba.MaxAveragePercentOfIdealDRAMBWDisplayCanUseInNormalSystemOperation = soc->max_avg_dram_bw_use_normal_percent; mode_lib->vba.UrgentLatencyPixelDataOnly = soc->urgent_latency_pixel_data_only_us; mode_lib->vba.UrgentLatencyPixelMixedWithVMData = soc->urgent_latency_pixel_mixed_with_vm_data_us; mode_lib->vba.UrgentLatencyVMDataOnly = soc->urgent_latency_vm_data_only_us; mode_lib->vba.RoundTripPingLatencyCycles = soc->round_trip_ping_latency_dcfclk_cycles; mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelDataOnly = soc->urgent_out_of_order_return_per_channel_pixel_only_bytes; mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelMixedWithVMData = soc->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes; mode_lib->vba.UrgentOutOfOrderReturnPerChannelVMDataOnly = soc->urgent_out_of_order_return_per_channel_vm_only_bytes; mode_lib->vba.WritebackLatency = soc->writeback_latency_us; mode_lib->vba.SRExitTime = soc->sr_exit_time_us; mode_lib->vba.SREnterPlusExitTime = soc->sr_enter_plus_exit_time_us; mode_lib->vba.DRAMClockChangeLatency = soc->dram_clock_change_latency_us; mode_lib->vba.DummyPStateCheck = soc->dram_clock_change_latency_us == soc->dummy_pstate_latency_us; mode_lib->vba.DRAMClockChangeSupportsVActive = !soc->disable_dram_clock_change_vactive_support || mode_lib->vba.DummyPStateCheck; mode_lib->vba.AllowDramClockChangeOneDisplayVactive = soc->allow_dram_clock_one_display_vactive; mode_lib->vba.Downspreading = soc->downspread_percent; mode_lib->vba.DRAMChannelWidth = soc->dram_channel_width_bytes; // new! mode_lib->vba.FabricDatapathToDCNDataReturn = soc->fabric_datapath_to_dcn_data_return_bytes; // new! mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading = soc->dcn_downspread_percent; // new mode_lib->vba.DISPCLKDPPCLKVCOSpeed = soc->dispclk_dppclk_vco_speed_mhz; // new mode_lib->vba.VMMPageSize = soc->vmm_page_size_bytes; mode_lib->vba.GPUVMMinPageSize = soc->gpuvm_min_page_size_bytes / 1024; mode_lib->vba.HostVMMinPageSize = soc->hostvm_min_page_size_bytes / 1024; // Set the voltage scaling clocks as the defaults. Most of these will // be set to different values by the test for (i = 0; i < mode_lib->vba.soc.num_states; i++) if (soc->clock_limits[i].state == mode_lib->vba.VoltageLevel) break; mode_lib->vba.DCFCLK = soc->clock_limits[i].dcfclk_mhz; mode_lib->vba.SOCCLK = soc->clock_limits[i].socclk_mhz; mode_lib->vba.DRAMSpeed = soc->clock_limits[i].dram_speed_mts; mode_lib->vba.FabricClock = soc->clock_limits[i].fabricclk_mhz; mode_lib->vba.XFCBusTransportTime = soc->xfc_bus_transport_time_us; mode_lib->vba.XFCXBUFLatencyTolerance = soc->xfc_xbuf_latency_tolerance_us; mode_lib->vba.UseUrgentBurstBandwidth = soc->use_urgent_burst_bw; mode_lib->vba.SupportGFX7CompatibleTilingIn32bppAnd64bpp = false; mode_lib->vba.WritebackLumaAndChromaScalingSupported = true; mode_lib->vba.MaxHSCLRatio = 4; mode_lib->vba.MaxVSCLRatio = 4; mode_lib->vba.Cursor64BppSupport = true; for (i = 0; i <= mode_lib->vba.soc.num_states; i++) { mode_lib->vba.DCFCLKPerState[i] = soc->clock_limits[i].dcfclk_mhz; mode_lib->vba.FabricClockPerState[i] = soc->clock_limits[i].fabricclk_mhz; mode_lib->vba.SOCCLKPerState[i] = soc->clock_limits[i].socclk_mhz; mode_lib->vba.PHYCLKPerState[i] = soc->clock_limits[i].phyclk_mhz; mode_lib->vba.PHYCLKD18PerState[i] = soc->clock_limits[i].phyclk_d18_mhz; mode_lib->vba.MaxDppclk[i] = soc->clock_limits[i].dppclk_mhz; mode_lib->vba.MaxDSCCLK[i] = soc->clock_limits[i].dscclk_mhz; mode_lib->vba.DRAMSpeedPerState[i] = soc->clock_limits[i].dram_speed_mts; //mode_lib->vba.DRAMSpeedPerState[i] = soc->clock_limits[i].dram_speed_mhz; mode_lib->vba.MaxDispclk[i] = soc->clock_limits[i].dispclk_mhz; mode_lib->vba.DTBCLKPerState[i] = soc->clock_limits[i].dtbclk_mhz; } mode_lib->vba.DoUrgentLatencyAdjustment = soc->do_urgent_latency_adjustment; mode_lib->vba.UrgentLatencyAdjustmentFabricClockComponent = soc->urgent_latency_adjustment_fabric_clock_component_us; mode_lib->vba.UrgentLatencyAdjustmentFabricClockReference = soc->urgent_latency_adjustment_fabric_clock_reference_mhz; } static void fetch_ip_params(struct display_mode_lib *mode_lib) { ip_params_st *ip = &mode_lib->vba.ip; // IP Parameters mode_lib->vba.UseMinimumRequiredDCFCLK = ip->use_min_dcfclk; #ifdef CONFIG_DRM_AMD_DC_DCN3_x mode_lib->vba.ClampMinDCFCLK = ip->clamp_min_dcfclk; #endif mode_lib->vba.MaxNumDPP = ip->max_num_dpp; mode_lib->vba.MaxNumOTG = ip->max_num_otg; mode_lib->vba.MaxNumHDMIFRLOutputs = ip->max_num_hdmi_frl_outputs; mode_lib->vba.MaxNumWriteback = ip->max_num_wb; mode_lib->vba.CursorChunkSize = ip->cursor_chunk_size; mode_lib->vba.CursorBufferSize = ip->cursor_buffer_size; mode_lib->vba.MaxDCHUBToPSCLThroughput = ip->max_dchub_pscl_bw_pix_per_clk; mode_lib->vba.MaxPSCLToLBThroughput = ip->max_pscl_lb_bw_pix_per_clk; mode_lib->vba.ROBBufferSizeInKByte = ip->rob_buffer_size_kbytes; mode_lib->vba.DETBufferSizeInKByte[0] = ip->det_buffer_size_kbytes; mode_lib->vba.PixelChunkSizeInKByte = ip->pixel_chunk_size_kbytes; mode_lib->vba.MetaChunkSize = ip->meta_chunk_size_kbytes; mode_lib->vba.MinMetaChunkSizeBytes = ip->min_meta_chunk_size_bytes; mode_lib->vba.WritebackChunkSize = ip->writeback_chunk_size_kbytes; mode_lib->vba.LineBufferSize = ip->line_buffer_size_bits; mode_lib->vba.MaxLineBufferLines = ip->max_line_buffer_lines; mode_lib->vba.PTEBufferSizeInRequestsLuma = ip->dpte_buffer_size_in_pte_reqs_luma; mode_lib->vba.PTEBufferSizeInRequestsChroma = ip->dpte_buffer_size_in_pte_reqs_chroma; mode_lib->vba.DPPOutputBufferPixels = ip->dpp_output_buffer_pixels; mode_lib->vba.OPPOutputBufferLines = ip->opp_output_buffer_lines; mode_lib->vba.MaxHSCLRatio = ip->max_hscl_ratio; mode_lib->vba.MaxVSCLRatio = ip->max_vscl_ratio; mode_lib->vba.WritebackInterfaceLumaBufferSize = ip->writeback_luma_buffer_size_kbytes * 1024; mode_lib->vba.WritebackInterfaceChromaBufferSize = ip->writeback_chroma_buffer_size_kbytes * 1024; mode_lib->vba.WritebackInterfaceBufferSize = ip->writeback_interface_buffer_size_kbytes; mode_lib->vba.WritebackLineBufferSize = ip->writeback_line_buffer_buffer_size; mode_lib->vba.WritebackChromaLineBufferWidth = ip->writeback_chroma_line_buffer_width_pixels; mode_lib->vba.WritebackLineBufferLumaBufferSize = ip->writeback_line_buffer_luma_buffer_size; mode_lib->vba.WritebackLineBufferChromaBufferSize = ip->writeback_line_buffer_chroma_buffer_size; mode_lib->vba.Writeback10bpc420Supported = ip->writeback_10bpc420_supported; mode_lib->vba.WritebackMaxHSCLRatio = ip->writeback_max_hscl_ratio; mode_lib->vba.WritebackMaxVSCLRatio = ip->writeback_max_vscl_ratio; mode_lib->vba.WritebackMinHSCLRatio = ip->writeback_min_hscl_ratio; mode_lib->vba.WritebackMinVSCLRatio = ip->writeback_min_vscl_ratio; mode_lib->vba.WritebackMaxHSCLTaps = ip->writeback_max_hscl_taps; mode_lib->vba.WritebackMaxVSCLTaps = ip->writeback_max_vscl_taps; mode_lib->vba.WritebackConfiguration = dm_normal; mode_lib->vba.GPUVMMaxPageTableLevels = ip->gpuvm_max_page_table_levels; mode_lib->vba.HostVMMaxNonCachedPageTableLevels = ip->hostvm_max_page_table_levels; mode_lib->vba.HostVMMaxPageTableLevels = ip->hostvm_max_page_table_levels; mode_lib->vba.HostVMCachedPageTableLevels = ip->hostvm_cached_page_table_levels; mode_lib->vba.MaxInterDCNTileRepeaters = ip->max_inter_dcn_tile_repeaters; mode_lib->vba.NumberOfDSC = ip->num_dsc; mode_lib->vba.ODMCapability = ip->odm_capable; mode_lib->vba.DISPCLKRampingMargin = ip->dispclk_ramp_margin_percent; mode_lib->vba.XFCSupported = ip->xfc_supported; mode_lib->vba.XFCFillBWOverhead = ip->xfc_fill_bw_overhead_percent; mode_lib->vba.XFCFillConstant = ip->xfc_fill_constant_bytes; mode_lib->vba.DPPCLKDelaySubtotal = ip->dppclk_delay_subtotal; mode_lib->vba.DPPCLKDelaySCL = ip->dppclk_delay_scl; mode_lib->vba.DPPCLKDelaySCLLBOnly = ip->dppclk_delay_scl_lb_only; mode_lib->vba.DPPCLKDelayCNVCFormater = ip->dppclk_delay_cnvc_formatter; mode_lib->vba.DPPCLKDelayCNVCCursor = ip->dppclk_delay_cnvc_cursor; mode_lib->vba.DISPCLKDelaySubtotal = ip->dispclk_delay_subtotal; mode_lib->vba.DynamicMetadataVMEnabled = ip->dynamic_metadata_vm_enabled; mode_lib->vba.ODMCombine4To1Supported = ip->odm_combine_4to1_supported; mode_lib->vba.ProgressiveToInterlaceUnitInOPP = ip->ptoi_supported; mode_lib->vba.PDEProcessingBufIn64KBReqs = ip->pde_proc_buffer_size_64k_reqs; mode_lib->vba.PTEGroupSize = ip->pte_group_size_bytes; mode_lib->vba.SupportGFX7CompatibleTilingIn32bppAnd64bpp = ip->gfx7_compat_tiling_supported; } static void fetch_pipe_params(struct display_mode_lib *mode_lib) { display_e2e_pipe_params_st *pipes = mode_lib->vba.cache_pipes; ip_params_st *ip = &mode_lib->vba.ip; unsigned int OTGInstPlane[DC__NUM_DPP__MAX]; unsigned int j, k; bool PlaneVisited[DC__NUM_DPP__MAX]; bool visited[DC__NUM_DPP__MAX]; // Convert Pipes to Planes for (k = 0; k < mode_lib->vba.cache_num_pipes; ++k) visited[k] = false; mode_lib->vba.NumberOfActivePlanes = 0; mode_lib->vba.ImmediateFlipSupport = false; mode_lib->vba.ImmediateFlipRequirement = dm_immediate_flip_not_required; for (j = 0; j < mode_lib->vba.cache_num_pipes; ++j) { display_pipe_source_params_st *src = &pipes[j].pipe.src; display_pipe_dest_params_st *dst = &pipes[j].pipe.dest; scaler_ratio_depth_st *scl = &pipes[j].pipe.scale_ratio_depth; scaler_taps_st *taps = &pipes[j].pipe.scale_taps; display_output_params_st *dout = &pipes[j].dout; display_clocks_and_cfg_st *clks = &pipes[j].clks_cfg; if (visited[j]) continue; visited[j] = true; mode_lib->vba.pipe_plane[j] = mode_lib->vba.NumberOfActivePlanes; mode_lib->vba.DPPPerPlane[mode_lib->vba.NumberOfActivePlanes] = 1; mode_lib->vba.SourceScan[mode_lib->vba.NumberOfActivePlanes] = (enum scan_direction_class) (src->source_scan); mode_lib->vba.ViewportWidth[mode_lib->vba.NumberOfActivePlanes] = src->viewport_width; mode_lib->vba.ViewportWidthChroma[mode_lib->vba.NumberOfActivePlanes] = src->viewport_width_c; mode_lib->vba.ViewportHeight[mode_lib->vba.NumberOfActivePlanes] = src->viewport_height; mode_lib->vba.ViewportHeightChroma[mode_lib->vba.NumberOfActivePlanes] = src->viewport_height_c; mode_lib->vba.ViewportYStartY[mode_lib->vba.NumberOfActivePlanes] = src->viewport_y_y; mode_lib->vba.ViewportYStartC[mode_lib->vba.NumberOfActivePlanes] = src->viewport_y_c; mode_lib->vba.PitchY[mode_lib->vba.NumberOfActivePlanes] = src->data_pitch; mode_lib->vba.SurfaceWidthY[mode_lib->vba.NumberOfActivePlanes] = src->surface_width_y; mode_lib->vba.SurfaceHeightY[mode_lib->vba.NumberOfActivePlanes] = src->surface_height_y; mode_lib->vba.PitchC[mode_lib->vba.NumberOfActivePlanes] = src->data_pitch_c; mode_lib->vba.SurfaceHeightC[mode_lib->vba.NumberOfActivePlanes] = src->surface_height_c; mode_lib->vba.SurfaceWidthC[mode_lib->vba.NumberOfActivePlanes] = src->surface_width_c; mode_lib->vba.DCCMetaPitchY[mode_lib->vba.NumberOfActivePlanes] = src->meta_pitch; mode_lib->vba.DCCMetaPitchC[mode_lib->vba.NumberOfActivePlanes] = src->meta_pitch_c; mode_lib->vba.HRatio[mode_lib->vba.NumberOfActivePlanes] = scl->hscl_ratio; mode_lib->vba.HRatioChroma[mode_lib->vba.NumberOfActivePlanes] = scl->hscl_ratio_c; mode_lib->vba.VRatio[mode_lib->vba.NumberOfActivePlanes] = scl->vscl_ratio; mode_lib->vba.VRatioChroma[mode_lib->vba.NumberOfActivePlanes] = scl->vscl_ratio_c; mode_lib->vba.ScalerEnabled[mode_lib->vba.NumberOfActivePlanes] = scl->scl_enable; mode_lib->vba.Interlace[mode_lib->vba.NumberOfActivePlanes] = dst->interlaced; if (dst->interlaced && !ip->ptoi_supported) { mode_lib->vba.VRatio[mode_lib->vba.NumberOfActivePlanes] *= 2.0; mode_lib->vba.VRatioChroma[mode_lib->vba.NumberOfActivePlanes] *= 2.0; } mode_lib->vba.htaps[mode_lib->vba.NumberOfActivePlanes] = taps->htaps; mode_lib->vba.vtaps[mode_lib->vba.NumberOfActivePlanes] = taps->vtaps; mode_lib->vba.HTAPsChroma[mode_lib->vba.NumberOfActivePlanes] = taps->htaps_c; mode_lib->vba.VTAPsChroma[mode_lib->vba.NumberOfActivePlanes] = taps->vtaps_c; mode_lib->vba.HTotal[mode_lib->vba.NumberOfActivePlanes] = dst->htotal; mode_lib->vba.VTotal[mode_lib->vba.NumberOfActivePlanes] = dst->vtotal; mode_lib->vba.DCCEnable[mode_lib->vba.NumberOfActivePlanes] = src->dcc_use_global ? ip->dcc_supported : src->dcc && ip->dcc_supported; mode_lib->vba.DCCRate[mode_lib->vba.NumberOfActivePlanes] = src->dcc_rate; /* TODO: Needs to be set based on src->dcc_rate_luma/chroma */ mode_lib->vba.DCCRateLuma[mode_lib->vba.NumberOfActivePlanes] = src->dcc_rate; mode_lib->vba.DCCRateChroma[mode_lib->vba.NumberOfActivePlanes] = src->dcc_rate_chroma; mode_lib->vba.SourcePixelFormat[mode_lib->vba.NumberOfActivePlanes] = (enum source_format_class) (src->source_format); mode_lib->vba.HActive[mode_lib->vba.NumberOfActivePlanes] = dst->hactive; mode_lib->vba.VActive[mode_lib->vba.NumberOfActivePlanes] = dst->vactive; mode_lib->vba.SurfaceTiling[mode_lib->vba.NumberOfActivePlanes] = (enum dm_swizzle_mode) (src->sw_mode); mode_lib->vba.ScalerRecoutWidth[mode_lib->vba.NumberOfActivePlanes] = dst->recout_width; // TODO: or should this be full_recout_width???...maybe only when in hsplit mode? mode_lib->vba.ODMCombineEnabled[mode_lib->vba.NumberOfActivePlanes] = dst->odm_combine; mode_lib->vba.OutputFormat[mode_lib->vba.NumberOfActivePlanes] = (enum output_format_class) (dout->output_format); mode_lib->vba.OutputBpp[mode_lib->vba.NumberOfActivePlanes] = dout->output_bpp; mode_lib->vba.Output[mode_lib->vba.NumberOfActivePlanes] = (enum output_encoder_class) (dout->output_type); mode_lib->vba.skip_dio_check[mode_lib->vba.NumberOfActivePlanes] = dout->is_virtual; if (!dout->dsc_enable) mode_lib->vba.ForcedOutputLinkBPP[mode_lib->vba.NumberOfActivePlanes] = dout->output_bpp; else mode_lib->vba.ForcedOutputLinkBPP[mode_lib->vba.NumberOfActivePlanes] = 0.0; mode_lib->vba.OutputLinkDPLanes[mode_lib->vba.NumberOfActivePlanes] = dout->dp_lanes; /* TODO: Needs to be set based on dout->audio.audio_sample_rate_khz/sample_layout */ mode_lib->vba.AudioSampleRate[mode_lib->vba.NumberOfActivePlanes] = dout->max_audio_sample_rate; mode_lib->vba.AudioSampleLayout[mode_lib->vba.NumberOfActivePlanes] = 1; mode_lib->vba.DRAMClockChangeLatencyOverride = 0.0; mode_lib->vba.DSCEnabled[mode_lib->vba.NumberOfActivePlanes] = dout->dsc_enable; mode_lib->vba.DSCEnable[mode_lib->vba.NumberOfActivePlanes] = dout->dsc_enable; mode_lib->vba.NumberOfDSCSlices[mode_lib->vba.NumberOfActivePlanes] = dout->dsc_slices; if (!dout->dsc_input_bpc) { mode_lib->vba.DSCInputBitPerComponent[mode_lib->vba.NumberOfActivePlanes] = ip->maximum_dsc_bits_per_component; } else { mode_lib->vba.DSCInputBitPerComponent[mode_lib->vba.NumberOfActivePlanes] = dout->dsc_input_bpc; } mode_lib->vba.WritebackEnable[mode_lib->vba.NumberOfActivePlanes] = dout->wb_enable; mode_lib->vba.ActiveWritebacksPerPlane[mode_lib->vba.NumberOfActivePlanes] = dout->num_active_wb; mode_lib->vba.WritebackSourceHeight[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_src_height; mode_lib->vba.WritebackSourceWidth[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_src_width; mode_lib->vba.WritebackDestinationWidth[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_dst_width; mode_lib->vba.WritebackDestinationHeight[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_dst_height; mode_lib->vba.WritebackHRatio[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_hratio; mode_lib->vba.WritebackVRatio[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_vratio; mode_lib->vba.WritebackPixelFormat[mode_lib->vba.NumberOfActivePlanes] = (enum source_format_class) (dout->wb.wb_pixel_format); mode_lib->vba.WritebackHTaps[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_htaps_luma; mode_lib->vba.WritebackVTaps[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_vtaps_luma; mode_lib->vba.WritebackLumaHTaps[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_htaps_luma; mode_lib->vba.WritebackLumaVTaps[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_vtaps_luma; mode_lib->vba.WritebackChromaHTaps[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_htaps_chroma; mode_lib->vba.WritebackChromaVTaps[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_vtaps_chroma; mode_lib->vba.WritebackHRatio[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_hratio; mode_lib->vba.WritebackVRatio[mode_lib->vba.NumberOfActivePlanes] = dout->wb.wb_vratio; mode_lib->vba.DynamicMetadataEnable[mode_lib->vba.NumberOfActivePlanes] = src->dynamic_metadata_enable; mode_lib->vba.DynamicMetadataLinesBeforeActiveRequired[mode_lib->vba.NumberOfActivePlanes] = src->dynamic_metadata_lines_before_active; mode_lib->vba.DynamicMetadataTransmittedBytes[mode_lib->vba.NumberOfActivePlanes] = src->dynamic_metadata_xmit_bytes; mode_lib->vba.XFCEnabled[mode_lib->vba.NumberOfActivePlanes] = src->xfc_enable && ip->xfc_supported; mode_lib->vba.XFCSlvChunkSize = src->xfc_params.xfc_slv_chunk_size_bytes; mode_lib->vba.XFCTSlvVupdateOffset = src->xfc_params.xfc_tslv_vupdate_offset_us; mode_lib->vba.XFCTSlvVupdateWidth = src->xfc_params.xfc_tslv_vupdate_width_us; mode_lib->vba.XFCTSlvVreadyOffset = src->xfc_params.xfc_tslv_vready_offset_us; mode_lib->vba.PixelClock[mode_lib->vba.NumberOfActivePlanes] = dst->pixel_rate_mhz; mode_lib->vba.PixelClockBackEnd[mode_lib->vba.NumberOfActivePlanes] = dst->pixel_rate_mhz; mode_lib->vba.DPPCLK[mode_lib->vba.NumberOfActivePlanes] = clks->dppclk_mhz; if (ip->is_line_buffer_bpp_fixed) mode_lib->vba.LBBitPerPixel[mode_lib->vba.NumberOfActivePlanes] = ip->line_buffer_fixed_bpp; else { unsigned int lb_depth; switch (scl->lb_depth) { case dm_lb_6: lb_depth = 18; break; case dm_lb_8: lb_depth = 24; break; case dm_lb_10: lb_depth = 30; break; case dm_lb_12: lb_depth = 36; break; case dm_lb_16: lb_depth = 48; break; case dm_lb_19: lb_depth = 57; break; default: lb_depth = 36; } mode_lib->vba.LBBitPerPixel[mode_lib->vba.NumberOfActivePlanes] = lb_depth; } mode_lib->vba.NumberOfCursors[mode_lib->vba.NumberOfActivePlanes] = 0; // The DML spreadsheet assumes that the two cursors utilize the same amount of bandwidth. We'll // calculate things a little more accurately for (k = 0; k < DC__NUM_CURSOR__MAX; ++k) { switch (k) { case 0: mode_lib->vba.CursorBPP[mode_lib->vba.NumberOfActivePlanes][0] = CursorBppEnumToBits( (enum cursor_bpp) (src->cur0_bpp)); mode_lib->vba.CursorWidth[mode_lib->vba.NumberOfActivePlanes][0] = src->cur0_src_width; if (src->cur0_src_width > 0) mode_lib->vba.NumberOfCursors[mode_lib->vba.NumberOfActivePlanes]++; break; case 1: mode_lib->vba.CursorBPP[mode_lib->vba.NumberOfActivePlanes][1] = CursorBppEnumToBits( (enum cursor_bpp) (src->cur1_bpp)); mode_lib->vba.CursorWidth[mode_lib->vba.NumberOfActivePlanes][1] = src->cur1_src_width; if (src->cur1_src_width > 0) mode_lib->vba.NumberOfCursors[mode_lib->vba.NumberOfActivePlanes]++; break; default: dml_print( "ERROR: Number of cursors specified exceeds supported maximum\n") ; } } OTGInstPlane[mode_lib->vba.NumberOfActivePlanes] = dst->otg_inst; if (j == 0) mode_lib->vba.UseMaximumVStartup = dst->use_maximum_vstartup; else mode_lib->vba.UseMaximumVStartup = mode_lib->vba.UseMaximumVStartup || dst->use_maximum_vstartup; if (dst->odm_combine && !src->is_hsplit) dml_print( "ERROR: ODM Combine is specified but is_hsplit has not be specified for pipe %i\n", j); if (src->is_hsplit) { for (k = j + 1; k < mode_lib->vba.cache_num_pipes; ++k) { display_pipe_source_params_st *src_k = &pipes[k].pipe.src; display_pipe_dest_params_st *dst_k = &pipes[k].pipe.dest; if (src_k->is_hsplit && !visited[k] && src->hsplit_grp == src_k->hsplit_grp) { mode_lib->vba.pipe_plane[k] = mode_lib->vba.NumberOfActivePlanes; mode_lib->vba.DPPPerPlane[mode_lib->vba.NumberOfActivePlanes]++; if (mode_lib->vba.SourceScan[mode_lib->vba.NumberOfActivePlanes] == dm_horz) { mode_lib->vba.ViewportWidth[mode_lib->vba.NumberOfActivePlanes] += src_k->viewport_width; mode_lib->vba.ViewportWidthChroma[mode_lib->vba.NumberOfActivePlanes] += src_k->viewport_width_c; mode_lib->vba.ScalerRecoutWidth[mode_lib->vba.NumberOfActivePlanes] += dst_k->recout_width; } else { mode_lib->vba.ViewportHeight[mode_lib->vba.NumberOfActivePlanes] += src_k->viewport_height; mode_lib->vba.ViewportHeightChroma[mode_lib->vba.NumberOfActivePlanes] += src_k->viewport_height_c; } visited[k] = true; } } } if (pipes[k].pipe.src.immediate_flip) { mode_lib->vba.ImmediateFlipSupport = true; mode_lib->vba.ImmediateFlipRequirement = dm_immediate_flip_required; } mode_lib->vba.NumberOfActivePlanes++; } // handle overlays through BlendingAndTiming // BlendingAndTiming tells you which instance to look at to get timing, the so called 'master' for (j = 0; j < mode_lib->vba.NumberOfActivePlanes; ++j) PlaneVisited[j] = false; for (j = 0; j < mode_lib->vba.NumberOfActivePlanes; ++j) { for (k = j + 1; k < mode_lib->vba.NumberOfActivePlanes; ++k) { if (!PlaneVisited[k] && OTGInstPlane[j] == OTGInstPlane[k]) { // doesn't matter, so choose the smaller one mode_lib->vba.BlendingAndTiming[j] = j; PlaneVisited[j] = true; mode_lib->vba.BlendingAndTiming[k] = j; PlaneVisited[k] = true; } } if (!PlaneVisited[j]) { mode_lib->vba.BlendingAndTiming[j] = j; PlaneVisited[j] = true; } } // TODO: ODMCombineEnabled => 2 * DPPPerPlane...actually maybe not since all pipes are specified // Do we want the dscclk to automatically be halved? Guess not since the value is specified mode_lib->vba.SynchronizedVBlank = pipes[0].pipe.dest.synchronized_vblank_all_planes; for (k = 1; k < mode_lib->vba.cache_num_pipes; ++k) { ASSERT(mode_lib->vba.SynchronizedVBlank == pipes[k].pipe.dest.synchronized_vblank_all_planes); } mode_lib->vba.GPUVMEnable = false; mode_lib->vba.HostVMEnable = false; mode_lib->vba.OverrideGPUVMPageTableLevels = 0; mode_lib->vba.OverrideHostVMPageTableLevels = 0; for (k = 0; k < mode_lib->vba.cache_num_pipes; ++k) { mode_lib->vba.GPUVMEnable = mode_lib->vba.GPUVMEnable || !!pipes[k].pipe.src.gpuvm || !!pipes[k].pipe.src.vm; mode_lib->vba.OverrideGPUVMPageTableLevels = (pipes[k].pipe.src.gpuvm_levels_force_en && mode_lib->vba.OverrideGPUVMPageTableLevels < pipes[k].pipe.src.gpuvm_levels_force) ? pipes[k].pipe.src.gpuvm_levels_force : mode_lib->vba.OverrideGPUVMPageTableLevels; mode_lib->vba.HostVMEnable = mode_lib->vba.HostVMEnable || !!pipes[k].pipe.src.hostvm || !!pipes[k].pipe.src.vm; mode_lib->vba.OverrideHostVMPageTableLevels = (pipes[k].pipe.src.hostvm_levels_force_en && mode_lib->vba.OverrideHostVMPageTableLevels < pipes[k].pipe.src.hostvm_levels_force) ? pipes[k].pipe.src.hostvm_levels_force : mode_lib->vba.OverrideHostVMPageTableLevels; } mode_lib->vba.AllowDRAMSelfRefreshOrDRAMClockChangeInVblank = dm_try_to_allow_self_refresh_and_mclk_switch; if (mode_lib->vba.OverrideGPUVMPageTableLevels) mode_lib->vba.GPUVMMaxPageTableLevels = mode_lib->vba.OverrideGPUVMPageTableLevels; if (mode_lib->vba.OverrideHostVMPageTableLevels) mode_lib->vba.HostVMMaxPageTableLevels = mode_lib->vba.OverrideHostVMPageTableLevels; mode_lib->vba.GPUVMEnable = mode_lib->vba.GPUVMEnable && !!ip->gpuvm_enable; mode_lib->vba.HostVMEnable = mode_lib->vba.HostVMEnable && !!ip->hostvm_enable; } // in wm mode we pull the parameters needed from the display_e2e_pipe_params_st structs // rather than working them out as in recalculate_ms static void recalculate_params( struct display_mode_lib *mode_lib, const display_e2e_pipe_params_st *pipes, unsigned int num_pipes) { // This is only safe to use memcmp because there are non-POD types in struct display_mode_lib if (memcmp(&mode_lib->soc, &mode_lib->vba.soc, sizeof(mode_lib->vba.soc)) != 0 || memcmp(&mode_lib->ip, &mode_lib->vba.ip, sizeof(mode_lib->vba.ip)) != 0 || num_pipes != mode_lib->vba.cache_num_pipes || memcmp( pipes, mode_lib->vba.cache_pipes, sizeof(display_e2e_pipe_params_st) * num_pipes) != 0) { mode_lib->vba.soc = mode_lib->soc; mode_lib->vba.ip = mode_lib->ip; memcpy(mode_lib->vba.cache_pipes, pipes, sizeof(*pipes) * num_pipes); mode_lib->vba.cache_num_pipes = num_pipes; mode_lib->funcs.recalculate(mode_lib); } } bool Calculate256BBlockSizes( enum source_format_class SourcePixelFormat, enum dm_swizzle_mode SurfaceTiling, unsigned int BytePerPixelY, unsigned int BytePerPixelC, unsigned int *BlockHeight256BytesY, unsigned int *BlockHeight256BytesC, unsigned int *BlockWidth256BytesY, unsigned int *BlockWidth256BytesC) { if ((SourcePixelFormat == dm_444_64 || SourcePixelFormat == dm_444_32 || SourcePixelFormat == dm_444_16 || SourcePixelFormat == dm_444_8)) { if (SurfaceTiling == dm_sw_linear) { *BlockHeight256BytesY = 1; } else if (SourcePixelFormat == dm_444_64) { *BlockHeight256BytesY = 4; } else if (SourcePixelFormat == dm_444_8) { *BlockHeight256BytesY = 16; } else { *BlockHeight256BytesY = 8; } *BlockWidth256BytesY = 256 / BytePerPixelY / *BlockHeight256BytesY; *BlockHeight256BytesC = 0; *BlockWidth256BytesC = 0; } else { if (SurfaceTiling == dm_sw_linear) { *BlockHeight256BytesY = 1; *BlockHeight256BytesC = 1; } else if (SourcePixelFormat == dm_420_8) { *BlockHeight256BytesY = 16; *BlockHeight256BytesC = 8; } else { *BlockHeight256BytesY = 8; *BlockHeight256BytesC = 8; } *BlockWidth256BytesY = 256 / BytePerPixelY / *BlockHeight256BytesY; *BlockWidth256BytesC = 256 / BytePerPixelC / *BlockHeight256BytesC; } return true; } bool CalculateMinAndMaxPrefetchMode( enum self_refresh_affinity AllowDRAMSelfRefreshOrDRAMClockChangeInVblank, unsigned int *MinPrefetchMode, unsigned int *MaxPrefetchMode) { if (AllowDRAMSelfRefreshOrDRAMClockChangeInVblank == dm_neither_self_refresh_nor_mclk_switch) { *MinPrefetchMode = 2; *MaxPrefetchMode = 2; return false; } else if (AllowDRAMSelfRefreshOrDRAMClockChangeInVblank == dm_allow_self_refresh) { *MinPrefetchMode = 1; *MaxPrefetchMode = 1; return false; } else if (AllowDRAMSelfRefreshOrDRAMClockChangeInVblank == dm_allow_self_refresh_and_mclk_switch) { *MinPrefetchMode = 0; *MaxPrefetchMode = 0; return false; } else if (AllowDRAMSelfRefreshOrDRAMClockChangeInVblank == dm_try_to_allow_self_refresh_and_mclk_switch) { *MinPrefetchMode = 0; *MaxPrefetchMode = 2; return false; } *MinPrefetchMode = 0; *MaxPrefetchMode = 2; return true; } void PixelClockAdjustmentForProgressiveToInterlaceUnit(struct display_mode_lib *mode_lib) { unsigned int k; //Progressive To Interlace Unit Effect for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) { if (mode_lib->vba.Interlace[k] == 1 && mode_lib->vba.ProgressiveToInterlaceUnitInOPP == true) { mode_lib->vba.PixelClock[k] = 2 * mode_lib->vba.PixelClockBackEnd[k]; } } } static unsigned int CursorBppEnumToBits(enum cursor_bpp ebpp) { switch (ebpp) { case dm_cur_2bit: return 2; case dm_cur_32bit: return 32; case dm_cur_64bit: return 64; default: return 0; } } void ModeSupportAndSystemConfiguration(struct display_mode_lib *mode_lib) { soc_bounding_box_st *soc = &mode_lib->vba.soc; unsigned int k; unsigned int total_pipes = 0; mode_lib->vba.VoltageLevel = mode_lib->vba.cache_pipes[0].clks_cfg.voltage; mode_lib->vba.ReturnBW = mode_lib->vba.ReturnBWPerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb]; if (mode_lib->vba.ReturnBW == 0) mode_lib->vba.ReturnBW = mode_lib->vba.ReturnBWPerState[mode_lib->vba.VoltageLevel][0]; mode_lib->vba.FabricAndDRAMBandwidth = mode_lib->vba.FabricAndDRAMBandwidthPerState[mode_lib->vba.VoltageLevel]; fetch_socbb_params(mode_lib); fetch_ip_params(mode_lib); fetch_pipe_params(mode_lib); mode_lib->vba.DCFCLK = mode_lib->vba.cache_pipes[0].clks_cfg.dcfclk_mhz; mode_lib->vba.SOCCLK = mode_lib->vba.cache_pipes[0].clks_cfg.socclk_mhz; if (mode_lib->vba.cache_pipes[0].clks_cfg.dispclk_mhz > 0.0) mode_lib->vba.DISPCLK = mode_lib->vba.cache_pipes[0].clks_cfg.dispclk_mhz; else mode_lib->vba.DISPCLK = soc->clock_limits[mode_lib->vba.VoltageLevel].dispclk_mhz; // Total Available Pipes Support Check for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) total_pipes += mode_lib->vba.DPPPerPlane[k]; ASSERT(total_pipes <= DC__NUM_DPP__MAX); } double CalculateWriteBackDISPCLK( enum source_format_class WritebackPixelFormat, double PixelClock, double WritebackHRatio, double WritebackVRatio, unsigned int WritebackLumaHTaps, unsigned int WritebackLumaVTaps, unsigned int WritebackChromaHTaps, unsigned int WritebackChromaVTaps, double WritebackDestinationWidth, unsigned int HTotal, unsigned int WritebackChromaLineBufferWidth) { double CalculateWriteBackDISPCLK = 1.01 * PixelClock * dml_max( dml_ceil(WritebackLumaHTaps / 4.0, 1) / WritebackHRatio, dml_max((WritebackLumaVTaps * dml_ceil(1.0 / WritebackVRatio, 1) * dml_ceil(WritebackDestinationWidth / 4.0, 1) + dml_ceil(WritebackDestinationWidth / 4.0, 1)) / (double) HTotal + dml_ceil(1.0 / WritebackVRatio, 1) * (dml_ceil(WritebackLumaVTaps / 4.0, 1) + 4.0) / (double) HTotal, dml_ceil(1.0 / WritebackVRatio, 1) * WritebackDestinationWidth / (double) HTotal)); if (WritebackPixelFormat != dm_444_32) { CalculateWriteBackDISPCLK = dml_max(CalculateWriteBackDISPCLK, 1.01 * PixelClock * dml_max( dml_ceil(WritebackChromaHTaps / 2.0, 1) / (2 * WritebackHRatio), dml_max((WritebackChromaVTaps * dml_ceil(1 / (2 * WritebackVRatio), 1) * dml_ceil(WritebackDestinationWidth / 2.0 / 2.0, 1) + dml_ceil(WritebackDestinationWidth / 2.0 / WritebackChromaLineBufferWidth, 1)) / HTotal + dml_ceil(1 / (2 * WritebackVRatio), 1) * (dml_ceil(WritebackChromaVTaps / 4.0, 1) + 4) / HTotal, dml_ceil(1.0 / (2 * WritebackVRatio), 1) * WritebackDestinationWidth / 2.0 / HTotal))); } return CalculateWriteBackDISPCLK; } #endif
the_stack_data/118879.c
#include <assert.h> #include <ctype.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char* readline(); char* ltrim(char*); char* rtrim(char*); int parse_int(char*); /* * Complete the 'maxMin' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER k * 2. INTEGER_ARRAY arr */ int compare(int *a,int *b) { return *(int*)a-*(int*)b; } int maxMin(int k, int arr_count, int* arr) { qsort(arr,arr_count,sizeof(int),compare); int end = k - 1; int min=arr[end]-arr[0]; for(int i=0;i<arr_count-end;i++) { int j = 0; if( (j=(arr[i+end]-arr[i]) ) <min) { min=j; } } return min; } int main() { FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w"); int n = parse_int(ltrim(rtrim(readline()))); int k = parse_int(ltrim(rtrim(readline()))); int* arr = malloc(n * sizeof(int)); for (int i = 0; i < n; i++) { int arr_item = parse_int(ltrim(rtrim(readline()))); *(arr + i) = arr_item; } int result = maxMin(k, n, arr); fprintf(fptr, "%d\n", result); fclose(fptr); return 0; } char* readline() { size_t alloc_length = 1024; size_t data_length = 0; char* data = malloc(alloc_length); while (true) { char* cursor = data + data_length; char* line = fgets(cursor, alloc_length - data_length, stdin); if (!line) { break; } data_length += strlen(cursor); if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; } alloc_length <<= 1; data = realloc(data, alloc_length); if (!data) { data = '\0'; break; } } if (data[data_length - 1] == '\n') { data[data_length - 1] = '\0'; data = realloc(data, data_length); if (!data) { data = '\0'; } } else { data = realloc(data, data_length + 1); if (!data) { data = '\0'; } else { data[data_length] = '\0'; } } return data; } char* ltrim(char* str) { if (!str) { return '\0'; } if (!*str) { return str; } while (*str != '\0' && isspace(*str)) { str++; } return str; } char* rtrim(char* str) { if (!str) { return '\0'; } if (!*str) { return str; } char* end = str + strlen(str) - 1; while (end >= str && isspace(*end)) { end--; } *(end + 1) = '\0'; return str; } int parse_int(char* str) { char* endptr; int value = strtol(str, &endptr, 10); if (endptr == str || *endptr != '\0') { exit(EXIT_FAILURE); } return value; }
the_stack_data/243892670.c
#include <sys/types.h> #include <stdint.h> #include <stddef.h> #include "sys/types.h" #undef KEY #if defined(__i386) # define KEY '_','_','i','3','8','6' #elif defined(__x86_64) # define KEY '_','_','x','8','6','_','6','4' #elif defined(__ppc__) # define KEY '_','_','p','p','c','_','_' #elif defined(__ppc64__) # define KEY '_','_','p','p','c','6','4','_','_' #elif defined(__aarch64__) # define KEY '_','_','a','a','r','c','h','6','4','_','_' #elif defined(__ARM_ARCH_7A__) # define KEY '_','_','A','R','M','_','A','R','C','H','_','7','A','_','_' #elif defined(__ARM_ARCH_7S__) # define KEY '_','_','A','R','M','_','A','R','C','H','_','7','S','_','_' #endif #define SIZE (sizeof(u_int32_t)) char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[', ('0' + ((SIZE / 10000)%10)), ('0' + ((SIZE / 1000)%10)), ('0' + ((SIZE / 100)%10)), ('0' + ((SIZE / 10)%10)), ('0' + (SIZE % 10)), ']', #ifdef KEY ' ','k','e','y','[', KEY, ']', #endif '\0'}; #ifdef __CLASSIC_C__ int main(argc, argv) int argc; char *argv[]; #else int main(int argc, char *argv[]) #endif { int require = 0; require += info_size[argc]; (void)argv; return require; }
the_stack_data/843629.c
/* Copyright 2016 Rose-Hulman But based on idea from http://cnds.eecs.jacobs-university.de/courses/caoslab-2007/ */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <sys/wait.h> void myGoofyFunnyFunction(){ wait(NULL); } int main() { char command[82]; char *parsed_command[2]; bool isBG = false; //takes at most two input arguments // infinite loop but ^C quits while (1) { printf("SHELL%% "); fgets(command, 82, stdin); command[strlen(command) - 1] = '\0';//remove the \n int len_1; for(len_1 = 0;command[len_1] != '\0';len_1++){ if(command[len_1] == ' ') break; } parsed_command[0] = command; if(parsed_command[0][0] == 'B' && parsed_command[0][1] == 'G'){ parsed_command[0] = parsed_command[0] + 2; isBG = true; } if(len_1 == strlen(command)){ printf("Command is '%s' with no arguments\n", parsed_command[0]); parsed_command[1] = NULL; }else{ command[len_1] = '\0'; parsed_command[1] = command + len_1 + 1; printf("Command is '%s' with argument '%s'\n", parsed_command[0], parsed_command[1]); } if(isBG){ pid_t chl1 = fork(); if(chl1 == 0){ pid_t chl2 = fork(); if(chl2 == 0){ execlp(parsed_command[0], parsed_command[0], parsed_command[1], NULL); }else{ wait(NULL); printf("Background command finished!\n"); exit(EXIT_SUCCESS); } }else{ signal(SIGCHLD, myGoofyFunnyFunction); } }else{ if(fork() == 0){ execlp(parsed_command[0], parsed_command[0], parsed_command[1], NULL); }else{ wait(NULL); } } } }
the_stack_data/99144.c
/* -*- C++ -*- */ /************************************************************************* * Copyright(c) 1995~2005 Masaharu Goto ([email protected]) * * For the licensing terms see the file COPYING * ************************************************************************/ /************************************************************************** * array.c * * Array class speed up library * * makecint -dl array.sl -c array.c * * Constructor, copy constructor, destructor, operator overloading * function overloading, reference type * **************************************************************************/ #include <stdlib.h> #include <stdio.h> #include <math.h> #define G__ARRAYSL void G__ary_assign(double *c,double start,double stop,int n) { int i; double res; res = (stop-start)/(n-1); for(i=0;i<n;i++) c[i] = i*res + start ; } void G__ary_plus(double *c,double *a,double *b,int n) { int i; for(i=0;i<n;i++) c[i] = a[i] + b[i]; } void G__ary_minus(double *c,double *a,double *b,int n) { int i; for(i=0;i<n;i++) c[i] = a[i] - b[i]; } void G__ary_multiply(double *c,double *a,double *b,int n) { int i; for(i=0;i<n;i++) c[i] = a[i] * b[i]; } void G__ary_divide(double *c,double *a,double *b,int n) { int i; for(i=0;i<n;i++) { if(b[i]!=0) c[i] = a[i] / b[i]; else { if(a[i]==0) c[i]=1; else if(a[i]>0) c[i]=HUGE_VAL; else c[i] = -HUGE_VAL; } } } void G__ary_power(double *c,double *a,double *b,int n) { int i,j; int flag=0; double r; for(i=0;i<n;i++) { #ifndef G__OLDIMPLEMENTATION1622 c[i] = pow(a[i],b[i]); #else if(a[i]>0) c[i] = exp(b[i]*log(a[i])); else if(a[i]==0) c[i]=0; else { if(fmod(b[i],1.0)==0.0) { r=1; for(j=0;j<(int)a[i];j++) r *= b[i]; } else if(flag==0) { fprintf(stderr,"Error: Power operator oprand<0\n"); flag++; } } #endif } } void G__ary_exp(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = exp(a[i]); } void G__ary_log(double *c,double *a,int n) { int i; for(i=0;i<n;i++) { if(a[i]>0) c[i] = log(a[i]); else c[i] = -HUGE_VAL; } } void G__ary_log10(double *c,double *a,int n) { int i; for(i=0;i<n;i++) { if(a[i]>0) c[i] = log10(a[i]); else c[i] = -HUGE_VAL; } } void G__ary_sinc(double *c,double *a,int n) { int i; for(i=0;i<n;i++) { if(a[i]!=0) c[i] = sin(a[i])/a[i]; else c[i] = 1; } } void G__ary_sin(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = sin(a[i]); } void G__ary_cos(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = cos(a[i]); } void G__ary_tan(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = tan(a[i]); } void G__ary_sinh(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = sinh(a[i]); } void G__ary_cosh(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = cosh(a[i]); } void G__ary_tanh(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = tanh(a[i]); } void G__ary_asin(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = asin(a[i]); } void G__ary_acos(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = acos(a[i]); } void G__ary_atan(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = atan(a[i]); } void G__ary_fabs(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = fabs(a[i]); } void G__ary_sqrt(double *c,double *a,int n) { int i; for(i=0;i<n;i++) c[i] = sqrt(a[i]); } void G__ary_rect(double *c,double *a,int n) { int i; for(i=0;i<n;i++) { if(-0.5<a[i] && a[i]<0.5) c[i]=1.0; else if(a[i]==0.5 || a[i]==0.5) c[i]=0.5; else c[i]=0.0; } } void G__ary_square(double *c,double *a,int n) { int i; double tmp; for(i=0;i<n;i++) { tmp = sin(a[i]); if(tmp<0) c[i] = -1.0; else if(tmp==0) c[i]= 0.0; else c[i] = 1.0; } } void G__ary_rand(double *c,double *a,int n) { int i; #if defined(__CINT__) || defined(G__WIN32) for(i=0;i<n;i++) c[i] = (double)rand()/0x3fffffff-1.0; #else for(i=0;i<n;i++) c[i] = drand48(); #endif } void G__ary_conv(double *c,double *a,int n,double *b,int m) { int i,j,k; int f,t; f = m/2; t = m-f; for(i=0;i<n;i++) { c[i]=0.0; for(j=0;j<m;j++) { k=i-f+j; if(k<0) c[i] += a[0]*b[j]; else if(k>=n) c[i] += a[n-1]*b[j]; else c[i] += a[k]*b[j]; } } } void G__ary_integ(double *c,double *a,double *b,int n) { int i; double integ=0.0; for(i=0;i<n-1;i++) { integ += b[i]*(a[i+1]-a[i]); c[i] = integ; } integ += b[i]*(a[i]-a[i-1]); c[i] = integ; } void G__ary_diff(double *c,double *a,double *b,int n) { int i; double k,m; for(i=0;i<n-1;i++) { k = a[i+1]-a[i]; if(k!=0) c[i] = (b[i+1]-b[i])/k; else { m = k*(b[i+1]-b[i]); if(m==0) { if(k>0) c[i] = 1; else c[i] = -1; } else if(m>0) c[i] = HUGE_VAL; else c[i] = -HUGE_VAL; } } c[i] = c[i-1]; } void G__ary_max(double *c,double *a,double *b,int n) { int i; for(i=0;i<n;i++) { if(a[i]<b[i]) c[i] = b[i]; else c[i] = a[i]; } } void G__ary_min(double *c,double *a,double *b,int n) { int i; for(i=0;i<n;i++) { if(a[i]>b[i]) c[i] = b[i]; else c[i] = a[i]; } }
the_stack_data/36906.c
/* Code generated from eC source file: ecs.main.ec */ #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 #include <stdint.h> #include <sys/types.h> #if /*defined(_W64) || */(defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__) #define _64BIT 1 #else #define _64BIT 0 #endif #define arch_PointerSize sizeof(void *) #define structSize_Instance (_64BIT ? 24 : 12) #define structSize_Module (_64BIT ? 560 : 300) 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); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BTNode; struct __ecereNameSpace__ecere__sys__BTNode; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___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); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__OldList; struct __ecereNameSpace__ecere__sys__OldList { void * first; void * last; int count; unsigned int offset; unsigned int circ; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Method; struct __ecereNameSpace__ecere__com__Method { 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; char * dataTypeString; struct Type * dataType; int memberAccess; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Property; struct __ecereNameSpace__ecere__com__Property { struct __ecereNameSpace__ecere__com__Property * prev; struct __ecereNameSpace__ecere__com__Property * next; char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; 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; char * category; unsigned int compiled; unsigned int selfWatchable; unsigned int isWatchable; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_CodePosition; struct CodePosition { int line; int charPos; int pos; int included; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Location; struct Location { struct CodePosition start; struct CodePosition end; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Attrib; struct Attrib; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ExtDecl; struct ExtDecl; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassDefinition; struct ClassDefinition; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Context; struct Context; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Instantiation; struct Instantiation; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declaration; struct Declaration; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Statement; struct Statement; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TypeName; struct TypeName; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Initializer; struct Initializer; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataValue; 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; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Expression; struct Expression; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateDatatype; struct TemplateDatatype; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateArgument; struct TemplateArgument; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateParameter; struct TemplateParameter; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Specifier; struct Specifier; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Identifier; struct Identifier; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declarator; struct Declarator; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionDefinition; struct FunctionDefinition; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_DBTableDef; struct DBTableDef; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_External; struct External; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ModuleImport; struct ModuleImport; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassImport; struct ClassImport; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Symbol; struct Symbol; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Type; struct Type; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class; struct __ecereNameSpace__ecere__com__Class { struct __ecereNameSpace__ecere__com__Class * prev; struct __ecereNameSpace__ecere__com__Class * next; char * name; int offset; int structSize; int (* * _vTbl)(); int vTblSize; int (* Constructor)(struct __ecereNameSpace__ecere__com__Instance *); void (* Destructor)(struct __ecereNameSpace__ecere__com__Instance *); 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; char * dataTypeString; struct Type * dataType; int typeSize; int defaultAlignment; void (* Initialize)(); int memberOffset; struct __ecereNameSpace__ecere__sys__OldList selfWatchers; char * designerClass; unsigned int noExpansion; char * defaultProperty; unsigned int comRedefinition; int count; unsigned int isRemote; unsigned int internalDecl; void * data; unsigned int computeSize; int structAlignment; int destructionWatchOffset; unsigned int fixed; struct __ecereNameSpace__ecere__sys__OldList delayedCPValues; int inheritanceAccess; 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; } __attribute__ ((gcc_struct)); extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char * name); extern void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance; struct __ecereNameSpace__ecere__com__Instance { int (* * _vTbl)(); struct __ecereNameSpace__ecere__com__Class * _class; int _refCount; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataMember; struct __ecereNameSpace__ecere__com__DataMember { struct __ecereNameSpace__ecere__com__DataMember * prev; struct __ecereNameSpace__ecere__com__DataMember * next; char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; 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; int structAlignment; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__SerialBuffer; struct __ecereNameSpace__ecere__com__SerialBuffer { unsigned char * _buffer; unsigned int count; unsigned int _size; unsigned int pos; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__ClassTemplateArgument; struct __ecereNameSpace__ecere__com__ClassTemplateArgument { union { struct { char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; } __attribute__ ((gcc_struct)); struct __ecereNameSpace__ecere__com__DataValue expression; struct { char * memberString; union { struct __ecereNameSpace__ecere__com__DataMember * member; struct __ecereNameSpace__ecere__com__Property * prop; struct __ecereNameSpace__ecere__com__Method * method; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); static struct __ecereNameSpace__ecere__com__Instance * __currentModule; struct __ecereNameSpace__ecere__com__Instance * __thisModule; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Application; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Module; unsigned int __ecereDll_Load_ec(struct __ecereNameSpace__ecere__com__Instance * module); unsigned int __ecereDll_Unload_ec(struct __ecereNameSpace__ecere__com__Instance * module); struct __ecereNameSpace__ecere__com__Class * __ecereClass_Attrib; struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassDefinition; struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassImport; struct __ecereNameSpace__ecere__com__Class * __ecereClass_CodePosition; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Context; struct __ecereNameSpace__ecere__com__Class * __ecereClass_ContextStringPair; struct __ecereNameSpace__ecere__com__Class * __ecereClass_DBTableDef; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declaration; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declarator; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Definition; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Expression; struct __ecereNameSpace__ecere__com__Class * __ecereClass_ExtDecl; struct __ecereNameSpace__ecere__com__Class * __ecereClass_External; struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionDefinition; struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionImport; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Identifier; struct __ecereNameSpace__ecere__com__Class * __ecereClass_ImportedModule; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Initializer; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Instantiation; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Location; struct __ecereNameSpace__ecere__com__Class * __ecereClass_MethodImport; struct __ecereNameSpace__ecere__com__Class * __ecereClass_ModuleImport; struct __ecereNameSpace__ecere__com__Class * __ecereClass_PropertyImport; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Specifier; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Statement; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Symbol; struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateArgument; struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateDatatype; struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateParameter; struct __ecereNameSpace__ecere__com__Class * __ecereClass_Type; struct __ecereNameSpace__ecere__com__Class * __ecereClass_TypeName; unsigned int __ecereDll_Load_ecere(struct __ecereNameSpace__ecere__com__Instance * module); unsigned int __ecereDll_Unload_ecere(struct __ecereNameSpace__ecere__com__Instance * module); struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__BTNamedLink; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__ClassTemplateArgument; int __ecereVMethodID___ecereNameSpace__ecere__com__Container_Add; int __ecereVMethodID___ecereNameSpace__ecere__com__Container_Free; int __ecereVMethodID___ecereNameSpace__ecere__com__Container_RemoveAll; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__CustomAVLTree; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataMember; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataValue; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__GlobalFunction; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Iterator; struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__Iterator_data; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__IteratorPointer; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__List; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__List_TPL_String_; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Map; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Map_TPL_ContextStringPair__ecere__com__List_TPL_String___; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__MapIterator; struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__MapIterator_key; struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__MapIterator_map; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Method; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__NameSpace; struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__Platform_char__PTR_; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Property; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__SerialBuffer; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__SubModule; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BTNode; struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_next; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BinaryTree; struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_first; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__File; int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof; int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Puts; int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Read; int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek; int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Write; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__OldLink; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__OldList; struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__TempFile; void __ecereRegisterModule_ecs(struct __ecereNameSpace__ecere__com__Instance * module); void __ecereUnregisterModule_ecs(struct __ecereNameSpace__ecere__com__Instance * module); void __ecereCreateModuleInstances_ecs(); void __ecereDestroyModuleInstances_ecs(); extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com____ecere_COM_Initialize(unsigned int guiApp, int argc, char * argv[]); extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com__eModule_LoadStatic(struct __ecereNameSpace__ecere__com__Instance * fromModule, char * name, int importAccess, unsigned int (* Load)(struct __ecereNameSpace__ecere__com__Instance * module), unsigned int (* Unload)(struct __ecereNameSpace__ecere__com__Instance * module)); extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_FindClass(struct __ecereNameSpace__ecere__com__Instance * module, char * name); extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_FindMethod(struct __ecereNameSpace__ecere__com__Class * _class, char * name, struct __ecereNameSpace__ecere__com__Instance * module); extern struct __ecereNameSpace__ecere__com__Property * __ecereNameSpace__ecere__com__eClass_FindProperty(struct __ecereNameSpace__ecere__com__Class * _class, char * name, struct __ecereNameSpace__ecere__com__Instance * module); extern void __ecereNameSpace__ecere__LoadTranslatedStrings(char * moduleName, char * name); extern void __ecereNameSpace__ecere__com__eInstance_Evolve(struct __ecereNameSpace__ecere__com__Instance ** instancePtr, struct __ecereNameSpace__ecere__com__Class * _class); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__NameSpace; struct __ecereNameSpace__ecere__com__NameSpace { 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; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___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; char * name; void * library; void * Unload; int importType; int origImportType; struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace; struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace; } __attribute__ ((gcc_struct)); extern void __ecereNameSpace__ecere__UnloadTranslatedStrings(char * name); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Application; struct __ecereNameSpace__ecere__com__Application { int argc; char * * argv; int exitCode; unsigned int isGUIApp; struct __ecereNameSpace__ecere__sys__OldList allModules; char * parsedCommand; struct __ecereNameSpace__ecere__com__NameSpace systemNameSpace; } __attribute__ ((gcc_struct)); extern void __ecereNameSpace__ecere__com__eInstance_DecRef(struct __ecereNameSpace__ecere__com__Instance * instance); int main(int _argc, char * _argv[]) { int exitCode; struct __ecereNameSpace__ecere__com__Instance * module; struct __ecereNameSpace__ecere__com__Class * _class; struct __ecereNameSpace__ecere__com__Method * method; struct __ecereNameSpace__ecere__com__Property * _property; __thisModule = __currentModule = module = __ecereNameSpace__ecere__com____ecere_COM_Initialize((unsigned int)1, _argc, (void *)_argv); __ecereNameSpace__ecere__com__eModule_LoadStatic(module, "ec", 2, __ecereDll_Load_ec, __ecereDll_Unload_ec); __ecereNameSpace__ecere__com__eModule_LoadStatic(module, "ecere", 2, __ecereDll_Load_ecere, __ecereDll_Unload_ecere); __ecereRegisterModule_ecs(module); __ecereClass___ecereNameSpace__ecere__com__Application = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Application"); __ecereClass___ecereNameSpace__ecere__com__Instance = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Instance"); __ecereClass___ecereNameSpace__ecere__com__Module = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Module"); __ecereClass_Attrib = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Attrib"); __ecereClass_ClassDefinition = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ClassDefinition"); __ecereClass_ClassImport = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ClassImport"); __ecereClass_CodePosition = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "CodePosition"); __ecereClass_Context = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Context"); __ecereClass_ContextStringPair = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ContextStringPair"); __ecereClass_DBTableDef = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "DBTableDef"); __ecereClass_Declaration = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Declaration"); __ecereClass_Declarator = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Declarator"); __ecereClass_Definition = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Definition"); __ecereClass_Expression = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Expression"); __ecereClass_ExtDecl = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ExtDecl"); __ecereClass_External = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "External"); __ecereClass_FunctionDefinition = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "FunctionDefinition"); __ecereClass_FunctionImport = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "FunctionImport"); __ecereClass_Identifier = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Identifier"); __ecereClass_ImportedModule = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ImportedModule"); __ecereClass_Initializer = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Initializer"); __ecereClass_Instantiation = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Instantiation"); __ecereClass_Location = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Location"); __ecereClass_MethodImport = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "MethodImport"); __ecereClass_ModuleImport = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ModuleImport"); __ecereClass_PropertyImport = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "PropertyImport"); __ecereClass_Specifier = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Specifier"); __ecereClass_Statement = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Statement"); __ecereClass_Symbol = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Symbol"); __ecereClass_TemplateArgument = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "TemplateArgument"); __ecereClass_TemplateDatatype = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "TemplateDatatype"); __ecereClass_TemplateParameter = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "TemplateParameter"); __ecereClass_Type = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "Type"); __ecereClass_TypeName = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "TypeName"); __ecereClass___ecereNameSpace__ecere__com__BTNamedLink = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::BTNamedLink"); __ecereClass___ecereNameSpace__ecere__com__Class = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Class"); __ecereClass___ecereNameSpace__ecere__com__ClassTemplateArgument = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::ClassTemplateArgument"); _class = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Container"); method = __ecereNameSpace__ecere__com__eClass_FindMethod(_class, "Add", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__com__Container_Add = method->vid; method = __ecereNameSpace__ecere__com__eClass_FindMethod(_class, "Free", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__com__Container_Free = method->vid; method = __ecereNameSpace__ecere__com__eClass_FindMethod(_class, "RemoveAll", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__com__Container_RemoveAll = method->vid; __ecereClass___ecereNameSpace__ecere__com__CustomAVLTree = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::CustomAVLTree"); __ecereClass___ecereNameSpace__ecere__com__DataMember = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::DataMember"); __ecereClass___ecereNameSpace__ecere__com__DataValue = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::DataValue"); __ecereClass___ecereNameSpace__ecere__com__GlobalFunction = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::GlobalFunction"); __ecereClass___ecereNameSpace__ecere__com__Iterator = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Iterator"); __ecereProp___ecereNameSpace__ecere__com__Iterator_data = _property = __ecereNameSpace__ecere__com__eClass_FindProperty(__ecereClass___ecereNameSpace__ecere__com__Iterator, "data", module); __ecereClass___ecereNameSpace__ecere__com__IteratorPointer = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::IteratorPointer"); __ecereClass___ecereNameSpace__ecere__com__List = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::List"); __ecereClass___ecereNameSpace__ecere__com__List_TPL_String_ = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::List<String>"); __ecereClass___ecereNameSpace__ecere__com__Map = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Map"); __ecereClass___ecereNameSpace__ecere__com__Map_TPL_ContextStringPair__ecere__com__List_TPL_String___ = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Map<ContextStringPair, ecere::com::List<String> >"); __ecereClass___ecereNameSpace__ecere__com__MapIterator = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::MapIterator"); __ecereProp___ecereNameSpace__ecere__com__MapIterator_key = _property = __ecereNameSpace__ecere__com__eClass_FindProperty(__ecereClass___ecereNameSpace__ecere__com__MapIterator, "key", module); __ecereProp___ecereNameSpace__ecere__com__MapIterator_map = _property = __ecereNameSpace__ecere__com__eClass_FindProperty(__ecereClass___ecereNameSpace__ecere__com__MapIterator, "map", module); __ecereClass___ecereNameSpace__ecere__com__Method = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Method"); __ecereClass___ecereNameSpace__ecere__com__NameSpace = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::NameSpace"); _class = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Platform"); __ecereProp___ecereNameSpace__ecere__com__Platform_char__PTR_ = _property = __ecereNameSpace__ecere__com__eClass_FindProperty(_class, "char *", module); __ecereClass___ecereNameSpace__ecere__com__Property = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::Property"); __ecereClass___ecereNameSpace__ecere__com__SerialBuffer = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::SerialBuffer"); __ecereClass___ecereNameSpace__ecere__com__SubModule = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::com::SubModule"); __ecereClass___ecereNameSpace__ecere__sys__BTNode = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::sys::BTNode"); __ecereProp___ecereNameSpace__ecere__sys__BTNode_next = _property = __ecereNameSpace__ecere__com__eClass_FindProperty(__ecereClass___ecereNameSpace__ecere__sys__BTNode, "next", module); __ecereClass___ecereNameSpace__ecere__sys__BinaryTree = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::sys::BinaryTree"); __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_first = _property = __ecereNameSpace__ecere__com__eClass_FindProperty(__ecereClass___ecereNameSpace__ecere__sys__BinaryTree, "first", module); __ecereClass___ecereNameSpace__ecere__sys__File = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::sys::File"); method = __ecereNameSpace__ecere__com__eClass_FindMethod(__ecereClass___ecereNameSpace__ecere__sys__File, "Eof", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof = method->vid; method = __ecereNameSpace__ecere__com__eClass_FindMethod(__ecereClass___ecereNameSpace__ecere__sys__File, "Puts", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__sys__File_Puts = method->vid; method = __ecereNameSpace__ecere__com__eClass_FindMethod(__ecereClass___ecereNameSpace__ecere__sys__File, "Read", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__sys__File_Read = method->vid; method = __ecereNameSpace__ecere__com__eClass_FindMethod(__ecereClass___ecereNameSpace__ecere__sys__File, "Seek", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek = method->vid; method = __ecereNameSpace__ecere__com__eClass_FindMethod(__ecereClass___ecereNameSpace__ecere__sys__File, "Write", module); if(method) __ecereVMethodID___ecereNameSpace__ecere__sys__File_Write = method->vid; __ecereClass___ecereNameSpace__ecere__sys__OldLink = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::sys::OldLink"); __ecereClass___ecereNameSpace__ecere__sys__OldList = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::sys::OldList"); __ecereClass___ecereNameSpace__ecere__sys__TempFile = __ecereNameSpace__ecere__com__eSystem_FindClass(module, "ecere::sys::TempFile"); __ecereNameSpace__ecere__LoadTranslatedStrings((((void *)0)), "ecs"); _class = __ecereNameSpace__ecere__com__eSystem_FindClass(__currentModule, "SymbolgenApp"); __ecereNameSpace__ecere__com__eInstance_Evolve((struct __ecereNameSpace__ecere__com__Instance **)&__currentModule, _class); __thisModule = __currentModule; __ecereCreateModuleInstances_ecs(); ((void (*)(void *))(void *)((struct __ecereNameSpace__ecere__com__Instance *)(char *)__currentModule)->_vTbl[12])(__currentModule); __ecereDestroyModuleInstances_ecs(); __ecereNameSpace__ecere__UnloadTranslatedStrings("ecs"); _class = __ecereNameSpace__ecere__com__eSystem_FindClass(__currentModule, "ecere::com::Application"); exitCode = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Instance *)__currentModule) + structSize_Module)))->exitCode; (__ecereNameSpace__ecere__com__eInstance_DecRef(__currentModule), __currentModule = 0); return exitCode; } void __ecereRegisterModule_ecs_main(struct __ecereNameSpace__ecere__com__Instance * module) { struct __ecereNameSpace__ecere__com__Class * class; } void __ecereUnregisterModule_ecs_main(struct __ecereNameSpace__ecere__com__Instance * module) { }
the_stack_data/536717.c
#include <stdio.h> #include <string.h> main() { int c; while((c = getchar()) != EOF) { if(c == '<' || c == 'B' || c == '"') //Courtesy by Marcela Montserrat, she help me to put more arguments// { do { c = getchar(); } while(c != EOF && c != '>'); } else { putchar(c); } } }
the_stack_data/1021551.c
/*Write a program having a function iseven() which takes a number as input and returns 1 if the number is even else returns 0. Create the main() function to input a number and check it to be even or odd using iseven() function.*/ #include<stdio.h> int iseven(int n) { return(n%2?0:1); } main() { int num; printf("Enter the number :"); scanf("%d",&num); if(iseven(num)) printf("%d is even",num); else printf("%d is odd",num); }
the_stack_data/159514776.c
void foo(int pos, int C[const static 1 + pos + 4]) { for (int i = 0; i < 4; ++i) C[1 + pos + i] += i; } void bar(int n, int A[const static n]) { #pragma scop __pencil_assume(n >= 4); foo(-1, A); #pragma endscop }
the_stack_data/87639030.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> int countPrimes(int n) { if (n < 3) { return 0; } int i, j; bool *marked = malloc(n); memset(marked, false, n); int count = n >> 1; for (i = 3; i * i <= n; i += 2) { if (!marked[i]) { for (j = i * i; j < n; j += (i << 1)) { if (!marked[j]) { marked[j] = true; --count; } } } } return count; } int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: ./test n\n"); exit(-1); } printf("%d\n", countPrimes(atoi(argv[1]))); return 0; }
the_stack_data/68886913.c
// Copyright (c) 2020, devgo.club // All rights reserved. #include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> void output(int64_t count, ...); int64_t sum(int64_t count, ...); int main(int argc, char const *argv) { output(3, "C", "Go", "Js"); printf("sum: 1+2+3+4+5=%ld\n", sum(5, 1, 2, 3, 4, 5)); return EXIT_SUCCESS; } void output(int64_t count, ...) { va_list args; va_start(args, count); for (int64_t i = 0; i < count; i++) { char *s = va_arg(args, char *); printf("output: [%ld] %s\n", i, s); } va_end(args); } int64_t sum(int64_t count, ...) { int64_t result = 0; va_list args; va_start(args, count); for (int64_t i = 0; i < count; ++i) { int64_t n = va_arg(args, int64_t); result += n; } va_end(args); return result; }
the_stack_data/829138.c
/* copied the below from test_xi2.c of xinput source code got the xinput source code from git clone git://anongit.freedesktop.org/xorg/app/xinput to build xinput: cd /home/j/dev/apps/x11/xinput && autoreconf -i && ./configure && make got this idea from http://stackoverflow.com/questions/16369850/xinput-2-key-code-to-string http://unix.stackexchange.com/questions/129159/record-every-keystroke-and-store-in-a-file to print the modifier keysym, check out PrintModifierMapping of exec.c of xmodmap source from http://cgit.freedesktop.org/xorg/app/xmodmap/ to compile: gcc -o show-active-keyboard-modifiers \ `pkg-config --cflags --libs xi` \ `pkg-config --cflags --libs x11` show-active-keyboard-modifiers.c also checkout XI2 tutorials at: http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html http://who-t.blogspot.com/2009/07/xi2-recipes-part-4.html http://who-t.blogspot.com/2009/07/xi2-and-xlib-cookies.html usage: ./show-active-keyboard-modifiers | sed -e 's/_[LR]//g' */ /* #include "xinput.h" */ #include <X11/Xlib.h> #include <X11/extensions/XInput.h> #include <X11/extensions/XInput2.h> #include <X11/Xutil.h> #include <X11/XKBlib.h> /* which declares: KeySym XkbKeycodeToKeysym(Display *dpy, KeyCode kc, unsigned int group, unsigned int level); */ #include <stdio.h> #include <stdlib.h> #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 1 #endif #ifndef EXIT_FAILURE #define EXIT_FAILURE 0 #endif int xinput_version(Display* display); #include <string.h> int xi_opcode; extern struct modtab { const char *name; char *first_keysym_name; } modifier_table[]; struct modtab modifier_table[] = { /* keep in order so it can be index */ { "shift", 0 }, { "lock", 0 }, { "control", 0 }, { "mod1", 0 }, { "mod2", 0 }, { "mod3", 0 }, { "mod4", 0 }, { "mod5", 0 }}; static void output(int check, char * label, FILE *fp) { int first_set_bit = 1; int i = 0; if (0 < check) { fprintf(fp, "%s:[", label); for (i = 0; i < 8; i++) { if ((1 << i) & check) { fprintf(fp, "%s%s", (first_set_bit ? "" : ","), modifier_table[i].first_keysym_name); first_set_bit = 0; } } fprintf(fp, "]"); } } /* static void print_deviceevent(XIDeviceEvent* event); */ /* static const char* type_to_name(int evtype); */ int main( void ) { Display *display; XIEventMask mask[1] = { {0} }; XIEventMask *m; Window win; int event, error; XModifierKeymap *map = NULL; int i = 0; XIDeviceEvent* cookieData; int min_keycode, max_keycode, keysyms_per_keycode = 0; display = XOpenDisplay(NULL); if (display == NULL) { fprintf(stderr, "Unable to connect to X server\n"); goto out; } if (!XQueryExtension(display, "XInputExtension", &xi_opcode, &event, &error)) { printf("X Input extension not available.\n"); goto out; } /* set line buffering to stdout */ setvbuf(stdout, NULL, _IOLBF, 0); /* got this from PrintModifierMapping of exec.c of xmodmap source */ map = XGetModifierMapping (display); XDisplayKeycodes (display, &min_keycode, &max_keycode); XGetKeyboardMapping (display, min_keycode, (max_keycode - min_keycode + 1), &keysyms_per_keycode); for (i = 0; i < 8; i++) { /* fprintf(stdout, "%-10s", modifier_table[i].name); */ int j = 0; for (j = 0; j < map->max_keypermod; j++) { int k = (i * map->max_keypermod) + j; if (map->modifiermap[k]) { KeySym ks; int index = 0; char *nm; do { ks = XkbKeycodeToKeysym( display, map->modifiermap[k], 0, index); index++; } while ( !ks && index < keysyms_per_keycode); nm = XKeysymToString(ks); /* fprintf (stdout, "%s (0x%0x) ", */ /* (nm ? nm : "Badkey") , map->modifiermap[k]); */ if (0 == j && nm) { modifier_table[i].first_keysym_name = nm; } } } /* fprintf(stdout, "\n"); */ } /* fprintf (stdout, "\n"); */ win = DefaultRootWindow(display); /* Select for motion events */ m = &mask[0]; m->deviceid = XIAllDevices; m->mask_len = XIMaskLen(XI_LASTEVENT); m->mask = calloc(m->mask_len, sizeof(char)); XISetMask(m->mask, XI_KeyPress); XISetMask(m->mask, XI_KeyRelease); XISelectEvents(display, win, &mask[0], 1); XSync(display, False); free(mask[0].mask); while(1) { XEvent ev; XGenericEventCookie *cookie = (XGenericEventCookie*)&ev.xcookie; XNextEvent(display, (XEvent*)&ev); if (XGetEventData(display, cookie) && cookie->type == GenericEvent && cookie->extension == xi_opcode) { /* printf("EVENT type %d (%s)\n", cookie->evtype, type_to_name(cookie->evtype)); */ switch (cookie->evtype) { case XI_KeyPress: case XI_KeyRelease: default: /* print_deviceevent(cookie->data); */ cookieData = cookie->data; output(cookieData->mods.locked, "Locked", stdout); output(cookieData->mods.latched, " Latched", stdout); output(cookieData->mods.effective, " Effective", stdout); fprintf(stdout, "\n"); break; } } XFreeEventData(display, cookie); } XDestroyWindow(display, win); XSync(display, False); XCloseDisplay(display); return EXIT_SUCCESS; out: if (display) XCloseDisplay(display); return EXIT_FAILURE; } /* static void print_deviceevent(XIDeviceEvent* event) */ /* { */ /* double *val; */ /* int i; */ /* printf(" device: %d (%d)\n", event->deviceid, event->sourceid); */ /* printf(" detail: %d\n", event->detail); */ /* switch(event->evtype) { */ /* case XI_KeyPress: */ /* case XI_KeyRelease: */ /* printf(" flags: %s\n", (event->flags & XIKeyRepeat) ? "repeat" : ""); */ /* break; */ /* #if HAVE_XI21 */ /* case XI_ButtonPress: */ /* case XI_ButtonRelease: */ /* case XI_Motion: */ /* printf(" flags: %s\n", (event->flags & XIPointerEmulated) ? "emulated" : ""); */ /* break; */ /* #endif */ /* } */ /* printf(" root: %.2f/%.2f\n", event->root_x, event->root_y); */ /* printf(" event: %.2f/%.2f\n", event->event_x, event->event_y); */ /* printf(" buttons:"); */ /* for (i = 0; i < event->buttons.mask_len * 8; i++) */ /* if (XIMaskIsSet(event->buttons.mask, i)) */ /* printf(" %d", i); */ /* printf("\n"); */ /* printf(" modifiers: locked %#x latched %#x base %#x effective: %#x\n", */ /* event->mods.locked, event->mods.latched, */ /* event->mods.base, event->mods.effective); */ /* printf(" group: locked %#x latched %#x base %#x effective: %#x\n", */ /* event->group.locked, event->group.latched, */ /* event->group.base, event->group.effective); */ /* printf(" valuators:\n"); */ /* val = event->valuators.values; */ /* for (i = 0; i < event->valuators.mask_len * 8; i++) */ /* if (XIMaskIsSet(event->valuators.mask, i)) */ /* printf(" %i: %.2f\n", i, *val++); */ /* printf(" windows: root 0x%lx event 0x%lx child 0x%lx\n", */ /* event->root, event->event, event->child); */ /* } */ /* static const char* type_to_name(int evtype) */ /* { */ /* const char *name; */ /* switch(evtype) { */ /* case XI_DeviceChanged: name = "DeviceChanged"; break; */ /* case XI_KeyPress: name = "KeyPress"; break; */ /* case XI_KeyRelease: name = "KeyRelease"; break; */ /* case XI_ButtonPress: name = "ButtonPress"; break; */ /* case XI_ButtonRelease: name = "ButtonRelease"; break; */ /* case XI_Motion: name = "Motion"; break; */ /* case XI_Enter: name = "Enter"; break; */ /* case XI_Leave: name = "Leave"; break; */ /* case XI_FocusIn: name = "FocusIn"; break; */ /* case XI_FocusOut: name = "FocusOut"; break; */ /* case XI_HierarchyChanged: name = "HierarchyChanged"; break; */ /* case XI_PropertyEvent: name = "PropertyEvent"; break; */ /* case XI_RawKeyPress: name = "RawKeyPress"; break; */ /* case XI_RawKeyRelease: name = "RawKeyRelease"; break; */ /* case XI_RawButtonPress: name = "RawButtonPress"; break; */ /* case XI_RawButtonRelease: name = "RawButtonRelease"; break; */ /* case XI_RawMotion: name = "RawMotion"; break; */ /* case XI_TouchBegin: name = "TouchBegin"; break; */ /* case XI_TouchUpdate: name = "TouchUpdate"; break; */ /* case XI_TouchEnd: name = "TouchEnd"; break; */ /* case XI_RawTouchBegin: name = "RawTouchBegin"; break; */ /* case XI_RawTouchUpdate: name = "RawTouchUpdate"; break; */ /* case XI_RawTouchEnd: name = "RawTouchEnd"; break; */ /* default: */ /* name = "unknown event type"; break; */ /* } */ /* return name; */ /* } */
the_stack_data/774816.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 #include <stdlib.h> int main(void) { int counter = 0; while (counter < 5) { counter++; } while (counter < 10) { counter++; } while (counter < 15) { counter++; } return (0); }
the_stack_data/97011718.c
extern int __VERIFIER_nondet_int(void); char *(cstrncat)(char *s1, const char *s2, int n) { char *s = s1; /* Loop over the data in s1. */ while (*s != '\0') s++; /* s now points to s1's trailing null character, now copy up to n bytes from s1 into s stopping if a null character is encountered in s2. It is not safe to use strncpy here since it copies EXACTLY n characters, NULL padding if necessary. */ while (n != 0 && (*s = *s2++) != '\0') { n--; s++; } if (*s != '\0') *s = '\0'; return s1; } int main() { char *s1; char *s2; int n = __VERIFIER_nondet_int(); cstrncat(s1, s2, n); return 0; }
the_stack_data/13313.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_str_is_lowercase.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: kchenna <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/09/25 18:04:46 by kchenna #+# #+# */ /* Updated: 2018/09/25 23:05:00 by kchenna ### ########.fr */ /* */ /* ************************************************************************** */ int ft_str_is_lowercase(char *str) { if (*str == '\0') return (1); while (*str != '\0') { if (*str >= 'a' && *str <= 'z') str++; else return (0); } return (1); }
the_stack_data/3261988.c
/* * Copyright (C) 2016 Bas Stottelaar <[email protected]> * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @ingroup sys_auto_init_saul * @{ * * @file * @brief Auto initialization of Si70xx driver. * * @author Bas Stottelaar <[email protected]> * * @} */ #ifdef MODULE_SI70XX #include "assert.h" #include "log.h" #include "saul_reg.h" #include "si70xx.h" #include "si70xx_params.h" /** * @brief Define the number of configured sensors */ #define SI70XX_NUM (sizeof(si70xx_params) / sizeof(si70xx_params[0])) /** * @brief Allocation of memory for device descriptors */ static si70xx_t si70xx_devs[SI70XX_NUM]; /** * @brief Memory for the SAUL registry entries */ static saul_reg_t saul_entries[SI70XX_NUM * 2]; /** * @brief Define the number of saul info */ #define SI70XX_INFO_NUM (sizeof(si70xx_saul_info) / sizeof(si70xx_saul_info[0])) /** * @name Reference the driver structs. * @{ */ extern const saul_driver_t si70xx_temperature_saul_driver; extern const saul_driver_t si70xx_relative_humidity_saul_driver; /** @} */ void auto_init_si70xx(void) { assert(SI70XX_INFO_NUM == SI70XX_NUM); for (unsigned i = 0; i < SI70XX_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing SI70xx #%u\n", i); if (si70xx_init(&si70xx_devs[i], &si70xx_params[i]) != SI70XX_OK) { LOG_ERROR("[auto_init_saul] error initializing SI70xx #%i\n", i); continue; } /* temperature */ saul_entries[i * 2].dev = &si70xx_devs[i]; saul_entries[i * 2].name = si70xx_saul_info[i].name; saul_entries[i * 2].driver = &si70xx_temperature_saul_driver; /* relative humidity */ saul_entries[(i * 2) + 1].dev = &si70xx_devs[i]; saul_entries[(i * 2) + 1].name = si70xx_saul_info[i].name; saul_entries[(i * 2) + 1].driver = \ &si70xx_relative_humidity_saul_driver; saul_reg_add(&saul_entries[i * 2]); saul_reg_add(&saul_entries[(i * 2) + 1]); } } #else typedef int dont_be_pedantic; #endif /* MODULE_SI70XX */
the_stack_data/34455.c
/* * Copyright 2014, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) */ int c; int d[10]; char x;
the_stack_data/165766930.c
/*************************************************************************\ * Copyright (C) Michael Kerrisk, 2018. * * * * This program is free software. You may use, modify, and redistribute it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation, either version 3 or (at your option) any * * later version. This program is distributed without any warranty. See * * the file COPYING.gpl-v3 for details. * \*************************************************************************/ /* Supplementary program for Chapter 19 */ /* inotify_dtree.c This is an example application to demonstrate the robust use of the inotify API. The goal of the application is to maintain an internal representation ("a cache") of the directory trees named on its command line. To keep the application shorter, just the directories are represented, not the files, but dealing with the latter is simpler in any case. As directories are added, removed, and renamed in the subtrees, the resulting inotify events are used to maintain an internal representation of the directory trees that remains consistent with the filesystem. The program also provides a command-line interface that allows the user to perform tasks such as dumping the current state of the cache and running a consistency check of the cache against the current state of the directory tree(s). Testing of this program is ongoing, and bug reports (to [email protected]) are welcome. The rand_dtree.c program can be used to stress test the operation of this program. See also the article "Filesystem notification, part 2: A deeper investigation of inotify" July 2014 https://lwn.net/Articles/605128/ */ /* Known limitations - Pathnames longer than PATH_MAX are not handled. */ #define _GNU_SOURCE #include <sys/select.h> #include <sys/stat.h> #include <limits.h> #include <sys/select.h> #include <sys/inotify.h> #include <fcntl.h> #include <ftw.h> #include <signal.h> #include <stdarg.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) /* logMessage() flags */ #define VB_BASIC 1 /* Basic messages */ #define VB_NOISY 2 /* Verbose messages */ static int verboseMask; static int checkCache; static int dumpCache; static int readBufferSize = 0; static char *stopFile; static int abortOnCacheProblem; static FILE *logfp = NULL; static int inotifyReadCnt = 0; /* Counts number of read()s from inotify file descriptor */ static const int INOTIFY_READ_BUF_LEN = (100 * (sizeof(struct inotify_event) + NAME_MAX + 1)); static void dumpCacheToLog(void); /* Something went badly wrong. Create a 'stop' file to signal the 'rand_dtree' processes to stop, dump a copy of the cache to the log file, and abort. */ __attribute__ ((__noreturn__)) static void createStopFileAndAbort(void) { open(stopFile, O_CREAT | O_RDWR, 0600); dumpCacheToLog(); abort(); } /* Write a log message. The message is sent to none, either, or both of stderr and the log file, depending on 'vb_mask' and whether a log file has been specified via command-line options . */ static void logMessage(int vb_mask, const char *format, ...) { va_list argList; /* Write message to stderr if 'vb_mask' is zero, or matches one of the bits in 'verboseMask' */ if ((vb_mask == 0) || (vb_mask & verboseMask)) { va_start(argList, format); vfprintf(stderr, format, argList); va_end(argList); } /* If we have a log file, write the message there */ if (logfp != NULL) { va_start(argList, format); vfprintf(logfp, format, argList); va_end(argList); } } /***********************************************************************/ /* Display some information about an inotify event. (Used when when we are doing verbose logging.) */ static void displayInotifyEvent(struct inotify_event *ev) { logMessage(VB_NOISY, "==> wd = %d; ", ev->wd); if (ev->cookie > 0) logMessage(VB_NOISY, "cookie = %4d; ", ev->cookie); logMessage(VB_NOISY, "mask = "); if (ev->mask & IN_ISDIR) logMessage(VB_NOISY, "IN_ISDIR "); if (ev->mask & IN_CREATE) logMessage(VB_NOISY, "IN_CREATE "); if (ev->mask & IN_DELETE_SELF) logMessage(VB_NOISY, "IN_DELETE_SELF "); if (ev->mask & IN_MOVE_SELF) logMessage(VB_NOISY, "IN_MOVE_SELF "); if (ev->mask & IN_MOVED_FROM) logMessage(VB_NOISY, "IN_MOVED_FROM "); if (ev->mask & IN_MOVED_TO) logMessage(VB_NOISY, "IN_MOVED_TO "); if (ev->mask & IN_IGNORED) logMessage(VB_NOISY, "IN_IGNORED "); if (ev->mask & IN_Q_OVERFLOW) logMessage(VB_NOISY, "IN_Q_OVERFLOW "); if (ev->mask & IN_UNMOUNT) logMessage(VB_NOISY, "IN_UNMOUNT "); logMessage(VB_NOISY, "\n"); if (ev->len > 0) logMessage(VB_NOISY, " name = %s\n", ev->name); } /***********************************************************************/ /* Data structures and functions for the watch list cache */ /* We use a very simple data structure for caching watched directory paths: a dynamically sized array that is searched linearly. Not efficient, but our main goal is to demonstrate the use of inotify. */ struct watch { int wd; /* Watch descriptor (-1 if slot unused) */ char path[PATH_MAX]; /* Cached pathname */ }; struct watch *wlCache = NULL; /* Array of cached items */ static int cacheSize = 0; /* Current size of the array */ /* Deallocate the watch cache */ static void freeCache(void) { free(wlCache); cacheSize = 0; wlCache = NULL; } /* Check that all pathnames in the cache are valid, and refer to directories */ static void checkCacheConsistency(void) { int failures, j; struct stat sb; failures = 0; for (j = 0; j < cacheSize; j++) { if (wlCache[j].wd >= 0) { if (lstat(wlCache[j].path, &sb) == -1) { logMessage(0, "checkCacheConsistency: stat: " "[slot = %d; wd = %d] %s: %s\n", j, wlCache[j].wd, wlCache[j].path, strerror(errno)); failures++; } else if (!S_ISDIR(sb.st_mode)) { logMessage(0, "checkCacheConsistency: %s is not a directory\n", wlCache[j].path); exit(EXIT_FAILURE); } } } if (failures > 0) logMessage(VB_NOISY, "checkCacheConsistency: %d failures\n", failures); } /* Check whether the cache contains the watch descriptor 'wd'. If found, return the slot number, otherwise return -1. */ static int findWatch(int wd) { int j; for (j = 0; j < cacheSize; j++) if (wlCache[j].wd == wd) return j; return -1; } /* Find and return the cache slot for the watch descriptor 'wd'. The caller expects this watch descriptor to exist. If it does not, there is a problem, which is signaled by the -1 return. */ static int findWatchChecked(int wd) { int slot; slot = findWatch(wd); if (slot >= 0) return slot; logMessage(0, "Could not find watch %d\n", wd); /* With multiple renamers there are still rare cases where the cache is missing entries after a 'Could not find watch' event. It looks as though this is because of races with nftw(), since the cache is (occasionally) re-created with fewer entries than there are objects in the tree(s). Returning -1 to our caller identifies that there's a problem, and the caller should probably trigger a cache rebuild. */ if (abortOnCacheProblem) { createStopFileAndAbort(); } else { return -1; } } /* Mark a cache entry as unused */ static void markCacheSlotEmpty(int slot) { logMessage(VB_NOISY, " markCacheSlotEmpty: slot = %d; wd = %d; path = %s\n", slot, wlCache[slot].wd, wlCache[slot].path); wlCache[slot].wd = -1; wlCache[slot].path[0] = '\0'; } /* Find a free slot in the cache */ static int findEmptyCacheSlot(void) { int j; const int ALLOC_INCR = 200; for (j = 0; j < cacheSize; j++) if (wlCache[j].wd == -1) return j; /* No free slot found; resize cache */ cacheSize += ALLOC_INCR; wlCache = realloc(wlCache, cacheSize * sizeof(struct watch)); if (wlCache == NULL) errExit("realloc"); for (j = cacheSize - ALLOC_INCR; j < cacheSize; j++) markCacheSlotEmpty(j); return cacheSize - ALLOC_INCR; /* Return first slot in newly allocated space */ } /* Add an item to the cache */ static int addWatchToCache(int wd, const char *pathname) { int slot; slot = findEmptyCacheSlot(); wlCache[slot].wd = wd; strncpy(wlCache[slot].path, pathname, PATH_MAX); return slot; } /* Return the cache slot that corresponds to a particular pathname, or -1 if the pathname is not in the cache */ static int pathnameToCacheSlot(const char *pathname) { int j; for (j = 0; j < cacheSize; j++) if (wlCache[j].wd >= 0 && strcmp(wlCache[j].path, pathname) == 0) return j; return -1; } /* Is 'pathname' in the watch cache? */ static int pathnameInCache(const char *pathname) { return pathnameToCacheSlot(pathname) >= 0; } /* Dump contents of watch cache to the log file */ static void dumpCacheToLog(void) { int cnt, j; cnt = 0; for (j = 0; j < cacheSize; j++) { if (wlCache[j].wd >= 0) { fprintf(logfp, "%d: wd = %d; %s\n", j, wlCache[j].wd, wlCache[j].path); cnt++; } } fprintf(logfp, "Total entries: %d\n", cnt); } /***********************************************************************/ /* Data structures and functions for dealing with the directory pathnames provided as command-line arguments. These directories form the roots of the trees that we will monitor */ static char **rootDirPaths; /* List of pathnames supplied on command line */ static int numRootDirs; /* Number of pathnames supplied on command line */ static int ignoreRootDirs; /* Number of command-line pathnames that we've ceased to monitor */ static struct stat *rootDirStat; /* stat(2) structures for root directories */ /* Duplicate the pathnames supplied on the command line, perform some sanity checking along the way */ static void copyRootDirPaths(char *argv[]) { char **p; int j, k; struct stat sb; p = argv; numRootDirs = 0; /* Count the number of root paths, and check that the paths are valid */ for (p = argv; *p != NULL; p++) { /* Check that command-line arguments are directories */ if (lstat(*p, &sb) == -1) { fprintf(stderr, "lstat() failed on '%s'\n", *p); exit(EXIT_FAILURE); } if (! S_ISDIR(sb.st_mode)) { fprintf(stderr, "'%s' is not a directory\n", *p); exit(EXIT_FAILURE); } numRootDirs++; } /* Create a copy of the root directory pathnames */ rootDirPaths = calloc(numRootDirs, sizeof(char *)); if (rootDirPaths == NULL) errExit("calloc"); rootDirStat = calloc(numRootDirs, sizeof(struct stat)); if (rootDirPaths == NULL) errExit("calloc"); for (j = 0; j < numRootDirs; j++) { rootDirPaths[j] = strdup(argv[j]); if (rootDirPaths[j] == NULL) errExit("strdup"); /* If the same filesystem object appears more than once in the command line, this will cause confusion if we later try to zap an object from the set of root paths. So, reject such duplicates now. Note that we can't just do simple string comparisons of the arguments, since different pathname strings may refer to the same filesystem object (e.g., "mydir" and "./mydir"). So, we use stat() to compare i-node numbers and containing device IDs. */ if (lstat(argv[j], &rootDirStat[j]) == -1) errExit("lstat"); for (k = 0; k < j; k++) { if ((rootDirStat[j].st_ino == rootDirStat[k].st_ino) && (rootDirStat[j].st_dev == rootDirStat[k].st_dev)) { fprintf(stderr, "Duplicate filesystem objects: %s, %s\n", argv[j], argv[k]); exit(EXIT_FAILURE); } } } ignoreRootDirs = 0; } /* Return the address of the element in 'rootDirPaths' that points to a string matching 'path', or NULL if there is no match */ static char ** findRootDirPath(const char *path) { int j; for (j = 0; j < numRootDirs; j++) if (rootDirPaths[j] != NULL && strcmp(path, rootDirPaths[j]) == 0) return &rootDirPaths[j]; return NULL; } /* Is 'path' one of the pathnames that was listed on the command line? */ static int isRootDirPath(const char *path) { return findRootDirPath(path) != NULL; } /* We've ceased to monitor a root directory pathname (probably because it was renamed), so zap this pathname from the root path list */ static void zapRootDirPath(const char *path) { char **p; printf("zapRootDirPath: %s\n", path); p = findRootDirPath(path); if (p == NULL) { fprintf(stderr, "zapRootDirPath(): path not found!\n"); exit(EXIT_FAILURE); } *p = NULL; ignoreRootDirs++; if (ignoreRootDirs == numRootDirs) { fprintf(stderr, "No more root paths left to monitor; bye!\n"); exit(EXIT_SUCCESS); } } /***********************************************************************/ /* Below is a function called by nftw() to traverse a directory tree. The function adds a watch for each directory in the tree. Each successful call to this function should return 0 to indicate to nftw() that the tree traversal should continue. */ /* The usual hack for nftw()... We can't pass arguments to the function invoked by nftw(), so we use these global variables to exchange information with the function. */ static int dirCnt; /* Count of directories added to watch list */ static int ifd; /* Inotify file descriptor */ static int traverseTree(const char *pathname, const struct stat *sb, int tflag, struct FTW *ftwbuf) { int wd, slot, flags; if (! S_ISDIR(sb->st_mode)) return 0; /* Ignore nondirectory files */ /* Create a watch for this directory */ flags = IN_CREATE | IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE_SELF; if (isRootDirPath(pathname)) flags |= IN_MOVE_SELF; wd = inotify_add_watch(ifd, pathname, flags | IN_ONLYDIR); if (wd == -1) { /* By the time we come to create a watch, the directory might already have been deleted or renamed, in which case we'll get an ENOENT error. In that case, we log the error, but carry on execution. Other errors are unexpected, and if we hit them, we give up. */ logMessage(VB_BASIC, "inotify_add_watch: %s: %s\n", pathname, strerror(errno)); if (errno == ENOENT) return 0; else exit(EXIT_FAILURE); } if (findWatch(wd) >= 0) { /* This watch descriptor is already in the cache; nothing more to do. */ logMessage(VB_BASIC, "WD %d already in cache (%s)\n", wd, pathname); return 0; } dirCnt++; /* Cache information about the watch */ slot = addWatchToCache(wd, pathname); /* Print the name of the current directory */ logMessage(VB_NOISY, " watchDir: wd = %d [cache slot: %d]; %s\n", wd, slot, pathname); return 0; } /* Add the directory in 'pathname' to the watch list of the inotify file descriptor 'inotifyFd'. The process is recursive: watch items are also created for all of the subdirectories of 'pathname'. Returns number of watches/cache entries added for this subtree. */ static int watchDir(int inotifyFd, const char *pathname) { dirCnt = 0; ifd = inotifyFd; /* Use FTW_PHYS to avoid following soft links to directories (which could lead us in circles) */ /* By the time we come to process 'pathname', it may already have been deleted, so we log errors from nftw(), but keep on going */ if (nftw(pathname, traverseTree, 20, FTW_PHYS) == -1) logMessage(VB_BASIC, "nftw: %s: %s (directory probably deleted before we " "could watch)\n", pathname, strerror(errno)); return dirCnt; } /* Add watches and cache entries for a subtree, logging a message noting the number entries added. */ static void watchSubtree(int inotifyFd, char *path) { int cnt; cnt = watchDir(inotifyFd, path); logMessage(VB_BASIC, " watchSubtree: %s: %d entries added\n", path, cnt); } /***********************************************************************/ /* The directory oldPathPrefix/oldName was renamed to newPathPrefix/newName. Fix up cache entries for oldPathPrefix/oldName and all of its subdirectories to reflect the change. */ static void rewriteCachedPaths(const char *oldPathPrefix, const char *oldName, const char *newPathPrefix, const char *newName) { char fullPath[PATH_MAX], newPrefix[PATH_MAX]; char newPath[PATH_MAX]; size_t len; int j; snprintf(fullPath, sizeof(fullPath), "%s/%s", oldPathPrefix, oldName); snprintf(newPrefix, sizeof(newPrefix), "%s/%s", newPathPrefix, newName); len = strlen(fullPath); logMessage(VB_BASIC, "Rename: %s ==> %s\n", fullPath, newPrefix); for (j = 0; j < cacheSize; j++) { if (strncmp(fullPath, wlCache[j].path, len) == 0 && (wlCache[j].path[len] == '/' || wlCache[j].path[len] == '\0')) { snprintf(newPath, sizeof(newPath), "%s%s", newPrefix, &wlCache[j].path[len]); strncpy(wlCache[j].path, newPath, PATH_MAX); logMessage(VB_NOISY, " wd %d [cache slot %d] ==> %s\n", wlCache[j].wd, j, newPath); } } } /* Zap watches and cache entries for directory 'path' and all of its subdirectories. Returns number of entries that we (tried to) zap, or -1 if an inotify_rm_watch() call failed. */ static int zapSubtree(int inotifyFd, char *path) { size_t len; int j; int cnt; char *pn; logMessage(VB_NOISY, "Zapping subtree: %s\n", path); len = strlen(path); /* The argument we receive might be a pointer to a pathname string that is actually stored in the cache. If we zap that pathname part way through scanning the whole cache, then chaos results. So, create a temporary copy. */ pn = strdup(path); cnt = 0; for (j = 0; j < cacheSize; j++) { if (wlCache[j].wd >= 0) { if (strncmp(pn, wlCache[j].path, len) == 0 && (wlCache[j].path[len] == '/' || wlCache[j].path[len] == '\0')) { logMessage(VB_NOISY, " removing watch: wd = %d (%s)\n", wlCache[j].wd, wlCache[j].path); if (inotify_rm_watch(inotifyFd, wlCache[j].wd) == -1) { logMessage(0, "inotify_rm_watch wd = %d (%s): %s\n", wlCache[j].wd, wlCache[j].path, strerror(errno)); /* When we have multiple renamers, sometimes inotify_rm_watch() fails. In this case, we force a cache rebuild by returning -1. (TODO: Is there a better solution?) */ cnt = -1; break; } markCacheSlotEmpty(j); cnt++; } } } free(pn); return cnt; } /* When the cache is in an unrecoverable state, we discard the current inotify file descriptor ('oldInotifyFd') and create a new one (returned as the function result), and zap and rebuild the cache. If 'oldInotifyFd' is -1, this is the initial build of the cache, or an explicitly requested cache rebuild, so we are a little less verbose, and we reset 'reinitCnt'. */ static int reinitialize(int oldInotifyFd) { int inotifyFd; static int reinitCnt; int cnt, j; if (oldInotifyFd >= 0) { close(oldInotifyFd); reinitCnt++; logMessage(0, "Reinitializing cache and inotify FD (reinitCnt = %d)\n", reinitCnt); } else { logMessage(0, "Initializing cache\n"); reinitCnt = 0; } inotifyFd = inotify_init(); if (inotifyFd == -1) errExit("inotify_init"); logMessage(VB_BASIC, " new inotifyFd = %d\n", inotifyFd); freeCache(); for (j = 0; j < numRootDirs; j++) if (rootDirPaths[j] != NULL) watchSubtree(inotifyFd, rootDirPaths[j]); cnt = 0; for (j = 0; j < cacheSize; j++) if (wlCache[j].wd >= 0) cnt++; if (oldInotifyFd >= 0) logMessage(0, "Rebuilt cache with %d entries\n", cnt); return inotifyFd; } /* Process the next inotify event in the buffer specified by 'buf' and 'bufSize'. In most cases, a single event is consumed, but if there is an IN_MOVED_FROM+IN_MOVED_TO pair that share a cookie value, both events are consumed. Returns the number of bytes in the event(s) consumed from 'buf'. */ static size_t processNextInotifyEvent(int *inotifyFd, char *buf, int bufSize, int firstTry) { char fullPath[PATH_MAX + NAME_MAX]; struct inotify_event *ev; size_t evLen; int evCacheSlot; ev = (struct inotify_event *) buf; displayInotifyEvent(ev); if (ev->wd != -1 && !(ev->mask & IN_IGNORED)) { /* IN_Q_OVERFLOW has (ev->wd == -1) */ /* Skip IN_IGNORED, since it will come after an event that has already zapped the corresponding cache entry */ /* Cache consistency check; see the discussion of "intra-tree" rename() events */ evCacheSlot = findWatchChecked(ev->wd); if (evCacheSlot == -1) { /* Cache reached an inconsistent state */ *inotifyFd = reinitialize(*inotifyFd); /* Discard all remaining events in current read() buffer */ return INOTIFY_READ_BUF_LEN; } } evLen = sizeof(struct inotify_event) + ev->len; if ((ev->mask & IN_ISDIR) && (ev->mask & (IN_CREATE | IN_MOVED_TO))) { /* A new subdirectory was created, or a subdirectory was renamed into the tree; create watches for it, and all of its subdirectories. */ snprintf(fullPath, sizeof(fullPath), "%s/%s", wlCache[evCacheSlot].path, ev->name); logMessage(VB_BASIC, "Directory creation on wd %d: %s\n", ev->wd, fullPath); /* We only watch the new subtree if it has not already been cached. This deals with a race condition: * On the one hand, the following steps might occur: 1. The "child" directory is created. 2. The "grandchild" directory is created 3. We receive an IN_CREATE event for the creation of the "child" and create a watch and a cache entry for it. 4. To handle the possibility that step 2 came before step 3, we recursively walk through the descendants of the "child" directory, adding any subdirectories to the cache. * On the other hand, the following steps might occur: 1. The "child" directory is created. 3. We receive an IN_CREATE event for the creation of the "child" and create a watch and a cache entry for it. 3. The "grandchild" directory is created 4. During the recursive walk through the descendants of the "child" directory, we cache the "grandchild" and add a watch for it. 5. We receive the IN_CREATE event for the creation of the "grandchild". At this point, we should NOT create a cache entry and watch for the "grandchild" because they already exist. (Creating the watch for the second time is harmless, but adding a second cache for the grandchild would leave the cache in a confused state.) */ if (!pathnameInCache(fullPath)) watchSubtree(*inotifyFd, fullPath); } else if (ev->mask & IN_DELETE_SELF) { /* A directory was deleted. Remove the corresponding item from the cache. */ logMessage(VB_BASIC, "Clearing watchlist item %d (%s)\n", ev->wd, wlCache[evCacheSlot].path); if (isRootDirPath(wlCache[evCacheSlot].path)) zapRootDirPath(wlCache[evCacheSlot].path); markCacheSlotEmpty(evCacheSlot); /* No need to remove the watch; that happens automatically */ } else if ((ev->mask & (IN_MOVED_FROM | IN_ISDIR)) == (IN_MOVED_FROM | IN_ISDIR)) { /* We have a "moved from" event. To know how to deal with it, we need to determine whether there is a following "moved to" event with a matching cookie value (i.e., an "intra-tree" rename() where the source and destination are inside our monitored trees). If there is not, then we are dealing with a rename() out of our monitored tree(s). We assume that if this is an "intra-tree" rename() event, then the "moved to" event is the next event in the buffer returned by the current read(). (If we are already at the last event in this buffer, then we ask our caller to read a bit more, in the hope of getting the following IN_MOVED_TO event in the next read().) In most cases, the assumption holds. However, where multiple processes are manipulating the tree, we can can get event sequences such as the following: IN_MOVED_FROM (rename(x) by process A) IN_MOVED_FROM (rename(y) by process B) IN_MOVED_TO (rename(y) by process B) IN_MOVED_TO (rename(x) by process A) In principle, there may be arbitrarily complex variations on the above theme. Our assumption that related IN_MOVED_FROM and IN_MOVED_TO events are consecutive is broken by such scenarios. We could try to resolve this issue by extending the window we use to search for IN_MOVED_TO events beyond the next item in the queue. But this must be done heuristically (e.g., limiting the window to N events or to events read within X milliseconds), because sometimes we will have an unmatched IN_MOVED_FROM events that result from out-of-tree renames. The heuristic approach is therefore unavoidably racy: there is always a chance that we will fail to match up an IN_MOVED_FROM+IN_MOVED_TO event pair. So, this program takes the simple approach of assuming that an IN_MOVED_FROM+IN_MOVED_TO pair occupy consecutive events in the buffer returned by read(). When that assumption is wrong (and we therefore fail to recognize an intra-tree rename() event), then the rename will be treated as separate "moved from" and "moved to" events, with the result that some watch items and cache entries are zapped and re-created. This causes the watch descriptors in our cache to become inconsistent with the watch descriptors in as yet unread events, because the watches are re-created with different watch descriptor numbers. Once such an inconsistency occurs, then, at some later point, we will do a lookup for a watch descriptor returned by inotify, and find that it is not in our cache. When that happens, we reinitialize our cache with a fresh set of watch descriptors and re-create the inotify file descriptor, in order to bring our cache back into consistency with the filesystem. An alternative would be to cache the cookies of the (recent) IN_MOVED_FROM events for which which we did not find a matching IN_MOVED_TO event, and rebuild our watch cache when we find an IN_MOVED_TO event whose cookie matches one of the cached cookies. Yet another approach when we detect an out-of-tree rename would be to reinitialize the cache and create a new inotify file descriptor. (TODO: consider the fact that for a rename event, there won't be other events for the object between IN_MOVED_FROM and IN_MOVED_TO.) Rebuilding the watch cache is expensive if the monitored tree is large. So, there is a trade-off between how much effort we want to go to to avoid cache rebuilds versus how much effort we want to devote to matching up IN_MOVED_FROM+IN_MOVED_TO event pairs. At the one extreme we would do no search ahead for IN_MOVED_TO, with the result that every rename() potentially could trigger a cache rebuild. Limiting the search window to just the following event is a compromise that catches the vast majority of intra-tree renames and triggers relatively few cache rebuilds. */ struct inotify_event *nextEv; nextEv = (struct inotify_event *) (buf + evLen); if (((char *) nextEv < buf + bufSize) && (nextEv->mask & IN_MOVED_TO) && (nextEv->cookie == ev->cookie)) { int nextEvCacheSlot; /* We have a rename() event. We need to fix up the cached pathnames for the corresponding directory and all of its subdirectories. */ nextEvCacheSlot = findWatchChecked(nextEv->wd); if (nextEvCacheSlot == -1) { /* Cache reached an inconsistent state */ *inotifyFd = reinitialize(*inotifyFd); /* Discard all remaining events in current read() buffer */ return INOTIFY_READ_BUF_LEN; } rewriteCachedPaths(wlCache[evCacheSlot].path, ev->name, wlCache[nextEvCacheSlot].path, nextEv->name); /* We have also processed the next (IN_MOVED_TO) event, so skip over it */ evLen += sizeof(struct inotify_event) + nextEv->len; } else if (((char *) nextEv < buf + bufSize) || !firstTry) { /* We got a "moved from" event without an accompanying "moved to" event. The directory has been moved outside the tree we are monitoring. We need to remove the watches and zap the cache entries for the moved directory and all of its subdirectories. */ logMessage(VB_NOISY, "MOVED_OUT: %p %p\n", wlCache[evCacheSlot].path, ev->name); logMessage(VB_NOISY, "firstTry = %d; remaining bytes = %d\n", firstTry, buf + bufSize - (char *) nextEv); snprintf(fullPath, sizeof(fullPath), "%s/%s", wlCache[evCacheSlot].path, ev->name); if (zapSubtree(*inotifyFd, fullPath) == -1) { /* Cache reached an inconsistent state */ *inotifyFd = reinitialize(*inotifyFd); /* Discard all remaining events in current read() buffer */ return INOTIFY_READ_BUF_LEN; } } else { logMessage(VB_NOISY, "HANGING IN_MOVED_FROM\n"); return -1; /* Tell our caller to do another read() */ } } else if (ev->mask & IN_Q_OVERFLOW) { static int overflowCnt = 0; overflowCnt++; logMessage(0, "Queue overflow (%d) (inotifyReadCnt = %d)\n", overflowCnt, inotifyReadCnt); /* When the queue overflows, some events are lost, at which point we've lost any chance of keeping our cache consistent with the state of the filesystem. So, discard this inotify file descriptor and create a new one, and zap and rebuild the cache. */ *inotifyFd = reinitialize(*inotifyFd); /* Discard all remaining events in current read() buffer */ evLen = INOTIFY_READ_BUF_LEN; } else if (ev->mask & IN_UNMOUNT) { /* When a filesystem is unmounted, each of the watches on the is dropped, and an unmount and an ignore event are generated. There's nothing left for us to monitor, so we just zap the corresponding cache entry. */ logMessage(0, "Filesystem unmounted: %s\n", wlCache[evCacheSlot].path); markCacheSlotEmpty(evCacheSlot); /* No need to remove the watch; that happens automatically */ } else if (ev->mask & IN_MOVE_SELF && isRootDirPath(wlCache[evCacheSlot].path)) { /* If the root path moves to a new location in the same filesystem, then all cached pathnames become invalid, and we have no direct way of knowing the new name of the root path. We could in theory find the new name by caching the i-node of the root path on start-up and then trying to find a pathname that corresponds to that i-node. Instead, we'll keep things simple, and just cease monitoring it. */ logMessage(0, "Root path moved: %s\n", wlCache[evCacheSlot].path); zapRootDirPath(wlCache[evCacheSlot].path); if (zapSubtree(*inotifyFd, wlCache[evCacheSlot].path) == -1) { /* Cache reached an inconsistent state */ *inotifyFd = reinitialize(*inotifyFd); /* Discard all remaining events in current read() buffer */ return INOTIFY_READ_BUF_LEN; } } if (checkCache) checkCacheConsistency(); if (dumpCache) dumpCacheToLog(); return evLen; } static void alarmHandler(int sig) { return; /* Just interrupt read() */ } /* Read a block of events from the inotify file descriptor, 'inotifyFd'. Process the events relating to directories in the subtree we are monitoring, in order to keep our cached view of the subtree in sync with the filesystem. */ static void processInotifyEvents(int *inotifyFd) { char buf[INOTIFY_READ_BUF_LEN] __attribute__ ((aligned(__alignof__(struct inotify_event)))); ssize_t numRead, nr; char *evp; size_t cnt; int evLen; int firstTry; int j; struct sigaction sa; /* SIGALRM handler is designed simply to interrupt read() */ sigemptyset(&sa.sa_mask); sa.sa_handler = alarmHandler; sa.sa_flags = 0; if (sigaction(SIGALRM, &sa, NULL) == -1) errExit("sigaction"); firstTry = 1; /* Read some events from inotify file descriptor */ cnt = (readBufferSize > 0) ? readBufferSize : INOTIFY_READ_BUF_LEN; numRead = read(*inotifyFd, buf, cnt); if (numRead == -1) errExit("read"); if (numRead == 0) { fprintf(stderr, "read() from inotify fd returned 0!"); exit(EXIT_FAILURE); } inotifyReadCnt++; logMessage(VB_NOISY, "\n==========> Read %d: got %zd bytes\n", inotifyReadCnt, numRead); /* Process each event in the buffer returned by read() */ for (evp = buf; evp < buf + numRead; ) { evLen = processNextInotifyEvent(inotifyFd, evp, buf + numRead - evp, firstTry); if (evLen > 0) { evp += evLen; firstTry = 1; } else { /* We got here because an IN_MOVED_FROM event was found at the end of a previously read buffer and that event may be part of an "intra-tree" rename(), meaning that we should check if there is a subsequent IN_MOVED_TO event with the same cookie value. We left that event unprocessed and we will now try to read some more events, delaying for a short time, to give the associated IN_MOVED_IN event (if there is one) a chance to arrive. However, we only want to do this once: if the read() below fails to gather further events, then when we reprocess the IN_MOVED_FROM we should treat it as though this is an out-of-tree rename(). Thus, we set 'firstTry' to 0 for the next processNextInotifyEvent() call. */ int savedErrno; firstTry = 0; numRead = buf + numRead - evp; /* Shuffle remaining bytes to start of buffer */ for (j = 0; j < numRead; j++) buf[j] = evp[j]; /* Set a timeout for read(). Some rough testing suggests that a 2-millisecond timeout is sufficient to ensure that, in around 99.8% of cases, we get the IN_MOVED_TO event (if there is one) that matched an IN_MOVED_FROM event, even in a highly dynamic directory tree. This number may, of course, warrant tuning on different hardware and in environments with different filesystem activity levels. */ ualarm(2000, 0); nr = read(*inotifyFd, buf + numRead, INOTIFY_READ_BUF_LEN - numRead); savedErrno = errno; /* In case ualarm() should change errno */ ualarm(0, 0); /* Cancel alarm */ errno = savedErrno; if (nr == -1 && errno != EINTR) errExit("read"); if (nr == 0) { fprintf(stderr, "read() from inotify fd returned 0!"); exit(EXIT_FAILURE); } if (errno != -1) { numRead += nr; inotifyReadCnt++; logMessage(VB_NOISY, "\n==========> SECONDARY Read %d: got %zd bytes\n", inotifyReadCnt, nr); } else { /* EINTR */ logMessage(VB_NOISY, "\n==========> SECONDARY Read got nothing\n"); } evp = buf; /* Start again at beginning of buffer */ } } } /***********************************************************************/ /* We allow some simple interactive commands, mainly to check the operation of the program */ static void executeCommand(int *inotifyFd) { const int MAX_LINE = 100; ssize_t numRead; char line[MAX_LINE], arg[MAX_LINE]; char cmd; int j, cnt, ns, failures; struct stat sb; FILE *fp; numRead = read(STDIN_FILENO, line, MAX_LINE); if (numRead <= 0) { printf("bye!\n"); exit(EXIT_FAILURE); } line[numRead - 1] = '\0'; if (strlen(line) == 0) return; ns = sscanf(line, "%c %s\n", &cmd, arg); switch (cmd) { case 'a': /* Add/refresh a subtree */ cnt = zapSubtree(*inotifyFd, arg); if (cnt == 0) { logMessage(VB_BASIC, "Adding new subtree: %s\n", arg); } else { logMessage(VB_BASIC, "Zapped: %s, %d entries\n", arg, cnt); } watchSubtree(*inotifyFd, arg); break; case 'c': /* Check that all cached pathnames exist */ case 'C': cnt = 0; failures = 0; for (j = 0; j < cacheSize; j++) { if (wlCache[j].wd >= 0) { if (lstat(wlCache[j].path, &sb) == -1) { if (cmd == 'c') logMessage(VB_BASIC, "stat: [slot = %d; wd = %d] %s: %s\n", j, wlCache[j].wd, wlCache[j].path, strerror(errno)); failures++; } else if (!S_ISDIR(sb.st_mode)) { if (cmd == 'c') logMessage(0, "%s is not a directory\n", wlCache[j].path); exit(EXIT_FAILURE); } else { if (cmd == 'c') logMessage(VB_NOISY, "OK: [slot = %d; wd = %d] %s\n", j, wlCache[j].wd, wlCache[j].path); cnt++; } } } logMessage(0, "Successfully verified %d entries\n", cnt); logMessage(0, "Failures: %d\n", failures); break; case 'l': /* List entries in the cache */ cnt = 0; for (j = 0; j < cacheSize; j++) { if (wlCache[j].wd >= 0) { logMessage(0, "%d: %d %s\n", j, wlCache[j].wd, wlCache[j].path); cnt++; } } logMessage(VB_BASIC, "Total entries: %d\n", cnt); break; case 'q': /* Quit */ exit(EXIT_SUCCESS); case 'v': /* Set log verbosity level */ if (ns == 2) verboseMask = atoi(arg); else { verboseMask = !verboseMask; printf("%s\n", verboseMask ? "on" : "off"); } break; case 'd': /* Toggle cache dumping */ dumpCache = !dumpCache; printf("%s\n", dumpCache ? "on" : "off"); break; case 'x': /* Set toggle checking */ checkCache = !checkCache; printf("%s\n", checkCache ? "on" : "off"); break; case 'w': /* Write directory list to file */ /* We can compare the output from the below against the output from "find DIR -type d" to check whether the contents of the cache are consistent with the state of the filesystem */ fp = fopen(arg, "w+"); if (fp == NULL) perror("fopen"); for (j = 0; j < cacheSize; j++) if (wlCache[j].wd >= 0) fprintf(fp, "%s\n", wlCache[j].path); fclose(fp); break; case 'z': /* Stop watching a subtree, and zap its cache entries */ cnt = zapSubtree(*inotifyFd, arg); logMessage(VB_BASIC, "Zapped: %s, %d entries\n", arg, cnt); break; case '0': /* Rebuild cache */ close(*inotifyFd); *inotifyFd = reinitialize(-1); break; default: printf("Unrecognized command: %c\n", cmd); printf("Commands:\n"); printf("0 Rebuild cache\n"); printf("a path Add/refresh pathname watches and cache\n"); printf("c Verify cached pathnames\n"); printf("d Toggle cache dumping\n"); printf("l List cached pathnames\n"); printf("q Quit\n"); printf("v [n] Toggle/set verbose level for messages to stderr\n"); printf(" 0 = no messages\n"); printf(" 1 = basic messages\n"); printf(" 2 = verbose messages\n"); printf(" 3 = basic and verbose messages\n"); printf("w file Write directory list to file\n"); printf("x Toggle cache checking\n"); printf("z path Zap pathname and watches from cache\n"); break; } } /***********************************************************************/ static void usageError(const char *pname) { fprintf(stderr, "Usage: %s [options] directory-path\n\n", pname); fprintf(stderr, " -v lvl Display logging information\n"); fprintf(stderr, " -l file Send logging information to a file\n"); fprintf(stderr, " -x Check cache consistency after each " "operation\n"); fprintf(stderr, " -d Dump cache to log after every operation\n"); fprintf(stderr, " -b size Set buffer size for read() from " "inotify FD\n"); fprintf(stderr, " -a file Abort when cache inconsistency detected, " "and create 'stop' file\n"); exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { fd_set rfds; int opt; int inotifyFd; /* Parse command-line options */ verboseMask = 0; checkCache = 0; dumpCache = 0; stopFile = NULL; abortOnCacheProblem = 0; while ((opt = getopt(argc, argv, "a:dxl:v:b:")) != -1) { switch (opt) { case 'a': abortOnCacheProblem = 1; stopFile = optarg; break; case 'x': checkCache = 1; break; case 'd': dumpCache = 1; break; case 'v': verboseMask = atoi(optarg); break; case 'b': readBufferSize = atoi(optarg); break; case 'l': logfp = fopen(optarg, "w+"); if (logfp == NULL) errExit("fopen"); setbuf(logfp, NULL); break; default: usageError(argv[0]); } } if (optind >= argc) usageError(argv[0]); /* Save a copy of the directories on the command line */ copyRootDirPaths(&argv[optind]); /* Create an inotify instance and populate it with entries for directory named on command line */ inotifyFd = reinitialize(-1); /* Loop to handle inotify events and keyboard commands */ printf("%s> ", argv[0]); fflush(stdout); for (;;) { FD_ZERO(&rfds); FD_SET(STDIN_FILENO, &rfds); FD_SET(inotifyFd, &rfds); if (select(inotifyFd + 1, &rfds, NULL, NULL, NULL) == -1) errExit("select"); if (FD_ISSET(STDIN_FILENO, &rfds)) { executeCommand(&inotifyFd); printf("%s> ", argv[0]); fflush(stdout); } if (FD_ISSET(inotifyFd, &rfds)) processInotifyEvents(&inotifyFd); } exit(EXIT_SUCCESS); }
the_stack_data/231392676.c
#include <stdio.h> void main() { int n,m=1,last,t=0; printf("Enter End : "); scanf("%d",&n); for(int i=0; i<n; i++) { printf("%d ",m); last=t; m+=last; t=m; } }
the_stack_data/162644320.c
/* ******************************************************************************* * Copyright (c) 2020-2021, STMicroelectronics * All rights reserved. * * 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(ARDUINO_GENERIC_WB10CCUX) #include "pins_arduino.h" /** * @brief System Clock Configuration * @param None * @retval None */ WEAK void SystemClock_Config(void) { /* SystemClock_Config can be generated by STM32CubeMX */ #warning "SystemClock_Config() is empty. Default clock at reset is used." } #endif /* ARDUINO_GENERIC_* */
the_stack_data/105466.c
/* XPM */ static const char *const xpm_icon_0[] = { /* columns rows colors chars-per-pixel */ "16 16 81 1", " c #585755", ". c #6E6D6A", "X c #72706E", "o c #898784", "O c #8C8B88", "+ c #8F8E8A", "@ c #918F8C", "# c #94928F", "$ c #969591", "% c #999894", "& c #9C9A96", "* c #A4A39F", "= c #A9A8A4", "- c #ADABA7", "; c #AEACA8", ": c #AFAEA9", "> c #B0AFAA", ", c #B3B1AD", "< c #B7B5B1", "1 c #B8B6B2", "2 c #B8B7B2", "3 c #BAB8B4", "4 c #BBB9B5", "5 c #BEBCB8", "6 c #BFBEB9", "7 c #C0BEBA", "8 c #C1BFBB", "9 c #C5C3BF", "0 c #C8C6C1", "q c #C8C7C2", "w c #C9C7C2", "e c #C9C7C3", "r c #C9C8C3", "t c #CAC8C3", "y c #CBC9C4", "u c #CBCAC5", "i c #CCCAC5", "p c #CCCAC6", "a c #CDCBC6", "s c #CECCC7", "d c #CECCC8", "f c #CECDC8", "g c #CFCDC8", "h c #CFCDC9", "j c #CFCEC9", "k c #D0CEC9", "l c #D0CFCA", "z c #D1CFCA", "x c #D1D0CB", "c c #D2D0CB", "v c #D2D1CC", "b c #D3D1CC", "n c #D3D2CD", "m c #D4D2CD", "M c #D5D3CE", "N c #D6D3CE", "B c #D6D4CF", "V c #D7D5CF", "C c #D7D5D0", "Z c #D7D6D0", "A c #D7D6D1", "S c #D8D6D0", "D c #D8D6D1", "F c #D9D7D1", "G c #D9D7D2", "H c #DAD8D2", "J c #DAD8D3", "K c #DBD9D3", "L c #DBD9D4", "P c #DCD9D4", "I c #DCDAD4", "U c #DCDAD5", "Y c #DDDBD5", "T c #DDDBD6", "R c #DDDCD6", "E c #DEDCD6", "W c #DEDCD7", "Q c #DFDDD8", "! c #E0DED8", "~ c #E0DED9", "^ c #E4E2DC", /* pixels */ "mmmmmBmmDJLJJLJm", "jiCmBmmC^UUUUEBx", "jyBmmBmC~kJmLmwk", "siBmBmmCQC:i=mis", "ktBbbbxBUU$@ wdd", "skELULLQ~m:13kij", "kJEJLJLCJmLDLDtk", "kBbCCLCsBkjjjzik", "kCL:<O0bJJDDVKkk", "kmQ&%X,CBbDDJBtk", "kBC6<6mkVD;*@Lyg", "kCCJLLCkBU#o.iss", "xiy0w0wwDD468Bik", "jwmxbbkm~bDDDmws", "jb~EQUU~Wkbkkbjk", "mCJJLDLLJDDDLDLm" }; /* XPM */ static const char *const xpm_icon_1[] = { /* columns rows colors chars-per-pixel */ "32 32 163 2", " c #30302F", ". c #313130", "X c #383837", "o c #393938", "O c #3C3C3A", "+ c #3D3D3B", "@ c #40403E", "# c #494847", "$ c #4B4A49", "% c #51504E", "& c #545452", "* c #555452", "= c #565553", "- c #585755", "; c #5A5957", ": c #5D5C5A", "> c #61605E", ", c #666663", "< c #676664", "1 c #6C6B68", "2 c #6D6C6A", "3 c #6E6D6A", "4 c #747270", "5 c #757471", "6 c #767572", "7 c #7B7A77", "8 c #82817E", "9 c #858481", "0 c #888683", "q c #888784", "w c #8C8A87", "e c #8E8D89", "r c #91908C", "t c #94928F", "y c #969591", "u c #9E9D99", "i c #9F9D99", "p c #A2A19D", "a c #A3A19D", "s c #A4A29E", "d c #A6A5A1", "f c #A7A6A2", "g c #A8A6A2", "h c #A9A7A3", "j c #A9A8A4", "k c #ABAAA6", "l c #AEACA8", "z c #B0AEAA", "x c #B1AFAB", "c c #B2B0AC", "v c #B3B1AD", "b c #B4B3AF", "n c #B5B3AF", "m c #B6B4B0", "M c #B6B5B1", "N c #B9B7B3", "B c #BAB8B4", "V c #BBB9B5", "C c #BBBAB5", "Z c #BCBBB7", "A c #BDBBB7", "S c #BDBCB8", "D c #BEBCB8", "F c #BEBDB8", "G c #BFBDB9", "H c #BFBEB9", "J c #C0BEBA", "K c #C0BFBA", "L c #C1C0BB", "P c #C2C0BB", "I c #C2C0BC", "U c #C3C1BD", "Y c #C4C2BE", "T c #C5C3BE", "R c #C5C3BF", "E c #C6C4BF", "W c #C6C4C0", "Q c #C7C5C0", "! c #C7C5C1", "~ c #C7C6C1", "^ c #C8C6C1", "/ c #C8C6C2", "( c #C9C8C3", ") c #CAC8C3", "_ c #CAC8C4", "` c #CAC9C4", "' c #CBC9C4", "] c #CBCAC5", "[ c #CCCAC5", "{ c #CCCAC6", "} c #CDCBC6", "| c #CECCC7", " . c #CECCC8", ".. c #CECDC8", "X. c #CFCDC8", "o. c #CFCDC9", "O. c #CFCEC9", "+. c #D0CEC9", "@. c #D0CFCA", "#. c #D1CFCA", "$. c #D1CFCB", "%. c #D1D0CB", "&. c #D2D0CB", "*. c #D2D0CC", "=. c #D2D1CC", "-. c #D3D1CC", ";. c #D4D2CD", ":. c #D4D3CE", ">. c #D5D3CE", ",. c #D6D3CE", "<. c #D6D4CE", "1. c #D6D4CF", "2. c #D7D4CF", "3. c #D7D5CF", "4. c #D7D5D0", "5. c #D7D6D0", "6. c #D7D6D1", "7. c #D8D5D0", "8. c #D8D6D0", "9. c #D8D6D1", "0. c #D9D7D2", "q. c #DAD8D2", "w. c #DAD8D3", "e. c #DBD8D3", "r. c #DBD9D3", "t. c #DBD9D4", "y. c #DCD9D4", "u. c #DCDAD5", "i. c #DDDAD5", "p. c #DCDBD5", "a. c #DDDBD5", "s. c #DCDBD6", "d. c #DDDBD6", "f. c #DEDCD7", "g. c #DFDDD7", "h. c #DFDDD8", "j. c #E0DED8", "k. c #E0DED9", "l. c #E1DFD9", "z. c #E1DFDA", "x. c #E2E0DB", "c. c #E3E1DB", "v. c #E3E1DC", "b. c #E4E2DC", "n. c #E4E2DD", "m. c #E5E3DE", "M. c #E6E4DE", "N. c #E6E4DF", "B. c #E8E6E0", "V. c #E8E6E1", "C. c #E8E7E1", "Z. c #E9E7E1", "A. c #E9E7E2", "S. c #EAE8E2", "D. c #EBE9E3", "F. c #EBE9E4", "G. c #ECEAE4", "H. c #ECEAE5", "J. c #EDEBE5", "K. c #EDEBE6", "L. c #EEECE6", "P. c #EFEDE7", "I. c #F1EFE9", /* pixels */ ";.;.;.;.1.1.;.1.1.;.1.;.1.;.;.1.;.-.-.-.-.-.-.%.;.%.;.%.;.-.;.1.", "1.;.;.;.;.;.1.;.;.1.;.1.;.1.;.;.7.t.t.7.e.e.e.e.e.e.e.e.e.e.1.-.", "1.X.J 4.;.1.;.1.1.;.1.;.1.;.1.;.L.K.S.S.V.D.S.S.S.S.S.V.F.t.#.;.", "1.X.F 4.;.;.1.;.;.1.;.1.;.1.;.;.F.-.$.-.-.%.%.%.%.%.%.-.1.V X.4.", ";.X.F 4.;.1.;.1.1.;.1.;.1.;.1.;.F.4.1.;.1.;.;.1.;.4.4.;.4.F #.4.", "4.X.J 4.;.;.1.;.;.1.;.1.;.1.;.;.F.4.;.;.;.1.;.;.-.;.-.;.4.F X.1.", "4.X.J 4.;.1.;.1.1.;.1.;.1.;.;.;.F.4.-.-.4.;.4.;.t.;.;.;.4.F X.1.", ";.X.F 4.;.;.1.;.;.1.;.1.;.1.1.;.F.4.-.d.d + U V.1 & f.-.4.F X.1.", "4.X.F 7.;.;.;.;.4.4.;.;.1.;.1.;.F.4.;.-.t., Q l : 1 t.%.7.J | 1.", "4.X.F 7.;.;.4.;.;.;.;.4.;.;.;.;.K.4.;.;.-.& c 1 $ . m t.;.J #.1.", ";.X.D ;.#.#.;.#.#.#.-.$.$.-.$.#.S.4.%.t.d = 7 X.m 8 { ;.2.F | ;.", "4. .Y N.z.N.c.c.c.N.z.N.v.z.N.v.L.1.1.-.7.N.h.4.w.z.4.-.7.F #.4.", "7.{ %.K.z.c.N.z.v.v.N.z.c.c.B.4.N.4.1.1.%.@.%.-.-.#.1.-.4.J X.4.", "1.{ #.f.#.%.%.%.$.#.%.#.#.#.;.K t.e.-.1.4.4.4.:.4.4.4.-.7.F #.;.", "7.{ #.z.#.1.;.;.;.1.;.;.;.1.7.Q p.:.| X. .X.X. .X.X.X.X.$.V X.;.", "4.{ #.z.#.;.1.d.7.;.f.d.;.;.7.Q 4.@.` { { ` { { { { { { { Q -.1.", "4.{ $.z.-.-.-.x { #.k m ;.-.4.Y h.C.c.v.c.N.c.c.c.N.c.c.N.;.#.;.", "4.{ $.z.X.4.{ + y K = X j d.4.W p.4.X.%.#.%.#.#.#.#.#.%.;.C X.1.", "4.{ $.z.-.%.B.i t I.j @ a h.4.U p.e.1.1.1.%.1.-.-.-.;.;.7.F #.;.", "1.{ O.c.X.4.#.; > v e ; i h.;.W f.e.-.-.1.f.-.e.j.d.;.;.7.F #.1.", "4.{ %.z.#.7.^ e r F e s w.$.7.W p.e.-.2.` z ;.P s z 7.;.4.J X.;.", "4.{ #.z.-.;.4.v.z.7.z.z.;.;.w.W p.e.%.t.j | < + y d.-.4.F #.4.", "1.{ #.z.#.;.;.#.#.-.#.-.-.-.4.W p.e.%.%.D.6 { e 6 4 X.;.2.F { 4.", "2.{ #.c.;.4.4.4.4.7.7.2.4.4.w.Q f.e.%.4.F X w d 9 $ ^ 7.;.J #.;.", "2.| %.e.E { ` ` { ( ( ( ( ( .D p.e.%.e.b 0 u B 9 V e.-.4.F #.;.", "1.| U ` F U U J U U K U W K K G M.1.1.%.e.c.x.e.N.e.-.;.4.F X.4.", "1.| F e.4.7.4.7.4.4.4.4.7.7.w.4.J.1.%.1.%.%.%.-.#.;.;.;.7.F X.4.", "1.| J 1.1.;.;.;.1.-.:.-.;.;.4.$.S.e.e.2.8.2.2.1.1.1.1.7.t.F #.;.", "1.| F -.%.%.%.%.-.X.-.-.%.%.-.-.C.{ Q Q ` E E ` ~ E ^ ^ ^ m X.4.", "1.| { L.S.S.S.S.S.S.S.S.S.S.S.F.L.4.4.5.8.2.8.8.5.e.1.2.7.4.1.:.", "1.-.7.t.e.e.e.e.t.t.5.e.e.e.e.5.e.p.p.p.e.f.f.f.f.f.d.d.d.f.1.-.", "-.1.;.-.-.%.;.%.-.-.-.-.-.-.-.-.-.%.-.-.%.%.%.%.%.%.%.%.%.%.-.1." }; /* XPM */ static const char *const xpm_icon_2[] = { /* columns rows colors chars-per-pixel */ "48 48 231 2", " c #060606", ". c #0E0E0E", "X c #151515", "o c #181717", "O c #181817", "+ c #191918", "@ c #20201F", "# c #232222", "$ c #242423", "% c #252524", "& c #272726", "* c #292928", "= c #2B2B2A", "- c #2D2C2B", "; c #2E2D2C", ": c #302F2E", "> c #353433", ", c #353533", "< c #363534", "1 c #373635", "2 c #373735", "3 c #383736", "4 c #3B3A39", "5 c #3D3C3B", "6 c #3E3D3C", "7 c #3E3E3C", "8 c #3F3E3D", "9 c #403F3E", "0 c #424240", "q c #434341", "w c #454442", "e c #464543", "r c #464544", "t c #474644", "y c #474645", "u c #4A4A48", "i c #52514F", "p c #535351", "a c #575654", "s c #585855", "d c #595856", "f c #5C5B59", "g c #5D5D5A", "h c #61605E", "j c #676664", "k c #696866", "l c #6B6A68", "z c #6C6B69", "x c #6E6D6A", "c c #71706D", "v c #71706E", "b c #73726F", "n c #747370", "m c #777673", "M c #7B7A77", "N c #7C7B78", "B c #848380", "V c #858481", "C c #868582", "Z c #878682", "A c #888784", "S c #8B8A86", "D c #8F8E8A", "F c #8F8E8B", "G c #91908C", "H c #91908D", "J c #969491", "K c #979692", "L c #9C9B97", "P c #9D9C98", "I c #9F9D99", "U c #A09F9B", "Y c #A2A09D", "T c #A2A19D", "R c #A3A19E", "E c #A8A7A3", "W c #A9A7A3", "Q c #ACAAA6", "! c #ACABA7", "~ c #ADACA8", "^ c #B0AFAA", "/ c #B0AFAB", "( c #B1AFAB", ") c #B1B0AB", "_ c #B2B1AD", "` c #B3B1AD", "' c #B3B2AE", "] c #B4B2AE", "[ c #B4B3AE", "{ c #B4B3AF", "} c #B5B3AF", "| c #B5B4B0", " . c #B6B4B0", ".. c #B6B5B0", "X. c #B7B6B1", "o. c #B7B6B2", "O. c #B8B6B2", "+. c #B8B7B2", "@. c #B8B7B3", "#. c #B9B7B3", "$. c #B9B8B3", "%. c #BAB8B4", "&. c #BAB9B4", "*. c #BAB9B5", "=. c #BBB9B5", "-. c #BBBAB5", ";. c #BCBAB6", ":. c #BCBBB6", ">. c #BDBBB7", ",. c #BDBCB8", "<. c #BEBCB8", "1. c #BFBDB9", "2. c #BFBEB9", "3. c #C0BEBA", "4. c #C0BFBA", "5. c #C1BFBB", "6. c #C1C0BB", "7. c #C2C0BC", "8. c #C3C1BC", "9. c #C3C1BD", "0. c #C3C2BD", "q. c #C4C2BE", "w. c #C4C3BE", "e. c #C5C3BE", "r. c #C5C3BF", "t. c #C6C4BF", "y. c #C6C4C0", "u. c #C6C5C0", "i. c #C7C5C0", "p. c #C7C5C1", "a. c #C8C6C2", "s. c #C8C7C2", "d. c #CAC8C3", "f. c #CBC9C4", "g. c #CCCAC5", "h. c #CCCBC6", "j. c #CDCBC6", "k. c #CECCC7", "l. c #CECCC8", "z. c #CFCDC8", "x. c #CFCDC9", "c. c #CFCEC9", "v. c #D0CEC9", "b. c #D0CECA", "n. c #D1CFCA", "m. c #D1CFCB", "M. c #D1D0CB", "N. c #D2D0CB", "B. c #D1D1CD", "V. c #D2D0CC", "C. c #D2D1CC", "Z. c #D3D1CC", "A. c #D3D2CD", "S. c #D4D2CD", "D. c #D5D3CE", "F. c #D5D4CF", "G. c #D6D4CF", "H. c #D7D4CF", "J. c #D7D5D0", "K. c #D8D5D0", "L. c #D8D6D0", "P. c #D8D6D1", "I. c #D9D6D1", "U. c #D9D7D1", "Y. c #D8D7D2", "T. c #D9D7D2", "R. c #DAD7D2", "E. c #DAD8D2", "W. c #DAD8D3", "Q. c #DBD8D3", "!. c #DBD9D3", "~. c #DAD9D4", "^. c #DBD9D4", "/. c #DBDAD5", "(. c #DCDAD5", "). c #DDDAD5", "_. c #DDDBD5", "`. c #DCDBD6", "'. c #DDDBD6", "]. c #DDDCD7", "[. c #DEDCD7", "{. c #DFDDD8", "}. c #E0DED9", "|. c #E1DFD9", " X c #E1DFDA", ".X c #E1E0DA", "XX c #E2E0DA", "oX c #E2E0DB", "OX c #E3E1DB", "+X c #E3E1DC", "@X c #E4E2DC", "#X c #E4E2DD", "$X c #E5E3DD", "%X c #E5E3DE", "&X c #E6E4DF", "*X c #E7E5DF", "=X c #E7E5E0", "-X c #E7E6E0", ";X c #E8E6E0", ":X c #E9E6E1", ">X c #E8E7E1", ",X c #E8E7E2", "<X c #E9E7E2", "1X c #EAE8E2", "2X c #EAE8E3", "3X c #EBE9E3", "4X c #EBE9E4", "5X c #ECEAE4", "6X c #ECEAE5", "7X c #ECEBE5", "8X c #EDEBE5", "9X c #EDEBE6", "0X c #EDECE6", "qX c #EEECE6", "wX c #EEECE7", "eX c #F0EEE8", "rX c #F0EEE9", "tX c #F1EFE9", "yX c #F2F0EA", "uX c #F3F1EB", "iX c #F3F2EC", "pX c #F4F2EC", "aX c #F4F2ED", "sX c #F5F3ED", "dX c #F5F4EF", "fX c #F7F4EF", "gX c #F7F5EF", "hX c #F8F5EF", "jX c #F9F6F1", "kX c #F9F7F2", "lX c #FCFAF4", /* pixels */ "D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.", "D.D.D.D.Z.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.Z.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.Z.D.D.D.", "D.D.D.G.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.H.m.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.Z.D.D.D.D.", "D.Z.D.c.j.G.Z.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.}.$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X+X$X+XZ.D.D.D.", "D.D.P.9.&.P.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.m.fXeX5X8X8X8X8X8X8X8X8X8X8X8X8X8X8X4X6XD.m.D.Z.D.", "D.D.P.9.:.P.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.H.uXH.z.n.n.n.n.n.n.n.n.n.n.n.n.n.c.Z.c.~ D.D.D.D.", "D.D.P.9.:.P.Z.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.m.uXP.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.J.m.X.N.D.D.D.", "D.D.P.9.:.P.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.m.fX^.m.D.D.D.D.D.D.D.D.D.D.D.D.D.Z.J.Z._ Z.D.Z.D.", "D.N.P.9.;.I.m.D.D.D.D.D.D.D.D.D.G.Z.Z.G.Z.G.G.Z.uXP.Z.G.Z.D.Z.D.Z.D.Z.D.Z.D.J.Z.Z.J.Z.[ Z.D.Z.D.", "D.D.P.9.:.P.H.H.D.D.D.D.D.D.D.D.G.G.G.G.G.G.Z.Z.fX^.N.D.D.D.N.G.J.Z.J.Z.D.J.Z.D.Z.A.Z.[ Z.D.D.D.", "D.D.P.9.:.K.D.D.D.D.D.D.D.D.D.D.Z.G.G.Z.G.Z.G.N.uXQ.N.D.D.D.^.Z.Z.D.Z.J.J.n.D.Z.Z.J.Z.[ Z.D.D.D.", "D.D.P.9.:.H.D.D.D.D.D.D.D.D.D.D.Z.G.G.Z.G.G.G.Z.uXQ.Z.G.n.].V X V +XZ.c.% w {.Z.Z.G.Z._ Z.D.Z.D.", "D.D.P.9.<.P.m.H.D.D.D.D.D.D.D.D.G.G.G.Z.Z.G.G.Z.fXQ.N.D.D.D.<.d x &X.Xg 8 t Q.Z.Z.J.Z._ Z.D.Z.D.", "D.D.P.9.:.P.D.D.D.D.D.D.D.D.D.D.G.Z.G.G.G.G.Z.Z.uXP.D.D.D.c.eXb l uXK t 8.0 -XN.J.Z.Z.[ Z.D.D.D.", "D.D.G.9.:.P.D.D.D.D.D.D.D.D.D.D.Z.G.Z.G.G.Z.G.Z.uXQ.N.D.D.n.:Xx l lXd @ w A {.M.J.Z.[ Z.D.Z.D.", "D.D.P.9.:.R.D.D.D.D.D.D.D.D.D.D.G.G.Z.G.G.Z.G.Z.uXQ.D.D.n.}.c O O n f.T V ; &.J.Z.A.Z.[ Z.D.D.D.", "J.A.J.w.&.G.c.N.n.n.n.n.n.n.n.n.N.N.N.c.N.N.N.k.uXQ.N.G.A.G.t.8.5.9.^.}.^.n.^.D.D.D.m.[ Z.D.Z.D.", "G.Z.Y.8.8.3X&X&X*X*X*X&X*X*X*X&X&X&X&X&X&X&X&X&XgXQ.N.G.G.N.G.Q.^.P.D.m.D.J.Z.D.D.D.Z.[ Z.D.D.D.", "Z.Z.Q.2.Z.kX*X8X5X3X3X3X5X3X3X3X3X3X5X3X3X3X0XY.7XQ.N.G.N.G.A.G.Z.Z.D.D.Z.D.D.Z.Z.D.Z._ Z.D.Z.D.", "G.G.Q.<.Z.&Xd.n.n.n.n.n.n.n.n.n.N.z.N.N.N.c.Z._ &X].N.G.G.G.A.G.D.D.D.J.D.D.D.D.Z.G.Z.{ Z.D.D.D.", "Z.Z./.<.A.3XN.G.D.D.D.D.D.D.D.D.G.Z.G.G.N.G.Q.+.*X/.N.Z.N.N.A.A.Z.D.Z.Z.D.Z.D.m.D.Z.n._ Z.D.D.D.", "G.Z.Q.4.N.:Xc.G.D.D.D.D.D.D.D.D.G.G.G.N.G.N.J.+.3X.XJ.Q.Q.Q.Q.Q.P.^.^.P.P.^.P.^.P./.J.X.Z.D.Z.D.", "J.D.P.<.D.3Xz.D.Z.D.Z.Z.D.D.D.D.N.N.G.G.G.N.Q.+.+Xt.+.&.-.-.&.&.&.:.&.&.&.:.&.:.&.:.&.~ D.D.Z.D.", "Z.Z.P.8.N.3Xn.D.D.D.D.G.G.D.N.D.Q.G.N.G.N.G.G.+..X.X`.`.`.`.`.`./.].].].].^./.].].^.{.P.Z.D.D.D.", "J.Z./.<.Z.3Xc.D.D.D.P.n.j.D.P.n.<.n./.Z.J.Z.J.X.,X4XOX$X$X+X$X+X$X$X$X+X$X+X$X+X$X$X&X9.n.D.D.D.", "J.Z.P.5.Z.4Xc.D.D.^.Q $ t &X) 8 u 1 P ].Z.D.J.@.&XQ.k.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n.n./ m.D.D.D.", "Z.Z./.5.Z.3Xn.D.D.G.a.D 8 .Xd.H M ; A [email protected]].D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.Z.[ D.D.m.D.", "J.Z.J.<.Z.:Xc.D.D.Z..X[ 8 ^..X_ a % K {.Z.Z.J.X.-X^.N.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.Z.[ m.D.D.D.", "G.Z.Y.8.Z.3Xc.G.D.N.^.E 4 }.<.#.fXf j :XN.Z.J.@.:X^.Z.D.D.D.D.m.Z.D.Z.n.n.D.D.Z.Z.D.n.[ n.D.D.D.", "A.Z.Q.2.A.4Xc.D.n.}.Y # + u ) 3 = 0 4.J.Z.D.P.X.:X^.Z.D.D.Z.J.}.P.D.P.$XOX].D.D.D.D.Z.[ D.D.D.D.", "G.Z.Q.<.Z.3Xc.D.N.D.n.a.j.a.P.N.i.P.P.D.G.Z.J.X.:X/.Z.D.D.D.f.I 4.^[email protected] S T J.D.Z.D.Z._ m.D.D.D.", "J.Z.Q.<.Z.:Xn.D.D.D.D.P.G.P.D.D.P.Z.D.D.Z.D.J.X.3X^.Z.D.n.{.M . m hXd > h m /.Z.D.D.Z.[ D.D.m.D.", "G.G.Q.<.Z.4Xc.J.Z.J.D.D.Z.D.Z.D.D.D.D.D.D.m.P.#.*X^.D.D.Z.N.{.c k jXd , l / /.Z.D.D.Z.[ Z.G.Z.G.", "Z.Z./.<.Z.4Xc.Z.J.Z.D.D.D.D.D.D.D.D.D.D.D.D.H.#.*X^.Z.D.D.c.uXc b hXL S D = #.Q.N.D.N.{ Z.G.Z.Z.", "J.Z.Q.<.Z.,Xc.Z.Z.D.Z.D.D.D.Z.D.D.m.D.D.D.m.P.#.:X^.Z.D.D.G.i.p i k.T I ( - [ ^.Z.D.N.{ N.G.G.G.", "G.Z./.<.Z.4XJ.J.J.P.P.P.P.P.P.P.P.P.P.P.P.P.^.%.:X^.Z.D.N.{.n 3 1 N E 8 4 H ^.n.D.D.Z._ Z.G.Z.Z.", "Z.Z./.<.Z./.@.,.:.3.:.3.:.<.:.<.,.,.,.<.<.<.<.~ 3XQ.Z.G.A.Z.]..X.X^./.OX$X^.D.D.A.A.Z.[ Z.G.Z.G.", "G.G.J.8.8.h.6.8.5.9.5.5.5.9.9.5.8.y.5.5.8.8.8.8.uXQ.N.G.Z.G.Z.c.n.D.D.m.n.D.D.Z.G.A.Z.[ Z.G.Z.Z.", "Z.Z.Q.y.&./.J.Q.P.P.P.P.P.K.P.P.J.J.Y.J.J.J.J.J.uXQ.N.G.G.G.Z.G.D.D.D.D.D.D.D.D.Z.G.Z.[ N.G.G.G.", "G.Z.J.8.:.J.Z.Z.D.D.D.m.D.D.D.D.Z.J.Z.Z.Z.J.D.Z.uXQ.Z.A.Z.G.Z.G.D.Z.D.Z.D.D.Z.D.Z.G.Z.[ Z.G.Z.Z.", "D.D.P.9.:.P.D.D.D.D.D.D.D.D.D.D.J.D.D.J.D.D.D.Z.tX^.m.Z.D.Z.D.Z.D.m.D.D.D.Z.D.Z.Z.G.m.[ Z.D.D.D.", "D.D.P.9.:.P.m.Z.D.m.D.m.D.D.D.m.Z.Z.Z.Z.Z.Z.Z.Z.fX^.J.J.J.D.J.J.J.J.J.J.D.J.D.J.G.G.D.[ Z.D.Z.D.", "D.D.P.8.&.^.D.J.K.K.J.J.D.J.J.D.J.D.D.J.J.J.J.J.4X<[email protected].#.X. .X.@[email protected].#.X.X.X.X._ D.D.D.D.", "D.Z.P.i.D.jXaXaXfXtXtXfXaXfXtXfXaXaXaXaXaXaXaXaXfX6X6X6X6X8X8X8X6X6X6X6X6X6X8X8X0X0X6X8XD.Z.D.D.", "D.D.D.D.J.J.J.J.D.J.D.J.J.J.D.J.J.J.J.J.J.J.J.J.J.J.J.P.J.P.H.D.P.J.K.K.D.P.H.H.P.J.P.J.Z.D.D.D.", "D.D.D.Z.Z.D.Z.Z.Z.D.Z.D.m.D.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.D.D.Z.D.D.D.D.m.D.D.Z.D.D.D.Z.D.Z.D.D.D.D.", "D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.J.D.D.D.D.D.D.D.J.D.D.D.D.D.D.D.D.D.D.D.D.D.", "D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D." }; const char *const *const xpm_icons[] = { xpm_icon_0, xpm_icon_1, xpm_icon_2, }; const int n_xpm_icons = 3;
the_stack_data/122320.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #define BST_MAX_LEVEL 800 #define container_of(ptr, type, member) \ ((type *)((char *)(ptr) - (size_t)&(((type *)0)->member))) #define list_entry(ptr, type, member) \ container_of(ptr, type, member) #define list_first_entry(ptr, type, field) list_entry((ptr)->next, type, field) #define list_last_entry(ptr, type, field) list_entry((ptr)->prev, type, field) #define list_for_each(p, head) \ for (p = (head)->next; p != (head); p = p->next) #define list_for_each_reverse(p, head) \ for (p = (head)->prev; p != (head); p = p->prev) #define list_for_each_safe(p, n, head) \ for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next) #define list_for_each_safe_reverse(p, n, head) \ for (p = (head)->prev, n = p->prev; p != (head); p = n, n = p->prev) struct Object { int *nums; int len; }; struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; }; struct list_head { struct list_head *next, *prev; }; struct bfs_node { struct TreeNode *node; struct list_head link; }; struct TreeNode *make_tree(int *nums, int pos, int size) { if (nums[pos] == INT_MIN) { return NULL; } struct TreeNode *node = malloc(sizeof(*node)); node->val = nums[pos]; int left = 2 * pos + 1; int right = 2 * pos + 2; if (left >= size) { node->left = NULL; } else { node->left = make_tree(nums, left, size); } if (right >= size) { node->right = NULL; } else { node->right = make_tree(nums, right, size); } return node; } void free_tree(struct TreeNode *node) { if (node == NULL) { return; } if (node->left != NULL) { free_tree(node->left); } if (node->right != NULL) { free_tree(node->right); } free(node); } void print_tree(struct TreeNode *node) { printf("%d ", node->val); if (node->left != NULL) { print_tree(node->left); } else { printf("# "); } if (node->right != NULL) { print_tree(node->right); } else { printf("# "); } } void INIT_LIST_HEAD(struct list_head *list) { list->next = list->prev = list; } int list_empty(const struct list_head *head) { return head->next == head; } void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { next->prev = new; new->next = next; new->prev = prev; prev->next = new; } void list_add(struct list_head *_new, struct list_head *head) { __list_add(_new, head, head->next); } void list_add_tail(struct list_head *_new, struct list_head *head) { __list_add(_new, head->prev, head); } void __list_del(struct list_head *entry) { entry->next->prev = entry->prev; entry->prev->next = entry->next; } void list_del(struct list_head *entry) { __list_del(entry); entry->next = entry->prev = NULL; } struct bfs_node *node_new(struct list_head *free_list, struct TreeNode *node) { struct bfs_node *new; if (list_empty(free_list)) { new = malloc(sizeof(*new)); } else { new = list_first_entry(free_list, struct bfs_node, link); list_del(&new->link); } new->node = node; return new; } void queue(struct list_head *parents, struct list_head *children, int reverse, struct list_head *free_list, int **results, int *col_sizes, int level) { struct list_head *p, *n; struct bfs_node *new, *parent; list_for_each(p, parents) { parent = list_entry(p, struct bfs_node, link); if (parent->node->left != NULL) { new = node_new(free_list, parent->node->left); list_add_tail(&new->link, children); } if (parent->node->right != NULL) { new = node_new(free_list, parent->node->right); list_add_tail(&new->link, children); } col_sizes[level]++; } int i = 0; results[level] = malloc(col_sizes[level] * sizeof(int)); if (reverse) { list_for_each_safe_reverse(p, n, parents) { parent = list_entry(p, struct bfs_node, link); results[level][i++] = parent->node->val; list_del(p); list_add(p, free_list); } } else { list_for_each_safe(p, n, parents) { parent = list_entry(p, struct bfs_node, link); results[level][i++] = parent->node->val; list_del(p); list_add(p, free_list); } } } int ** zigzag_level_order(struct TreeNode *root, int **column_sizes, int *return_size) { if (root == NULL) { *return_size = 0; return NULL; } struct list_head free_list; struct list_head q0; struct list_head q1; INIT_LIST_HEAD(&free_list); INIT_LIST_HEAD(&q0); INIT_LIST_HEAD(&q1); int **results = malloc(BST_MAX_LEVEL * sizeof(int *)); *column_sizes = malloc(BST_MAX_LEVEL * sizeof(int)); memset(*column_sizes, 0, BST_MAX_LEVEL * sizeof(int)); int level = 0; struct bfs_node *new = node_new(&free_list, root); list_add_tail(&new->link, &q0); while (!list_empty(&q0) || !list_empty(&q1)) { if (level & 0x1) { queue(&q1, &q0, 1, &free_list, results, *column_sizes, level); } else { queue(&q0, &q1, 0, &free_list, results, *column_sizes, level); } level++; } *return_size = level; return results; } int main(int argc, char **argv) { int nums1[] = { 3, 9, 20, INT_MIN, INT_MIN, 15, 7 }, len1 = sizeof(nums1) / sizeof(int); struct Object inputs[] = { { .nums = nums1, .len = len1 }, }; int i, j, k, *col_sizes, len = sizeof(inputs) / sizeof(struct Object); for (i = 0; i < len; i++) { int *nums = inputs[i].nums; int size = inputs[i].len; struct TreeNode *root = make_tree(nums, 0, size); printf("\n Input: "); print_tree(root); printf("\n Output:\n"); int count; int **lists = zigzag_level_order(root, &col_sizes, &count); for (j = 0; j < count; j++) { for (k = 0; k < col_sizes[j]; k++) { printf("%d ", lists[j][k]); } printf("\n"); } free_tree(root); } return EXIT_SUCCESS; }
the_stack_data/836074.c
/* * Convert a logo in ASCII PNM format to C source suitable for inclusion in * the Linux kernel * * (C) Copyright 2001-2003 by Geert Uytterhoeven <[email protected]> * * -------------------------------------------------------------------------- * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of the Linux * distribution for more details. */ #include <ctype.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static const char *programname; static const char *filename; static const char *logoname = "linux_logo"; static const char *outputname; static FILE *out; #define LINUX_LOGO_MONO 1 /* monochrome black/white */ #define LINUX_LOGO_VGA16 2 /* 16 colors VGA text palette */ #define LINUX_LOGO_CLUT224 3 /* 224 colors */ #define LINUX_LOGO_GRAY256 4 /* 256 levels grayscale */ static const char *logo_types[LINUX_LOGO_GRAY256+1] = { [LINUX_LOGO_MONO] = "LINUX_LOGO_MONO", [LINUX_LOGO_VGA16] = "LINUX_LOGO_VGA16", [LINUX_LOGO_CLUT224] = "LINUX_LOGO_CLUT224", [LINUX_LOGO_GRAY256] = "LINUX_LOGO_GRAY256" }; #define MAX_LINUX_LOGO_COLORS 224 struct color { unsigned char red; unsigned char green; unsigned char blue; }; static const struct color clut_vga16[16] = { { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0xaa }, { 0x00, 0xaa, 0x00 }, { 0x00, 0xaa, 0xaa }, { 0xaa, 0x00, 0x00 }, { 0xaa, 0x00, 0xaa }, { 0xaa, 0x55, 0x00 }, { 0xaa, 0xaa, 0xaa }, { 0x55, 0x55, 0x55 }, { 0x55, 0x55, 0xff }, { 0x55, 0xff, 0x55 }, { 0x55, 0xff, 0xff }, { 0xff, 0x55, 0x55 }, { 0xff, 0x55, 0xff }, { 0xff, 0xff, 0x55 }, { 0xff, 0xff, 0xff }, }; static int logo_type = LINUX_LOGO_CLUT224; static unsigned int logo_width; static unsigned int logo_height; static struct color **logo_data; static struct color logo_clut[MAX_LINUX_LOGO_COLORS]; static unsigned int logo_clutsize; static void die(const char *fmt, ...) __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); static void usage(void) __attribute ((noreturn)); static unsigned int get_number(FILE *fp) { int c, val; /* Skip leading whitespace */ do { c = fgetc(fp); if (c == EOF) die("%s: end of file\n", filename); if (c == '#') { /* Ignore comments 'till end of line */ do { c = fgetc(fp); if (c == EOF) die("%s: end of file\n", filename); } while (c != '\n'); } } while (isspace(c)); /* Parse decimal number */ val = 0; while (isdigit(c)) { val = 10*val+c-'0'; c = fgetc(fp); if (c == EOF) die("%s: end of file\n", filename); } return val; } static unsigned int get_number255(FILE *fp, unsigned int maxval) { unsigned int val = get_number(fp); return (255*val+maxval/2)/maxval; } static void read_image(void) { FILE *fp; unsigned int i, j; int magic; unsigned int maxval; /* open image file */ fp = fopen(filename, "r"); if (!fp) die("Cannot open file %s: %s\n", filename, strerror(errno)); /* check file type and read file header */ magic = fgetc(fp); if (magic != 'P') die("%s is not a PNM file\n", filename); magic = fgetc(fp); switch (magic) { case '1': case '2': case '3': /* Plain PBM/PGM/PPM */ break; case '4': case '5': case '6': /* Binary PBM/PGM/PPM */ die("%s: Binary PNM is not supported\n" "Use pnmnoraw(1) to convert it to ASCII PNM\n", filename); default: die("%s is not a PNM file\n", filename); } logo_width = get_number(fp); logo_height = get_number(fp); /* allocate image data */ logo_data = (struct color **)malloc(logo_height*sizeof(struct color *)); if (!logo_data) die("%s\n", strerror(errno)); for (i = 0; i < logo_height; i++) { logo_data[i] = malloc(logo_width*sizeof(struct color)); if (!logo_data[i]) die("%s\n", strerror(errno)); } /* read image data */ switch (magic) { case '1': /* Plain PBM */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) logo_data[i][j].red = logo_data[i][j].green = logo_data[i][j].blue = 255*(1-get_number(fp)); break; case '2': /* Plain PGM */ maxval = get_number(fp); for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) logo_data[i][j].red = logo_data[i][j].green = logo_data[i][j].blue = get_number255(fp, maxval); break; case '3': /* Plain PPM */ maxval = get_number(fp); for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) { logo_data[i][j].red = get_number255(fp, maxval); logo_data[i][j].green = get_number255(fp, maxval); logo_data[i][j].blue = get_number255(fp, maxval); } break; } /* close file */ fclose(fp); } static inline int is_black(struct color c) { return c.red == 0 && c.green == 0 && c.blue == 0; } static inline int is_white(struct color c) { return c.red == 255 && c.green == 255 && c.blue == 255; } static inline int is_gray(struct color c) { return c.red == c.green && c.red == c.blue; } static inline int is_equal(struct color c1, struct color c2) { return c1.red == c2.red && c1.green == c2.green && c1.blue == c2.blue; } static void write_header(void) { /* open logo file */ if (outputname) { out = fopen(outputname, "w"); if (!out) die("Cannot create file %s: %s\n", outputname, strerror(errno)); } else { out = stdout; } fputs("/*\n", out); fputs(" * DO NOT EDIT THIS FILE!\n", out); fputs(" *\n", out); fprintf(out, " * It was automatically generated from %s\n", filename); fputs(" *\n", out); fprintf(out, " * Linux logo %s\n", logoname); fputs(" */\n\n", out); fputs("#include <linux/linux_logo.h>\n\n", out); fprintf(out, "static unsigned char %s_data[] __initdata = {\n", logoname); } static void write_footer(void) { fputs("\n};\n\n", out); fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname); fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]); fprintf(out, "\t.width\t\t= %d,\n", logo_width); fprintf(out, "\t.height\t\t= %d,\n", logo_height); if (logo_type == LINUX_LOGO_CLUT224) { fprintf(out, "\t.clutsize\t= %d,\n", logo_clutsize); fprintf(out, "\t.clut\t\t= %s_clut,\n", logoname); } fprintf(out, "\t.data\t\t= %s_data\n", logoname); fputs("};\n\n", out); /* close logo file */ if (outputname) fclose(out); } static int write_hex_cnt; static void write_hex(unsigned char byte) { if (write_hex_cnt % 12) fprintf(out, ", 0x%02x", byte); else if (write_hex_cnt) fprintf(out, ",\n\t0x%02x", byte); else fprintf(out, "\t0x%02x", byte); write_hex_cnt++; } static void write_logo_mono(void) { unsigned int i, j; unsigned char val, bit; /* validate image */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) if (!is_black(logo_data[i][j]) && !is_white(logo_data[i][j])) die("Image must be monochrome\n"); /* write file header */ write_header(); /* write logo data */ for (i = 0; i < logo_height; i++) { for (j = 0; j < logo_width;) { for (val = 0, bit = 0x80; bit && j < logo_width; j++, bit >>= 1) if (logo_data[i][j].red) val |= bit; write_hex(val); } } /* write logo structure and file footer */ write_footer(); } static void write_logo_vga16(void) { unsigned int i, j, k; unsigned char val; /* validate image */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) { for (k = 0; k < 16; k++) if (is_equal(logo_data[i][j], clut_vga16[k])) break; if (k == 16) die("Image must use the 16 console colors only\n" "Use ppmquant(1) -map clut_vga16.ppm to reduce the number " "of colors\n"); } /* write file header */ write_header(); /* write logo data */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) { for (k = 0; k < 16; k++) if (is_equal(logo_data[i][j], clut_vga16[k])) break; val = k<<4; if (++j < logo_width) { for (k = 0; k < 16; k++) if (is_equal(logo_data[i][j], clut_vga16[k])) break; val |= k; } write_hex(val); } /* write logo structure and file footer */ write_footer(); } static void write_logo_clut224(void) { unsigned int i, j, k; /* validate image */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) { for (k = 0; k < logo_clutsize; k++) if (is_equal(logo_data[i][j], logo_clut[k])) break; if (k == logo_clutsize) { if (logo_clutsize == MAX_LINUX_LOGO_COLORS) die("Image has more than %d colors\n" "Use ppmquant(1) to reduce the number of colors\n", MAX_LINUX_LOGO_COLORS); logo_clut[logo_clutsize++] = logo_data[i][j]; } } /* write file header */ write_header(); /* write logo data */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) { for (k = 0; k < logo_clutsize; k++) if (is_equal(logo_data[i][j], logo_clut[k])) break; write_hex(k+32); } fputs("\n};\n\n", out); /* write logo clut */ fprintf(out, "static unsigned char %s_clut[] __initdata = {\n", logoname); write_hex_cnt = 0; for (i = 0; i < logo_clutsize; i++) { write_hex(logo_clut[i].red); write_hex(logo_clut[i].green); write_hex(logo_clut[i].blue); } /* write logo structure and file footer */ write_footer(); } static void write_logo_gray256(void) { unsigned int i, j; /* validate image */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) if (!is_gray(logo_data[i][j])) die("Image must be grayscale\n"); /* write file header */ write_header(); /* write logo data */ for (i = 0; i < logo_height; i++) for (j = 0; j < logo_width; j++) write_hex(logo_data[i][j].red); /* write logo structure and file footer */ write_footer(); } static void die(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); exit(1); } static void usage(void) { die("\n" "Usage: %s [options] <filename>\n" "\n" "Valid options:\n" " -h : display this usage information\n" " -n <name> : specify logo name (default: linux_logo)\n" " -o <output> : output to file <output> instead of stdout\n" " -t <type> : specify logo type, one of\n" " mono : monochrome black/white\n" " vga16 : 16 colors VGA text palette\n" " clut224 : 224 colors (default)\n" " gray256 : 256 levels grayscale\n" "\n", programname); } int main(int argc, char *argv[]) { int opt; programname = argv[0]; opterr = 0; while (1) { opt = getopt(argc, argv, "hn:o:t:"); if (opt == -1) break; switch (opt) { case 'h': usage(); break; case 'n': logoname = optarg; break; case 'o': outputname = optarg; break; case 't': if (!strcmp(optarg, "mono")) logo_type = LINUX_LOGO_MONO; else if (!strcmp(optarg, "vga16")) logo_type = LINUX_LOGO_VGA16; else if (!strcmp(optarg, "clut224")) logo_type = LINUX_LOGO_CLUT224; else if (!strcmp(optarg, "gray256")) logo_type = LINUX_LOGO_GRAY256; else usage(); break; default: usage(); break; } } if (optind != argc-1) usage(); filename = argv[optind]; read_image(); switch (logo_type) { case LINUX_LOGO_MONO: write_logo_mono(); break; case LINUX_LOGO_VGA16: write_logo_vga16(); break; case LINUX_LOGO_CLUT224: write_logo_clut224(); break; case LINUX_LOGO_GRAY256: write_logo_gray256(); break; } exit(0); }
the_stack_data/206393926.c
#include <stdlib.h> struct S { void* (*allocfn)(size_t); }; void init2(void* (*f)(size_t), struct S *s) { s->allocfn = f; } void init(struct S *s) { init2(malloc, s); } void* derived(struct S* s) { return s->allocfn(10); }
the_stack_data/19464.c
int fib(int n) { if (n <= 1) { return n; } else { return fib(n - 1) + fib(n - 2); } } int main() { int n = 5; return fib(n); }
the_stack_data/136693.c
char *a = "hello\ \nworld"; void main() { }
the_stack_data/351387.c
/* -*- Last-Edit: Wed May 7 10:12:52 1993 by Monica; -*- */ #include <stdio.h> /* A job descriptor. */ #define NULL 0 #define NEW_JOB 1 #define UPGRADE_PRIO 2 #define BLOCK 3 #define UNBLOCK 4 #define QUANTUM_EXPIRE 5 #define FINISH 6 #define FLUSH 7 #define MAXPRIO 3 typedef struct _job { struct _job *next, *prev; /* Next and Previous in job list. */ int val ; /* Id-value of program. */ short priority; /* Its priority. */ } Ele, *Ele_Ptr; typedef struct list /* doubly linked list */ { Ele *first; Ele *last; int mem_count; /* member count */ } List; /*----------------------------------------------------------------------------- new_ele alloates a new element with value as num. -----------------------------------------------------------------------------*/ Ele* new_ele(new_num) int new_num; { Ele *ele; ele =(Ele *)malloc(sizeof(Ele)); ele->next = NULL; ele->prev = NULL; ele->val = new_num; return ele; } /*----------------------------------------------------------------------------- new_list allocates, initializes and returns a new list. Note that if the argument compare() is provided, this list can be made into an ordered list. see insert_ele(). -----------------------------------------------------------------------------*/ List *new_list() { List *list; list = (List *)malloc(sizeof(List)); list->first = NULL; list->last = NULL; list->mem_count = 0; return (list); } /*----------------------------------------------------------------------------- append_ele appends the new_ele to the list. If list is null, a new list is created. The modified list is returned. -----------------------------------------------------------------------------*/ List *append_ele(a_list, a_ele) List *a_list; Ele *a_ele; { if (!a_list) a_list = new_list(); /* make list without compare function */ a_ele->prev = a_list->last; /* insert at the tail */ if (a_list->last) a_list->last->next = a_ele; else a_list->first = a_ele; a_list->last = a_ele; a_ele->next = NULL; a_list->mem_count++; return (a_list); } /*----------------------------------------------------------------------------- find_nth fetches the nth element of the list (count starts at 1) -----------------------------------------------------------------------------*/ Ele *find_nth(f_list, n) List *f_list; int n; { Ele *f_ele; int i; if (!f_list) return NULL; f_ele = f_list->first; for (i=1; f_ele && (i<n); i++) f_ele = f_ele->next; return f_ele; } /*----------------------------------------------------------------------------- del_ele deletes the old_ele from the list. Note: even if list becomes empty after deletion, the list node is not deallocated. -----------------------------------------------------------------------------*/ List *del_ele(d_list, d_ele) List *d_list; Ele *d_ele; { if (!d_list || !d_ele) return (NULL); if (d_ele->next) d_ele->next->prev = d_ele->prev; else d_list->last = d_ele->prev; if (d_ele->prev) d_ele->prev->next = d_ele->next; else d_list->first = d_ele->next; /* KEEP d_ele's data & pointers intact!! */ d_list->mem_count--; return (d_list); } /*----------------------------------------------------------------------------- free_ele deallocate the ptr. Caution: The ptr should point to an object allocated in a single call to malloc. -----------------------------------------------------------------------------*/ void free_ele(ptr) Ele *ptr; { free(ptr); } int alloc_proc_num; int num_processes; Ele* cur_proc; List *prio_queue[MAXPRIO+1]; /* 0th element unused */ List *block_queue; void finish_process() { schedule(); if (cur_proc) { fprintf(stdout, "%d ", cur_proc->val); free_ele(cur_proc); num_processes--; } } void finish_all_processes() { int i; int total; total = num_processes; for (i=0; i<total; i++) finish_process(); } schedule() { int i; cur_proc = NULL; for (i=MAXPRIO; i > 0; i--) { if (prio_queue[i]->mem_count > 0) { cur_proc = prio_queue[i]->first; prio_queue[i] = del_ele(prio_queue[i], cur_proc); return; } } } void upgrade_process_prio(prio, ratio) int prio; float ratio; { int count; int n; Ele *proc; List *src_queue, *dest_queue; if (prio >= MAXPRIO) return; src_queue = prio_queue[prio]; dest_queue = prio_queue[prio+1]; count = src_queue->mem_count; if (count > 0) { n = (int) (count*ratio + 1); proc = find_nth(src_queue, n); if (proc) { src_queue = del_ele(src_queue, proc); /* append to appropriate prio queue */ proc->priority = prio; dest_queue = append_ele(dest_queue, proc); } } } void unblock_process(ratio) float ratio; { int count; int n; Ele *proc; int prio; if (block_queue) { count = block_queue->mem_count + 1; n = (int) (count*ratio); /* change in where +1 was added - logic change */ proc = find_nth(block_queue, n); if (proc) { block_queue = del_ele(block_queue, proc); /* append to appropriate prio queue */ prio = proc->priority; prio_queue[prio] = append_ele(prio_queue[prio], proc); } } } void quantum_expire() { int prio; schedule(); if (cur_proc) { prio = cur_proc->priority; prio_queue[prio] = append_ele(prio_queue[prio], cur_proc); } } void block_process() { schedule(); if (cur_proc) { block_queue = append_ele(block_queue, cur_proc); } } Ele * new_process(prio) int prio; { Ele *proc; proc = new_ele(alloc_proc_num++); proc->priority = prio; num_processes++; return proc; } void add_process(prio) int prio; { Ele *proc; proc = new_process(prio); prio_queue[prio] = append_ele(prio_queue[prio], proc); } void init_prio_queue(prio, num_proc) int prio; int num_proc; { List *queue; Ele *proc; int i; queue = new_list(); for (i=0; i<num_proc; i++) { proc = new_process(prio); queue = append_ele(queue, proc); } prio_queue[prio] = queue; } void initialize() { alloc_proc_num = 0; num_processes = 0; } /* test driver */ main(argc, argv) int argc; char *argv[]; { int command; int prio; float ratio; int status; if (argc < (MAXPRIO+1)) { fprintf(stdout, "incorrect usage\n"); return; } initialize(); for (prio=MAXPRIO; prio >= 1; prio--) { init_prio_queue(prio, atoi(argv[prio])); } for (status = fscanf(stdin, "%d", &command); ((status!=EOF) && status); status = fscanf(stdin, "%d", &command)) { switch(command) { case FINISH: finish_process(); break; case BLOCK: block_process(); break; case QUANTUM_EXPIRE: quantum_expire(); break; case UNBLOCK: fscanf(stdin, "%f", &ratio); unblock_process(ratio); break; case UPGRADE_PRIO: fscanf(stdin, "%d", &prio); fscanf(stdin, "%f", &ratio); if (prio > MAXPRIO || prio <= 0) { fprintf(stdout, "** invalid priority\n"); return; } else upgrade_process_prio(prio, ratio); break; case NEW_JOB: fscanf(stdin, "%d", &prio); if (prio > MAXPRIO || prio <= 0) { fprintf(stdout, "** invalid priority\n"); return; } else add_process(prio); break; case FLUSH: finish_all_processes(); break; } } } /* A simple input spec: a.out n3 n2 n1 where n3, n2, n1 are non-negative integers indicating the number of initial processes at priority 3, 2, and 1, respectively. The input file is a list of commands of the following kinds: (For simplicity, comamnd names are integers (NOT strings) FINISH ;; this exits the current process (printing its number) NEW_JOB priority ;; this adds a new process at specified priority BLOCK ;; this adds the current process to the blocked queue QUANTUM_EXPIRE ;; this puts the current process at the end ;; of its prioqueue UNBLOCK ratio ;; this unblocks a process from the blocked queue ;; and ratio is used to determine which one UPGRADE_PRIO small-priority ratio ;; this promotes a process from ;; the small-priority queue to the next higher priority ;; and ratio is used to determine which process FLUSH ;; causes all the processes from the prio queues to ;; exit the system in their priority order where NEW_JOB 1 UPGRADE_PRIO 2 BLOCK 3 UNBLOCK 4 QUANTUM_EXPIRE 5 FINISH 6 FLUSH 7 and priority is in 1..3 and small-priority is in 1..2 and ratio is in 0.0..1.0 The output is a list of numbers indicating the order in which processes exit from the system. */
the_stack_data/247017215.c
//{{BLOCK(steef) //====================================================================== // // steef, 64x64@8, // Transparent palette entry: 97. // + palette 256 entries, not compressed // + 64 tiles not compressed // Total size: 512 + 4096 = 4608 // // Time-stamp: 2019-12-21, 22:29:35 // Exported by Cearn's GBA Image Transmogrifier, v0.8.6 // ( http://www.coranac.com/projects/#grit ) // //====================================================================== const unsigned short steefTiles[2048] __attribute__((aligned(4)))= { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0xF000,0x0000,0x0000,0x0000,0xF0F0, 0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0xF000,0xF0F0, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0xF000,0xF0F0,0xF0F0,0x00F0, 0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0x0000,0x0000,0xF0F0, 0x00F0,0x0000,0x0000,0xF0EC,0x0000,0x0000,0x0000,0xF000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0xF000,0x0000,0x0000,0x0000, 0xF0EC,0xF0F0,0x0000,0x0000,0xF0F0,0x00F0,0x0000,0x0000, 0xF0F0,0xF0F0,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x00F0,0x0000,0x0000,0xF000,0xECF0,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x00F0,0x0000,0x0000,0xF000,0xECF0,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0xF0F0,0xF0F0,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00EC, 0x0000,0x0000,0xF000,0xF0F0,0x0000,0x0000,0xF000,0xF0F0, 0x0000,0x0000,0x0000,0x00EC,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0xF000,0xF0F0,0x0000,0x0000,0xF000,0xECF0, 0x0000,0x0000,0xF0F0,0xF0F0,0x0000,0x0000,0xF0F0,0xF0F0, 0x0000,0x0000,0xF0F0,0xF0F0,0x0000,0x0000,0xF000,0xF0F0, 0x0000,0x0000,0xF000,0xF0F0,0x0000,0x0000,0xF000,0xF0F0, 0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000,0xF0F0, 0x0000,0x0000,0xF000,0xF0F0,0xF000,0xF0F0,0xF0F0,0xF0F0, 0xF000,0xF0F0,0xF0F0,0xF0F0,0x00F0,0xF0F0,0xF0F0,0x00F0, 0x00F0,0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000, 0xF0F0,0x0000,0xF000,0xECF0,0x00F0,0x0000,0xF0F0,0x00F0, 0x00F0,0xF000,0xF0F0,0x00F0,0x00F0,0xF000,0xF0F0,0x0000, 0x0000,0xF0F0,0xF0F0,0x0000,0x0000,0xF0F0,0x00F0,0x0000, 0xF000,0xF0F0,0x00F0,0x0000,0xF000,0xF0F0,0xECF0,0x00F0, 0xF000,0xF0F0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0xF0F0,0xF0F0,0x00F0, 0x0000,0xF000,0xF0F0,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xF0F0,0xF0F0, 0x0000,0x0000,0x0000,0x0000,0x0000,0xF000,0x00F0,0x0000, 0x0000,0xEC00,0x0000,0xEC00,0x0000,0x0000,0x0000,0xF000, 0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000,0xF0F0, 0x0000,0x0000,0xF000,0xF0F0,0x00F0,0x0000,0xF000,0xF0F0, 0xF000,0xF0F0,0xF0F0,0x0000,0xF0F0,0xECF0,0xF0F0,0x0000, 0xF0F0,0x00F0,0xF0F0,0x0000,0xF0F0,0xF000,0x00F0,0x0000, 0xF0F0,0xF000,0x00F0,0x0000,0x00F0,0xF0F0,0x0000,0x0000, 0xF0F0,0x00F0,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0xF0F0,0xF0F0, 0x0000,0xF000,0xF0F0,0xF0F0,0x0000,0xF000,0xF0F0,0xF0F0, 0x0000,0xF0F0,0xF0F0,0x00F0,0x0000,0xF0F0,0xF0F0,0x0000, 0xF000,0xF0F0,0x00F0,0x0000,0xF000,0xF0F0,0x0000,0x0000, 0xF0F0,0xF0F0,0x0000,0xF0F0,0xF0F0,0xF0F0,0x00F0,0xF0F0, 0xF0F0,0xF0F0,0x00F0,0xF000,0x00EC,0x0000,0x0000,0xF000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF0F0,0x0000,0x0000,0xF000,0xF0F0,0x00F0,0x0000,0x0000, 0xF0F0,0x00F0,0x0000,0xF000,0xF0F0,0x00F0,0x0000,0xF000, 0xF0F0,0x00F0,0x0000,0xF0F0,0xF0F0,0xF0F0,0x0000,0xF0F0, 0xF0F0,0xF0F0,0xF000,0xF0F0,0xF0F0,0xF0F0,0xF000,0xF0F0, 0xF0F0,0xF0F0,0xF0F0,0x00F0,0xF0F0,0xF0F0,0x0000,0x0000, 0xF0F0,0x00F0,0x0000,0xF000,0xF0F0,0x00F0,0x0000,0xF0F0, 0xF0F0,0x0000,0x0000,0xF0F0,0xF0F0,0x0000,0xF000,0xF0F0, 0x00F0,0x0000,0xF0F0,0xF0F0,0x00F0,0x0000,0xF0F0,0xF0F0, 0xF000,0xF0F0,0xF0F0,0x00F0,0xF0F0,0x00F0,0xF000,0x00F0, 0xF0F0,0x0000,0xF000,0x00F0,0xF0F0,0x0000,0xF0F0,0x00F0, 0x00F0,0xF000,0xF0F0,0x00F0,0xF0F0,0xF0F0,0xF0F0,0xF000, 0xF0F0,0xF0F0,0x00F0,0xF0F0,0xF0F0,0xF0F0,0x0000,0xF0F0, 0x0000,0xF000,0xF0F0,0xF0F0,0x0000,0xF0F0,0x00F0,0xF000, 0xF000,0xF0F0,0x0000,0xF000,0xF0F0,0xF0F0,0x0000,0xF0F0, 0xF0F0,0x00F0,0xF000,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0, 0xF0F0,0xF0F0,0xF0F0,0x00F0,0xF0F0,0xF0F0,0xF0F0,0x0000, 0x00F0,0x0000,0xF0F0,0xF0F0,0x00F0,0x0000,0xF0F0,0xF0F0, 0x00F0,0xEC00,0xF0F0,0x00F0,0x00F0,0xF0F0,0xF0F0,0x0000, 0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF000,0xF0F0,0xF0F0,0xF0F0, 0xF000,0xF0F0,0xF0F0,0x00F0,0xF0F0,0xF0F0,0x00F0,0x0000, 0xECF0,0x0000,0x0000,0x0000,0x00EC,0x0000,0x0000,0x0000, 0x0000,0x00F0,0x0000,0x0000,0xF000,0x00F0,0x0000,0x0000, 0xF0F0,0x0000,0x0000,0x0000,0x00F0,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF000,0xF0F0,0x0000,0x0000,0xF000,0xF0F0,0x0000,0x0000, 0xF000,0xF0F0,0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000, 0x0000,0xF0F0,0x0000,0x0000,0x0000,0xF0EC,0x00F0,0x0000, 0x0000,0xF000,0xF0F0,0x0000,0x0000,0x0000,0xF0F0,0xF0F0, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0xF000,0x0000,0x0000,0x0000,0xF000, 0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0xF000,0xF0F0, 0x0000,0xF000,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0x00F0, 0xF0F0,0x00F0,0xF000,0xF0F0,0xF0F0,0x00F0,0xF0F0,0xF0F0, 0xF0F0,0x00F0,0xF0F0,0xF0F0,0xF0F0,0x0000,0xF0F0,0xF0F0, 0xF0F0,0x0000,0xF000,0xF0F0,0x00F0,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0xF0F0,0xF0F0,0x0000,0xF000,0xF0F0,0xF0F0, 0xF000,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0x00F0,0xF0F0,0xF0F0, 0x00F0,0x0000,0xF000,0xF0F0,0x0000,0x0000,0x0000,0xF000, 0x0000,0x0000,0x0000,0x0000,0xF0F0,0x00F0,0x0000,0x0000, 0x0000,0x0000,0xF000,0xF0F0,0x0000,0x0000,0xF0F0,0xF0F0, 0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0x00F0,0xF0F0, 0xF0F0,0x00F0,0x0000,0xF000,0x00EC,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF0F0,0x0000,0x0000,0xF000,0xF0F0,0x0000,0x0000,0xF0F0, 0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0,0xF0F0, 0xF0F0,0xF0F0,0x00F0,0xF000,0xF000,0x00EC,0x0000,0xF0F0, 0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0xF000,0xF0F0, 0xF0F0,0xF0F0,0x0000,0x0000,0xF0F0,0xF0F0,0x0000,0x0000, 0xF0F0,0x00F0,0x0000,0x0000,0xF0F0,0x00F0,0x0000,0x0000, 0xF0F0,0x00EC,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000, 0xF0F0,0x0000,0xF0F0,0x0000,0x00F0,0xF000,0xF0F0,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0xF000,0x0000,0x0000,0x0000,0xF000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF0F0,0xF0F0,0x00F0,0x0000,0x0000,0x0000,0x0000,0xEC00, 0x0000,0x0000,0x0000,0xF000,0x0000,0x0000,0x0000,0xF000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x00F0,0x0000,0x0000,0x0000, 0x00F0,0x0000,0x0000,0x0000,0x00F0,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF0F0,0x00F0,0x0000,0x0000,0xF0F0,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x00F0,0x0000,0x0000,0xF0F0,0xF0F0,0x00EC,0x0000, 0xF000,0xF0F0,0x0000,0x0000,0xF0F0,0xF0F0,0x00F0,0x0000, 0x0000,0x00F0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0xF0F0,0xF0F0,0x0000,0xF0F0,0xF0F0,0xF0F0, 0x0000,0xF000,0xF0F0,0xF0F0,0x0000,0xF0F0,0xF0F0,0x00F0, 0x0000,0x0000,0x00F0,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x00F0,0xEC00,0xF0F0,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; const unsigned short steefPal[256] __attribute__((aligned(4)))= { 0x7C1F,0x0003,0x0002,0x0003,0x0421,0x0422,0x0821,0x0024, 0x0C21,0x0822,0x0C21,0x0024,0x1041,0x0C22,0x1041,0x0023, 0x0823,0x0006,0x0025,0x1042,0x1042,0x0025,0x1043,0x0046, 0x0844,0x1443,0x1460,0x1462,0x0047,0x1462,0x0C43,0x0046, 0x0047,0x0446,0x0446,0x0047,0x1463,0x0066,0x0047,0x1881, 0x0049,0x0467,0x0467,0x0068,0x0468,0x1884,0x1885,0x0088, 0x1485,0x0887,0x0C87,0x1086,0x0489,0x048A,0x046D,0x24A3, 0x0888,0x0489,0x0889,0x0C89,0x088A,0x1CA5,0x04AA,0x08AA, 0x0CA9,0x088B,0x1CC6,0x18C7,0x04AB,0x14C8,0x08AB,0x04CB, 0x0CCB,0x24E6,0x10CA,0x0CCB,0x0CCA,0x20E6,0x28E4,0x14C9, 0x1CE8,0x20E8,0x08AF,0x18E9,0x04CD,0x08CD,0x0CCC,0x0CB2, 0x10CD,0x08CD,0x10EB,0x2508,0x0CEC,0x14EC,0x10EE,0x2908, 0x2945,0x0820,0x250A,0x10F1,0x050F,0x1D2B,0x292A,0x0D0E, 0x212B,0x150F,0x0D10,0x110E,0x190E,0x0D0F,0x192D,0x152D, 0x1512,0x1514,0x1930,0x1131,0x2D4B,0x1950,0x1D4F,0x2D6C, 0x1932,0x1551,0x1533,0x0D51,0x1950,0x296D,0x39A6,0x1134, 0x2151,0x216F,0x1553,0x1D54,0x1952,0x1D72,0x2171,0x358D, 0x1575,0x2157,0x1976,0x1994,0x2175,0x1D93,0x2193,0x2194, 0x2594,0x2DB0,0x19B4,0x29B1,0x39CF,0x2DB4,0x2997,0x29B3, 0x1DB6,0x21B6,0x25B6,0x25B6,0x4A29,0x25B6,0x29D4,0x21D6, 0x21D5,0x31F2,0x21B9,0x25D9,0x29D8,0x29D8,0x25D8,0x2DF6, 0x29F6,0x29D9,0x29F7,0x25F6,0x29F7,0x21F8,0x29F6,0x2DF6, 0x31D9,0x3613,0x4631,0x31FA,0x2619,0x2DFA,0x3617,0x3636, 0x2A1A,0x2A1A,0x2A19,0x2E38,0x2E19,0x2A1A,0x2E19,0x3237, 0x3237,0x3218,0x2A19,0x2A39,0x3638,0x2E3B,0x2A3A,0x2E3A, 0x2E3A,0x323B,0x2E5A,0x5EAC,0x323A,0x363A,0x2E59,0x3A58, 0x5ACA,0x3A5A,0x325A,0x3659,0x3A59,0x365A,0x365A,0x4698, 0x3A7B,0x3A7B,0x3A7C,0x3A9A,0x3E7C,0x3E7B,0x3E9B,0x429A, 0x670F,0x42BC,0x3EBC,0x429E,0x42BB,0x3ABC,0x46BC,0x46DB, 0x42BD,0x6B2E,0x6B4C,0x46DD,0x4ADD,0x46DE,0x778B,0x7FCE, 0x7FFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; //}}BLOCK(steef)
the_stack_data/36074516.c
#include <stdio.h> #include <stdlib.h> #include<math.h> #define ll long long #define f(i,a,b) for(i=a;i<b;i++) #define fd(i,b,a) for(i=b;i>a;i--) #define nl '\n' int isprime(int j) { int i; f(i,2,sqrt(j)+1) { if(j%i==0) return 0; } return 1; } int main() { ll n; int i; //int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973}; int* pg = malloc(1500*sizeof(int)); pg[0]=2; int c=1; f(i,2,10000) { if(isprime(i)) { pg[c]=i; c++; } } scanf("%lld",&n); ll tem; int k=0; int ans; int exp; while(n) { if(n%pg[k]==0) { printf("%d ",pg[k]); exp=0; tem = pg[k]; while(n%tem==0) { exp++; tem=tem*pg[k]; } tem/=pg[k]; n=n/tem; ans+=exp; k++; if(n==1) break; } else k++; } printf("\n"); printf("%d\n",ans); free(pg); return 0; }
the_stack_data/98575361.c
char n[11]; int s; int digit_w[10]={5,0,7,7,2,7,7,1,7,7}; int digit_h[10][2]={{3,3},{2,2},{2,1},{2,2},{3,2},{1,2},{1,3},{2,2},{3,3},{3,2}}; int i,j,k; main() { scanf("%d%s",&s,n); for(i=0;i<2*s+3;i++) { for(k=0;n[k];k++) { if(i==0||i==s+1||i==2*s+2) { for(j=0;j<s+2;j++) { if(j==0||j==s+1)putchar(' '); else putchar(digit_w[n[k]-'0']&(1<<(i/(s+1)))?'-':' '); } } else { putchar(digit_h[n[k]-'0'][i>s]&1?'|':' '); for(j=0;j<s;j++)putchar(' '); putchar(digit_h[n[k]-'0'][i>s]&2?'|':' '); } putchar(' '); } puts(""); } }
the_stack_data/28263356.c
#include "stdlib.h" extern char *getenv(const char *); struct SH { int arena_size; char *arena; int minsize; int freelist_size; }; static struct SH sh; static int sh_getlist(char *ptr) { int size = sh.freelist_size - 1; int bit = (sh.arena_size + ptr - sh.arena) / sh.minsize; int t = bit; return 0; } int main() { char *ptr = getenv("gude"); int rc = sh_getlist(ptr); return rc; }
the_stack_data/14200082.c
#include <stdio.h> /*06. Write a program that finds the biggest of five numbers by using only five if statements.*/ int main() { double a, b, c, d, e, max = 0; printf("Enter a, b, c, d and e, seperated by space: "); scanf("%lf %lf %lf %lf %lf", &a, &b, &c, &d, &e); if(a > max) { max = a; } if(b > max) { max = b; } if(c > max) { max = c; } if(d > max) { max = d; } if(e > max) { max = e; } printf("Max: %.2lf\n", max); return 0; }
the_stack_data/56960.c
#include <stdio.h> #include <stdlib.h> //给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。 // //你的算法时间复杂度必须是 O(log n) 级别。 // //如果数组中不存在目标值,返回 [-1, -1]。 // //示例 1: // //输入: nums = [5,7,7,8,8,10], target = 8 //输出: [3,4] //示例 2: // //输入: nums = [5,7,7,8,8,10], target = 6 //输出: [-1,-1] /** * Return an array of size *returnSize. * Note: The returned array must be malloced, assume caller calls free(). */ //int *searchRange(int *nums, int numsSize, int target, int *returnSize) { // // int low = 0; // int high = numsSize - 1; // int mid = 0; // int flag = 0; // while (low <= high) { // mid = (low + high) / 2; // if (nums[mid] == target) { // flag = 1; // break; // } else if (target < nums[mid]) { // high = mid - 1; // } else { // low = mid + 1; // } // } // // *returnSize = 2; // int *ret = (int *) malloc(*returnSize * sizeof(int)); // // if (flag == 0) { // ret[0] = -1; // ret[1] = -1; // return ret; // } // // int midH = mid; // while (nums[midH] <= target && midH < numsSize) { // midH++; // } // int midL = mid; // while (nums[midL] >= target && midL >= 0) { // midL--; // } // // ret[0] = midL + 1; // ret[1] = midH - 1; // return ret; // //} int *searchRange(int *nums, int numsSize, int target, int *returnSize) { int i = 0; while (target != nums[i] && i < numsSize) { i++; } *returnSize = 2; int *ret = (int *) malloc(*returnSize * sizeof(int)); if (i == numsSize) { ret[0] = -1; ret[1] = -1; } else { ret[0] = i; while (target == nums[i] && i < numsSize) { i++; } ret[1] = i - 1; } return ret; } int main() { // int arr[] = {5, 7, 7, 8, 8, 10}; int arr[] = {1}; int size; int *res = searchRange(arr, sizeof(arr) / sizeof(int), 1, &size); for (int i = 0; i < size; ++i) { printf("%d,", res[i]); } free(res); return 0; }
the_stack_data/103264239.c
#include <stdio.h> void f1 (void) { printf("%i\n", 1); } void f2 (void) { printf("%i\n", 2); } void f3 (void) { printf("%i\n", 3); } void f4 (void) { printf("%i\n", 4); } void f5 (void) { printf("%i\n", 5); } void f6 (void) { printf("%i\n", 6); } void f7 (void) { printf("%i\n", 7); } void f8 (void) { printf("%i\n", 8); } void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); struct action { int x; void_fp fun; }; struct action rec = { .x = 4, .fun = f2 }; // There is a basic check that excludes all functions that aren't used anywhere // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; void func(int i) { // Can mutate rec.fun=f4; const void_fp fp = rec.fun; fp(); } int main() { for(int i=0;i<3;i++) { func(i); } return 0; }
the_stack_data/225141923.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putmem.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: erli <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/08 16:39:13 by erli #+# #+# */ /* Updated: 2018/11/08 16:42:21 by erli ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> #include <string.h> void ft_putmem(const void *ptr, size_t n) { size_t i; unsigned char *str; i = 0; str = (unsigned char *)ptr; while (i < n) { write(1, str + i, 1); i++; } }
the_stack_data/234519408.c
#define STATIC_ASSERT(condition) \ int some_array##__LINE__[(condition) ? 1 : -1]; #define G(X) _Generic((X), \ long double: 1, \ default: 10, \ float: 2, \ int: 3, \ char: 4, \ struct some: 5 \ ) struct some { } s; int i; char ch; long double ld; short sh; #ifdef __GNUC__ STATIC_ASSERT(G(i)==3); STATIC_ASSERT(G(sh)==10); STATIC_ASSERT(G(ld)==1); STATIC_ASSERT(G(ch)==4); STATIC_ASSERT(G(s)==5); #else // Visual Studio doesn't have it. #endif int main() { }
the_stack_data/935776.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static doublecomplex c_b1 = {0.,0.}; static doublecomplex c_b2 = {1.,0.}; static integer c_n1 = -1; static integer c__0 = 0; static integer c__1 = 1; /* > \brief \b ZGESDD */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download ZGESDD + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgesdd. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgesdd. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgesdd. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE ZGESDD( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT, */ /* WORK, LWORK, RWORK, IWORK, INFO ) */ /* CHARACTER JOBZ */ /* INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N */ /* INTEGER IWORK( * ) */ /* DOUBLE PRECISION RWORK( * ), S( * ) */ /* COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ), */ /* $ WORK( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > ZGESDD computes the singular value decomposition (SVD) of a complex */ /* > M-by-N matrix A, optionally computing the left and/or right singular */ /* > vectors, by using divide-and-conquer method. The SVD is written */ /* > */ /* > A = U * SIGMA * conjugate-transpose(V) */ /* > */ /* > where SIGMA is an M-by-N matrix which is zero except for its */ /* > f2cmin(m,n) diagonal elements, U is an M-by-M unitary matrix, and */ /* > V is an N-by-N unitary matrix. The diagonal elements of SIGMA */ /* > are the singular values of A; they are real and non-negative, and */ /* > are returned in descending order. The first f2cmin(m,n) columns of */ /* > U and V are the left and right singular vectors of A. */ /* > */ /* > Note that the routine returns VT = V**H, not V. */ /* > */ /* > The divide and conquer algorithm makes very mild assumptions about */ /* > floating point arithmetic. It will work on machines with a guard */ /* > digit in add/subtract, or on those binary machines without guard */ /* > digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or */ /* > Cray-2. It could conceivably fail on hexadecimal or decimal machines */ /* > without guard digits, but we know of none. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] JOBZ */ /* > \verbatim */ /* > JOBZ is CHARACTER*1 */ /* > Specifies options for computing all or part of the matrix U: */ /* > = 'A': all M columns of U and all N rows of V**H are */ /* > returned in the arrays U and VT; */ /* > = 'S': the first f2cmin(M,N) columns of U and the first */ /* > f2cmin(M,N) rows of V**H are returned in the arrays U */ /* > and VT; */ /* > = 'O': If M >= N, the first N columns of U are overwritten */ /* > in the array A and all rows of V**H are returned in */ /* > the array VT; */ /* > otherwise, all columns of U are returned in the */ /* > array U and the first M rows of V**H are overwritten */ /* > in the array A; */ /* > = 'N': no columns of U or rows of V**H are computed. */ /* > \endverbatim */ /* > */ /* > \param[in] M */ /* > \verbatim */ /* > M is INTEGER */ /* > The number of rows of the input matrix A. M >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The number of columns of the input matrix A. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] A */ /* > \verbatim */ /* > A is COMPLEX*16 array, dimension (LDA,N) */ /* > On entry, the M-by-N matrix A. */ /* > On exit, */ /* > if JOBZ = 'O', A is overwritten with the first N columns */ /* > of U (the left singular vectors, stored */ /* > columnwise) if M >= N; */ /* > A is overwritten with the first M rows */ /* > of V**H (the right singular vectors, stored */ /* > rowwise) otherwise. */ /* > if JOBZ .ne. 'O', the contents of A are destroyed. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ /* > \endverbatim */ /* > */ /* > \param[out] S */ /* > \verbatim */ /* > S is DOUBLE PRECISION array, dimension (f2cmin(M,N)) */ /* > The singular values of A, sorted so that S(i) >= S(i+1). */ /* > \endverbatim */ /* > */ /* > \param[out] U */ /* > \verbatim */ /* > U is COMPLEX*16 array, dimension (LDU,UCOL) */ /* > UCOL = M if JOBZ = 'A' or JOBZ = 'O' and M < N; */ /* > UCOL = f2cmin(M,N) if JOBZ = 'S'. */ /* > If JOBZ = 'A' or JOBZ = 'O' and M < N, U contains the M-by-M */ /* > unitary matrix U; */ /* > if JOBZ = 'S', U contains the first f2cmin(M,N) columns of U */ /* > (the left singular vectors, stored columnwise); */ /* > if JOBZ = 'O' and M >= N, or JOBZ = 'N', U is not referenced. */ /* > \endverbatim */ /* > */ /* > \param[in] LDU */ /* > \verbatim */ /* > LDU is INTEGER */ /* > The leading dimension of the array U. LDU >= 1; */ /* > if JOBZ = 'S' or 'A' or JOBZ = 'O' and M < N, LDU >= M. */ /* > \endverbatim */ /* > */ /* > \param[out] VT */ /* > \verbatim */ /* > VT is COMPLEX*16 array, dimension (LDVT,N) */ /* > If JOBZ = 'A' or JOBZ = 'O' and M >= N, VT contains the */ /* > N-by-N unitary matrix V**H; */ /* > if JOBZ = 'S', VT contains the first f2cmin(M,N) rows of */ /* > V**H (the right singular vectors, stored rowwise); */ /* > if JOBZ = 'O' and M < N, or JOBZ = 'N', VT is not referenced. */ /* > \endverbatim */ /* > */ /* > \param[in] LDVT */ /* > \verbatim */ /* > LDVT is INTEGER */ /* > The leading dimension of the array VT. LDVT >= 1; */ /* > if JOBZ = 'A' or JOBZ = 'O' and M >= N, LDVT >= N; */ /* > if JOBZ = 'S', LDVT >= f2cmin(M,N). */ /* > \endverbatim */ /* > */ /* > \param[out] WORK */ /* > \verbatim */ /* > WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) */ /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* > \endverbatim */ /* > */ /* > \param[in] LWORK */ /* > \verbatim */ /* > LWORK is INTEGER */ /* > The dimension of the array WORK. LWORK >= 1. */ /* > If LWORK = -1, a workspace query is assumed. The optimal */ /* > size for the WORK array is calculated and stored in WORK(1), */ /* > and no other work except argument checking is performed. */ /* > */ /* > Let mx = f2cmax(M,N) and mn = f2cmin(M,N). */ /* > If JOBZ = 'N', LWORK >= 2*mn + mx. */ /* > If JOBZ = 'O', LWORK >= 2*mn*mn + 2*mn + mx. */ /* > If JOBZ = 'S', LWORK >= mn*mn + 3*mn. */ /* > If JOBZ = 'A', LWORK >= mn*mn + 2*mn + mx. */ /* > These are not tight minimums in all cases; see comments inside code. */ /* > For good performance, LWORK should generally be larger; */ /* > a query is recommended. */ /* > \endverbatim */ /* > */ /* > \param[out] RWORK */ /* > \verbatim */ /* > RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK)) */ /* > Let mx = f2cmax(M,N) and mn = f2cmin(M,N). */ /* > If JOBZ = 'N', LRWORK >= 5*mn (LAPACK <= 3.6 needs 7*mn); */ /* > else if mx >> mn, LRWORK >= 5*mn*mn + 5*mn; */ /* > else LRWORK >= f2cmax( 5*mn*mn + 5*mn, */ /* > 2*mx*mn + 2*mn*mn + mn ). */ /* > \endverbatim */ /* > */ /* > \param[out] IWORK */ /* > \verbatim */ /* > IWORK is INTEGER array, dimension (8*f2cmin(M,N)) */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit. */ /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ /* > > 0: The updating process of DBDSDC did not converge. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date June 2016 */ /* > \ingroup complex16GEsing */ /* > \par Contributors: */ /* ================== */ /* > */ /* > Ming Gu and Huan Ren, Computer Science Division, University of */ /* > California at Berkeley, USA */ /* > */ /* ===================================================================== */ /* Subroutine */ int zgesdd_(char *jobz, integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *s, doublecomplex *u, integer *ldu, doublecomplex *vt, integer *ldvt, doublecomplex *work, integer *lwork, doublereal *rwork, integer *iwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, u_dim1, u_offset, vt_dim1, vt_offset, i__1, i__2, i__3; /* Local variables */ integer lwork_zgebrd_mm__, lwork_zgebrd_mn__, lwork_zgebrd_nn__, lwork_zgelqf_mn__, lwork_zgeqrf_mn__; doublecomplex cdum[1]; integer iscl; doublereal anrm; integer idum[1], ierr, itau, lwork_zunglq_mn__, lwork_zunglq_nn__, lwork_zungqr_mm__, lwork_zungqr_mn__, irvt, lwork_zunmbr_prc_mm__, lwork_zunmbr_prc_mn__, lwork_zunmbr_prc_nn__, lwork_zunmbr_qln_mm__, lwork_zunmbr_qln_mn__, lwork_zunmbr_qln_nn__, i__; extern logical lsame_(char *, char *); integer chunk, minmn; extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, integer *, doublecomplex *, doublecomplex *, integer *, doublecomplex *, integer *, doublecomplex *, doublecomplex *, integer *); integer wrkbl, itaup, itauq; logical wntqa; integer nwork; logical wntqn, wntqo, wntqs; extern /* Subroutine */ int zlacp2_(char *, integer *, integer *, doublereal *, integer *, doublecomplex *, integer *); integer mnthr1, mnthr2, ie; extern /* Subroutine */ int dbdsdc_(char *, char *, integer *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, integer *); integer il; extern doublereal dlamch_(char *); integer ir, iu; extern /* Subroutine */ int dlascl_(char *, integer *, integer *, doublereal *, doublereal *, integer *, integer *, doublereal *, integer *, integer *); integer lwork_zungbr_p_mn__, lwork_zungbr_p_nn__, lwork_zungbr_q_mn__, lwork_zungbr_q_mm__; extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); doublereal bignum; extern /* Subroutine */ int zgebrd_(integer *, integer *, doublecomplex *, integer *, doublereal *, doublereal *, doublecomplex *, doublecomplex *, doublecomplex *, integer *, integer *); extern logical disnan_(doublereal *); extern doublereal zlange_(char *, integer *, integer *, doublecomplex *, integer *, doublereal *); extern /* Subroutine */ int zgelqf_(integer *, integer *, doublecomplex *, integer *, doublecomplex *, doublecomplex *, integer *, integer * ), zlacrm_(integer *, integer *, doublecomplex *, integer *, doublereal *, integer *, doublecomplex *, integer *, doublereal *) , zlarcm_(integer *, integer *, doublereal *, integer *, doublecomplex *, integer *, doublecomplex *, integer *, doublereal *), zlascl_(char *, integer *, integer *, doublereal *, doublereal *, integer *, integer *, doublecomplex *, integer *, integer *), zgeqrf_(integer *, integer *, doublecomplex *, integer *, doublecomplex *, doublecomplex *, integer *, integer * ); integer ldwrkl; extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, doublecomplex *, integer *, doublecomplex *, integer *), zlaset_(char *, integer *, integer *, doublecomplex *, doublecomplex *, doublecomplex *, integer *); integer ldwrkr, minwrk, ldwrku, maxwrk; extern /* Subroutine */ int zungbr_(char *, integer *, integer *, integer *, doublecomplex *, integer *, doublecomplex *, doublecomplex *, integer *, integer *); integer ldwkvt; doublereal smlnum; logical wntqas; extern /* Subroutine */ int zunmbr_(char *, char *, char *, integer *, integer *, integer *, doublecomplex *, integer *, doublecomplex *, doublecomplex *, integer *, doublecomplex *, integer *, integer * ), zunglq_(integer *, integer *, integer * , doublecomplex *, integer *, doublecomplex *, doublecomplex *, integer *, integer *); logical lquery; integer nrwork; extern /* Subroutine */ int zungqr_(integer *, integer *, integer *, doublecomplex *, integer *, doublecomplex *, doublecomplex *, integer *, integer *); integer blk; doublereal dum[1], eps; integer iru, ivt; /* -- LAPACK driver routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* June 2016 */ /* ===================================================================== */ /* Test the input arguments */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --s; u_dim1 = *ldu; u_offset = 1 + u_dim1 * 1; u -= u_offset; vt_dim1 = *ldvt; vt_offset = 1 + vt_dim1 * 1; vt -= vt_offset; --work; --rwork; --iwork; /* Function Body */ *info = 0; minmn = f2cmin(*m,*n); mnthr1 = (integer) (minmn * 17. / 9.); mnthr2 = (integer) (minmn * 5. / 3.); wntqa = lsame_(jobz, "A"); wntqs = lsame_(jobz, "S"); wntqas = wntqa || wntqs; wntqo = lsame_(jobz, "O"); wntqn = lsame_(jobz, "N"); lquery = *lwork == -1; minwrk = 1; maxwrk = 1; if (! (wntqa || wntqs || wntqo || wntqn)) { *info = -1; } else if (*m < 0) { *info = -2; } else if (*n < 0) { *info = -3; } else if (*lda < f2cmax(1,*m)) { *info = -5; } else if (*ldu < 1 || wntqas && *ldu < *m || wntqo && *m < *n && *ldu < * m) { *info = -8; } else if (*ldvt < 1 || wntqa && *ldvt < *n || wntqs && *ldvt < minmn || wntqo && *m >= *n && *ldvt < *n) { *info = -10; } /* Compute workspace */ /* Note: Comments in the code beginning "Workspace:" describe the */ /* minimal amount of workspace allocated at that point in the code, */ /* as well as the preferred amount for good performance. */ /* CWorkspace refers to complex workspace, and RWorkspace to */ /* real workspace. NB refers to the optimal block size for the */ /* immediately following subroutine, as returned by ILAENV.) */ if (*info == 0) { minwrk = 1; maxwrk = 1; if (*m >= *n && minmn > 0) { /* There is no complex work space needed for bidiagonal SVD */ /* The real work space needed for bidiagonal SVD (dbdsdc) is */ /* BDSPAC = 3*N*N + 4*N for singular values and vectors; */ /* BDSPAC = 4*N for singular values only; */ /* not including e, RU, and RVT matrices. */ /* Compute space preferred for each routine */ zgebrd_(m, n, cdum, m, dum, dum, cdum, cdum, cdum, &c_n1, &ierr); lwork_zgebrd_mn__ = (integer) cdum[0].r; zgebrd_(n, n, cdum, n, dum, dum, cdum, cdum, cdum, &c_n1, &ierr); lwork_zgebrd_nn__ = (integer) cdum[0].r; zgeqrf_(m, n, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zgeqrf_mn__ = (integer) cdum[0].r; zungbr_("P", n, n, n, cdum, n, cdum, cdum, &c_n1, &ierr); lwork_zungbr_p_nn__ = (integer) cdum[0].r; zungbr_("Q", m, m, n, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zungbr_q_mm__ = (integer) cdum[0].r; zungbr_("Q", m, n, n, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zungbr_q_mn__ = (integer) cdum[0].r; zungqr_(m, m, n, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zungqr_mm__ = (integer) cdum[0].r; zungqr_(m, n, n, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zungqr_mn__ = (integer) cdum[0].r; zunmbr_("P", "R", "C", n, n, n, cdum, n, cdum, cdum, n, cdum, & c_n1, &ierr); lwork_zunmbr_prc_nn__ = (integer) cdum[0].r; zunmbr_("Q", "L", "N", m, m, n, cdum, m, cdum, cdum, m, cdum, & c_n1, &ierr); lwork_zunmbr_qln_mm__ = (integer) cdum[0].r; zunmbr_("Q", "L", "N", m, n, n, cdum, m, cdum, cdum, m, cdum, & c_n1, &ierr); lwork_zunmbr_qln_mn__ = (integer) cdum[0].r; zunmbr_("Q", "L", "N", n, n, n, cdum, n, cdum, cdum, n, cdum, & c_n1, &ierr); lwork_zunmbr_qln_nn__ = (integer) cdum[0].r; if (*m >= mnthr1) { if (wntqn) { /* Path 1 (M >> N, JOBZ='N') */ maxwrk = *n + lwork_zgeqrf_mn__; /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zgebrd_nn__; maxwrk = f2cmax(i__1,i__2); minwrk = *n * 3; } else if (wntqo) { /* Path 2 (M >> N, JOBZ='O') */ wrkbl = *n + lwork_zgeqrf_mn__; /* Computing MAX */ i__1 = wrkbl, i__2 = *n + lwork_zungqr_mn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zgebrd_nn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zunmbr_qln_nn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zunmbr_prc_nn__; wrkbl = f2cmax(i__1,i__2); maxwrk = *m * *n + *n * *n + wrkbl; minwrk = (*n << 1) * *n + *n * 3; } else if (wntqs) { /* Path 3 (M >> N, JOBZ='S') */ wrkbl = *n + lwork_zgeqrf_mn__; /* Computing MAX */ i__1 = wrkbl, i__2 = *n + lwork_zungqr_mn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zgebrd_nn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zunmbr_qln_nn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zunmbr_prc_nn__; wrkbl = f2cmax(i__1,i__2); maxwrk = *n * *n + wrkbl; minwrk = *n * *n + *n * 3; } else if (wntqa) { /* Path 4 (M >> N, JOBZ='A') */ wrkbl = *n + lwork_zgeqrf_mn__; /* Computing MAX */ i__1 = wrkbl, i__2 = *n + lwork_zungqr_mm__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zgebrd_nn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zunmbr_qln_nn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*n << 1) + lwork_zunmbr_prc_nn__; wrkbl = f2cmax(i__1,i__2); maxwrk = *n * *n + wrkbl; /* Computing MAX */ i__1 = *n * 3, i__2 = *n + *m; minwrk = *n * *n + f2cmax(i__1,i__2); } } else if (*m >= mnthr2) { /* Path 5 (M >> N, but not as much as MNTHR1) */ maxwrk = (*n << 1) + lwork_zgebrd_mn__; minwrk = (*n << 1) + *m; if (wntqo) { /* Path 5o (M >> N, JOBZ='O') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zungbr_p_nn__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zungbr_q_mn__; maxwrk = f2cmax(i__1,i__2); maxwrk += *m * *n; minwrk += *n * *n; } else if (wntqs) { /* Path 5s (M >> N, JOBZ='S') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zungbr_p_nn__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zungbr_q_mn__; maxwrk = f2cmax(i__1,i__2); } else if (wntqa) { /* Path 5a (M >> N, JOBZ='A') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zungbr_p_nn__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zungbr_q_mm__; maxwrk = f2cmax(i__1,i__2); } } else { /* Path 6 (M >= N, but not much larger) */ maxwrk = (*n << 1) + lwork_zgebrd_mn__; minwrk = (*n << 1) + *m; if (wntqo) { /* Path 6o (M >= N, JOBZ='O') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zunmbr_prc_nn__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zunmbr_qln_mn__; maxwrk = f2cmax(i__1,i__2); maxwrk += *m * *n; minwrk += *n * *n; } else if (wntqs) { /* Path 6s (M >= N, JOBZ='S') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zunmbr_qln_mn__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zunmbr_prc_nn__; maxwrk = f2cmax(i__1,i__2); } else if (wntqa) { /* Path 6a (M >= N, JOBZ='A') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zunmbr_qln_mm__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*n << 1) + lwork_zunmbr_prc_nn__; maxwrk = f2cmax(i__1,i__2); } } } else if (minmn > 0) { /* There is no complex work space needed for bidiagonal SVD */ /* The real work space needed for bidiagonal SVD (dbdsdc) is */ /* BDSPAC = 3*M*M + 4*M for singular values and vectors; */ /* BDSPAC = 4*M for singular values only; */ /* not including e, RU, and RVT matrices. */ /* Compute space preferred for each routine */ zgebrd_(m, n, cdum, m, dum, dum, cdum, cdum, cdum, &c_n1, &ierr); lwork_zgebrd_mn__ = (integer) cdum[0].r; zgebrd_(m, m, cdum, m, dum, dum, cdum, cdum, cdum, &c_n1, &ierr); lwork_zgebrd_mm__ = (integer) cdum[0].r; zgelqf_(m, n, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zgelqf_mn__ = (integer) cdum[0].r; zungbr_("P", m, n, m, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zungbr_p_mn__ = (integer) cdum[0].r; zungbr_("P", n, n, m, cdum, n, cdum, cdum, &c_n1, &ierr); lwork_zungbr_p_nn__ = (integer) cdum[0].r; zungbr_("Q", m, m, n, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zungbr_q_mm__ = (integer) cdum[0].r; zunglq_(m, n, m, cdum, m, cdum, cdum, &c_n1, &ierr); lwork_zunglq_mn__ = (integer) cdum[0].r; zunglq_(n, n, m, cdum, n, cdum, cdum, &c_n1, &ierr); lwork_zunglq_nn__ = (integer) cdum[0].r; zunmbr_("P", "R", "C", m, m, m, cdum, m, cdum, cdum, m, cdum, & c_n1, &ierr); lwork_zunmbr_prc_mm__ = (integer) cdum[0].r; zunmbr_("P", "R", "C", m, n, m, cdum, m, cdum, cdum, m, cdum, & c_n1, &ierr); lwork_zunmbr_prc_mn__ = (integer) cdum[0].r; zunmbr_("P", "R", "C", n, n, m, cdum, n, cdum, cdum, n, cdum, & c_n1, &ierr); lwork_zunmbr_prc_nn__ = (integer) cdum[0].r; zunmbr_("Q", "L", "N", m, m, m, cdum, m, cdum, cdum, m, cdum, & c_n1, &ierr); lwork_zunmbr_qln_mm__ = (integer) cdum[0].r; if (*n >= mnthr1) { if (wntqn) { /* Path 1t (N >> M, JOBZ='N') */ maxwrk = *m + lwork_zgelqf_mn__; /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zgebrd_mm__; maxwrk = f2cmax(i__1,i__2); minwrk = *m * 3; } else if (wntqo) { /* Path 2t (N >> M, JOBZ='O') */ wrkbl = *m + lwork_zgelqf_mn__; /* Computing MAX */ i__1 = wrkbl, i__2 = *m + lwork_zunglq_mn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zgebrd_mm__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zunmbr_qln_mm__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zunmbr_prc_mm__; wrkbl = f2cmax(i__1,i__2); maxwrk = *m * *n + *m * *m + wrkbl; minwrk = (*m << 1) * *m + *m * 3; } else if (wntqs) { /* Path 3t (N >> M, JOBZ='S') */ wrkbl = *m + lwork_zgelqf_mn__; /* Computing MAX */ i__1 = wrkbl, i__2 = *m + lwork_zunglq_mn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zgebrd_mm__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zunmbr_qln_mm__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zunmbr_prc_mm__; wrkbl = f2cmax(i__1,i__2); maxwrk = *m * *m + wrkbl; minwrk = *m * *m + *m * 3; } else if (wntqa) { /* Path 4t (N >> M, JOBZ='A') */ wrkbl = *m + lwork_zgelqf_mn__; /* Computing MAX */ i__1 = wrkbl, i__2 = *m + lwork_zunglq_nn__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zgebrd_mm__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zunmbr_qln_mm__; wrkbl = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = wrkbl, i__2 = (*m << 1) + lwork_zunmbr_prc_mm__; wrkbl = f2cmax(i__1,i__2); maxwrk = *m * *m + wrkbl; /* Computing MAX */ i__1 = *m * 3, i__2 = *m + *n; minwrk = *m * *m + f2cmax(i__1,i__2); } } else if (*n >= mnthr2) { /* Path 5t (N >> M, but not as much as MNTHR1) */ maxwrk = (*m << 1) + lwork_zgebrd_mn__; minwrk = (*m << 1) + *n; if (wntqo) { /* Path 5to (N >> M, JOBZ='O') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zungbr_q_mm__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zungbr_p_mn__; maxwrk = f2cmax(i__1,i__2); maxwrk += *m * *n; minwrk += *m * *m; } else if (wntqs) { /* Path 5ts (N >> M, JOBZ='S') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zungbr_q_mm__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zungbr_p_mn__; maxwrk = f2cmax(i__1,i__2); } else if (wntqa) { /* Path 5ta (N >> M, JOBZ='A') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zungbr_q_mm__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zungbr_p_nn__; maxwrk = f2cmax(i__1,i__2); } } else { /* Path 6t (N > M, but not much larger) */ maxwrk = (*m << 1) + lwork_zgebrd_mn__; minwrk = (*m << 1) + *n; if (wntqo) { /* Path 6to (N > M, JOBZ='O') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zunmbr_qln_mm__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zunmbr_prc_mn__; maxwrk = f2cmax(i__1,i__2); maxwrk += *m * *n; minwrk += *m * *m; } else if (wntqs) { /* Path 6ts (N > M, JOBZ='S') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zunmbr_qln_mm__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zunmbr_prc_mn__; maxwrk = f2cmax(i__1,i__2); } else if (wntqa) { /* Path 6ta (N > M, JOBZ='A') */ /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zunmbr_qln_mm__; maxwrk = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = maxwrk, i__2 = (*m << 1) + lwork_zunmbr_prc_nn__; maxwrk = f2cmax(i__1,i__2); } } } maxwrk = f2cmax(maxwrk,minwrk); } if (*info == 0) { work[1].r = (doublereal) maxwrk, work[1].i = 0.; if (*lwork < minwrk && ! lquery) { *info = -12; } } if (*info != 0) { i__1 = -(*info); xerbla_("ZGESDD", &i__1, (ftnlen)6); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ if (*m == 0 || *n == 0) { return 0; } /* Get machine constants */ eps = dlamch_("P"); smlnum = sqrt(dlamch_("S")) / eps; bignum = 1. / smlnum; /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */ anrm = zlange_("M", m, n, &a[a_offset], lda, dum); if (disnan_(&anrm)) { *info = -4; return 0; } iscl = 0; if (anrm > 0. && anrm < smlnum) { iscl = 1; zlascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, & ierr); } else if (anrm > bignum) { iscl = 1; zlascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, & ierr); } if (*m >= *n) { /* A has at least as many rows as columns. If A has sufficiently */ /* more rows than columns, first reduce using the QR */ /* decomposition (if sufficient workspace available) */ if (*m >= mnthr1) { if (wntqn) { /* Path 1 (M >> N, JOBZ='N') */ /* No singular vectors to be computed */ itau = 1; nwork = itau + *n; /* Compute A=Q*R */ /* CWorkspace: need N [tau] + N [work] */ /* CWorkspace: prefer N [tau] + N*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__1, &ierr); /* Zero out below R */ i__1 = *n - 1; i__2 = *n - 1; zlaset_("L", &i__1, &i__2, &c_b1, &c_b1, &a[a_dim1 + 2], lda); ie = 1; itauq = 1; itaup = itauq + *n; nwork = itaup + *n; /* Bidiagonalize R in A */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + 2*N*NB [work] */ /* RWorkspace: need N [e] */ i__1 = *lwork - nwork + 1; zgebrd_(n, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__1, &ierr); nrwork = ie + *n; /* Perform bidiagonal SVD, compute singular values only */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + BDSPAC */ dbdsdc_("U", "N", n, &s[1], &rwork[ie], dum, &c__1, dum, & c__1, dum, idum, &rwork[nrwork], &iwork[1], info); } else if (wntqo) { /* Path 2 (M >> N, JOBZ='O') */ /* N left singular vectors to be overwritten on A and */ /* N right singular vectors to be computed in VT */ iu = 1; /* WORK(IU) is N by N */ ldwrku = *n; ir = iu + ldwrku * *n; if (*lwork >= *m * *n + *n * *n + *n * 3) { /* WORK(IR) is M by N */ ldwrkr = *m; } else { ldwrkr = (*lwork - *n * *n - *n * 3) / *n; } itau = ir + ldwrkr * *n; nwork = itau + *n; /* Compute A=Q*R */ /* CWorkspace: need N*N [U] + N*N [R] + N [tau] + N [work] */ /* CWorkspace: prefer N*N [U] + N*N [R] + N [tau] + N*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__1, &ierr); /* Copy R to WORK( IR ), zeroing out below it */ zlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr); i__1 = *n - 1; i__2 = *n - 1; zlaset_("L", &i__1, &i__2, &c_b1, &c_b1, &work[ir + 1], & ldwrkr); /* Generate Q in A */ /* CWorkspace: need N*N [U] + N*N [R] + N [tau] + N [work] */ /* CWorkspace: prefer N*N [U] + N*N [R] + N [tau] + N*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zungqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork], &i__1, &ierr); ie = 1; itauq = itau; itaup = itauq + *n; nwork = itaup + *n; /* Bidiagonalize R in WORK(IR) */ /* CWorkspace: need N*N [U] + N*N [R] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [U] + N*N [R] + 2*N [tauq, taup] + 2*N*NB [work] */ /* RWorkspace: need N [e] */ i__1 = *lwork - nwork + 1; zgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__1, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of R in WORK(IRU) and computing right singular vectors */ /* of R in WORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ iru = ie + *n; irvt = iru + *n * *n; nrwork = irvt + *n * *n; dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix WORK(IU) */ /* Overwrite WORK(IU) by the left singular vectors of R */ /* CWorkspace: need N*N [U] + N*N [R] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [U] + N*N [R] + 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", n, n, &rwork[iru], n, &work[iu], &ldwrku); i__1 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[ itauq], &work[iu], &ldwrku, &work[nwork], &i__1, & ierr); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by the right singular vectors of R */ /* CWorkspace: need N*N [U] + N*N [R] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [U] + N*N [R] + 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt); i__1 = *lwork - nwork + 1; zunmbr_("P", "R", "C", n, n, n, &work[ir], &ldwrkr, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & ierr); /* Multiply Q in A by left singular vectors of R in */ /* WORK(IU), storing result in WORK(IR) and copying to A */ /* CWorkspace: need N*N [U] + N*N [R] */ /* CWorkspace: prefer N*N [U] + M*N [R] */ /* RWorkspace: need 0 */ i__1 = *m; i__2 = ldwrkr; for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { /* Computing MIN */ i__3 = *m - i__ + 1; chunk = f2cmin(i__3,ldwrkr); zgemm_("N", "N", &chunk, n, n, &c_b2, &a[i__ + a_dim1], lda, &work[iu], &ldwrku, &c_b1, &work[ir], & ldwrkr); zlacpy_("F", &chunk, n, &work[ir], &ldwrkr, &a[i__ + a_dim1], lda); /* L10: */ } } else if (wntqs) { /* Path 3 (M >> N, JOBZ='S') */ /* N left singular vectors to be computed in U and */ /* N right singular vectors to be computed in VT */ ir = 1; /* WORK(IR) is N by N */ ldwrkr = *n; itau = ir + ldwrkr * *n; nwork = itau + *n; /* Compute A=Q*R */ /* CWorkspace: need N*N [R] + N [tau] + N [work] */ /* CWorkspace: prefer N*N [R] + N [tau] + N*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__2, &ierr); /* Copy R to WORK(IR), zeroing out below it */ zlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr); i__2 = *n - 1; i__1 = *n - 1; zlaset_("L", &i__2, &i__1, &c_b1, &c_b1, &work[ir + 1], & ldwrkr); /* Generate Q in A */ /* CWorkspace: need N*N [R] + N [tau] + N [work] */ /* CWorkspace: prefer N*N [R] + N [tau] + N*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zungqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork], &i__2, &ierr); ie = 1; itauq = itau; itaup = itauq + *n; nwork = itaup + *n; /* Bidiagonalize R in WORK(IR) */ /* CWorkspace: need N*N [R] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [R] + 2*N [tauq, taup] + 2*N*NB [work] */ /* RWorkspace: need N [e] */ i__2 = *lwork - nwork + 1; zgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__2, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ iru = ie + *n; irvt = iru + *n * *n; nrwork = irvt + *n * *n; dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of R */ /* CWorkspace: need N*N [R] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [R] + 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", n, n, &rwork[iru], n, &u[u_offset], ldu); i__2 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by right singular vectors of R */ /* CWorkspace: need N*N [R] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [R] + 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt); i__2 = *lwork - nwork + 1; zunmbr_("P", "R", "C", n, n, n, &work[ir], &ldwrkr, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & ierr); /* Multiply Q in A by left singular vectors of R in */ /* WORK(IR), storing result in U */ /* CWorkspace: need N*N [R] */ /* RWorkspace: need 0 */ zlacpy_("F", n, n, &u[u_offset], ldu, &work[ir], &ldwrkr); zgemm_("N", "N", m, n, n, &c_b2, &a[a_offset], lda, &work[ir], &ldwrkr, &c_b1, &u[u_offset], ldu); } else if (wntqa) { /* Path 4 (M >> N, JOBZ='A') */ /* M left singular vectors to be computed in U and */ /* N right singular vectors to be computed in VT */ iu = 1; /* WORK(IU) is N by N */ ldwrku = *n; itau = iu + ldwrku * *n; nwork = itau + *n; /* Compute A=Q*R, copying result to U */ /* CWorkspace: need N*N [U] + N [tau] + N [work] */ /* CWorkspace: prefer N*N [U] + N [tau] + N*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__2, &ierr); zlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu); /* Generate Q in U */ /* CWorkspace: need N*N [U] + N [tau] + M [work] */ /* CWorkspace: prefer N*N [U] + N [tau] + M*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zungqr_(m, m, n, &u[u_offset], ldu, &work[itau], &work[nwork], &i__2, &ierr); /* Produce R in A, zeroing out below it */ i__2 = *n - 1; i__1 = *n - 1; zlaset_("L", &i__2, &i__1, &c_b1, &c_b1, &a[a_dim1 + 2], lda); ie = 1; itauq = itau; itaup = itauq + *n; nwork = itaup + *n; /* Bidiagonalize R in A */ /* CWorkspace: need N*N [U] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [U] + 2*N [tauq, taup] + 2*N*NB [work] */ /* RWorkspace: need N [e] */ i__2 = *lwork - nwork + 1; zgebrd_(n, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__2, &ierr); iru = ie + *n; irvt = iru + *n * *n; nrwork = irvt + *n * *n; /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix WORK(IU) */ /* Overwrite WORK(IU) by left singular vectors of R */ /* CWorkspace: need N*N [U] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [U] + 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", n, n, &rwork[iru], n, &work[iu], &ldwrku); i__2 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", n, n, n, &a[a_offset], lda, &work[ itauq], &work[iu], &ldwrku, &work[nwork], &i__2, & ierr); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by right singular vectors of R */ /* CWorkspace: need N*N [U] + 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer N*N [U] + 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt); i__2 = *lwork - nwork + 1; zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & ierr); /* Multiply Q in U by left singular vectors of R in */ /* WORK(IU), storing result in A */ /* CWorkspace: need N*N [U] */ /* RWorkspace: need 0 */ zgemm_("N", "N", m, n, n, &c_b2, &u[u_offset], ldu, &work[iu], &ldwrku, &c_b1, &a[a_offset], lda); /* Copy left singular vectors of A from A to U */ zlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset], ldu); } } else if (*m >= mnthr2) { /* MNTHR2 <= M < MNTHR1 */ /* Path 5 (M >> N, but not as much as MNTHR1) */ /* Reduce to bidiagonal form without QR decomposition, use */ /* ZUNGBR and matrix multiplication to compute singular vectors */ ie = 1; nrwork = ie + *n; itauq = 1; itaup = itauq + *n; nwork = itaup + *n; /* Bidiagonalize A */ /* CWorkspace: need 2*N [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + (M+N)*NB [work] */ /* RWorkspace: need N [e] */ i__2 = *lwork - nwork + 1; zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq], &work[itaup], &work[nwork], &i__2, &ierr); if (wntqn) { /* Path 5n (M >> N, JOBZ='N') */ /* Compute singular values only */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + BDSPAC */ dbdsdc_("U", "N", n, &s[1], &rwork[ie], dum, &c__1, dum, & c__1, dum, idum, &rwork[nrwork], &iwork[1], info); } else if (wntqo) { iu = nwork; iru = nrwork; irvt = iru + *n * *n; nrwork = irvt + *n * *n; /* Path 5o (M >> N, JOBZ='O') */ /* Copy A to VT, generate P**H */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt); i__2 = *lwork - nwork + 1; zungbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], & work[nwork], &i__2, &ierr); /* Generate Q in A */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zungbr_("Q", m, n, n, &a[a_offset], lda, &work[itauq], &work[ nwork], &i__2, &ierr); if (*lwork >= *m * *n + *n * 3) { /* WORK( IU ) is M by N */ ldwrku = *m; } else { /* WORK(IU) is LDWRKU by N */ ldwrku = (*lwork - *n * 3) / *n; } nwork = iu + ldwrku * *n; /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Multiply real matrix RWORK(IRVT) by P**H in VT, */ /* storing the result in WORK(IU), copying to VT */ /* CWorkspace: need 2*N [tauq, taup] + N*N [U] */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + 2*N*N [rwork] */ zlarcm_(n, n, &rwork[irvt], n, &vt[vt_offset], ldvt, &work[iu] , &ldwrku, &rwork[nrwork]); zlacpy_("F", n, n, &work[iu], &ldwrku, &vt[vt_offset], ldvt); /* Multiply Q in A by real matrix RWORK(IRU), storing the */ /* result in WORK(IU), copying to A */ /* CWorkspace: need 2*N [tauq, taup] + N*N [U] */ /* CWorkspace: prefer 2*N [tauq, taup] + M*N [U] */ /* RWorkspace: need N [e] + N*N [RU] + 2*N*N [rwork] */ /* RWorkspace: prefer N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here */ nrwork = irvt; i__2 = *m; i__1 = ldwrku; for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) { /* Computing MIN */ i__3 = *m - i__ + 1; chunk = f2cmin(i__3,ldwrku); zlacrm_(&chunk, n, &a[i__ + a_dim1], lda, &rwork[iru], n, &work[iu], &ldwrku, &rwork[nrwork]); zlacpy_("F", &chunk, n, &work[iu], &ldwrku, &a[i__ + a_dim1], lda); /* L20: */ } } else if (wntqs) { /* Path 5s (M >> N, JOBZ='S') */ /* Copy A to VT, generate P**H */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt); i__1 = *lwork - nwork + 1; zungbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], & work[nwork], &i__1, &ierr); /* Copy A to U, generate Q */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu); i__1 = *lwork - nwork + 1; zungbr_("Q", m, n, n, &u[u_offset], ldu, &work[itauq], &work[ nwork], &i__1, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ iru = nrwork; irvt = iru + *n * *n; nrwork = irvt + *n * *n; dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Multiply real matrix RWORK(IRVT) by P**H in VT, */ /* storing the result in A, copying to VT */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + 2*N*N [rwork] */ zlarcm_(n, n, &rwork[irvt], n, &vt[vt_offset], ldvt, &a[ a_offset], lda, &rwork[nrwork]); zlacpy_("F", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt); /* Multiply Q in U by real matrix RWORK(IRU), storing the */ /* result in A, copying to U */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here */ nrwork = irvt; zlacrm_(m, n, &u[u_offset], ldu, &rwork[iru], n, &a[a_offset], lda, &rwork[nrwork]); zlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset], ldu); } else { /* Path 5a (M >> N, JOBZ='A') */ /* Copy A to VT, generate P**H */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt); i__1 = *lwork - nwork + 1; zungbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], & work[nwork], &i__1, &ierr); /* Copy A to U, generate Q */ /* CWorkspace: need 2*N [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu); i__1 = *lwork - nwork + 1; zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[ nwork], &i__1, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ iru = nrwork; irvt = iru + *n * *n; nrwork = irvt + *n * *n; dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Multiply real matrix RWORK(IRVT) by P**H in VT, */ /* storing the result in A, copying to VT */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + 2*N*N [rwork] */ zlarcm_(n, n, &rwork[irvt], n, &vt[vt_offset], ldvt, &a[ a_offset], lda, &rwork[nrwork]); zlacpy_("F", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt); /* Multiply Q in U by real matrix RWORK(IRU), storing the */ /* result in A, copying to U */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here */ nrwork = irvt; zlacrm_(m, n, &u[u_offset], ldu, &rwork[iru], n, &a[a_offset], lda, &rwork[nrwork]); zlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset], ldu); } } else { /* M .LT. MNTHR2 */ /* Path 6 (M >= N, but not much larger) */ /* Reduce to bidiagonal form without QR decomposition */ /* Use ZUNMBR to compute singular vectors */ ie = 1; nrwork = ie + *n; itauq = 1; itaup = itauq + *n; nwork = itaup + *n; /* Bidiagonalize A */ /* CWorkspace: need 2*N [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + (M+N)*NB [work] */ /* RWorkspace: need N [e] */ i__1 = *lwork - nwork + 1; zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq], &work[itaup], &work[nwork], &i__1, &ierr); if (wntqn) { /* Path 6n (M >= N, JOBZ='N') */ /* Compute singular values only */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + BDSPAC */ dbdsdc_("U", "N", n, &s[1], &rwork[ie], dum, &c__1, dum, & c__1, dum, idum, &rwork[nrwork], &iwork[1], info); } else if (wntqo) { iu = nwork; iru = nrwork; irvt = iru + *n * *n; nrwork = irvt + *n * *n; if (*lwork >= *m * *n + *n * 3) { /* WORK( IU ) is M by N */ ldwrku = *m; } else { /* WORK( IU ) is LDWRKU by N */ ldwrku = (*lwork - *n * 3) / *n; } nwork = iu + ldwrku * *n; /* Path 6o (M >= N, JOBZ='O') */ /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by right singular vectors of A */ /* CWorkspace: need 2*N [tauq, taup] + N*N [U] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*N [U] + N*NB [work] */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] */ zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt); i__1 = *lwork - nwork + 1; zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & ierr); if (*lwork >= *m * *n + *n * 3) { /* Path 6o-fast */ /* Copy real matrix RWORK(IRU) to complex matrix WORK(IU) */ /* Overwrite WORK(IU) by left singular vectors of A, copying */ /* to A */ /* CWorkspace: need 2*N [tauq, taup] + M*N [U] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + M*N [U] + N*NB [work] */ /* RWorkspace: need N [e] + N*N [RU] */ zlaset_("F", m, n, &c_b1, &c_b1, &work[iu], &ldwrku); zlacp2_("F", n, n, &rwork[iru], n, &work[iu], &ldwrku); i__1 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[ itauq], &work[iu], &ldwrku, &work[nwork], &i__1, & ierr); zlacpy_("F", m, n, &work[iu], &ldwrku, &a[a_offset], lda); } else { /* Path 6o-slow */ /* Generate Q in A */ /* CWorkspace: need 2*N [tauq, taup] + N*N [U] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*N [U] + N*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zungbr_("Q", m, n, n, &a[a_offset], lda, &work[itauq], & work[nwork], &i__1, &ierr); /* Multiply Q in A by real matrix RWORK(IRU), storing the */ /* result in WORK(IU), copying to A */ /* CWorkspace: need 2*N [tauq, taup] + N*N [U] */ /* CWorkspace: prefer 2*N [tauq, taup] + M*N [U] */ /* RWorkspace: need N [e] + N*N [RU] + 2*N*N [rwork] */ /* RWorkspace: prefer N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here */ nrwork = irvt; i__1 = *m; i__2 = ldwrku; for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { /* Computing MIN */ i__3 = *m - i__ + 1; chunk = f2cmin(i__3,ldwrku); zlacrm_(&chunk, n, &a[i__ + a_dim1], lda, &rwork[iru], n, &work[iu], &ldwrku, &rwork[nrwork]); zlacpy_("F", &chunk, n, &work[iu], &ldwrku, &a[i__ + a_dim1], lda); /* L30: */ } } } else if (wntqs) { /* Path 6s (M >= N, JOBZ='S') */ /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ iru = nrwork; irvt = iru + *n * *n; nrwork = irvt + *n * *n; dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of A */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] */ zlaset_("F", m, n, &c_b1, &c_b1, &u[u_offset], ldu) ; zlacp2_("F", n, n, &rwork[iru], n, &u[u_offset], ldu); i__2 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by right singular vectors of A */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] */ zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt); i__2 = *lwork - nwork + 1; zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & ierr); } else { /* Path 6a (M >= N, JOBZ='A') */ /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC */ iru = nrwork; irvt = iru + *n * *n; nrwork = irvt + *n * *n; dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, & rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1], info); /* Set the right corner of U to identity matrix */ zlaset_("F", m, m, &c_b1, &c_b1, &u[u_offset], ldu) ; if (*m > *n) { i__2 = *m - *n; i__1 = *m - *n; zlaset_("F", &i__2, &i__1, &c_b1, &c_b2, &u[*n + 1 + (*n + 1) * u_dim1], ldu); } /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of A */ /* CWorkspace: need 2*N [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + M*NB [work] */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] */ zlacp2_("F", n, n, &rwork[iru], n, &u[u_offset], ldu); i__2 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by right singular vectors of A */ /* CWorkspace: need 2*N [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work] */ /* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] */ zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt); i__2 = *lwork - nwork + 1; zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & ierr); } } } else { /* A has more columns than rows. If A has sufficiently more */ /* columns than rows, first reduce using the LQ decomposition (if */ /* sufficient workspace available) */ if (*n >= mnthr1) { if (wntqn) { /* Path 1t (N >> M, JOBZ='N') */ /* No singular vectors to be computed */ itau = 1; nwork = itau + *m; /* Compute A=L*Q */ /* CWorkspace: need M [tau] + M [work] */ /* CWorkspace: prefer M [tau] + M*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__2, &ierr); /* Zero out above L */ i__2 = *m - 1; i__1 = *m - 1; zlaset_("U", &i__2, &i__1, &c_b1, &c_b1, &a[(a_dim1 << 1) + 1] , lda); ie = 1; itauq = 1; itaup = itauq + *m; nwork = itaup + *m; /* Bidiagonalize L in A */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + 2*M*NB [work] */ /* RWorkspace: need M [e] */ i__2 = *lwork - nwork + 1; zgebrd_(m, m, &a[a_offset], lda, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__2, &ierr); nrwork = ie + *m; /* Perform bidiagonal SVD, compute singular values only */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + BDSPAC */ dbdsdc_("U", "N", m, &s[1], &rwork[ie], dum, &c__1, dum, & c__1, dum, idum, &rwork[nrwork], &iwork[1], info); } else if (wntqo) { /* Path 2t (N >> M, JOBZ='O') */ /* M right singular vectors to be overwritten on A and */ /* M left singular vectors to be computed in U */ ivt = 1; ldwkvt = *m; /* WORK(IVT) is M by M */ il = ivt + ldwkvt * *m; if (*lwork >= *m * *n + *m * *m + *m * 3) { /* WORK(IL) M by N */ ldwrkl = *m; chunk = *n; } else { /* WORK(IL) is M by CHUNK */ ldwrkl = *m; chunk = (*lwork - *m * *m - *m * 3) / *m; } itau = il + ldwrkl * chunk; nwork = itau + *m; /* Compute A=L*Q */ /* CWorkspace: need M*M [VT] + M*M [L] + M [tau] + M [work] */ /* CWorkspace: prefer M*M [VT] + M*M [L] + M [tau] + M*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__2, &ierr); /* Copy L to WORK(IL), zeroing about above it */ zlacpy_("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl); i__2 = *m - 1; i__1 = *m - 1; zlaset_("U", &i__2, &i__1, &c_b1, &c_b1, &work[il + ldwrkl], & ldwrkl); /* Generate Q in A */ /* CWorkspace: need M*M [VT] + M*M [L] + M [tau] + M [work] */ /* CWorkspace: prefer M*M [VT] + M*M [L] + M [tau] + M*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zunglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork], &i__2, &ierr); ie = 1; itauq = itau; itaup = itauq + *m; nwork = itaup + *m; /* Bidiagonalize L in WORK(IL) */ /* CWorkspace: need M*M [VT] + M*M [L] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [VT] + M*M [L] + 2*M [tauq, taup] + 2*M*NB [work] */ /* RWorkspace: need M [e] */ i__2 = *lwork - nwork + 1; zgebrd_(m, m, &work[il], &ldwrkl, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__2, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RU] + M*M [RVT] + BDSPAC */ iru = ie + *m; irvt = iru + *m * *m; nrwork = irvt + *m * *m; dbdsdc_("U", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix WORK(IU) */ /* Overwrite WORK(IU) by the left singular vectors of L */ /* CWorkspace: need M*M [VT] + M*M [L] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [VT] + M*M [L] + 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu); i__2 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); /* Copy real matrix RWORK(IRVT) to complex matrix WORK(IVT) */ /* Overwrite WORK(IVT) by the right singular vectors of L */ /* CWorkspace: need M*M [VT] + M*M [L] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [VT] + M*M [L] + 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", m, m, &rwork[irvt], m, &work[ivt], &ldwkvt); i__2 = *lwork - nwork + 1; zunmbr_("P", "R", "C", m, m, m, &work[il], &ldwrkl, &work[ itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2, & ierr); /* Multiply right singular vectors of L in WORK(IL) by Q */ /* in A, storing result in WORK(IL) and copying to A */ /* CWorkspace: need M*M [VT] + M*M [L] */ /* CWorkspace: prefer M*M [VT] + M*N [L] */ /* RWorkspace: need 0 */ i__2 = *n; i__1 = chunk; for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) { /* Computing MIN */ i__3 = *n - i__ + 1; blk = f2cmin(i__3,chunk); zgemm_("N", "N", m, &blk, m, &c_b2, &work[ivt], m, &a[i__ * a_dim1 + 1], lda, &c_b1, &work[il], &ldwrkl); zlacpy_("F", m, &blk, &work[il], &ldwrkl, &a[i__ * a_dim1 + 1], lda); /* L40: */ } } else if (wntqs) { /* Path 3t (N >> M, JOBZ='S') */ /* M right singular vectors to be computed in VT and */ /* M left singular vectors to be computed in U */ il = 1; /* WORK(IL) is M by M */ ldwrkl = *m; itau = il + ldwrkl * *m; nwork = itau + *m; /* Compute A=L*Q */ /* CWorkspace: need M*M [L] + M [tau] + M [work] */ /* CWorkspace: prefer M*M [L] + M [tau] + M*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__1, &ierr); /* Copy L to WORK(IL), zeroing out above it */ zlacpy_("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl); i__1 = *m - 1; i__2 = *m - 1; zlaset_("U", &i__1, &i__2, &c_b1, &c_b1, &work[il + ldwrkl], & ldwrkl); /* Generate Q in A */ /* CWorkspace: need M*M [L] + M [tau] + M [work] */ /* CWorkspace: prefer M*M [L] + M [tau] + M*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zunglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork], &i__1, &ierr); ie = 1; itauq = itau; itaup = itauq + *m; nwork = itaup + *m; /* Bidiagonalize L in WORK(IL) */ /* CWorkspace: need M*M [L] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [L] + 2*M [tauq, taup] + 2*M*NB [work] */ /* RWorkspace: need M [e] */ i__1 = *lwork - nwork + 1; zgebrd_(m, m, &work[il], &ldwrkl, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__1, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RU] + M*M [RVT] + BDSPAC */ iru = ie + *m; irvt = iru + *m * *m; nrwork = irvt + *m * *m; dbdsdc_("U", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of L */ /* CWorkspace: need M*M [L] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [L] + 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu); i__1 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by left singular vectors of L */ /* CWorkspace: need M*M [L] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [L] + 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", m, m, &rwork[irvt], m, &vt[vt_offset], ldvt); i__1 = *lwork - nwork + 1; zunmbr_("P", "R", "C", m, m, m, &work[il], &ldwrkl, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & ierr); /* Copy VT to WORK(IL), multiply right singular vectors of L */ /* in WORK(IL) by Q in A, storing result in VT */ /* CWorkspace: need M*M [L] */ /* RWorkspace: need 0 */ zlacpy_("F", m, m, &vt[vt_offset], ldvt, &work[il], &ldwrkl); zgemm_("N", "N", m, n, m, &c_b2, &work[il], &ldwrkl, &a[ a_offset], lda, &c_b1, &vt[vt_offset], ldvt); } else if (wntqa) { /* Path 4t (N >> M, JOBZ='A') */ /* N right singular vectors to be computed in VT and */ /* M left singular vectors to be computed in U */ ivt = 1; /* WORK(IVT) is M by M */ ldwkvt = *m; itau = ivt + ldwkvt * *m; nwork = itau + *m; /* Compute A=L*Q, copying result to VT */ /* CWorkspace: need M*M [VT] + M [tau] + M [work] */ /* CWorkspace: prefer M*M [VT] + M [tau] + M*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & i__1, &ierr); zlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); /* Generate Q in VT */ /* CWorkspace: need M*M [VT] + M [tau] + N [work] */ /* CWorkspace: prefer M*M [VT] + M [tau] + N*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zunglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &work[ nwork], &i__1, &ierr); /* Produce L in A, zeroing out above it */ i__1 = *m - 1; i__2 = *m - 1; zlaset_("U", &i__1, &i__2, &c_b1, &c_b1, &a[(a_dim1 << 1) + 1] , lda); ie = 1; itauq = itau; itaup = itauq + *m; nwork = itaup + *m; /* Bidiagonalize L in A */ /* CWorkspace: need M*M [VT] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [VT] + 2*M [tauq, taup] + 2*M*NB [work] */ /* RWorkspace: need M [e] */ i__1 = *lwork - nwork + 1; zgebrd_(m, m, &a[a_offset], lda, &s[1], &rwork[ie], &work[ itauq], &work[itaup], &work[nwork], &i__1, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RU] + M*M [RVT] + BDSPAC */ iru = ie + *m; irvt = iru + *m * *m; nrwork = irvt + *m * *m; dbdsdc_("U", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of L */ /* CWorkspace: need M*M [VT] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [VT] + 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu); i__1 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, m, m, &a[a_offset], lda, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); /* Copy real matrix RWORK(IRVT) to complex matrix WORK(IVT) */ /* Overwrite WORK(IVT) by right singular vectors of L */ /* CWorkspace: need M*M [VT] + 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer M*M [VT] + 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacp2_("F", m, m, &rwork[irvt], m, &work[ivt], &ldwkvt); i__1 = *lwork - nwork + 1; zunmbr_("P", "R", "C", m, m, m, &a[a_offset], lda, &work[ itaup], &work[ivt], &ldwkvt, &work[nwork], &i__1, & ierr); /* Multiply right singular vectors of L in WORK(IVT) by */ /* Q in VT, storing result in A */ /* CWorkspace: need M*M [VT] */ /* RWorkspace: need 0 */ zgemm_("N", "N", m, n, m, &c_b2, &work[ivt], &ldwkvt, &vt[ vt_offset], ldvt, &c_b1, &a[a_offset], lda); /* Copy right singular vectors of A from A to VT */ zlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); } } else if (*n >= mnthr2) { /* MNTHR2 <= N < MNTHR1 */ /* Path 5t (N >> M, but not as much as MNTHR1) */ /* Reduce to bidiagonal form without QR decomposition, use */ /* ZUNGBR and matrix multiplication to compute singular vectors */ ie = 1; nrwork = ie + *m; itauq = 1; itaup = itauq + *m; nwork = itaup + *m; /* Bidiagonalize A */ /* CWorkspace: need 2*M [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + (M+N)*NB [work] */ /* RWorkspace: need M [e] */ i__1 = *lwork - nwork + 1; zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq], &work[itaup], &work[nwork], &i__1, &ierr); if (wntqn) { /* Path 5tn (N >> M, JOBZ='N') */ /* Compute singular values only */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + BDSPAC */ dbdsdc_("L", "N", m, &s[1], &rwork[ie], dum, &c__1, dum, & c__1, dum, idum, &rwork[nrwork], &iwork[1], info); } else if (wntqo) { irvt = nrwork; iru = irvt + *m * *m; nrwork = iru + *m * *m; ivt = nwork; /* Path 5to (N >> M, JOBZ='O') */ /* Copy A to U, generate Q */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu); i__1 = *lwork - nwork + 1; zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[ nwork], &i__1, &ierr); /* Generate P**H in A */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ i__1 = *lwork - nwork + 1; zungbr_("P", m, n, m, &a[a_offset], lda, &work[itaup], &work[ nwork], &i__1, &ierr); ldwkvt = *m; if (*lwork >= *m * *n + *m * 3) { /* WORK( IVT ) is M by N */ nwork = ivt + ldwkvt * *n; chunk = *n; } else { /* WORK( IVT ) is M by CHUNK */ chunk = (*lwork - *m * 3) / *m; nwork = ivt + ldwkvt * chunk; } /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC */ dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Multiply Q in U by real matrix RWORK(IRVT) */ /* storing the result in WORK(IVT), copying to U */ /* CWorkspace: need 2*M [tauq, taup] + M*M [VT] */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + 2*M*M [rwork] */ zlacrm_(m, m, &u[u_offset], ldu, &rwork[iru], m, &work[ivt], & ldwkvt, &rwork[nrwork]); zlacpy_("F", m, m, &work[ivt], &ldwkvt, &u[u_offset], ldu); /* Multiply RWORK(IRVT) by P**H in A, storing the */ /* result in WORK(IVT), copying to A */ /* CWorkspace: need 2*M [tauq, taup] + M*M [VT] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*N [VT] */ /* RWorkspace: need M [e] + M*M [RVT] + 2*M*M [rwork] */ /* RWorkspace: prefer M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here */ nrwork = iru; i__1 = *n; i__2 = chunk; for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { /* Computing MIN */ i__3 = *n - i__ + 1; blk = f2cmin(i__3,chunk); zlarcm_(m, &blk, &rwork[irvt], m, &a[i__ * a_dim1 + 1], lda, &work[ivt], &ldwkvt, &rwork[nrwork]); zlacpy_("F", m, &blk, &work[ivt], &ldwkvt, &a[i__ * a_dim1 + 1], lda); /* L50: */ } } else if (wntqs) { /* Path 5ts (N >> M, JOBZ='S') */ /* Copy A to U, generate Q */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu); i__2 = *lwork - nwork + 1; zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[ nwork], &i__2, &ierr); /* Copy A to VT, generate P**H */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); i__2 = *lwork - nwork + 1; zungbr_("P", m, n, m, &vt[vt_offset], ldvt, &work[itaup], & work[nwork], &i__2, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC */ irvt = nrwork; iru = irvt + *m * *m; nrwork = iru + *m * *m; dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Multiply Q in U by real matrix RWORK(IRU), storing the */ /* result in A, copying to U */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + 2*M*M [rwork] */ zlacrm_(m, m, &u[u_offset], ldu, &rwork[iru], m, &a[a_offset], lda, &rwork[nrwork]); zlacpy_("F", m, m, &a[a_offset], lda, &u[u_offset], ldu); /* Multiply real matrix RWORK(IRVT) by P**H in VT, */ /* storing the result in A, copying to VT */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here */ nrwork = iru; zlarcm_(m, n, &rwork[irvt], m, &vt[vt_offset], ldvt, &a[ a_offset], lda, &rwork[nrwork]); zlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); } else { /* Path 5ta (N >> M, JOBZ='A') */ /* Copy A to U, generate Q */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu); i__2 = *lwork - nwork + 1; zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[ nwork], &i__2, &ierr); /* Copy A to VT, generate P**H */ /* CWorkspace: need 2*M [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + N*NB [work] */ /* RWorkspace: need 0 */ zlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); i__2 = *lwork - nwork + 1; zungbr_("P", n, n, m, &vt[vt_offset], ldvt, &work[itaup], & work[nwork], &i__2, &ierr); /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC */ irvt = nrwork; iru = irvt + *m * *m; nrwork = iru + *m * *m; dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Multiply Q in U by real matrix RWORK(IRU), storing the */ /* result in A, copying to U */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + 2*M*M [rwork] */ zlacrm_(m, m, &u[u_offset], ldu, &rwork[iru], m, &a[a_offset], lda, &rwork[nrwork]); zlacpy_("F", m, m, &a[a_offset], lda, &u[u_offset], ldu); /* Multiply real matrix RWORK(IRVT) by P**H in VT, */ /* storing the result in A, copying to VT */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here */ nrwork = iru; zlarcm_(m, n, &rwork[irvt], m, &vt[vt_offset], ldvt, &a[ a_offset], lda, &rwork[nrwork]); zlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); } } else { /* N .LT. MNTHR2 */ /* Path 6t (N > M, but not much larger) */ /* Reduce to bidiagonal form without LQ decomposition */ /* Use ZUNMBR to compute singular vectors */ ie = 1; nrwork = ie + *m; itauq = 1; itaup = itauq + *m; nwork = itaup + *m; /* Bidiagonalize A */ /* CWorkspace: need 2*M [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + (M+N)*NB [work] */ /* RWorkspace: need M [e] */ i__2 = *lwork - nwork + 1; zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq], &work[itaup], &work[nwork], &i__2, &ierr); if (wntqn) { /* Path 6tn (N > M, JOBZ='N') */ /* Compute singular values only */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + BDSPAC */ dbdsdc_("L", "N", m, &s[1], &rwork[ie], dum, &c__1, dum, & c__1, dum, idum, &rwork[nrwork], &iwork[1], info); } else if (wntqo) { /* Path 6to (N > M, JOBZ='O') */ ldwkvt = *m; ivt = nwork; if (*lwork >= *m * *n + *m * 3) { /* WORK( IVT ) is M by N */ zlaset_("F", m, n, &c_b1, &c_b1, &work[ivt], &ldwkvt); nwork = ivt + ldwkvt * *n; } else { /* WORK( IVT ) is M by CHUNK */ chunk = (*lwork - *m * 3) / *m; nwork = ivt + ldwkvt * chunk; } /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC */ irvt = nrwork; iru = irvt + *m * *m; nrwork = iru + *m * *m; dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of A */ /* CWorkspace: need 2*M [tauq, taup] + M*M [VT] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*M [VT] + M*NB [work] */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] */ zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu); i__2 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); if (*lwork >= *m * *n + *m * 3) { /* Path 6to-fast */ /* Copy real matrix RWORK(IRVT) to complex matrix WORK(IVT) */ /* Overwrite WORK(IVT) by right singular vectors of A, */ /* copying to A */ /* CWorkspace: need 2*M [tauq, taup] + M*N [VT] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*N [VT] + M*NB [work] */ /* RWorkspace: need M [e] + M*M [RVT] */ zlacp2_("F", m, m, &rwork[irvt], m, &work[ivt], &ldwkvt); i__2 = *lwork - nwork + 1; zunmbr_("P", "R", "C", m, n, m, &a[a_offset], lda, &work[ itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2, &ierr); zlacpy_("F", m, n, &work[ivt], &ldwkvt, &a[a_offset], lda); } else { /* Path 6to-slow */ /* Generate P**H in A */ /* CWorkspace: need 2*M [tauq, taup] + M*M [VT] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*M [VT] + M*NB [work] */ /* RWorkspace: need 0 */ i__2 = *lwork - nwork + 1; zungbr_("P", m, n, m, &a[a_offset], lda, &work[itaup], & work[nwork], &i__2, &ierr); /* Multiply Q in A by real matrix RWORK(IRU), storing the */ /* result in WORK(IU), copying to A */ /* CWorkspace: need 2*M [tauq, taup] + M*M [VT] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*N [VT] */ /* RWorkspace: need M [e] + M*M [RVT] + 2*M*M [rwork] */ /* RWorkspace: prefer M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here */ nrwork = iru; i__2 = *n; i__1 = chunk; for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) { /* Computing MIN */ i__3 = *n - i__ + 1; blk = f2cmin(i__3,chunk); zlarcm_(m, &blk, &rwork[irvt], m, &a[i__ * a_dim1 + 1] , lda, &work[ivt], &ldwkvt, &rwork[nrwork]); zlacpy_("F", m, &blk, &work[ivt], &ldwkvt, &a[i__ * a_dim1 + 1], lda); /* L60: */ } } } else if (wntqs) { /* Path 6ts (N > M, JOBZ='S') */ /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC */ irvt = nrwork; iru = irvt + *m * *m; nrwork = iru + *m * *m; dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of A */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] */ zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu); i__1 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by right singular vectors of A */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need M [e] + M*M [RVT] */ zlaset_("F", m, n, &c_b1, &c_b1, &vt[vt_offset], ldvt); zlacp2_("F", m, m, &rwork[irvt], m, &vt[vt_offset], ldvt); i__1 = *lwork - nwork + 1; zunmbr_("P", "R", "C", m, n, m, &a[a_offset], lda, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & ierr); } else { /* Path 6ta (N > M, JOBZ='A') */ /* Perform bidiagonal SVD, computing left singular vectors */ /* of bidiagonal matrix in RWORK(IRU) and computing right */ /* singular vectors of bidiagonal matrix in RWORK(IRVT) */ /* CWorkspace: need 0 */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC */ irvt = nrwork; iru = irvt + *m * *m; nrwork = iru + *m * *m; dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, & rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1], info); /* Copy real matrix RWORK(IRU) to complex matrix U */ /* Overwrite U by left singular vectors of A */ /* CWorkspace: need 2*M [tauq, taup] + M [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work] */ /* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] */ zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu); i__1 = *lwork - nwork + 1; zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); /* Set all of VT to identity matrix */ zlaset_("F", n, n, &c_b1, &c_b2, &vt[vt_offset], ldvt); /* Copy real matrix RWORK(IRVT) to complex matrix VT */ /* Overwrite VT by right singular vectors of A */ /* CWorkspace: need 2*M [tauq, taup] + N [work] */ /* CWorkspace: prefer 2*M [tauq, taup] + N*NB [work] */ /* RWorkspace: need M [e] + M*M [RVT] */ zlacp2_("F", m, m, &rwork[irvt], m, &vt[vt_offset], ldvt); i__1 = *lwork - nwork + 1; zunmbr_("P", "R", "C", n, n, m, &a[a_offset], lda, &work[ itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & ierr); } } } /* Undo scaling if necessary */ if (iscl == 1) { if (anrm > bignum) { dlascl_("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], & minmn, &ierr); } if (*info != 0 && anrm > bignum) { i__1 = minmn - 1; dlascl_("G", &c__0, &c__0, &bignum, &anrm, &i__1, &c__1, &rwork[ ie], &minmn, &ierr); } if (anrm < smlnum) { dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], & minmn, &ierr); } if (*info != 0 && anrm < smlnum) { i__1 = minmn - 1; dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &i__1, &c__1, &rwork[ ie], &minmn, &ierr); } } /* Return optimal workspace in WORK(1) */ work[1].r = (doublereal) maxwrk, work[1].i = 0.; return 0; /* End of ZGESDD */ } /* zgesdd_ */
the_stack_data/148577308.c
#include <stdio.h> #include <stdlib.h> #include <time.h> /* Faça um programa que calcule e imprima a soma de todos os elementos de uma matrix 5 x 7 */ int main(int argc, char const *argv[]) { int i, j, soma = 0, mat[5][7]; srand(time(NULL)); for (i = 0; i < 5; i++){ for(j = 0; j < 7; j++){ mat[i][j] = rand() % 100; } } for(i = 0; i < 5; i++){ for(j = 0; j < 7; j++){ soma += mat[i][j]; printf("%2d ", mat[i][j]); } printf("\n"); } printf("\n\nSoma total: %d\n\n", soma); return 0; }
the_stack_data/7950693.c
// 포인터가 가르키는 데이터의 유효성 문제 1 – auto variables #include <pthread.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> typedef struct { char field1[10]; char field2[10]; int field3; } PARAMS; void *Producer(void *arg) { PARAMS *pProducer = (PARAMS *) arg; sleep(1); printf("Producer => %s %d\n", pProducer->field1, pProducer->field3); } void *Consumer(void *arg) { PARAMS *pConsumer = (PARAMS *) arg; sleep(2); printf("Consumer => %s %d\n", pConsumer->field2, pConsumer->field3); } pthread_t ThreadVector[2]; // non-local variables void sub() { PARAMS pSub; strcpy(pSub.field1, "hello"); strcpy(pSub.field2, "world"); pSub.field3 = 2020; pthread_create(&ThreadVector[0], NULL, Producer, (void *) &pSub); pthread_create(&ThreadVector[1], NULL, Consumer, (void *) &pSub); } void main() { sub(); pthread_join(ThreadVector[0], NULL); pthread_join(ThreadVector[1], NULL); }
the_stack_data/234518780.c
// WARNING in binder_send_failed_reply // https://syzkaller.appspot.com/bug?id=db4346349c092186c40b65d3ecfd84d8adddf553 // status:fixed // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <dirent.h> #include <endian.h> #include <errno.h> #include <errno.h> #include <fcntl.h> #include <fcntl.h> #include <linux/futex.h> #include <linux/if.h> #include <linux/if_ether.h> #include <linux/if_tun.h> #include <linux/ip.h> #include <linux/tcp.h> #include <net/if_arp.h> #include <pthread.h> #include <signal.h> #include <stdarg.h> #include <stdarg.h> #include <stdbool.h> #include <stdio.h> #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/stat.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include <errno.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string.h> #include <sys/stat.h> const int kFailStatus = 67; const int kRetryStatus = 69; static void fail(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus); } static void exitf(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit(kRetryStatus); } static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* uctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) { _longjmp(segv_env, 1); } doexit(sig); } static void install_segv_handler() { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } static uint64_t current_time_ms() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) fail("clock_gettime failed"); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir() { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) fail("failed to mkdtemp"); if (chmod(tmpdir, 0777)) fail("failed to chmod"); if (chdir(tmpdir)) fail("failed to chdir"); } static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv; rv = vsnprintf(str, size, format, args); if (rv < 0) fail("tun: snprintf failed"); if ((size_t)rv >= size) fail("tun: string '%s...' doesn't fit into buffer", str); } static void snprintf_check(char* str, size_t size, const char* format, ...) { va_list args; va_start(args, format); vsnprintf_check(str, size, format, args); va_end(args); } #define COMMAND_MAX_LEN 128 #define PATH_PREFIX \ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin " #define PATH_PREFIX_LEN (sizeof(PATH_PREFIX) - 1) static void execute_command(const char* format, ...) { va_list args; char command[PATH_PREFIX_LEN + COMMAND_MAX_LEN]; int rv; va_start(args, format); memcpy(command, PATH_PREFIX, PATH_PREFIX_LEN); vsnprintf_check(command + PATH_PREFIX_LEN, COMMAND_MAX_LEN, format, args); rv = system(command); if (rv != 0) fail("tun: command \"%s\" failed with code %d", &command[0], rv); va_end(args); } static int tunfd = -1; static int tun_frags_enabled; #define SYZ_TUN_MAX_PACKET_SIZE 1000 #define MAX_PIDS 32 #define ADDR_MAX_LEN 32 #define LOCAL_MAC "aa:aa:aa:aa:aa:%02hx" #define REMOTE_MAC "bb:bb:bb:bb:bb:%02hx" #define LOCAL_IPV4 "172.20.%d.170" #define REMOTE_IPV4 "172.20.%d.187" #define LOCAL_IPV6 "fe80::%02hxaa" #define REMOTE_IPV6 "fe80::%02hxbb" #define IFF_NAPI 0x0010 #define IFF_NAPI_FRAGS 0x0020 static void initialize_tun(uint64_t pid) { if (pid >= MAX_PIDS) fail("tun: no more than %d executors", MAX_PIDS); int id = pid; tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } char iface[IFNAMSIZ]; snprintf_check(iface, sizeof(iface), "syz%d", id); struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_NAPI | IFF_NAPI_FRAGS; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) fail("tun: ioctl(TUNSETIFF) failed"); } if (ioctl(tunfd, TUNGETIFF, (void*)&ifr) < 0) fail("tun: ioctl(TUNGETIFF) failed"); tun_frags_enabled = (ifr.ifr_flags & IFF_NAPI_FRAGS) != 0; char local_mac[ADDR_MAX_LEN]; snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC, id); char remote_mac[ADDR_MAX_LEN]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC, id); char local_ipv4[ADDR_MAX_LEN]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, id); char remote_ipv4[ADDR_MAX_LEN]; snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, id); char local_ipv6[ADDR_MAX_LEN]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, id); char remote_ipv6[ADDR_MAX_LEN]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, id); execute_command("sysctl -w net.ipv6.conf.%s.accept_dad=0", iface); execute_command("sysctl -w net.ipv6.conf.%s.router_solicitations=0", iface); execute_command("ip link set dev %s address %s", iface, local_mac); execute_command("ip addr add %s/24 dev %s", local_ipv4, iface); execute_command("ip -6 addr add %s/120 dev %s", local_ipv6, iface); execute_command("ip neigh add %s lladdr %s dev %s nud permanent", remote_ipv4, remote_mac, iface); execute_command("ip -6 neigh add %s lladdr %s dev %s nud permanent", remote_ipv6, remote_mac, iface); execute_command("ip link set dev %s up", iface); } static void setup_tun(uint64_t pid, bool enable_tun) { if (enable_tun) initialize_tun(pid); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; if (errno == EBADFD) return -1; fail("tun: read failed with %d", rv); } return rv; } static void flush_tun() { char data[SYZ_TUN_MAX_PACKET_SIZE]; while (read_tun(&data[0], sizeof(data)) != -1) ; } static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { char buf[1024]; char* hash; NONFAILING(strncpy(buf, (char*)a0, sizeof(buf))); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } static void remove_dir(const char* dir) { DIR* dp; struct dirent* ep; int iter = 0; retry: dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exitf("opendir(%s) failed due to NOFILE, exiting", dir); } exitf("opendir(%s) failed", dir); } while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exitf("lstat(%s) failed", filename); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exitf("unlink(%s) failed", filename); if (umount2(filename, MNT_DETACH)) exitf("umount(%s) failed", filename); } } closedir(dp); int i; for (i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exitf("umount(%s) failed", dir); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exitf("rmdir(%s) failed", dir); } } static void test(); void loop() { int iter; for (iter = 0;; iter++) { char cwdbuf[256]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) fail("failed to mkdir"); int pid = fork(); if (pid < 0) fail("loop fork failed"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); if (chdir(cwdbuf)) fail("failed to chdir"); flush_tun(); test(); doexit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { int res = waitpid(-1, &status, __WALL | WNOHANG); if (res == pid) break; usleep(1000); if (current_time_ms() - start > 5 * 1000) { kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } } remove_dir(cwdbuf); } } struct thread_t { int created, running, call; pthread_t th; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static int collide; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { while (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &th->running, FUTEX_WAIT, 0, 0); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 0, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); } return 0; } static void execute(int num_calls) { int call, thread; running = 0; for (call = 0; call < num_calls; call++) { for (thread = 0; thread < sizeof(threads) / sizeof(threads[0]); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); pthread_create(&th->th, &attr, thr, th); } if (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) { th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); if (collide && call % 2) break; struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 20 * 1000 * 1000; syscall(SYS_futex, &th->running, FUTEX_WAIT, 1, &ts); if (running) usleep((call == num_calls - 1) ? 10000 : 1000); break; } } } } long r[2]; uint64_t procid; void execute_call(int call) { switch (call) { case 0: syscall(__NR_mmap, 0x20000000, 0x8000, 3, 0x32, -1, 0); break; case 1: NONFAILING(memcpy((void*)0x20002ff3, "/dev/binder#", 13)); r[0] = syz_open_dev(0x20002ff3, 0, 0); break; case 2: syscall(__NR_close, r[0]); break; case 3: NONFAILING(memcpy((void*)0x20008ff3, "/dev/binder#", 13)); r[1] = syz_open_dev(0x20008ff3, 0, 0); break; case 4: syscall(__NR_mmap, 0x20000000, 0x2000, 0, 0x20011, r[1], 0); break; case 5: syscall(__NR_mmap, 0x20009000, 0x1000, 3, 0x32, -1, 0); break; case 6: syscall(__NR_ioctl, r[1], 0x40046207, 0); break; case 7: syscall(__NR_mmap, 0x2000a000, 0x1000, 3, 0x32, -1, 0); break; case 8: NONFAILING(*(uint64_t*)0x2000a000 = 4); NONFAILING(*(uint64_t*)0x2000a008 = 0); NONFAILING(*(uint64_t*)0x2000a010 = 0x2000aff0); NONFAILING(*(uint64_t*)0x2000a018 = 0x44); NONFAILING(*(uint64_t*)0x2000a020 = 0); NONFAILING(*(uint64_t*)0x2000a028 = 0x20004000); NONFAILING(*(uint32_t*)0x2000aff0 = 0x630c); NONFAILING(memcpy((void*)0x20004000, "\x27\x16\xc8\x4b\xf8\x1a\x47\x7a\xd3\x31\x8a\xa4\xe2\x2d" "\x24\x4b\x80\x14\x91\xb0\xab\x31\x99\xa9\x2b\x02\x2c\xdb" "\x39\x0a\xa9\x7e\x9e\xd8\xe4\x52\xda\xe8\xd7\x24\xc2\x6d" "\x0e\xb9\x3c\x4d\x31\xa7\x18\x51\xa3\x52\x6c\xb6\x1f\xba" "\x5e\xa3\x38\x23\xf4\xf6\x92\xf0\x13\x16\x7a\x90", 68)); syscall(__NR_ioctl, r[0], 0xc0306201, 0x2000a000); break; case 9: NONFAILING(*(uint64_t*)0x20007000 = 4); NONFAILING(*(uint64_t*)0x20007008 = 0); NONFAILING(*(uint64_t*)0x20007010 = 0x20005fd4); NONFAILING(*(uint64_t*)0x20007018 = 0); NONFAILING(*(uint64_t*)0x20007020 = 0); NONFAILING(*(uint64_t*)0x20007028 = 0x20002000); NONFAILING(*(uint32_t*)0x20005fd4 = 0x40486311); NONFAILING(*(uint64_t*)0x20005fd8 = 0); NONFAILING(*(uint64_t*)0x20005fe0 = 0); syscall(__NR_ioctl, r[0], 0xc0306201, 0x20007000); break; case 10: syscall(__NR_fcntl, -1, 0x402, 0); break; case 11: syscall(__NR_ioctl, r[1], 0x40046207, 0); break; case 12: NONFAILING(*(uint64_t*)0x2000afd0 = 0x44); NONFAILING(*(uint64_t*)0x2000afd8 = 0); NONFAILING(*(uint64_t*)0x2000afe0 = 0x20009f84); NONFAILING(*(uint64_t*)0x2000afe8 = 0); NONFAILING(*(uint64_t*)0x2000aff0 = 0); NONFAILING(*(uint64_t*)0x2000aff8 = 0x20003fb3); NONFAILING(*(uint32_t*)0x20009f84 = 0x40486311); NONFAILING(*(uint32_t*)0x20009f88 = 0); NONFAILING(*(uint32_t*)0x20009f8c = 0); NONFAILING(*(uint64_t*)0x20009f90 = 0); NONFAILING(*(uint32_t*)0x20009f98 = 0); NONFAILING(*(uint32_t*)0x20009f9c = 0); NONFAILING(*(uint32_t*)0x20009fa0 = 0); NONFAILING(*(uint32_t*)0x20009fa4 = 0); NONFAILING(*(uint64_t*)0x20009fa8 = 0); NONFAILING(*(uint64_t*)0x20009fb0 = 0); NONFAILING(*(uint64_t*)0x20009fb8 = 0x2000a000); NONFAILING(*(uint64_t*)0x20009fc0 = 0x20003000); syscall(__NR_ioctl, r[0], 0xc0306201, 0x2000afd0); break; } } void test() { memset(r, -1, sizeof(r)); execute(13); collide = 1; execute(13); } int main() { char* cwd = get_current_dir_name(); for (procid = 0; procid < 8; procid++) { if (fork() == 0) { install_segv_handler(); for (;;) { if (chdir(cwd)) fail("failed to chdir"); use_temporary_dir(); setup_tun(procid, true); loop(); } } } sleep(1000000); return 0; }
the_stack_data/128457.c
void fence() { asm("sync"); } void lwfence() { asm("lwsync"); } void isync() { asm("isync"); } int __unbuffered_cnt = 0; int __unbuffered_p0_r1 = 0; int __unbuffered_p0_r3 = 0; int __unbuffered_p1_r1 = 0; int __unbuffered_p1_r3 = 0; int x = 0; int y = 0; void *P0(void *arg) { __unbuffered_p0_r1 = y; lwfence(); __unbuffered_p0_r3 = 1; x = __unbuffered_p0_r3; // Instrumentation for CPROVER fence(); __unbuffered_cnt++; } void *P1(void *arg) { __unbuffered_p1_r1 = 2; x = __unbuffered_p1_r1; lwfence(); __unbuffered_p1_r3 = 1; y = __unbuffered_p1_r3; // Instrumentation for CPROVER fence(); __unbuffered_cnt++; } int main() { __CPROVER_ASYNC_0: P0(0); __CPROVER_ASYNC_1: P1(0); __CPROVER_assume(__unbuffered_cnt == 2); fence(); // EXPECT:exists __CPROVER_assert( !(x == 2 && __unbuffered_p0_r1 == 1), "Program proven to be relaxed for PPC, model checker says YES."); return 0; }
the_stack_data/142346.c
/* ******************************************************************************* * Copyright (c) 2020-2021, STMicroelectronics * All rights reserved. * * 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 * ******************************************************************************* */ /* * Automatically generated from STM32H742V(G-I)Hx.xml, STM32H742V(G-I)Tx.xml * STM32H743V(G-I)Hx.xml, STM32H743VGTx.xml * STM32H743VITx.xml, STM32H750VBTx.xml * STM32H753VIHx.xml, STM32H753VITx.xml * CubeMX DB release 6.0.30 */ #if defined(ARDUINO_DevEBoxH743VITX) || defined(ARDUINO_DevEBoxH750VBTX) #include "Arduino.h" #include "PeripheralPins.h" /* ===== * Notes: * - The pins mentioned Px_y_ALTz are alternative possibilities which use other * HW peripheral instances. You can use them the same way as any other "normal" * pin (i.e. analogWrite(PA7_ALT1, 128);). * * - Commented lines are alternative possibilities which are not used per default. * If you change them, you will have to know what you do * ===== */ //*** ADC *** #ifdef HAL_ADC_MODULE_ENABLED WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_INP16 {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, // ADC1_INP17 {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_INP14 {PA_2_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_INP14 {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_INP15 {PA_3_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_INP15 {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC1_INP18 {PA_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC2_INP18 {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC1_INP19 {PA_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC2_INP19 {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_INP3 {PA_6_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_INP3 {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_INP7 {PA_7_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_INP7 {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_INP9 {PB_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_INP9 {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_INP5 {PB_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_INP5 {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_INP10 {PC_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_INP10 {PC_0_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_INP10 {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_INP11 {PC_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_INP11 {PC_1_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_INP11 {PC_2_C, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_INP0 {PC_3_C, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_INP1 {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_INP4 {PC_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_INP4 {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_INP8 {PC_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_INP8 {NC, NP, 0} }; #endif //*** DAC *** #ifdef HAL_DAC_MODULE_ENABLED WEAK const PinMap PinMap_DAC[] = { {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1 {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 {NC, NP, 0} }; #endif //*** I2C *** #ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SDA[] = { {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_7_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_9_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PD_13, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, {NC, NP, 0} }; #endif #ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_6_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_8_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PD_12, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, {NC, NP, 0} }; #endif //*** TIM *** #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_TIM[] = { {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_0_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PA_1_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 {PA_1_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 {PA_2_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 {PA_2_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PA_3_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 {PA_3_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_5_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PA_6_ALT1, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PA_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PA_7_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N {PA_7_ALT3, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PB_0_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PB_0_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_1_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PB_1_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PB_6_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PB_7_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PB_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PB_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1 {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PB_14_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N {PB_14_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 1, 0)}, // TIM12_CH1 {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_15_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_15_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 2, 0)}, // TIM12_CH2 {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PC_6_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PC_7_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PC_8_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PC_9_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PE_4, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N {PE_5, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 {PE_6, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 {PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {NC, NP, 0} }; #endif //*** UART *** #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_TX[] = { {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_9, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, {PA_9_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PA_12, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, {PA_15, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, {PB_4, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, {PB_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, {PB_6_ALT1, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, {PB_6_ALT2, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PB_9, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PB_13, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, {PB_14, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_10_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PE_1, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, {PE_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, {NC, NP, 0} }; #endif #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, {PA_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, {PA_10_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PA_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, {PB_3, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, {PB_5, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, {PB_7, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, {PB_7_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PB_8, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PB_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, {PB_15, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_11_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PE_0, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, {PE_7, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, {NC, NP, 0} }; #endif #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, {PA_12_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PB_14, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PB_14_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_15, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, {PE_9, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, {NC, NP, 0} }; #endif #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, {PA_11_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PB_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_14, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, {PE_10, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, {NC, NP, 0} }; #endif //*** SPI *** #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_7_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, {PB_5_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_3_C, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, {PD_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; #endif #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_6_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_4_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_2_C, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; #endif #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_5_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PA_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_3_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; #endif #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PA_4_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, {PA_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PA_15_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI6)}, {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; #endif //*** FDCAN *** #ifdef HAL_FDCAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_RD[] = { {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {PB_5, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, {PB_8, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, {PD_0, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {NC, NP, 0} }; #endif #ifdef HAL_FDCAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {PB_6, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, {PB_9, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, {PD_1, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {NC, NP, 0} }; #endif //*** ETHERNET *** #ifdef HAL_ETH_MODULE_ENABLED WEAK const PinMap PinMap_Ethernet[] = { {PA_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS {PA_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_REF_CLK {PA_1_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_CLK {PA_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDIO {PA_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL {PA_7, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS_DV {PA_7_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_DV {PB_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2 {PB_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3 {PB_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT {PB_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 {PB_10, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER {PB_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN {PB_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 {PB_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 {PC_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDC {PC_2_C, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 {PC_3_C, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK {PC_4, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD0 {PC_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD1 {PE_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 {NC, NP, 0} }; #endif //*** QUADSPI *** #ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA0[] = { {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO0 {PD_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO0 {PE_7, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO0 {NC, NP, 0} }; #endif #ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA1[] = { {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO1 {PD_12, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO1 {PE_8, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO1 {NC, NP, 0} }; #endif #ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA2[] = { {PE_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO2 {PE_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO2 {NC, NP, 0} }; #endif #ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA3[] = { {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3 {PD_13, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3 {PE_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO3 {NC, NP, 0} }; #endif #ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_SCLK[] = { {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_CLK {NC, NP, 0} }; #endif #ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_SSEL[] = { {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_NCS {PB_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_NCS {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK2_NCS {NC, NP, 0} }; #endif //*** USB *** #if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) WEAK const PinMap PinMap_USB_OTG_FS[] = { // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_SOF // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_ID {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DM {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DP {NC, NP, 0} }; #endif #if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) WEAK const PinMap PinMap_USB_OTG_HS[] = { #ifdef USE_USB_HS_IN_FS // {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_SOF // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_ID // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS // {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DM {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DP #else // {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D0 // {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_CK // {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D1 // {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D2 // {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D7 // {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D3 // {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D4 // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D5 // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D6 // {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_STP // {PC_2_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_DIR // {PC_3_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_NXT #endif /* USE_USB_HS_IN_FS */ {NC, NP, 0} }; #endif //*** SD *** #ifdef HAL_SD_MODULE_ENABLED WEAK const PinMap PinMap_SD[] = { // {PA_0, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDIO2)}, // SDMMC2_CMD // {PB_3, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D2 // {PB_4, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D3 // {PB_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDIO1)}, // SDMMC1_CKIN // {PB_8_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D4 // {PB_8_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D4 // {PB_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDIO1)}, // SDMMC1_CDIR // {PB_9_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D5 // {PB_9_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D5 // {PB_14, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D0 // {PB_15, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D1 // {PC_1, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDIO2)}, // SDMMC2_CK // {PC_6, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDIO1)}, // SDMMC1_D0DIR // {PC_6_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D6 // {PC_6_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D6 // {PC_7, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDIO1)}, // SDMMC1_D123DIR // {PC_7_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D7 // {PC_7_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D7 {PC_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D0 {PC_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D1 {PC_10, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D2 {PC_11, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D3 {PC_12, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO1)}, // SDMMC1_CK {PD_2, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO1)}, // SDMMC1_CMD // {PD_6, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDIO2)}, // SDMMC2_CK // {PD_7, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDIO2)}, // SDMMC2_CMD {NC, NP, 0} }; #endif #endif /* ARDUINO_DevEBoxH743VITX || ARDUINO_DevEBoxH750VBTX */
the_stack_data/104828276.c
struct Pilha{ int posicaoTopo; int capacidade; int *proximoElemento; }; int main() { struct Pilha meusLivros; return 0; }
the_stack_data/165400.c
/* <TAGS>signal_processing filter</TAGS> DESCRIPTION Remove linear trends from a data series USES ARGUMENTS double *y : pointer to array holding input time-series, constant intervals assumed size_t nn : number of elements in y[] double *result_d : array to hold results, initialized by calling function result_d[0]= intercept result_d[1]= slope result_d[2]= Pearson's r RETURN VALUE 0 on success 1 on failure (impossible at present) */ #include<stdlib.h> #include<stdio.h> #include<math.h> int xf_detrend1_d(double *y, size_t nn, double *result_d) { size_t ii; double r=NAN,slope=NAN,intercept=NAN,aa,bb; double SUMx=0.0,SUMy=0.0,SUMx2=0.0,SUMy2=0.0,SUMxy=0.0; double SSx=0.0,SSy=0.0,SPxy=0.0; if(nn<2) return(1); for(ii=0;ii<nn;ii++) { aa=(double)ii; bb=y[ii]; SUMx += aa; SUMy += bb; SUMx2 += aa*aa; SUMy2 += bb*bb; SUMxy += aa*bb; } SSx = SUMx2-((SUMx*SUMx)/nn); SSy = SUMy2-((SUMy*SUMy)/nn); SPxy = SUMxy-((SUMx*SUMy)/nn); /* DETREND THE DATA, PROVIDED THERE IS VARIABILITY IN THE TIME SERIES */ if(SSy!=0.0) { r = SPxy/(sqrt(SSx)*sqrt(SSy)); slope= SPxy/SSx; intercept= (SUMy/nn)-(slope*(SUMx/nn)); for(ii=0;ii<nn;ii++) { y[ii] -= (intercept + slope*(double)ii); } } /* OTHERWISE (OR IF SLOPE IS EXACTLY ZERO) SUBTRACT THE MEAN */ else { r=0.0; slope=0.0; intercept=y[0]; aa=SUMy/(double)nn; for(ii=0;ii<nn;ii++) { y[ii] -= aa; } } /* COPY COEFFICIENTS TO RESULTS ARRAY */ result_d[0]=intercept; result_d[1]=slope; result_d[2]=r; return(0); }
the_stack_data/181392831.c
/* wprintf example */ #include <wchar.h> int main() { wprintf(L"Characters: %lc %lc \n", L'a', 65); wprintf(L"Decimals: %d %ld\n", 1977, 650000L); wprintf(L"Preceding with blanks: %10d \n", 1977); wprintf(L"Preceding with zeros: %010d \n", 1977); wprintf(L"Some different radixes: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100); wprintf(L"floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416); wprintf(L"Width trick: %*d \n", 5, 10); wprintf(L"%ls \n", L"A wide string"); wint_t x = 5; wchar_t name[] = L"GEEKS"; wprintf(L"x = %d \n", x); wprintf(L"HELLO %ls \n", name); return 0; }
the_stack_data/92328966.c
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main(int argc, char **argv) { int err, len, servfd; struct sockaddr_in servaddr; char sendline[4096], recvline[4096]; if (argc != 2) { printf("usage: %s <server ip>\n", argv[0]); exit(1); } servfd = socket(AF_INET, SOCK_STREAM, 0); if (servfd == -1) { printf("create socket error: %s(errno: %d)\n", strerror(errno), errno); exit(1); } memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(5555); if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) < 0) { printf("inet_pton error for %s\n", argv[1]); exit(1); } if (connect(servfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { printf("connect error: %s(errno: %d)\n", strerror(errno), errno); exit(1); } printf("=====send message to server: \n"); fgets(sendline, sizeof(sendline)-1, stdin); if (send(servfd, sendline, strlen(sendline), 0) < 0) { printf("connect error: %s(errno: %d)\n", strerror(errno), errno); exit(1); } len = recv(servfd, recvline, sizeof(recvline), 0); if (len >= 0) { recvline[len] = '\0'; printf("=====recv=====\n%s\n", recvline); } close(servfd); }
the_stack_data/225143470.c
//////////////////////////////////////////////////////////////////////////// // // Function Name : Min() // Description : Accept Number From User And Return Smallest Digit Using Recursion // Input : Integer // Output : Integer // Author : Prasad Dangare // Date : 22 May 2021 // //////////////////////////////////////////////////////////////////////////// #include <stdio.h> int Min(int iNo) { static int i = 0, iMin = 9; if(iNo != 0) { i = iNo % 10; if(i < iMin) { iMin = i; } iNo = iNo / 10; Min(iNo); } return iMin; /*int iDigit = 0, iMin = 9; while(iNo != 0) { iDigit = iNo % 10; if(iDigit < iMin) { iMin = iDigit; } iNo = iNo / 10; } return iMin;*/ } int main() { int iValue = 0, iRet = 0; printf("Enter The Digit : "); scanf("%d", &iValue); iRet = Min(iValue); printf("Smallest Digit is : %d", iRet); return 0; }
the_stack_data/15762195.c
#define My_ctype_DEF #include "ctype.h"
the_stack_data/11074772.c
//BIBLIOTECAS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #define CLEAR "CLS" //METODO PARA CALCULAR TEMPO unsigned long long current_timestamp() { struct timeval tv; unsigned long long tim; gettimeofday(&tv, NULL); tim = 1000000 * tv.tv_sec + tv.tv_usec; return tim; } //CRIANDO UM ARRAY(PONTEIRO) COM TAMANHO TAM int *criarArray(int tam) { int *array = (int *) malloc(sizeof(int) * tam); for (int i = 0; i < tam; i++) { array[i] = i + 1; } return array; } //DESORGANIZANDO O ARRAY int *desorganizar(int *array, int tam) { time_t tim; srand((unsigned) time(&tim)); for (int i = 0; i < tam; i++) { int rand_pos = (int)(((double)rand()/RAND_MAX) * tam); int t = array[rand_pos]; array[rand_pos] = array[i]; array[i] = t; } return array; } //IMPRIMINDO O ARRAY void imprimirArray(int *array, int tam) { for (int i = 0; i < tam; i++) { printf("%d ", array[i]); } } //MENU void imprimeMenu() { printf("================================================================\n"); printf("| Tempo de execucao de diferentes metodos de ordenacao |\n"); printf("================================================================\n"); printf("| Operacoes: |\n"); printf("| 1) Insertion Sort |\n"); printf("| 2) Shell Sort |\n"); printf("| 3) Bubble Sort |\n"); printf("| 4) Quick Sort |\n"); printf("| 5) Merge Sort |\n"); printf("| 6) Heap Sort |\n"); printf("| 7) Imprimir array original |\n"); printf("| 8) Imprimir array ordenado |\n"); printf("| 9) Sair |\n"); printf("+--------------------------------------------------------------+\n"); printf("Pressione a opcao desejada: "); } void insertionSort(int *array, int tam) { int i, k, aux; for(k = 1; k < tam; k++){ aux = array[k]; for(i = k - 1; i >= 0 && aux < array[i]; i--) array[i + 1] = array[i]; array[i + 1] = aux; } } void shellSort(int *array, int tam) { int gap, j, k, aux; for(gap = tam / 2; gap >= 1; gap = gap / 2){ for(j = gap; j < tam; j++){ aux = array[j]; for(k = j -gap; k >= 0 && aux < array[k]; k-=gap){ array[k + gap] = array[k]; } array[k + gap] = aux; } } } void bubbleSort(int *array, int tam) { int i, j, aux; for(j = tam - 1; j > 0; j--) { for(i = 0; i < j; i++) { if(array[i] > array[i + 1]) { aux = array[i]; array[i] = array[i + 1]; array[i + 1] = aux; } } } } void quickSort(int *array, int p, int u) { int i, j, pivo, aux; i = p; j = u; pivo= array[(i + j)/2]; do{ while(array[i] < pivo && i < u) i++; while(array[j] > pivo && j > p) j--; if(i <= j){ aux = array[i]; array[i] = array[j]; array[j] = aux; i++; j--; } } while(i <= j); if(p < j) quickSort(array, p, j); if(i < u) quickSort(array, i, u); } void merge(int *ordenado, int *temporario, int esquerda, int meio, int direita) { int i, esq_fim, tam, tmp_pos; esq_fim = meio - 1; tmp_pos = esquerda; tam = direita - esquerda + 1; while ((esquerda <= esq_fim) && (meio <= direita)) { if (ordenado[esquerda] <= ordenado[meio]) { temporario[tmp_pos] = ordenado[esquerda]; tmp_pos++; esquerda++; } else { temporario[tmp_pos] = ordenado[meio]; tmp_pos++; meio++; } } if (esquerda <= esq_fim) { memcpy(&temporario[tmp_pos], &ordenado[esquerda], (esq_fim - esquerda + 1)*sizeof(int)); } if (meio <= direita) { memcpy(&temporario[tmp_pos], &ordenado[meio], (direita - meio + 1)*sizeof(int)); } memcpy(&ordenado[direita - tam + 1], &temporario[direita - tam + 1], tam*sizeof(int)); } void mergeSort(int *ordenado, int *temporario, int esquerda, int direita) { int meio; if (direita > esquerda) { meio = (direita + esquerda) / 2; mergeSort(ordenado, temporario, esquerda, meio); mergeSort(ordenado, temporario, meio+1, direita); merge(ordenado, temporario, esquerda, meio+1, direita); } } void heapfica(int *x, int n) { int i, aux, s, f; for (int i = 1; i < n; i++) { aux = x[i]; s = i; f = (s - 1) / 2; while (s > 0 && x[f] < aux) { x[s] = x[f]; s = f; f = (s - 1) / 2; } x[s] = aux; } } void heapSort(int *x, int n) { int i, s, f, ival; heapfica(x, n); for(i = n - 1; i > 0; i--) { ival = x[i]; x[i] = x[0]; f = 0; if (i == 1) { s = -1; } else { s = 1; } if (i > 2 && x[2] > x[1]) { s = 2; } while (s >= 0 && ival < x[s]) { x[f] = x[s]; f = s; s = 2 * f + 1; if (s + 1 <= i - 1 && x[s] < x[s + 1]) { s = s + 1; } if (s > i - 1) { s = -1; } } x[f] = ival; } } int main() { int *original, *ordenado, tam; char opcao = '0'; unsigned long long t1, t2; printf("Digite o tamanho do vetor: "); scanf("%d", &tam); original = desorganizar(criarArray(tam), tam); ordenado = (int *) malloc(sizeof(int) * tam); memcpy(ordenado, original, sizeof(int) * tam); getchar(); while(opcao != '9'){ system("CLS"); imprimeMenu(); opcao = getchar(); switch(opcao){ //INSERTIONSORT case '1': memcpy(ordenado, original, sizeof(int) * tam); t1 = current_timestamp(); insertionSort(ordenado, tam); t2 = current_timestamp(); printf("\nDuracao em microssegundos: %lld\n", t2-t1); getchar(); getchar(); break; //SHELLSORT case '2': memcpy(ordenado, original, sizeof(int) * tam); t1 = current_timestamp(); shellSort(ordenado, tam); t2 = current_timestamp(); printf("\nDuracao em microssegundos: %lld\n", t2-t1); getchar(); getchar(); break; //BUBBLESORT case '3': memcpy(ordenado, original, sizeof(int) * tam); t1 = current_timestamp(); bubbleSort(ordenado, tam); t2 = current_timestamp(); printf("\nDuracao em microssegundos: %lld\n", t2-t1); getchar(); getchar(); break; //QUICKSORT case '4': memcpy(ordenado, original, sizeof(int) * tam); t1 = current_timestamp(); quickSort(ordenado, 0, tam-1); t2 = current_timestamp(); printf("\nDuracao em microssegundos: %lld\n", t2-t1); getchar(); getchar(); break; //MERGESORT case '5': memcpy(ordenado, original, sizeof(int) * tam); t1 = current_timestamp(); int *temporario; temporario = (int *)malloc(sizeof(int) * tam); mergeSort(ordenado, temporario, 0, tam-1); t2 = current_timestamp(); printf("\nDuracao em microssegundos: %lld\n", t2-t1); getchar(); getchar(); break; //HEAPSORT case '6': memcpy(ordenado, original, sizeof(int) * tam); t1 = current_timestamp(); heapSort(ordenado, tam); t2 = current_timestamp(); printf("\nDuracao em microssegundos: %lld\n", t2-t1); getchar(); getchar(); break; //IMPRIMINDO O ARRAY ORIGINAL case '7': imprimirArray(original, tam); getchar(); getchar(); break; //IMPRIMINDO O ARRAY ORDENADO case '8': imprimirArray(ordenado, tam); getchar(); getchar(); break; //SAINDO DO PGM case '9': printf("\nSaindo do programa...\n"); break; //NENHUMA OPCAO ANTERIOR default: printf("\nOpcao invalida!\n"); getchar(); getchar(); break; } } return (EXIT_SUCCESS); }
the_stack_data/50138117.c
#ifdef STM32H7xx #include "stm32h7xx_hal_sd_ex.c" #elif STM32L4xx #include "stm32l4xx_hal_sd_ex.c" #elif STM32L5xx #include "stm32l5xx_hal_sd_ex.c" #elif STM32MP1xx #include "stm32mp1xx_hal_sd_ex.c" #endif
the_stack_data/182953901.c
/* Ex 3 tarefa 09 */ #include <stdio.h> #include <stdlib.h> // Função que retorna o maior número do conjunto int maiorNumero(int numero, int conjunto[numero]) { int maior, cont; maior = conjunto[0]; cont = 1; while (cont < numero) { if(conjunto[cont] > maior) { maior = conjunto[cont]; } cont++; } return (maior); } int main() { int n, i; scanf("%d", &n); if(n >= 1 && n <= 100){ int conjunto[n]; i = 0; while (i < n){ scanf("%d", &conjunto[i]); i++; } printf("%d", maiorNumero(n, conjunto)); } return 0; }
the_stack_data/435015.c
#include <stdio.h> #include <sys/time.h> int main(int argc, char** argv) { struct timeval time_struct; gettimeofday(&time_struct, 0); printf("%lld", (time_struct.tv_sec * 1000ll) + (time_struct.tv_usec / 1000ll)); return 0; }
the_stack_data/93633.c
#define _GNU_SOURCE #include <errno.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> char* __randname(char*); char* mktemp(char* template) { size_t l = strlen(template); int retries = 100; struct stat st; if (l < 6 || memcmp(template + l - 6, "XXXXXX", 6)) { errno = EINVAL; *template = 0; return template; } do { __randname(template + l - 6); if (stat(template, &st)) { if (errno != ENOENT) *template = 0; return template; } } while (--retries); *template = 0; errno = EEXIST; return template; }
the_stack_data/156394439.c
/***** * Copyright (c) 2015-2016, Stefan Reif * 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 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. * *****/ /* * fuzzme.c * * This tool passes stdin directly to xpr. * * Usage: * ./fuzzme <input * afl-fuzz -i input-dir -o findings-dir ./fuzzme */ #ifdef MAIN #include "xpr.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> static void die(const char *msg) { perror(msg); exit(EXIT_FAILURE); } int main(void) { char *line = NULL; size_t linesz = 0; unsigned long long lineno = 0; while (1) { lineno++; ssize_t result = getdelim(&line, &linesz, '\0', stdin); if (result < 0) break; xpr(line, NULL); //printf("%llu: %lf\n", lineno, xpr(line, NULL)); } if (ferror(stdin)) die("getline"); free(line); exit(EXIT_SUCCESS); } #undef MAIN #include "xpr.c" #endif /* MAIN */
the_stack_data/135848.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isprint.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cben-bar <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/02 14:52:51 by cben-bar #+# #+# */ /* Updated: 2021/11/02 15:34:41 by cben-bar ### ########lyon.fr */ /* */ /* ************************************************************************** */ int ft_isprint(int c) { if (c >= 32 && c <= 126) return (1); return (0); }
the_stack_data/54433.c
#include <assert.h> #include <stdlib.h> void dynamicAllocationUninitialized(int trigger) { int *obj; if(trigger) { obj = (int *)malloc(sizeof(int)); *obj = 42; } else { obj = (int *)malloc(sizeof(int)); *obj = 76; } assert(*obj == 42); } int global; void globalUninitialized(int trigger) { if(trigger) { global = 44; } else { global = 20; } assert(global == 44); } void staticLocalUninitialized(int trigger) { static int staticLocal; if(trigger) { staticLocal = 43; } assert(staticLocal == 43); } void localUninitialized(int trigger) { int local; if(trigger) { local = 24; } assert(local == 24); }
the_stack_data/73375.c
#include <math.h> double sin(double num) { return sinl(num); }
the_stack_data/653689.c
#include<stdio.h> #include<stdlib.h> char *mx_strnew(const int size) { if( size < 0) return NULL; char *p = (char *) malloc((size + 1) * sizeof(char)); if (p != NULL) { for (int i = 0; i < size + 1; i++) { p[i] = '\0'; } } return p; }
the_stack_data/218892161.c
/* * Generic program for testing shellcode byte arrays. * Created by zillion and EVL * * Visit: http://safemode.org/ */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <errno.h> /* * Print message */ static void croak(const char *msg) { fprintf(stderr, "%s\n", msg); fflush(stderr); } /* * Educate user */ static void usage(const char *prgnam) { fprintf(stderr, "\nExecute code : %s -e <file-containing-shellcode>\n", prgnam); fprintf(stderr, "Convert code : %s -p <file-containing-shellcode> \n\n", prgnam); fflush(stderr); exit(1); } /* * Signal error and bail out. */ static void barf(const char *msg) { perror(msg); exit(1); } /* * Main code starts here */ int main(int argc, char **argv) { FILE *fp; void *code; int arg; int i; int l; int m = 15; /* max # of bytes to print on one line */ struct stat sbuf; long flen; /* Note: assume files are < 2**32 bytes long ;-) */ void (*fptr)(void); if(argc < 3) usage(argv[0]); if(stat(argv[2], &sbuf)) barf("failed to stat file"); flen = (long) sbuf.st_size; if(!(code = malloc(flen))) barf("failed to grab required memeory"); if(!(fp = fopen(argv[2], "rb"))) barf("failed to open file"); if(fread(code, 1, flen, fp) != flen) barf("failed to slurp file"); if(fclose(fp)) barf("failed to close file"); while ((arg = getopt (argc, argv, "e:p:")) != -1) { switch (arg) { case 'e': croak("Calling code ..."); fptr = (void (*)(void)) code; (*fptr)(); break; case 'p': printf("\n\nchar shellcode[] =\n"); l = m; for(i = 0; i < flen; ++i) { if(l >= m) { if(i) printf("\"\n"); printf( "\t\""); l = 0; } ++l; printf("\\x%02x", ((unsigned char *)code)[i]); } printf("\";\n\n\n"); break; default : usage(argv[0]); } } return 0; }
the_stack_data/45449827.c
/* { dg-do compile } */ /* { dg-options "-Wtautological-compare -fdiagnostics-show-caret" } */ #define FOO foo void fn1 (int foo) { if (foo == foo); /* { dg-warning "self-comparison always evaluates to true" } */ /* { dg-begin-multiline-output "" } if (foo == foo); ^~ { dg-end-multiline-output "" { target c } } */ /* { dg-begin-multiline-output "" } if (foo == foo); ~~~ ^~ ~~~ { dg-end-multiline-output "" { target c++ } } */ } void fn2 (int foo) { if (FOO == FOO); /* { dg-warning "self-comparison always evaluates to true" } */ /* { dg-begin-multiline-output "" } if (FOO == FOO); ^~ { dg-end-multiline-output "" } */ } void fn3 (int foo) { if ((foo & 16) == 10); /* { dg-warning "bitwise comparison always evaluates to false" } */ /* { dg-begin-multiline-output "" } if ((foo & 16) == 10); ^~ { dg-end-multiline-output "" { target c } } */ /* { dg-begin-multiline-output "" } if ((foo & 16) == 10); ~~~~~~~~~~ ^~ ~~ { dg-end-multiline-output "" { target c++ } } */ }
the_stack_data/153194.c
#include <stdlib.h> extern int __VERIFIER_nondet_int(void); int test_fun(int i, int j, int k, int tmp) { int* i_ref = alloca(sizeof(int)); int* j_ref = alloca(sizeof(int)); int* k_ref = alloca(sizeof(int)); int* tmp_ref = alloca(sizeof(int)); int* c = alloca(sizeof(int)); *i_ref = i; *j_ref = j; *k_ref = k; *tmp_ref = tmp; *c = 0; while ((*i_ref <= 100) && (*j_ref <= k)) { *tmp_ref = *i_ref; *i_ref = *j_ref; *j_ref = *tmp_ref + 1; *k_ref = *k_ref - 1; *c = *c + 1; } return *c; } int main() { return test_fun(__VERIFIER_nondet_int(),__VERIFIER_nondet_int(),__VERIFIER_nondet_int(),__VERIFIER_nondet_int()); }
the_stack_data/612813.c
#include <stdio.h> int main() { int a; printf("Enter an integer -> "); scanf("%d", &a); if (a % 5 == 0 && a % 6 == 0) printf("Is %d divisible by 5 and 6? true\n", a); else printf("Is %d divisible by 5 and 6? false\n", a); if (a % 5 == 0 || a % 6 == 0) printf("Is %d divisible by 5 or 6? true\n", a); else printf("Is %d divisible by 5 or 6? false\n"); if ((a % 5 == 0 || a % 6 == 0) && (!((a % 5 == 0) && (a % 6 == 0)))) printf("Is %d divisible by 5 or 6,but not both? true\n", a); else printf("Is %d divisible by 5 or 6,but not both? false\n", a); }
the_stack_data/34513994.c
#include <stdio.h> #include <string.h> int array [10], strlens [10]; char *str_pointers [10]; char str [10] [100]; char test [10*100], minstr[1000]; int minlen; int tslen, depth, n; int min (int i, int j) { return (i < j) ? i : j; } void try (int i) { int j,k, flag, l; int length = strlens[i]; //printf("launching try\n"); if (tslen == 0) { strcpy (test, str_pointers[i]); tslen = length; } else { for (j = 0; j < tslen; j ++){ flag = 1; for (k = 0; k < min (tslen - j, length); k ++) { //printf("comparing %c %c\n", str_pointers [i] [k], test [k + j]); flag = flag && (str_pointers[i] [k] == test [k + j]); } if (flag && ((j + length) > tslen)) { k = tslen - j; while (k < length) { test [tslen] = str_pointers [i] [k]; tslen++; k++; } } if (flag) goto out1; } k = 0; while (k < length) { test [tslen] = str_pointers [i] [k]; tslen++; k++; } out1: ; } //for (i = 0; i < min (tslen, 10); i++) printf("%c", test[i]); // printf("\n"); } void find_superstring () { // printf("Launched fss\n"); int i; for (i = 0; i < n; i++ ) { //printf("i = %d\n", i); if (!(array[i])) { int temp = tslen; try (i); if (depth < n) { depth++; array[i] = 1; // int temp = tslen; find_superstring (); // tslen = temp; array[i] = 0; depth--; } else if (minlen > tslen) { minlen = tslen; strcpy(minstr, test); } tslen = temp; } } } int main() { int i; scanf("%d ", &n); //for (i = 0; i < 10; array[i] = 0, i++) ; /* Считаем строки и свяжем указатели */ for (i = 0; i < n; i++) { array[i] = 0; gets (str[i]); str_pointers[i] = str[i]; strlens[i] = strlen(str_pointers[i]); } depth = 1; tslen = 0; minlen = 1000; find_superstring(); //printf ("minlen = %d\n superstr = ", minlen); //for (i = 0; i < min (minlen, 10); i++) printf("%c", minstr[i]); printf("%d\n", minlen); return 0; }
the_stack_data/3522.c
/*rr * Copyright (c) 2005-2006, Kohsuke Ohtani * 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. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ #include <unistd.h> #include <err.h> #include <errno.h> #include <stdlib.h> #include <limits.h> #include <stdio.h> #ifdef CMDBOX #define main(argc, argv) pwd_main(argc, argv) #endif int main(int argc, char *argv[]) { char cwd[PATH_MAX]; char *p; if (argc > 1) { fprintf(stderr, "usage: pwd\n"); exit(1); } if ((p = getcwd(cwd, PATH_MAX)) == NULL) { err(1, NULL); exit(1); } puts(p); exit(0); }
the_stack_data/29824077.c
#include <stdio.h> #define SIZE 5 void forEach(void *, int, void (*)(void *, int)); void loop(void *, int); int main(void) { int arr[SIZE] = {12, 234, 32, 45, 57}; forEach(arr, SIZE, loop); return 0; } void forEach(void *arr, int size, void (*fn)(void *, int)) { int *array = (int *) arr; for (int i = 0; i < size; i++) { fn(&array[i], i); } } void loop(void * pt, int index) { int *val = (int *) pt; printf("index=%d, val=%d\n", index, *val); }
the_stack_data/14921.c
/* * 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_SWSTATEDNX_GENERAL #ifdef BCM_DNX_SUPPORT #if defined(INCLUDE_KBP) #include <soc/dnxc/swstate/dnxc_sw_state_c_includes.h> #include <soc/dnx/swstate/auto_generated/access/kbp_access.h> #include <soc/dnx/swstate/auto_generated/diagnostic/kbp_diagnostic.h> kbp_sw_state_t* kbp_sw_state_dummy = NULL; int kbp_sw_state_is_init(int unit, uint8 *is_init) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_IS_INIT, DNXC_SW_STATE_NO_FLAGS); *is_init = (NULL != ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_IS_INIT_LOGGING, BSL_LS_SWSTATEDNX_ISINIT, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID]), "kbp_sw_state[%d]", unit); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_init(int unit) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_INIT, DNXC_SW_STATE_NO_FLAGS); DNX_SW_STATE_MODULE_INIT( unit, KBP_MODULE_ID, DNXC_SW_STATE_IMPLEMENTATION_WB, kbp_sw_state_t, DNXC_SW_STATE_AUTO_GENERATED_ALLOCATION, "kbp_sw_state_init"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_INIT_LOGGING, BSL_LS_SWSTATEDNX_INIT, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID]), "kbp_sw_state[%d]", unit); DNX_SW_STATE_DIAG_INFO_UPDATE( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_INFO, DNX_SW_STATE_DIAG_ALLOC, sizeof(kbp_sw_state_t), NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_is_device_locked_set(int unit, int is_device_locked) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->is_device_locked, is_device_locked, int, 0, "kbp_sw_state_is_device_locked_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &is_device_locked, "kbp_sw_state[%d]->is_device_locked", unit); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_IS_DEVICE_LOCKED_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_is_device_locked_get(int unit, int *is_device_locked) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, is_device_locked); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *is_device_locked = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->is_device_locked; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->is_device_locked, "kbp_sw_state[%d]->is_device_locked", unit); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_IS_DEVICE_LOCKED_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_set(int unit, uint32 db_handles_info_idx_0, CONST kbp_db_handles_t *db_handles_info) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_MEMCPY( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0], db_handles_info, kbp_db_handles_t, 0, "kbp_sw_state_db_handles_info_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, db_handles_info, "kbp_sw_state[%d]->db_handles_info[%d]", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_get(int unit, uint32 db_handles_info_idx_0, kbp_db_handles_t *db_handles_info) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, db_handles_info); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *db_handles_info = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0]; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0], "kbp_sw_state[%d]->db_handles_info[%d]", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_caching_bmp_set(int unit, uint32 db_handles_info_idx_0, int caching_bmp) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].caching_bmp, caching_bmp, int, 0, "kbp_sw_state_db_handles_info_caching_bmp_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &caching_bmp, "kbp_sw_state[%d]->db_handles_info[%d].caching_bmp", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_CACHING_BMP_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_caching_bmp_get(int unit, uint32 db_handles_info_idx_0, int *caching_bmp) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, caching_bmp); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *caching_bmp = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].caching_bmp; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].caching_bmp, "kbp_sw_state[%d]->db_handles_info[%d].caching_bmp", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_CACHING_BMP_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_db_p_set(int unit, uint32 db_handles_info_idx_0, kbp_db_t_p db_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].db_p, db_p, kbp_db_t_p, 0, "kbp_sw_state_db_handles_info_db_p_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &db_p, "kbp_sw_state[%d]->db_handles_info[%d].db_p", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_DB_P_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_db_p_get(int unit, uint32 db_handles_info_idx_0, kbp_db_t_p *db_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, db_p); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *db_p = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].db_p; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].db_p, "kbp_sw_state[%d]->db_handles_info[%d].db_p", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_DB_P_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_ad_db_zero_size_p_set(int unit, uint32 db_handles_info_idx_0, kbp_ad_db_t_p ad_db_zero_size_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_db_zero_size_p, ad_db_zero_size_p, kbp_ad_db_t_p, 0, "kbp_sw_state_db_handles_info_ad_db_zero_size_p_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &ad_db_zero_size_p, "kbp_sw_state[%d]->db_handles_info[%d].ad_db_zero_size_p", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_AD_DB_ZERO_SIZE_P_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_ad_db_zero_size_p_get(int unit, uint32 db_handles_info_idx_0, kbp_ad_db_t_p *ad_db_zero_size_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, ad_db_zero_size_p); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *ad_db_zero_size_p = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_db_zero_size_p; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_db_zero_size_p, "kbp_sw_state[%d]->db_handles_info[%d].ad_db_zero_size_p", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_AD_DB_ZERO_SIZE_P_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_ad_entry_zero_size_p_set(int unit, uint32 db_handles_info_idx_0, kbp_ad_entry_t_p ad_entry_zero_size_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_entry_zero_size_p, ad_entry_zero_size_p, kbp_ad_entry_t_p, 0, "kbp_sw_state_db_handles_info_ad_entry_zero_size_p_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &ad_entry_zero_size_p, "kbp_sw_state[%d]->db_handles_info[%d].ad_entry_zero_size_p", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_AD_ENTRY_ZERO_SIZE_P_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_ad_entry_zero_size_p_get(int unit, uint32 db_handles_info_idx_0, kbp_ad_entry_t_p *ad_entry_zero_size_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, ad_entry_zero_size_p); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *ad_entry_zero_size_p = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_entry_zero_size_p; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_entry_zero_size_p, "kbp_sw_state[%d]->db_handles_info[%d].ad_entry_zero_size_p", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_AD_ENTRY_ZERO_SIZE_P_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_ad_db_p_set(int unit, uint32 db_handles_info_idx_0, uint32 ad_db_p_idx_0, kbp_ad_db_t_p ad_db_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( ad_db_p_idx_0, DNX_KBP_NOF_AD_DB_INDEX); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_db_p[ad_db_p_idx_0], ad_db_p, kbp_ad_db_t_p, 0, "kbp_sw_state_db_handles_info_ad_db_p_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &ad_db_p, "kbp_sw_state[%d]->db_handles_info[%d].ad_db_p[%d]", unit, db_handles_info_idx_0, ad_db_p_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_AD_DB_P_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_ad_db_p_get(int unit, uint32 db_handles_info_idx_0, uint32 ad_db_p_idx_0, kbp_ad_db_t_p *ad_db_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, ad_db_p); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( ad_db_p_idx_0, DNX_KBP_NOF_AD_DB_INDEX); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *ad_db_p = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_db_p[ad_db_p_idx_0]; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].ad_db_p[ad_db_p_idx_0], "kbp_sw_state[%d]->db_handles_info[%d].ad_db_p[%d]", unit, db_handles_info_idx_0, ad_db_p_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_AD_DB_P_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_opt_result_size_set(int unit, uint32 db_handles_info_idx_0, int opt_result_size) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].opt_result_size, opt_result_size, int, 0, "kbp_sw_state_db_handles_info_opt_result_size_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &opt_result_size, "kbp_sw_state[%d]->db_handles_info[%d].opt_result_size", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_OPT_RESULT_SIZE_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_opt_result_size_get(int unit, uint32 db_handles_info_idx_0, int *opt_result_size) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, opt_result_size); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *opt_result_size = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].opt_result_size; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].opt_result_size, "kbp_sw_state[%d]->db_handles_info[%d].opt_result_size", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_OPT_RESULT_SIZE_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_cloned_db_id_set(int unit, uint32 db_handles_info_idx_0, int cloned_db_id) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].cloned_db_id, cloned_db_id, int, 0, "kbp_sw_state_db_handles_info_cloned_db_id_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &cloned_db_id, "kbp_sw_state[%d]->db_handles_info[%d].cloned_db_id", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_CLONED_DB_ID_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_cloned_db_id_get(int unit, uint32 db_handles_info_idx_0, int *cloned_db_id) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, cloned_db_id); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *cloned_db_id = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].cloned_db_id; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].cloned_db_id, "kbp_sw_state[%d]->db_handles_info[%d].cloned_db_id", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_CLONED_DB_ID_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_associated_dbal_table_id_set(int unit, uint32 db_handles_info_idx_0, int associated_dbal_table_id) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].associated_dbal_table_id, associated_dbal_table_id, int, 0, "kbp_sw_state_db_handles_info_associated_dbal_table_id_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &associated_dbal_table_id, "kbp_sw_state[%d]->db_handles_info[%d].associated_dbal_table_id", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_ASSOCIATED_DBAL_TABLE_ID_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_db_handles_info_associated_dbal_table_id_get(int unit, uint32 db_handles_info_idx_0, int *associated_dbal_table_id) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( db_handles_info_idx_0, DNX_KBP_NOF_DBS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, associated_dbal_table_id); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *associated_dbal_table_id = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].associated_dbal_table_id; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->db_handles_info[db_handles_info_idx_0].associated_dbal_table_id, "kbp_sw_state[%d]->db_handles_info[%d].associated_dbal_table_id", unit, db_handles_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_DB_HANDLES_INFO_ASSOCIATED_DBAL_TABLE_ID_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_instruction_info_set(int unit, uint32 instruction_info_idx_0, CONST kbp_instruction_handles_t *instruction_info) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_MEMCPY( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->instruction_info[instruction_info_idx_0], instruction_info, kbp_instruction_handles_t, 0, "kbp_sw_state_instruction_info_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, instruction_info, "kbp_sw_state[%d]->instruction_info[%d]", unit, instruction_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_INSTRUCTION_INFO_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_instruction_info_get(int unit, uint32 instruction_info_idx_0, kbp_instruction_handles_t *instruction_info) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( instruction_info_idx_0, DNX_KBP_NOF_INSTRUCTIONS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, instruction_info); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *instruction_info = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->instruction_info[instruction_info_idx_0]; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->instruction_info[instruction_info_idx_0], "kbp_sw_state[%d]->instruction_info[%d]", unit, instruction_info_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_INSTRUCTION_INFO_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_instruction_info_inst_p_set(int unit, uint32 instruction_info_idx_0, uint32 inst_p_idx_0, kbp_instruction_t_p inst_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_SET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( instruction_info_idx_0, DNX_KBP_NOF_INSTRUCTIONS); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( inst_p_idx_0, DNX_KBP_NOF_SMTS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); DNX_SW_STATE_SET( unit, KBP_MODULE_ID, ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->instruction_info[instruction_info_idx_0].inst_p[inst_p_idx_0], inst_p, kbp_instruction_t_p, 0, "kbp_sw_state_instruction_info_inst_p_set"); DNX_SW_STATE_LOG( unit, DNX_SW_STATE_SET_LOGGING, BSL_LS_SWSTATEDNX_SET, KBP_MODULE_ID, &inst_p, "kbp_sw_state[%d]->instruction_info[%d].inst_p[%d]", unit, instruction_info_idx_0, inst_p_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_INSTRUCTION_INFO_INST_P_INFO, DNX_SW_STATE_DIAG_MODIFY, NULL); DNXC_SW_STATE_FUNC_RETURN; } int kbp_sw_state_instruction_info_inst_p_get(int unit, uint32 instruction_info_idx_0, uint32 inst_p_idx_0, kbp_instruction_t_p *inst_p) { DNXC_SW_STATE_INIT_FUNC_DEFS; VERIFY_FUNCTION_CALL_ALLOWED( unit, KBP_MODULE_ID, SW_STATE_FUNC_GET, DNXC_SW_STATE_NO_FLAGS); VERIFY_MODULE_IS_INITIALIZED( unit, KBP_MODULE_ID, sw_state_roots_array[unit][KBP_MODULE_ID]); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( instruction_info_idx_0, DNX_KBP_NOF_INSTRUCTIONS); DNX_SW_STATE_PTR_NULL_CHECK( unit, KBP_MODULE_ID, inst_p); DNX_SW_STATE_OOB_STATIC_ARRAY_CHECK( inst_p_idx_0, DNX_KBP_NOF_SMTS); DNX_SW_STATE_DIAG_INFO_PRE( unit, KBP_MODULE_ID); *inst_p = ((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->instruction_info[instruction_info_idx_0].inst_p[inst_p_idx_0]; DNX_SW_STATE_LOG( unit, DNX_SW_STATE_GET_LOGGING, BSL_LS_SWSTATEDNX_GET, KBP_MODULE_ID, &((kbp_sw_state_t*)sw_state_roots_array[unit][KBP_MODULE_ID])->instruction_info[instruction_info_idx_0].inst_p[inst_p_idx_0], "kbp_sw_state[%d]->instruction_info[%d].inst_p[%d]", unit, instruction_info_idx_0, inst_p_idx_0); DNX_SW_STATE_DIAG_INFO_POST( unit, KBP_MODULE_ID, kbp_sw_state_info, KBP_SW_STATE_INSTRUCTION_INFO_INST_P_INFO, DNX_SW_STATE_DIAG_READ, NULL); DNXC_SW_STATE_FUNC_RETURN; } const char * dnx_kbp_ad_db_index_e_get_name(dnx_kbp_ad_db_index_e value) { DNX_SW_STATE_ENUM_COMPARE_AND_GET_NAME("DNX_KBP_AD_DB_INDEX_REGULAR", value, DNX_KBP_AD_DB_INDEX_REGULAR); DNX_SW_STATE_ENUM_COMPARE_AND_GET_NAME("DNX_KBP_AD_DB_INDEX_OPTIMIZED", value, DNX_KBP_AD_DB_INDEX_OPTIMIZED); DNX_SW_STATE_ENUM_COMPARE_AND_GET_NAME("DNX_KBP_NOF_AD_DB_INDEX", value, DNX_KBP_NOF_AD_DB_INDEX); return NULL; } kbp_sw_state_cbs kbp_sw_state = { kbp_sw_state_is_init, kbp_sw_state_init, { kbp_sw_state_is_device_locked_set, kbp_sw_state_is_device_locked_get} , { kbp_sw_state_db_handles_info_set, kbp_sw_state_db_handles_info_get, { kbp_sw_state_db_handles_info_caching_bmp_set, kbp_sw_state_db_handles_info_caching_bmp_get} , { kbp_sw_state_db_handles_info_db_p_set, kbp_sw_state_db_handles_info_db_p_get} , { kbp_sw_state_db_handles_info_ad_db_zero_size_p_set, kbp_sw_state_db_handles_info_ad_db_zero_size_p_get} , { kbp_sw_state_db_handles_info_ad_entry_zero_size_p_set, kbp_sw_state_db_handles_info_ad_entry_zero_size_p_get} , { kbp_sw_state_db_handles_info_ad_db_p_set, kbp_sw_state_db_handles_info_ad_db_p_get} , { kbp_sw_state_db_handles_info_opt_result_size_set, kbp_sw_state_db_handles_info_opt_result_size_get} , { kbp_sw_state_db_handles_info_cloned_db_id_set, kbp_sw_state_db_handles_info_cloned_db_id_get} , { kbp_sw_state_db_handles_info_associated_dbal_table_id_set, kbp_sw_state_db_handles_info_associated_dbal_table_id_get} } , { kbp_sw_state_instruction_info_set, kbp_sw_state_instruction_info_get, { kbp_sw_state_instruction_info_inst_p_set, kbp_sw_state_instruction_info_inst_p_get} } } ; #endif #endif #undef BSL_LOG_MODULE
the_stack_data/194394.c
// SPDX-License-Identifier: X11 // 2020-11-09 // 正直者 #include <stdio.h> int main() { int X,Y; scanf("%d %d", &X, &Y); printf("%d\n", X > Y ? X : Y); }
the_stack_data/70450282.c
//Random sample from N(m,s^2) distribution. #include<stdio.h> #include<math.h> #include<stdlib.h> #include<time.h> int main() { int i,j,n; float u1,u2,m,s,x,y; printf("Enter the parameters, m & s of N(m,s^2) distribution:\n"); scanf("%f%f",&m,&s); printf("Enter the number of observations to be generated:\n"); scanf("%d",&n); srand(time(0)); printf("The random sample is:\n\n"); for(i=1;i<=n;i++) { u1=rand()/(float)RAND_MAX; u2=rand()/(float)RAND_MAX; x=sqrt(-2*log(u1))*sin(2*3.14*u2); y=m+s*x; printf("%f\t",y); } printf("\n"); }
the_stack_data/57950785.c
#include <stdio.h> int main() { int v1,v2,v3,v4,v5,n; v1 = 1; v2 = 3; v3 = 4; v4 = 6; v5 = 9; printf("Enter a positive number: "); scanf("%d",&n); while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { while (n <= 6) { v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } v1 = v2; v2 = v3; v3 = v4; v4 = v5; v5 = v1; n = n+1; } printf("v5=%d",v5); return 0; }
the_stack_data/1264062.c
/* * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 * The President and Fellows of Harvard College. * * 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. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY 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 UNIVERSITY 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. */ #include <stdio.h> #include <unistd.h> #include <string.h> #include <err.h> #include <limits.h> /* * pwd - print working directory. * Usage: pwd * * Just uses the getcwd library call (which in turn uses the __getcwd * system call.) */ int main() { char buf[PATH_MAX+1], *p; p = getcwd(buf, sizeof(buf)); if (p == NULL) { err(1, "."); } printf("%s\n", buf); return 0; }
the_stack_data/860586.c
typedef union { int raw; struct{ unsigned int n:16; //дробное int m:16; //целое }; }u_fixed16; u_fixed16 fix_add(u_fixed16 a, u_fixed16 b) { u_fixed16 c={.raw=a.raw+b.raw}; return c; } u_fixed16 fix_sub(u_fixed16 a, u_fixed16 b) { u_fixed16 c={.raw=a.raw-b.raw}; return c; } u_fixed16 fix_mull(u_fixed16 a, u_fixed16 b) { int sign=a.raw & 0x80000000; a.raw &=~ 0x80000000; long aa=(long)a.raw; long bb=(long)b.raw; long r=(aa*bb)>>16; u_fixed16 rv={.raw=r|sign}; return rv; } u_fixed16 fix_div(u_fixed16 a, u_fixed16 b) { int sign=a.raw & 0x80000000; a.raw &=~ 0x80000000; long aa=(long)a.raw<<16; long bb=(long)b.raw; long r=(aa/bb); u_fixed16 rv={.raw=r|sign}; return rv; } #ifdef _STDIO_H #include <stdio.h> void print_drob(u_fixed16 a){ printf("%d.",a.m); u_fixed16 b={.m=10000,.n=0}; a.m=0; a=fix_mull(a,b); printf("%d\n",a.m); } #endif // DEBUG u_fixed16 u_int_to_fixed16(short m,unsigned short n){ u_fixed16 a={.m=n,.n=0}; u_fixed16 b={.m=10000,.n=0}; b=fix_div(a,b); b.m=m; b.n+=1; // print_drob(b); return b; } u_fixed16 u_sqrt(u_fixed16 A); u_fixed16 u_ln(u_fixed16 A); __attribute__((weak)) int main(int argc, char const *argv[]) { u_fixed16 a=u_int_to_fixed16(3,0000); a=u_ln(a); print_drob(a); return 0; } u_fixed16 u_sqrt(u_fixed16 A) { u_fixed16 x=fix_div(A, (u_fixed16)0x00020000); for (int k=0;k<20;k++){ x=fix_div(fix_add(x, fix_div(A,x)),(u_fixed16)0x00020000); } return x; } /* * A^n * ------------------------ * A^x'= A^x * ln(A) * A^x''= A^x * ln(A) * ln(A) * * f(x0)' f(x0)'' * C = ------ * (x-x0) + ------ * (x-x0)^2 + ... + остаточное выражение * 1! 2! * * x0 = 0 <= Превратим Тейлора в Маклорена * * * ln(A) * x + 0.5 * (ln(A)* x)^2 + 0.1667 * (ln(A)* x)^3 + 0.0417 * (ln(A)* x)^4 * * */ /* * ln(a) * ------------------------ * ln(x)' = 1/x * ln(x)'' =-1/x^2 * ln(x)''' = 2/x^3 * ln(x)''' =-6/x^4 * ln(x)'''' = 24/x^5 * * f(x0)' f(x0)'' * f(x) = ------ * (x-x0) + ------ * (x-x0)^2 + ... + остаточное выражение * 1! 2! * * x0 = 1 * * * f(x) = (x-1) - 1/((x-1)^2)*2 + 3/(x-1)^3 - 4/(x-1)^4 * * */ u_fixed16 u_pow(u_fixed16 A, u_fixed16 X){ } u_fixed16 _step(u_fixed16 A, int X){ if(!X){return u_int_to_fixed16(1,0);} u_fixed16 x=u_int_to_fixed16(X,0); for(int i=1;i<X;i++){ A=fix_mull(A, x); } return A; } u_fixed16 u_ln(u_fixed16 A){ u_fixed16 a=fix_div( u_int_to_fixed16(1,0),_step(fix_sub(A,u_int_to_fixed16(1,0)),1)); u_fixed16 b= _step(fix_sub(A,u_int_to_fixed16(1,0)),2); b=fix_div(u_int_to_fixed16(1,0),b); b=fix_div(b,u_int_to_fixed16(2,0)); a.raw-=b.raw; for(int i=3;i<500;i){ b= _step(fix_sub(A,u_int_to_fixed16(1,0)),i); b=fix_div(u_int_to_fixed16(1,0),b); b=fix_div(b,u_int_to_fixed16(i,0)); a.raw+=b.raw; i++; print_drob(a); b= _step(fix_sub(A,u_int_to_fixed16(1,0)),i); b=fix_div(u_int_to_fixed16(1,0),b); b=fix_div(b,u_int_to_fixed16(i,0)); a.raw-=b.raw; i++; print_drob(a); } return a; }
the_stack_data/193893229.c
#include <term.h> #define char_padding tigetstr("rmp") /** like TERMCAP(ip) but when in replace mode **/ /* TERMINFO_NAME(rmp) TERMCAP_NAME(rP) XOPEN(400) */
the_stack_data/514730.c
/********************************************************* * From C PROGRAMMING: A MODERN APPROACH, Second Edition * * By K. N. King * * Copyright (c) 2008, 1996 W. W. Norton & Company, Inc. * * All rights reserved. * * This program may be freely distributed for class use, * * provided that this copyright notice is retained. * *********************************************************/ /* square.c (Chapter 6, page 102) */ /* Prints a table of squares using a while statement */ #include <stdio.h> int main(void) { int i, n; printf("This program prints a table of squares.\n"); printf("Enter number of entries in table: "); scanf("%d", &n); i = 1; while (i <= n) { printf("%10d%10d\n", i, i * i); i++; } return 0; }
the_stack_data/73574832.c
/* posix/_cfgetospeed Created: June 11, 1993 by Philip Homburg */ #include <termios.h> speed_t _cfgetospeed(const struct termios *termios_p) { return termios_p->c_ospeed; }
the_stack_data/44569.c
# include<stdio.h> int main() { int choice; int i=0,j,b[5]; char c[5]; float t[5]; void *a[5]; while(i<5) { printf("press 1. enter integer 2.enter character 3.float"); scanf("%d",&choice); switch(choice) { case 1: printf("enter the number"); scanf("%d",&b[i]); a[i]=&b[i]; break; case 2: printf("enter the character"); scanf("%c",&c[i]); scanf("%c",&c[i]); a[i]=&c[i]; break; case 3: printf("enter the float"); scanf("%f",&t[i]); a[i]=&t[i]; break; } i++; } for(i=0;i<5;i++) { if(a[i]==&c[i]) printf("%c\n",c[i]); if(a[i]==&b[i]) printf("%d\n",b[i]); if(a[i]==&t[i]) printf("%f\n",t[i]); } }
the_stack_data/950071.c
#include <stdio.h> #define STRLEN 100 void escape(char s[], char t[]); int main(void) { char s[STRLEN]; char t[STRLEN] = "Salut nene\nCe mai faci?\n\tEsti bine?"; escape(s, t); printf("%s\n", s); return 0; } void escape(char s[], char t[]) { unsigned int i = 0; unsigned int j = 0; while(t[i] != '\0') { switch(t[i]) { case '\n': s[j] = '\\'; s[++j] = 'n'; break; case '\t': s[j] = '\\'; s[++j] = 't'; break; default: s[j] = t[i]; break; } ++i; ++j; } s[j] = '\0'; }
the_stack_data/125912.c
/** * \file * \brief arguments test. */ /* * Copyright (c) 2014, HP Labs. * All rights reserved. * * This file is distributed under the terms in the attached LICENSE file. * If you do not find this file, copies can be found by writing to: * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. */ #include <stdio.h> int main(int argc, char *argv[]) { for (int i = 0; i < argc; i++) { printf("argv[%d] = %s\n", i, argv[i]); } return 0; }
the_stack_data/107952710.c
#include <stdio.h> main() { int n,i,j,temp; do{ printf("Enter the number of elements in array\n"); scanf("%d",&n); }while (n<1); int a[n]; printf("\nEnter the elements in array\n"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("\nYour array is: "); for (i=0;i<n;i++) printf("%d ",a[i]); for (i=0;i<n;i++) { for (j=0;j+1<n-i;j++) { if (a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("\nSorted Array using Bubblr Sort is: "); for(i=0;i<n;i++) printf("%d ",a[i]); }
the_stack_data/162643912.c
/* gcc -g -o test 01_demo.c valgrind --tool=memcheck --leak-check=full ./test valgrind: Fatal error at startup: a function redirection sudo apt-get install libc6-dbg 申请未释放 ==19146== LEAK SUMMARY: ==19146== definitely lost: 4 bytes in 1 blocks ==19146== indirectly lost: 0 bytes in 0 blocks ==19146== possibly lost: 0 bytes in 0 blocks ==19146== still reachable: 0 bytes in 0 blocks ==19146== suppressed: 0 bytes in 0 blocks */ #include <stdlib.h> int main() { int *array = malloc(sizeof(int)); return 0; }
the_stack_data/50137101.c
#include <stdio.h> void foo2(int _k); typedef void (*funp)(int x); typedef int (*funptr)(void); funp ptr = foo2; void foo1(int _i, int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8,int i9) { int x; long j[10]={1,2,3,4,5,6,7,8,9}; int * runhack=NULL; long* hack = NULL; /*<< my evil pointer*/ printf("J[9] %ld &J[9] %p\n",j[9],&j[9]); hack = &j[9]; runhack = &j[9]; puts("stack image"); for(x = 0; x < 10*sizeof(int); ++x) { printf("%p\t\t0x%x\n",runhack,*runhack); ++runhack; } hack+=4; *hack=foo2; /* rt = &j[9]; rt = rt + 32/sizeof(int); printf("rt pointer %p\n",*rt); rt=ptr;*/ /* hack = 0x40000c2; *hack = ;*/ return; } void foo2(int _k) { int arr[10]= {10,11,12,13,14,15,16,17,18,19}; puts("Life is Cool. No More Main Again!"); printf("%d %d\n",arr[0],_k); return; } int main (void) { funptr x = main; printf(">>>>>>>> Main address = %p\n\n",(void*)x); printf(">>>>>>>> Foo1 address = %p\n",(void*)foo1); printf(">>>>>>>> Foo2 address = %p\n",(void*)foo2); int i=33; foo1(i,i+1,i+2,i+3,i+4,i+5,i+6,i+7,i+8,i+9); puts("********************************"); printf("Main !!\n"); puts("********************************"); return 0; }
the_stack_data/107953498.c
// stack traces #include <stdlib.h> // exit #include <stdio.h> // printf struct st_entry { char file[64], call[64]; unsigned int line; }; struct {struct st_entry entry[255]; unsigned char curr;} ST = {.curr=0}; #define st_push(fn)\ ST.entry[ST.curr] = \ (struct st_entry) {.file=__FILE__, .call=#fn, .line=__LINE__};\ if ((++ST.curr)+1 > 255) {puts("\nFunction stack overflow"); st_trace(); exit(1);} #define st_assert(cond, msg) \ ({if (!(cond)){\ st_push(st_assert(cond, msg));\ printf("\nAssert: %s", msg);\ st_trace(); exit(1);}\ cond;}) int st_entry_equal (struct st_entry* a, struct st_entry* b) { int f = 0, c = 0; // file/call readers if (a->line != b->line) return 0; while (a->file[f]!=0 || b->file[f]!=0) if (a->file[f] != b->file[f]) return 0; else f++; while (a->call[c]!=0 || b->call[c]!=0) if (a->call[c] != b->call[c]) return 0; else c++; return 1; } // typed call #define st_c(rtype, fn) ({ st_push(fn); rtype r = fn; ST.curr--; r;}) // void call #define st_v(fn) ({ st_push(fn); fn; ST.curr--;}) void st_trace () { printf("\nTraceback (last call first):\n"); struct st_entry *entry; int skip = 0; for (int u = ST.curr; u > 0; u--) { entry = &ST.entry[u-1]; if (skip) { if (!st_entry_equal(entry, &ST.entry[u])) { printf(" %d more ...\n", skip); skip = 0; } else skip++; } if (!skip) { printf("%12s:%-5d| %s\n", entry->file, entry->line, entry->call); if (st_entry_equal(entry, &ST.entry[u])) { skip++; printf("%12s", "..."); } } } } int checkeven(int n) { return st_assert(n%2, "oh no! it's even!"); } int foo (int n) { return st_c(int, checkeven(n)); } int recurs(int n) { if (n>0) return st_c(int, recurs(n-1)); return 0; } int main () { st_c(int, foo(13)); st_c(int, recurs(255)); // 254 and overflow triggers st_c(int, foo(12)); }
the_stack_data/997271.c
// RUN: %clang -ccc-host-triple x86_64-unknown-unknown -c -x assembler %s -### 2> %t.log // RUN: grep '.*gcc.*"-m64"' %t.log // RUN: %clang -ccc-host-triple x86_64-unknown-unknown -c -x assembler %s -### -m32 2> %t.log // RUN: grep '.*gcc.*"-m32"' %t.log // RUN: %clang -ccc-host-triple i386-unknown-unknown -c -x assembler %s -### 2> %t.log // RUN: grep '.*gcc.*"-m32"' %t.log // RUN: %clang -ccc-host-triple i386-unknown-unknown -c -x assembler %s -### -m64 2> %t.log // RUN: grep '.*gcc.*"-m64"' %t.log
the_stack_data/83769.c
#include <stdint.h> uint64_t __rand48_step(unsigned short *xi, unsigned short *lc) { uint64_t a, x; x = xi[0] | xi[1]+0U<<16 | xi[2]+0ULL<<32; a = lc[0] | lc[1]+0U<<16 | lc[2]+0ULL<<32; x = a*x + lc[3]; xi[0] = x; xi[1] = x>>16; xi[2] = x>>32; return x & 0xffffffffffffull; }
the_stack_data/92327970.c
/* * autor: cristobal liendo i * fecha: 30/10/17 * descripcion. 2d arrays */ #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(0)); int califas[2][10]; for (int i = 0; i < 2; i++) for (int j = 0; j < 10; j++) califas[i][j] = (rand() % 6) + 5; printf("Las calificaciones del primer grupo son:\n"); for (int i = 0; i < 10; i++) printf("%d%s", califas[0][i], (i == 9) ? "\n" : ", "); printf("\nLas calificaciones del segundo grupo son:\n"); for (int i = 0; i < 10; i++) printf("%d%s", califas[1][i], (i == 9) ? "\n" : ", "); }
the_stack_data/104827260.c
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define ROWS 480 #define COLS 640 #define DEGREES(radians) ((radians) * 57.29577951308232087679815481410517033240) #define RADIANS(degrees) ((degrees) * 0.017453292519943295769236907684886127134) void clear(unsigned char image[][COLS]); void read_image(char *fname, unsigned char image[][COLS]); void DIP(unsigned char image[][COLS], char *fname, unsigned char t); void threshold(unsigned char image[][COLS], unsigned char t); void header( int row, int col, unsigned char head[32] ); void save_image(char *fname, unsigned char image[][COLS]); int find_edge(int x, int y, int rho, int theta); int main() { unsigned char image[ROWS][COLS]; clear(image); read_image("image.raw", image); DIP(image, "image", 100); clear(image); return 0; } void clear( unsigned char image[][COLS] ) { int i,j; for ( i = 0 ; i < ROWS ; i++ ) for ( j = 0 ; j < COLS ; j++ ) image[i][j] = 0; } void read_image(char *fname, unsigned char image[][COLS]) { int i; FILE *fp; /* Read in a raw image */ /* Open the file */ if (( fp = fopen( fname, "rb" )) == NULL ) { fprintf( stderr, "error: couldn't open %s\n", fname ); exit( 1 ); } /* Read the file */ for ( i = 0; i < ROWS ; i++ ) if ( fread( image[i], 1, COLS, fp ) != COLS ) { fprintf( stderr, "error: couldn't read enough stuff\n" ); exit( 1 ); } /* Close the file */ fclose( fp ); printf("Image %s read successfully!\n", fname); } void save_image(char *fname, unsigned char image[][COLS]) { int i; unsigned char head[32]; FILE *fp; /* Save it into a ras image */ /* Open the file */ if (!( fp = fopen( fname, "wb" ))) fprintf( stderr, "error: could not open %s\n", fname ), exit(1); /* Create a header */ header(ROWS, COLS, head); /* Write the header */ fwrite( head, 4, 8, fp ); /* Write the image */ for ( i = 0; i < ROWS; i++ ) fwrite( image[i], 1, COLS, fp ); /* Close the file */ fclose( fp ); } void DIP(unsigned char image[][COLS], char *fname, unsigned char t) { int x, y, i, j, k; int sobelx, sobely, sgmval; int xmax = 0, ymax = 0, sgm_max = 0; int rho, theta; int minr = 0, maxr = 0; unsigned char edgex[ROWS][COLS]; unsigned char edgey[ROWS][COLS]; unsigned char SGM[ROWS][COLS]; unsigned char hough[ROWS][COLS]; static int bins[1600][180]; char exname[100], eyname[100], sgmname[100], bname[100]; clear(edgex); clear(edgey); clear(SGM); clear(hough); strcpy(exname, fname); strcpy(eyname, fname); strcpy(sgmname, fname); strcpy(bname, fname); strcat(exname, "_dx.ras"); strcat(eyname, "_dy.ras"); strcat(sgmname, "_sgm.ras"); strcat(bname, "_binary.ras"); for(y = 1; y < ROWS-1; y++) { for(x = 1; x < COLS-1; x++) { /* dE/dx */ sobelx = (-(image[y+1][x-1] + 2*image[y][x-1] + image[y-1][x-1]) + image[y+1][x+1] + 2*image[y][x+1] + image[y-1][x+1]); edgex[y][x] = sobelx; if(sobelx > xmax) { xmax = sobelx; } /* dE/dy */ sobely = (-(image[y+1][x-1] + 2*image[y+1][x] + image[y+1][x+1]) + image[y-1][x-1] + 2*image[y-1][x] + image[y-1][x+1]); edgey[y][x] = sobely; if(sobely > ymax) { ymax = sobely; } /* SGM */ sgmval = pow(pow(edgex[y][x], 2) + pow(edgey[y][x], 2), 0.5); SGM[y][x] = sgmval; if(sgmval > sgm_max) { sgm_max = sgmval;} } } /* Normalize */ for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { edgex[y][x] = 255*edgex[y][x]/xmax; edgey[y][x] = 255*edgey[y][x]/ymax; SGM[y][x] = 255*SGM[y][x]/sgm_max; } } save_image(exname, edgex); save_image(eyname, edgey); save_image(sgmname, SGM); threshold(SGM, t); save_image(bname, SGM); /* Hough transform */ for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { for(theta = 0; theta <= 180; theta++) { rho = -(x*sin(RADIANS(theta)) - y*cos(RADIANS(theta))); if (rho > maxr) {maxr = rho;} if (rho < minr) {minr = rho;} if (SGM[y][x] == 255) { /* printf("For [%d, %d] and theta, rho is: %d, %d\n", x, y, theta, rho); */ bins[rho + 800][theta]++; } } } } printf("Rho ranges from [%d, %d]\n", minr, maxr); /* Threshold bins */ for(j = 0; j < 1600; j++) { for(i = 0; i < 180; i++) { if(bins[j][i] > 100) { k = j - 800; printf("[%d, %d] = %d\n", k, i, bins[j][i]); } } } /* From above, rho and theta are estimated to be: Line 1: rho[-289, -302], theta[126, 131], peak @ -295, 129 Line 2: rho[-169, -171], theta[51], peak @ -171, 51 Line 3: rho[312, 321], theta[13, 14], peak @ 312, 14 */ for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { /* Line 1 */ if(find_edge(x, y, -295, 129)) {hough[y][x]=255;} /* Line 2 */ if(find_edge(x, y, -171, 51)) {hough[y][x]=255;} /* Line 3 */ if(find_edge(x, y, 312, 14)) {hough[y][x]=255;} } } save_image("hough.ras",hough); } int find_edge(int x, int y, int rho, int theta) { int a; a = ((x*sin(RADIANS(theta))) - (y*cos(RADIANS(theta))) + rho); if (a < 1 && a > -1) {return 1;} else {return 0;} } void threshold(unsigned char image[][COLS], unsigned char t) { int x, y; int a = 0; int cx = 0, cy = 0; for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { /* Thresholding */ if (image[y][x] >= t) { image[y][x] = 255; } /* Disregard background */ else { image[y][x] = 0; cx += x; cy += y; a += 1; } } } cx = cx/a; cy = cy/a; /* Re-color 5x5 center area */ for(y = cy - 2; y < cy + 3; y++) { for(x = cx - 2; x < cx + 3; x++) { image[y][x] = 128; } } printf("The area of the image is: %d pixels\n", a); printf("The center of the image is (x, y): (%d, %d)\n", cx, cy); } void header( int row, int col, unsigned char head[32] ) { int *p = (int *)head; char *ch; int num = row * col; /* Choose little-endian or big-endian header depending on the machine. Don't modify this */ /* Little-endian for PC */ *p = 0x956aa659; *(p + 3) = 0x08000000; *(p + 5) = 0x01000000; *(p + 6) = 0x0; *(p + 7) = 0xf8000000; ch = (char*)&col; head[7] = *ch; ch ++; head[6] = *ch; ch ++; head[5] = *ch; ch ++; head[4] = *ch; ch = (char*)&row; head[11] = *ch; ch ++; head[10] = *ch; ch ++; head[9] = *ch; ch ++; head[8] = *ch; ch = (char*)&num; head[19] = *ch; ch ++; head[18] = *ch; ch ++; head[17] = *ch; ch ++; head[16] = *ch; /* // Big-endian for unix *p = 0x59a66a95; *(p + 1) = col; *(p + 2) = row; *(p + 3) = 0x8; *(p + 4) = num; *(p + 5) = 0x1; *(p + 6) = 0x0; *(p + 7) = 0xf8; */ }
the_stack_data/115764349.c
#include <stdio.h> #include <ctype.h> // forward declaration int can_print_it(char ch); void print_letters(char arg[]); void print_arguments(int argc, char *argv[]) { int i = 0; for (i=0; i < argc; i++) { print_letters(argv[i]); } } void print_letters(char arg[]) { int i = 0; for (i = 0; arg[i] != '\0'; i++) { char ch = arg[i]; if (can_print_it(ch)) { printf("'%c' == %d ", ch, ch); } } printf("\n"); } int can_print_it(char ch) { return isalpha((int)ch) || isblank((int)ch); } int main (int argc, char *argv[]) { print_arguments(argc, argv); return 0; }
the_stack_data/234517796.c
#include <stdatomic.h> #include <pthread.h> #include <assert.h> #include <stdbool.h> #include <stdlib.h> extern void abort(void); #define CAS(ptr, expected, desired) (atomic_compare_exchange_strong_explicit(ptr, expected, desired, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED)) #define load(loc) (atomic_load_explicit(loc, __ATOMIC_ACQUIRE)) #define store(loc, val) (atomic_store_explicit(loc, val, __ATOMIC_RELEASE)) #define rx_load(loc) (atomic_load_explicit(loc, __ATOMIC_RELAXED)) #define rx_store(loc, val) (atomic_store_explicit(loc, val, __ATOMIC_RELAXED)) #define EMPTY -1 /* extern void retire(Node* ptr); */ void reach_error() { assert(0); } void __VERIFIER_assert(int expression) { if (!expression) { ERROR: {reach_error();abort();}}; return; } typedef struct Node { int val; _Atomic(struct Node*) next; } Node; _Atomic(Node *) Tail; _Atomic(Node *) Head; void init() { Node* node = malloc(sizeof (Node)); atomic_init(&node->next, NULL); atomic_init(&Head, node); atomic_init(&Tail, node); } void enqueue(int value) { Node *tail, *next, *node; node = malloc(sizeof (Node)); node->val = value; atomic_init(&node->next, NULL); while (true) { tail = load(&Tail); __VERIFIER_assert(tail != NULL); next = load(&tail->next); if (tail == load(&Tail)) { if (next == NULL) { if (CAS(&tail->next, &next, node)) { CAS(&Tail, &tail, node); break; } } else { CAS(&Tail, &tail, next); } } } } int dequeue() { Node *head, *next, *tail; int result; while (true) { head = load(&Head); __VERIFIER_assert(head != NULL); next = load(&head->next); if (head == load(&Head)) { if (next == NULL) { result = EMPTY; break; } else { result = next->val; //make atomic? if (CAS(&Head, &head, next)) { tail = load(&Tail); __VERIFIER_assert(tail != NULL); if (head == tail) { CAS(&Tail, &tail, next); } break; } } } } return result; } // =========== Worker threads ============== void *worker_1(void *unused) { int r; enqueue(42); r = dequeue(); __VERIFIER_assert(r != EMPTY); return NULL; } void *worker_2(void *unused) { int r; enqueue(41); r = dequeue(); __VERIFIER_assert(r != EMPTY); return NULL; } int main() { pthread_t t1, t2; init(); if (pthread_create(&t1, NULL, worker_1, NULL)) abort(); if (pthread_create(&t2, NULL, worker_2, NULL)) abort(); if (pthread_join(t1, NULL)) abort(); if (pthread_join(t2, NULL)) abort(); int r = dequeue(); __VERIFIER_assert(r == EMPTY); return 0; }
the_stack_data/190769395.c
int main(){ int x; int *p; printf("Informe o valor de x: "); scanf("%d", &x); p=&x; printf("O valor de x e: %d", *p); }
the_stack_data/127441.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2020-2021 Free Software Foundation, Inc. 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 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ extern int foo (void); int main (void) { return foo (); }
the_stack_data/100307.c
#include <stdio.h> int main() { int vet[5] = {1, 2, 3, 4, 5}; int *p = &vet; printf("\n\n"); // Letra 2A) printf("Letra 2A\n"); printf("end vet: %p\n", &vet); printf("end p: %p\n", p); // Letra 2B) printf("\nLetra 2B\n"); for (int i = 0; i < 5; i++) { printf("%d ", p[i]); } // Letra 2C) printf("\n\nLetra 2C\n"); for (int i = 0; i < 5; i++) { printf("%d ", *(p + 1)); } // Letra 2D) printf("\n\nLetra 2D-1\n"); for (int i = 0; i < 5; i++) { printf("%d ", vet[i]); } printf("\n\nLetra 2D-2\n"); for (int i = 0; i < 5; i++) { printf("%d ", *(vet + i)); } printf("\n\n"); return 0; }
the_stack_data/148579096.c
#include <stdlib.h> #include <assert.h> #include <stdio.h> #include <setjmp.h> typedef short int16_t; #define ARRAY_CREATE(array, init_capacity, init_size) {\ array = malloc(sizeof(*array)); \ array->data = malloc((init_capacity) * sizeof(*array->data)); \ assert(array->data != NULL); \ array->capacity = init_capacity; \ array->size = init_size; \ } #define ARRAY_PUSH(array, item) {\ if (array->size == array->capacity) { \ array->capacity *= 2; \ array->data = realloc(array->data, array->capacity * sizeof(*array->data)); \ assert(array->data != NULL); \ } \ array->data[array->size++] = item; \ } struct array_string_t { int16_t size; int16_t capacity; const char ** data; }; int err_i = 0; jmp_buf err_jmp[10]; #define TRY { int err_val = setjmp(err_jmp[err_i++]); if (!err_val) { #define CATCH } else { #define THROW(x) longjmp(err_jmp[--err_i], x) struct array_string_t * err_defs; #define END_TRY err_defs->size--; } } void print(int16_t p) { const char * e; TRY { if (p == 3) { ARRAY_PUSH(err_defs, "Parameter cannot be 3!"); THROW(err_defs->size); } printf("%d\n", p); } CATCH e = err_defs->data[err_val - 1]; printf("%s\n", e); END_TRY } int main(void) { ARRAY_CREATE(err_defs, 2, 0); TRY { int16_t i; i = 0; for (;i < 5;i++) print(i); } CATCH printf("Something went wrong!\n"); END_TRY return 0; }
the_stack_data/73576561.c
// Copyright 2016 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. /* Audio Video Capturing synchronization utility * * This is a command-line tool running on chameleon board to monitor the * changes of the audio page count and the video page count, and calcuate the * time interval between the first audio/video data captured. */ #include <assert.h> #include <fcntl.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> const int controller_addr = 0xff210000; const int controller_size = 0x10000; char* mem; inline int read_mem(int addr) { return *(int*)(mem + (addr - controller_addr)); } inline int audio_page_count() { const int audio_regs_base = 0xff212000; const int audio_reg_page_count = 0x14; return read_mem(audio_regs_base + audio_reg_page_count); } inline int video_field_count() { const int video_regs_base = 0xff210000; const int video_reg_frame_count = 0x20; return read_mem(video_regs_base + video_reg_frame_count); } int main() { const int fd = open("/dev/mem", O_RDONLY | O_SYNC); if (fd == -1) { perror("open"); exit(1); } mem = mmap(NULL, controller_size, PROT_READ, MAP_SHARED, fd, controller_addr); if (mem == MAP_FAILED) { perror("mmap"); exit(1); } int last_audio_page_count = audio_page_count(); int last_video_frame_count = video_field_count(); struct timeval ta, tv; bool done_audio = false, done_video = false; time_t timeout = time(NULL) + 20; while ((!done_audio || !done_video) && time(NULL) < timeout) { if (!done_audio) { const int current_audio_page_count = audio_page_count(); if (current_audio_page_count > last_audio_page_count) { gettimeofday(&ta, NULL); done_audio = true; } last_audio_page_count = current_audio_page_count; } /* * In chameleond, VideoDumper will capture 1 frame when it selects a new * input, so the change of the frame count from 0 to 1 may be originated * from that frame, and the second captured frame is always the frame * we care about. */ if (!done_video) { const int current_video_frame_count = video_field_count(); if (current_video_frame_count > last_video_frame_count && current_video_frame_count >= 2) { gettimeofday(&tv, NULL); done_video = true; } last_video_frame_count = current_video_frame_count; } usleep(100); } if (!done_audio || !done_video) { return -1; } /* * Because tv is the time when the second frame was captured, to estimate * the time when the first frame was captured, we need to shift it by -1/60 * second. */ const double diff = (tv.tv_sec - ta.tv_sec) + (tv.tv_usec - ta.tv_usec) * 1e-6 - 1.0 / 60; printf("%.8f\n", diff); munmap(mem, controller_size); close(fd); return 0; }
the_stack_data/367613.c
#include <stdio.h> int main(int argc, char **argv) { printf("Hello World!\n"); return 0; }
the_stack_data/242329659.c
#include <stdio.h> union intParts { int theInt; char bytes[sizeof(int)]; }; struct operator { int type; union { int intNum; float floatNum; double doubleNum; }; }; union Coins { struct { int quarter; int dime; int nickel; int penny; }; int coins[4]; }; int main(void) { union intParts parts; parts.theInt = 5968145; // Union variant printf("The int is %i\nThe bytes are [%i, %i, %i, %i]\n", parts.theInt, parts.bytes[0], parts.bytes[1], parts.bytes[2], parts.bytes[3]); int theInt = parts.theInt; // Variant 2 printf("The int is %i\nThe bytes are [%i, %i, %i, %i]\n", theInt, *((char*)&theInt), *((char*)&theInt+1), *((char*)&theInt+2), *((char*)&theInt+3)); // Variant 3 char * intChar = (char*)&theInt; printf("The int is %i\nThe bytes are [%i, %i, %i, %i]\n", theInt, intChar[0], intChar[1], intChar[2], intChar[3]); struct operator op; op.type = 0; op.intNum = 352; printf("%d, %f, %d", op.intNum, op.floatNum, op.doubleNum); union Coins change; for (int i = 0; i < sizeof(change) / sizeof(int); i++) { scanf("%i", change.coins + i); } printf("There are %i quarters, %i dimes, %i nickels, and %i pennies\n", change.quarter, change.dime, change.nickel, change.penny); return 0; }
the_stack_data/100141441.c
#include <stdio.h> //made this code with the explication of Raul Chavez alias "rulgamer07" #define FALSE 0 #define TRUE 1 int main() { int c, num, close, open; while((c = getchar()) != EOF) { switch(c) { case '(': open = TRUE; putchar(c); break; case ')': close = FALSE; putchar(c); break; case '[': open = TRUE; putchar(c); break; case ']': close = FALSE; putchar(c); break; case '{': open = TRUE; putchar(c); break; case '}': close = FALSE; putchar(c); break; case '<': open = TRUE; putchar(c); break; case '>': close = FALSE; putchar(c); break; default: if(c != '.' && c!=',' && c!=':' && c!=';' && c!='-' && c!='_') { if(open==TRUE) { putchar(c); } else { if(c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9'||c=='0') { num++; } else { num=0; } if(num==1) { putchar('X'); } if(num==0) { putchar(c); } } } } } return 0; }
the_stack_data/232956027.c
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <string.h> #define FAIL_IF_MSG( EXP , MSG) ( {if( EXP == -1) {printf(MSG);exit(EXIT_FAILURE);}} ) void bubbleSort(int fd); int main(int argc, char** argv) { if(argc != 2) { printf("Usage: %s <source_file>\n", argv[0]); exit(EXIT_FAILURE); } int sourceFileDescriptor; FAIL_IF_MSG( (sourceFileDescriptor = open(argv[1], O_RDWR | O_CREAT, 0644) ) , "Source file couldn't be opened.\n"); bubbleSort(sourceFileDescriptor); FAIL_IF_MSG(close(sourceFileDescriptor), "Error at closing the file descriptor!\n"); return 0; } void bubbleSort(int fd) { int firstNum, secondNum; int read1, read2; int modif = 1; struct flock lock, unlock; lock.l_type = F_WRLCK; lock.l_len = 2 * sizeof(firstNum); lock.l_whence = SEEK_CUR; lock.l_start = 0; unlock.l_type = F_UNLCK; unlock.l_len = 2 * sizeof(firstNum); unlock.l_whence = SEEK_CUR; unlock.l_start = -2 * sizeof(firstNum); while (modif) { modif = 0; //it will be set if we make a swap while (1) { FAIL_IF_MSG( (read1 = read( fd, &firstNum, sizeof(firstNum))),"Error at reading the number!\n"); if(read1 == 0) break; //EOF FAIL_IF_MSG( (read2 = read( fd, &secondNum, sizeof(secondNum))),"Error at reading the number!\n"); if(read2 == 0) break; if(firstNum > secondNum) { modif = 1; FAIL_IF_MSG(lseek(fd, -2*sizeof(firstNum), SEEK_CUR) ,"Error at seeking 2*sizeof(num) behind!\n"); printf("[PID: %d] trying to set the lock!\n", getpid()); int errnumber = fcntl(fd, F_SETLK, &lock); if(errnumber == -1) { printf("[PID: %d] Failed to set the lock! Error: %s\n", getpid(), strerror(errno)); //exit(EXIT_FAILURE); } printf("[PID: %d] Succes on setting the lock!\n", getpid()); FAIL_IF_MSG(write(fd, &secondNum, sizeof(secondNum)) ,"Error at writing the first num!\n"); FAIL_IF_MSG(write(fd, &firstNum, sizeof(firstNum)),"Error at writing the second number!\n"); //FAIL_IF_MSG( fcntl(fd, F_SETLK, &unlock),"Error at unlocking the C.S!\n"); //i had some issues with this macro, i couldn t print the error message. errnumber = fcntl(fd, F_SETLK, &unlock); if(errnumber == -1) { printf("[PID: %d] Failed to set the unlock lock! Error: %s\n", getpid(), strerror(errno)); //exit(EXIT_FAILURE); } printf("[PID: %d] Succes on setting the UNlock!\n", getpid()); } FAIL_IF_MSG(lseek(fd, -sizeof(firstNum), SEEK_CUR), "Error at seeking behind for the next loop!\n"); } FAIL_IF_MSG(lseek(fd, 0L, SEEK_SET),"Error at repositioning at the beginning of the file!\n"); } }
the_stack_data/92325423.c
/* This testcase is part of GDB, the GNU debugger. It was copied from gcc repo, gcc/testsuite/gcc.target/aarch64/eh_return.c. Copyright 2020 Free Software Foundation, Inc. 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 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdlib.h> #include <stdio.h> int val, test, failed; int main (void); void eh0 (void *p) { val = (int)(long)p & 7; if (val) abort (); } void eh1 (void *p, int x) { void *q = __builtin_alloca (x); eh0 (q); __builtin_eh_return (0, p); } void eh2a (int a,int b,int c,int d,int e,int f,int g,int h, void *p) { val = a + b + c + d + e + f + g + h + (int)(long)p & 7; } void eh2 (void *p) { eh2a (val, val, val, val, val, val, val, val, p); __builtin_eh_return (0, p); } void continuation (void) { test++; main (); } void fail (void) { failed = 1; printf ("failed\n"); continuation (); } void do_test1 (void) { if (!val) eh1 (continuation, 100); fail (); } void do_test2 (void) { if (!val) eh2 (continuation); fail (); } int main (void) { if (test == 0) do_test1 (); if (test == 1) do_test2 (); if (failed || test != 2) exit (1); exit (0); }
the_stack_data/719535.c
/* * Program that calculates how many digits is in a number */ #include <stdio.h> int main(void) { int number, digits; printf("Enter a number: "); (void)scanf("%d", &number); if (number < 0) number = -number; if (number < 10) digits = 1; else if (number < 100) digits = 2; else if (number < 1000) digits = 3; else if (number < 10000) digits = 4; else { printf("Too much digits!\n"); digits = 0; } printf("The number %d had %d digits.\n", number, digits); return 0; }