text
stringlengths
4
6.14k
#include <stdlib.h> #include <stdio.h> #ifndef BITWRITER #define BITWRITER typedef struct BitWriter { // Bits to be written in the FILE unsigned char buffer; // Number of bit that where currently written in the buffer int bit_number; // File pointer for writting FILE *file; } BitWriter; /** Initializes a bitwriter, all bitwriter files are opened in "wb" mode. */ int BitWriter_init(BitWriter *writer, char *filename); /** Write a bit to the bitwriter, if the bitwriter buffer is full it will flush it to the file (flushing does not mean calling fflush to force the writing). */ int BitWriter_write_bit(BitWriter *writer, unsigned char bit); /** Writes a stream of bits into the file. @param count The number of bit to extract from the bitstream */ int BitWriter_write_bits(BitWriter *writer, unsigned char bitstream, int count); /** Force writing every content on the buffer to the file */ int BitWriter_flush(BitWriter *writer); /** Flushes the buffer and closes the writer */ int BitWriter_close(BitWriter *writer); #endif // BITWRITER
#ifndef __FILE_IO_LZ4_H #define __FILE_IO_LZ4_H #include <unistd.h> #include <stdio.h> // fprintf, fopen, fread, _fileno, stdin, stdout #include <stdlib.h> // malloc #include <string.h> // strcmp, strlen #include <time.h> // clock #include "lz4.h" #include "lz4hc.h" #define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) #if defined(_MSC_VER) // Visual Studio # define swap32 _byteswap_ulong #elif GCC_VERSION >= 403 # define swap32 __builtin_bswap32 #else static inline unsigned int swap32(unsigned int x) { return ((x << 24) & 0xff000000 ) | ((x << 8) & 0x00ff0000 ) | ((x >> 8) & 0x0000ff00 ) | ((x >> 24) & 0x000000ff ); } #endif #define KB *(1U<<10) #define MB *(1U<<20) #define GB *(1U<<30) #define _1BIT 0x01 #define _2BITS 0x03 #define _3BITS 0x07 #define _4BITS 0x0F #define _8BITS 0xFF #define MAGICNUMBER_SIZE 4 #define LZ4S_MAGICNUMBER 0x184D2204 #define LZ4S_SKIPPABLE0 0x184D2A50 #define LZ4S_SKIPPABLEMASK 0xFFFFFFF0 #define LEGACY_MAGICNUMBER 0x184C2102 #define CACHELINE 64 #define LEGACY_BLOCKSIZE (8 MB) #define MIN_STREAM_BUFSIZE (1 MB + 64 KB) #define LZ4S_BLOCKSIZEID_DEFAULT 7 #define LZ4S_CHECKSUM_SEED 0 #define LZ4S_EOS 0 #define LZ4S_MAXHEADERSIZE (MAGICNUMBER_SIZE+2+8+4+1) static const int one = 1; #define CPU_LITTLE_ENDIAN (*(char*)(&one)) #define CPU_BIG_ENDIAN (!CPU_LITTLE_ENDIAN) #define LITTLE_ENDIAN_32(i) (CPU_LITTLE_ENDIAN?(i):swap32(i)) static int LZ4S_GetBlockSize_FromBlockId (int id) { return (1 << (8 + (2 * id))); } #endif
// -*- c++ -*- /*========================================================================= Program: Visualization Toolkit Module: vtkSamplePlaneSource.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /*---------------------------------------------------------------------------- Copyright (c) Sandia Corporation See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. ----------------------------------------------------------------------------*/ // .NAME vtkSamplePlaneSource - Create an oriented plane that can be used to sample the input. // // .SECTION Description // // This filter creates a plane with a given center point and normal. This // algorithm is designed to have an input whose bounds are used to establish the // size (in world coordinates) of the plane. The number of points in the x and // y direction of the plane are generally set by the resolution, but the output // will actually have more points than specified. The plane geometry will be // made larger than the bounds to ensure that, if used to probe the input, it // will cover the entire geometry. // #ifndef vtkSamplePlaneSource_h #define vtkSamplePlaneSource_h #include "vtkPolyDataAlgorithm.h" class vtkMultiProcessController; class vtkSamplePlaneSource : public vtkPolyDataAlgorithm { public: vtkTypeMacro(vtkSamplePlaneSource, vtkPolyDataAlgorithm); static vtkSamplePlaneSource *New(); virtual void PrintSelf(ostream &os, vtkIndent indent); // Description: // The location of the center of the plane. A point is guaranteed to be here. vtkGetVector3Macro(Center, double); vtkSetVector3Macro(Center, double); // Description: // The normal to the plane. vtkGetVector3Macro(Normal, double); vtkSetVector3Macro(Normal, double); // Description: // The approximate number of samples in each direction that will intersect the // input bounds. vtkGetMacro(Resolution, int); vtkSetMacro(Resolution, int); // Description: // The controller used to determine the actual bounds of the input. Use // a dummy controller if not running in parallel. vtkGetObjectMacro(Controller, vtkMultiProcessController); virtual void SetController(vtkMultiProcessController *); protected: vtkSamplePlaneSource(); ~vtkSamplePlaneSource(); double Center[3]; double Normal[3]; int Resolution; vtkMultiProcessController *Controller; virtual int FillInputPortInformation(int port, vtkInformation *info); virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector); // Description: // Finds the bounds of a data object (can be either a vtkDataSet or // a vtkCompositeDataSet containing vtkDataSets). virtual void ComputeLocalBounds(vtkDataObject *input, double bounds[6]); // Description: // Resolves the bounds of all parallel processes. virtual void ResolveParallelBounds(double bounds[6]); // Description: // Creates the output poly data based on the bounds and ivars. virtual void CreatePlane(const double bounds[6], vtkPolyData *output); private: vtkSamplePlaneSource(const vtkSamplePlaneSource &); // Not implemented void operator=(const vtkSamplePlaneSource &); // Not implemented }; #endif //vtkSamplePlaneSource_h
/***************************************************************************** * * PROJECT: Multi Theft Auto v1.0 * LICENSE: See LICENSE in the top level directory * FILE: xml/CXMLArrayImpl.h * PURPOSE: XML array class * DEVELOPERS: Christian Myhre Lundheim <> * * Multi Theft Auto is available from http://www.multitheftauto.com/ * *****************************************************************************/ #ifndef __CXMLARRAY_H #define __CXMLARRAY_H class CXMLCommon; class CXMLArray { public: static void Initialize ( void ); static unsigned long PopUniqueID ( CXMLCommon* pEntry ); static void PushUniqueID ( CXMLCommon* pEntry ); static CXMLCommon* GetEntry ( unsigned long ulID ); static unsigned long GetCapacity ( void ); static unsigned long GetUnusedAmount ( void ); private: static void ExpandBy ( unsigned long ulAmount ); static void PushUniqueID ( unsigned long ulID ); static CStack < unsigned long, 1, INVALID_XML_ID > m_IDStack; static std::vector < CXMLCommon* > m_Elements; static unsigned long m_ulCapacity; }; #endif
#ifndef ITERATIVERECONBASE_H #define ITERATIVERECONBASE_H #include <BackProjectorModuleBase.h> #include <ParameterHandling.h> #include <forwardprojectorbase.h> #include <backprojectorbase.h> class IterativeReconBase : public BackProjectorModuleBase { public: IterativeReconBase(std::string application, std::string name, eMatrixAlignment alignment, kipl::interactors::InteractionBase *interactor=nullptr); ~IterativeReconBase(); /// Sets up the back-projector with new parameters /// \param config Reconstruction parameter set /// \param parameters Additional set of configuration parameters virtual int Configure(ReconConfig config, std::map<std::string, std::string> parameters); /// Initializing the reconstructor virtual int Initialize(); /// Add one projection to the back-projection stack /// \param proj The projection /// \param angle Acquisition angle /// \param weight Intensity scaling factor for interpolation when the angles are non-uniformly distributed /// \param bLastProjection termination signal. When true the back-projeciton is finalized. virtual size_t Process(kipl::base::TImage<float,2> proj, float angle, float weight, bool bLastProjection); /// Starts the back-projection process of projections stored as a 3D volume. /// \param proj The projection data /// \param parameters A list of parameters, the list shall contain at least the parameters angles and weights each containing a space separated list with as many values as projections virtual size_t Process(kipl::base::TImage<float,3> proj, std::map<std::string, std::string> parameters); /// Gets a list parameters required by the module. /// \returns The parameter list virtual std::map<std::string, std::string> GetParameters(); /// Sets the region of interest on the projections. /// \param roi A four-entry array of ROI coordinates (x0,y0,x1,y1) virtual void SetROI(const std::vector<size_t> &roi); protected: virtual size_t reconstruct(kipl::base::TImage<float,3> proj,std::list<float> & angles) = 0; ForwardProjectorBase *m_fp; BackProjectorBase *m_bp; int m_nIterations; }; #endif // ITERATIVERECONBASE_H
#include "../../../../../src/cloudservices/qenginiouserobject_p.h"
////////////////////////////////////////////////////////////////////// // // Copyright (c) 2011 Audiokinetic Inc. / All Rights Reserved // ////////////////////////////////////////////////////////////////////// // AkTypes.h /// \file /// Data type definitions. #pragma once #define AK_ANDROID #define AK_LFECENTER ///< Internal use #define AK_REARCHANNELS ///< Internal use #if defined(__LP64__) || defined(_LP64) #ifdef __aarch64__ #define AK_CPU_ARM_64 #else #define AK_CPU_X86_64 #endif #else #ifdef __arm__ #define AK_CPU_ARM #else //#define AK_CPU_X86 //To enable when SIMD defines are enabled. #endif #endif #include <AK/SoundEngine/Platforms/POSIX/AkTypes.h>
#include "pthread_canceled.h" #include "../base.h" #include "../errno.h" #include <linux-syscalls/linux.h> #include <stddef.h> #include "../mach/lkm.h" #include "../../../../external/lkm/api.h" #include "bsdthread_create.h" #include <sys/errno.h> long sys_pthread_canceled(int action) { if (action == 0 && !uses_threads()) return -EINVAL; int ret = lkm_call(NR_pthread_canceled, (void*)(long) action); if (ret < 0) ret = errno_linux_to_bsd(ret); return ret; }
#ifndef SCENE_H #define SCENE_H #include <iostream> #include <cmath> #include "types.h" class Viewer; class Scene { public: Scene(); ~Scene(); public: // types typedef CGAL::Bbox_3 Bbox; public: void update_bbox(); Bbox bbox() { return m_bbox; } private: // member data Bbox m_bbox; Line m_line; Plane m_plane; Point m_centroid; Polyhedron *m_pPolyhedron; // view options bool m_view_polyhedron; public: // file menu int open(QString filename); // toggle view options void toggle_view_poyhedron(); // algorithms Vector normalize(const Vector& v); void refine_loop(); void fit_edges(); void fit_vertices(); void fit_triangles(); // rendering void draw(Viewer *viewer); void render_line(Viewer *viewer); void render_plane(Viewer* viewer); void render_centroid(Viewer* viewer); void render_polyhedron(Viewer* viewer); private: }; // end class Scene #endif // SCENE_H
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <math.h> #include <time.h> #include <sys/time.h> #include "main.h" #include "particle.h" #include "boundaries.h" extern double coefficient_of_restitution; int loops = 1; int loopsleft; void problem_init(int argc, char* argv[]){ // Setup constants dt = 1e-4; tmax = 1; if (argc>1){ loops = atoi(argv[1]); } loops*=2; loopsleft = loops; tmax = 1.2*(double)loops; boxsize = 3; root_nx = 10; root_ny = 3; root_nz = 1; coefficient_of_restitution = 1; // elastic collisions // Setup particle structures init_box(); // Initial conditions for (int i=0;i<10;i++){ struct particle pt; pt.x = -boxsize_x/2.+boxsize_x*(double)i/10.; pt.y = 0; pt.z = 0; pt.vx = (i==0?10:0); pt.vy = 0; pt.vz = 0; pt.ax = 0; pt.ay = 0; pt.az = 0; pt.m = 1; pt.r = 1; particles_add(pt); } // Do not use any ghost boxes nghostx = 1; nghosty = 1; nghostz = 0; printf("init done\n"); } double tcontact =0 ; double vlast = 0; extern double collisions_plog; void problem_inloop(){ if (particles[0].vx!=vlast){ vlast = particles[0].vx; if (vlast>0){ tcontact = t; } } } void problem_output(){ } void problem_finish(){ FILE* of = fopen("error.txt","a+"); double error= fabs(1.1*(double)loops-tcontact); struct timeval tim; gettimeofday(&tim, NULL); double timing_final = tim.tv_sec+(tim.tv_usec/1000000.0); double error_limit = 2e-3; int pass = (error>error_limit?0:1); fprintf(of,"%d\t%e\t%e\t%e\t%d\t%e\t",N,dt,error,error_limit,pass,timing_final-timing_initial); fprintf(of,"loops = %d",loops/2); fprintf(of,"\n"); fclose(of); }
/* * Copyright © 2001-2011 Stéphane Raimbault <stephane.raimbault@gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _MODBUS_RTU_H_ #define _MODBUS_RTU_H_ #include "modbus.h" MODBUS_BEGIN_DECLS /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5 * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes */ #define MODBUS_RTU_MAX_ADU_LENGTH 256 EXPORT modbus_t* modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop_bit); #define MODBUS_RTU_RS232 0 #define MODBUS_RTU_RS485 1 //EXPORT int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode); EXPORT int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode, const char *rts_pin); EXPORT int modbus_rtu_get_serial_mode(modbus_t *ctx); #define MODBUS_RTU_RTS_NONE 0 #define MODBUS_RTU_RTS_UP 1 #define MODBUS_RTU_RTS_DOWN 2 EXPORT int modbus_rtu_set_rts(modbus_t *ctx, int mode); EXPORT int modbus_rtu_get_rts(modbus_t *ctx); MODBUS_END_DECLS #endif /* _MODBUS_RTU_H_ */
//Copyright 2017 Jonathan Woolf and Carlos Santillana //This program is distributed under the terms of the GNU General Public License #ifndef __OR_H__ #define __OR_H__ #include "connector.h" class Or : public Connector { private: RShell* left; //Operation left of connector RShell* right; //Operation right of connector string type; //Sets type of child bool executed;//determines if was already executed bool exec;// determines whether or not to execute public: Or() //Default Constructor : type("||"), executed(false), exec(true) {} Or(RShell* l) //Constructor : left(l), type("||"), executed(false), exec(true) {} ~Or(){ delete left; delete right; } bool execute() //Returns true if one argument is true { bool executed = true; if(!left->get_executed()) { right->set_exec(true); } else right->set_exec(false); return executed; } string get_type() { return type; } virtual string get_input(){return "";}//Prevents abstraction void set_right_child(RShell* r){this->right = r;} }; #endif
/* help.c - command to show a help text. */ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc. * * GRUB 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. * * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>. */ #include <grub/dl.h> #include <grub/misc.h> #include <grub/term.h> #include <grub/extcmd.h> #include <grub/i18n.h> #include <grub/mm.h> #include <grub/normal.h> #include <grub/charset.h> static grub_err_t grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc, char **args) { int cnt = 0; char *currarg; if (argc == 0) { grub_command_t cmd; FOR_COMMANDS(cmd) { if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE)) { struct grub_term_output *term; const char *summary_translated = _(cmd->summary); char *command_help; grub_uint32_t *unicode_command_help; grub_uint32_t *unicode_last_position; command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated); if (!command_help) break; grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help, &unicode_last_position); FOR_ACTIVE_TERM_OUTPUTS(term) { unsigned stringwidth; grub_uint32_t *unicode_last_screen_position; unicode_last_screen_position = unicode_command_help; stringwidth = 0; while (unicode_last_screen_position < unicode_last_position && stringwidth < ((grub_term_width (term) / 2) - 2)) { struct grub_unicode_glyph glyph; unicode_last_screen_position += grub_unicode_aglomerate_comb (unicode_last_screen_position, unicode_last_position - unicode_last_screen_position, &glyph); stringwidth += grub_term_getcharwidth (term, &glyph); } grub_print_ucs4 (unicode_command_help, unicode_last_screen_position, 0, 0, term); if (!(cnt % 2)) grub_print_spaces (term, grub_term_width (term) / 2 - stringwidth); } if (cnt % 2) grub_printf ("\n"); cnt++; grub_free (command_help); grub_free (unicode_command_help); } } if (!(cnt % 2)) grub_printf ("\n"); } else { int i; grub_command_t cmd; for (i = 0; i < argc; i++) { currarg = args[i]; FOR_COMMANDS(cmd) { if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) { if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg))) { if (cnt++ > 0) grub_printf ("\n\n"); if ((cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) && ! (cmd->flags & GRUB_COMMAND_FLAG_DYNCMD)) grub_arg_show_help ((grub_extcmd_t) cmd->data); else grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary), _(cmd->description)); } } } } } return 0; } static grub_extcmd_t cmd; GRUB_MOD_INIT(help) { cmd = grub_register_extcmd ("help", grub_cmd_help, 0, N_("[PATTERN ...]"), N_("Show a help message."), 0); } GRUB_MOD_FINI(help) { grub_unregister_extcmd (cmd); }
/* * Copyright (C) 1996-1997 Id Software, 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 2 * 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ // r_shared.h -- general refresh-related stuff shared between the refresh and the driver // FIXME: clean up and move into d_iface.h #ifndef _R_SHARED_H_ # define _R_SHARED_H_ # define MAXVERTS 16 // max points in a surface polygon # define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate polygon (while processing) // !!! if this is changed, it must be changed in d_ifacea.h too !!! # define MAXHEIGHT 1024*2 # define MAXWIDTH 1280*2 # define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to // be farther away than anything in the scene extern int cachewidth; extern pixel_t *cacheblock; extern int screenwidth; extern float pixelAspect; extern int r_drawnpolycount; extern cvar_t r_clearcolor; extern int sintable[MAXWIDTH + CYCLE]; extern int intsintable[MAXWIDTH + CYCLE]; extern vec3_t vup, base_vup; extern vec3_t vpn, base_vpn; extern vec3_t vright, base_vright; extern entity_t *currententity; # define NUMSTACKEDGES 2400 # define MINEDGES NUMSTACKEDGES # define NUMSTACKSURFACES 800 # define MINSURFACES NUMSTACKSURFACES # define MAXSPANS 3000 // !!! if this is changed, it must be changed in asm_draw.h too !!! typedef struct espan_s { int u, v, count; struct espan_s *pnext; } espan_t; // FIXME: compress, make a union if that will help // insubmodel is only 1, flags is fewer than 32, spanstate could be a byte typedef struct surf_s { struct surf_s *next; // active surface stack in r_edge.c struct surf_s *prev; // used in r_edge.c for active surf stack struct espan_s *spans; // pointer to linked list of spans to draw int key; // sorting key (BSP order) int last_u; // set during tracing int spanstate; // 0 = not in span // 1 = in span // -1 = in inverted span (end before start) int flags; // currentface flags void *data; // associated data like msurface_t entity_t *entity; float nearzi; // nearest 1/z on surface, for mipmapping qboolean insubmodel; float d_ziorigin, d_zistepu, d_zistepv; int pad[2]; // to 64 bytes } surf_t; extern surf_t *surfaces, *surface_p, *surf_max; // surfaces are generated in back to front order by the bsp, so if a surf // pointer is greater than another one, it should be drawn in front // surfaces[1] is the background, and is used as the active surface stack. // surfaces[0] is a dummy, because index 0 is used to indicate no surface // attached to an edge_t extern vec3_t sxformaxis[4]; // s axis transformed into viewspace extern vec3_t txformaxis[4]; // t axis transformed into viewspac extern vec3_t modelorg, base_modelorg; extern float xcenter, ycenter; extern float xscale, yscale; extern float xscaleinv, yscaleinv; extern float xscaleshrink, yscaleshrink; extern int d_lightstylevalue[256]; // 8.8 frac of base light value extern void TransformVector (vec3_t in, vec3_t out); extern void SetUpForLineScan (fixed8_t startvertu, fixed8_t startvertv, fixed8_t endvertu, fixed8_t endvertv); extern int r_skymade; extern void R_MakeSky (void); extern int ubasestep, errorterm, erroradjustup, erroradjustdown; // flags in finalvert_t.flags # define ALIAS_LEFT_CLIP 0x0001 # define ALIAS_TOP_CLIP 0x0002 # define ALIAS_RIGHT_CLIP 0x0004 # define ALIAS_BOTTOM_CLIP 0x0008 # define ALIAS_Z_CLIP 0x0010 // !!! if this is changed, it must be changed in d_ifacea.h too !!! # define ALIAS_ONSEAM 0x0020 // also defined in modelgen.h; // must be kept in sync # define ALIAS_XY_CLIP_MASK 0x000F // !!! if this is changed, it must be changed in asm_draw.h too !!! typedef struct edge_s { fixed16_t u; fixed16_t u_step; struct edge_s *prev, *next; unsigned short surfs[2]; struct edge_s *nextremove; float nearzi; medge_t *owner; } edge_t; #endif // _R_SHARED_H_
/* * File: start.h * Author: Ian Bannerman * License: GNU Public License v3 * * Description: Header file for the Start widget displayed * by Inssidious on launch. Defines the logo, * text strings, buttons, & input fields displayed. * */ #ifndef START_H #define START_H #include <QtWidgets/QWidget> //QWidgets #include <QtWidgets/QLayout> //Layouts for QWidgets #include <QtWidgets/QLabel> //For Inssidious Logo #include <QtWidgets/QComboBox> //For available internet connections #include <QtWidgets/QLineEdit> //For editable line of text #include <QtWidgets/QPushButton> //For Start button #include <QObject> #include <QtCore/QEvent> class StartWidget : public QWidget { Q_OBJECT public: StartWidget(QWidget *parent); signals: //Signal to Inssidious that the user has set a name and password and asked to start void uiStartCore(QString networkName, QString networkPassword, QString networkAdapter); public slots: //Receive and display new status messages when signaled void onUiUpdateStartingText(QString messageText, bool isErrorMessage = false); void onCoreVisibleNetworkConnections(QList<QString> visibleNetworkConnections); private: /* Define the logo displayed at the top of the Start widget */ QLabel* logo; //Logo image QPixmap logoPixmap = QPixmap(":/Start/StartLogo.png"); //QPixmap for the logo png /* Define the Start widget description labels and input fields */ QPalette descriptionTextPalette; //Palette for the default grey description text QPalette errorTextPalette; //Palette for red error text if an field has invalid input QLabel* networkNameLabel; //Description text label QLabel* internetConnectionLabel; //Description text label QLabel* networkPasswordLabel; //Description text label QLineEdit* networkNameInput; //Editable field to specify the wireless network name QLineEdit* networkPasswordInput; //Editable field to specify the wireless network password QComboBox* internetConnectionComboBox; //Combo box for network adapters to use as the internet connection QFont statusEventClassFont; //Font for the event class header text QLabel* statusEventClass; //Status Event Class for Starting, Error, etc. QLabel* statusMessage; //Status message text /* Define the description text strings as const QString */ const QString networkNameText = "Set a name for the Inssidious wireless network:"; const QString networkPasswordText = "Set a password for the network:"; const QString internetConnectionText = "Select an Internet Connection:"; /* Define the Start button */ QPushButton* startButton; //Start button QString startButtonStyleSheet = //Style sheet for the background images of the button in different states "QPushButton{ border: 1px solid #72C55D; border-radius: 2px; background-color: #72C55D; color:#333333; font-family: 'Segoe UI Semibold'; font-size:16px; font-weight:400; text-decoration:none; }\ QPushButton:!enabled{ background-color: #F0F0F0; color:#444444; }\ QPushButton:pressed{ background-color: #4E9E38; color:#333333;}\ QPushButton:hover:!pressed{ background-color: #50B235; }\ QPushButton:on{ background-color: #72C55D; color:#333333;}\ QPushButton:focus{ outline: none; }"; private slots: //React to Start button being clicked and confirm user inputted valid data void onStartButtonClicked(); }; #endif // START_H
#ifndef ZASMDEFS_H #define ZASMDEFS_H #include "../zdefs.h" struct zasm { uint16_t command; int32_t arg1; int32_t arg2; }; struct ZAsmScript { ZAsmScript() : version(ZASM_VERSION), type(SCRIPT_NONE) { name_len = 21; name = new char[21]; strcpy(name, "Uninitialized Script"); commands_len = 1; commands = new zasm[1]; commands[0].command = 0xFFFF; } ~ZAsmScript() { delete[] name; delete[] commands; } ZAsmScript &operator=(const ZAsmScript &other) { version = other.version; type = other.type; name_len = other.name_len; delete[] name; name = new char[name_len]; strcpy(name, other.name); commands_len = other.commands_len; delete[] commands; commands = new zasm[commands_len]; for (int i = 0; i < commands_len; i++) commands[i] = other.commands[i]; return *this; } ZAsmScript(const ZAsmScript &other) { version = other.version; type = other.type; name_len = other.name_len; name = new char[name_len]; strcpy(name, other.name); commands_len = other.commands_len; commands = new zasm[commands_len]; for (int i = 0; i < commands_len; i++) commands[i] = other.commands[i]; } // Version of ZASM this script was compiled for int16_t version; // Type of the script (SCRIPT_GLOBAL, e.g.) int16_t type; // Name of the script, if the script was compiled from ZScript // For debugging and logging errors, etc. int16_t name_len; char *name; // The ZASM itself int32_t commands_len; zasm *commands; }; struct GameScripts { GameScripts() { // A fixed number of these (for now?) globalscripts.resize(NUMSCRIPTGLOBAL); } std::vector<ZAsmScript> globalscripts; std::vector<ZAsmScript> ffscripts; std::vector<ZAsmScript> itemscripts; std::vector<ZAsmScript> guyscripts; std::vector<ZAsmScript> wpnscripts; std::vector<ZAsmScript> linkscripts; std::vector<ZAsmScript> screenscripts; }; #endif
/************************************************************************ ** ** @file tst_varc.h ** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @date 9 6, 2015 ** ** @brief ** @copyright ** This source code is part of the Valentina project, a pattern making ** program, whose allow create and modeling patterns of clothing. ** Copyright (C) 2015 Valentina project ** <https://bitbucket.org/dismine/valentina> All Rights Reserved. ** ** Valentina 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. ** ** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>. ** *************************************************************************/ #ifndef TST_VARC_H #define TST_VARC_H #include <QObject> class TST_VArc : public QObject { Q_OBJECT public: explicit TST_VArc(QObject *parent = nullptr); private slots: void CompareTwoWays(); void NegativeArc(); void TestGetPoints_data(); void TestGetPoints(); void TestRotation_data(); void TestRotation(); void TestFlip_data(); void TestFlip(); void TestCutArc_data(); void TestCutArc(); }; #endif // TST_VARC_H
/* * gab - just to learn GLib and related technologies [G Address Book] * Copyright (C) 2010 Tieto Corp., Martin Kampas <martin.kampas@tieto.com> * * 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/>. * */ #ifndef __GAB_IPERSON_H__ #define __GAB_IPERSON_H__ #include <glib-object.h> G_BEGIN_DECLS typedef enum { GAB_IPERSON_PHONE_HOME, GAB_IPERSON_PHONE_MOBILE, GAB_IPERSON_PHONE_N_TYPES } GabIPersonPhoneType; #define GAB_IPERSON_TYPE (gab_iperson_get_type ()) #define GAB_IPERSON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAB_IPERSON_TYPE, GabIPerson)) #define GAB_IS_IPERSON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAB_IPERSON_TYPE)) #define GAB_IPERSON_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GAB_IPERSON_TYPE, GabIPersonInterface)) typedef struct _GabIPerson GabIPerson; /* dummy object */ typedef struct _GabIPersonInterface GabIPersonInterface; struct _GabIPersonInterface { GTypeInterface parent; const gchar *(*get_name) (GabIPerson *self); const gchar *(*get_surname) (GabIPerson *self); const gchar *(*get_address) (GabIPerson *self); void (*set_address) (GabIPerson *self, const gchar *address); const gchar *(*get_phone) (GabIPerson *self, GabIPersonPhoneType phone_type); void (*set_phone) (GabIPerson *self, GabIPersonPhoneType phone_type, const gchar *phone); }; GType gab_iperson_get_type (void); const gchar *gab_iperson_get_name (GabIPerson *self); const gchar *gab_iperson_get_surname (GabIPerson *self); const gchar *gab_iperson_get_address (GabIPerson *self); void gab_iperson_set_address (GabIPerson *self, const gchar *address); const gchar *gab_iperson_get_phone (GabIPerson *self, GabIPersonPhoneType phone_type); void gab_iperson_set_phone (GabIPerson *self, GabIPersonPhoneType phone_type, const gchar *phone); /* Signals */ void gab_iperson_address_changed (GabIPerson *self); void gab_iperson_phone_changed (GabIPerson *self); /* Helpers */ const gchar *gab_iperson_phone_type_to_str (GabIPersonPhoneType phone_type); GabIPersonPhoneType gab_iperson_phone_type_from_str (const gchar *phone_type); G_END_DECLS #endif /* __GAB_IPERSON_H__ */
#include "em_device.h" #include "em_chip.h" #include "em_cmu.h" #include "em_emu.h" #include "RegisterFile.h" #include "SystemDelay.h" #include "MODBUS.h" #include "ADPS9960.h" #include "timers.h" #include "IODrivers.h" void Check_distance(void) { uint16_t distance = 0; uint16_t threshold_max; uint16_t threshold_min; distance = ADPS9960_GetDistance(); threshold_max = register_direct_read (REGISTER_THRES_HIGH); threshold_min = register_direct_read (REGISTER_THRES_LOW); register_direct_write(REGISTER_DISTANCE, distance); if ( (distance > threshold_max) || (distance < threshold_min) ) { RelayOn (0); LEDOn(); } else { RelayOff (0); LEDOff(); } } int main(void) { /* Chip errata */ CHIP_Init(); CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFXO); CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO); Drivers_init(); register_init(); SysTicksInit(); modbus_init(); ADPS9960_Init(); Timers_init(); Timers_setDuty(3); /* Infinite loop */ while (1) { SysTicksDisable(); EMU_EnterEM2(true); SysTicksEnable(); modbus_slave(); if (Timers_triggered()) { Timers_processed(); Check_distance(); } } }
/* * Copyright (C) 2017 Çağrı Ulaş <cagriulas@gmail.com> * Copyright (C) 2017 Canberk Koç <canberkkoc@gmail.com> * * This file is part of bluelock-manager. * * bluelock-manager 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. * * bluelock-manager 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 bluelock-manager. If not, see <http://www.gnu.org/licenses/>. */ #ifndef BLUETOOTHITEMWIDGET_H #define BLUETOOTHITEMWIDGET_H #include <QtWidgets/QWidget> namespace Ui { class BluetoothItemWidget; } class BluetoothItemWidget : public QWidget { Q_OBJECT public: explicit BluetoothItemWidget(QString DeviceName, QString DeviceMAC, bool available = false, bool trusted = false, QWidget *parent = 0); ~BluetoothItemWidget(); QString getDeviceMAC(); void setDeviceName(QString deviceName); void setTrust(bool trusted); void setAvailable(bool available); public slots: void trustCheckBoxClicked(bool trustState); signals: void trustStateChanged(bool trustState); private: Ui::BluetoothItemWidget *ui; }; #endif // BLUETOOTHITEMWIDGET_H
#ifndef TILEMAP_H #define TILEMAP_H #include "structs/Tbyte.h" #include "gamegear/TileReference.h" #include <string> namespace Tales { /** * A rectangular area composed of tile identifiers. */ class TileMap { public: /** * Enum of tilemap types. * 2-byte-per-tile format is a standard "full" tilemap with 16-bit * identifiers. * 1-byte-per-tile format specifies only the low byte of each identifier, * with some particular high byte for all values specified in the code. * The main difference is that 1-byte-per-tile format restricts tiles * to a specific range (0-255 or 256-511) and prevents them from being * mirrored, having palette flags set, etc. */ enum TileMapFormat { oneBytePerTile, twoBytesPerTile }; /** * Default constructor. */ TileMap(); /** * Constructor from raw data. * @param data Raw data source. * @param format__ Format of the source data. * @param w__ Width in tiles of the source data. * @param h__ Height in tiles of the source data. */ TileMap(const Tbyte* data, TileMapFormat format__, int w__, int h__); /** * Constructor from raw 1bpt data. * @param data Raw data source. * @param format__ Format of the source data. * @param w__ Width in tiles of the source data. * @param h__ Height in tiles of the source data. * @param upperByte__ Upper byte of each tile entry. */ TileMap(const Tbyte* data, TileMapFormat format__, int w__, int h__, Tbyte upperByte__); /** * Copy constructor. */ TileMap(const TileMap& t); /** * Copy assignment. */ TileMap& operator=(const TileMap& t); /** * Destructor. */ ~TileMap(); /** * Reads a tilemap from raw data. * @param data Raw data source. * @param format__ Format of the source data. * @param w__ Width in tiles of the source data. * @param h__ Height in tiles of the source data. */ int readFromData(const Tbyte* data, TileMapFormat format__, int w__, int h__); /** * Reads a 1bpt tilemap from raw data. * @param data Raw data source. * @param format__ Format of the source data. * @param w__ Width in tiles of the source data. * @param h__ Height in tiles of the source data. */ int readFromData(const Tbyte* data, TileMapFormat format__, int w__, int h__, Tbyte upperByte__); /** * Writes the tilemap to raw data. * @param data Raw data destination. */ void writeToData(Tbyte* data) const; /** * Saves to a string. * @param data String to save to. */ void save(std::string& data) const; /** * Loads from a byte array. * @param data Byte array to load from. */ int load(const Tbyte* data); /** * Accesses tile data. * @param x X-position of the target tile. * @param y Y-position of the target tile. * @return Reference to the TileReference for the given tile. */ TileReference& tileData(int x, int y); /** * Accesses const tile data. * @param x X-position of the target tile. * @param y Y-position of the target tile. * @return Const reference to the TileReference for the given tile. */ const TileReference& tileData(int x, int y) const; /** * Getter. */ TileMapFormat format() const; /** * Getter. */ int w() const; /** * Getter. */ int h() const; /** * Getter. */ int lowerLimit() const; /** * Getter. */ int upperLimit() const; /** * Setter. */ void setFormat(TileMapFormat format__); /** * Setter. */ void setW(int w__); /** * Setter. */ void setH(int h__); /** * Setter. */ void setLowerLimit(int lowerLimit__); /** * Setter. */ void setUpperLimit(int upperLimit__); protected: /** * Default lower limit of tilemap range (0 = all tiles). */ const static int defaultLowerLimit_ = 0; /** * Default upper limit of tilemap range (512 = all tiles). */ const static int defaultUpperLimit_ = 512; /** * Deallocate the tile array. */ void destroyTileData(); /** * Initialize the tile array to the specified size. */ void reinitializeTileData(int w__, int h__); /** * Array of tile data. */ TileReference** tileData_; /** * Format of the source data. */ TileMapFormat format_; /** * Width in tiles of the tilemap. */ int w_; /** * Height in tiles of the tilemap. */ int h_; /** * Lower limit of the tiles that can be specified in the tilemap. */ int lowerLimit_; /** * Upper limit of the tiles that can be specified in the tilemap. */ int upperLimit_; }; }; #endif
/* This file is magic. Normalizing arrays of vectors is a time consuming but * common task in computer graphics. In this file, we temporarily break away * from Ocaml to indulge in hacky, bit-level black magic. In doing so, we * are able to outperform C++ compiled with -O2 by 15-20% -- all while still * accessing this function from a garbage collected, high-level language!! */ #define CAML_NAME_SPACE #include <caml/mlvalues.h> /* This is a fast inverse square root approximation algorithm, for optimizing * normalization of vectors. The algorithm is based on a similar version for * single precision floats by John Carmack and an extension to arbitary * precision formats by Chris Lomont (lomont.org/Math/Papers/2003/InvSqrt.pdf) */ inline double fastInvSqrt(double x) { double xhalf = 0.5 * x; long i = *(long *) &x; i = 0x5fe6ec85e7de30da - (i>>1); // "magic" approximation x = *(double *) &i; x = x * (1.5 - xhalf*x*x); // one step of newton's method return x; } /* Wrap with appropriate type conversion between C and ML bit representations */ value fastInvSqrtArr(value arr) { int len = (int) caml_array_length(arr); int i = 0; for (i = 0; i < len; i += 3) { double x = Double_field(arr, i); double y = Double_field(arr, i + 1); double z = Double_field(arr, i + 2); double ilen = fastInvSqrt(x*x + y*y + z*z); Store_double_field(arr, i, x * ilen); Store_double_field(arr, i + 1, y * ilen); Store_double_field(arr, i + 2, z * ilen); } return (Val_unit); }
/* * Red Bull Media Player * Copyright (C) 2011, Red Bull * * 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/>. */ #ifndef SUBSECTIONSETUPOBJECT_H #define SUBSECTIONSETUPOBJECT_H #include "../../../Interfaces/UserSettings/ISetupSubSectionObject.h" namespace RedBullPlayer { namespace Modules { namespace SettingsDetailView { class SubSectionSetupObject : public ISetupSubSectionObject { Q_OBJECT public: SubSectionSetupObject( QString id, QString title, QObject *parent ) : ISetupSubSectionObject( parent ) { _id = id; _title = title; } virtual QString getTitleText() { return _title; } virtual QString getId() { return _id; } private: QString _id; QString _title; }; } } } #endif // SUBSECTIONSETUPOBJECT_H
/// Copyright 2010-2012 4kdownload.com (developers@4kdownload.com) /** This file is part of 4k Download. 4k Download is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: 1. GNU GENERAL PUBLIC LICENSE Version 3 (See file COPYING.GPLv3 for details). 2. 4k Download Commercial License (Send request to developers@4kdownload.com for details). */ #ifndef _OPENMEDIA_DT_SLIDESHOW_SOURCE_IMPL_H_INCLUDED_4ED84B5C #define _OPENMEDIA_DT_SLIDESHOW_SOURCE_IMPL_H_INCLUDED_4ED84B5C #ifdef _MSC_VER #pragma once #endif #include <openmedia/DTAVSource.h> namespace openmedia { class av_source::Impl { public: virtual video_source * video() = 0; virtual audio_source * audio() = 0; virtual double seek(double position) = 0; virtual void apply_settings(media_settings_ptr settings) = 0; virtual ~Impl() = 0; }; inline av_source::Impl::~Impl() {} } #endif
#ifndef PROGRESSDIALOG_H #define PROGRESSDIALOG_H #include <QDialog> namespace Ui { class ProgressDialog; } class ProgressDialog : public QDialog { Q_OBJECT public: explicit ProgressDialog(QWidget *parent = 0); ~ProgressDialog(); void setLabel(QString label); QString label(); void showCancelButton(bool fShow = true); void showProgressBar(bool fShow = true); int min(); int max(); int progress(); public slots: void setProgress(int value); void setProgress(int value, int max, QString label); void setMax(int value); void setMin(int value); private: QMovie *movieIcon; QMovie *movieIconSmall; Ui::ProgressDialog *ui; // QWidget interface protected: void showEvent(QShowEvent *); void hideEvent(QHideEvent *); void keyPressEvent(QKeyEvent *); // QDialog interface public slots: void reject(); void accept(); }; #endif // PROGRESSDIALOG_H
/******************************************************************************** ** Form generated from reading UI file 'add_line_master.ui' ** ** Created: Thu Aug 11 22:41:13 2011 ** by: Qt User Interface Compiler version 4.7.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_ADD_LINE_MASTER_H #define UI_ADD_LINE_MASTER_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QDialog> #include <QtGui/QDialogButtonBox> #include <QtGui/QGraphicsView> #include <QtGui/QGridLayout> #include <QtGui/QHeaderView> #include <QtGui/QLabel> #include <QtGui/QSpinBox> #include <QtGui/QWidget> QT_BEGIN_NAMESPACE class Ui_Dialog { public: QDialogButtonBox *buttonBox; QLabel *label; QWidget *gridLayoutWidget; QGridLayout *gridLayout; QLabel *label_2; QLabel *label_3; QLabel *label_4; QLabel *label_5; QLabel *label_6; QSpinBox *startXspin; QSpinBox *startYspin; QSpinBox *heithSpin; QSpinBox *widthSpin; QSpinBox *thickSpin; QGraphicsView *graphicsView; void setupUi(QDialog *Dialog) { if (Dialog->objectName().isEmpty()) Dialog->setObjectName(QString::fromUtf8("Dialog")); Dialog->resize(527, 300); buttonBox = new QDialogButtonBox(Dialog); buttonBox->setObjectName(QString::fromUtf8("buttonBox")); buttonBox->setGeometry(QRect(30, 240, 341, 32)); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); label = new QLabel(Dialog); label->setObjectName(QString::fromUtf8("label")); label->setGeometry(QRect(40, 30, 191, 16)); gridLayoutWidget = new QWidget(Dialog); gridLayoutWidget->setObjectName(QString::fromUtf8("gridLayoutWidget")); gridLayoutWidget->setGeometry(QRect(40, 60, 251, 161)); gridLayout = new QGridLayout(gridLayoutWidget); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); gridLayout->setContentsMargins(0, 0, 0, 0); label_2 = new QLabel(gridLayoutWidget); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_2, 0, 0, 1, 1); label_3 = new QLabel(gridLayoutWidget); label_3->setObjectName(QString::fromUtf8("label_3")); label_3->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_3, 1, 0, 1, 1); label_4 = new QLabel(gridLayoutWidget); label_4->setObjectName(QString::fromUtf8("label_4")); label_4->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_4, 0, 2, 1, 1); label_5 = new QLabel(gridLayoutWidget); label_5->setObjectName(QString::fromUtf8("label_5")); label_5->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_5, 1, 2, 1, 1); label_6 = new QLabel(gridLayoutWidget); label_6->setObjectName(QString::fromUtf8("label_6")); label_6->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_6, 2, 0, 1, 2); startXspin = new QSpinBox(gridLayoutWidget); startXspin->setObjectName(QString::fromUtf8("startXspin")); startXspin->setAlignment(Qt::AlignCenter); gridLayout->addWidget(startXspin, 0, 1, 1, 1); startYspin = new QSpinBox(gridLayoutWidget); startYspin->setObjectName(QString::fromUtf8("startYspin")); startYspin->setAlignment(Qt::AlignCenter); gridLayout->addWidget(startYspin, 1, 1, 1, 1); heithSpin = new QSpinBox(gridLayoutWidget); heithSpin->setObjectName(QString::fromUtf8("heithSpin")); heithSpin->setAlignment(Qt::AlignCenter); gridLayout->addWidget(heithSpin, 1, 3, 1, 1); widthSpin = new QSpinBox(gridLayoutWidget); widthSpin->setObjectName(QString::fromUtf8("widthSpin")); widthSpin->setAlignment(Qt::AlignCenter); gridLayout->addWidget(widthSpin, 0, 3, 1, 1); thickSpin = new QSpinBox(gridLayoutWidget); thickSpin->setObjectName(QString::fromUtf8("thickSpin")); thickSpin->setAlignment(Qt::AlignCenter); gridLayout->addWidget(thickSpin, 2, 2, 1, 1); graphicsView = new QGraphicsView(Dialog); graphicsView->setObjectName(QString::fromUtf8("graphicsView")); graphicsView->setGeometry(QRect(310, 60, 200, 161)); retranslateUi(Dialog); QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), Dialog, SLOT(reject())); QMetaObject::connectSlotsByName(Dialog); } // setupUi void retranslateUi(QDialog *Dialog) { Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("Dialog", "\320\234\320\260\321\201\321\202\320\265\321\200 \320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275\320\270\321\217 \320\273\320\270\320\275\320\270\320\270", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("Dialog", "startX", 0, QApplication::UnicodeUTF8)); label_3->setText(QApplication::translate("Dialog", "startY", 0, QApplication::UnicodeUTF8)); label_4->setText(QApplication::translate("Dialog", "+X", 0, QApplication::UnicodeUTF8)); label_5->setText(QApplication::translate("Dialog", "+Y", 0, QApplication::UnicodeUTF8)); label_6->setText(QApplication::translate("Dialog", "\320\242\320\276\320\273\321\211\320\270\320\275\320\260", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; namespace Ui { class Dialog: public Ui_Dialog {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_ADD_LINE_MASTER_H
/*---------------------------------------------------------------------------- ADOL-C -- Automatic Differentiation by Overloading in C++ File: zos_forward.c Revision: $Id: zos_forward.c 134 2009-03-03 14:25:24Z imosqueira $ Contents: zos_forward (zero-order-scalar forward mode) Copyright (c) 2004 Technical University Dresden Department of Mathematics Institute of Scientific Computing This file is part of ADOL-C. This software is provided under the terms of the Common Public License. Any use, reproduction, or distribution of the software constitutes recipient's acceptance of the terms of this license. See the accompanying copy of the Common Public License for more details. ----------------------------------------------------------------------------*/ #define _ZOS_ 1 #define _KEEP_ 1 #include "uni5_for.c" #undef _KEEP_ #undef _ZOS_
/* ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _USBCFG_H_ #define _USBCFG_H_ #define USBD2_DATA_REQUEST_EP 1 #define USBD2_DATA_AVAILABLE_EP 1 #define USBD2_INTERRUPT_REQUEST_EP 2 extern const USBConfig usbcfg; #endif /* _USBCFG_H_ */ /** @} */
#import <Foundation/Foundation.h> #import "SpectaTypes.h" @class SPTExample ; @interface SPTExampleGroup : NSObject { NSString *_name; SPTExampleGroup *_root; SPTExampleGroup *_parent; NSMutableArray *_children; NSMutableArray *_beforeAllArray; NSMutableArray *_afterAllArray; NSMutableArray *_beforeEachArray; NSMutableArray *_afterEachArray; NSMutableDictionary *_sharedExamples; unsigned int _exampleCount; unsigned int _ranExampleCount; BOOL _focused; } @property (nonatomic, copy) NSString *name; @property (nonatomic, assign) SPTExampleGroup *root; @property (nonatomic, assign) SPTExampleGroup *parent; @property (nonatomic, retain) NSMutableArray *children; @property (nonatomic, retain) NSMutableArray *beforeAllArray; @property (nonatomic, retain) NSMutableArray *afterAllArray; @property (nonatomic, retain) NSMutableArray *beforeEachArray; @property (nonatomic, retain) NSMutableArray *afterEachArray; @property (nonatomic, retain) NSMutableDictionary *sharedExamples; @property (nonatomic) unsigned int exampleCount; @property (nonatomic) unsigned int ranExampleCount; @property (nonatomic, getter=isFocused) BOOL focused; + (void)setAsyncSpecTimeout:(NSTimeInterval)timeout; - (id)initWithName:(NSString *)name parent:(SPTExampleGroup *)parent root:(SPTExampleGroup *)root; - (SPTExampleGroup *)addExampleGroupWithName:(NSString *)name; - (SPTExampleGroup *)addExampleGroupWithName:(NSString *)name focused:(BOOL)focused; - (SPTExample *)addExampleWithName:(NSString *)name block:(id)block; - (SPTExample *)addExampleWithName:(NSString *)name block:(id)block focused:(BOOL)focused; - (void)addBeforeAllBlock:(SPTVoidBlock)block; - (void)addAfterAllBlock:(SPTVoidBlock)block; - (void)addBeforeEachBlock:(SPTVoidBlock)block; - (void)addAfterEachBlock:(SPTVoidBlock)block; - (NSArray *)compileExamplesWithNameStack:(NSArray *)nameStack; @end
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo * This benchmark is part of SWSC */ #include <assert.h> #include <stdint.h> #include <stdatomic.h> #include <pthread.h> atomic_int vars[3]; atomic_int atom_0_r3_1; atomic_int atom_1_r3_2; atomic_int atom_2_r1_1; atomic_int atom_2_r3_0; void *t0(void *arg){ label_1:; atomic_store_explicit(&vars[0], 1, memory_order_seq_cst); int v2_r3 = atomic_load_explicit(&vars[0], memory_order_seq_cst); int v3_r4 = v2_r3 ^ v2_r3; int v4_r4 = v3_r4 + 1; atomic_store_explicit(&vars[1], v4_r4, memory_order_seq_cst); int v23 = (v2_r3 == 1); atomic_store_explicit(&atom_0_r3_1, v23, memory_order_seq_cst); return NULL; } void *t1(void *arg){ label_2:; atomic_store_explicit(&vars[1], 2, memory_order_seq_cst); int v6_r3 = atomic_load_explicit(&vars[1], memory_order_seq_cst); int v7_r4 = v6_r3 ^ v6_r3; int v8_r4 = v7_r4 + 1; atomic_store_explicit(&vars[2], v8_r4, memory_order_seq_cst); int v24 = (v6_r3 == 2); atomic_store_explicit(&atom_1_r3_2, v24, memory_order_seq_cst); return NULL; } void *t2(void *arg){ label_3:; int v10_r1 = atomic_load_explicit(&vars[2], memory_order_seq_cst); int v12_r3 = atomic_load_explicit(&vars[0], memory_order_seq_cst); int v25 = (v10_r1 == 1); atomic_store_explicit(&atom_2_r1_1, v25, memory_order_seq_cst); int v26 = (v12_r3 == 0); atomic_store_explicit(&atom_2_r3_0, v26, memory_order_seq_cst); return NULL; } int main(int argc, char *argv[]){ pthread_t thr0; pthread_t thr1; pthread_t thr2; atomic_init(&vars[1], 0); atomic_init(&vars[0], 0); atomic_init(&vars[2], 0); atomic_init(&atom_0_r3_1, 0); atomic_init(&atom_1_r3_2, 0); atomic_init(&atom_2_r1_1, 0); atomic_init(&atom_2_r3_0, 0); pthread_create(&thr0, NULL, t0, NULL); pthread_create(&thr1, NULL, t1, NULL); pthread_create(&thr2, NULL, t2, NULL); pthread_join(thr0, NULL); pthread_join(thr1, NULL); pthread_join(thr2, NULL); int v13 = atomic_load_explicit(&vars[1], memory_order_seq_cst); int v14 = (v13 == 2); int v15 = atomic_load_explicit(&atom_0_r3_1, memory_order_seq_cst); int v16 = atomic_load_explicit(&atom_1_r3_2, memory_order_seq_cst); int v17 = atomic_load_explicit(&atom_2_r1_1, memory_order_seq_cst); int v18 = atomic_load_explicit(&atom_2_r3_0, memory_order_seq_cst); int v19_conj = v17 & v18; int v20_conj = v16 & v19_conj; int v21_conj = v15 & v20_conj; int v22_conj = v14 & v21_conj; if (v22_conj == 1) assert(0); return 0; }
/* * DO NOT EDIT THIS FILE - it is generated by Glade. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> #include <stdio.h> #include <gnome.h> #include "support.h" GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name) { GtkWidget *parent, *found_widget; for (;;) { if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else parent = widget->parent; if (!parent) parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); if (parent == NULL) break; widget = parent; } found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); if (!found_widget) g_warning ("Widget not found: %s", widget_name); return found_widget; } /* This is an internally used function to create pixmaps. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename) { GtkWidget *pixmap; gchar *pathname; if (!filename || !filename[0]) return gtk_image_new (); pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, filename, TRUE, NULL); if (!pathname) { g_warning ("Couldn't find pixmap file: %s", filename); return gtk_image_new (); } pixmap = gtk_image_new_from_file (pathname); g_free (pathname); return pixmap; } /* This is an internally used function to create pixmaps. */ GdkPixbuf* create_pixbuf (const gchar *filename) { gchar *pathname = NULL; GdkPixbuf *pixbuf; GError *error = NULL; if (!filename || !filename[0]) return NULL; pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, filename, TRUE, NULL); if (!pathname) { g_warning ("Couldn't find pixmap file: %s", filename); return NULL; } pixbuf = gdk_pixbuf_new_from_file (pathname, &error); if (!pixbuf) { fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message); g_error_free (error); } g_free (pathname); return pixbuf; } /* This is used to set ATK action descriptions. */ void glade_set_atk_action_description (AtkAction *action, const gchar *action_name, const gchar *description) { gint n_actions, i; n_actions = atk_action_get_n_actions (action); for (i = 0; i < n_actions; i++) { if (!strcmp (atk_action_get_name (action, i), action_name)) atk_action_set_description (action, i, description); } }
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <papi.h> #include <sys/timerfd.h> /* typedef struct { char dirname[256]; char filename[256]; unsigned looplineno; unsigned iter; } __dt_currentposition; */ //__dt_currentposition __dt_pos; //extern __dt_currentposition __dt_pos; int events[3] = {PAPI_TOT_CYC, PAPI_L1_TCM, PAPI_L2_TCM}; int eventnum = 3; long long values[3]; long long tempvalues[3]; int eventset; FILE *gnuplotfile; //static char __dt_curfilename[]="test3.c"; //static char __dt_curdirname[]="///"; struct periodic_info { int timer_fd; unsigned long long wakeups_missed; }; static int make_periodic (unsigned int period, struct periodic_info *info) { int ret; unsigned int ns; unsigned int sec; int fd; struct itimerspec itval; /* Create the timer */ fd = timerfd_create (CLOCK_MONOTONIC, 0); info->wakeups_missed = 0; info->timer_fd = fd; if (fd == -1) return fd; /* Make the timer periodic */ sec = period/1000000; ns = (period - (sec * 1000000)) * 1000; itval.it_interval.tv_sec = sec; itval.it_interval.tv_nsec = ns; itval.it_value.tv_sec = sec; itval.it_value.tv_nsec = ns; ret = timerfd_settime (fd, 0, &itval, NULL); return ret; } static void wait_period (struct periodic_info *info) { unsigned long long missed; int ret; /* Wait for the next timer event. If we have missed any the number is written to "missed" */ ret = read (info->timer_fd, &missed, sizeof (missed)); if (ret == -1) { perror ("read timer"); return; } /* "missed" should always be >= 1, but just to be sure, check it is not 0 anyway */ if (missed > 0) info->wakeups_missed += (missed - 1); } void *PapiKernel (void *Args) { struct periodic_info info; long long i=0; tempvalues[0]=0; tempvalues[1]=0; tempvalues[2]=0; // 10ms interval make_periodic (10000, &info); while (1) { i+=10; /* Do useful work */ PAPI_read(eventset, values); fprintf(gnuplotfile,"%lld\t%lld\t%lld\n", i, values[1]-tempvalues[1], values[2]-tempvalues[2]); //__dt_pos.filename,__dt_pos.looplineno,__dt_pos.iter); //lastmissrate=(values[1]-tempvalues[1])*180/(values[2]-tempvalues[2]); //printf(__dt_curfilename); tempvalues[1]=values[1]; tempvalues[2]=values[2]; wait_period (&info); } return NULL; } int test() { int i,j; int numInt; int numCachelineUsed; int *a; numInt = 2*1024*1024; //numInt = 1024*1024; numCachelineUsed = 8*1024*1024/64; //numCachelineUsed = 4*1024*1024/64; a = (int*) malloc(sizeof(int)*numInt); pthread_attr_t attr; pthread_t Thread; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); pthread_create(&Thread, &attr, PapiKernel, NULL); //cache miss = 1 for(j=0; j<16; j++) for(i=0; i< numCachelineUsed; i++) { //strcpy(__dt_pos.dirname, __dt_curdirname); //strcpy(__dt_pos.filename, __dt_curfilename); //__dt_pos.looplineno = 100; //__dt_pos.iter = 200; a[i*16+j]++; } //cache miss = 0 for(i=0;i<numInt;i++) a[i]++; //cache miss = 1 for(j=0; j<16; j++) for(i=0; i< numCachelineUsed; i++) a[i*16+j]++; //cache miss = 0 for(i=0;i<numInt;i++) a[i]++; //cache miss = 1 for(j=0; j<16; j++) for(i=0; i< numCachelineUsed; i++) a[i*16+j]++; //cache miss = 0 for(i=0;i<numInt;i++) a[i]++; pthread_cancel(Thread); return 0; } int main (int argc, char *argv[]) { int i, j; //papi init code begin long long s; long long e; int retval; int eventcode; PAPI_option_t opt; if(PAPI_VER_CURRENT != PAPI_library_init(PAPI_VER_CURRENT)){ printf("Can't initiate PAPI library!\n"); exit(-1); } if (PAPI_thread_init(pthread_self) != PAPI_OK) { printf("Can't thread init!\n"); exit(-1); } eventset = PAPI_NULL; if(PAPI_create_eventset(&eventset) != PAPI_OK){ printf("Can't create eventset!\n"); exit(-3); } if ( ( retval = PAPI_assign_eventset_component( eventset, 0 ) ) != PAPI_OK ) { printf("Can't assign_event_component!\n"); exit(-3); } memset( &opt, 0x0, sizeof ( PAPI_option_t ) ); opt.inherit.inherit = PAPI_INHERIT_ALL; opt.inherit.eventset = eventset; if ( ( retval = PAPI_set_opt( PAPI_INHERIT, &opt ) ) != PAPI_OK ) { printf("Can't set inherit!\n"); exit(-3); } PAPI_event_name_to_code("MEM_LOAD_MISC_RETIRED:LLC_MISS",&eventcode); events[1] = eventcode; PAPI_event_name_to_code("CPU_CLK_UNHALTED:THREAD_P",&eventcode); events[2] = eventcode; for(i=0;i<3;i++) { retval = PAPI_add_event(eventset, events[i]); if(retval != PAPI_OK){ printf("error %d\n",retval); exit(-4); } } //papi init code end /* create output file in gnuplot format */ gnuplotfile = fopen("test3_tcm.txt", "w"); //fprintf(gnuplotfile,"#time(ms)\tMEM_LOAD_MISC_RETIRED:LLC_MISS\tCPU_CLK_UNHALTED:THREAD_P\n"); s = PAPI_get_real_usec(); PAPI_start(eventset); test(); PAPI_stop(eventset, values); e = PAPI_get_real_usec(); fclose(gnuplotfile); /*Print out PAPI reading*/ printf("Wallclock time: %lld usec\n",e-s); printf("Total Cycles\t%lld\n", values[0]); printf("MEM_LOAD_MISC_RETIRED:LLC_MISS\t%lld\n", values[1]); printf("CPU_CLK_UNHALTED:THREAD_P\t%lld\n", values[2]); return 0; }
// e.g. https://www.aliexpress.com/item/IPS-3-97-inch-HD-TFT-LCD-Touch-Screen-Module-OTM8009A-Drive-IC-800-480/32676929794.html // on https://www.aliexpress.com/item/STM32F407ZGT6-Development-Board-ARM-M4-STM32F4-cortex-M4-core-Board-Compatibility-Multiple-Extension/32795142050.html // // this version is for use with Arduino package STM32GENERIC, board "BLACK F407VE/ZE/ZG boards". // Specific Board "BLACK F407ZG (M4 DEMO)" #include "GxIO/STM32GENERIC/GxIO_STM32F407ZGM4_FSMC/GxIO_STM32F407ZGM4_FSMC.h" //#include "GxIO/STM32GENERIC/GxIO_STM32F407ZGM4_P16/GxIO_STM32F407ZGM4_P16.h" #include "GxCTRL/GxCTRL_OTM8009A/GxCTRL_OTM8009A.h" // 800x480 GxIO_Class io; // #define GxIO_Class is in the selected header file GxCTRL_Class controller(io); // #define GxCTRL_Class is in the selected header file TFT_Class tft(io, controller, 800, 480); // landscape 800x480 //TFT_Class tft(io, controller, 480, 800); // portrait 480x800
/* * isis_antenna_pinmap.h * * Copyright (C) 2017-2019, Universidade Federal de Santa Catarina. * * This file is part of FloripaSat-TTC. * * FloripaSat-TTC 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. * * FloripaSat-TTC 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 FloripaSat-TTC. If not, see <http://www.gnu.org/licenses/>. * */ /** * \brief ISIS antenna driver pin map. * * \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com> * * \version 0.2.1 * * \date 21/09/2017 * * \defgroup isis_antenna_pinmap * \{ */ #ifndef ISIS_ANTENNA_PINMAP_H_ #define ISIS_ANTENNA_PINMAP_H_ #include <config/pinmap.h> #define ISIS_ANTENNA_I2C_PORT ANTENNA_I2C_PORT #define ISIS_ANTENNA_I2C_USCI ANTENNA_I2C_USCI #define ISIS_ANTENNA_I2C_BASE_ADDRESS ANTENNA_I2C_BASE_ADDRESS #define ISIS_ANTENNA_I2C_SDA_PORT ANTENNA_I2C_SDA_PORT #define ISIS_ANTENNA_I2C_SDA_PIN ANTENNA_I2C_SDA_PIN #define ISIS_ANTENNA_I2C_SCL_PORT ANTENNA_I2C_SCL_PORT #define ISIS_ANTENNA_I2C_SCL_PIN ANTENNA_I2C_SCL_PIN #define ISIS_ANTENNA_GPIO_DEBUG_PORT ANTENNA_GPIO_DEBUG_PORT #define ISIS_ANTENNA_GPIO_DEBUG_PIN ANTENNA_GPIO_DEBUG_PIN #endif // ISIS_ANTENNA_PINMAP_H_ //! \} End of isis_antenna_pinmap group
/* * File: /src/bin-tree.c * * Project: nix-compress aka lz1337 * Author: Sebastian Büttner * Created: 11/27/2012 * */ /* Includes*/ // c-standard lib includes #include <stdlib.h> // third-party includes // cross-project includes // project-specific includes #include "bin-tree.h" /*---------------------------*/ TreePath* t_create(double Weight) { TreePath *tp; // 4 Bytes, stack TreeNode *tn; // 4 Bytes, stack tn = (TreeNode*) malloc( sizeof(TreeNode) ); // 16 Bytes (TreeNode), heap tp = (TreePath*) malloc( sizeof(TreePath) ); // 12 Bytes (TreePath), heap tn->Left = 0x00; tn->Right = 0x00; tn->Parent= 0x00; tn->Data = 0x00; tp->Node = tn; tp->Weight = Weight; return tp; // = 28 Bytes } TreeNode* t_insert(TreeNode *parent, TreePath *new_element) { if (parent->Left == 0x00) { parent->Left = new_element; new_element->Node->Parent = parent->Left->Node; } else if (parent->Right == 0x00) { parent->Right = new_element; new_element->Node->Parent = parent->Right->Node; } else { t_insert(parent->Left->Node, new_element); } return new_element->Node; } void t_delete(TreePath *e) { TreeNode *pe; if (e) { pe = e->Node->Parent; t_delete( e->Node->Left ); t_delete( e->Node->Right ); free(e->Node); free(e); pe->Left = 0x00; pe->Right= 0x00; } }
/* Glom * * Copyright (C) 2001-2004 Murray Cumming * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * 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, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. */ #ifndef GLOM_BOX_WITHBUTTONS_H #define GLOM_BOX_WITHBUTTONS_H #include <gtkmm/box.h> #include "utility_widgets/adddel/adddel_withbuttons.h" #include <libglom/document/document.h> #include <libglom/connectionpool.h> #include <libglom/appstate.h> #include <glom/base_db.h> #include <gtkmm/builder.h> namespace Glom { /** A Gtk::Box base widget class, * with some extra signals to allow derived classes to be used generically in * Window_BoxHolder, allowing the dialog to respond to buttons in the box. */ class Box_WithButtons : public Gtk::Box { public: Box_WithButtons(); Box_WithButtons(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder); ///For use with libglademm's get_widget_derived(): explicit Box_WithButtons(BaseObjectType* cobject); Gtk::Window* get_app_window(); const Gtk::Window* get_app_window() const; //void show_hint(); //Public so that it can be called *after* this widget is added to its container. void set_button_cancel(Gtk::Button& button); //Signals: sigc::signal<void(Glib::ustring)> signal_selected; //When an item is selected. sigc::signal<void()> signal_cancelled; //When the cancel button is clicked. virtual Gtk::Widget* get_default_button(); private: //Signal handlers: void on_Button_Cancel(); //virtual void hint_set(const Glib::ustring& strText); //Member data: //Glib::ustring m_strHint; //Help text. Gtk::Box m_Box_Buttons; Gtk::Button m_Button_Cancel; //Derived classes can use it if it's necessary. }; } //namespace Glom #endif //GLOM_BOX_WITHBUTTONS_H
/*************************************************************************** * Copyright (C) 2011 by Serge Poltavsky * * serge.poltavski@gmail.com * * * * 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/> * ***************************************************************************/ #ifndef MINIZIPIMPL_H #define MINIZIPIMPL_H #include <vector> #include <string> #include <boost/shared_ptr.hpp> #include "zipimpl.h" #include "minizip/zip.h" namespace cf { class MiniZipFile { public: MiniZipFile(const std::string& zip_fname); int compressionLevel() const; int compressionMethod() const; const std::string& content() const; void setCompressionLevel(int level); void setContent(const std::string& content); void setSource(const std::string& source); const std::string& source() const { return source_; } const std::string& zipName() const { return zip_fname_; } private: std::string zip_fname_; std::string content_; std::string source_; int level_; }; typedef boost::shared_ptr<MiniZipFile> FilePtr; class MiniZipImpl : public ZipImpl { public: MiniZipImpl(); void addFile(const std::string& fname); size_t fileCount() const; bool hasFile(const std::string& fname) const; void removeFile(const std::string& fname); bool save(const std::string& fname); void setCompression(const std::string& fname, int level); void setContent(const std::string& fname, const std::string& content); void setSource(const std::string& fname, const std::string& sourceFile); private: typedef std::vector<FilePtr> FileList; typedef FileList::iterator iterator; typedef FileList::const_iterator const_iterator; private: const_iterator find(const std::string& fname) const; iterator find(const std::string& fname); void saveFile(FilePtr f); void writeFile(FilePtr f, const char * data, size_t length); void writeFile(FilePtr f, const std::string& filename); private: zipFile zf; FileList files_; }; } #endif // MINIZIPIMPL_H
/*------------------------------------------------------------------------ -- -- -- P O S I X L I B R A R Y -- -- -------------------------- -- -- -- -- Copyright (C) 1988, Perihelion Software Ltd. -- -- All Rights Reserved. -- -- -- -- termios.c -- -- -- -- Terminal IO control. -- -- -- -- Author: NHG 8/5/88 -- -- -- ------------------------------------------------------------------------*/ /* SccsId: %W% %G% Copyright (C) 1987, Perihelion Software Ltd.*/ /* $Id: termios.c,v 1.4 1993/04/20 12:59:03 nickc Exp $ */ #include <helios.h> /* standard header */ #define __in_termios 1 /* flag that we are in this module */ #include "pposix.h" #include <termios.h> #include <attrib.h> #define CTRL(c) (c&037) extern int cf_getospeed(struct termios *p) { CHECKSIGS(); return (int) GetOutputSpeed((Attributes *)p); } extern int cf_setospeed(struct termios *p, int speed) { CHECKSIGS(); SetOutputSpeed((Attributes *)p,speed); return 0; } extern int cf_getispeed(struct termios *p) { CHECKSIGS(); return (int) GetInputSpeed((Attributes *)p); } extern int cf_setispeed(struct termios *p, int speed) { CHECKSIGS(); SetInputSpeed((Attributes *)p,speed); return 0; } extern int tcgetattr(int fd, struct termios *p) { Stream *s; fdentry *f; CHECKSIGS(); if((f = checkfd(fd)) == NULL ) return -1; s = f->pstream->stream; if( GetAttributes(s,(Attributes *)p) < 0 ) { errno = posix_error(Result2(s)); return -1; } /* These bits are really ConsoleRawInput and ConsoleRawOutput */ /* so we must invert them to mean what POSIX thinks. */ p->c_lflag ^= ICANNON; p->c_oflag ^= OPOST; /* now setup c_cc vector */ p->c_cc[VINTR] = CTRL('c'); p->c_cc[VQUIT] = 034; p->c_cc[VSUSP] = CTRL('z'); p->c_cc[VSTART] = CTRL('q'); p->c_cc[VSTOP] = CTRL('s'); if( p->c_lflag & ICANNON ) { p->c_cc[VEOF] = CTRL('d'); p->c_cc[VEOL] = '\n'; p->c_cc[VERASE] = 0177; p->c_cc[VKILL] = CTRL('u'); } else { p->c_cc[VMIN] = p->c_min; p->c_cc[VTIME] = p->c_time; } CHECKSIGS(); return 0; } extern int tcsetattr(int fd, int actions, struct termios *p) { Stream *s; fdentry *f; CHECKSIGS(); if((f = checkfd(fd)) == NULL ) return -1; actions = actions; s = f->pstream->stream; p->c_lflag ^= ICANNON; p->c_oflag ^= OPOST; p->c_min = p->c_cc[VMIN]; p->c_time = p->c_cc[VTIME]; if( SetAttributes(s,(Attributes *)p) < 0 ) { errno = posix_error(Result2(s)); return -1; } CHECKSIGS(); return 0; } extern int tcsendbreak(int fd, int duration) { fd = fd; duration = duration; /* @@@ tcsendbreak */ CHECKSIGS(); return 0; } extern int tcdrain(int fd) { fd = fd; /* @@@ tcdrain */ CHECKSIGS(); return 0; } extern int tcflush(int fd, int qselect) { fd = fd; qselect = qselect; /* @@@ tcflush */ CHECKSIGS(); return 0; } extern int tcflow(int fd, int action) { fd = fd; action = action; /* @@@ tcflow */ CHECKSIGS(); errno = EINVAL; return -1; } /* end of termios.c */
/* base64.h -- Encode binary data using printable characters. Copyright (C) 2004-2006, 2009-2018 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, 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 <https://www.gnu.org/licenses/>. */ /* Ported to FreeDOS by LiquidFox1776 */ #ifndef BASE64_H # define BASE64_H #include "const.h" /* Get size_t. */ # include <stddef.h> /* Get bool. */ # include <stdbool.h> # ifdef __cplusplus extern "C" { # endif /* This uses that the expression (n+(k-1))/k means the smallest integer >= n/k, i.e., the ceiling of n/k. */ # define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) struct base64_decode_context { unsigned int i; char buf[4]; }; extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST; extern void base64_encode (const char *__restrict in, size_t inlen, char *__restrict out, size_t outlen); extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out); extern void base64_decode_ctx_init (struct base64_decode_context *ctx); extern bool base64_decode_ctx (struct base64_decode_context *ctx, const char *__restrict in, size_t inlen, char *__restrict out, size_t *outlen); extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx, const char *in, size_t inlen, char **out, size_t *outlen); #define base64_decode(in, inlen, out, outlen) \ base64_decode_ctx (NULL, in, inlen, out, outlen) #define base64_decode_alloc(in, inlen, out, outlen) \ base64_decode_alloc_ctx (NULL, in, inlen, out, outlen) # ifdef __cplusplus } # endif #endif /* BASE64_H */
/* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ #include "ompi_config.h" #include "ompi/mpi/fortran/mpif-h/bindings.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak PMPI_TYPE_CREATE_HVECTOR = ompi_type_create_hvector_f #pragma weak pmpi_type_create_hvector = ompi_type_create_hvector_f #pragma weak pmpi_type_create_hvector_ = ompi_type_create_hvector_f #pragma weak pmpi_type_create_hvector__ = ompi_type_create_hvector_f #pragma weak PMPI_Type_create_hvector_f = ompi_type_create_hvector_f #pragma weak PMPI_Type_create_hvector_f08 = ompi_type_create_hvector_f #else OMPI_GENERATE_F77_BINDINGS (PMPI_TYPE_CREATE_HVECTOR, pmpi_type_create_hvector, pmpi_type_create_hvector_, pmpi_type_create_hvector__, pompi_type_create_hvector_f, (MPI_Fint *count, MPI_Fint *blocklength, MPI_Aint *stride, MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr), (count, blocklength, stride, oldtype, newtype, ierr) ) #endif #endif #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_TYPE_CREATE_HVECTOR = ompi_type_create_hvector_f #pragma weak mpi_type_create_hvector = ompi_type_create_hvector_f #pragma weak mpi_type_create_hvector_ = ompi_type_create_hvector_f #pragma weak mpi_type_create_hvector__ = ompi_type_create_hvector_f #pragma weak MPI_Type_create_hvector_f = ompi_type_create_hvector_f #pragma weak MPI_Type_create_hvector_f08 = ompi_type_create_hvector_f #else #if ! OMPI_BUILD_MPI_PROFILING OMPI_GENERATE_F77_BINDINGS (MPI_TYPE_CREATE_HVECTOR, mpi_type_create_hvector, mpi_type_create_hvector_, mpi_type_create_hvector__, ompi_type_create_hvector_f, (MPI_Fint *count, MPI_Fint *blocklength, MPI_Aint *stride, MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr), (count, blocklength, stride, oldtype, newtype, ierr) ) #else #define ompi_type_create_hvector_f pompi_type_create_hvector_f #endif #endif void ompi_type_create_hvector_f(MPI_Fint *count, MPI_Fint *blocklength, MPI_Aint *stride, MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr) { int c_ierr; MPI_Datatype c_old = PMPI_Type_f2c(*oldtype); MPI_Datatype c_new; c_ierr = PMPI_Type_hvector(OMPI_FINT_2_INT(*count), OMPI_FINT_2_INT(*blocklength), *stride, c_old, &c_new); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *newtype = PMPI_Type_c2f(c_new); } }
/* ChibiOS/RT - Copyright (C) 2014 Uladzimir Pylinsky aka barthess Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* * FSMC driver system settings. */ #define STM32_FSMC_USE_FSMC1 FALSE #define STM32_FSMC_FSMC1_IRQ_PRIORITY 10 /* * FSMC NAND driver system settings. */ #define STM32_NAND_USE_NAND1 FALSE #define STM32_NAND_USE_NAND2 FALSE #define STM32_NAND_USE_EXT_INT FALSE #define STM32_NAND_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) #define STM32_NAND_DMA_PRIORITY 0 #define STM32_NAND_DMA_ERROR_HOOK(nandp) osalSysHalt("DMA failure") /* * FSMC SRAM driver system settings. */ #define STM32_USE_FSMC_SRAM FALSE #define STM32_SRAM_USE_FSMC_SRAM1 FALSE #define STM32_SRAM_USE_FSMC_SRAM2 FALSE #define STM32_SRAM_USE_FSMC_SRAM3 FALSE #define STM32_SRAM_USE_FSMC_SRAM4 FALSE /* * FSMC SDRAM driver system settings. */ #define STM32_USE_FSMC_SDRAM FALSE #define STM32_SDRAM_USE_FSMC_SDRAM1 FALSE #define STM32_SDRAM_USE_FSMC_SDRAM2 TRUE /* * TIMCAP driver system settings. */ #define STM32_TIMCAP_USE_TIM1 TRUE #define STM32_TIMCAP_USE_TIM2 FALSE #define STM32_TIMCAP_USE_TIM3 TRUE #define STM32_TIMCAP_USE_TIM4 TRUE #define STM32_TIMCAP_USE_TIM5 TRUE #define STM32_TIMCAP_USE_TIM8 TRUE #define STM32_TIMCAP_USE_TIM9 TRUE #define STM32_TIMCAP_TIM1_IRQ_PRIORITY 3 #define STM32_TIMCAP_TIM2_IRQ_PRIORITY 3 #define STM32_TIMCAP_TIM3_IRQ_PRIORITY 3 #define STM32_TIMCAP_TIM4_IRQ_PRIORITY 3 #define STM32_TIMCAP_TIM5_IRQ_PRIORITY 3 #define STM32_TIMCAP_TIM8_IRQ_PRIORITY 3 #define STM32_TIMCAP_TIM9_IRQ_PRIORITY 3 /* * COMP driver system settings. */ #define STM32_COMP_USE_COMP1 TRUE #define STM32_COMP_USE_COMP2 TRUE #define STM32_COMP_USE_COMP3 FALSE #define STM32_COMP_USE_COMP4 FALSE #define STM32_COMP_USE_COMP5 FALSE #define STM32_COMP_USE_COMP6 FALSE #define STM32_COMP_USE_COMP7 FALSE #define STM32_COMP_USE_INTERRUPTS TRUE #define STM32_COMP_1_2_3_IRQ_PRIORITY 5 #if STM32_COMP_USE_INTERRUPTS #define STM32_DISABLE_EXTI21_22_29_HANDLER #define STM32_DISABLE_EXTI30_32_HANDLER #define STM32_DISABLE_EXTI33_HANDLER #endif /* * USBH driver system settings. */ #define STM32_OTG1_CHANNELS_NUMBER 8 #define STM32_OTG2_CHANNELS_NUMBER 12 #define STM32_USBH_USE_OTG1 1 #define STM32_OTG1_RXFIFO_SIZE 1024 #define STM32_OTG1_PTXFIFO_SIZE 128 #define STM32_OTG1_NPTXFIFO_SIZE 128 #define STM32_USBH_USE_OTG2 0 #define STM32_OTG2_RXFIFO_SIZE 2048 #define STM32_OTG2_PTXFIFO_SIZE 1024 #define STM32_OTG2_NPTXFIFO_SIZE 1024 #define STM32_USBH_MIN_QSPACE 4 #define STM32_USBH_CHANNELS_NP 4 /* * CRC driver system settings. */ #define STM32_CRC_USE_CRC1 TRUE #define STM32_CRC_CRC1_DMA_IRQ_PRIORITY 1 #define STM32_CRC_CRC1_DMA_PRIORITY 2 #define STM32_CRC_CRC1_DMA_STREAM STM32_DMA1_STREAM2 #define CRCSW_USE_CRC1 FALSE #define CRCSW_CRC32_TABLE TRUE #define CRCSW_CRC16_TABLE TRUE #define CRCSW_PROGRAMMABLE TRUE /* * EICU driver system settings. */ #define STM32_EICU_USE_TIM1 TRUE #define STM32_EICU_USE_TIM2 FALSE #define STM32_EICU_USE_TIM3 TRUE #define STM32_EICU_USE_TIM4 TRUE #define STM32_EICU_USE_TIM5 TRUE #define STM32_EICU_USE_TIM8 TRUE #define STM32_EICU_USE_TIM9 TRUE #define STM32_EICU_USE_TIM10 TRUE #define STM32_EICU_USE_TIM11 TRUE #define STM32_EICU_USE_TIM12 TRUE #define STM32_EICU_USE_TIM13 TRUE #define STM32_EICU_USE_TIM14 TRUE #define STM32_EICU_TIM1_IRQ_PRIORITY 7 #define STM32_EICU_TIM2_IRQ_PRIORITY 7 #define STM32_EICU_TIM3_IRQ_PRIORITY 7 #define STM32_EICU_TIM4_IRQ_PRIORITY 7 #define STM32_EICU_TIM5_IRQ_PRIORITY 7 #define STM32_EICU_TIM8_IRQ_PRIORITY 7 #define STM32_EICU_TIM9_IRQ_PRIORITY 7 #define STM32_EICU_TIM10_IRQ_PRIORITY 7 #define STM32_EICU_TIM11_IRQ_PRIORITY 7 #define STM32_EICU_TIM12_IRQ_PRIORITY 7 #define STM32_EICU_TIM13_IRQ_PRIORITY 7 #define STM32_EICU_TIM14_IRQ_PRIORITY 7 /* * QEI driver system settings. */ #define STM32_QEI_USE_TIM1 TRUE #define STM32_QEI_USE_TIM2 FALSE #define STM32_QEI_USE_TIM3 TRUE #define STM32_QEI_TIM1_IRQ_PRIORITY 3 #define STM32_QEI_TIM2_IRQ_PRIORITY 3 #define STM32_QEI_TIM3_IRQ_PRIORITY 3
/* * This file is part of Cleanflight. * * Cleanflight 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. * * Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>. */ #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include "platform.h" #include "build/build_config.h" #include "drivers/time.h" #include "drivers/system.h" #include "drivers/io.h" #include "hardware_revision.h" uint8_t hardwareRevision = AFF4_UNKNOWN; static IO_t HWDetectPin = IO_NONE; void detectHardwareRevision(void) { HWDetectPin = IOGetByTag(IO_TAG(HW_PIN)); IOInit(HWDetectPin, OWNER_SYSTEM, RESOURCE_INPUT, 0); IOConfigGPIO(HWDetectPin, IOCFG_IPU); delayMicroseconds(10); // allow configuration to settle // Check hardware revision if (IORead(HWDetectPin)) { hardwareRevision = AFF4_REV_1; } else { hardwareRevision = AFF4_REV_2; } } void updateHardwareRevision(void) { }
#include <stdlib.h> #include <errno.h> #include "malloc_impl.h" int posix_memalign(void **res, size_t align, size_t len) { if (align < sizeof(void *)) return EINVAL; void *mem = __memalign(align, len); if (!mem) return errno; *res = mem; return 0; }
/********************************************************************** ** smepowercad ** Copyright (C) 2015 Smart Micro Engineering GmbH ** 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/>. **********************************************************************/ #ifndef CAD_HEATCOOL_DIRTARRESTER_H #define CAD_HEATCOOL_DIRTARRESTER_H #include "caditem.h" #include "items/cad_basic_pipe.h" class CAD_HeatCool_DirtArrester : public CADitem { public: CAD_HeatCool_DirtArrester(); virtual ~CAD_HeatCool_DirtArrester(); virtual QList<CADitemTypes::ItemType> flangable_items(int flangeIndex); virtual QImage wizardImage(); virtual QString iconPath(); virtual QString domain(); virtual QString description(); virtual void calculate(); virtual void processWizardInput(); virtual QMatrix4x4 rotationOfFlange(quint8 num); // virtual void paint(GLWidget* glwidget); // QOpenGLBuffer arrayBufVertices; // QOpenGLBuffer indexBufFaces; // QOpenGLBuffer indexBufLines; qreal d, e, f, l, fe, ff, s, m; CAD_basic_pipe *pipe, *flange_left, *flange_right; CAD_basic_pipe *flap, *flap_outline; }; #endif // CAD_HEATCOOL_DIRTARRESTER_H
#include <stdio.h> #include "Set.h" #include "Object.h" #include "New.h" int main() { void *s1 = new(Set); void *s2 = new(Set); void *a = add(s1, new(Object)); void *a2 = add(s2, a); void *b = add(s2, new(Object)); void *c = new(Object); if (contains(s1, a) && contains(s1, b)) puts("ok"); if (contains(s1, c)) puts("contains?"); if (differ(a, add(s1, a))) puts("differ?"); if (contains(s1, drop(s1, a))) puts("drop?"); delete(drop(s1, b)); delete(drop(s1, c)); delete(drop(s2, a2)); return 0; }
/* Modify the temperature conversion program to print the table * in reverse order, that is, from 300 degrees to 0 */ #include <stdio.h> int main() { float fahr; float celsius; int lower; int upper; int step; lower = 0; upper = 300; step = 20; fahr = upper; printf("fahr celsius\n"); while(fahr >= lower){ celsius = (5.0/9.0) * (fahr - 32.0); printf("%3.0f %6.1f\n", fahr, celsius); fahr = fahr - step; } }
/* * rpf.c: Conversion of float to reduced precision format values * * Written by: Stefan Frank * Richard Krampfl * Ullrich Hafner * * This file is part of FIASCO («F»ractal «I»mage «A»nd «S»equence «CO»dec) * Copyright (C) 1994-2000 Ullrich Hafner <hafner@bigfoot.de> */ /* * $Date: 2000/06/14 20:49:37 $ * $Author: hafner $ * $Revision: 5.1 $ * $State: Exp $ */ #include "pm_config.h" #include "config.h" #include "mallocvar.h" #include "types.h" #include "macros.h" #include "error.h" #include "misc.h" #include "rpf.h" int const RPF_ZERO = -1; /***************************************************************************** private code *****************************************************************************/ typedef struct { double fraction; int exponent; } FracExp; static FracExp fracExpFromDouble(double const x) { FracExp retval; retval.fraction = frexp(x, &retval.exponent); return retval; } int rtob (real_t const f, const rpf_t * const rpfP) /* * Convert real number 'f' into fixed point format. * The real number in [-'range'; +'range'] is scaled to [-1 ; +1]. * Sign and the first 'precision' - 1 bits of the mantissa are * packed into one integer. * * Return value: * real value in reduced precision format */ { /* * Extract mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit) */ double const normalized = f / rpfP->range; /* 'f' scaled to [-1,+1] */ FracExp const fracExp = fracExpFromDouble(normalized); unsigned int const signedMantissa = (unsigned int) (fracExp.fraction * (1<<23)); unsigned int mantissa; unsigned int sign; /* 0 for positive; 1 for negative */ if (signedMantissa < 0) { mantissa = -signedMantissa; sign = 1; } else { mantissa = +signedMantissa; sign = 0; } /* * Generate reduced precision mantissa. */ if (fracExp.exponent > 0) mantissa <<= fracExp.exponent; else mantissa >>= -fracExp.exponent; mantissa >>= (23 - rpfP->mantissa_bits - 1); mantissa += 1; /* Round last bit. */ mantissa >>= 1; if (mantissa == 0) /* close to zero */ return RPF_ZERO; else if (mantissa >= (1U << rpfP->mantissa_bits)) /* overflow */ return sign; else return ((mantissa & ((1U << rpfP->mantissa_bits) - 1)) << 1) | sign; } float btor (int const binary, const rpf_t * const rpfP) /* * Convert value 'binary' in reduced precision format to a real value. * For more information refer to function rtob() above. * * Return value: * converted value */ { unsigned int mantissa; float sign; float f; if (binary == RPF_ZERO) return 0; if (binary < 0 || binary >= 1 << (rpfP->mantissa_bits + 1)) error ("Reduced precision format: value %d out of range.", binary); /* * Restore IEEE float format: * mantissa (23 Bits), exponent (8 Bits) and sign (1 Bit) */ sign = (binary & 0x1) == 0 ? 1.0 : -1.0; mantissa = (binary & ((0x1 << (rpfP->mantissa_bits + 1)) - 1)) >> 1; mantissa <<= (23 - rpfP->mantissa_bits); if (mantissa == 0) f = sign; else f = sign * (float) mantissa / 8388608; return f * rpfP->range; /* expand [ -1 ; +1 ] to [ -range ; +range ] */ } rpf_t * alloc_rpf (unsigned const mantissa, fiasco_rpf_range_e const range) /* * Reduced precision format constructor. * Allocate memory for the rpf_t structure. * Number of mantissa bits is given by `mantissa'. * The range of the real values is in the interval [-`range', +`range']. * In case of invalid parameters, a structure with default values is * returned. * * Return value * pointer to the new rpf structure */ { rpf_t * rpfP; MALLOCVAR(rpfP); if (mantissa < 2) { warning (_("Size of RPF mantissa has to be in the interval [2,8]. " "Using minimum value 2.\n")); rpfP->mantissa_bits = 2; } else if (mantissa > 8) { warning (_("Size of RPF mantissa has to be in the interval [2,8]. " "Using maximum value 8.\n")); rpfP->mantissa_bits = 2; } else rpfP->mantissa_bits = mantissa; switch (range) { case FIASCO_RPF_RANGE_0_75: rpfP->range = 0.75; rpfP->range_e = range; break; case FIASCO_RPF_RANGE_1_50: rpfP->range = 1.50; rpfP->range_e = range; break; case FIASCO_RPF_RANGE_2_00: rpfP->range = 2.00; rpfP->range_e = range; break; case FIASCO_RPF_RANGE_1_00: rpfP->range = 1.00; rpfP->range_e = range; break; default: warning (_("Invalid RPF range specified. Using default value 1.0.")); rpfP->range = 1.00; rpfP->range_e = FIASCO_RPF_RANGE_1_00; break; } return rpfP; }
/* * Strawberry Music Player * This file was part of Clementine. * Copyright 2010, David Sansome <me@davidsansome.com> * * Strawberry 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. * * Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef NETWORKPROXYSETTINGSPAGE_H #define NETWORKPROXYSETTINGSPAGE_H #include "config.h" #include <QObject> #include <QString> #include "settingspage.h" class SettingsDialog; class Ui_NetworkProxySettingsPage; class NetworkProxySettingsPage : public SettingsPage { Q_OBJECT public: explicit NetworkProxySettingsPage(SettingsDialog* dialog); ~NetworkProxySettingsPage() override; static const char *kSettingsGroup; void Load() override; void Save() override; private: Ui_NetworkProxySettingsPage* ui_; }; #endif // NETWORKPROXYSETTINGSPAGE_H
/* File: jagbytoploadfastindex.c Project: jaguar-bytecode Author: Douwe Vos Date: Nov 3, 2012 Web: http://www.natpad.net/ e-mail: dmvos2000(at)yahoo.com Copyright (C) 2012 Douwe Vos. 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 "jagbytoploadfastindex.h" #include "../jagbytimnemonic.h" #include <logging/catlogdefs.h> #define CAT_LOG_LEVEL CAT_LOG_WARN #define CAT_LOG_CLAZZ "JagBytOpLoadFastIndex" #include <logging/catlog.h> struct _JagBytOpLoadFastIndexPrivate { JagBytType value_type; int index; }; static void l_imnemonic_iface_init(JagBytIMnemonicInterface *iface); G_DEFINE_TYPE_WITH_CODE(JagBytOpLoadFastIndex, jag_byt_op_load_fast_index, JAG_BYT_TYPE_ABSTRACT_MNEMONIC, // @suppress("Unused static function") G_ADD_PRIVATE(JagBytOpLoadFastIndex) G_IMPLEMENT_INTERFACE(JAG_BYT_TYPE_IMNEMONIC, l_imnemonic_iface_init) ); static void l_dispose(GObject *object); static void l_finalize(GObject *object); static void jag_byt_op_load_fast_index_class_init(JagBytOpLoadFastIndexClass *clazz) { GObjectClass *object_class = G_OBJECT_CLASS(clazz); object_class->dispose = l_dispose; object_class->finalize = l_finalize; } static void jag_byt_op_load_fast_index_init(JagBytOpLoadFastIndex *instance) { } static void l_dispose(GObject *object) { cat_log_detail("dispose:%p", object); G_OBJECT_CLASS(jag_byt_op_load_fast_index_parent_class)->dispose(object); cat_log_detail("disposed:%p", object); } static void l_finalize(GObject *object) { cat_log_detail("finalize:%p", object); cat_ref_denounce(object); G_OBJECT_CLASS(jag_byt_op_load_fast_index_parent_class)->finalize(object); cat_log_detail("finalized:%p", object); } JagBytOpLoadFastIndex *jag_byt_op_load_fast_index_new(JagBytOperation operation, int offset, JagBytType value_type, int frame_index) { JagBytOpLoadFastIndex *result = g_object_new(JAG_BYT_TYPE_OP_LOAD_FAST_INDEX, NULL); cat_ref_anounce(result); JagBytOpLoadFastIndexPrivate *priv = jag_byt_op_load_fast_index_get_instance_private(result); jag_byt_abstract_mnemonic_construct((JagBytAbstractMnemonic *) result, operation, offset, 1); priv->value_type = value_type; priv->index = frame_index; return result; } int jag_byt_op_load_fast_index_get_frame_index(JagBytOpLoadFastIndex *load_fast_index) { JagBytOpLoadFastIndexPrivate *priv = jag_byt_op_load_fast_index_get_instance_private(load_fast_index); return priv->index; } /********************* start JagBytIMnemonic implementation *********************/ static CatStringWo *l_to_string(JagBytIMnemonic *self, JagBytLabelRepository *label_repository) { CatStringWo *result = cat_string_wo_new(); short op_code = jag_byt_imnemonic_get_opp_code(self); switch(op_code) { case OP_ILOAD_0 : cat_string_wo_append_chars(result, "iload_0"); break; case OP_ILOAD_1 : cat_string_wo_append_chars(result, "iload_1"); break; case OP_ILOAD_2 : cat_string_wo_append_chars(result, "iload_2"); break; case OP_ILOAD_3 : cat_string_wo_append_chars(result, "iload_3"); break; case OP_LLOAD_0 : cat_string_wo_append_chars(result, "lload_0"); break; case OP_LLOAD_1 : cat_string_wo_append_chars(result, "lload_1"); break; case OP_LLOAD_2 : cat_string_wo_append_chars(result, "lload_2"); break; case OP_LLOAD_3 : cat_string_wo_append_chars(result, "lload_3"); break; case OP_FLOAD_0 : cat_string_wo_append_chars(result, "fload_0"); break; case OP_FLOAD_1 : cat_string_wo_append_chars(result, "fload_1"); break; case OP_FLOAD_2 : cat_string_wo_append_chars(result, "fload_2"); break; case OP_FLOAD_3 : cat_string_wo_append_chars(result, "fload_3"); break; case OP_DLOAD_0 : cat_string_wo_append_chars(result, "dload_0"); break; case OP_DLOAD_1 : cat_string_wo_append_chars(result, "dload_1"); break; case OP_DLOAD_2 : cat_string_wo_append_chars(result, "dload_2"); break; case OP_DLOAD_3 : cat_string_wo_append_chars(result, "dload_3"); break; case OP_ALOAD_0 : cat_string_wo_append_chars(result, "aload_0"); break; case OP_ALOAD_1 : cat_string_wo_append_chars(result, "aload_1"); break; case OP_ALOAD_2 : cat_string_wo_append_chars(result, "aload_2"); break; case OP_ALOAD_3 : cat_string_wo_append_chars(result, "aload_3"); break; default : break; } return result; } static void l_imnemonic_iface_init(JagBytIMnemonicInterface *iface) { JagBytIMnemonicInterface *p_iface = g_type_interface_peek_parent(iface); iface->getBranchOffset = p_iface->getBranchOffset; iface->getContinuesOffset = p_iface->getContinuesOffset; iface->getLength = p_iface->getLength; iface->getOffset = p_iface->getOffset; iface->getOperation = p_iface->getOperation; iface->getOppCode = p_iface->getOppCode; iface->toString = l_to_string; } /********************* end JagBytIMnemonic implementation *********************/
#ifndef CODA_DB_SQL_COMMON_H #define CODA_DB_SQL_COMMON_H #include <iterator> #include <sstream> #include <string> #include <type_traits> #include <vector> #include "sql_types.h" namespace coda::db { class sql_time; class sql_value; // stream operators for different types std::ostream &operator<<(std::ostream &out, const sql_blob &value); std::wostream &operator<<(std::wostream &out, const sql_blob &value); std::ostream &operator<<(std::ostream &out, const sql_null_type &null); std::wostream &operator<<(std::wostream &out, const sql_null_type &null); // to string functions std::string to_string(const sql_blob &value); std::wstring to_wstring(const sql_blob &value); std::string to_string(const sql_null_type &value); std::wstring to_wstring(const sql_null_type &value); namespace helper { /*! * utility method used in creating sql */ template<typename T> std::string join_csv(const std::vector<T> &list) { std::ostringstream buf; if (list.size() > 0) { std::ostream_iterator<T> it(buf, ","); copy(list.begin(), list.end() - 1, it); buf << *(list.end() - 1); } return buf.str(); } // convert between different string types std::string convert_string(const std::wstring &buf); std::wstring convert_string(const std::string &buf); // test if a string value is a positive boolean value bool is_positive_bool(const sql_string &value); bool is_positive_bool(const sql_wstring &value); // test if a string value is a negative bool value bool is_negative_bool(const sql_string &value); bool is_negative_bool(const sql_wstring &value); /** * test if a string value is a positive or negative bool value * @returns 0 if not a boolean, -1 if false, 1 if true */ template<typename S, typename = std::enable_if<is_sql_string<S>::value>> int is_bool(const S &value) { if (is_positive_bool(value)) { return 1; } if (is_negative_bool(value)) { return -1; } return 0; } template<typename T> struct is_type { public: template<typename V> bool operator()(const V &value) const { return std::is_same<T, V>::value || std::is_convertible<V, T>::value; } }; struct number_equality { public: number_equality(const sql_number &num) : num_(num) {} template<typename V> bool operator()(const V &value) const { return num_ == value; } private: const sql_number &num_; }; struct value_equality { public: value_equality(const sql_value &value) : value_(value) {} template<typename V> bool operator()(const V &value) const { return value_ == value; } private: const sql_value &value_; }; class as_sql_string { public: template<typename V> sql_string operator()(const V &value) const { return std::to_string(value); } sql_string operator()(const sql_time &value) const; sql_string operator()(const sql_string &value) const; sql_string operator()(const sql_wstring &value) const; sql_string operator()(const sql_blob &value) const; sql_string operator()(const sql_null_type &null) const; sql_string operator()(const sql_number &value) const; }; class as_sql_wstring { public: template<typename V> sql_wstring operator()(const V &value) const { return std::to_wstring(value); } sql_wstring operator()(const sql_time &value) const; sql_wstring operator()(const sql_string &value) const; sql_wstring operator()(const sql_wstring &value) const; sql_wstring operator()(const sql_blob &value) const; sql_wstring operator()(const sql_null_type &null) const; sql_wstring operator()(const sql_number &value) const; }; } // namespace helper } // namespace coda::db #endif
/* * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004,2008 Free Software Foundation, Inc. * * GRUB 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. * * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>. */ #include <grub/misc.h> #include <grub/mm.h> #include <grub/normal.h> #include <grub/term.h> /* Borrowed from GRUB Legacy */ static char *color_list[16] = { "black", "blue", "green", "cyan", "red", "magenta", "brown", "light-gray", "dark-gray", "light-blue", "light-green", "light-cyan", "light-red", "light-magenta", "yellow", "white" }; static int parse_color_name (grub_uint8_t *ret, char *name) { grub_uint8_t i; for (i = 0; i < sizeof (color_list) / sizeof (*color_list); i++) if (! grub_strcmp (name, color_list[i])) { *ret = i; return 0; } return -1; } void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name) { grub_uint8_t fg, bg; char *fg_name, *bg_name; /* nothing specified by user */ if (name == NULL) return; fg_name = grub_strdup (name); if (fg_name == NULL) { /* "out of memory" message was printed by grub_strdup() */ grub_wait_after_message (); return; } bg_name = grub_strchr (fg_name, '/'); if (bg_name == NULL) { grub_printf ("Warning: syntax error (missing slash) in `%s'\n", fg_name); grub_wait_after_message (); goto free_and_return; } *(bg_name++) = '\0'; if (parse_color_name (&fg, fg_name) == -1) { grub_printf ("Warning: invalid foreground color `%s'\n", fg_name); grub_wait_after_message (); goto free_and_return; } if (parse_color_name (&bg, bg_name) == -1) { grub_printf ("Warning: invalid background color `%s'\n", bg_name); grub_wait_after_message (); goto free_and_return; } *ret = (bg << 4) | fg; free_and_return: grub_free (fg_name); } /* Replace default `normal' colors with the ones specified by user (if any). */ char * grub_env_write_color_normal (struct grub_env_var *var __attribute__ ((unused)), const char *val) { grub_uint8_t color_normal, color_highlight; /* Use old settings in case grub_parse_color_name_pair() has no effect. */ grub_getcolor (&color_normal, &color_highlight); grub_parse_color_name_pair (&color_normal, val); /* Reloads terminal `normal' and `highlight' colors. */ grub_setcolor (color_normal, color_highlight); /* Propagates `normal' color to terminal current color. */ grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); return grub_strdup (val); } /* Replace default `highlight' colors with the ones specified by user (if any). */ char * grub_env_write_color_highlight (struct grub_env_var *var __attribute__ ((unused)), const char *val) { grub_uint8_t color_normal, color_highlight; /* Use old settings in case grub_parse_color_name_pair() has no effect. */ grub_getcolor (&color_normal, &color_highlight); grub_parse_color_name_pair (&color_highlight, val); /* Reloads terminal `normal' and `highlight' colors. */ grub_setcolor (color_normal, color_highlight); /* Propagates `normal' color to terminal current color. Note: Using GRUB_TERM_COLOR_NORMAL here rather than GRUB_TERM_COLOR_HIGHLIGHT is intentional. We don't want to switch to highlight state just because color was reloaded. */ grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); return grub_strdup (val); }
/** * Copyright © 2016 Daniel Gutson, Aurelio Remonda, Leonardo Boquillón, * Francisco Herrero, Emanuel Bringas, Gustavo Ojeda, * Taller Technologies. * * @file backtraceCommand.h * @author Gustavo Ojeda * @date 2016-05-10 * @brief BacktraceCommand class declaration. * * This file is part of agdb * * agdb 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. * * agdb 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 agdb. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _COMMAND_BACKTRACE_H_ #define _COMMAND_BACKTRACE_H_ #include <string> #include "common/exceptions.h" #include "commands/ICommand.h" namespace NSCommands { /** * @brief This command shows the source code accordingly to the user input. * * @details Usage: * backtrace: [filename line numberOfLine] */ class BacktraceCommand : public ICommand { private: using LineIndex = unsigned; using Message = std::string; /** @brief Arguments index. */ enum ArgumentsIndex { ArgumentsNumber }; /** Implements ICommand interface. */ void execute(const Arguments& args, NSDebuggingContext::Context& ctx) override; }; } // namespace NSCommands #endif // _COMMAND_BACKTRACE_H_
#include <common.h> #include "psperror.h" #include "umd9660_driver.h" #include "csoread.h" SceUID umdfd; int umd_open; int umd_is_cso; char umdfilename[0x48]; void VshCtrlSetUmdFile(char *file) { SetUmdFile(file); strncpy(umdfilename, file, 0x47); sceIoClose(umdfd); umd_open = 0; umdfd = -1; } int IsofileReadSectors(int lba, int nsectors, void *buf) { int read = ReadUmdFileRetry(buf, SECTOR_SIZE * nsectors, lba * SECTOR_SIZE); if (read < 0) return read; return read / SECTOR_SIZE; } int OpenIso() { umd_open = 0; sceIoClose(umdfd); if ((umdfd = sceIoOpen(umdfilename, PSP_O_RDONLY | 0xF0000, 0)) < 0) { return -1; } umd_is_cso = 0; if (CisoOpen(umdfd) >= 0) umd_is_cso = 1; umd_open = 1; return 0; } int ReadUmdFileRetry(void *buf, int size, u32 offset) { int i; for (i = 0; i < 0x10; i++) { if (sceIoLseek32(umdfd, offset, PSP_SEEK_SET) >= 0) { for (i = 0; i < 0x10; i++) { int read = sceIoRead(umdfd, buf, size); if (read >= 0) return read; OpenIso(); } return 0x80010013; } OpenIso(); } return 0x80010013; } int Umd9660ReadSectors2(int lba, int nsectors, void *buf) { if (umd_open == 0) { int i; for (i = 0; i < 0x10; i++) { if (sceIoLseek32(umdfd, 0, PSP_SEEK_CUR) >= 0) { break; } OpenIso(); } if (umd_open == 0) { return 0x80010013; } } if (umd_is_cso == 0) { return IsofileReadSectors(lba, nsectors, buf); } else { return CisofileReadSectors(lba, nsectors, buf); } }
#ifndef PARALLELMERGESORT_H_ #define PARALLELMERGESORT_H_ #include <pthread.h> /** * This struct contains all necessary parameters to pass to * the mergesort method */ typedef struct { int* arr1; int* arr2; int first; int last; int h; } Parameters; /** * ParallelMergesor class sorts an array using a concrete number of threads */ class ParallelMergesort { private: static int numThreads; static pthread_mutex_t mutex; public: static void sort(int* arr, int last, int numThreads); private: static void merge(int* source, int* destination, int first, int last, int h); static void* mergesort(void* params); static bool reserveThread(); static void freeThread(); }; #endif /* PARALLELMERGESORT_H_ */
/* This file is part of wxCDDB. wxCDDB 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. wxCDDB 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 wxCDDB. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __CDDBLISTCTRL__ #define __CDDBLISTCTRL__ #include <wx/listctrl.h> #include <wx/imaglist.h> #include <string> #include "cddbchangerowdlg.h" class CddbListCtrl : public wxListCtrl { public: CddbListCtrl (wxWindow* parent, wxWindowID id); ~CddbListCtrl (); void AddRow (int track, std::string artist, std::string title); struct s_cd_row GetRow (int rownumber); void OnActivated (wxListEvent& event); void OnSelected (wxListEvent& event); void OnColumnSelected (wxListEvent& event); void SetImageListFolder (wxString folder); void AddImageListImage (wxString filename); private: wxListItem m_col_check; wxListItem m_col_track; wxListItem m_col_artist; wxListItem m_col_title; wxString m_iconpath; wxImageList *m_imagelist; }; #endif
#include <string.h> #include "ndf1_types.h" #include "ndf_ast.h" #include "sae_par.h" int ndf1Simlr( const char *str1, size_t start, size_t end, const char *str2, int n ){ /* *+ * Name: * ndf1Simlr * Purpose: * Case insensitive string comparison, permitting abbreviation. * Synopsis: * int ndf1Simlr( const char *str1, size_t start, size_t end, * const char *str2, int n ) * Description: * The function returns a logical result indicating whether two strings * are the same apart from case. In assessing this, the first string is * allowed to be an abbreviation of the second string, so long as it * contains a specified minimum number of characters. * Parameters: * str1 * Pointer to a null terminated string holding the first string, * which may be an abbreviation. * start * The zero-based index of the first character to consider in "str1". * The whole string is used if "start" > "end". * end * The zero-based index of the last character to consider in "str1". * The whole string is used if "start" > "end". * str2 * Pointer to a null terminated string holding the second string. * n * The minimum number of characters to which the first string may be * abbreviated (although a smaller number will be accepted if there * are actually fewer than "n" characters in "str2"). * Returned Value: * Whether the two strings match after allowing for case and * abbreviation of the first string to no less than N characters. * Copyright: * Copyright (C) 2018 East Asian Observatory * All rights reserved. * Licence: * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA * 02110-1301, USA * Authors: * RFWS: R.F. Warren-Smith (STARLINK) * DSB: David S. Berry (EAO) * History: * 3-APR-2019 (DSB): * Original version, based on equivalent Fortran function by RFWS. *- */ /* Local Variables: */ int result; /* Returned value */ size_t l1; /* No. characters to use from STR1 */ size_t l2; /* No. characters to use from STR2 */ int status; /* Local status value */ int *old_status; /* Original status pointer */ /* Tell AST to watch a local status variable so that any previous error does not cause AST calls to return without action. */ status = SAI__OK; old_status = astWatch( &status ); /* Initialise */ result = 0; /* Find the number of characters in "str1", ignoring trailing blanks, but using at least 1 character. */ l1 = astChrLen( str1 ); if( l1 < 1 ) l1 = 1; /* Find the start and end values to use. */ if( start > end ) { start = 0; end = l1 - 1; } else if( end >= l1 ) { end = l1 - 1; } /* Adjust the number of characters to use from str1 and check there is some text left. */ l1 = end - start + 1; if( l1 > 0 ) { /* Find the number of characters from "str2" to compare with "str1". This must include at least "n" characters (or more if present in "str1"), but cannot exceed the length of "str2". */ l2 = NDF_MIN( NDF_MAX( l1, n ), strlen( str2 ) ); /* Compare the selected parts of the two strings, ignoring case. */ if( l1 <= l2 ) result = astChrMatchN( str1 + start, str2, l1 ); } /* Re-instate the original AST status pointer. */ astWatch( old_status ); /* Return the result */ return result; }
/* * modelomatic.h * * Created on: May 3, 2012 * Author: Simon Whelan */ #ifndef MODELOMATIC_H_ #define MODELOMATIC_H_ #ifdef ISUNIX #include "optimise.h" #include "TreeList.h" #include "model.h" #include "interface.h" #else #include "../PhyloLib/optimise.h" #include "../PhyloLib/TreeList.h" #include "../PhyloLib/model.h" #include "../PhyloLib/interface.h" #endif enum Lcorrection { L_EQU, L_EMP, L_NA }; // Uses likelihood correction from equal unosbserved character frequencies; empirical unobserved character frequencies; not applicable (e.g. nucleotides and codons). struct SModelDetails { string Name; // Model name double OrilnL; // Unadjusted model likelihood double lnL; // Adjusted likelihood double TreeLength; // Tree length double NoPar; // Number of parameters double AIC; // Normalised AIC Lcorrection Correction; // Likelihood correction used EDataType DataType; // Data type }; SModelDetails DoModelRun(CBaseModel *M, int NoPar, Lcorrection, double Adj = 0.0); #define MATIC_BRANCH_ACC 0.01 // Accuracy to which branch lengths are estimated in DoItFast int GetRYModels(CData *Data, CTree *Tree, vector <SModelDetails> *Models, int GeneticCode, ostream &out = cout); int GetNTModels(CData *Data, CTree *Tree, vector <SModelDetails> *Models, int GeneticCode, ostream &out = cout); int GetAAModels(CData *Data, CTree *Tree, vector <SModelDetails> *Models, int GeneticCode, ostream &out = cout); int GetCODModels(CData *Data, CTree *Tree, vector <SModelDetails> *Models, int GeneticCode, ostream &out = cout); int GetFullCodonModels(CData *Data, CTree *Tree, vector <SModelDetails> *Models, int GeneticCode, ostream &out = cout); bool GetModels(string file = "modelomatic.ini"); double GetAIC(double lnL, int NoPar) { return 2*(NoPar-lnL); } #endif /* MODELOMATIC_H_ */
/* sys/log1p.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "config.h" #include <math.h> #include "gsl_gsl_sys.h" double gsl_log1p (const double x) { volatile double y, z; y = 1 + x; z = y - 1; return log(y) - (z-x)/y ; /* cancels errors with IEEE arithmetic */ }
/* * Generated by asn1c-0.9.28 (http://lionet.info/asn1c) * From ASN.1 module "PMCPDLCMessageSetVersion1" * found in "../../../dumpvdl2.asn1/atn-b1_cpdlc-v1.asn1" * `asn1c -fcompound-names -fincludes-quoted -gen-PER` */ #include "PositionLevelLevel.h" static asn_TYPE_member_t asn_MBR_PositionLevelLevel_1[] = { { ATF_NOFLAGS, 0, offsetof(struct PositionLevelLevel, position), -1 /* Ambiguous tag (CHOICE?) */, 0, &asn_DEF_Position, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "position" }, { ATF_NOFLAGS, 0, offsetof(struct PositionLevelLevel, levels), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_LevelLevel, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "levels" }, }; static const ber_tlv_tag_t asn_DEF_PositionLevelLevel_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_PositionLevelLevel_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, 0, 0 }, /* levels */ { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* fixName */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* navaid */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 0, 0, 0 }, /* airport */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 0, 0, 0 }, /* latitudeLongitude */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 0, 0, 0 } /* placeBearingDistance */ }; static asn_SEQUENCE_specifics_t asn_SPC_PositionLevelLevel_specs_1 = { sizeof(struct PositionLevelLevel), offsetof(struct PositionLevelLevel, _asn_ctx), asn_MAP_PositionLevelLevel_tag2el_1, 6, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_PositionLevelLevel = { "PositionLevelLevel", "PositionLevelLevel", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, SEQUENCE_decode_uper, SEQUENCE_encode_uper, 0, /* Use generic outmost tag fetcher */ asn_DEF_PositionLevelLevel_tags_1, sizeof(asn_DEF_PositionLevelLevel_tags_1) /sizeof(asn_DEF_PositionLevelLevel_tags_1[0]), /* 1 */ asn_DEF_PositionLevelLevel_tags_1, /* Same as above */ sizeof(asn_DEF_PositionLevelLevel_tags_1) /sizeof(asn_DEF_PositionLevelLevel_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_PositionLevelLevel_1, 2, /* Elements count */ &asn_SPC_PositionLevelLevel_specs_1 /* Additional specs */ };
/* * Copyright Droids Corporation, Microb Technology, Eirbot (2005), * Robotics Association of Coslada, Eurobotics Engineering (2010) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Copyright Droids-corporation - Olivier MATZ - 2009 * * Revision : $Id$ */ /* Robotics Association of Coslada, Eurobotics Engineering (2010) * Javier Baliñas Santos <javier@arc-robots.org> * * Code ported to families of microcontrollers dsPIC, with DAC module, * from pwm_ng.c made by Olivier MATZ. * */ #ifndef HOST_VERSION #include <stdio.h> #include <string.h> #include <aversive.h> #include <dac_mc.h> #if (defined _DAC1LIE) uint16_t dac1_data_channel[2]; #endif #if (defined _DAC1LIE) uint16_t dac2_data_channel[2]; #endif void dac_mc_channel_init(struct dac_mc *dac, uint8_t dac_module_num, uint8_t dac_channel, uint8_t dac_mode, volatile uint16_t *sign_port, uint8_t sign_bit, volatile uint16_t *sign_port_n, uint8_t sign_bit_n){ /* Save config in structure */ memset(dac, 0, sizeof(*dac)); dac->mode = dac_mode; dac->module_num = (dac_module_num-1); dac->channel = dac_channel; dac->sign_port = sign_port; dac->sign_port_n = sign_port_n; dac->sign_bit = sign_bit; dac->sign_bit_n = sign_bit_n; /* Configure hardware based on default values */ if(dac->module_num == 0){ // Disable module DAC1CONbits.DACEN = 0; DAC1CONbits.AMPON = 0; /* DAC Clock Divider * XXX Fs_dac > 10*Fs_control ? */ _APSTSCLR = 7; DAC1CONbits.DACFDIV = 6; // Fs_dac = 410us @ Fcy = 40MHz // Enable channel output and interrupt if(dac->channel == CHANNEL_L){ DAC1STATbits.LOEN = 1; DAC1STATbits.LITYPE = 1; _DAC1LIF = 0; _DAC1LIE = 1; } else{ // CHANNEL_R DAC1STATbits.ROEN = 1; DAC1STATbits.RITYPE = 1; _DAC1RIF = 0; _DAC1RIE = 1; } // Default DAC channels value DAC1DFLT = 0x0000; // Enable module DAC1CONbits.DACEN = 1; } #if (defined _DAC2LIE) else{ // Disable module DAC2CONbits.DACEN = 0; /* DAC Clock Divider * XXX Fs_dac > 10*Fs_control ? */ _APSTSCLR = 4; DAC2CONbits.DACFDIV = 0; // Fs_dac = 410us @ Fcy = 40MHz // Enable channel output and interrupt if(dac->channel == CHANNEL_L){ DAC2STATbits.LOEN = 1; DAC2STATbits.LITYPE = 1; _DAC2LIF = 0; _DAC2LIE = 1; } else{ // CHANNEL_R DAC2STATbits.ROEN = 1; DAC2STATbits.RITYPE = 1; _DAC2RIF = 0; _DAC2RIE = 1; } // Default DAC channels value DAC2DFLT = 0x0000; // Enable module DAC2CONbits.DACEN = 1; } #endif /* defined _DAC2LIE */ } #if (defined _DAC1LIE) void __attribute__((interrupt, no_auto_psv))_DAC1RInterrupt(void) { _DAC1RIF = 0; /* Clear Right Channel Interrupt Flag */ DAC1RDAT = dac1_data_channel[CHANNEL_R]; /* User Code to Write to FIFO Goes Here */ } void __attribute__((interrupt, no_auto_psv))_DAC1LInterrupt(void) { _DAC1LIF = 0; /* Clear Left Channel Interrupt Flag */ DAC1LDAT = dac1_data_channel[CHANNEL_L]; /* User Code to Write to FIFO Goes Here */ } #endif #if (defined _DAC2LIE) void __attribute__((interrupt, no_auto_psv))_DAC2RInterrupt(void) { _DAC2RIF = 0; /* Clear Right Channel Interrupt Flag */ DAC2RDAT = dac2_data_channel[CHANNEL_R]; /* User Code to Write to FIFO Goes Here */ } void __attribute__((interrupt, no_auto_psv))_DAC2LInterrupt(void) { _DAC2LIF = 0; /* Clear Left Channel Interrupt Flag */ DAC2LDAT = dac2_data_channel[CHANNEL_L]; /* User Code to Write to FIFO Goes Here */ } #endif static inline void dac_sign_set(struct dac_mc *dac) { if (dac->mode & DAC_MC_MODE_SIGN_INVERTED){ *dac->sign_port &= ~(1 << dac->sign_bit); *dac->sign_port_n |= (1 << dac->sign_bit_n); } else{ *dac->sign_port |= (1 << dac->sign_bit); *dac->sign_port_n &= ~(1 << dac->sign_bit_n); } } static inline void dac_sign_reset(struct dac_mc *dac) { if (dac->mode &DAC_MC_MODE_SIGN_INVERTED){ *dac->sign_port |= (1 << dac->sign_bit); *dac->sign_port_n &= ~(1 << dac->sign_bit_n); } else{ *dac->sign_port &= ~(1 << dac->sign_bit); *dac->sign_port_n |= (1 << dac->sign_bit_n); } } void dac_mc_set(void *data, int32_t value) { #define DAC_VALUE_MAX +65535 #define DAC_VALUE_MIN -65535 struct dac_mc *dac = data; MAX(value, DAC_VALUE_MAX); if (dac->mode & DAC_MC_MODE_SIGNED) { MIN(value, DAC_VALUE_MIN); if (value < 0) { dac_sign_set(dac); value = -value; } else { dac_sign_reset(dac); } if (dac->mode & DAC_MC_MODE_REVERSE) value = DAC_VALUE_MAX-value; } else { MIN(value, 0); if (dac->mode & DAC_MC_MODE_REVERSE) value = DAC_VALUE_MAX-value; } if (dac->module_num == 0) dac1_data_channel[dac->channel] = (uint16_t)value; else dac2_data_channel[dac->channel] = (uint16_t)value; } #endif
/* * LLIB lsh shell (based on osh-v6shell) * Expression expander * Copyright (C) 2013-2014 Nicolas Provost dev AT doronic DOT fr * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __LLIB_SH_EXPANDER_H #define __LLIB_SH_EXPANDER_H #include "llib_sh_def.h" #include "llib_sh_var.h" #include "llib_sh_err.h" /** flags to control expander processing. */ typedef enum { LLIB_SH_EXPAND_NONE = 0, /**< none */ LLIB_SH_EXPAND_GLOB = 1, /**< perform file globbing */ LLIB_SH_EXPAND_TILDE = 2, /**< do normal tilde expansion */ LLIB_SH_EXPAND_VARTILDE = 4, /**< expand tildes in an assignment */ LLIB_SH_EXPAND_REDIR = 8, /**< file glob for a redirection (1 match only) */ LLIB_SH_EXPAND_CASE = 0x10, /**< keeps quotes around for CASE pattern */ LLIB_SH_EXPAND_QPAT = 0x20, /**< pattern in quoted parameter expansion */ LLIB_SH_EXPAND_VARTILDE2 = 0x40, /**< expand tildes after colons only */ LLIB_SH_EXPAND_WORD = 0x80, /**< expand word in parameter expansion */ LLIB_SH_EXPAND_QUOTED = 0x100, /**< expand word in double quotes */ LLIB_SH_EXPAND_VAR = 0x200, /**< expand variables */ LLIB_SH_EXPAND_ESC = 0x400, /**< substitute escape sequences \... */ LLIB_SH_EXPAND_ARI = 0x800, /**< evaluate $((..)) arithmetic sequences */ LLIB_SH_EXPAND_EVAL = 0x1000, /**< evaluate $(..) subshell sequences */ LLIB_SH_EXPAND_SQUOT = 0x2000, /**< keep single quoted sequences unaltered */ LLIB_SH_EXPAND_SKDQUOT = 0x4000, /**< skip double quote on first and last char */ LLIB_SH_EXPAND_BRACE = 0x8000, /**< enable brace expansion */ LLIB_SH_EXPAND_SPLIT = 0x10000, /**< enable word splitting after expansions and before pathnames globbing */ LLIB_SH_EXPAND_GLOB_TRIM = 0x20000, /**< trim when globbing (for CD) */ LLIB_SH_EXPAND_FULL = 0xFFFF, /**< full expand */ } llib_sh_expander_flags_t; /** maximum length of arithmetic expression */ #define LLIB_SH_EXPANDER_MAX_ARITH WORDMAX /** maximum length of sub-expression $(...) */ #define LLIB_SH_EXPANDER_MAX_SUB WORDMAX /** expander state flags */ typedef enum { LLIB_SH_EXPAND_STATE_NONE=0, /**< no special state */ } llib_sh_expander_state_t; /** maximum count of expanded words, which is also * the maximum count of arguments for a command. */ #define LLIB_SH_EXPANDER_MAX_WORDS 512 /** flags for expanded word */ typedef enum { LLIB_SH_EXPANDER_WF_NONE=0, /**< none (free word) */ LLIB_SH_EXPANDER_WF_USED=1, /**< word is used */ } llib_sh_expander_word_flag_t; /** an expanded word */ typedef struct { char* s; /**< the word string (dynamically allocated) */ int next; /**< index of next word (-1 for none) */ luint32 flags; /**< flags for this word */ } llib_sh_expander_word_t; /** words storage (linked list) */ typedef struct { llib_size_t count; /**< actual count of words in storage */ int last; /**< last word filled (-1 for none) */ int first; /**< first node of chain */ llib_sh_expander_word_t word[LLIB_SH_EXPANDER_MAX_WORDS]; /**< the expanded words */ } llib_sh_expander_words_t; /** expander structure */ typedef struct llib_sh_expander_t { llib_sh_var_stack_t* vstack; /**< variables stack to use */ int debug_fd; /**< debugging file (if > 0) */ int level; /**< current level in variables stack */ luint32 flags; /**< configuration flags for expander */ llib_sh_word_t expr; /**< input expression or word */ llib_sh_word_t sub; /**< sub expression */ llib_sh_word_t out; /**< expanded word buffer */ llib_sh_err_t error; /**< last error */ llib_sh_expander_words_t words; /**< list of expanded words */ /* internal variables */ llib_size_t expr_len; /**< length of string in 'expr' */ char* seq_start; /**< start of current sequence */ char* current; /**< current char being processed in 'in' */ char* out_pos; /**< where to put next char in 'out' */ luint32 state; /**< current state */ llib_sh_var_content_t var; /**< variable content buffer */ llib_sh_word_t word; /**< a word buffer */ int last_word; /**< head of words list on expander_run enter (-1 for empty) */ } llib_sh_expander_t; void llib_sh_expander_free (llib_sh_expander_t* e); lbool llib_sh_expander_init (llib_sh_expander_t* e, llib_sh_var_stack_t*, int level, int debug_fd); lbool llib_sh_expander_run (llib_sh_expander_t* e, char* expr, luint32 flags); lbool llib_sh_expander_run_argv (llib_sh_expander_t* e, llib_sh_var_stack_t* vs, int level, char*** argv, int* argc, luint32 flags, int debug_fd); lbool llib_sh_expander_var_word (llib_sh_word_t win, llib_sh_word_t wout, llib_sh_var_stack_t* vs, int level, llib_sh_err_t* err); #endif
#include <linux/module.h> #include <linux/fs.h> #include <linux/cdev.h> #include <linux/device.h> MODULE_AUTHOR("Ryuichi Ueda"); MODULE_DESCRIPTION("driver for LED control"); MODULE_LICENSE("GPL"); MODULE_VERSION("0.1"); static dev_t dev; static struct cdev cdv; static struct class *cls = NULL; static spinlock_t spn_lock; static int access_num = 0; static ssize_t led_write(struct file* filp, const char* buf, size_t count, loff_t* pos) { printk(KERN_INFO "led_write is called\n"); return 1; } static int led_open(struct inode* inode, struct file* filp) { spin_lock(&spn_lock); if(access_num){ spin_unlock(&spn_lock); return -EBUSY; } access_num++; spin_unlock(&spn_lock); return 0; } static int led_release(struct inode* inode, struct file* filp) { spin_lock(&spn_lock); access_num--; spin_unlock(&spn_lock); return 0; } static struct file_operations led_fops = { owner : THIS_MODULE, write : led_write, open : led_open, release : led_release, }; static int __init init_mod(void) { int retval; retval = alloc_chrdev_region(&dev, 0, 1, "myled"); if(retval < 0){ printk(KERN_ERR "alloc_chrdev_region failed.\n"); return retval; } printk(KERN_INFO "%s is loaded. major:%d\n",__FILE__,MAJOR(dev)); cdev_init(&cdv, &led_fops); retval = cdev_add(&cdv, dev, 1); if(retval < 0){ printk(KERN_ERR "cdev_add failed. major:%d, minor:%d ",MAJOR(dev),MINOR(dev); return retval; } cls = class_create(THIS_MODULE,"myled"); if(IS_ERR(cls)){ printk(KERN_ERR "class_create failed."); return PTR_ERR(cls); } device_create(cls, NULL, dev, NULL, "myled%d",MINOR(dev)); return 0; } static void __exit cleanup_mod(void) { cdev_del(&cdv); device_destroy(cls, dev); class_destroy(cls); unregister_chrdev_region(dev, 1); printk(KERN_INFO "%s is unloaded. major:%d\n",__FILE__,MAJOR(dev)); } module_init(init_mod); module_exit(cleanup_mod);
#include <stdio.h> #include <stdlib.h> #include <unistd.h> void print_usage(void) { printf("Pad a file to an even number of bytes.\n"); printf("Output by default written to stdout.\n"); printf("pad [options] file\n"); printf("-f Force output (if no padding, normally writes nothing)\n"); printf("-n Do not output anything, print what would happen\n"); printf("-o FILE output to FILE\n"); printf("-p NUM pad to 2 4 8 16 bytes. Default 4 bytes.\n"); printf("-u [BYTE] pad using BYTE. If BYTE 0 or not given,\n"); printf(" then will repeat the last bytes of the \n"); printf(" in file. Pads with zeros by default. \n"); printf("-v Print some debugging info (verbose)\n"); } #define PADS 4 const int allowed_paddings[] = { 2, 4, 8, 16}; int check_pad(int pad_to) { int is_ok,i; is_ok = 0; for (i = 0; i < PADS; i++) { if (pad_to == allowed_paddings[i]) is_ok = 1; } return is_ok; } int main(int argc, char * argv[]) { int pad_to, q, len, padding, read, op, w, u, f; FILE * in; FILE * out; char * data; char* o; if (argc < 2) { print_usage(); return 0; } /* set the default options: */ pad_to = 4; q = 1; w = 1; f = 0; out = NULL; o = 0; u = -1; /* get the user options: */ while((op = getopt(argc, argv, "p:vno:u::f" )) != -1) { switch (op) { case 'f': f = 1; break; case 'n': w = 0; q = 0; break; case 'o': o = optarg; break; case 'p': pad_to = atoi(optarg); if (check_pad(pad_to) == 0) { printf("Not a valid padding value\n"); print_usage(); return 0; } break; case 'u': if (optarg) u = atoi(optarg); else u = 0; break; case 'v': q = 0; break; case '?': print_usage(); return 0; default: break; } } /* open the file */ in = fopen(argv[optind], "rb"); if (in == NULL) { printf("Could not open file %s\n", argv[optind]); return 1; } /* find the length */ fseek(in , 0,SEEK_END); len = ftell(in); if (len == 0) { printf("Empty file!\n"); return 2; } /* start of file again.. */ fseek(in , 0,SEEK_SET); /* see if we need to pad */ padding = ( (len & (pad_to-1)) ); if (padding) { padding = pad_to - padding; } if (!q) { printf("Padding %s to %d byte boundary\n", argv[optind], pad_to); } if (padding || f) { /* yes we do */ data = (char*) malloc(len); fread(data, 1, len , in); fclose(in); if (o != NULL) { out = fopen(o, "wb"); if (!out) { printf("Could not open %s \n", o); return 3; } } if (!q) { printf("Padding - in size %d out size %d (%d byte%sadded)\n", len, len + padding, padding, (padding<2)?" ":"s "); } if (w) { if (out == NULL) { read = 0; while (read < len) putchar(data[read++]); if (u != 0) { while (padding--) putchar((u==-1)?0:(u&0xff)); } else { /* write last bytes of file again */ while (padding--) putchar(data[len-padding-1]); } } else { /* write to file */ fwrite(data, 1, len, out); if (ferror(out)) { printf( "Error writing to %s \n", o); return 4; } if (u != 0) { while (padding--) fputc((u==-1)?0:(u&0xff), out); } else { /* write last bytes of file again */ while (padding--) fputc(data[len-padding-1], out); } fflush(out); fclose(out); } } } else { if (!q) { printf("No padding - "\ "in size %d out size %d\n", len, len + padding); } } return 0; }
#ifndef _GETTIMEOFDAY_H_ #define _GETTIMEOFDAY_H_ #include "stdafx.h" #include <winsock2.h> #include <ws2tcpip.h> #include <time.h> #include <windows.h> #include "config.h" const __int64 DELTA_EPOCH_IN_MICROSECS; /* IN UNIX the use of the timezone struct is obsolete; I don't know why you use it. See http://linux.about.com/od/commands/l/blcmdl2_gettime.htm But if you want to use this structure to know about GMT(UTC) diffrence from your local time it will be next: tz_minuteswest is the real diffrence in minutes from GMT(UTC) and a tz_dsttime is a flag indicates whether daylight is now in use */ struct timezone2 { __int32 tz_minuteswest; /* minutes W of Greenwich */ bool tz_dsttime; /* type of dst correction */ }; struct timeval2 { __int32 tv_sec; /* seconds */ __int32 tv_usec; /* microseconds */ }; int gettimeofday(struct timeval2 *tv/*in*/, struct timezone2 *tz/*in*/); #endif /* _GETTIMEOFDAY_H_ */
/* * Copyright (C) 2014 by Volodymyr Kachurovskyi <Volodymyr.Kachurovskyi@gmail.com> * * This file is part of Skwarka. * * Skwarka 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. * * Skwarka 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 Skwarka. If not, see <http://www.gnu.org/licenses/>. */ #ifndef HALF_FLOAT_H #define HALF_FLOAT_H // Disable compiler warning raised in the OpenEXR's code. #pragma warning( push ) #pragma warning( disable : 4231 ) #include "Half/half.h" #include "Half/halfLimits.h" #pragma warning( pop ) typedef half HalfFloat; #endif // HALF_FLOAT_H
#pragma once #ifndef __Gamemode_h__ #define __Gamemode_h__ class Gamemode { protected: int id = 0; char *name = "undefined"; int countdown = 0; public: Gamemode(); virtual ~Gamemode(); static void Select(int id); static void SelectionMenu(); static void updateDisplay(int gameModeShowing); virtual void Setup(); virtual void Loop(); void Init(); static const int GAMEMODES_MAX = 3; static const int GAMEMODE_DEFUSE = 1; static const int GAMEMODE_CODEDEFUSE = 2; static const int GAMEMODE_RUSH = 3; static char gameModes[2][14]; }; #endif
/* * This file is part of Bipscript. * * Bipscript 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. * * Bipscript 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 Bipscript. If not, see <http://www.gnu.org/licenses/>. */ #ifndef BINDTRANSPORT_H #define BINDTRANSPORT_H #include "squirrel.h" namespace bipscript { namespace transport { class TimePosition; class TimeSignature; } namespace binding { // object references to types in this package extern HSQOBJECT TransportExternalObject; extern HSQOBJECT TransportInternalObject; extern HSQOBJECT TransportMasterObject; extern HSQOBJECT TransportPositionObject; extern HSQOBJECT TransportTimeSignatureObject; SQInteger TransportPositionPush(HSQUIRRELVM vm, transport::TimePosition *); transport::TimePosition *getTransportPosition(HSQUIRRELVM &vm, int index); transport::TimeSignature *getTransportTimeSignature(HSQUIRRELVM &vm, int index); // release hooks for types in this package SQInteger TransportPositionRelease(SQUserPointer p, SQInteger size); SQInteger TransportTimeSignatureRelease(SQUserPointer p, SQInteger size); // method to bind this package void bindTransport(HSQUIRRELVM vm); }} #endif // BINDTRANSPORT_H
#ifndef _APP_ELF_TESTS_ #define _APP_ELF_TESTS_ #include "miosix/testsuite/elf_testsuite/aelf1.h" #include "miosix/testsuite/elf_testsuite/aelf2.h" #include "miosix/testsuite/elf_testsuite/aelf3.h" #include "miosix/testsuite/elf_testsuite/aelf4.h" #include "miosix/testsuite/elf_testsuite/aelf5.h" #include "miosix/testsuite/elf_testsuite/aelf6.h" #include "miosix/testsuite/elf_testsuite/aelf7.h" #endif //_APP_ELF_TESTS_
#pragma once #include "ComputationThread.h" template<class Algorithm> class DMRGThread : public ComputationThread { protected: int m_Sweeps; int m_Sites; virtual void Calculate(); public: Algorithm dmrg; DMRGThread(int sites, double Jz = 1., double Jxy = 1., int sweeps = 4, int states = 10, int nrExcitedStates = 0); virtual ~DMRGThread(); }; #ifndef _DMRGThread #include "DMRGThread.cpp" #endif
/* mcscoreboard-miner * Copyright (C) 2013 Toon Schoenmakers * * 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/>. */ #ifndef _FILE_PROCESSORS_H #define _FILE_PROCESSORS_H #include "config.h" void process_scoreboard_data(struct config* config); void process_player_data(struct config* config, char* player_file); void process_level_data(struct config* config); void process_stats(struct config* config, char* player_file); #endif //_FILE_PROCESSORS_H
#define MAC 1 #define WINDOWS 0 //#define PC 0 #define SGI 0 #define MOTIF 0 #define BEBOX 0 #define CARBON 1 #define TARGET_API_MAC_CARBON 1 #define TARGET_OS_MAC 1 #define OLDP2C 1 #define OPAQUE_TOOLBOX_STRUCTS 1 #define USENAVSERVICES 1
#ifndef _THREAD_H_ #define _THREAD_H_ class Thread { public: Thread() { } virtual ~Thread() { } virtual void main() { }; }; #endif
/***************************************************************************** * Copyright (C) 2004-2013 The PaGMO development team, * * Advanced Concepts Team (ACT), European Space Agency (ESA) * * http://apps.sourceforge.net/mediawiki/pagmo * * http://apps.sourceforge.net/mediawiki/pagmo/index.php?title=Developers * * http://apps.sourceforge.net/mediawiki/pagmo/index.php?title=Credits * * act@esa.int * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * *****************************************************************************/ #ifndef LUKSAN_VLCEK_2_H #define LUKSAN_VLCEK_2_H #include <string> #include <vector> #include "../config.h" #include "../serialization.h" #include "../types.h" #include "base.h" namespace pagmo { namespace problem { /// Test problem from the Luksan and Vlcek book. /** * Implementation of the Example 5.2 in "Sparse and Parially Separable * Test Problems for Unconstrained and Equality Constrained * Optimization" by Luksan and Vlcek. Code adapted from the Ipopt scalable problem examples * * @author Dario Izzo (dario.izzo@esa.int) */ class __PAGMO_VISIBLE luksan_vlcek_2: public base { public: luksan_vlcek_2(int = 16, const double & = 0, const double & = 0); base_ptr clone() const; std::string get_name() const; protected: void objfun_impl(fitness_vector &, const decision_vector &) const; void compute_constraints_impl(constraint_vector &, const decision_vector &) const; void set_sparsity(int &, std::vector<int> &, std::vector<int> &) const; private: friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int) { ar & boost::serialization::base_object<base>(*this); ar & m_clb; ar & m_cub; } std::vector<double> m_clb; std::vector<double> m_cub; }; }} //namespaces BOOST_CLASS_EXPORT_KEY(pagmo::problem::luksan_vlcek_2) #endif // LUKSAN_VLCEK_2_H
/* * vectorized FIR filter. Best used for cabinet+microphone emulation * * (c) 2013 Benedikt Hofmeister */ /* 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or point your web browser to http://www.gnu.org. */ #include "FIR.h" //include coefficient vectors #include "firs.h" #include <stdio.h> void instantiateFIR(FIR* pFIR, const uint uiSampleRate) { printf("FIR: instantiating FIR with %d samples / s\n", uiSampleRate); //check which base frequency to use float** ppfDataSource = NULL; uint nSourceRate = 0; uint* pnSourceBufferLengths = NULL; switch(uiSampleRate) { case 44100: case 22050: case 88200: ppfDataSource = g_aafFIRs44k1; nSourceRate = 44100; pnSourceBufferLengths = g_anSamples44k1; break; default: //case 48000: //case 96000: //case 192000: ppfDataSource = g_aafFIRs48k; nSourceRate = 48000; pnSourceBufferLengths = g_anSamples48k; break; } double fRateScaler = (float)nSourceRate / (double)uiSampleRate; printf("FIR: chosen rate %d, scaler %f\n", nSourceRate, fRateScaler); //reserve buffer uint uiModel = 0; for(; uiModel < NUM_MODELS; uiModel++) { uint nSourceSamples = pnSourceBufferLengths[uiModel]; uint n8Tuples = (uint)(fRateScaler * (float)nSourceSamples - 1.0f) / 8 + 1; pFIR->m_anHistory8Tuples[uiModel] = n8Tuples; uint nDestSamples = n8Tuples * 8; #ifdef _MSC_VER pFIR->m_apfHistory[uiModel] = (v8f_t*) _aligned_malloc(n8Tuples * sizeof(v8f_t), 16); #else posix_memalign((void**)&(pFIR->m_apfHistory[uiModel]), sizeof(v8f_t), n8Tuples * sizeof(v8f_t)); #endif #ifdef _MSC_VER pFIR->m_apfFIR[uiModel] = (v8f_t*) _aligned_malloc(nDestSamples * sizeof(v8f_t), 16); #else posix_memalign((void**)&(pFIR->m_apfFIR[uiModel]), sizeof(v8f_t), nDestSamples * sizeof(v8f_t)); #endif //fill fir coefficients //the fir is reversed here, so multiplication with history data can be carried out sequentially uint uiPermutation = 0; for(; uiPermutation < 8; uiPermutation++) { uint uiFIRSample = 0; while (uiFIRSample < nDestSamples) { float afCoeffs[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; const uint uiStartSample = uiFIRSample; for (; uiFIRSample < uiStartSample + 8 && uiFIRSample < nDestSamples; uiFIRSample++) { uint uiSourcePosUnscaled = (uiPermutation - uiFIRSample + nDestSamples) % nDestSamples; uint uiSourceBufferPos = (uint)((double)uiSourcePosUnscaled * fRateScaler); if(uiSourceBufferPos < nSourceSamples) afCoeffs[uiFIRSample & 0x7] = ppfDataSource[uiModel][uiSourceBufferPos]; } const uint uiDestIndex = uiPermutation * n8Tuples + (uiStartSample >> 3); pFIR->m_apfFIR [uiModel][uiDestIndex] = v8f_create(afCoeffs); } } } memset(pFIR->m_auiBufferPos, 0, NUM_MODELS * sizeof(uint)); } void fir(FIR* pFIR, float* pIn, float* pOut, const uint nSamples, const uint uiSampleRate, uint model, float gain) { uint uiSample = 0; for(; uiSample < nSamples; uiSample++) { //position of current sample in history buffer const uint uiPermutation = (pFIR->m_auiBufferPos[model])&0x7; //batch of current sample const uint uiBatchOffset = pFIR->m_auiBufferPos[model]>>3; uint uiModel = 0; for(; uiModel < NUM_MODELS; uiModel++) { //position of current sample in history buffer const uint uiModelPermutation = (pFIR->m_auiBufferPos[uiModel])&0x7; //batch of current sample const uint uiModelBatchOffset = pFIR->m_auiBufferPos[uiModel]>>3; //put current sample to buffer, apply gain float afBuffer[8]; v8f_get(afBuffer, &pFIR->m_apfHistory[uiModel][uiModelBatchOffset]); afBuffer[uiModelPermutation] = pIn[uiSample] * gain; pFIR->m_apfHistory[uiModel][uiModelBatchOffset] = v8f_create(afBuffer); if(++(pFIR->m_auiBufferPos[uiModel]) >= pFIR->m_anHistory8Tuples[uiModel] * 8) pFIR->m_auiBufferPos[uiModel] = 0; } //sub-sums of MAC operation v8f_t v8fSum = V8F_ZERO; //index to the block to use const uint uiPermutationOffset = pFIR->m_anHistory8Tuples[model] * uiPermutation; const uint FIR_SAMPLES_8 = pFIR->m_anHistory8Tuples[model]; //multiply-accumulate FIR samples with input buffer uint uiBatch = 0; for(; uiBatch < uiBatchOffset; uiBatch++) v8fSum += pFIR->m_apfHistory[model][uiBatch] * (pFIR->m_apfFIR[model][uiBatch + FIR_SAMPLES_8 - uiBatchOffset + uiPermutationOffset]); for(; uiBatch < FIR_SAMPLES_8; uiBatch++) v8fSum += pFIR->m_apfHistory[model][uiBatch] * (pFIR->m_apfFIR[model][uiBatch - uiBatchOffset + uiPermutationOffset]); //accumulate sub-sums float afResults[8]; v8f_get(afResults, &v8fSum); float fCollector = afResults[0]; uint uiComponent = 1; for(; uiComponent < 8; uiComponent++) fCollector += afResults[uiComponent]; //throw out a result pOut[uiSample] = CLAMP(fCollector, -1.0f, 1.0f); } }
/* ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "ch.h" #include "hal.h" static VirtualTimer vt1, vt2; static void restart(void *p) { (void)p; chSysLockFromIsr(); uartStartSendI(&UARTD1, 14, "Hello World!\r\n"); chSysUnlockFromIsr(); } static void ledoff(void *p) { (void)p; palClearPad(GPIOE, GPIOE_LED3_RED); } /* * This callback is invoked when a transmission buffer has been completely * read by the driver. */ static void txend1(UARTDriver *uartp) { (void)uartp; palSetPad(GPIOE, GPIOE_LED3_RED); } /* * This callback is invoked when a transmission has physically completed. */ static void txend2(UARTDriver *uartp) { (void)uartp; palClearPad(GPIOE, GPIOE_LED3_RED); chSysLockFromIsr(); if (chVTIsArmedI(&vt1)) chVTResetI(&vt1); chVTSetI(&vt1, MS2ST(5000), restart, NULL); chSysUnlockFromIsr(); } /* * This callback is invoked on a receive error, the errors mask is passed * as parameter. */ static void rxerr(UARTDriver *uartp, uartflags_t e) { (void)uartp; (void)e; } /* * This callback is invoked when a character is received but the application * was not ready to receive it, the character is passed as parameter. */ static void rxchar(UARTDriver *uartp, uint16_t c) { (void)uartp; (void)c; /* Flashing the LED each time a character is received.*/ palSetPad(GPIOE, GPIOE_LED3_RED); chSysLockFromIsr(); if (chVTIsArmedI(&vt2)) chVTResetI(&vt2); chVTSetI(&vt2, MS2ST(200), ledoff, NULL); chSysUnlockFromIsr(); } /* * This callback is invoked when a receive buffer has been completely written. */ static void rxend(UARTDriver *uartp) { (void)uartp; } /* * UART driver configuration structure. */ static UARTConfig uart_cfg_1 = { txend1, txend2, rxend, rxchar, rxerr, 38400, 0, USART_CR2_LINEN, 0 }; /* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1, PA9 and PA10 are routed to USART1. */ uartStart(&UARTD1, &uart_cfg_1); palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1)); /* USART1 TX. */ palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1)); /* USART1 RX. */ /* * Starts the transmission, it will be handled entirely in background. */ uartStartSend(&UARTD1, 13, "Starting...\r\n"); /* * Normal main() thread activity, in this demo it does nothing. */ while (TRUE) { chThdSleepMilliseconds(500); } }
/* t-encrypt.c - Regression tests for encrypt.c * Copyright (C) 2017 g10 Code GmbH * * This file is part of Payproc. * * Payproc 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. * * Payproc 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/>. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <stdlib.h> #include <string.h> #include <assert.h> #include "t-common.h" #include "encrypt.c" /* The module under test. */ static void test_encrypt_string (void) { gpg_error_t err; const char fortune[] = "Knowledge, sir, should be free to all!"; /* -- Harry Mudd, "I, Mudd", stardate 4513.3*/ char *ciphertext = NULL; char *plaintext = NULL; err = encrypt_string (&ciphertext, fortune, (ENCRYPT_TO_DATABASE | ENCRYPT_TO_BACKOFFICE)); if (err) { log_info ("test encryption failed: %s <%s>\n", gpg_strerror (err), gpg_strsource (err)); fail (0); goto leave; } if (verbose) log_info ("encrypted: '%s'\n", ciphertext); err = decrypt_string (&plaintext, ciphertext); if (err) { log_info ("test decryption failed: %s <%s>\n", gpg_strerror (err), gpg_strsource (err)); fail (0); goto leave; } if (verbose) log_info ("decrypted: '%s'\n", plaintext); if (strcmp (fortune, plaintext)) { log_info ("encryption/decryption mismatch\n"); fail (0); } leave: xfree (ciphertext); xfree (plaintext); } int main (int argc, char **argv) { if (argc > 1 && !strcmp (argv[1], "--verbose")) verbose = 1; if (!gpgme_check_version (NEED_GPGME_VERSION)) log_fatal ("%s is too old (need %s, have %s)\n", "gpgme", NEED_GPGME_VERSION, gpgme_check_version (NULL)); opt.database_key_fpr = "5B83120DB1E3A65AE5A8DCF6AA43F1DCC7FED1B7"; opt.backoffice_key_fpr = "B21DEAB4F875FB3DA42F1D1D139563682A020D0A"; encrypt_setup_keys (); if (verbose) encrypt_show_keys (); test_encrypt_string (); encrypt_release_keys (); return !!errorcount; }
#include "../../../../../src/datavisualization/utils/abstractobjecthelper_p.h"
/* File: odbc_xsb.h ** Author(s): Lily Dong ** Contact: xsb-contact@cs.sunysb.edu ** ** Copyright (C) The Research Foundation of SUNY, 1986, 1993-1998 ** ** XSB is free software; you can redistribute it and/or modify it under the ** terms of the GNU Library General Public License as published by the Free ** Software Foundation; either version 2 of the License, or (at your option) ** any later version. ** ** XSB 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 Library General Public License for ** more details. ** ** You should have received a copy of the GNU Library General Public License ** along with XSB; if not, write to the Free Software Foundation, ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** $Id: odbc_xsb.h,v 1.14 2012-12-08 18:21:36 dwarren Exp $ ** */ #ifndef __ODBC_XSB_H__ #define __ODBC_XSB_H__ #ifdef XSB_ODBC #include "odbc_def_xsb.h" //the function declarations are kept seperate from the constant and structure declarations //of ODBC_XSB since each function depends on CTXTdecl from context.h, but context.h depends on the //structure declarations of ODBC_XSB. extern void ODBCConnect(CTXTdecl); extern void ODBCDisconnect(CTXTdecl); extern void SetBindVarNum(CTXTdecl); extern void FindFreeCursor(CTXTdecl); extern void SetBindVal(CTXTdecl); extern void Parse(CTXTdecl); extern int GetColumn(CTXTdecl); extern void SetCursorClose(struct ODBC_Cursor *); extern void FetchNextRow(CTXTdecl); extern void ODBCCommit(CTXTdecl); extern void ODBCRollback(CTXTdecl); extern void ODBCColumns(CTXTdecl); extern void ODBCTables(CTXTdecl); extern void ODBCUserTables(CTXTdecl); extern void ODBCDescribeSelect(CTXTdecl); extern void ODBCConnectOption(CTXTdecl); extern void ODBCDataSources(CTXTdecl); extern void ODBCDrivers(CTXTdecl); extern void ODBCGetInfo(CTXTdecl); extern void ODBCRowCount(CTXTdecl); #endif /*XSB_ODBC defined*/ #endif /*this header included*/
/*============================================================================ * Licencia: * Autor: * Fecha: *===========================================================================*/ /*==================[inlcusiones]============================================*/ #include "sapi.h" // <= Biblioteca sAPI #include "os.h" // <= freeOSEK #include "common.h" /*==================[definiciones y macros]==================================*/ typedef enum { DOWN,RISING,UP,FALLING} STATES; // FSM debouncer uint32_t debouncerCounter = 0; typedef enum { WAITING_1, WAITING_2} DELTA_STATES; typedef struct { STATES state; uint8_t tec; uint32_t evt; uint32_t task; } TECS; /*==================[definiciones de datos internos]=========================*/ /*==================[definiciones de datos externos]=========================*/ /*==================[declaraciones de funciones internas]====================*/ void MonitorInit() { gpioConfig(LED1, GPIO_OUTPUT); } void TecInit() { gpioConfig(TEC1, GPIO_INPUT); gpioConfig(TEC2, GPIO_INPUT); } void UartMonitorInit() { uartConfig( UART_USB, 115200 ); uartWriteString( UART_USB, "ready osek ej20libs build 7\n"); } TASK (Alive) { gpioToggle(LEDR); TerminateTask(); } TASK (DeltaTime) { DELTA_STATES state = WAITING_1; uint32_t counter; uint32_t debouncerCounterCopy; EventMaskType events; while (1) { WaitEvent( EvtTec1 | EvtTec2 ); GetEvent(DeltaTime, &events); bool_t t1 = false; bool_t t2 = false; if ( events & EvtTec1) { ClearEvent(EvtTec1); t1 = true; } if ( events & EvtTec2) { ClearEvent(EvtTec2); t2 = true; } if (t1 || t2) { GetResource(CountLock); debouncerCounterCopy = debouncerCounter; ReleaseResource(CountLock); } switch (state) { case WAITING_1: if (t1) { counter = debouncerCounterCopy; state=WAITING_2; } else { } break; case WAITING_2: if (t2) { // will fail in day 25 * 40 because of the sign // will fail in day 50 * 50 because of the overflow int elapsed = (debouncerCounterCopy - counter ) * 40 ; // TODO: replace with proper call char buffer[32]; itoa(elapsed, buffer, 10); uartWriteString( UART_USB, "Elapsed time: "); uartWriteString( UART_USB, buffer); uartWriteString( UART_USB, " ms\n"); state = WAITING_1; } else { counter = debouncerCounterCopy; } break; default: break; } } } TASK (ReadTec) { static TECS tec[2] = { {UP,TEC1,EvtTec1,DeltaTime}, {UP,TEC2,EvtTec2,DeltaTime} }; GetResource(CountLock); ++debouncerCounter; ReleaseResource(CountLock); uint8_t idx; for (idx = 0; idx < 2; ++idx) { int pressed = ! gpioRead(tec[idx].tec); switch ( tec[idx].state ) { case DOWN: { if (pressed) { // keep DOWN } else { tec[idx].state = RISING; } break; } case RISING: { if (pressed) { // revert tec[idx].state = DOWN; } else { // change tec[idx].state = UP; // if (callbackUP()) callbackUP(idx); } break; } case UP: { if (pressed) { tec[idx].state = FALLING; } else { // keep UP } break; } case FALLING: { if (pressed ) { // change tec[idx].state = DOWN; SetEvent(tec[idx].task, tec[idx].evt); // if (callbackDOWN()) callbackDOWN(idx); } else { // revert tec[idx].state = UP; } break; } } } TerminateTask(); } /*==================[declaraciones de funciones externas]====================*/ /*==================[funcion principal]======================================*/ int main( void ) { StartOS(AppMode1); return 0; } void StartupHook(void) { boardConfig(); UartMonitorInit(); TecInit(); MonitorInit(); } void ErrorHook(void) { uartWriteString( UART_USB, "ShutdownOS\n"); ShutdownOS(0); } /*==================[definiciones de funciones internas]=====================*/ /*==================[definiciones de funciones externas]=====================*/ /*==================[end of file]============================================*/
/* Copyright (C) Cfengine AS This file is part of Cfengine 3 - written and maintained by Cfengine AS. 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; version 3. 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA To the extent this program is licensed as part of the Enterprise versions of Cfengine, the applicable Commerical Open Source License (COSL) may apply to this file if you as a licensee so wish it. See included file COSL.txt. */ #ifndef CFENGINE_SCOPE_H #define CFENGINE_SCOPE_H #include "cf3.defs.h" void SetScope(char *id); void SetNewScope(char *id); void NewScope(const char *name); void DeleteScope(char *name); Scope *GetScope(const char *scope); void CopyScope(const char *new_scopename, const char *old_scopename); void DeleteAllScope(void); void AugmentScope(char *scope, char *ns, Rlist *lvals, Rlist *rvals); void DeleteFromScope(char *scope, Rlist *args); void PushThisScope(void); void PopThisScope(void); void ShowScope(char *); void SplitScopeName(const char *scope_name, char namespace_out[CF_MAXVARSIZE], char bundle_out[CF_MAXVARSIZE]); void JoinScopeName(const char *ns, const char *bundle, char scope_out[CF_MAXVARSIZE]); #endif
/* * DML - Dependence Modeling Library * Copyright (C) 2011-2013 Yasser Gonzalez <contact@yassergonzalez.com> * * 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 "config.h" #include <glib.h> #include <gsl/gsl_vector.h> #include "src/dml.h" static void copula_pdf_indep(const dml_copula_t *copula, const gsl_vector *u, const gsl_vector *v, gsl_vector *pdf) { gsl_vector_set_all(pdf, 1); } static void copula_cdf_indep(const dml_copula_t *copula, const gsl_vector *u, const gsl_vector *v, gsl_vector *cdf) { gsl_vector_memcpy(cdf, u); gsl_vector_mul(cdf, v); } static void copula_h_indep(const dml_copula_t *copula, const gsl_vector *u, const gsl_vector *v, gsl_vector *h) { gsl_vector_memcpy(h, u); } static void copula_hinv_indep(const dml_copula_t *copula, const gsl_vector *u, const gsl_vector *v, gsl_vector *hinv) { gsl_vector_memcpy(hinv, u); } static void copula_aic_indep(const dml_copula_t *copula, const gsl_vector *u, const gsl_vector *v, double *aic) { *aic = 0; } dml_copula_t * dml_copula_alloc_indep() { dml_copula_t *copula; copula = g_malloc(sizeof(dml_copula_t)); copula->type = DML_COPULA_INDEP; copula->fit = NULL; // Disabled. copula->pdf = copula_pdf_indep; copula->cdf = copula_cdf_indep; copula->h = copula_h_indep; copula->hinv = copula_hinv_indep; copula->aic = copula_aic_indep; copula->free = NULL; // Disabled. copula->data = NULL; // Disabled. return copula; }
/* * Copyright (C) 1999, 2000, 2004 MIPS Technologies, Inc. * All rights reserved. * Authors: Carsten Langgaard <carstenl@mips.com> * Maciej W. Rozycki <macro@mips.com> * * Copyright (C) 2009 Lemote Inc. * Author: Wu Zhangjin <wuzhangjin@gmail.com> * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. */ #include <linux/types.h> #include <linux/pci.h> #include <linux/kernel.h> #include <linux/export.h> #include <loongson.h> #ifdef CONFIG_CS5536 #include <cs5536/cs5536_pci.h> #include <cs5536/cs5536.h> #endif #define PCI_ACCESS_READ 0 #define PCI_ACCESS_WRITE 1 #define CFG_SPACE_REG(offset) \ (void *)CKSEG1ADDR(LOONGSON_PCICFG_BASE | (offset)) #define ID_SEL_BEGIN 11 #define MAX_DEV_NUM (31 - ID_SEL_BEGIN) static int loongson_pcibios_config_access(unsigned char access_type, struct pci_bus *bus, unsigned int devfn, int where, u32 *data) { u32 busnum = bus->number; u32 addr, type; u32 dummy; void *addrp; int device = PCI_SLOT(devfn); int function = PCI_FUNC(devfn); int reg = where & ~3; if (busnum == 0) { /* board-specific part,currently,only fuloong2f,yeeloong2f * use CS5536, fuloong2e use via686b, gdium has no * south bridge */ #ifdef CONFIG_CS5536 /* cs5536_pci_conf_read4/write4() will call _rdmsr/_wrmsr() to * access the regsters PCI_MSR_ADDR, PCI_MSR_DATA_LO, * PCI_MSR_DATA_HI, which is bigger than PCI_MSR_CTRL, so, it * will not go this branch, but the others. so, no calling dead * loop here. */ if ((PCI_IDSEL_CS5536 == device) && (reg < PCI_MSR_CTRL)) { switch (access_type) { case PCI_ACCESS_READ: *data = cs5536_pci_conf_read4(function, reg); break; case PCI_ACCESS_WRITE: cs5536_pci_conf_write4(function, reg, *data); break; } return 0; } #endif /* Type 0 configuration for onboard PCI bus */ if (device > MAX_DEV_NUM) { return -1; } addr = (1 << (device + ID_SEL_BEGIN)) | (function << 8) | reg; type = 0; } else { /* Type 1 configuration for offboard PCI bus */ addr = (busnum << 16) | (device << 11) | (function << 8) | reg; type = 0x10000; } /* Clear aborts */ LOONGSON_PCICMD |= LOONGSON_PCICMD_MABORT_CLR | \ LOONGSON_PCICMD_MTABORT_CLR; LOONGSON_PCIMAP_CFG = (addr >> 16) | type; /* Flush Bonito register block */ dummy = LOONGSON_PCIMAP_CFG; mmiowb(); addrp = CFG_SPACE_REG(addr & 0xffff); if (access_type == PCI_ACCESS_WRITE) { writel(cpu_to_le32(*data), addrp); } else { *data = le32_to_cpu(readl(addrp)); } /* Detect Master/Target abort */ if (LOONGSON_PCICMD & (LOONGSON_PCICMD_MABORT_CLR | LOONGSON_PCICMD_MTABORT_CLR)) { /* Error occurred */ /* Clear bits */ LOONGSON_PCICMD |= (LOONGSON_PCICMD_MABORT_CLR | LOONGSON_PCICMD_MTABORT_CLR); return -1; } return 0; } /* * We can't address 8 and 16 bit words directly. Instead we have to * read/write a 32bit word and mask/modify the data we actually want. */ static int loongson_pcibios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { u32 data = 0; if ((size == 2) && (where & 1)) { return PCIBIOS_BAD_REGISTER_NUMBER; } else if ((size == 4) && (where & 3)) { return PCIBIOS_BAD_REGISTER_NUMBER; } if (loongson_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, where, &data)) { return -1; } if (size == 1) { *val = (data >> ((where & 3) << 3)) & 0xff; } else if (size == 2) { *val = (data >> ((where & 3) << 3)) & 0xffff; } else { *val = data; } return PCIBIOS_SUCCESSFUL; } static int loongson_pcibios_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { u32 data = 0; if ((size == 2) && (where & 1)) { return PCIBIOS_BAD_REGISTER_NUMBER; } else if ((size == 4) && (where & 3)) { return PCIBIOS_BAD_REGISTER_NUMBER; } if (size == 4) { data = val; } else { if (loongson_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, where, &data)) { return -1; } if (size == 1) data = (data & ~(0xff << ((where & 3) << 3))) | (val << ((where & 3) << 3)); else if (size == 2) data = (data & ~(0xffff << ((where & 3) << 3))) | (val << ((where & 3) << 3)); } if (loongson_pcibios_config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data)) { return -1; } return PCIBIOS_SUCCESSFUL; } struct pci_ops loongson_pci_ops = { .read = loongson_pcibios_read, .write = loongson_pcibios_write }; #ifdef CONFIG_CS5536 DEFINE_RAW_SPINLOCK(msr_lock); void _rdmsr(u32 msr, u32 *hi, u32 *lo) { struct pci_bus bus = { .number = PCI_BUS_CS5536 }; u32 devfn = PCI_DEVFN(PCI_IDSEL_CS5536, 0); unsigned long flags; raw_spin_lock_irqsave(&msr_lock, flags); loongson_pcibios_write(&bus, devfn, PCI_MSR_ADDR, 4, msr); loongson_pcibios_read(&bus, devfn, PCI_MSR_DATA_LO, 4, lo); loongson_pcibios_read(&bus, devfn, PCI_MSR_DATA_HI, 4, hi); raw_spin_unlock_irqrestore(&msr_lock, flags); } EXPORT_SYMBOL(_rdmsr); void _wrmsr(u32 msr, u32 hi, u32 lo) { struct pci_bus bus = { .number = PCI_BUS_CS5536 }; u32 devfn = PCI_DEVFN(PCI_IDSEL_CS5536, 0); unsigned long flags; raw_spin_lock_irqsave(&msr_lock, flags); loongson_pcibios_write(&bus, devfn, PCI_MSR_ADDR, 4, msr); loongson_pcibios_write(&bus, devfn, PCI_MSR_DATA_LO, 4, lo); loongson_pcibios_write(&bus, devfn, PCI_MSR_DATA_HI, 4, hi); raw_spin_unlock_irqrestore(&msr_lock, flags); } EXPORT_SYMBOL(_wrmsr); #endif
typedef struct NodArboreBinar { char info; NodArboreBinar *st,*dr; }NodArboreBinar; typedef struct nodst { NodArboreBinar *element; nodst *pred; }nodst; typedef struct nodq { NodArboreBinar *element; nodq *suc; }nodq; typedef struct stiva { nodst *top; }stiva; typedef struct coada { nodq *pr,*ul; }coada; stiva stivaVida(); void push(stiva *s, NodArboreBinar *x); NodArboreBinar *top(stiva s); void pop(stiva *s); coada coadaVida(); void insereaza(coada *C, NodArboreBinar *x); int esteVida(coada C); void citeste(coada C, NodArboreBinar *x); void elimina(coada *C); NodArboreBinar* construiesteArb(char a[], int n); void RSD(NodArboreBinar *radacina); void SRD(NodArboreBinar *radacina); void SDR(NodArboreBinar *radacina); void BFS(NodArboreBinar *radacina); //PROBLEMA 2 void oglindireArb(NodArboreBinar *radacina); int numarNoduriArb(char a[],int n); void afisareNiv(char a[],int n,int nivel); int nrNoduri_cu_un_singur_fiu(char a[],int n); void afisareKSRD(NodArboreBinar *radacina, int k);
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "rh4n.h" #include "rh4n_nat.h" int rh4nnatGetParameter(pnni_611_functions nnifuncs, void *parmhandle, RH4nProperties **props, char **formatstr, char *errorstr, bool checkformat) { struct parameter_description pdprop, pdformat; int nniret = 0; if((nniret = nnifuncs->pf_nni_get_parm_info(nnifuncs, RH4NNATPROPPOS, parmhandle, &pdprop)) != NNI_RC_OK) return(RH4N_RET_NNI_ERR); if(pdprop.format != NNI_TYPE_BIN || pdprop.dimensions != 0 || pdprop.length_all == 0) { printf("Bin parm missmatch\n"); return(RH4N_RET_PARM_MISSMATCH); } if((nniret = nnifuncs->pf_nni_get_parm(nnifuncs, RH4NNATPROPPOS, parmhandle, sizeof(RH4nProperties*), props)) != NNI_RC_OK) { printf("nniret: %d\n", nniret); return(RH4N_RET_NNI_ERR); } if(*props == NULL) return(RH4N_RET_PARM_MISSMATCH); if(!checkformat) return(RH4N_RET_OK); if((nniret = nnifuncs->pf_nni_get_parm_info(nnifuncs, RH4NNATFORMATPOS, parmhandle, &pdformat)) != NNI_RC_OK) return(RH4N_RET_NNI_ERR); if(pdformat.format != NNI_TYPE_ALPHA || pdformat.dimensions != 0 || pdformat.length_all == 0) { printf("Format A missmatch\n"); return(RH4N_RET_PARM_MISSMATCH); } if((*formatstr = malloc(sizeof(char)*(pdformat.length_all+1))) == NULL) return(RH4N_RET_MEMORY_ERR); memset(*formatstr, 0x00, sizeof(char)*(pdformat.length_all+1)); if((nniret = nnifuncs->pf_nni_get_parm(nnifuncs, RH4NNATFORMATPOS, parmhandle, pdformat.length_all, *formatstr)) != NNI_RC_OK) { free(*formatstr); return(RH4N_RET_NNI_ERR); } return(RH4N_RET_OK); } int rh4nnatParseFormatStr(char *formatstr, struct RH4nNatLDAInfos *pldainfos, RH4nProperties *props) { int i = 0; char *at_pos = NULL, *point_pos = NULL; for(; i < strlen(formatstr); i++) { if(formatstr[i] == '.' && at_pos == NULL) { //Found a point before a '@' char return(RH4N_RET_MALFORMED_FORMAT_STR); } else if(formatstr[i] == '.' && point_pos != NULL) { //Found second point return(RH4N_RET_MALFORMED_FORMAT_STR); } else if(formatstr[i] == '@' && at_pos != NULL) { //Found a second @ return(RH4N_RET_MALFORMED_FORMAT_STR); } else if(formatstr[i] == '.') { point_pos = &formatstr[i]; } else if(formatstr[i] == '@') { at_pos = &formatstr[i]; } } if(at_pos == NULL) { //Didn't found an '@' char return(RH4N_RET_MALFORMED_FORMAT_STR); } else if(at_pos == formatstr) { //struct name is empty return(RH4N_RET_MALFORMED_FORMAT_STR); } *at_pos = '\0'; if(strlen(formatstr) > NNI_LEN_NAME) { //struct name to long return(RH4N_RET_BUFFER_OVERFLOW); } strcpy(pldainfos->struct_name, formatstr); if(point_pos) { if(point_pos == at_pos+1) { //library entry is empty return(RH4N_RET_MALFORMED_FORMAT_STR); } *point_pos = '\0'; if(strlen(at_pos+1) > NNI_LEN_LIBRARY) { //lib name is to long return(RH4N_RET_BUFFER_OVERFLOW); } strcpy(pldainfos->library, at_pos+1); if(strlen(point_pos+1) == 0) { //LDA name is empty return(RH4N_RET_MALFORMED_FORMAT_STR); } else if(strlen(point_pos+1) > NNI_LEN_MEMBER) { //LDA name is to long return(RH4N_RET_BUFFER_OVERFLOW); } strcpy(pldainfos->ldaname, point_pos+1); } else { if(strlen(at_pos+1) == 0) { //LDA name is emptty return(RH4N_RET_MALFORMED_FORMAT_STR); } else if(strlen(at_pos+1) > NNI_LEN_MEMBER) { //LDA name is to long return(RH4N_RET_BUFFER_OVERFLOW); } strcpy(pldainfos->ldaname, at_pos+1); strcpy(pldainfos->library, props->natlibrary); } rh4n_log_debug(props->logging, "json-struct: [%s]", pldainfos->struct_name); rh4n_log_debug(props->logging, "lib: [%s]", pldainfos->library); rh4n_log_debug(props->logging, "lda: [%s]", pldainfos->ldaname); return(RH4N_RET_OK); } int parseVariableFormatStr(char *formatstr, RH4nProperties *props, char *groupname, char *varname) { char *pointpos = NULL; if((pointpos = strchr(formatstr, '.')) == NULL) { strcpy(varname, formatstr); *groupname = '\0'; } else { *pointpos = '\0'; strcpy(groupname, formatstr); strcpy(varname, pointpos+1); } rh4n_log_debug(props->logging, "Found group: [%s]", groupname); rh4n_log_debug(props->logging, "Found varname [%s]", varname); return(RH4N_RET_OK); }
/* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <boost/shared_ptr.hpp> #include <map> #include <string> #include <Swiften/Disco/CapsStorage.h> namespace Swift { class CapsMemoryStorage : public CapsStorage { public: CapsMemoryStorage() {} virtual DiscoInfo::ref getDiscoInfo(const std::string& hash) const { CapsMap::const_iterator i = caps.find(hash); if (i != caps.end()) { return i->second; } else { return DiscoInfo::ref(); } } virtual void setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo) { caps[hash] = discoInfo; } private: typedef std::map<std::string, DiscoInfo::ref> CapsMap; CapsMap caps; }; }
/* * Copyright (C) 2010, Broadcom Corporation * All Rights Reserved. * * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. * $Id: typedefs.h,v 1.103.12.5 2010-08-17 18:10:20 Exp $ */ #ifndef _TYPEDEFS_H_ #define _TYPEDEFS_H_ #ifdef __cplusplus #define TYPEDEF_BOOL #ifndef FALSE #define FALSE false #endif #ifndef TRUE #define TRUE true #endif #else #endif #if defined(__x86_64__) #define TYPEDEF_UINTPTR typedef unsigned long long int uintptr; #endif #if defined(TARGETOS_nucleus) #include <stddef.h> #define TYPEDEF_FLOAT_T #endif #if defined(__sparc__) #define TYPEDEF_ULONG #endif #if defined(LINUX_PORT) #define TYPEDEF_UINT #ifndef TARGETENV_android #define TYPEDEF_USHORT #define TYPEDEF_ULONG #endif #ifdef __KERNEL__ #include <linux/version.h> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) #define TYPEDEF_BOOL #endif #endif #endif #if defined(__GNUC__) && defined(__STRICT_ANSI__) #define TYPEDEF_INT64 #define TYPEDEF_UINT64 #endif #if !defined(__BOB__) && !defined(TARGETOS_nucleus) #if defined(__KERNEL__) #if defined(LINUX_PORT) #include <linux/types.h> #endif #else #include <sys/types.h> #endif #endif #define USE_TYPEDEF_DEFAULTS #ifdef USE_TYPEDEF_DEFAULTS #undef USE_TYPEDEF_DEFAULTS #ifndef TYPEDEF_BOOL typedef unsigned char bool; #endif #ifndef TYPEDEF_UCHAR typedef unsigned char uchar; #endif #ifndef TYPEDEF_USHORT typedef unsigned short ushort; #endif #ifndef TYPEDEF_UINT typedef unsigned int uint; #endif #ifndef TYPEDEF_ULONG typedef unsigned long ulong; #endif #ifndef TYPEDEF_UINT8 typedef unsigned char uint8; #endif #ifndef TYPEDEF_UINT16 typedef unsigned short uint16; #endif #ifndef TYPEDEF_UINT32 typedef unsigned int uint32; #endif #ifndef TYPEDEF_UINT64 typedef unsigned long long uint64; #endif #ifndef TYPEDEF_UINTPTR typedef unsigned int uintptr; #endif #ifndef TYPEDEF_INT8 typedef signed char int8; #endif #ifndef TYPEDEF_INT16 typedef signed short int16; #endif #ifndef TYPEDEF_INT32 typedef signed int int32; #endif #ifndef TYPEDEF_INT64 typedef signed long long int64; #endif #ifndef TYPEDEF_FLOAT32 typedef float float32; #endif #ifndef TYPEDEF_FLOAT64 typedef double float64; #endif #ifndef TYPEDEF_FLOAT_T #if defined(FLOAT32) typedef float32 float_t; #else typedef float64 float_t; #endif #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #ifndef NULL #define NULL 0 #endif #ifndef OFF #define OFF 0 #endif #ifndef ON #define ON 1 #endif #define AUTO (-1) #ifndef PTRSZ #define PTRSZ sizeof(char*) #endif #if defined(__GNUC__) #define BWL_COMPILER_GNU #elif defined(__CC_ARM) && __CC_ARM #define BWL_COMPILER_ARMCC #else #error "Unknown compiler!" #endif #ifndef INLINE #if defined(BWL_COMPILER_MICROSOFT) #define INLINE __inline #elif defined(BWL_COMPILER_GNU) #define INLINE __inline__ #elif defined(BWL_COMPILER_ARMCC) #define INLINE __inline #else #define INLINE #endif #endif #undef TYPEDEF_BOOL #undef TYPEDEF_UCHAR #undef TYPEDEF_USHORT #undef TYPEDEF_UINT #undef TYPEDEF_ULONG #undef TYPEDEF_UINT8 #undef TYPEDEF_UINT16 #undef TYPEDEF_UINT32 #undef TYPEDEF_UINT64 #undef TYPEDEF_UINTPTR #undef TYPEDEF_INT8 #undef TYPEDEF_INT16 #undef TYPEDEF_INT32 #undef TYPEDEF_INT64 #undef TYPEDEF_FLOAT32 #undef TYPEDEF_FLOAT64 #undef TYPEDEF_FLOAT_T #endif #define UNUSED_PARAMETER(x) (void)(x) #include <bcmdefs.h> #endif
// // // C++ Interface: Sonogram // // Description: // // // Author: Melchior FRANZ <mfranz@kde.org>, (C) 2004 // // Copyright: See COPYING file that comes with this distribution // // #ifndef SONOGRAM_H #define SONOGRAM_H #include "analyzerbase.h" /** @author Melchior FRANZ */ class Sonogram : public Analyzer::Base { Q_OBJECT public: Q_INVOKABLE Sonogram(QWidget*); ~Sonogram(); static const char* kName; protected: void analyze(QPainter& p, const Scope&, bool new_frame); void transform(Scope&); void demo(QPainter& p); void resizeEvent(QResizeEvent*); QPixmap canvas_; }; #endif
/* Test isatty() function. Copyright (C) 2011-2019 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 <https://www.gnu.org/licenses/>. */ #include <config.h> #include <unistd.h> #include "signature.h" SIGNATURE_CHECK (isatty, int, (int)); #include <errno.h> #include <fcntl.h> #include "macros.h" /* The name of the "always silent" device. */ #if defined _WIN32 && ! defined __CYGWIN__ /* Native Windows API. */ # define DEV_NULL "NUL" #else /* Unix API. */ # define DEV_NULL "/dev/null" #endif int main (void) { const char *file = "test-isatty.txt"; /* Test behaviour for invalid file descriptors. */ { errno = 0; ASSERT (isatty (-1) == 0); ASSERT (errno == EBADF || errno == 0 /* seen on IRIX 6.5, Solaris 10 */ ); } { close (99); errno = 0; ASSERT (isatty (99) == 0); ASSERT (errno == EBADF || errno == 0 /* seen on IRIX 6.5, Solaris 10 */ ); } /* Test behaviour for regular files. */ { int fd; fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644); ASSERT (0 <= fd); ASSERT (write (fd, "hello", 5) == 5); ASSERT (close (fd) == 0); fd = open (file, O_RDONLY); ASSERT (0 <= fd); ASSERT (! isatty (fd)); ASSERT (close (fd) == 0); } /* Test behaviour for pipes. */ { int fd[2]; ASSERT (pipe (fd) == 0); ASSERT (! isatty (fd[0])); ASSERT (! isatty (fd[1])); ASSERT (close (fd[0]) == 0); ASSERT (close (fd[1]) == 0); } /* Test behaviour for /dev/null. */ { int fd; fd = open (DEV_NULL, O_RDONLY); ASSERT (0 <= fd); ASSERT (! isatty (fd)); ASSERT (close (fd) == 0); } ASSERT (unlink (file) == 0); return 0; }
#pragma once enum COLORS { BLACK = 0, BLUE = 1, GREEN = 2, CYAN = 3, RED = 4, MAGENTA = 5, BROWN = 6, LIGHTGRAY = 7, DARKGRAY = 8, LIGHTBLUE = 9, LIGHTGREEN = 10, LIGHTCYAN = 11, LIGHTRED = 12, LIGHTMAGENTA = 13, YELLOW = 14, WHITE = 15, BLINK = 128 }; enum CURSORTYPE { _NOCURSOR,// turns off the cursor _SOLIDCURSOR,// solid block cursor _NORMALCURSOR // normal underscore cursor }; struct text_info { unsigned char attribute; /* text attribute */ unsigned char normattr; /* normal attribute */ int screenheight; /* text screen's height */ int screenwidth; /* text screen's width */ int curx; /* x-coordinate in current window */ int cury; /* y-coordinate in current window */ }; int c_getch(void); int c_getche(void); int c_kbhit(void); void c_clrscr(); void c_gotoxy(int x, int y); void c_setcursortype(int cur_t); void c_textbackground(int newcolor); void c_textcolor(int newcolor); int c_wherex(void); int c_wherey(void); void c_gettextinfo(struct text_info *r); void c_textattr(int newattr);
//////////////////////////////////////////////////////////////// #define ENABLE_INSTR_START_32b 1 #if ENABLE_INSTR_START_32b == 1 inline int instr_start(int a){ int res; __asm volatile( "start %1, %0 \n\t" : "=r" (res) : "r" (a) ); return res; } inline int prog_start(int a){ return a + 0; } #define start(a) instr_start(a) #endif
#include <sys/types.h> #include <sys/param.h> #include <sys/device.h> #include <sys/buf.h> #include <unistd.h> #include <sys/unistd.h> #include <pmon.h> #include <stdio.h> #include <file.h> #include "string.h" #include <sys/fcntl.h> #include "autoconf.h" #include "gzip.h" #if NGZIP > 0 #include <gzipfs.h> #endif /* NGZIP */ #include <pmon/dev/loopdev.h> static struct device *get_device(dev_t dev); int loopdevmatch( struct device *parent, void *match, void *aux); void loopdevattach(struct device *parent, struct device *self, void *aux); struct cfattach loopdev_ca = { sizeof(struct loopdev_softc), loopdevmatch, loopdevattach, }; struct cfdriver loopdev_cd = { NULL, "loopdev", DV_DISK }; void loopdevstrategy(struct buf *bp) { struct loopdev_softc *priv; unsigned int blkno, blkcnt; int ret ; priv=get_device(bp->b_dev); blkno = bp->b_blkno; blkno = blkno /(priv->bs/DEV_BSIZE); blkcnt = howmany(bp->b_bcount, priv->bs); /* Valid request? */ if (bp->b_blkno < 0 || (bp->b_bcount % priv->bs) != 0 || (bp->b_bcount / priv->bs) >= (1 << NBBY)) { bp->b_error = EINVAL; printf("Invalid request \n"); goto bad; } /* If it's a null transfer, return immediately. */ if (bp->b_bcount == 0) goto done; if(bp->b_flags & B_READ){ #if NGZIP > 0 if(priv->unzip){ gz_lseek(priv->fd,blkno*priv->bs,SEEK_SET); ret=gz_read(priv->fd,(unsigned long *)bp->b_data,bp->b_bcount); } else #endif { lseek(priv->fd,blkno*priv->bs,SEEK_SET); ret = read(priv->fd,(unsigned long *)bp->b_data,bp->b_bcount); } if(ret != bp->b_bcount) bp->b_flags |= B_ERROR; dotik(30000, 0); } else { lseek(priv->fd,blkno*priv->bs,SEEK_SET); ret = write(priv->fd,(unsigned long *)bp->b_data,bp->b_bcount); if(ret != bp->b_bcount) bp->b_flags |= B_ERROR; dotik(30000, 0); } done: biodone(bp); return; bad: bp->b_flags |= B_ERROR; biodone(bp); } static int losetup(int argc,char **argv) { int i; struct loopdev_softc *priv; int dev; if(argc<3)return -1; dev=find_device(&argv[1]); priv=get_device(dev); if(!priv)return -1; strncpy(priv->dev,argv[2],63); priv->bs=DEV_BSIZE; priv->seek=0; priv->count=-1; for(i=3;i<argc;i++) { if(!strncmp(argv[i],"bs=",3)) priv->bs=strtoul(&argv[i][3],0,0); else if(!strncmp(argv[i],"count=",6)) priv->count=strtoul(&argv[i][6],0,0); else if(!strncmp(argv[i],"seek=",5)) priv->seek=strtoul(&argv[i][5],0,0); else if(!strncmp(argv[i],"access=",7)) priv->access=strtoul(&argv[i][7],0,0); #if NGZIP > 0 else if(!strcmp(argv[i],"unzip=1")) priv->unzip=1; #endif } return 0; } int loopdevopen( dev_t dev, int flag, int fmt, struct proc *p) { char loopdevcmd[0x200]; char *loopdevenv; struct loopdev_softc *priv=get_device(dev); if(!priv)return -1; printf(" >>>> loopdevopen xname[%s]\n",priv->sc_dev.dv_xname); if((loopdevenv=getenv(priv->sc_dev.dv_xname))) { sprintf(loopdevcmd,"losetup %s %s",priv->sc_dev.dv_xname,loopdevenv); do_cmd(loopdevcmd); } priv->fd=open(priv->dev,priv->access); printf(" >>>> loopdevopen open[%s][%d]\n",priv->dev,priv->fd); if(priv->fd==-1)return -1; #if NGZIP > 0 printf(" >>>> loopdevopen gz-open[%d]\n",priv->unzip); if(priv->unzip&&(gz_open(priv->fd)==-1))priv->unzip=0; #endif lseek(priv->fd,priv->seek*priv->bs,SEEK_SET); return 0; } int loopdevread( dev_t dev, struct uio *uio, int flags) { return physio(loopdevstrategy, NULL, dev, B_READ, minphys, uio); } int loopdevwrite( dev_t dev, struct uio *uio, int flags) { return (physio(loopdevstrategy, NULL, dev, B_WRITE, minphys, uio)); } int loopdevclose( dev_t dev, int flag, int fmt, struct proc *p) { struct loopdev_softc *priv=get_device(dev); #if NGZIP > 0 if(priv->unzip)gz_close(priv->fd); #endif close(priv->fd); return 0; } int loopdevmatch(parent, match, aux) struct device *parent; void *match, *aux; { struct confargs *ca = aux; if (!strncmp(ca->ca_name, loopdev_cd.cd_name,7)) return 1; else return 0; } void loopdevattach(parent, self, aux) struct device *parent, *self; void *aux; { struct loopdev_softc *priv = (void *)self; strncpy(priv->dev,"/dev/mtd0",63); priv->bs=DEV_BSIZE; priv->seek=0; priv->count=-1; priv->access=O_RDWR; #if NGZIP > 0 priv->unzip=0; #endif } static const Cmd Cmds[] = { {"MyCmds"}, {"losetup", "loopdev0 devfile [bs=0x20000] [count=-1] [seek=0]", 0, "losetup",losetup, 0, 99, CMD_REPEAT}, {0, 0} }; static void init_cmd __P((void)) __attribute__ ((constructor)); static void init_cmd() { cmdlist_expand(Cmds, 1); }
/** ** When this module is loaded only secure connections are able to oper up. ** I know this doesn't prevent cleartext passwords from being sent when an ** oper not using SSL tries to oper up, but it ensures that private messages ** between opers are always encrypted. ** ** Change text in `#define NOSSL_ALLOWED ""' to any IP from which ** one may oper without using SSL. ** E. g. #define NOSSL_ALLOWED "10.10.0.4" ** ** Changelog: ** Version 0.1 ** Initial release ** Version 0.2 ** - Description fixed ** - Fixed Typo in year (MOD_HEADER, was 2004) ** - Added support for an ip (localhost?) from which one can oper without ** using SSL (useful for BOPM or such) ** Version 0.3 ** - Fixed a compiler warning about implicit function declaration (Thx to Bram) ** **/ #include "config.h" #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "msg.h" #include "proto.h" #include "channel.h" #include <time.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include "h.h" #ifdef STRIPBADWORDS #include "badwords.h" #endif #define NOSSL_ALLOWED "" ModuleInfo* modinfo_m_soper = NULL; Cmdoverride* cmd_soper = NULL; DLLFUNC int m_f_soper(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]); ModuleHeader MOD_HEADER(m_soper) = { "m_soper", /* Name of module */ "$Id: m_soper, v 0.3 2005/02/09 cloud", /* Version */ "m_soper - Restricts the use of /oper to secure connections", /* Short description of module */ "3.2-b8-1", NULL }; DLLFUNC int MOD_INIT(m_soper)(ModuleInfo *modinfo) { modinfo_m_soper = modinfo; return MOD_SUCCESS; } DLLFUNC int MOD_LOAD(m_soper)(int module_load) { cmd_soper = CmdoverrideAdd(modinfo_m_soper->handle, "oper", m_f_soper); if (NULL == cmd_soper) { return MOD_FAILED; } return MOD_SUCCESS; } DLLFUNC int MOD_UNLOAD(m_soper)(int module_unload) { CmdoverrideDel(cmd_soper); return MOD_SUCCESS; } DLLFUNC int m_f_soper(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]) { if (IsServer(sptr)) return 0; /* If NOSSL_ALLOWED is not empty and matches the IP of the connecting client let it oper. */ if ((NOSSL_ALLOWED[0] != '\0') && GetIP(sptr)) { if (!match(NOSSL_ALLOWED, GetIP(sptr))) { return CallCmdoverride(ovr, cptr, sptr, parc, parv); } } if (!(sptr->umodes & UMODE_SECURE)) { sendto_one(sptr, ":%s %s %s :*** The /oper command is restricted to secure connections.", me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name); return 0; } return CallCmdoverride(ovr, cptr, sptr, parc, parv); }
#include <stdio.h> #include <time.h> struct timespec tim; int main() { tim.tv_sec = 1; tim.tv_nsec = 500000000; nanosleep(&tim, NULL); return 0; }
/***************************************************************************** * Copyright 2015-2020 Alexander Barthel alex@littlenavmap.org * * 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/>. *****************************************************************************/ #ifndef ATOOLS_FS_DB_SCENERYAREAWRITER_H #define ATOOLS_FS_DB_SCENERYAREAWRITER_H #include "fs/db/writerbase.h" #include "fs/scenery/sceneryarea.h" namespace atools { namespace fs { namespace db { class SceneryAreaWriter : public atools::fs::db::WriterBase<atools::fs::scenery::SceneryArea> { public: SceneryAreaWriter(atools::sql::SqlDatabase& db, atools::fs::db::DataWriter& dataWriter) : WriterBase(db, dataWriter, "scenery_area") { } QString getCurrentSceneryLocalPath() const { return currentSceneryLocalPath; } const scenery::SceneryArea& getCurrentArea() const { return currentArea; } protected: virtual void writeObject(const atools::fs::scenery::SceneryArea *type) override; QString currentSceneryLocalPath; scenery::SceneryArea currentArea; }; } // namespace writer } // namespace fs } // namespace atools #endif // ATOOLS_FS_DB_SCENERYAREAWRITER_H
/* syssignal.h - System-dependent definitions for signals. Copyright (C) 1993, 1999, 2001-2013 Free Software Foundation, Inc. This file is part of GNU Emacs. GNU Emacs 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. GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <signal.h> #include <stdbool.h> extern void init_signals (bool); #ifdef HAVE_PTHREAD #include <pthread.h> /* If defined, asynchronous signals delivered to a non-main thread are forwarded to the main thread. */ #define FORWARD_SIGNAL_TO_MAIN_THREAD #endif #if defined HAVE_TIMER_SETTIME && defined SIGEV_SIGNAL # define HAVE_ITIMERSPEC #endif #if (defined SIGPROF && !defined PROFILING \ && (defined HAVE_SETITIMER || defined HAVE_ITIMERSPEC)) # define PROFILER_CPU_SUPPORT #endif extern sigset_t empty_mask; typedef void (*signal_handler_t) (int); extern void emacs_sigaction_init (struct sigaction *, signal_handler_t); char const *safe_strsignal (int) ATTRIBUTE_CONST; #if NSIG < NSIG_MINIMUM # undef NSIG # define NSIG NSIG_MINIMUM #endif #ifndef SA_SIGINFO # define SA_SIGINFO 0 #endif #ifndef emacs_raise # define emacs_raise(sig) raise (sig) #endif #ifndef HAVE_STRSIGNAL # define strsignal(sig) safe_strsignal (sig) #endif void deliver_process_signal (int, signal_handler_t);
// -------------------------------------------------------------------------------- // // Copyright (C) 2008-2022 J.Rios anonbeat@gmail.com // // 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, 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; see the file LICENSE. If not, write to // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, // Boston, MA 02110-1301 USA. // // http://www.gnu.org/copyleft/gpl.html // // -------------------------------------------------------------------------------- // #ifndef __CONFIRMEXIT_H__ #define __CONFIRMEXIT_H__ #include <wx/bitmap.h> #include <wx/image.h> #include <wx/icon.h> #include <wx/statbmp.h> #include <wx/gdicmn.h> #include <wx/font.h> #include <wx/colour.h> #include <wx/settings.h> #include <wx/string.h> #include <wx/stattext.h> #include <wx/sizer.h> #include <wx/checkbox.h> #include <wx/button.h> #include <wx/dialog.h> namespace Guayadeque { // -------------------------------------------------------------------------------- // class guExitConfirmDlg : public wxDialog { private: protected: wxCheckBox * m_AskAgainCheckBox; public: guExitConfirmDlg( wxWindow * parent ); // ~guExitConfirmDlg(); bool GetConfirmChecked( void ); }; } #endif // -------------------------------------------------------------------------------- //
/* * This file is part of Cleanflight. * * Cleanflight 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. * * Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>. */ #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include "platform.h" #ifdef SERIAL_RX #include "common/utils.h" #include "drivers/time.h" #include "io/serial.h" #ifdef TELEMETRY #include "telemetry/telemetry.h" #endif #include "rx/rx.h" #include "rx/sumd.h" // driver for SUMD receiver using UART2 // FIXME test support for more than 8 channels, should probably work up to 12 channels #define SUMD_SYNCBYTE 0xA8 #define SUMD_MAX_CHANNEL 16 #define SUMD_BUFFSIZE (SUMD_MAX_CHANNEL * 2 + 5) // 6 channels + 5 = 17 bytes for 6 channels #define SUMD_BAUDRATE 115200 static bool sumdFrameDone = false; static uint16_t sumdChannels[SUMD_MAX_CHANNEL]; static uint16_t crc; #define CRC_POLYNOME 0x1021 // CRC calculation, adds a 8 bit unsigned to 16 bit crc static void CRC16(uint8_t value) { uint8_t i; crc = crc ^ (int16_t)value << 8; for (i = 0; i < 8; i++) { if (crc & 0x8000) crc = (crc << 1) ^ CRC_POLYNOME; else crc = (crc << 1); } } static uint8_t sumd[SUMD_BUFFSIZE] = { 0, }; static uint8_t sumdChannelCount; // Receive ISR callback static void sumdDataReceive(uint16_t c) { uint32_t sumdTime; static uint32_t sumdTimeLast; static uint8_t sumdIndex; sumdTime = micros(); if ((sumdTime - sumdTimeLast) > 4000) sumdIndex = 0; sumdTimeLast = sumdTime; if (sumdIndex == 0) { if (c != SUMD_SYNCBYTE) return; else { sumdFrameDone = false; // lazy main loop didnt fetch the stuff crc = 0; } } if (sumdIndex == 2) sumdChannelCount = (uint8_t)c; if (sumdIndex < SUMD_BUFFSIZE) sumd[sumdIndex] = (uint8_t)c; sumdIndex++; if (sumdIndex < sumdChannelCount * 2 + 4) CRC16((uint8_t)c); else if (sumdIndex == sumdChannelCount * 2 + 5) { sumdIndex = 0; sumdFrameDone = true; } } #define SUMD_OFFSET_CHANNEL_1_HIGH 3 #define SUMD_OFFSET_CHANNEL_1_LOW 4 #define SUMD_BYTES_PER_CHANNEL 2 #define SUMD_FRAME_STATE_OK 0x01 #define SUMD_FRAME_STATE_FAILSAFE 0x81 static uint8_t sumdFrameStatus(void) { uint8_t channelIndex; uint8_t frameStatus = RX_FRAME_PENDING; if (!sumdFrameDone) { return frameStatus; } sumdFrameDone = false; // verify CRC if (crc != ((sumd[SUMD_BYTES_PER_CHANNEL * sumdChannelCount + SUMD_OFFSET_CHANNEL_1_HIGH] << 8) | (sumd[SUMD_BYTES_PER_CHANNEL * sumdChannelCount + SUMD_OFFSET_CHANNEL_1_LOW]))) return frameStatus; switch (sumd[1]) { case SUMD_FRAME_STATE_FAILSAFE: frameStatus = RX_FRAME_COMPLETE | RX_FRAME_FAILSAFE; break; case SUMD_FRAME_STATE_OK: frameStatus = RX_FRAME_COMPLETE; break; default: return frameStatus; } if (sumdChannelCount > SUMD_MAX_CHANNEL) sumdChannelCount = SUMD_MAX_CHANNEL; for (channelIndex = 0; channelIndex < sumdChannelCount; channelIndex++) { sumdChannels[channelIndex] = ( (sumd[SUMD_BYTES_PER_CHANNEL * channelIndex + SUMD_OFFSET_CHANNEL_1_HIGH] << 8) | sumd[SUMD_BYTES_PER_CHANNEL * channelIndex + SUMD_OFFSET_CHANNEL_1_LOW] ); } return frameStatus; } static uint16_t sumdReadRawRC(const rxRuntimeConfig_t *rxRuntimeConfig, uint8_t chan) { UNUSED(rxRuntimeConfig); return sumdChannels[chan] / 8; } bool sumdInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) { UNUSED(rxConfig); rxRuntimeConfig->channelCount = SUMD_MAX_CHANNEL; rxRuntimeConfig->rxRefreshRate = 11000; rxRuntimeConfig->rcReadRawFn = sumdReadRawRC; rxRuntimeConfig->rcFrameStatusFn = sumdFrameStatus; const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL); if (!portConfig) { return false; } #ifdef TELEMETRY bool portShared = telemetryCheckRxPortShared(portConfig); #else bool portShared = false; #endif serialPort_t *sumdPort = openSerialPort(portConfig->identifier, FUNCTION_RX_SERIAL, sumdDataReceive, SUMD_BAUDRATE, portShared ? MODE_RXTX : MODE_RX, SERIAL_NOT_INVERTED | (rxConfig->halfDuplex ? SERIAL_BIDIR : 0) ); #ifdef TELEMETRY if (portShared) { telemetrySharedPort = sumdPort; } #endif return sumdPort != NULL; } #endif
//============== IV:Multiplayer - https://github.com/Neproify/ivmultiplayer ============== // // File: CIVPhysical.h // Project: Client.Core // Author(s): jenksta // License: See LICENSE in root directory // //============================================================================== #pragma once #include "CIVDynamicEntity.h" #include "CIVWeaponInfo.h" class IVPhysical : public IVDynamicEntity { public: // 000-10C // 13C - In Water (BYTE)? PAD(IVPhysical, pad0, 0xD8); // 10C-1E4 // 0x1BC - IVEntity * m_pAttachedToEntity; // 0x140 - BYTE m_byteAttachedToEntity; // 0x150 - IVEntity * m_pCollidedEntity; // 0x1AA - BYTE m_byteHasDamageEntity; // 0x1C0 - CVector3 vecAttachedOffset; // 0x1D0 - Quaternion quatAttachedOffset; IVEntity * m_pLastDamageEntity; // 1E4-1E8 PAD(IVPhysical, pad1, 0x4); // 1E8-1EC eWeaponType m_lastDamageWeapon; // 1EC-1F0 // -1: None, eWeaponType: Weapon float m_fHealth; // 1F0-1F4 PAD(IVPhysical, pad3, 0x1C); // 1F4-210 virtual ~IVPhysical(); virtual void Function55(); virtual void Function56(); // seems get flag virtual void Function57(); // something with bound or so virtual void Function58(); // nullsub virtual CVector3* GetVelocity(CVector3*); virtual void SetHealth(float); virtual void SetHealth(float, int); virtual void AddHealth(float); virtual float GetHealth(); virtual void Function64(); // something with network object virtual void Function65(); // return 1; virtual void Function66(); // return 1; virtual CVector3* Function67(CVector3*); // sets something virtual void Function68(); // unregister reference virtual void Function69(); // physics calculation virtual void Function70(); virtual void Function71(); }; class CIVPhysical : public CIVDynamicEntity { public: CIVPhysical(); CIVPhysical(IVPhysical * pPhysical); ~CIVPhysical(); void SetPhysical(IVPhysical * pPhysical); IVPhysical * GetPhysical(); void SetMoveSpeed(const CVector3& vecMoveSpeed); void GetMoveSpeed(CVector3& vecMoveSpeed); void SetTurnSpeed(const CVector3& vecTurnSpeed); void GetTurnSpeed(CVector3& vecTurnSpeed); void SetLastDamageEntity(IVEntity * pLastDamageEntity); IVEntity * GetLastDamageEntity(); void SetHealth(float fHealth); float GetHealth(); };
/* This file is part of Darling. Copyright (C) 2019 Lubos Dolezel Darling 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. Darling 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 Darling. If not, see <http://www.gnu.org/licenses/>. */ #include <Foundation/Foundation.h> @interface MCPeerID : NSObject @end
#ifndef HELPER_H #define HELPER_H #include <string> void create_fonts(); void create_resources(); void create_sounds(); void create_sprites(); ///Convert an angle in degrees to radians double deg_to_rad(const double deg) noexcept; ///Convert an angle in radians to degrees double rad_to_deg(const double rad) noexcept; ///Extract the base of a filename: /// /home/richel/hello.txt -> hello.txt /// /etc/sudoers -> sudoers std::string extract_base(const std::string& s); #endif // HELPER_H