Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Remove duplicate comment from the c file
#include <math.h> #include "gauge.h" /** * Initializes the gauge struct * @arg gauge The gauge struct to initialize * @return 0 on success. */ int init_gauge(gauge_t *gauge) { gauge->count = 0; gauge->sum = 0; gauge->value = 0; return 0; } /** * Adds a new sample to the struct * @arg gauge The gauge to add to * @arg sample The new sample value * @arg delta Is this a delta update? * @return 0 on success. */ int gauge_add_sample(gauge_t *gauge, double sample, bool delta) { if (delta) { gauge->value += sample; } else { gauge->value = sample; } gauge->sum += sample; gauge->count++; return 0; } /** * Returns the number of samples in the gauge * @arg gauge The gauge to query * @return The number of samples */ uint64_t gauge_count(gauge_t *gauge) { return gauge->count; } /** * Returns the mean gauge value * @arg gauge The gauge to query * @return The mean value of the gauge */ double gauge_mean(gauge_t *gauge) { return (gauge->count) ? gauge->sum / gauge->count : 0; } /** * Returns the sum of the gauge * @arg gauge The gauge to query * @return The sum of values */ double gauge_sum(gauge_t *gauge) { return gauge->sum; } /** * Returns the gauge value (for backwards compat) * @arg gauge the gauge to query * @return The gauge value */ double gauge_value(gauge_t *gauge) { return gauge->value; }
#include <math.h> #include "gauge.h" int init_gauge(gauge_t *gauge) { gauge->count = 0; gauge->sum = 0; gauge->value = 0; return 0; } int gauge_add_sample(gauge_t *gauge, double sample, bool delta) { if (delta) { gauge->value += sample; } else { gauge->value = sample; } gauge->sum += sample; gauge->count++; return 0; } uint64_t gauge_count(gauge_t *gauge) { return gauge->count; } double gauge_mean(gauge_t *gauge) { return (gauge->count) ? gauge->sum / gauge->count : 0; } double gauge_sum(gauge_t *gauge) { return gauge->sum; } double gauge_value(gauge_t *gauge) { return gauge->value; }
Make portable unit tests default on all platforms. (vs CPPUNIT)
// // // Copyright (C) 2010 SIPfoundry Inc. // Licensed by SIPfoundry under the LGPL license. // // Copyright (C) 2010 SIPez LLC All rights reserved. // Licensed to SIPfoundry under a Contributor Agreement. // // $$ // Author: Daniel Petrie // dpetrie AT SIPez DOT com ////////////////////////////////////////////////////////////////////////////// #ifndef _sipxunittests_h_ #define _sipxunittests_h_ #if !defined(NO_CPPUNIT) && defined(ANDROID) #define NO_CPPUNIT 1 #endif #if defined(NO_CPPUNIT) #define SIPX_UNIT_BASE_CLASS SipxPortUnitTestClass #include <os/OsIntTypes.h> #include <sipxportunit/SipxPortUnitTest.h> #include <utl/UtlString.h> typedef UtlString string; #else #define SIPX_UNIT_BASE_CLASS CppUnit::TestCase #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> using namespace std; #endif #endif
// // // Copyright (C) 2010-2016 SIPez LLC. All rights reserved. // // $$ // Author: Daniel Petrie // dpetrie AT SIPez DOT com ////////////////////////////////////////////////////////////////////////////// #ifndef _sipxunittests_h_ #define _sipxunittests_h_ //#if !defined(NO_CPPUNIT) && defined(ANDROID) #define NO_CPPUNIT 1 //#endif #if defined(NO_CPPUNIT) #define SIPX_UNIT_BASE_CLASS SipxPortUnitTestClass #include <os/OsIntTypes.h> #include <sipxportunit/SipxPortUnitTest.h> #include <utl/UtlString.h> typedef UtlString string; #else #define SIPX_UNIT_BASE_CLASS CppUnit::TestCase #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> using namespace std; #endif #endif
Replace getcpy() with mh_xstrdup() where the string isn't NULL.
/* * getarguments.c -- Get the argument vector ready to go. * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. */ #include <h/mh.h> #include <h/utils.h> char ** getarguments (char *invo_name, int argc, char **argv, int check_context) { char *cp = NULL, **ap = NULL, **bp = NULL, **arguments = NULL; int n = 0; /* * Check if profile/context specifies any arguments */ if (check_context && (cp = context_find (invo_name))) { cp = getcpy (cp); /* make copy */ ap = brkstring (cp, " ", "\n"); /* split string */ /* Count number of arguments split */ bp = ap; while (*bp++) n++; } arguments = (char **) mh_xmalloc ((argc + n) * sizeof(*arguments)); bp = arguments; /* Copy any arguments from profile/context */ if (ap != NULL && n > 0) { while (*ap) *bp++ = *ap++; } /* Copy arguments from command line */ argv++; while (*argv) *bp++ = *argv++; /* Now NULL terminate the array */ *bp = NULL; return arguments; }
/* * getarguments.c -- Get the argument vector ready to go. * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. */ #include <h/mh.h> #include <h/utils.h> char ** getarguments (char *invo_name, int argc, char **argv, int check_context) { char *cp = NULL, **ap = NULL, **bp = NULL, **arguments = NULL; int n = 0; /* * Check if profile/context specifies any arguments */ if (check_context && (cp = context_find (invo_name))) { cp = mh_xstrdup(cp); /* make copy */ ap = brkstring (cp, " ", "\n"); /* split string */ /* Count number of arguments split */ bp = ap; while (*bp++) n++; } arguments = (char **) mh_xmalloc ((argc + n) * sizeof(*arguments)); bp = arguments; /* Copy any arguments from profile/context */ if (ap != NULL && n > 0) { while (*ap) *bp++ = *ap++; } /* Copy arguments from command line */ argv++; while (*argv) *bp++ = *argv++; /* Now NULL terminate the array */ *bp = NULL; return arguments; }
Add the reading and printing of the matrix.
/* Student: Szogyenyi Zoltan Anul: I Materie: Stagiu de Practica Limbaj de programare: C Data: Martie 21 2015 - Sambata 2. Se citesc de la tastatură elementele unei matrici de caractere (nr. linii=nr. coloane), A(NxN), N<=10. a) Să se afişeze matricea A; b) Să se formeze şi să se afişeze cuvântul format din caracterele pe pe diagonala principală a matricii A; c) Să se calculeze şi să se afişeze numărul de litere mari, litere mici şi cifre din matrice; d) Să se afişeze cuvântul format din caracterele de pe diagonala secundară; e) Să se afişeze procentul literelor mari, al literelor mici şi al cifrelor de pe cele 2 diagonale; f) Să se afişeze caracterele comune aflate pe liniile p şi q (p, q < N, p şi q citite de la tastatură); g) Să se afişeze in ordine alfabetică, crescătoare, literele mari aflate pe coloanele impare */ #include <stdio.h> void printMatrix(int matrix[10][10], int); int main() { int a[10][10]; int n; // Se citesc de la tastatură elementele unei matrici de caractere (nr. linii=nr.coloane), A(NxN), N<=10. printf("The size of the matrix: "); scanf("%d", &n); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { printf("a[%d][%d]= ", i, j); scanf("%d", &a[i][j]); } } // a) Să se afişeze matricea A; printMatrix(a, n); return 0; } void printMatrix(int matrix[10][10], int n) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { printf("%d ", matrix[i][j]); } printf("\n"); } }
Update the driver version to 8.04.00.13-k.
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2013 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.04.00.08-k" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 4 #define QLA_DRIVER_PATCH_VER 0 #define QLA_DRIVER_BETA_VER 0
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2013 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.04.00.13-k" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 4 #define QLA_DRIVER_PATCH_VER 0 #define QLA_DRIVER_BETA_VER 0
Update driver version to 5.03.00-k7
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2012 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.03.00-k6"
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2012 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.03.00-k7"
Change property attribute to strong
// // BNCDeviceInfo.h // Branch-TestBed // // Created by Sojan P.R. on 3/22/16. // Copyright © 2016 Branch Metrics. All rights reserved. // #import <Foundation/Foundation.h> #ifndef BNCDeviceInfo_h #define BNCDeviceInfo_h #endif /* BNCDeviceInfo_h */ @interface BNCDeviceInfo : NSObject //---------Properties-------------// @property (nonatomic, strong) NSString *hardwareId; @property (nonatomic, strong) NSString *hardwareIdType; @property (nonatomic) BOOL isRealHardwareId; @property (nonatomic, strong) NSString *vendorId; @property (nonatomic, strong) NSString *brandName; @property (nonatomic, strong) NSString *modelName; @property (nonatomic, strong) NSString *osName; @property (nonatomic, strong) NSString *osVersion; @property (nonatomic) NSNumber *screenWidth; @property (nonatomic) NSNumber *screenHeight; @property (nonatomic) BOOL isAdTrackingEnabled; //----------Methods----------------// + (BNCDeviceInfo *)getInstance; @end
// // BNCDeviceInfo.h // Branch-TestBed // // Created by Sojan P.R. on 3/22/16. // Copyright © 2016 Branch Metrics. All rights reserved. // #import <Foundation/Foundation.h> #ifndef BNCDeviceInfo_h #define BNCDeviceInfo_h #endif /* BNCDeviceInfo_h */ @interface BNCDeviceInfo : NSObject //---------Properties-------------// @property (nonatomic, strong) NSString *hardwareId; @property (nonatomic, strong) NSString *hardwareIdType; @property (nonatomic) BOOL isRealHardwareId; @property (nonatomic, strong) NSString *vendorId; @property (nonatomic, strong) NSString *brandName; @property (nonatomic, strong) NSString *modelName; @property (nonatomic, strong) NSString *osName; @property (nonatomic, strong) NSString *osVersion; @property (nonatomic, strong) NSNumber *screenWidth; @property (nonatomic, strong) NSNumber *screenHeight; @property (nonatomic) BOOL isAdTrackingEnabled; //----------Methods----------------// + (BNCDeviceInfo *)getInstance; @end
Switch hash map class to a flat hash map
#ifndef JTL_HASH_MAP_H__ #define JTL_HASH_MAP_H__ #include <memory> namespace jtl { template <typename Key, typename Value> class HashMap { struct MapNode { MapNode(Key k, Value v) : key(k), value(v) {} ~MapNode() { delete key; delete value; } Key key; Value value; }; // struct MapNode class HashMapBase_ { private: // bins is an array of pointers to arrays of key-value nodes MapNode** bins_; }; // class HashMapBase_ public: private: Key* bins_; }; // class HashMap } // namespace jtl #endif
#ifndef JTL_FLAT_HASH_MAP_H__ #define JTL_FLAT_HASH_MAP_H__ #include <memory> #include <cctype> namespace jtl { template <typename Key> struct Hash { using argument_type = Key; using result_type = std::size_t; result_type operator()(const Key& k); }; // struct Hash template <typename Key, typename Value> class FlatHashMap { public: FlatHashMap() : bins_(), hash_() {} struct MapNode { MapNode(Key k, Value v) : key(k), value(v) {} Key key; Value value; }; // struct MapNode private: std::vector<std::vector<MapNode>> bins_; Hash<Key> hash_; }; // class HashMap } // namespace jtl #endif // JTL_FLAT_HASH_MAP__
Add instance var for hotkey arguments
#pragma once #include <vector> class HotkeyInfo { public: enum HotkeyActions { IncreaseVolume, DecreaseVolume, SetVolume, Mute, VolumeSlider, RunApp, Settings, Exit, }; static std::vector<std::wstring> ActionNames; public: int keyCombination = 0; int action = -1; };
#pragma once #include <vector> class HotkeyInfo { public: enum HotkeyActions { IncreaseVolume, DecreaseVolume, SetVolume, Mute, VolumeSlider, RunApp, Settings, Exit, }; static std::vector<std::wstring> ActionNames; public: int keyCombination = 0; int action = -1; std::vector<std::wstring> args; };
Fix build error with import
// // CRToast // Copyright (c) 2014-2015 Collin Ruffenach. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for CRToast. FOUNDATION_EXPORT double CRToastVersionNumber; //! Project version string for CRToast. FOUNDATION_EXPORT const unsigned char CRToastVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <CRToast/PublicHeader.h> #import <CRToast/CRToastConfig.h> #import <CRToast/CRToastManager.h>
// // CRToast // Copyright (c) 2014-2015 Collin Ruffenach. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for CRToast. FOUNDATION_EXPORT double CRToastVersionNumber; //! Project version string for CRToast. FOUNDATION_EXPORT const unsigned char CRToastVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <CRToast/PublicHeader.h> #import "CRToast/CRToastConfig.h" #import "CRToast/CRToastManager.h"
Make the genericPage methods activate and deactivate widgets public instead of protected.
/* * dialer - MeeGo Voice Call Manager * Copyright (c) 2009, 2010, Intel Corporation. * * This program is licensed under the terms and conditions of the * Apache License, version 2.0. The full text of the Apache License is at * http://www.apache.org/licenses/LICENSE-2.0 * */ #ifndef GENERICPAGE_H #define GENERICPAGE_H #include <MApplicationPage> class MainWindow; class MLayout; class MGridLayoutPolicy; class GenericPage : public MApplicationPage { Q_OBJECT public: enum PageType { PAGE_NONE = -1, PAGE_DIALER = 0, PAGE_RECENT = 1, PAGE_PEOPLE = 2, PAGE_FAVORITE = 3, PAGE_DEBUG = 4, }; GenericPage(); virtual ~GenericPage(); virtual void createContent(); virtual MGridLayoutPolicy * policy(M::Orientation); MainWindow *mainWindow(); protected: virtual void showEvent(QShowEvent *event); virtual void activateWidgets(); virtual void deactivateAndResetWidgets(); MLayout * layout; MGridLayoutPolicy * landscape; MGridLayoutPolicy * portrait; PageType m_pageType; }; #endif // GENERICPAGE_H
/* * dialer - MeeGo Voice Call Manager * Copyright (c) 2009, 2010, Intel Corporation. * * This program is licensed under the terms and conditions of the * Apache License, version 2.0. The full text of the Apache License is at * http://www.apache.org/licenses/LICENSE-2.0 * */ #ifndef GENERICPAGE_H #define GENERICPAGE_H #include <MApplicationPage> class MainWindow; class MLayout; class MGridLayoutPolicy; class GenericPage : public MApplicationPage { Q_OBJECT public: enum PageType { PAGE_NONE = -1, PAGE_DIALER = 0, PAGE_RECENT = 1, PAGE_PEOPLE = 2, PAGE_FAVORITE = 3, PAGE_DEBUG = 4, }; GenericPage(); virtual ~GenericPage(); virtual void createContent(); virtual MGridLayoutPolicy * policy(M::Orientation); virtual void activateWidgets(); virtual void deactivateAndResetWidgets(); MainWindow *mainWindow(); protected: virtual void showEvent(QShowEvent *event); MLayout * layout; MGridLayoutPolicy * landscape; MGridLayoutPolicy * portrait; PageType m_pageType; }; #endif // GENERICPAGE_H
Support for MS Visual Studio 2008.
#ifndef __SimpleITKMacro_h #define __SimpleITKMacro_h #include <stdint.h> #include <itkImageBase.h> #include <itkImage.h> #include <itkLightObject.h> #include <itkSmartPointer.h> // Define macros to aid in the typeless layer typedef itk::ImageBase<3> SimpleImageBase; namespace itk { namespace simple { // To add a new type you must: // 1. Add an entry to ImageDataType // 2. Add to the sitkDataTypeSwitch // 3. Add the new type to ImageFileReader/ImageFileWriter enum ImageDataType { sitkUInt8, // Unsigned 8 bit integer sitkInt16, // Signed 16 bit integer sitkInt32, // Signed 32 bit integer sitkFloat32, // 32 bit float }; #define sitkImageDataTypeCase(typeN, type, call ) \ case typeN: { typedef type DataType; call; }; break #define sitkImageDataTypeSwitch( call ) \ sitkImageDataTypeCase ( sitkUInt8, uint8_t, call ); \ sitkImageDataTypeCase ( sitkInt16, int16_t, call ); \ sitkImageDataTypeCase ( sitkInt32, int32_t, call ); \ sitkImageDataTypeCase ( sitkFloat32, float, call ); } } #endif
#ifndef __SimpleITKMacro_h #define __SimpleITKMacro_h // Ideally, take the types from the C99 standard. However, // VS 8 does not have stdint.h, but they are defined anyway. #ifndef _MSC_VER #include <stdint.h> #endif #include <itkImageBase.h> #include <itkImage.h> #include <itkLightObject.h> #include <itkSmartPointer.h> // Define macros to aid in the typeless layer typedef itk::ImageBase<3> SimpleImageBase; namespace itk { namespace simple { // To add a new type you must: // 1. Add an entry to ImageDataType // 2. Add to the sitkDataTypeSwitch // 3. Add the new type to ImageFileReader/ImageFileWriter enum ImageDataType { sitkUInt8, // Unsigned 8 bit integer sitkInt16, // Signed 16 bit integer sitkInt32, // Signed 32 bit integer sitkFloat32, // 32 bit float }; #define sitkImageDataTypeCase(typeN, type, call ) \ case typeN: { typedef type DataType; call; }; break #define sitkImageDataTypeSwitch( call ) \ sitkImageDataTypeCase ( sitkUInt8, uint8_t, call ); \ sitkImageDataTypeCase ( sitkInt16, int16_t, call ); \ sitkImageDataTypeCase ( sitkInt32, int32_t, call ); \ sitkImageDataTypeCase ( sitkFloat32, float, call ); } } #endif
Fix this XTARGET so that this does doesn't XPASS on non-darwin hosts.
// RUN: %llvmgcc %s -c -m32 -fasm-blocks -o /dev/null // This should not warn about unreferenced label. 7729514. // XFAIL: * // XTARGET: i386-apple-darwin,x86_64-apple-darwin,i686-apple-darwin void quarterAsm(int array[], int len) { __asm { mov esi, array; mov ecx, len; shr ecx, 2; loop: movdqa xmm0, [esi]; psrad xmm0, 2; movdqa [esi], xmm0; add esi, 16; sub ecx, 1; jnz loop; } }
// RUN: %llvmgcc %s -c -m32 -fasm-blocks -o /dev/null // This should not warn about unreferenced label. 7729514. // XFAIL: * // XTARGET: x86,i386,i686 void quarterAsm(int array[], int len) { __asm { mov esi, array; mov ecx, len; shr ecx, 2; loop: movdqa xmm0, [esi]; psrad xmm0, 2; movdqa [esi], xmm0; add esi, 16; sub ecx, 1; jnz loop; } }
Add interface for stream cipher
// MIT License // Copyright (c) 2017 Zhuhao Wang // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #pragma once #include <memory> #include <boost/noncopyable.hpp> namespace nekit { namespace crypto { enum class ErrorCode { NoError, ValidationFailed }; enum class Action { Decryption = 0, Encryption = 1 }; // This class provide support for stream cipher or block cipher in stream mode. class StreamCipherInterface: private boost::noncopyable { public: virtual ~StreamCipherInterface() = default; virtual void SetKey(const uint8_t *data, bool copy) = 0; virtual void SetIv(const uint8_t *data, bool copy) = 0; virtual ErrorCode Process(const uint8_t *input, size_t len, const uint8_t *input_tag, uint8_t *output, uint8_t *output_tag) = 0; virtual void Reset() = 0; virtual size_t key_size() = 0; virtual size_t iv_size() = 0; virtual size_t block_size() = 0; virtual size_t tag_size() = 0; }; } // namespace crypto } // namespace nekit
Fix type mismatch between property and ivar
// // MustacheToken.h // OCMustache // // Created by Wesley Moore on 31/10/10. // Copyright 2010 Wesley Moore. All rights reserved. // #import <Foundation/Foundation.h> enum mustache_token_type { mustache_token_type_etag = 1, // Escaped tag mustache_token_type_utag, // Unescaped tag mustache_token_type_section, mustache_token_type_inverted, mustache_token_type_static, // Static text mustache_token_type_partial }; @interface MustacheToken : NSObject { enum mustache_token_type type; const char *content; NSUInteger content_length; } @property(nonatomic, assign) enum mustache_token_type type; @property(nonatomic, assign) const char *content; @property(nonatomic, assign) size_t contentLength; - (id)initWithType:(enum mustache_token_type)token_type content:(const char *)content contentLength:(NSUInteger)length; - (NSString *)contentString; @end
// // MustacheToken.h // OCMustache // // Created by Wesley Moore on 31/10/10. // Copyright 2010 Wesley Moore. All rights reserved. // #import <Foundation/Foundation.h> enum mustache_token_type { mustache_token_type_etag = 1, // Escaped tag mustache_token_type_utag, // Unescaped tag mustache_token_type_section, mustache_token_type_inverted, mustache_token_type_static, // Static text mustache_token_type_partial }; @interface MustacheToken : NSObject { enum mustache_token_type type; const char *content; NSUInteger content_length; } @property(nonatomic, assign) enum mustache_token_type type; @property(nonatomic, assign) const char *content; @property(nonatomic, assign) NSUInteger contentLength; - (id)initWithType:(enum mustache_token_type)token_type content:(const char *)content contentLength:(NSUInteger)length; - (NSString *)contentString; @end
Add unitconverter include to gmx top reader
/* * Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org) * * 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 _VOTCA_CSG_GMXTOPOLOGYREADER_H #define _VOTCA_CSG_GMXTOPOLOGYREADER_H #include <string> #include <votca/csg/topologyreader.h> namespace votca { namespace csg { /** \brief reader for gromacs topology files This class encapsulates the gromacs reading functions and provides an interface to fill a topolgy class */ class GMXTopologyReader : public TopologyReader { public: GMXTopologyReader() = default; /// read a topology file bool ReadTopology(std::string file, Topology &top) override; private: }; } // namespace csg } // namespace votca #endif /* _VOTCA_CSG_GMXTOPOLOGYREADER_H */
/* * Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org) * * 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 _VOTCA_CSG_GMXTOPOLOGYREADER_H #define _VOTCA_CSG_GMXTOPOLOGYREADER_H #include <string> #include <votca/csg/topologyreader.h> #include <votca/tools/unitconverter.h> namespace votca { namespace csg { /** \brief reader for gromacs topology files This class encapsulates the gromacs reading functions and provides an interface to fill a topolgy class */ class GMXTopologyReader : public TopologyReader { public: GMXTopologyReader() = default; /// read a topology file bool ReadTopology(std::string file, Topology &top) override; private: }; } // namespace csg } // namespace votca #endif /* _VOTCA_CSG_GMXTOPOLOGYREADER_H */
Change incorrect prototype from 'dram_init(void)' to 'dram_cartridge_init(void)'
/* * Copyright (c) 2012 Israel Jacques * See LICENSE for details. * * Israel Jacques <mrko@eecs.berkeley.edu> */ #ifndef _DRAM_CARTRIDGE_H__ #define _DRAM_CARTRIDGE_H__ extern void dram_init(void); #endif /* !_DRAM_CARTRIDGE_H_
/* * Copyright (c) 2012 Israel Jacques * See LICENSE for details. * * Israel Jacques <mrko@eecs.berkeley.edu> */ #ifndef _DRAM_CARTRIDGE_H__ #define _DRAM_CARTRIDGE_H__ extern void dram_cartridge_init(void); #endif /* !_DRAM_CARTRIDGE_H_
Test for shift by negative
// PARAM: --enable ana.int.interval --enable exp.partition-arrays.enabled --set ana.activated "['base', 'mallocWrapper']" int main(void) { // Shifting by a negative number is UB, but we should still not crash on it, but go to top instead int v = -1; int r = 17; int u = r >> v; }
Change hard limit on heap
/* * Copyright (c) 2012 Israel Jacquez * See LICENSE for details. * * Israel Jacquez <mrkotfw@gmail.com> */ #ifndef _SLOB_H_ #define _SLOB_H_ #include <stddef.h> /*- * Restrictions * * 1. Allocation requests bigger than SLOB_PAGE_BREAK_2ND cannot be * serviced. This is due to the memory block manager not able to * guarantee that sequential allocations of SLOB pages will be * contiguous. */ /* * Adjust the number of pages to be statically allocated as needed. If * memory is quickly exhausted, increase the SLOB page count. */ #ifndef SLOB_PAGE_COUNT #define SLOB_PAGE_COUNT 4 #endif /* !SLOB_PAGE_COUNT */ #define SLOB_PAGE_SIZE 0x1000 #define SLOB_PAGE_MASK (~(SLOB_PAGE_SIZE - 1)) #define SLOB_PAGE_BREAK_1ST 0x0100 #define SLOB_PAGE_BREAK_2ND 0x0400 void slob_init(void); void *slob_alloc(size_t); void slob_free(void *); #endif /* _SLOB_H_ */
/* * Copyright (c) 2012 Israel Jacquez * See LICENSE for details. * * Israel Jacquez <mrkotfw@gmail.com> */ #ifndef _SLOB_H_ #define _SLOB_H_ #include <stddef.h> /*- * Restrictions * * 1. Heap size limit: Allocation requests bigger than * SLOB_PAGE_BREAK_2ND cannot be serviced. This is due to the * memory block manager not able to guarantee that sequential * allocations of SLOB pages will be contiguous. */ /* * Adjust the number of pages to be statically allocated as needed. If * memory is quickly exhausted, increase the SLOB page count. */ #ifndef SLOB_PAGE_COUNT #define SLOB_PAGE_COUNT 4 #endif /* !SLOB_PAGE_COUNT */ #define SLOB_PAGE_SIZE 0x4000 #define SLOB_PAGE_MASK (~(SLOB_PAGE_SIZE - 1)) #define SLOB_PAGE_BREAK_1ST 0x0100 #define SLOB_PAGE_BREAK_2ND 0x0400 void slob_init(void); void *slob_alloc(size_t); void slob_free(void *); #endif /* _SLOB_H_ */
Add further issue with recursion
// PARAM: --sets solver td3 --set ana.activated "['base','threadid','threadflag','octagon','mallocWrapper']" // Example from https://github.com/sosy-lab/sv-benchmarks/blob/master/c/recursive-simple/afterrec_2calls-1.c void f(int); void f2(int); void f(int n) { if (n<3) return; n--; f2(n); assert(1); } void f2(int n) { if (n<3) return; n--; f(n); assert(1); } int main(void) { f(4); }
Fix dll import name error[132001]
#ifndef MUSICMOBILEGLOBALDEFINE_H #define MUSICMOBILEGLOBALDEFINE_H /* ================================================= * This file is part of the TTK Music Player project * Copyright (c) 2015 - 2017 Greedysky Studio * All rights reserved! * Redistribution and use of the source code or any derivative * works are strictly forbiden. =================================================*/ #include "musicglobal.h" ////////////////////////////////////// ///exoprt /// /// #define MUSIC_EXPORT #ifdef MUSIC_EXPORT # define MUSIC_MOBILE_EXPORT Q_DECL_EXPORT #else # define MUSIC_MOBILE_EXPORT Q_DECL_IMPORT #endif #endif // MUSICMOBILEGLOBALDEFINE_H
#ifndef MUSICMOBILEGLOBALDEFINE_H #define MUSICMOBILEGLOBALDEFINE_H /* ================================================= * This file is part of the TTK Music Player project * Copyright (c) 2015 - 2017 Greedysky Studio * All rights reserved! * Redistribution and use of the source code or any derivative * works are strictly forbiden. =================================================*/ #include "musicglobal.h" ////////////////////////////////////// ///exoprt /// /// #define MUSIC_EXPORT #ifdef MUSIC_EXPORT # define MUSIC_MOBILE_EXPORT Q_DECL_EXPORT #else # define MUSIC_MOBILE_IMPORT Q_DECL_IMPORT #endif #endif // MUSICMOBILEGLOBALDEFINE_H
Boost json::spirit support for mArrays and mObjects
#include <json_spirit.h> namespace sqlite { // json_spirit::mArray template<> void get_col_from_db(database_binder& db, int inx, json_spirit::mArray& a) { json_spirit::mValue tmp; std::string str((char*)sqlite3_column_blob(db._stmt, inx), sqlite3_column_bytes(db._stmt, inx)); json_spirit::read(str, tmp); a = tmp.get_array(); } template<> database_binder& operator <<(database_binder& db, const json_spirit::mArray& val) { auto tmp = json_spirit::write(val); if(sqlite3_bind_blob(db._stmt, db._inx, tmp.c_str() , tmp.size() , SQLITE_TRANSIENT) != SQLITE_OK) { db.throw_sqlite_error(); } ++db._inx; return db; } // json_spirit::mObject template<> void get_col_from_db(database_binder& db, int inx, json_spirit::mObject& a) { json_spirit::mValue tmp; std::string str((char*)sqlite3_column_blob(db._stmt, inx), sqlite3_column_bytes(db._stmt, inx)); json_spirit::read(str, tmp); a = tmp.get_obj(); } template<> database_binder& operator <<(database_binder& db, const json_spirit::mObject& val) { auto tmp = json_spirit::write(val); if(sqlite3_bind_blob(db._stmt, db._inx, tmp.c_str(), tmp.size(), SQLITE_TRANSIENT) != SQLITE_OK) { db.throw_sqlite_error(); } ++db._inx; return db; } }
Initialize global var to avoid macOS linker error
/*------------------------------------------------------------------------- * * resource_manager.c * GPDB resource manager code. * * * Copyright (c) 2006-2017, Greenplum inc. * * ------------------------------------------------------------------------- */ #include "postgres.h" #include "utils/guc.h" #include "utils/resource_manager.h" /* * GUC variables. */ bool ResourceScheduler; /* Is scheduling enabled? */ ResourceManagerPolicy Gp_resource_manager_policy;
/*------------------------------------------------------------------------- * * resource_manager.c * GPDB resource manager code. * * * Copyright (c) 2006-2017, Greenplum inc. * * ------------------------------------------------------------------------- */ #include "postgres.h" #include "utils/guc.h" #include "utils/resource_manager.h" /* * GUC variables. */ bool ResourceScheduler = false; /* Is scheduling enabled? */ ResourceManagerPolicy Gp_resource_manager_policy;
Use WALL time for timer
#include <stdio.h> #include <time.h> int multiples_three_five(int limit) { long total = 0; int i; for (i=1; i < limit; i++) total += i % 3 == 0 || i % 5 == 0 ? i : 0; return total; } int main(void) { clock_t start, stop; start = clock(); long ans = multiples_three_five(1000); printf ("Answer: %ld\n", ans); stop = clock(); printf ("Time: %f\n", ((float)stop - (float)start) / CLOCKS_PER_SEC); return 0; }
#include <time.h> #include <stdio.h> #define NANO 10000000000 int multiples_three_five(int limit) { long total = 0; for (int i=1; i < limit; i++) total += i % 3 == 0 || i % 5 == 0 ? i : 0; return total; } int main(void) { struct timespec start; clock_gettime(CLOCK_REALTIME, &start); double start_time = ((float) start.tv_sec) + ((float) start.tv_nsec) / NANO; long ans = multiples_three_five(1000); printf ("Answer: %ld\n", ans); struct timespec stop; clock_gettime(CLOCK_REALTIME, &stop); double stop_time = ((float) stop.tv_sec) + ((float) stop.tv_nsec) / NANO; printf ("Time: %.8f\n", stop_time - start_time); return 0; }
Use condor_commands.h instead of defining commands here.
#ifndef __COLLECTOR_H__ #define __COLLECTOR_H__ #include "sched.h" enum AdTypes { STARTD_AD, SCHEDD_AD, MASTER_AD, GATEWAY_AD, CKPT_SRVR_AD, NUM_AD_TYPES }; // collector commands const int UPDATE_STARTD_AD = 0; const int UPDATE_SCHEDD_AD = 1; const int UPDATE_MASTER_AD = 2; const int UPDATE_GATEWAY_AD = 3; const int UPDATE_CKPT_SRVR_AD = 4; const int QUERY_STARTD_ADS = 5; const int QUERY_SCHEDD_ADS = 6; const int QUERY_MASTER_ADS = 7; const int QUERY_GATEWAY_ADS = 8; const int QUERY_CKPT_SRVR_ADS = 9; #endif // __COLLECTOR_H__
#ifndef __COLLECTOR_H__ #define __COLLECTOR_H__ #include "sched.h" enum AdTypes { STARTD_AD, SCHEDD_AD, MASTER_AD, GATEWAY_AD, CKPT_SRVR_AD, NUM_AD_TYPES }; #include "condor_commands.h" // collector commands #endif // __COLLECTOR_H__
Update doxygen documentation on HMAC
/** * @file * Hashing module documentation file. */ /** * @addtogroup hashing_module Hashing module * * The Hashing module provides one-way hashing functions. Such functions can be * used for creating a hash message authentication code (HMAC) when sending a * message. Such a HMAC can be used in combination with a private key * for authentication, which is a message integrity control. * * All hash algorithms can be accessed via the generic MD layer (see * \c md_init_ctx()) * * The following hashing-algorithms are provided: * - MD2, MD4, MD5 128-bit one-way hash functions by Ron Rivest (see * \c md2_hmac(), \c md4_hmac() and \c md5_hmac()). * - SHA-1, SHA-256, SHA-384/512 160-bit or more one-way hash functions by * NIST and NSA (see\c sha1_hmac(), \c sha256_hmac() and \c sha512_hmac()). * * This module provides one-way hashing which can be used for authentication. */
/** * @file * Hashing module documentation file. */ /** * @addtogroup hashing_module Hashing module * * The Hashing module provides one-way hashing functions. Such functions can be * used for creating a hash message authentication code (HMAC) when sending a * message. Such a HMAC can be used in combination with a private key * for authentication, which is a message integrity control. * * All hash algorithms can be accessed via the generic MD layer (see * \c md_init_ctx()) * * The following hashing-algorithms are provided: * - MD2, MD4, MD5 128-bit one-way hash functions by Ron Rivest. * - SHA-1, SHA-256, SHA-384/512 160-bit or more one-way hash functions by * NIST and NSA. * * This module provides one-way hashing which can be used for authentication. */
Extend list of intel registers
enum args { AIMM = 1, AIMM8, AIMM16, AIMM32, AIMM64, AREG_AX, AREG_AL, AREG_AH, AREG_EAX, AREG_BC, AREG_BL, AREG_BH, AREG_EBX, AREG_CX, AREG_CL, AREG_CH, AREG_ECX, AREG_DX, AREG_DL, AREG_DH, AREG_EDX, AREG_SI, AREG_DI, AREG_SP, AREG_ESP, AREG_EBP, AREP, };
enum args { AIMM = 1, AIMM8, AIMM16, AIMM32, AIMM64, AREG_CS, AREG_DS, AREG_SS, AREG_ES AREG_FS, AREG_GS, AREG_EFLAGS, AREG_AX, AREG_AL, AREG_AH, AREG_EAX, AREG_RAX, AREG_BX, AREG_BL, AREG_BH, AREG_EBX, AREG_RBX, AREG_CX, AREG_CL, AREG_CH, AREG_ECX, AREG_RCX, AREG_DX, AREG_DL, AREG_DH, AREG_EDX, AREG_RDX, AREG_SI, AREG_DI, AREG_SP, AREG_ESP, AREG_RSP, AREG_BP, AREG_EBP, AREG_RBP, AREP, };
Add raw array access to hsv structure, and operator[] operations to hsv and rgb classes
#ifndef __INC_PIXELS_H #define __INC_PIXELS_H #include <stdint.h> struct CRGB { union { struct { uint8_t r; uint8_t g; uint8_t b; }; uint8_t raw[3]; }; }; #ifdef SUPPORT_ARGB struct CARGB { union { struct { uint8_t a; uint8_t g; uint8_t r; uint8_t b; }; uint8_t raw[4]; uint32_t all32; }; }; #endif struct CHSV { union { uint8_t hue; uint8_t h; }; union { uint8_t saturation; uint8_t sat; uint8_t s; }; union { uint8_t value; uint8_t val; uint8_t v; }; }; // Define RGB orderings enum EOrder { RGB=0012, RBG=0021, GRB=0102, GBR=0120, BRG=0201, BGR=0210 }; #endif
#ifndef __INC_PIXELS_H #define __INC_PIXELS_H #include <stdint.h> struct CRGB { union { struct { uint8_t r; uint8_t g; uint8_t b; }; uint8_t raw[3]; }; inline uint8_t& operator[] (uint8_t x) __attribute__((always_inline)) { return raw[x]; } }; #ifdef SUPPORT_ARGB struct CARGB { union { struct { uint8_t a; uint8_t g; uint8_t r; uint8_t b; }; uint8_t raw[4]; uint32_t all32; }; }; #endif struct CHSV { union { struct { union { uint8_t hue; uint8_t h; }; union { uint8_t saturation; uint8_t sat; uint8_t s; }; union { uint8_t value; uint8_t val; uint8_t v; }; }; uint8_t raw[3]; }; inline uint8_t& operator[](uint8_t x) __attribute__((always_inline)) { return raw[x]; } }; // Define RGB orderings enum EOrder { RGB=0012, RBG=0021, GRB=0102, GBR=0120, BRG=0201, BGR=0210 }; #endif
Make creator compile without being on ahiemstra's machine ;)
/* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef GLUON_CREATOR_COMPONENTSDOCK_H #define GLUON_CREATOR_COMPONENTSDOCK_H #include <../../home/ahiemstra/Projects/gluon/creator/lib/widgets/dock.h> namespace Gluon { namespace Creator { class ComponentsDock : public Gluon::Creator::Dock { public: ComponentsDock(const QString& title, QWidget* parent = 0, Qt::WindowFlags flags = 0); ~ComponentsDock(); void setSelection(Gluon::GluonObject* obj = 0); QAbstractItemView* view(); QAbstractItemModel* model(); private: class ComponentsDockPrivate; ComponentsDockPrivate* d; }; } } #endif // GLUON_CREATOR_COMPONENTSDOCK_H
/* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef GLUON_CREATOR_COMPONENTSDOCK_H #define GLUON_CREATOR_COMPONENTSDOCK_H #include "widgets/dock.h" namespace Gluon { namespace Creator { class ComponentsDock : public Gluon::Creator::Dock { public: ComponentsDock(const QString& title, QWidget* parent = 0, Qt::WindowFlags flags = 0); ~ComponentsDock(); void setSelection(Gluon::GluonObject* obj = 0); QAbstractItemView* view(); QAbstractItemModel* model(); private: class ComponentsDockPrivate; ComponentsDockPrivate* d; }; } } #endif // GLUON_CREATOR_COMPONENTSDOCK_H
Correct this test for the fact that the number of uses is now printed in a comment.
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s // RUN: grep 'declare i32 @f0() readnone$' %t // RUN: grep 'declare i32 @f1() readonly$' %t // RUN: grep 'declare void @f2(.* sret)$' %t // RUN: grep 'declare void @f3(.* sret)$' %t // RUN: grep 'declare void @f4(.* byval)$' %t // RUN: grep 'declare void @f5(.* byval)$' %t // PR3835 typedef int T0; typedef struct { int a[16]; } T1; T0 __attribute__((const)) f0(void); T0 __attribute__((pure)) f1(void); T1 __attribute__((const)) f2(void); T1 __attribute__((pure)) f3(void); void __attribute__((const)) f4(T1 a); void __attribute__((pure)) f5(T1 a); void *ps[] = { f0, f1, f2, f3, f4, f5 };
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s // RUN: grep 'declare i32 @f0() readnone ;' %t // RUN: grep 'declare i32 @f1() readonly ;' %t // RUN: grep 'declare void @f2(.* sret) ;' %t // RUN: grep 'declare void @f3(.* sret) ;' %t // RUN: grep 'declare void @f4(.* byval) ;' %t // RUN: grep 'declare void @f5(.* byval) ;' %t // PR3835 typedef int T0; typedef struct { int a[16]; } T1; T0 __attribute__((const)) f0(void); T0 __attribute__((pure)) f1(void); T1 __attribute__((const)) f2(void); T1 __attribute__((pure)) f3(void); void __attribute__((const)) f4(T1 a); void __attribute__((pure)) f5(T1 a); void *ps[] = { f0, f1, f2, f3, f4, f5 };
Add alias for invalid event ID.
#ifndef VAST_ALIASES_H #define VAST_ALIASES_H #include <cstdint> #include <limits> namespace vast { /// Uniquely identifies a VAST event. using event_id = uint64_t; /// The smallest possible event ID. static constexpr event_id min_event_id = 1; /// The largest possible event ID. static constexpr event_id max_event_id = std::numeric_limits<event_id>::max() - 1; /// Uniquely identifies a VAST type. using type_id = uint64_t; } // namespace vast #endif
#ifndef VAST_ALIASES_H #define VAST_ALIASES_H #include <cstdint> #include <limits> namespace vast { /// Uniquely identifies a VAST event. using event_id = uint64_t; /// The invalid event ID. static constexpr event_id invalid_event_id = 0; /// The smallest possible event ID. static constexpr event_id min_event_id = 1; /// The largest possible event ID. static constexpr event_id max_event_id = std::numeric_limits<event_id>::max() - 1; /// Uniquely identifies a VAST type. using type_id = uint64_t; } // namespace vast #endif
Change client version number to 1.2.0.0
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 1 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2013 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 2 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2013 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
Use typedef for reading struct
#ifndef GH_DATASTORE_H #define GH_DATASTORE_H #include <sqlite3.h> struct reading { int id; char *title; int readmill_id; int total_pages; }; sqlite3 *gh_datastore_open_db (char *data_dir); int gh_datastore_get_db_version (sqlite3 *db); void gh_datastore_set_db_version (sqlite3 *db, int version); #endif
#ifndef GH_DATASTORE_H #define GH_DATASTORE_H #include <sqlite3.h> typedef struct { int id; char *title; int readmill_id; int total_pages; } Reading; sqlite3 *gh_datastore_open_db (char *data_dir); int gh_datastore_get_db_version (sqlite3 *db); void gh_datastore_set_db_version (sqlite3 *db, int version); #endif
Add ABI check for syscall numbers definitions
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This header will be kept up to date so that we can compile system-call // policies even when system headers are old. // System call numbers are accessible through __NR_syscall_name. #ifndef SANDBOX_LINUX_SERVICES_LINUX_SYSCALLS_H_ #define SANDBOX_LINUX_SERVICES_LINUX_SYSCALLS_H_ #if defined(__x86_64__) #include "sandbox/linux/services/x86_64_linux_syscalls.h" #endif #if defined(__i386__) #include "sandbox/linux/services/x86_32_linux_syscalls.h" #endif #if defined(__arm__) && defined(__ARM_EABI__) #include "sandbox/linux/services/arm_linux_syscalls.h" #endif #if defined(__mips__) #include "sandbox/linux/services/mips_linux_syscalls.h" #endif #endif // SANDBOX_LINUX_SERVICES_LINUX_SYSCALLS_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This header will be kept up to date so that we can compile system-call // policies even when system headers are old. // System call numbers are accessible through __NR_syscall_name. #ifndef SANDBOX_LINUX_SERVICES_LINUX_SYSCALLS_H_ #define SANDBOX_LINUX_SERVICES_LINUX_SYSCALLS_H_ #if defined(__x86_64__) #include "sandbox/linux/services/x86_64_linux_syscalls.h" #endif #if defined(__i386__) #include "sandbox/linux/services/x86_32_linux_syscalls.h" #endif #if defined(__arm__) && defined(__ARM_EABI__) #include "sandbox/linux/services/arm_linux_syscalls.h" #endif #if defined(__mips__) && defined(_ABIO32) #include "sandbox/linux/services/mips_linux_syscalls.h" #endif #endif // SANDBOX_LINUX_SERVICES_LINUX_SYSCALLS_H_
Add class for representing a Grid on the device
#ifndef GRIDINF_INCLUDE_GPUGRID_H #define GRIDINF_INCLUDE_GPUGRID_H #include "matdim.h" namespace ginf { // Mirrors the Grid class, but uses an implementation that is more suitable for GPUs. template <typename T> class GpuGrid { public: int smModel; // The smoothness cost model MatDim dimDt, dimSm; // Dimensions of cost matrices T *dtCosts; // Data cost matrix T *smCosts; // Smoothness cost matrix // Declare this functions only when compiling with nvcc #ifdef __CUDACC__ // Get width/height __device__ int getWidth() { return dimDt.x; } __device__ int getHeight() { return dimDt.y; } // Get total number of nodes __device__ int getNumNodes() { return dimDt.x * dimDt.y; } // Get number of labels __device__ int getNumLabels() { return dimDt.z; } // Get the cost of labeling (x, y) with label fp __device__ T getDataCost(int x, int y, int fp) { return dtCosts[dimDt.idx(x, y, fp)]; } // Get the smoothness cost V(fp, fq) __device__ T getSmoothnessCost(int fp, int fq) { return smCosts[dimSm.idx(fp, fq)]; } // Returns the cost of a labeling for a particular pixel __device__ T getLabelingCost(int *f, int x, int y, int label) { T totalCost = getDataCost(x, y, label); for (int d = 0; d < GINF_NUM_DIR; d++) { int nx = x + dDirX[d], ny = y + dDirY[d]; if (dimDt.isValid(nx, ny)) { totalCost += getSmoothnessCost(label, (int)f[dimDt.idx(nx, ny)]); } } return totalCost; } #endif }; // Explicit instantiations for template classes template class GpuGrid<int>; template class GpuGrid<float>; } #endif
Add to comments; remove use of sinfo from calling routines; adjust code to play well with other routing functions; add framework for handling loops
/* $Id$Revision: */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifndef ORTHO_H #define ORTHO_H #include <render.h> void orthoEdges (Agraph_t* g, int useLbls, splineInfo* sinfo); #endif
/* $Id$Revision: */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifndef ORTHO_H #define ORTHO_H #include <render.h> void orthoEdges (Agraph_t* g, int useLbls); #endif
Fix a static analyzer error
// // ArticleCellView.h // PXListView // // Adapted from PXListView by Alex Rozanski // Modified by Barijaona Ramaholimihaso // #import <Cocoa/Cocoa.h> #import "PXListViewCell.h" #import "ArticleView.h" @interface ArticleCellView : PXListViewCell { AppController * controller; ArticleView *articleView; NSProgressIndicator * progressIndicator; } @property (nonatomic, retain) ArticleView *articleView; @property BOOL inProgress; @property int folderId; // Public functions -(id)initWithReusableIdentifier: (NSString*)identifier inFrame:(NSRect)frameRect; @end
// // ArticleCellView.h // PXListView // // Adapted from PXListView by Alex Rozanski // Modified by Barijaona Ramaholimihaso // #import <Cocoa/Cocoa.h> #import "PXListViewCell.h" #import "ArticleView.h" @interface ArticleCellView : PXListViewCell { AppController * controller; ArticleView *articleView; NSProgressIndicator * progressIndicator; BOOL inProgress; int folderId; } @property (nonatomic, retain) ArticleView *articleView; @property BOOL inProgress; @property int folderId; // Public functions -(id)initWithReusableIdentifier: (NSString*)identifier inFrame:(NSRect)frameRect; @end
Use http_headers.h to define HTTP header tags for logging
/* * $Id$ * * Define the tags in the shared memory in a reusable format. * Whoever includes this get to define what the SLTM macro does. * */ SLTM(CLI) SLTM(SessionOpen) SLTM(SessionClose) SLTM(ClientAddr) SLTM(Request) SLTM(URL) SLTM(Protocol) SLTM(Headers)
/* * $Id$ * * Define the tags in the shared memory in a reusable format. * Whoever includes this get to define what the SLTM macro does. * */ SLTM(CLI) SLTM(SessionOpen) SLTM(SessionClose) SLTM(ClientAddr) SLTM(Request) SLTM(URL) SLTM(Protocol) SLTM(H_Unknown) #define HTTPH(a, b) SLTM(b) #include "http_headers.h" #undef HTTPH
Add prototypes for functions for parsing slave's responses
#define _MASTERCOILS #include <inttypes.h> //Functions for building requests extern uint8_t MODBUSBuildRequest01( uint8_t, uint16_t, uint16_t ); extern uint8_t MODBUSBuildRequest05( uint8_t, uint16_t, uint16_t ); extern uint8_t MODBUSBuildRequest15( uint8_t, uint16_t, uint16_t, uint8_t * ); //Functions for parsing responses extern void MODBUSParseResponse01( union MODBUSParser *, union MODBUSParser * ); //extern void MODBUSParseResponse05( union MODBUSParser *, union MODBUSParser * ); //extern void MODBUSParseResponse15( union MODBUSParser *, union MODBUSParser * );
#define _MASTERCOILS #include <inttypes.h> //Functions for building requests extern uint8_t MODBUSBuildRequest01( uint8_t, uint16_t, uint16_t ); extern uint8_t MODBUSBuildRequest05( uint8_t, uint16_t, uint16_t ); extern uint8_t MODBUSBuildRequest15( uint8_t, uint16_t, uint16_t, uint8_t * ); //Functions for parsing responses extern void MODBUSParseResponse01( union MODBUSParser *, union MODBUSParser * ); extern void MODBUSParseResponse05( union MODBUSParser *, union MODBUSParser * ); extern void MODBUSParseResponse15( union MODBUSParser *, union MODBUSParser * );
Remove manual addObject usage from the collector
#include <unordered_set> #include "../src/include/gc_obj.h" #include "../src/include/collector.h" class BinaryTreeNode : public gc_obj { public: BinaryTreeNode(const int id); ~BinaryTreeNode() = delete; int size() const; void curtailToLevel(const int lvl); void extendToLevel(const int size,Collector* collector); void addLeftChild(BinaryTreeNode* leftChild); void addRightChild(BinaryTreeNode* rightChild); virtual void finalize(); virtual std::unordered_set<gc_obj*> getManagedChildren(); private: int id; BinaryTreeNode* leftChild; BinaryTreeNode* rightChild; };
#include <unordered_set> #include "../src/include/gc_obj.h" class BinaryTreeNode : public gc_obj { public: BinaryTreeNode(const int id); int size() const; void curtailToLevel(const int lvl); void extendToLevel(const int size); void addLeftChild(BinaryTreeNode* leftChild); void addRightChild(BinaryTreeNode* rightChild); virtual void finalize(); virtual std::unordered_set<gc_obj*> getManagedChildren(); private: int id; BinaryTreeNode* leftChild; BinaryTreeNode* rightChild; };
Add Q_OBJECT macro (requested by lupdate).
// // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Bastian Holst <bastianholst@gmx.de> // #ifndef BBCWEATHERITEM_H #define BBCWEATHERITEM_H #include "WeatherItem.h" class QString; class QUrl; namespace Marble { class BBCWeatherItem : public WeatherItem { public: BBCWeatherItem( QObject *parent = 0 ); ~BBCWeatherItem(); virtual bool request( const QString& type ); QString service() const; void addDownloadedFile( const QString& url, const QString& type ); QUrl observationUrl() const; QUrl forecastUrl() const; quint32 bbcId() const; void setBbcId( quint32 id ); QString creditHtml() const; private: quint32 m_bbcId; bool m_observationRequested; bool m_forecastRequested; }; } // namespace Marble #endif // BBCWEATHERITEM_H
// // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Bastian Holst <bastianholst@gmx.de> // #ifndef BBCWEATHERITEM_H #define BBCWEATHERITEM_H #include "WeatherItem.h" class QString; class QUrl; namespace Marble { class BBCWeatherItem : public WeatherItem { Q_OBJECT public: BBCWeatherItem( QObject *parent = 0 ); ~BBCWeatherItem(); virtual bool request( const QString& type ); QString service() const; void addDownloadedFile( const QString& url, const QString& type ); QUrl observationUrl() const; QUrl forecastUrl() const; quint32 bbcId() const; void setBbcId( quint32 id ); QString creditHtml() const; private: quint32 m_bbcId; bool m_observationRequested; bool m_forecastRequested; }; } // namespace Marble #endif // BBCWEATHERITEM_H
Create headers for ImageFilter and EmoticonFilter
#include "message-processor.h" class UrlFilter : public AbstractMessageFilter { virtual void filterMessage(Message& message); };
#include "message-processor.h" class UrlFilter : public AbstractMessageFilter { virtual void filterMessage(Message& message); }; class ImageFilter : public AbstractMessageFilter { virtual void filterMessage(Message& message); }; class EmoticonFilter : public AbstractMessageFilter { virtual void filterMessage(Message& message); };
UPDATE some variable name changes
#ifndef SSPAPPLICATION_DEBUG_DEBUGHANDLER_H #define SSPAPPLICATION_DEBUG_DEBUGHANDLER_H #include <vector> #include <iostream> #include <Windows.h> class DebugHandler { private: std::vector<LARGE_INTEGER> m_timers; std::vector<std::string> m_labels; std::vector<unsigned short int> m_timerMins; std::vector<unsigned short int> m_timerMaxs; std::vector<float> m_customValues; unsigned short int m_lastFPS[10]; unsigned short int m_lastFPSCurr; public: DebugHandler(); ~DebugHandler(); int StartTimer(std::string label); //returns timer ID, -1 fail int EndTimer(); int EndTimer(int timerID); int StartProgram(); int EndProgram(); int ShowFPS(bool show); int CreateCustomLabel(std::string label, float value); //returns label ID, -1 fail int UpdateCustomLabel(int labelID, float newValue); int Display(); }; #endif
#ifndef SSPAPPLICATION_DEBUG_DEBUGHANDLER_H #define SSPAPPLICATION_DEBUG_DEBUGHANDLER_H #include <vector> #include <iostream> #include <Windows.h> class DebugHandler { private: std::vector<LARGE_INTEGER> m_timers; std::vector<std::string> m_labels; std::vector<unsigned short int> m_timerMins; std::vector<unsigned short int> m_timerMaxs; std::vector<float> m_customValues; unsigned short int m_frameTimes[10]; unsigned short int m_currFrameTimesPtr; public: DebugHandler(); ~DebugHandler(); int StartTimer(std::string label); //returns timer ID, -1 fail int EndTimer(); int EndTimer(int timerID); int StartProgram(); int EndProgram(); int ShowFPS(bool show); int CreateCustomLabel(std::string label, float value); //returns label ID, -1 fail int UpdateCustomLabel(int labelID, float newValue); int Display(); }; #endif
Modify set resource. Using floats now.
#include <string.h> #include "proxrcmds.h" #include "sim-hab.h" void cb_set_resource(bionet_resource_t *resource, bionet_value_t *value) { uint8_t data; float content; int id; bionet_node_t *node; bionet_value_get_uint8(value, &data); if(data < 0 || data > 255) return; node = bionet_resource_get_node(resource); // get index of resource //FIXME: probably a better way to do this for(int i=0; i<16; i++) { char buf[5]; char name[24]; strcpy(name, "Potentiometer\0"); sprintf(buf,"%d", i); int len = strlen(buf); buf[len] = '\0'; strcat(name, buf); if(bionet_resource_matches_id(resource, name)) { id = i; break; } } // command proxr to adjust to new value set_potentiometer(id, data); // set resources datapoint to new value content = data*POT_CONVERSION; bionet_resource_set_float(resource, content, NULL); hab_report_datapoints(node); }
#include <string.h> #include "proxrcmds.h" #include "sim-hab.h" void cb_set_resource(bionet_resource_t *resource, bionet_value_t *value) { float data; float content; int id; bionet_node_t *node; bionet_value_get_float(value, &data); if(data < 0 || data > 255) return; node = bionet_resource_get_node(resource); // get index of resource //FIXME: probably a better way to do this for(int i=0; i<16; i++) { char buf[5]; char name[24]; strcpy(name, "Potentiometer\0"); sprintf(buf,"%d", i); int len = strlen(buf); buf[len] = '\0'; strcat(name, buf); if(bionet_resource_matches_id(resource, name)) { id = i; break; } } // command proxr to adjust to new value set_potentiometer(id, (int)data); // set resources datapoint to new value content = data*POT_CONVERSION; bionet_resource_set_float(resource, content, NULL); hab_report_datapoints(node); }
Remove stack hard limit on ia64
#ifndef _ASM_IA64_RESOURCE_H #define _ASM_IA64_RESOURCE_H #include <asm/ustack.h> #define _STK_LIM_MAX DEFAULT_USER_STACK_SIZE #include <asm-generic/resource.h> #endif /* _ASM_IA64_RESOURCE_H */
#ifndef _ASM_IA64_RESOURCE_H #define _ASM_IA64_RESOURCE_H #include <asm/ustack.h> #include <asm-generic/resource.h> #endif /* _ASM_IA64_RESOURCE_H */
Decrease MAX_EDITSTR. Was way too big.
#pragma once #include <Windows.h> #include <functional> #include <string> class Control { public: Control(); Control(int id, HWND parent); ~Control(); virtual RECT Dimensions(); virtual void Enable(); virtual void Disable(); virtual bool Enabled(); virtual void Enabled(bool enabled); virtual std::wstring Text(); virtual int TextAsInt(); virtual bool Text(std::wstring text); virtual bool Text(int value); void WindowExStyle(); void WindowExStyle(long exStyle); void AddWindowExStyle(long exStyle); void RemoveWindowExStyle(long exStyle); /// <summary>Handles WM_COMMAND messages.</summary> /// <param name="nCode">Control-defined notification code</param> virtual DLGPROC Command(unsigned short nCode); /// <summary>Handles WM_NOTIFY messages.</summary> /// <param name="nHdr">Notification header structure</param> virtual DLGPROC Notification(NMHDR *nHdr); protected: int _id; HWND _hWnd; HWND _parent; protected: static const int MAX_EDITSTR = 0x4000; };
#pragma once #include <Windows.h> #include <functional> #include <string> class Control { public: Control(); Control(int id, HWND parent); ~Control(); virtual RECT Dimensions(); virtual void Enable(); virtual void Disable(); virtual bool Enabled(); virtual void Enabled(bool enabled); virtual std::wstring Text(); virtual int TextAsInt(); virtual bool Text(std::wstring text); virtual bool Text(int value); void WindowExStyle(); void WindowExStyle(long exStyle); void AddWindowExStyle(long exStyle); void RemoveWindowExStyle(long exStyle); /// <summary>Handles WM_COMMAND messages.</summary> /// <param name="nCode">Control-defined notification code</param> virtual DLGPROC Command(unsigned short nCode); /// <summary>Handles WM_NOTIFY messages.</summary> /// <param name="nHdr">Notification header structure</param> virtual DLGPROC Notification(NMHDR *nHdr); protected: int _id; HWND _hWnd; HWND _parent; protected: static const int MAX_EDITSTR = 4096; };
Document (lack of) character encoding rules in the API
/* * libtu/util.h * * Copyright (c) Tuomo Valkonen 1999-2002. * * You may distribute and modify this library under the terms of either * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. */ #ifndef LIBTU_UTIL_H #define LIBTU_UTIL_H #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include "types.h" #include "optparser.h" extern void libtu_init(const char *argv0); extern const char *libtu_progname(); extern const char *libtu_progbasename(); #endif /* LIBTU_UTIL_H */
/* * libtu/util.h * * Copyright (c) Tuomo Valkonen 1999-2002. * * You may distribute and modify this library under the terms of either * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. */ #ifndef LIBTU_UTIL_H #define LIBTU_UTIL_H #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include "types.h" #include "optparser.h" /** * @parame argv0 The program name used to invoke the current program, with * path (if specified). Unfortunately it is generally not easy to determine * the encoding of this string, so we don't require a specific one here. * * @see http://stackoverflow.com/questions/5408730/what-is-the-encoding-of-argv */ extern void libtu_init(const char *argv0); /** * The program name used to invoke the current program, with path (if * supplied). Unfortunately the encoding is undefined. */ extern const char *libtu_progname(); /** * The program name used to invoke the current program, without path. * Unfortunately the encoding is undefined. */ extern const char *libtu_progbasename(); #endif /* LIBTU_UTIL_H */
Fix bad template SFINAE declaration
#pragma once #include <type_traits> namespace ugly { template<typename T> constexpr const bool is_enum_flag = false; template<typename T = typename std::enable_if<is_enum_flag<T>, T>::type> class auto_bool { private: T val_; public: constexpr auto_bool(T val) : val_(val) {} constexpr operator T() const { return val_; } constexpr explicit operator bool() const { return static_cast<std::underlying_type_t<T>>(val_) != 0; } }; template <typename T> std::enable_if_t<is_enum_flag<T>, auto_bool<T>> operator&(T lhs, T rhs) { return static_cast<T>( static_cast<typename std::underlying_type<T>::type>(lhs) & static_cast<typename std::underlying_type<T>::type>(rhs)); } template <typename T> std::enable_if_t<is_enum_flag<T>, T> operator|(T lhs, T rhs) { return static_cast<T>( static_cast<typename std::underlying_type<T>::type>(lhs) | static_cast<typename std::underlying_type<T>::type>(rhs)); } }
#pragma once #include <type_traits> namespace ugly { template<typename T> constexpr const bool is_enum_flag = false; template<typename T, typename = typename std::enable_if<is_enum_flag<T>>::type> class auto_bool { private: T val_; public: constexpr auto_bool(T val) : val_(val) {} constexpr operator T() const { return val_; } constexpr explicit operator bool() const { return static_cast<std::underlying_type_t<T>>(val_) != 0; } }; template <typename T> std::enable_if_t<is_enum_flag<T>, auto_bool<T>> operator&(T lhs, T rhs) { return static_cast<T>( static_cast<typename std::underlying_type<T>::type>(lhs) & static_cast<typename std::underlying_type<T>::type>(rhs)); } template <typename T> std::enable_if_t<is_enum_flag<T>, T> operator|(T lhs, T rhs) { return static_cast<T>( static_cast<typename std::underlying_type<T>::type>(lhs) | static_cast<typename std::underlying_type<T>::type>(rhs)); } }
Kill processes which access descendants of given directory
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <dirent.h> #include <limits.h> /** * kill processes which access descendants of given directory */ int is_number(const char *s) { size_t i, len = strlen(s); for (i = 0; i < len; i++) { if (!isdigit(s[i])) return 0; } return 1; } void kill_processes(const char *dir) { DIR *par_pdir, *chl_pdir; struct dirent *par_pdent, *chl_pdent; char path[PATH_MAX]; par_pdir = opendir("/proc"); if (par_pdir == NULL) { perror("opendir"); return; } /* using children of /proc/pid/fd, find out processes which accesses * given directory and kill thoses */ while (par_pdent = readdir(par_pdir)) { if (isdigit(par_pdent->d_name[0]) && ((par_pdent->d_type == DT_DIR) || (par_pdent->d_type == DT_UNKNOWN))) { snprintf(path, sizeof(path), "/proc/%s/fd", par_pdent->d_name); chi_pdir = opendir(path); if (chl_pdir == NULL) { if (errno != EACCES || errno != ENOENT) perror(opendir); continue; } while (chl_pdent = readdir(chl_pdir)) { } } } } int main(int argc, const char *argv[]) { kill_processes(argv[1]); return 0; }
Add some more print statements to this test, just to help differentiate the output when debugging is enabled
/* * Copyright © 2009 CNRS, INRIA, Université Bordeaux 1 * Copyright © 2009 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. */ #include <hwloc.h> #include <stdio.h> int main(int argc, char *argv[]) { mytest_hwloc_topology_t topology; unsigned depth; hwloc_cpuset_t cpu_set; /* Just call a bunch of functions to see if we can link and run */ cpu_set = mytest_hwloc_cpuset_alloc(); mytest_hwloc_topology_init(&topology); mytest_hwloc_topology_load(topology); depth = mytest_hwloc_topology_get_depth(topology); printf("Max depth: %u\n", depth); mytest_hwloc_topology_destroy(topology); mytest_hwloc_cpuset_free(cpu_set); return 0; }
/* * Copyright © 2009 CNRS, INRIA, Université Bordeaux 1 * Copyright © 2009 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. */ #include <hwloc.h> #include <stdio.h> int main(int argc, char *argv[]) { mytest_hwloc_topology_t topology; unsigned depth; hwloc_cpuset_t cpu_set; /* Just call a bunch of functions to see if we can link and run */ printf("*** Test 1: cpuset alloc\n"); cpu_set = mytest_hwloc_cpuset_alloc(); printf("*** Test 2: topology init\n"); mytest_hwloc_topology_init(&topology); printf("*** Test 3: topology load\n"); mytest_hwloc_topology_load(topology); printf("*** Test 4: topology get depth\n"); depth = mytest_hwloc_topology_get_depth(topology); printf(" Max depth: %u\n", depth); printf("*** Test 5: topology destroy\n"); mytest_hwloc_topology_destroy(topology); printf("*** Test 6: cpuset free\n"); mytest_hwloc_cpuset_free(cpu_set); return 0; }
Fix some GCC initialization warnings
#pragma once #include <vector> #include <boost/multiprecision/cpp_int.hpp> namespace dev { namespace eth { namespace jit { using byte = uint8_t; using bytes = std::vector<byte>; using u256 = boost::multiprecision::uint256_t; using bigint = boost::multiprecision::cpp_int; struct NoteChannel {}; // FIXME: Use some log library? enum class ReturnCode { Stop = 0, Return = 1, Suicide = 2, BadJumpDestination = 101, OutOfGas = 102, StackTooSmall = 103, BadInstruction = 104, LLVMConfigError = 201, LLVMCompileError = 202, LLVMLinkError = 203, }; /// Representation of 256-bit value binary compatible with LLVM i256 // TODO: Replace with h256 struct i256 { uint64_t a; uint64_t b; uint64_t c; uint64_t d; }; static_assert(sizeof(i256) == 32, "Wrong i265 size"); #define UNTESTED assert(false) } } }
#pragma once #include <vector> #include <boost/multiprecision/cpp_int.hpp> namespace dev { namespace eth { namespace jit { using byte = uint8_t; using bytes = std::vector<byte>; using u256 = boost::multiprecision::uint256_t; using bigint = boost::multiprecision::cpp_int; struct NoteChannel {}; // FIXME: Use some log library? enum class ReturnCode { Stop = 0, Return = 1, Suicide = 2, BadJumpDestination = 101, OutOfGas = 102, StackTooSmall = 103, BadInstruction = 104, LLVMConfigError = 201, LLVMCompileError = 202, LLVMLinkError = 203, }; /// Representation of 256-bit value binary compatible with LLVM i256 // TODO: Replace with h256 struct i256 { uint64_t a = 0; uint64_t b = 0; uint64_t c = 0; uint64_t d = 0; }; static_assert(sizeof(i256) == 32, "Wrong i265 size"); #define UNTESTED assert(false) } } }
Rename of Input to HandleInput
/****************************************************************************** GameState.h Game State Management Copyright (c) 2013 Jeffrey Carpenter Portions Copyright (c) 2013 Fielding Johnston ******************************************************************************/ #ifndef GAMEAPP_GAMESTATE_HEADERS #define GAMEAPP_GAMESTATE_HEADERS #include <iostream> #include <string> #include "SDL.h" #include "SDLInput.h" #include "gamelib.h" { public: virtual ~GameState(); virtual void Pause() = 0; virtual void Resume() = 0; virtual void Input ( void ) = 0; virtual void Update ( void ) = 0; virtual void Draw ( void ) = 0; private: // ... }; #endif // GAMEAPP_GAMESTATE_HEADERS defined
/****************************************************************************** GameState.h Game State Management Copyright (c) 2013 Jeffrey Carpenter Portions Copyright (c) 2013 Fielding Johnston ******************************************************************************/ #ifndef GAMEAPP_GAMESTATE_HEADERS #define GAMEAPP_GAMESTATE_HEADERS #include <iostream> #include <string> #include "SDL.h" #include "SDLInput.h" #include "gamelib.h" { public: virtual ~GameState(); virtual void Pause() = 0; virtual void Resume() = 0; virtual void HandleInput ( void ) = 0; virtual void Update ( void ) = 0; virtual void Draw ( void ) = 0; private: // ... }; #endif // GAMEAPP_GAMESTATE_HEADERS defined
Change printf format %d -> %u
#define _BSD_SOURCE #include <stdio.h> #include <arpa/inet.h> #include <netinet/ip.h> #include "config.h" #include "common.h" void printpkt(void) { struct ip *iphdr = (struct ip *) pkt; printf("ip.version=%d " "ip.ihl=%d " "ip.tos=%02x " "ip.length=%d " "ip.id=%d " "ip.flags=%d%c%c " "ip.offset=%d " "ip.ttl=%d " "ip.protocol=%d " "ip.checksum=%04x " "ip.src=%s ", iphdr->ip_v, iphdr->ip_hl, iphdr->ip_tos, iphdr->ip_len, iphdr->ip_id, iphdr->ip_off & IP_RF, flag('d', iphdr->ip_off & IP_DF), flag('m', iphdr->ip_off & IP_MF), iphdr->ip_off & IP_OFFMASK, iphdr->ip_ttl, iphdr->ip_p, iphdr->ip_sum, inet_ntoa(iphdr->ip_src)); printf("ip.dst=%s ", inet_ntoa(iphdr->ip_dst)); dumppkt(iphdr->ip_hl * 4); }
#define _BSD_SOURCE #include <stdio.h> #include <arpa/inet.h> #include <netinet/ip.h> #include "config.h" #include "common.h" void printpkt(void) { struct ip *iphdr = (struct ip *) pkt; printf("ip.version=%u " "ip.ihl=%u " "ip.tos=%02x " "ip.length=%u " "ip.id=%u " "ip.flags=%u%c%c " "ip.offset=%u " "ip.ttl=%u " "ip.protocol=%u " "ip.checksum=%04x " "ip.src=%s ", iphdr->ip_v, iphdr->ip_hl, iphdr->ip_tos, iphdr->ip_len, iphdr->ip_id, iphdr->ip_off & IP_RF, flag('d', iphdr->ip_off & IP_DF), flag('m', iphdr->ip_off & IP_MF), iphdr->ip_off & IP_OFFMASK, iphdr->ip_ttl, iphdr->ip_p, iphdr->ip_sum, inet_ntoa(iphdr->ip_src)); printf("ip.dst=%s ", inet_ntoa(iphdr->ip_dst)); dumppkt(iphdr->ip_hl * 4); }
Disable function execution for now, to focus on parsing issues
// // Wasm3 - high performance WebAssembly interpreter written in C. // // Copyright © 2019 Steven Massey, Volodymyr Shymanskyy. // All rights reserved. // #include <stdint.h> #include <stddef.h> #include "wasm3.h" #define FATAL(...) __builtin_trap() int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { M3Result result = m3Err_none; if (size < 8 || size > 256*1024) { return 0; } IM3Environment env = m3_NewEnvironment (); if (env) { IM3Runtime runtime = m3_NewRuntime (env, 128, NULL); if (runtime) { IM3Module module = NULL; result = m3_ParseModule (env, &module, data, size); if (module) { result = m3_LoadModule (runtime, module); if (result == 0) { IM3Function f = NULL; result = m3_FindFunction (&f, runtime, "fib"); if (f) { m3_CallV (f, 10); } } else { m3_FreeModule (module); } } m3_FreeRuntime(runtime); } m3_FreeEnvironment(env); } return 0; }
// // Wasm3 - high performance WebAssembly interpreter written in C. // // Copyright © 2019 Steven Massey, Volodymyr Shymanskyy. // All rights reserved. // #include <stdint.h> #include <stddef.h> #include "wasm3.h" #define FATAL(...) __builtin_trap() int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { M3Result result = m3Err_none; if (size < 8 || size > 256*1024) { return 0; } IM3Environment env = m3_NewEnvironment (); if (env) { IM3Runtime runtime = m3_NewRuntime (env, 128, NULL); if (runtime) { IM3Module module = NULL; result = m3_ParseModule (env, &module, data, size); if (module) { result = m3_LoadModule (runtime, module); if (result == 0) { IM3Function f = NULL; result = m3_FindFunction (&f, runtime, "fib"); /* TODO: if (f) { m3_CallV (f, 10); }*/ } else { m3_FreeModule (module); } } m3_FreeRuntime(runtime); } m3_FreeEnvironment(env); } return 0; }
Remove logger ids loop from sample
#ifndef MYTHREAD_H #define MYTHREAD_H #include <QThread> #include "easylogging++.h" class MyThread : public QThread { Q_OBJECT public: MyThread(int id) : threadId(id) {} private: int threadId; protected: void run() { LINFO <<"Writing from a thread " << threadId; LVERBOSE(2) << "This is verbose level 2 logging from thread #" << threadId; // Following line will be logged only once from second running thread (which every runs second into // this line because of interval 2) LWARNING_EVERY_N(2) << "This will be logged only once from thread who every reaches this line first. Currently running from thread #" << threadId; for (int i = 1; i <= 10; ++i) { LVERBOSE_EVERY_N(2, 3) << "Verbose level 3 log every two times. This is at " << i << " from thread #" << threadId; } // Following line will be logged once with every thread because of interval 1 LINFO_EVERY_N(1) << "This interval log will be logged with every thread, this one is from thread #" << threadId; LINFO_IF(threadId == 2) << "This log is only for thread 2 and is ran by thread #" << threadId; std::vector<std::string> myLoggers; easyloggingpp::Loggers::getAllLogIdentifiers(myLoggers); for (unsigned int i = 0; i < myLoggers.size(); ++i) { std::cout << "Logger ID [" << myLoggers.at(i) << "]"; } easyloggingpp::Configurations c; c.parseFromText("*ALL:\n\nFORMAT = %level"); } }; #endif
#ifndef MYTHREAD_H #define MYTHREAD_H #include <QThread> #include "easylogging++.h" class MyThread : public QThread { Q_OBJECT public: MyThread(int id) : threadId(id) {} private: int threadId; protected: void run() { LINFO <<"Writing from a thread " << threadId; LVERBOSE(2) << "This is verbose level 2 logging from thread #" << threadId; // Following line will be logged only once from second running thread (which every runs second into // this line because of interval 2) LWARNING_EVERY_N(2) << "This will be logged only once from thread who every reaches this line first. Currently running from thread #" << threadId; for (int i = 1; i <= 10; ++i) { LVERBOSE_EVERY_N(2, 3) << "Verbose level 3 log every two times. This is at " << i << " from thread #" << threadId; } // Following line will be logged once with every thread because of interval 1 LINFO_EVERY_N(1) << "This interval log will be logged with every thread, this one is from thread #" << threadId; LINFO_IF(threadId == 2) << "This log is only for thread 2 and is ran by thread #" << threadId; } }; #endif
Add tools to mark a field as never-non-zero while constructed
// Copyright 2022 Google LLC // // 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 // // https://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. #pragma once #include <stddef.h> #include "marker/unsafe.h" namespace sus::mem::layout { namespace __private { template <class T> struct layout_nonzero_tag final { static constexpr bool has_field(...) { return false; } static constexpr bool has_field(int) requires(std::is_same_v< decltype(std::declval<T>().SusUnsafeNonZeroIsNonZero()), bool>) { return true; }; static constexpr bool is_non_zero(const T* t) { return t->SusUnsafeNonZeroIsNonZero(); }; static constexpr void set_zero(T* t) { t->SusUnsafeNonZeroSetZero(); }; }; } // namespace __private template <class T> struct nonzero_field { static constexpr bool has_field = __private::layout_nonzero_tag<T>::has_field(0); static constexpr bool is_non_zero(::sus::marker::UnsafeFnMarker, const T* t) noexcept { return __private::layout_nonzero_tag<T>::is_non_zero(t); } static constexpr void set_zero(::sus::marker::UnsafeFnMarker, T* t) noexcept { __private::layout_nonzero_tag<T>::set_zero(t); } }; } // namespace sus::mem::layout /// Mark a class field as never being zero (after a constructor has run, until /// the destructor has completed). #define sus_class_nonzero_field(unsafe_fn, T, name) \ static_assert(std::is_same_v<decltype(unsafe_fn), \ const ::sus::marker::UnsafeFnMarker>); \ template <class SusOuterClassTypeForNonZeroField> \ friend struct ::sus::mem::layout::__private::layout_nonzero_tag; \ constexpr inline bool SusUnsafeNonZeroIsNonZero() const noexcept { \ static_assert(std::same_as<decltype(*this), const T&>); \ return static_cast<bool>(name); \ } \ constexpr inline void SusUnsafeNonZeroSetZero() noexcept { \ name = static_cast<decltype(name)>(0u); \ } \ static_assert(true)
Add GPIO Switch first implementation
#include <stdlib.h> #include <stdio.h> #include <iostream> #include <errno.h> int main (int argc, char* argv[]){ if (argc < 2){ printf("Error, missing arguments\n"); printf("Convention: \n"); printf("./gpio_switch pin value\n"); return EXIT_SUCCESS; }else{ int valueFile; char refPath[256]; sprintf(refPath, "/sys/class/gpio/gpio%s", argv[2]); char valuePath[256]; sprintf(valuePath, "%s/value", refPath); if ((valueFile = open(valuePath)) < 0) { if (errno == ENOENT){ int exportFile; if ((exportFile = open("/sys/class/gpio/export", O_WRONLY)) < 0){ return EXIT_FAILURE; } write(exportFile, argv[1], sizeof(argv[1])); close(exportFile); char directionPath[256]; sprintf(directionPath, "%s/direction", refPath); int directionFile = open(directionPath, O_WRONLY); char* direction = "out"; write(directionFile, direction, sizeof(direction)); close(directionFile); }else{ return EXIT_FAILURE; } } write(valuePath, argv[2], sizeof(argv[2])); close(valueFile); } }
Fix do_isfile to support symbolic links on Windows.
/** * \file os_isfile.c * \brief Returns true if the given file exists on the file system. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project */ #include <sys/stat.h> #include "premake.h" int os_isfile(lua_State* L) { const char* filename = luaL_checkstring(L, 1); lua_pushboolean(L, do_isfile(filename)); return 1; } int do_isfile(const char* filename) { struct stat buf; if (stat(filename, &buf) == 0) { return ((buf.st_mode & S_IFDIR) == 0); } else { return 0; } }
/** * \file os_isfile.c * \brief Returns true if the given file exists on the file system. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project */ #include <sys/stat.h> #include "premake.h" int os_isfile(lua_State* L) { const char* filename = luaL_checkstring(L, 1); lua_pushboolean(L, do_isfile(filename)); return 1; } int do_isfile(const char* filename) { struct stat buf; #if PLATFORM_WINDOWS DWORD attrib = GetFileAttributesA(filename); if (attrib != INVALID_FILE_ATTRIBUTES) { return (attrib & FILE_ATTRIBUTE_DIRECTORY) == 0; } #else if (stat(filename, &buf) == 0) { return ((buf.st_mode & S_IFDIR) == 0); } #endif return 0; }
Use a fresh version number for the trunk version
// KMail Version Information // #ifndef kmversion_h #define kmversion_h #define KMAIL_VERSION "1.8.91" #endif /*kmversion_h*/
// KMail Version Information // #ifndef kmversion_h #define kmversion_h #define KMAIL_VERSION "1.9.50" #endif /*kmversion_h*/
Use a deque instead of a list as inner cache in nested loop.
#pragma once #include <annis/types.h> #include <annis/graphstorage/graphstorage.h> #include <annis/db.h> #include <annis/iterators.h> namespace annis { class Operator; /** * A join that checks all combinations of the left and right matches if their are connected. * * @param lhsIdx the column of the LHS tuple to join on * @param rhsIdx the column of the RHS tuple to join on */ class NestedLoopJoin : public Iterator { public: NestedLoopJoin(std::shared_ptr<Operator> op, std::shared_ptr<Iterator> lhs, std::shared_ptr<Iterator> rhs, size_t lhsIdx, size_t rhsIdx, bool materializeInner=true, bool leftIsOuter=true); virtual ~NestedLoopJoin(); virtual bool next(std::vector<Match>& tuple) override; virtual void reset() override; private: std::shared_ptr<Operator> op; const bool materializeInner; const bool leftIsOuter; bool initialized; std::vector<Match> matchOuter; std::vector<Match> matchInner; std::shared_ptr<Iterator> outer; std::shared_ptr<Iterator> inner; const size_t outerIdx; const size_t innerIdx; bool firstOuterFinished; std::list<std::vector<Match>> innerCache; std::list<std::vector<Match>>::const_iterator itInnerCache; private: bool fetchNextInner(); }; } // end namespace annis
#pragma once #include <annis/types.h> #include <annis/graphstorage/graphstorage.h> #include <annis/db.h> #include <annis/iterators.h> #include <deque> namespace annis { class Operator; /** * A join that checks all combinations of the left and right matches if their are connected. * * @param lhsIdx the column of the LHS tuple to join on * @param rhsIdx the column of the RHS tuple to join on */ class NestedLoopJoin : public Iterator { public: NestedLoopJoin(std::shared_ptr<Operator> op, std::shared_ptr<Iterator> lhs, std::shared_ptr<Iterator> rhs, size_t lhsIdx, size_t rhsIdx, bool materializeInner=true, bool leftIsOuter=true); virtual ~NestedLoopJoin(); virtual bool next(std::vector<Match>& tuple) override; virtual void reset() override; private: std::shared_ptr<Operator> op; const bool materializeInner; const bool leftIsOuter; bool initialized; std::vector<Match> matchOuter; std::vector<Match> matchInner; std::shared_ptr<Iterator> outer; std::shared_ptr<Iterator> inner; const size_t outerIdx; const size_t innerIdx; bool firstOuterFinished; std::deque<std::vector<Match>> innerCache; std::deque<std::vector<Match>>::const_iterator itInnerCache; private: bool fetchNextInner(); }; } // end namespace annis
Add test with inconsistent IntDomain crash
// PARAM: --enable ana.int.def_exc --enable ana.int.interval --enable ana.sv-comp.functions --set sem.int.signed_overflow assume_none --set ana.int.refinement never // used to crash in branch when is_bool returned true, but to_bool returned None on (0,[1,1]) // manually minimized from sv-benchmarks/c/recursive/MultCommutative-2.c extern int __VERIFIER_nondet_int(void); void f(int m) { if (m < 0) { f(-m); } if (m == 0) { return; } f(m - 1); } int main() { int m = __VERIFIER_nondet_int(); if (m < 0 || m > 1) { return 0; } f(m); // m=[0,1] return 0; }
Use extern C if C++
#ifndef PATHFINDER_H_DEF #define PATHFINDER_H_DEF #include "pathfinder/mathutil.h" #include "pathfinder/structs.h" #include "pathfinder/fit.h" #include "pathfinder/spline.h" #include "pathfinder/trajectory.h" #include "pathfinder/modifiers/tank.h" #include "pathfinder/modifiers/swerve.h" #include "pathfinder/followers/encoder.h" #include "pathfinder/followers/distance.h" #include "pathfinder/io.h" #endif
#ifndef PATHFINDER_H_DEF #define PATHFINDER_H_DEF #ifdef __cplusplus extern "C" { #endif #include "pathfinder/mathutil.h" #include "pathfinder/structs.h" #include "pathfinder/fit.h" #include "pathfinder/spline.h" #include "pathfinder/trajectory.h" #include "pathfinder/modifiers/tank.h" #include "pathfinder/modifiers/swerve.h" #include "pathfinder/followers/encoder.h" #include "pathfinder/followers/distance.h" #include "pathfinder/io.h" #ifdef __cplusplus } #endif #endif
Add regression test where known functions in unknown AD should be spawned
#include <pthread.h> #include <assert.h> void foo() { assert(1); } void bar() { assert(1); } void (*funs[2])() = { &foo, &bar }; extern void magic1(); extern void magic2(void (*funs[])()); void *t_fun(void *arg) { // just for going to multithreaded mode return NULL; } int main() { pthread_t id; pthread_create(&id, NULL, t_fun, NULL); // enter multithreaded mode magic1(); // invalidate funs a bit magic2(funs); return 0; }
Add unsigned eq emits spurious underflow warning
// PARAM: --enable ana.int.interval #include <assert.h> int main() { unsigned long x; x = 0; int b; b = x == 7; // NOWARN if (b) assert(0); // NOWARN (unreachable) else assert(1); // reachable return 0; }
Append node to end of the list.
#include<stdio.h> #include"listHelper.h" void makeNode(struct linkList **head, struct linkList **tail, int dat) { struct linkList *curr; curr = (struct linkList*)malloc(sizeof(struct linkList)); curr->data = dat; curr->next = NULL; if(*head == NULL) *head = *tail = curr; else { (*tail)->next = curr; *tail = curr; } } void main() { int dat; struct linkList *head, *tail; tail = head = NULL; for (dat = 1; dat <= 21; dat++) makeNode(&head, &tail, dat); displayList(head); displayList(head); free(head); }
Implement vectorEffect nonScalingStroke / non-scaling-stroke
/** * Copyright (c) 2015-present, react-native-community. * All rights reserved. * * This source code is licensed under the MIT-style license found in the * LICENSE file in the root directory of this source tree. */ typedef CF_ENUM(int32_t, RNSVGVectorEffect) { kRNSVGVectorEffectDefault, kRNSVGVectorEffectNonScalingStroke, kRNSVGVectorEffectInherit, kRNSVGVectorEffectUri };
Fix osx build (this is going to be removed soon anyways)
#ifndef __SYS_TYPES_H__ #define __SYS_TYPES_H__ 1 #include <MacTypes.h> #include <alloca.h> #include <string.h> typedef short int16_t; typedef long int32_t; typedef long long int64_t; #define vorbis_size32_t long #if defined(__cplusplus) extern "C" { #endif #pragma options align=power char *strdup(const char *inStr); #pragma options align=reset #if defined(__cplusplus) } #endif #endif /* __SYS_TYPES_H__ */
#ifndef __SYS_TYPES_H__ #define __SYS_TYPES_H__ 1 #include <MacTypes.h> #include <alloca.h> #include <string.h> typedef short int16_t; // typedef long int32_t; typedef long long int64_t; #define vorbis_size32_t long #if defined(__cplusplus) extern "C" { #endif #pragma options align=power char *strdup(const char *inStr); #pragma options align=reset #if defined(__cplusplus) } #endif #endif /* __SYS_TYPES_H__ */
Replace inline with static inline to enable DEBUG build (linking actually)
#ifndef PZLIB_H #define PZLIB_H typedef unsigned int psize_type; typedef int pssize_type; typedef pssize_type writerfunc(void *cookie, const void *buf, psize_type len); typedef void closefunc(void*); struct pz { writerfunc *wf; closefunc *cf; }; inline pssize_type do_write(void *cookie, const void *buf, psize_type len) { struct pz* p = (struct pz*)cookie; return (p->wf)(cookie, buf, len); } inline void do_close(void *cookie) { struct pz* p = (struct pz*)cookie; (p->cf)(cookie); } #ifdef __cplusplus extern "C" { #endif void *make_fd(int fd); extern writerfunc write_fd; extern closefunc free_fd; #ifdef __cplusplus } #endif #endif
#ifndef PZLIB_H #define PZLIB_H typedef unsigned int psize_type; typedef int pssize_type; typedef pssize_type writerfunc(void *cookie, const void *buf, psize_type len); typedef void closefunc(void*); struct pz { writerfunc *wf; closefunc *cf; }; static inline pssize_type do_write(void *cookie, const void *buf, psize_type len) { struct pz* p = (struct pz*)cookie; return (p->wf)(cookie, buf, len); } static inline void do_close(void *cookie) { struct pz* p = (struct pz*)cookie; (p->cf)(cookie); } #ifdef __cplusplus extern "C" { #endif void *make_fd(int fd); extern writerfunc write_fd; extern closefunc free_fd; #ifdef __cplusplus } #endif #endif
Add helper function Queue empty implementation
#include "queue.h" struct Queue { size_t head; size_t tail; size_t size; void** e; }; Queue* Queue_Create(size_t n) { Queue* q = (Queue *)malloc(sizeof(Queue)); q->size = n; q->head = q->tail = 1; q->e = (void **)malloc(sizeof(void*) * (n + 1)); return q; }
#include "queue.h" struct Queue { size_t head; size_t tail; size_t size; void** e; }; Queue* Queue_Create(size_t n) { Queue* q = (Queue *)malloc(sizeof(Queue)); q->size = n; q->head = q->tail = 1; q->e = (void **)malloc(sizeof(void*) * (n + 1)); return q; } int Queue_Empty(Queue* q) { return (q->head == q->tail); }
Fix mispelled separate compilation macro.
#ifndef _NPY_PRIVATE_BUFFER_H_ #define _NPY_PRIVATE_BUFFER_H_ #ifdef NPY_ENABLE_MULTIPLE_COMPILATION extern NPY_NO_EXPORT PyBufferProcs array_as_buffer; #else NPY_NO_EXPORT PyBufferProcs array_as_buffer; #endif #endif
#ifndef _NPY_PRIVATE_BUFFER_H_ #define _NPY_PRIVATE_BUFFER_H_ #ifdef NPY_ENABLE_SEPARATE_COMPILATION extern NPY_NO_EXPORT PyBufferProcs array_as_buffer; #else NPY_NO_EXPORT PyBufferProcs array_as_buffer; #endif #endif
Add cast to uint16_t in CRC function
#include "modlib.h" uint16_t MODBUSSwapEndian( uint16_t Data ) { //Change big-endian to little-endian and vice versa uint8_t Swap; //Create 2 bytes long union union Conversion { uint16_t Data; uint8_t Bytes[2]; } Conversion; //Swap bytes Conversion.Data = Data; Swap = Conversion.Bytes[0]; Conversion.Bytes[0] = Conversion.Bytes[1]; Conversion.Bytes[1] = Swap; return Conversion.Data; } uint16_t MODBUSCRC16( uint8_t *Data, uint16_t Length ) { //Calculate CRC16 checksum using given data and length uint16_t CRC = 0xFFFF; uint16_t i; uint8_t j; for ( i = 0; i < Length; i++ ) { CRC ^= Data[i]; //XOR current data byte with CRC value for ( j = 8; j != 0; j-- ) { //For each bit //Is least-significant-bit is set? if ( ( CRC & 0x0001 ) != 0 ) { CRC >>= 1; //Shift to right and xor CRC ^= 0xA001; } else CRC >>= 1; } } return CRC; }
#include "modlib.h" uint16_t MODBUSSwapEndian( uint16_t Data ) { //Change big-endian to little-endian and vice versa uint8_t Swap; //Create 2 bytes long union union Conversion { uint16_t Data; uint8_t Bytes[2]; } Conversion; //Swap bytes Conversion.Data = Data; Swap = Conversion.Bytes[0]; Conversion.Bytes[0] = Conversion.Bytes[1]; Conversion.Bytes[1] = Swap; return Conversion.Data; } uint16_t MODBUSCRC16( uint8_t *Data, uint16_t Length ) { //Calculate CRC16 checksum using given data and length uint16_t CRC = 0xFFFF; uint16_t i; uint8_t j; for ( i = 0; i < Length; i++ ) { CRC ^= (uint16_t) Data[i]; //XOR current data byte with CRC value for ( j = 8; j != 0; j-- ) { //For each bit //Is least-significant-bit is set? if ( ( CRC & 0x0001 ) != 0 ) { CRC >>= 1; //Shift to right and xor CRC ^= 0xA001; } else CRC >>= 1; } } return CRC; }
Fix minimum version to one that exists in 10.5
#import <Cocoa/Cocoa.h> #include <gtk/gtk.h> #if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) @interface _GNSMenuDelegate : NSObject <NSMenuDelegate> {} #else @interface _GNSMenuDelegate : NSObject {} #endif @end
#import <Cocoa/Cocoa.h> #include <gtk/gtk.h> #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) @interface _GNSMenuDelegate : NSObject <NSMenuDelegate> {} #else @interface _GNSMenuDelegate : NSObject {} #endif @end
Change logger define to namespace stone function
#ifndef lilthumb #define lilthumb #include <ctime> namespace lilthumb{ std::string timeString() { time_t rawtime; struct tm * timeinfo; char buffer[80]; time (&rawtime); timeinfo = localtime(&rawtime); strftime(buffer,80,"%d-%m-%Y %I:%M:%S",timeinfo); std::string str(buffer); return str; } } #define logger(stream,message) stream << lilthumb::timeString() << " | "<< message << std::endl; #endif
#ifndef lilthumb #define lilthumb #include <ctime> #include <ostream> namespace lilthumb{ std::string timeString() { time_t rawtime; struct tm * timeinfo; char buffer[80]; time (&rawtime); timeinfo = localtime(&rawtime); strftime(buffer,80,"%d-%m-%Y %I:%M:%S",timeinfo); std::string str(buffer); return str; } void stone( std::ostream& stream, std::string message ) { stream << timeString() << " | " << message << std::endl; } } #endif
Add motes_abp and motes_otaa link list structure definition.
#ifndef __LWP_CONFIG_H #define __LWP_CONFIG_H #include <stdint.h> #include <stdbool.h> typedef enum{ CFLAG_NWKSKEY = (1<<0), CFLAG_APPSKEY = (1<<1), CFLAG_APPKEY = (1<<2), CFLAG_JOINR = (1<<3), CFLAG_JOINA = (1<<4), }config_flag_t; typedef struct message{ uint8_t *buf; int16_t len; struct message *next; }message_t; typedef struct{ uint32_t flag; uint8_t nwkskey[16]; uint8_t appskey[16]; uint8_t appkey[16]; uint8_t band; bool joinkey; uint8_t *joinr; uint8_t joinr_size; uint8_t *joina; uint8_t joina_size; message_t *message; message_t *maccmd; }config_t; int config_parse(const char *file, config_t *config); void config_free(config_t *config); #endif // __CONFIG_H
#ifndef __LWP_CONFIG_H #define __LWP_CONFIG_H #include <stdint.h> #include <stdbool.h> typedef enum{ CFLAG_NWKSKEY = (1<<0), CFLAG_APPSKEY = (1<<1), CFLAG_APPKEY = (1<<2), CFLAG_JOINR = (1<<3), CFLAG_JOINA = (1<<4), }config_flag_t; typedef struct message{ uint8_t *buf; int16_t len; struct message *next; }message_t; typedef struct motes_abp{ uint8_t band; uint8_t devaddr[4]; uint8_t nwkskey[16]; uint8_t appskey[16]; struct message *next; }motes_abp_t; typedef struct motes_abp{ uint8_t band; uint8_t devaddr[4]; uint8_t nwkskey[16]; uint8_t appskey[16]; struct message *next; }motes_abp_t; typedef struct{ uint32_t flag; uint8_t nwkskey[16]; uint8_t appskey[16]; uint8_t appkey[16]; uint8_t band; bool joinkey; uint8_t *joinr; uint8_t joinr_size; uint8_t *joina; uint8_t joina_size; message_t *message; message_t *maccmd; }config_t; int config_parse(const char *file, config_t *config); void config_free(config_t *config); #endif // __CONFIG_H
Add missing header method declarations.
//--------------------------------------------------------------------*- C++ -*- // CLING - the C++ LLVM-based InterpreterG :) // version: $Id$ // author: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch> //------------------------------------------------------------------------------ #ifndef CLING_RUNTIME_EXCEPTIONS_H #define CLING_RUNTIME_EXCEPTIONS_H namespace cling { namespace runtime { ///\brief Exception that is thrown when a null pointer dereference is found /// or a method taking non-null arguments is called with NULL argument. /// class cling_null_deref_exception { }; } // end namespace runtime } // end namespace cling #endif // CLING_RUNTIME_EXCEPTIONS_H
//--------------------------------------------------------------------*- C++ -*- // CLING - the C++ LLVM-based InterpreterG :) // version: $Id$ // author: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch> //------------------------------------------------------------------------------ #ifndef CLING_RUNTIME_EXCEPTIONS_H #define CLING_RUNTIME_EXCEPTIONS_H namespace clang { class Sema; } namespace cling { namespace runtime { ///\brief Exception that is thrown when a null pointer dereference is found /// or a method taking non-null arguments is called with NULL argument. /// class cling_null_deref_exception { private: unsigned m_Location; clang::Sema* m_Sema; public: cling_null_deref_exception(void* Loc, clang::Sema* S); ~cling_null_deref_exception(); void what() throw(); }; } // end namespace runtime } // end namespace cling #endif // CLING_RUNTIME_EXCEPTIONS_H
Fix typo spotted by Nico Weber.
//===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // AST Consumers. // //===----------------------------------------------------------------------===// #ifndef REWRITE_ASTCONSUMERS_H #define REWRITE_ASTCONSUMERS_H #include <string> namespace llvm { class raw_ostream; } namespace clang { class ASTConsumer; class Diagnostic; class LangOptions; class Preprocessor; // ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code. // This is considered experimental, and only works with Apple's ObjC runtime. ASTConsumer *CreateObjCRewriter(const std::string &InFile, llvm::raw_ostream *OS, Diagnostic &Diags, const LangOptions &LOpts, bool SilenceRewriteMacroWarning); /// CreateHTMLPrinter - Create an AST consumer which rewrites source code to /// HTML with syntax highlighting suitable for viewing in a web-browser. ASTConsumer *CreateHTMLPrinter(llvm::raw_ostream *OS, Preprocessor &PP, bool SyntaxHighlight = true, bool HighlightMacros = true); } // end clang namespace #endif
//===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // AST Consumers. // //===----------------------------------------------------------------------===// #ifndef REWRITE_ASTCONSUMERS_H #define REWRITE_ASTCONSUMERS_H #include <string> namespace llvm { class raw_ostream; } namespace clang { class ASTConsumer; class Diagnostic; class LangOptions; class Preprocessor; // ObjC rewriter: attempts to rewrite ObjC constructs into pure C code. // This is considered experimental, and only works with Apple's ObjC runtime. ASTConsumer *CreateObjCRewriter(const std::string &InFile, llvm::raw_ostream *OS, Diagnostic &Diags, const LangOptions &LOpts, bool SilenceRewriteMacroWarning); /// CreateHTMLPrinter - Create an AST consumer which rewrites source code to /// HTML with syntax highlighting suitable for viewing in a web-browser. ASTConsumer *CreateHTMLPrinter(llvm::raw_ostream *OS, Preprocessor &PP, bool SyntaxHighlight = true, bool HighlightMacros = true); } // end clang namespace #endif
Disable db upgrade code for the moment.
/* Uncomment to compile with tcpd/libwrap support. */ //#define WITH_WRAP /* Compile with database upgrading support? If disabled, mosquitto won't * automatically upgrade old database versions. */ #define WITH_DB_UPGRADE /* Compile with memory tracking support? If disabled, mosquitto won't track * heap memory usage nor export '$SYS/broker/heap/current size', but will use * slightly less memory and CPU time. */ #define WITH_MEMORY_TRACKING
/* Uncomment to compile with tcpd/libwrap support. */ //#define WITH_WRAP /* Compile with database upgrading support? If disabled, mosquitto won't * automatically upgrade old database versions. */ //#define WITH_DB_UPGRADE /* Compile with memory tracking support? If disabled, mosquitto won't track * heap memory usage nor export '$SYS/broker/heap/current size', but will use * slightly less memory and CPU time. */ #define WITH_MEMORY_TRACKING
Add a triple to this test and make sure it passes on arm where it was supposed to.
// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s // PR 5406 // XFAIL: * // XTARGET: arm typedef struct { char x[3]; } A0; void foo (int i, ...); // CHECK: call void (i32, ...)* @foo(i32 1, i32 {{.*}}) nounwind int main (void) { A0 a3; a3.x[0] = 0; a3.x[0] = 0; a3.x[2] = 26; foo (1, a3 ); return 0; }
// RUN: %clang_cc1 %s -emit-llvm -triple arm-apple-darwin -o - | FileCheck %s // PR 5406 typedef struct { char x[3]; } A0; void foo (int i, ...); // CHECK: call arm_aapcscc void (i32, ...)* @foo(i32 1, [1 x i32] {{.*}}) int main (void) { A0 a3; a3.x[0] = 0; a3.x[0] = 0; a3.x[2] = 26; foo (1, a3 ); return 0; }
Add framework timer code from Pebble feature_timer demo app
#include "pebble_os.h" #include "pebble_app.h" #include "pebble_fonts.h" #define MY_UUID { 0x78, 0x1D, 0x21, 0x66, 0x09, 0x09, 0x4F, 0x9C, 0x88, 0xFD, 0x89, 0x9B, 0x04, 0xBF, 0x5E, 0x32 } PBL_APP_INFO(MY_UUID, "Pomade", "Jon Speicher", 0, 1, /* App version */ DEFAULT_MENU_ICON, APP_INFO_STANDARD_APP); Window window; void handle_init(AppContextRef ctx) { window_init(&window, "Pomade"); window_stack_push(&window, true /* Animated */); } void pbl_main(void *params) { PebbleAppHandlers handlers = { .init_handler = &handle_init }; app_event_loop(params, &handlers); }
#include "pebble_os.h" #include "pebble_app.h" #include "pebble_fonts.h" #define MY_UUID { 0x78, 0x1D, 0x21, 0x66, 0x09, 0x09, 0x4F, 0x9C, 0x88, 0xFD, 0x89, 0x9B, 0x04, 0xBF, 0x5E, 0x32 } PBL_APP_INFO(MY_UUID, "Pomade", "Jon Speicher", 0, 1, /* App version */ DEFAULT_MENU_ICON, APP_INFO_STANDARD_APP); Window window; TextLayer timerLayer; AppTimerHandle timer_handle; #define COOKIE_MY_TIMER 1 void handle_timer(AppContextRef ctx, AppTimerHandle handle, uint32_t cookie) { if (cookie == COOKIE_MY_TIMER) { text_layer_set_text(&timerLayer, "Timer happened!"); } // If you want the timer to run again you need to call `app_timer_send_event()` // again here. } void handle_init(AppContextRef ctx) { window_init(&window, "Pomade"); window_stack_push(&window, true /* Animated */); text_layer_init(&timerLayer, window.layer.frame); text_layer_set_text(&timerLayer, "Waiting for timer..."); layer_add_child(&window.layer, &timerLayer.layer); timer_handle = app_timer_send_event(ctx, 1500 /* milliseconds */, COOKIE_MY_TIMER); } void pbl_main(void *params) { PebbleAppHandlers handlers = { .init_handler = &handle_init, .timer_handler = &handle_timer }; app_event_loop(params, &handlers); }
Add header file for linked list queue
/* * Copyright 2017 Brandon Yannoni * * 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 LINKED_LIST_QUEUE_H #define LINKED_LIST_QUEUE_H #include <pthread.h> #include "../function_queue.h" #include "../qterror.h" /* * This structure is a linked list node structure for function queue * elements. */ struct fqellnode { struct function_queue_element element; /* the element value */ struct fqellnode* next; /* the address of the next node */ }; /* * This structure is used to store the function queue elements and any * persistant data necessary for the manipulation procedures. */ struct fqlinkedlist { struct fqellnode* head; /* a pointer to the head of the list */ struct fqellnode* tail; /* a pointer to the tail of the list */ size_t size; /* current number of elements */ }; extern const struct fqdispatchtable fqdispatchtablell; #endif
Add function.toString() and source code if --debug
namespace NJS::Class { class Function { public: int cnt = 0; string code = "[native code]"; void Delete(); Function(void *_f); void *__NJS_VALUE; vector<pair<const char *, NJS::VAR>> __OBJECT; template <class... Args> NJS::VAR operator()(Args... args); explicit NJS::Class::Function::operator std::string() const { return "function () { " + code + " }"; } }; } // namespace NJS::CLASS
namespace NJS::Class { class Function { public: int cnt = 0; string code = "[native code]"; void Delete(); Function(void *_f); void *__NJS_VALUE; vector<pair<const char *, NJS::VAR>> __OBJECT; template <class... Args> NJS::VAR operator()(Args... args); explicit operator std::string() const { return "function () { " + code + " }"; } }; } // namespace NJS::CLASS
Add missing file. Oops :(
// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. #ifndef WEBKIT_GLUE_SCREEN_INFO_H_ #define WEBKIT_GLUE_SCREEN_INFO_H_ #include "base/gfx/rect.h" namespace webkit_glue { struct ScreenInfo { int depth; int depth_per_component; bool is_monochrome; gfx::Rect rect; gfx::Rect available_rect; }; } // namespace webkit_glue #endif // WEBKIT_GLUE_SCREEN_INFO_H_
Implement the inverse sine function.
#include <pal.h> /** * * Caclulates the inverse sine (arc sine) of the argument 'a'. Arguments must be * in the range -1 to 1. The function does not check for illegal input values. * Results are in the range -pi/2 to pi/2. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @return None * */ #include <math.h> void p_asin_f32(const float *a, float *c, int n) { int i; for (i = 0; i < n; i++) { *(c + i) = asinf(*(a + i)); } }
#include <math.h> #include <pal.h> static const float pi_2 = (float) M_PI / 2.f; /* * 0 <= x <= 1 * asin x = pi/2 - (1 - x)^(1/2) * (a0 + a1 * x + ... + a3 * x^3) + e(x) * |e(x)| <= 5 * 10^-5 */ static inline float __p_asin_pos(const float x) { const float a0 = 1.5707288f; const float a1 = -0.2121144f; const float a2 = 0.0742610f; const float a3 = -0.0187293f; float a_ = 1.f - x; float a; p_sqrt_f32(&a_, &a, 1); return pi_2 - a * (a0 + a1 * x + a2 * x * x + a3 * x * x * x); } /* * -1 <= x <= 1 * asin(-x) = - asin x */ static inline float _p_asin(const float x) { if (x >= 0.f) return __p_asin_pos(x); else return -1.f * __p_asin_pos(-x); } /** * * Caclulates the inverse sine (arc sine) of the argument 'a'. Arguments must be * in the range -1 to 1. The function does not check for illegal input values. * Results are in the range -pi/2 to pi/2. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @return None * */ void p_asin_f32(const float *a, float *c, int n) { int i; for (i = 0; i < n; i++) { c[i] = _p_asin(a[i]); } }
Add --nocolor to more programs
/* * @file _usage.h * @brief standardize help/usage output across all our programs * @internal * * Copyright 2007 Gentoo Foundation * Released under the GPLv2 */ #define getoptstring_COMMON "Ch" #define longopts_COMMON \ { "help", 0, NULL, 'h'}, \ { "nocolor", 0, NULL, 'C'}, #define case_RC_COMMON_GETOPT \ case 'C': setenv ("RC_NOCOLOR", "yes", 1); break; \ case 'h': usage (EXIT_SUCCESS); \ default: usage (EXIT_FAILURE);
Adjust a test case and make it more jump optimization neutral for JIT case.
/*- * Test 0083: Check that the last instruction is BPF_RET. * * $FreeBSD$ */ /* BPF program */ struct bpf_insn pc[] = { BPF_JUMP(BPF_JMP+BPF_JA, 0, 0, 0), }; /* Packet */ u_char pkt[] = { 0x00, }; /* Packet length seen on wire */ u_int wirelen = sizeof(pkt); /* Packet length passed on buffer */ u_int buflen = sizeof(pkt); /* Invalid instruction */ int invalid = 1; /* Expected return value */ u_int expect = 0; /* Expected signal */ #ifdef BPF_JIT_COMPILER int expect_signal = SIGSEGV; #else int expect_signal = SIGABRT; #endif
/*- * Test 0083: Check that the last instruction is BPF_RET. * * $FreeBSD$ */ /* BPF program */ struct bpf_insn pc[] = { BPF_STMT(BPF_LD|BPF_IMM, 0), }; /* Packet */ u_char pkt[] = { 0x00, }; /* Packet length seen on wire */ u_int wirelen = sizeof(pkt); /* Packet length passed on buffer */ u_int buflen = sizeof(pkt); /* Invalid instruction */ int invalid = 1; /* Expected return value */ u_int expect = 0; /* Expected signal */ #ifdef BPF_JIT_COMPILER int expect_signal = SIGSEGV; #else int expect_signal = SIGABRT; #endif
Add enough space in DNS cache for IPV6
/* Copyright 2016 Vanderbilt University 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. */ #pragma once #ifndef ACCRE_DNS_CACHE_H_INCLUDED #define ACCRE_DNS_CACHE_H_INCLUDED #include "tbx/toolbox_visibility.h" #ifdef __cplusplus extern "C" { #endif // Functions TBX_API int tbx_dnsc_lookup(const char * name, char * byte_addr, char * ip_addr); TBX_API int tbx_dnsc_shutdown(); TBX_API int tbx_dnsc_startup(); TBX_API int tbx_dnsc_startup_sized(int size); // Preprocessor macros #define DNS_ADDR_MAX 4 #define DNS_IPV4 0 #define DNS_IPV6 1 #ifdef __cplusplus } #endif #endif
/* Copyright 2016 Vanderbilt University 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. */ #pragma once #ifndef ACCRE_DNS_CACHE_H_INCLUDED #define ACCRE_DNS_CACHE_H_INCLUDED #include "tbx/toolbox_visibility.h" #ifdef __cplusplus extern "C" { #endif // Functions TBX_API int tbx_dnsc_lookup(const char * name, char * byte_addr, char * ip_addr); TBX_API int tbx_dnsc_shutdown(); TBX_API int tbx_dnsc_startup(); TBX_API int tbx_dnsc_startup_sized(int size); // Preprocessor macros #define DNS_ADDR_MAX 16 #define DNS_IPV4 0 #define DNS_IPV6 1 #ifdef __cplusplus } #endif #endif
Add crc32 and identity hash functions
// SPDX-License-Identifier: Apache-2.0 // Copyright 2021 Eotvos Lorand University, Budapest, Hungary #include "dpdk_model_v1model.h" #include "util_packet.h" #include "util_debug.h" #include "dpdk_lib.h" #include "stateful_memory.h" #include <rte_ip.h> void hash(uint16_t* result, enum_HashAlgorithm_t hash, uint16_t base, uint8_buffer_t data, uint32_t max, SHORT_STDPARAMS) { debug(" : Executing hash\n"); }
// SPDX-License-Identifier: Apache-2.0 // Copyright 2021 Eotvos Lorand University, Budapest, Hungary #include "dpdk_model_v1model.h" #include "util_packet.h" #include "util_debug.h" #include "dpdk_lib.h" #include "stateful_memory.h" #include "rte_hash_crc.h" #include <rte_ip.h> void hash(uint16_t* result, enum_HashAlgorithm_t hash, uint16_t base, uint8_buffer_t data, uint32_t max, SHORT_STDPARAMS) { debug(" : Executing hash\n"); dbg_bytes(data.buffer, data.buffer_size, " Input: " T4LIT(%d) " bytes: ", data.buffer_size); if (hash == enum_HashAlgorithm_crc32){ uint32_t crc32_result = rte_hash_crc(data.buffer, data.buffer_size, 0xffffffff); memcpy(result, &crc32_result, 4); } else if (hash == enum_HashAlgorithm_identity) { memcpy(result, data.buffer, data.buffer_size > 8 ? 8 : data.buffer_size); } else { debug(" : Unkown hashing method!\n"); } dbg_bytes(result, 4, " Result:"); }
Add support for pushing ints to the stack.
#include <stdlib.h> #include <stdio.h> #include <string.h> void runStep(struct stack_node node, struct stack_node *top) { switch( node.data.type ) { case 0: struct stack_node push; push.cdr = top; push.data = node.data; *top = push; break; } }
Add a factory for Producer<Byte>
#include "ByteProducer.h" static void _start (struct ByteProducerInternal *self, struct ByteListenerInternal *listener) { ByteProducer *producer = (ByteProducer *) self; producer->start (producer, (ByteListener *) listener); } static void _stop (struct ByteProducerInternal *self) { ByteProducer *producer = (ByteProducer *) self; producer->stop (producer); }; ByteProducer *byte_producer_create (byte_producer_start start, byte_producer_stop stop) { ByteProducer *producer = xmalloc (sizeof (ByteProducer)); producer->start = start; producer->stop = stop; producer->_start = _start; producer->_stop = _stop; return producer; }
Address compiler warning - unused variable
{ struct RClass *Control_class = mrb_define_class_under(mrb, UI_module(mrb), "Control", mrb->object_class); #define CONTROL_SUBCLASS(name) { struct RClass* subclass = mrb_define_class_under(mrb, UI_module(mrb), #name, Control_class); } CONTROL_SUBCLASS(Area) CONTROL_SUBCLASS(Box) CONTROL_SUBCLASS(Button) CONTROL_SUBCLASS(Checkbox) CONTROL_SUBCLASS(ColorButton) CONTROL_SUBCLASS(Combobox) CONTROL_SUBCLASS(DateTimePicker) CONTROL_SUBCLASS(EditableCombobox) CONTROL_SUBCLASS(Entry) CONTROL_SUBCLASS(FontButton) CONTROL_SUBCLASS(Form) CONTROL_SUBCLASS(Grid) CONTROL_SUBCLASS(Group) CONTROL_SUBCLASS(Label) CONTROL_SUBCLASS(MultilineEntry) CONTROL_SUBCLASS(ProgressBar) CONTROL_SUBCLASS(RadioButtons) CONTROL_SUBCLASS(Separator) CONTROL_SUBCLASS(Slider) CONTROL_SUBCLASS(Spinbox) CONTROL_SUBCLASS(Tab) CONTROL_SUBCLASS(Window) #undef CONTROL_SUBCLASS }
{ struct RClass *Control_class = mrb_define_class_under(mrb, UI_module(mrb), "Control", mrb->object_class); #define CONTROL_SUBCLASS(name) { mrb_define_class_under(mrb, UI_module(mrb), #name, Control_class); } CONTROL_SUBCLASS(Area) CONTROL_SUBCLASS(Box) CONTROL_SUBCLASS(Button) CONTROL_SUBCLASS(Checkbox) CONTROL_SUBCLASS(ColorButton) CONTROL_SUBCLASS(Combobox) CONTROL_SUBCLASS(DateTimePicker) CONTROL_SUBCLASS(EditableCombobox) CONTROL_SUBCLASS(Entry) CONTROL_SUBCLASS(FontButton) CONTROL_SUBCLASS(Form) CONTROL_SUBCLASS(Grid) CONTROL_SUBCLASS(Group) CONTROL_SUBCLASS(Label) CONTROL_SUBCLASS(MultilineEntry) CONTROL_SUBCLASS(ProgressBar) CONTROL_SUBCLASS(RadioButtons) CONTROL_SUBCLASS(Separator) CONTROL_SUBCLASS(Slider) CONTROL_SUBCLASS(Spinbox) CONTROL_SUBCLASS(Tab) CONTROL_SUBCLASS(Window) #undef CONTROL_SUBCLASS }
Declare the properties as nonatomic
#import <UIKit/UIKit.h> #define SUPPORTS_UNDOCUMENTED_API 1 @interface UIColor (expanded) - (CGColorSpaceModel) colorSpaceModel; - (NSString *) colorSpaceString; - (BOOL) canProvideRGBComponents; - (NSArray *) arrayFromRGBAComponents; - (CGFloat) red; - (CGFloat) blue; - (CGFloat) green; - (CGFloat) alpha; - (NSString *) stringFromColor; - (NSString *) hexStringFromColor; #if SUPPORTS_UNDOCUMENTED_API // Optional Undocumented API calls - (NSString *) fetchStyleString; - (UIColor *) rgbColor; // Via Poltras #endif + (UIColor *) colorWithString: (NSString *) stringToConvert; + (UIColor *) colorWithHexString: (NSString *) stringToConvert; @property (readonly) CGFloat red; @property (readonly) CGFloat green; @property (readonly) CGFloat blue; @property (readonly) CGFloat alpha; @end
#import <UIKit/UIKit.h> #define SUPPORTS_UNDOCUMENTED_API 1 @interface UIColor (expanded) - (CGColorSpaceModel) colorSpaceModel; - (NSString *) colorSpaceString; - (BOOL) canProvideRGBComponents; - (NSArray *) arrayFromRGBAComponents; - (CGFloat) red; - (CGFloat) blue; - (CGFloat) green; - (CGFloat) alpha; - (NSString *) stringFromColor; - (NSString *) hexStringFromColor; #if SUPPORTS_UNDOCUMENTED_API // Optional Undocumented API calls - (NSString *) fetchStyleString; - (UIColor *) rgbColor; // Via Poltras #endif + (UIColor *) colorWithString: (NSString *) stringToConvert; + (UIColor *) colorWithHexString: (NSString *) stringToConvert; @property (nonatomic, readonly) CGFloat red; @property (nonatomic, readonly) CGFloat green; @property (nonatomic, readonly) CGFloat blue; @property (nonatomic, readonly) CGFloat alpha; @end
Add some extra operators to base::ComPtr
// LAF Base Library // Copyright (c) 2017 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. #ifndef BASE_WIN_COMPTR_H_INCLUDED #define BASE_WIN_COMPTR_H_INCLUDED #pragma once #if !defined(_WIN32) #error This header file can be used only on Windows platform #endif #include "base/disable_copying.h" namespace base { template<class T> class ComPtr { public: ComPtr() : m_ptr(nullptr) { } ~ComPtr() { reset(); } T** operator&() { return &m_ptr; } T* operator->() { return m_ptr; } T* get() { return m_ptr; } void reset() { if (m_ptr) { m_ptr->Release(); m_ptr = nullptr; } } private: T* m_ptr; DISABLE_COPYING(ComPtr); }; } // namespace base #endif
// LAF Base Library // Copyright (c) 2021 Igara Studio S.A. // Copyright (c) 2017 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. #ifndef BASE_WIN_COMPTR_H_INCLUDED #define BASE_WIN_COMPTR_H_INCLUDED #pragma once #if !defined(_WIN32) #error This header file can be used only on Windows platform #endif #include <algorithm> namespace base { template<class T> class ComPtr { public: ComPtr() : m_ptr(nullptr) { } ComPtr<T>(const ComPtr<T>& p) : m_ptr(p.m_ptr) { if (m_ptr) m_ptr->AddRef(); } ComPtr(ComPtr&& tmp) { std::swap(m_ptr, tmp.m_ptr); } ~ComPtr() { reset(); } T** operator&() { return &m_ptr; } T* operator->() { return m_ptr; } operator bool() const { return m_ptr != nullptr; } // Add new reference using operator=() ComPtr<T>& operator=(const ComPtr<T>& p) { if (m_ptr) m_ptr->Release(); m_ptr = p.m_ptr; if (m_ptr) m_ptr->AddRef(); return *this; } ComPtr& operator=(std::nullptr_t) { reset(); return *this; } T* get() { return m_ptr; } void reset() { if (m_ptr) { m_ptr->Release(); m_ptr = nullptr; } } private: T* m_ptr; }; } // namespace base #endif
Use new NanoTime location header, oops.
#ifndef TIMEOUT_QUEUE_H #define TIMEOUT_QUEUE_H #include <map> class TimeoutQueue { typedef std::map<NanoTime, CallbackQueue> timeout_map_t; LogHandle log_; timeout_map_t timeout_queue_; public: TimeoutQueue(void) : log_("/event/timeout/queue"), timeout_queue_() { } ~TimeoutQueue() { } bool empty(void) const { timeout_map_t::const_iterator it; /* * Since we allow elements within each CallbackQueue to be * cancelled, we must scan them. * * XXX * We really shouldn't allow this, even if it means we have * to specialize CallbackQueue for this purpose or add * virtual methods to it. As it is, we can return true * for empty and for ready at the same time. And in those * cases we have to call perform to garbage collect the * unused CallbackQueues. We'll, quite conveniently, * never make that call. Yikes. */ for (it = timeout_queue_.begin(); it != timeout_queue_.end(); ++it) { if (it->second.empty()) continue; return (false); } return (true); } Action *append(uintmax_t, SimpleCallback *); uintmax_t interval(void) const; void perform(void); bool ready(void) const; }; #endif /* !TIMEOUT_QUEUE_H */
#ifndef TIMEOUT_QUEUE_H #define TIMEOUT_QUEUE_H #include <map> #include <common/time/time.h> class TimeoutQueue { typedef std::map<NanoTime, CallbackQueue> timeout_map_t; LogHandle log_; timeout_map_t timeout_queue_; public: TimeoutQueue(void) : log_("/event/timeout/queue"), timeout_queue_() { } ~TimeoutQueue() { } bool empty(void) const { timeout_map_t::const_iterator it; /* * Since we allow elements within each CallbackQueue to be * cancelled, we must scan them. * * XXX * We really shouldn't allow this, even if it means we have * to specialize CallbackQueue for this purpose or add * virtual methods to it. As it is, we can return true * for empty and for ready at the same time. And in those * cases we have to call perform to garbage collect the * unused CallbackQueues. We'll, quite conveniently, * never make that call. Yikes. */ for (it = timeout_queue_.begin(); it != timeout_queue_.end(); ++it) { if (it->second.empty()) continue; return (false); } return (true); } Action *append(uintmax_t, SimpleCallback *); uintmax_t interval(void) const; void perform(void); bool ready(void) const; }; #endif /* !TIMEOUT_QUEUE_H */
Fix alpha build and add __FBSDID.
/*- * Copyright (c) 2004 Doug Rabson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include <stdint.h> #include <machine/alpha_cpu.h> void _set_tp(void *tp) { alpha_pal_wrunique((uintptr_t) tp); }
/*- * Copyright (c) 2004 Doug Rabson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <machine/alpha_cpu.h> void _set_tp(void *tp) { alpha_pal_wrunique((uintptr_t) tp); }
UPDATE doubble checked for Fransisco
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATE_H #define SSPAPPLICATION_GAMESTATES_GAMESTATE_H #include "InputHandler.h" #include "ComponentHandler.h" #include "../GraphicsDLL/Camera.h" #include "../NetworkDLL/NetworkModule.h" //class NetworkModule; class GameStateHandler; class GameState { private: //Variables protected: GameStateHandler* m_gsh; ComponentHandler* m_cHandler; Camera* m_cameraRef; //static NetworkModule* m_networkModule; char* m_ip = "192.168.1.25"; //Tobias NUC Specific local ip int InitializeBase(GameStateHandler* gsh, ComponentHandler* cHandler, Camera* cameraRef); public: GameState(); virtual ~GameState(); virtual int ShutDown() = 0; //Returns 1 for success and 0 for failure virtual int Initialize(GameStateHandler* gsh, ComponentHandler* cHandler, Camera* cameraRef) = 0; virtual int Update(float dt, InputHandler * inputHandler) = 0; private: //Helper functions }; #endif
#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATE_H #define SSPAPPLICATION_GAMESTATES_GAMESTATE_H #include "InputHandler.h" #include "ComponentHandler.h" #include "../GraphicsDLL/Camera.h" //#include "../NetworkDLL/NetworkModule.h" //class NetworkModule; class GameStateHandler; class GameState { private: //Variables protected: GameStateHandler* m_gsh; ComponentHandler* m_cHandler; Camera* m_cameraRef; //static NetworkModule* m_networkModule; char* m_ip = "192.168.1.25"; //Tobias NUC Specific local ip int InitializeBase(GameStateHandler* gsh, ComponentHandler* cHandler, Camera* cameraRef); public: GameState(); virtual ~GameState(); virtual int ShutDown() = 0; //Returns 1 for success and 0 for failure virtual int Initialize(GameStateHandler* gsh, ComponentHandler* cHandler, Camera* cameraRef) = 0; virtual int Update(float dt, InputHandler * inputHandler) = 0; private: //Helper functions }; #endif
Use a breakpoint to cause an exception to cause the registers to be saved for debugging purposes.
/* $OpenBSD: db_interface.c,v 1.2 1996/12/28 06:21:50 rahnds Exp $ */ #include <sys/param.h> #include <sys/proc.h> #include <machine/db_machdep.h> void Debugger() { db_trap(T_BREAKPOINT); /* __asm volatile ("tw 4,2,2"); */ }
/* $OpenBSD: db_interface.c,v 1.3 1999/07/05 20:23:08 rahnds Exp $ */ #include <sys/param.h> #include <sys/proc.h> #include <machine/db_machdep.h> void Debugger() { /* db_trap(T_BREAKPOINT); */ __asm volatile ("tw 4,2,2"); }
Fix inclusion guard for NavigationWidget
#ifndef NAVIGATIONWIDGET_H #define NAVIGATIONWIDGET_H #include <QWidget> #include <QLabel> #include "qnavigation_global.h" class QLabel; class QPushButton; namespace QNavigation { class SlidingStackedWidget; class NavigationWidgetPrivate; class NavigationWidget : public QWidget { Q_OBJECT Q_DECLARE_PRIVATE(NavigationWidget) NavigationWidgetPrivate * const d_ptr; Q_PRIVATE_SLOT(d_func(), void cleanup()) public: explicit NavigationWidget(QWidget *parent = 0); virtual ~NavigationWidget(); bool level() const; QLabel *titleLabel() const; QPushButton *backButton() const; SlidingStackedWidget *stackedWidget() const; bool navigationBarHidden() const; void setNavigationBarHidden(bool hidden); public slots: void push(QWidget *item); void pop(); void popToTop(); }; } // namespace QNavigation #endif // NAVIGATIONWIDGET_H
#ifndef QNAVIGATION_NAVIGATIONWIDGET_H #define QNAVIGATION_NAVIGATIONWIDGET_H #include <QWidget> #include <QLabel> #include "qnavigation_global.h" class QLabel; class QPushButton; namespace QNavigation { class SlidingStackedWidget; class NavigationWidgetPrivate; class NavigationWidget : public QWidget { Q_OBJECT Q_DECLARE_PRIVATE(NavigationWidget) NavigationWidgetPrivate * const d_ptr; Q_PRIVATE_SLOT(d_func(), void cleanup()) public: explicit NavigationWidget(QWidget *parent = 0); virtual ~NavigationWidget(); bool level() const; QLabel *titleLabel() const; QPushButton *backButton() const; SlidingStackedWidget *stackedWidget() const; bool navigationBarHidden() const; void setNavigationBarHidden(bool hidden); public slots: void push(QWidget *item); void pop(); void popToTop(); }; } // namespace QNavigation #endif // QNAVIGATION_NAVIGATIONWIDGET_H
Add missing WebRTC header file
/* * libjingle * Copyright 2014, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "RTCVideoRenderer.h" @class RTCEAGLVideoView; @protocol RTCEAGLVideoViewDelegate - (void)videoView:(RTCEAGLVideoView*)videoView didChangeVideoSize:(CGSize)size; @end @class RTCVideoTrack; // RTCEAGLVideoView renders |videoTrack| onto itself using OpenGLES. @interface RTCEAGLVideoView : UIView @property(nonatomic, strong) RTCVideoTrack* videoTrack; @property(nonatomic, weak) id<RTCEAGLVideoViewDelegate> delegate; @end
Fix Instapaper Root API issue
// // InstapaperAPI.h // newsyc // // Created by Grant Paul on 3/10/11. // Copyright 2011 Xuzz Productions, LLC. All rights reserved. // #import <HNKit/NSString+URLEncoding.h> #define kInstapaperAPIRootURL [NSURL URLWithString:@"https://instapaper.com/api/"] #define kInstapaperAPIAuthenticationURL [NSURL URLWithString:[[kInstapaperAPIRootURL absoluteString] stringByAppendingString:@"authenticate"]] #define kInstapaperAPIAddItemURL [NSURL URLWithString:[[kInstapaperAPIRootURL absoluteString] stringByAppendingString:@"add"]]
// // InstapaperAPI.h // newsyc // // Created by Grant Paul on 3/10/11. // Copyright 2011 Xuzz Productions, LLC. All rights reserved. // #import <HNKit/NSString+URLEncoding.h> #define kInstapaperAPIRootURL [NSURL URLWithString:@"https://www.instapaper.com/api/"] #define kInstapaperAPIAuthenticationURL [NSURL URLWithString:[[kInstapaperAPIRootURL absoluteString] stringByAppendingString:@"authenticate"]] #define kInstapaperAPIAddItemURL [NSURL URLWithString:[[kInstapaperAPIRootURL absoluteString] stringByAppendingString:@"add"]]
Make Cons::car_ and Cons::cdr_ public members.
#ifndef MCLISP_CONS_H_ #define MCLISP_CONS_H_ namespace mclisp { class ConsCell { public: ConsCell(): car_(nullptr), cdr_(nullptr) {} ConsCell(ConsCell* car, ConsCell* cdr): car_(car), cdr_(cdr) {} private: ConsCell* car_; ConsCell* cdr_; }; } // namespace mclisp #endif // MCLISP_CONS_H_
#ifndef MCLISP_CONS_H_ #define MCLISP_CONS_H_ namespace mclisp { class ConsCell { public: ConsCell(): car_(nullptr), cdr_(nullptr) {} ConsCell(ConsCell* car, ConsCell* cdr): car_(car), cdr_(cdr) {} ConsCell* car_; ConsCell* cdr_; }; } // namespace mclisp #endif // MCLISP_CONS_H_