Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
REFACTOR removed duplicates and created own file for this
void multiply_by_diagonal(const int rows, const int cols, double* restrict diagonal, double* restrict matrix) { /* * Multiply a matrix by a diagonal matrix (represented as a flat array * of n values). The diagonal structure is exploited (so that we use * n^2 multiplications instead of n^3); the product looks something * like * * sage: A = matrix([[a,b,c], [d,e,f],[g,h,i]]); * sage: w = matrix([[z1,0,0],[0,z2,0],[0,0,z3]]); * sage: A * w * => [a*z1 b*z2 c*z3] * [d*z1 e*z2 f*z3] * [g*z1 h*z2 i*z3] */ int i, j; /* traverse the matrix in the correct order. */ #ifdef USE_COL_MAJOR for (j = 0; j < cols; j++) for (i = 0; i < rows; i++) #else for (i = 0; i < rows; i++) for (j = 0; j < cols; j++) #endif matrix[ORDER(i, j, rows, cols)] *= diagonal[j]; }
Clear screen before each cycle
#ifndef SCHED_H #define SCHED_H #include <Input.h> #include <Watch.h> #include <Display.h> #include <unistd.h> // for sleep() class Sched { public: Sched(Input* input, Watch* watch, Display* display) : input_(input) , watch_(watch) , display_(display) {} public: void run() { while(!shouldStop()) { sleep(1); input_->frame(); // watch_->frame(); // display_->frame(); } } bool shouldStop() const { return input_->shouldStop(); } private: Input* input_; Watch* watch_; Display* display_; }; #endif
#ifndef SCHED_H #define SCHED_H #include <Input.h> #include <Watch.h> #include <Display.h> #include <unistd.h> // for sleep() #include <iostream> class Sched { public: Sched(Input* input, Watch* watch, Display* display) : input_(input) , watch_(watch) , display_(display) {} public: void run() { while(!shouldStop()) { sleep(1); // clear screen, normally this should be done in Display // but we want to fsm debug output to be shown (and not wiped away by this // clear screen) std::cout << "\x1B[2J\x1B[H"; input_->frame(); // watch_->frame(); // display_->frame(); } } bool shouldStop() const { return input_->shouldStop(); } private: Input* input_; Watch* watch_; Display* display_; }; #endif
Add unit converter include to lammps dump writer
/* * 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_LAMMPSDUMPWRITER_H #define __VOTCA_CSG_LAMMPSDUMPWRITER_H #include <stdio.h> #include <votca/csg/topology.h> #include <votca/csg/trajectorywriter.h> namespace votca { namespace csg { class LAMMPSDumpWriter : public TrajectoryWriter { public: void Open(std::string file, bool bAppend = false) override; void Close() override; void Write(Topology *conf) override; private: FILE *_out; }; } // namespace csg } // namespace votca #endif // __VOTCA_CSG_LAMMPSDUMPWRITER_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_LAMMPSDUMPWRITER_H #define __VOTCA_CSG_LAMMPSDUMPWRITER_H #include <stdio.h> #include <votca/csg/topology.h> #include <votca/csg/trajectorywriter.h> #include <votca/tools/unitconverter.h> namespace votca { namespace csg { class LAMMPSDumpWriter : public TrajectoryWriter { public: void Open(std::string file, bool bAppend = false) override; void Close() override; void Write(Topology *conf) override; private: FILE *_out; }; } // namespace csg } // namespace votca #endif // __VOTCA_CSG_LAMMPSDUMPWRITER_H
Merge changes allowing up to 128 elements per Guacamole instruction.
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 _GUAC_PARSER_CONSTANTS_H #define _GUAC_PARSER_CONSTANTS_H /** * Constants related to the Guacamole protocol parser. * * @file parser-constants.h */ /** * The maximum number of characters per instruction. */ #define GUAC_INSTRUCTION_MAX_LENGTH 8192 /** * The maximum number of digits to allow per length prefix. */ #define GUAC_INSTRUCTION_MAX_DIGITS 5 /** * The maximum number of elements per instruction, including the opcode. */ #define GUAC_INSTRUCTION_MAX_ELEMENTS 64 #endif
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 _GUAC_PARSER_CONSTANTS_H #define _GUAC_PARSER_CONSTANTS_H /** * Constants related to the Guacamole protocol parser. * * @file parser-constants.h */ /** * The maximum number of characters per instruction. */ #define GUAC_INSTRUCTION_MAX_LENGTH 8192 /** * The maximum number of digits to allow per length prefix. */ #define GUAC_INSTRUCTION_MAX_DIGITS 5 /** * The maximum number of elements per instruction, including the opcode. */ #define GUAC_INSTRUCTION_MAX_ELEMENTS 128 #endif
Add contructor to initialize fetchGenerator correctly
//! \file WikiWalker.h #ifndef WIKIWALKER_H #define WIKIWALKER_H #include <string> #include "CurlWikiGrabber.h" #include "Walker.h" namespace WikiWalker { //! main "app" class class WikiWalker : public Walker { public: /*! given an URL, start collecting links * \param url start point for analysis */ void startWalking(const std::string& url); /*! fetch not only requested article, but also linked ones. * \param depth whether to fetch linked articles as well */ void setDeep(bool depth) { fetchGenerator = depth; } /*! Read data from cache file. * Used for initialization. * \param cacheFile file name of the cache. */ void readCache(const std::string& cacheFile); /*! Write data to cache file. * \param cacheFile file name of the cache. */ void writeCache(const std::string& cacheFile); private: CurlWikiGrabber grabber; bool fetchGenerator; }; } // namespace WikiWalker #endif // WIKIWALKER_H
//! \file WikiWalker.h #ifndef WIKIWALKER_H #define WIKIWALKER_H #include <string> #include "CurlWikiGrabber.h" #include "Walker.h" namespace WikiWalker { //! main "app" class class WikiWalker : public Walker { public: //! Creates a new instance WikiWalker() : Walker(), fetchGenerator(false), grabber() { } /*! given an URL, start collecting links * \param url start point for analysis */ void startWalking(const std::string& url); /*! fetch not only requested article, but also linked ones. * \param depth whether to fetch linked articles as well */ void setDeep(bool depth) { fetchGenerator = depth; } /*! Read data from cache file. * Used for initialization. * \param cacheFile file name of the cache. */ void readCache(const std::string& cacheFile); /*! Write data to cache file. * \param cacheFile file name of the cache. */ void writeCache(const std::string& cacheFile); private: CurlWikiGrabber grabber; bool fetchGenerator; }; } // namespace WikiWalker #endif // WIKIWALKER_H
Add priv_data field in DecodedFrame struct.
#ifndef __VIDEO_RX_H__ #define __VIDEO_RX_H__ #include "libavformat/avformat.h" typedef struct DecodedFrame { AVFrame* pFrameRGB; uint8_t *buffer; } DecodedFrame; typedef struct FrameManager { enum PixelFormat pix_fmt; void (*put_video_frame_rx)(uint8_t *data, int width, int height, int nframe); DecodedFrame* (*get_decoded_frame_buffer)(int width, int height); void (*release_decoded_frame_buffer)(void); } FrameManager; int start_video_rx(const char* sdp, int maxDelay, FrameManager *frame_manager); int stop_video_rx(); #endif /* __VIDEO_RX_H__ */
#ifndef __VIDEO_RX_H__ #define __VIDEO_RX_H__ #include "libavformat/avformat.h" typedef struct DecodedFrame { AVFrame* pFrameRGB; uint8_t *buffer; void *priv_data; /* User private data */ } DecodedFrame; typedef struct FrameManager { enum PixelFormat pix_fmt; void (*put_video_frame_rx)(uint8_t *data, int width, int height, int nframe); DecodedFrame* (*get_decoded_frame_buffer)(int width, int height); void (*release_decoded_frame_buffer)(void); } FrameManager; int start_video_rx(const char* sdp, int maxDelay, FrameManager *frame_manager); int stop_video_rx(); #endif /* __VIDEO_RX_H__ */
Add C implementation for problem 10
#include <stdlib.h> #include <stdio.h> #include "utils.h" #define LIMIT 2000000 unsigned long solution(){ unsigned long n; unsigned long total_sum = 0L; n = 2L; while(n <= LIMIT){ if(is_prime(n) == 1){ total_sum = total_sum + n; } n += 1L; } return total_sum; } int main(int argc, char *argv[]){ unsigned_long_time_it(solution); return 0; }
CREATE ns_prefix/box/ didn't work right when namespace prefix existed.
/* Copyright (C) 2002 Timo Sirainen */ #include "common.h" #include "mail-namespace.h" #include "commands.h" bool cmd_create(struct client_command_context *cmd) { struct mail_namespace *ns; const char *mailbox, *full_mailbox; bool directory; size_t len; /* <mailbox> */ if (!client_read_string_args(cmd, 1, &mailbox)) return FALSE; full_mailbox = mailbox; ns = client_find_namespace(cmd, &mailbox); if (ns == NULL) return TRUE; len = strlen(full_mailbox); if (len == 0 || full_mailbox[len-1] != ns->sep) directory = FALSE; else { /* name ends with hierarchy separator - client is just informing us that it wants to create children under this mailbox. */ directory = TRUE; mailbox = t_strndup(mailbox, len-1); full_mailbox = t_strndup(full_mailbox, strlen(full_mailbox)-1); } if (!client_verify_mailbox_name(cmd, full_mailbox, FALSE, TRUE)) return TRUE; if (mail_storage_mailbox_create(ns->storage, mailbox, directory) < 0) client_send_storage_error(cmd, ns->storage); else client_send_tagline(cmd, "OK Create completed."); return TRUE; }
/* Copyright (C) 2002 Timo Sirainen */ #include "common.h" #include "mail-namespace.h" #include "commands.h" bool cmd_create(struct client_command_context *cmd) { struct mail_namespace *ns; const char *mailbox, *full_mailbox; bool directory; size_t len; /* <mailbox> */ if (!client_read_string_args(cmd, 1, &mailbox)) return FALSE; full_mailbox = mailbox; ns = client_find_namespace(cmd, &mailbox); if (ns == NULL) return TRUE; len = strlen(full_mailbox); if (len == 0 || full_mailbox[len-1] != ns->sep) directory = FALSE; else { /* name ends with hierarchy separator - client is just informing us that it wants to create children under this mailbox. */ directory = TRUE; mailbox = t_strndup(mailbox, strlen(mailbox)-1); full_mailbox = t_strndup(full_mailbox, len-1); } if (!client_verify_mailbox_name(cmd, full_mailbox, FALSE, TRUE)) return TRUE; if (mail_storage_mailbox_create(ns->storage, mailbox, directory) < 0) client_send_storage_error(cmd, ns->storage); else client_send_tagline(cmd, "OK Create completed."); return TRUE; }
Add git r done version of detail::raw_pointer_cast
/* * Copyright 2008-2009 NVIDIA Corporation * * 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. */ /*! \file casts.h * \brief Unsafe casts for internal use. */ #pragma once #include <thrust/iterator/iterator_traits.h> namespace thrust { namespace detail { namespace dispatch { template<typename TrivialIterator> typename thrust::iterator_traits<TrivialIterator>::value_type * raw_pointer_cast(TrivialIterator i, thrust::random_access_host_iterator_tag) { typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer; // cast away constness return const_cast<Pointer>(&*i); } // end raw_pointer_cast() // this path will work for device_ptr & device_vector::iterator template<typename TrivialIterator> typename thrust::iterator_traits<TrivialIterator>::value_type * raw_pointer_cast(TrivialIterator i, thrust::random_access_device_iterator_tag) { typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer; // cast away constness return const_cast<Pointer>((&*i).get()); } // end raw_pointer_cast() } // end dispatch template<typename TrivialIterator> typename thrust::iterator_traits<TrivialIterator>::value_type *raw_pointer_cast(TrivialIterator i) { return detail::dispatch::raw_pointer_cast(i, thrust::iterator_traits<TrivialIterator>::iterator_category()); } // end raw_pointer_cast() } // end detail } // end thrust
Change swift_once_t to be actually pointer-sized on non-Darwin
//===--- Once.h - Runtime support for lazy initialization ------*- C++ -*--===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // Swift runtime functions in support of lazy initialization. // //===----------------------------------------------------------------------===// #ifndef SWIFT_RUNTIME_ONCE_H #define SWIFT_RUNTIME_ONCE_H #include "swift/Runtime/HeapObject.h" namespace swift { #ifdef __APPLE__ // On OS X and iOS, swift_once_t matches dispatch_once_t. typedef long swift_once_t; #else // On other platforms swift_once_t is pointer-sized. typedef int swift_once_t; #endif /// Runs the given function with the given context argument exactly once. /// The predicate argument must point to a global or static variable of static /// extent of type swift_once_t. extern "C" void swift_once(swift_once_t *predicate, void (*fn)(HeapObject *ctx), HeapObject *ctx); } #endif
//===--- Once.h - Runtime support for lazy initialization ------*- C++ -*--===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // Swift runtime functions in support of lazy initialization. // //===----------------------------------------------------------------------===// #ifndef SWIFT_RUNTIME_ONCE_H #define SWIFT_RUNTIME_ONCE_H #include "swift/Runtime/HeapObject.h" namespace swift { #ifdef __APPLE__ // On OS X and iOS, swift_once_t matches dispatch_once_t. typedef long swift_once_t; #else // On other platforms swift_once_t is pointer-sized. typedef void *swift_once_t; #endif /// Runs the given function with the given context argument exactly once. /// The predicate argument must point to a global or static variable of static /// extent of type swift_once_t. extern "C" void swift_once(swift_once_t *predicate, void (*fn)(HeapObject *ctx), HeapObject *ctx); } #endif
Add test where printf shouldn't invalidate pointer argument
#include <stdio.h> #include <assert.h> int main() { int x = 42; printf("&x = %p\n", &x); // doesn't invalidate x despite taking address assert(x == 42); return 0; }
Make this test suitable for optimized builds by avoiding the name.
// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s #include <stdint.h> #define ldrex_func(p, rl, rh) \ __asm__ __volatile__( \ "ldrexd%[_rl], %[_rh], [%[_p]]" \ : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \ : [_p] "p" (p) : "memory") int64_t foo(int64_t v, volatile int64_t *p) { register uint32_t rl asm("r1"); register uint32_t rh asm("r2"); int64_t r; uint32_t t; __asm__ __volatile__( \ "ldrexd%[_rl], %[_rh], [%[_p]]" \ : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \ : [_p] "p" (p) : "memory"); // CHECK: %0 = call %0 asm sideeffect "ldrexd$0, $1, [$2]", "={r1},={r2},r,~{memory}"(i64* %tmp) return r; }
// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s #include <stdint.h> #define ldrex_func(p, rl, rh) \ __asm__ __volatile__( \ "ldrexd%[_rl], %[_rh], [%[_p]]" \ : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \ : [_p] "p" (p) : "memory") int64_t foo(int64_t v, volatile int64_t *p) { register uint32_t rl asm("r1"); register uint32_t rh asm("r2"); int64_t r; uint32_t t; __asm__ __volatile__( \ "ldrexd%[_rl], %[_rh], [%[_p]]" \ : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \ : [_p] "p" (p) : "memory"); // CHECK: %0 = call %0 asm sideeffect "ldrexd$0, $1, [$2]", "={r1},={r2},r,~{memory}"(i64* return r; }
Support amd64. Release 2.3.5. Replace crittercism sdk.(ver 4.3.7)
// // KRCloudSyncBlocks.h // CloudSync // // Created by allting on 12. 10. 19.. // Copyright (c) 2012년 allting. All rights reserved. // #ifndef CloudSync_KRCloudSyncBlocks_h #define CloudSync_KRCloudSyncBlocks_h @class KRSyncItem; typedef void (^KRCloudSyncStartBlock)(NSArray* syncItems); typedef void (^KRCloudSyncProgressBlock)(KRSyncItem* synItem, float progress); typedef void (^KRCloudSyncCompletedBlock)(NSArray* syncItems, NSError* error); typedef void (^KRCloudSyncResultBlock)(BOOL succeeded, NSError* error); typedef void (^KRCloudSyncPublishingURLBlock)(NSURL* url, BOOL succeeded, NSError* error); typedef void (^KRResourcesCompletedBlock)(NSArray* resources, NSError* error); typedef void (^KRServiceAvailableBlock)(BOOL available); typedef void (^KRiCloudRemoveFileBlock)(BOOL succeeded, NSError* error); #endif
// // KRCloudSyncBlocks.h // CloudSync // // Created by allting on 12. 10. 19.. // Copyright (c) 2012년 allting. All rights reserved. // #ifndef CloudSync_KRCloudSyncBlocks_h #define CloudSync_KRCloudSyncBlocks_h @class KRSyncItem; typedef void (^KRCloudSyncStartBlock)(NSArray* syncItems); typedef void (^KRCloudSyncProgressBlock)(KRSyncItem* synItem, CGFloat progress); typedef void (^KRCloudSyncCompletedBlock)(NSArray* syncItems, NSError* error); typedef void (^KRCloudSyncResultBlock)(BOOL succeeded, NSError* error); typedef void (^KRCloudSyncPublishingURLBlock)(NSURL* url, BOOL succeeded, NSError* error); typedef void (^KRResourcesCompletedBlock)(NSArray* resources, NSError* error); typedef void (^KRServiceAvailableBlock)(BOOL available); typedef void (^KRiCloudRemoveFileBlock)(BOOL succeeded, NSError* error); #endif
Switch to __cdecl till we get --kill-at to work
#ifndef PLUGIN_H_ #define PLUGIN_H_ #include <windows.h> #define EXPORT_CALLING __stdcall #define EXPORT __declspec(dllexport) EXPORT_CALLING #include "common.h" // just defined to make compilation work ; ignored #define RTLD_DEFAULT NULL #define RTLD_LOCAL -1 #define RTLD_LAZY -1 static inline void *dlopen(const char *name, int flags) { // TODO use LoadLibraryEx() and flags ? return LoadLibrary(name); } static inline void *dlsym(void *handle, const char *name) { FARPROC g = GetProcAddress(handle, name); void *h; *(FARPROC*)&h = g; return h; } static inline char *dlerror(void) { static __thread char buf[1024]; FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, sizeof buf, NULL); return buf; } static inline int dlclose(void *handle) { return !FreeLibrary(handle); } #endif
#ifndef PLUGIN_H_ #define PLUGIN_H_ #include <windows.h> // TODO use __stdcall #define EXPORT_CALLING __cdecl #define EXPORT __declspec(dllexport) EXPORT_CALLING #include "common.h" // just defined to make compilation work ; ignored #define RTLD_DEFAULT NULL #define RTLD_LOCAL -1 #define RTLD_LAZY -1 static inline void *dlopen(const char *name, int flags) { // TODO use LoadLibraryEx() and flags ? return LoadLibrary(name); } static inline void *dlsym(void *handle, const char *name) { FARPROC g = GetProcAddress(handle, name); void *h; *(FARPROC*)&h = g; return h; } static inline char *dlerror(void) { static __thread char buf[1024]; FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, sizeof buf, NULL); return buf; } static inline int dlclose(void *handle) { return !FreeLibrary(handle); } #endif
Call this version what it is. Missed in earlier.
#ifndef _COMMON_H #define _COMMON_H #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #ifdef _LINUX #include <bsd/string.h> #endif #include <libxml/parser.h> #include <libxml/tree.h> #include <libxml/xmlsave.h> #include <libxml/encoding.h> #include <libxml/xmlstring.h> #include <openssl/bio.h> #include <openssl/evp.h> #ifndef _READLINE #include <histedit.h> #else #include <readline/readline.h> #include <readline/history.h> #endif #define NAME "kc" #define VERSION "2.2.0" #define USAGE "[-k database file] [-r] [-p password file] [-m cipher mode] [-b] [-v] [-h]" #define PASSWORD_MAXLEN 64 enum { KC_GENERATE_IV = 1, KC_GENERATE_SALT = 1 << 1, KC_GENERATE_KEY = 1 << 2 }; #ifndef _READLINE const char *el_prompt_null(void); #endif const char *prompt_str(void); int malloc_check(void *); void version(void); void quit(int); #endif
#ifndef _COMMON_H #define _COMMON_H #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #ifdef _LINUX #include <bsd/string.h> #endif #include <libxml/parser.h> #include <libxml/tree.h> #include <libxml/xmlsave.h> #include <libxml/encoding.h> #include <libxml/xmlstring.h> #include <openssl/bio.h> #include <openssl/evp.h> #ifndef _READLINE #include <histedit.h> #else #include <readline/readline.h> #include <readline/history.h> #endif #define NAME "kc" #define VERSION "2.2.0rc2" #define USAGE "[-k database file] [-r] [-p password file] [-m cipher mode] [-b] [-v] [-h]" #define PASSWORD_MAXLEN 64 enum { KC_GENERATE_IV = 1, KC_GENERATE_SALT = 1 << 1, KC_GENERATE_KEY = 1 << 2 }; #ifndef _READLINE const char *el_prompt_null(void); #endif const char *prompt_str(void); int malloc_check(void *); void version(void); void quit(int); #endif
Change video bitrate to 2 Mbps
#ifndef PICAM_CONFIG_H #define PICAM_CONFIG_H #if defined(__cplusplus) extern "C" { #endif // Even if we specify 30 FPS, Raspberry Pi Camera provides slighly lower FPS. #define TARGET_FPS 30 #define GOP_SIZE TARGET_FPS #define H264_BIT_RATE 3000 * 1000 // 3 Mbps // 1600x900 is the upper limit if you don't use tunnel from camera to video_encode. // 720p (1280x720) is good enough for most cases. #define WIDTH 1280 #define HEIGHT 720 // Choose the value that results in non-repeating decimal when divided by 90000. // e.g. 48000 and 32000 are fine, but 44100 and 22050 are bad. #define AUDIO_SAMPLE_RATE 48000 #define AAC_BIT_RATE 40000 // 40 kbps // Set this value to 1 if you want to produce audio-only stream for debugging. #define AUDIO_ONLY 0 #if defined(__cplusplus) } #endif #endif
#ifndef PICAM_CONFIG_H #define PICAM_CONFIG_H #if defined(__cplusplus) extern "C" { #endif // 1600x900 is the upper limit if you don't use tunnel from camera to video_encode. // 720p (1280x720) is good enough for most cases. #define WIDTH 1280 #define HEIGHT 720 // Even if we specify 30 FPS, Raspberry Pi Camera provides slighly lower FPS. #define TARGET_FPS 30 // Distance between two key frames #define GOP_SIZE TARGET_FPS #define H264_BIT_RATE 2000 * 1000 // 2 Mbps // Choose the value that results in non-repeating decimal when divided by 90000. // e.g. 48000 and 32000 are fine, but 44100 and 22050 are bad. #define AUDIO_SAMPLE_RATE 48000 #define AAC_BIT_RATE 40000 // 40 Kbps // Set this value to 1 if you want to produce audio-only stream for debugging. #define AUDIO_ONLY 0 #if defined(__cplusplus) } #endif #endif
Add ARGV and ARGV_CONCAT macros
/* * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in * the LICENSE file in the root directory of this source tree. An * additional grant of patent rights can be found in the PATENTS file * in the same directory. * */ #pragma once #include <stddef.h> size_t argv_count(const char* const* argv); const char** argv_concat(const char* const* argv1, ...); const char** argv_concat_deepcopy(const char* const* argv1, ...); extern const char* const empty_argv[];
/* * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in * the LICENSE file in the root directory of this source tree. An * additional grant of patent rights can be found in the PATENTS file * in the same directory. * */ #pragma once #include <stddef.h> size_t argv_count(const char* const* argv); const char** argv_concat(const char* const* argv1, ...); const char** argv_concat_deepcopy(const char* const* argv1, ...); extern const char* const empty_argv[]; #define ARGV(...) ((const char*[]){__VA_ARGS__ , NULL}) #define ARGV_CONCAT(...) argv_concat(__VA_ARGS__ , NULL)
Use write(2) to display helptext.
// Copyright 2016, Jeffrey E. Bedard #include "xstatus.h" #include "config.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> static const char * helptext = "DESCRIPTION: Simple X toolbar for minimalistic" " window managers.\n" "USAGE: xstatus [-d DELAY][-f FILE][-h]\n" "\t-d DELAY Set delay between status updates," " in seconds.\n" "\t-f FILE Set FILE to be continuously polled and" " displayed.\n" "\t-h Print this usage information. \n" "Copyright 2016, Jeffrey E. Bedard <jefbed@gmail.com>\n" "Project page: https://github.com/jefbed/xstatus\n"; int main(int argc, char ** argv) { char *filename=DEFAULTF; uint8_t delay=1; int opt; while((opt = getopt(argc, argv, "d:f:h")) != -1) { switch(opt) { case 'd': delay=atoi(optarg); break; case 'f': filename=optarg; break; case 'h': default: fprintf(stdout, "%s", helptext); exit(0); } } run_xstatus(filename, delay); }
// Copyright 2016, Jeffrey E. Bedard #include "xstatus.h" #include "config.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> static const char helptext[] = "DESCRIPTION: Simple X toolbar for minimalistic" " window managers.\n" "USAGE: xstatus [-d DELAY][-f FILE][-h]\n" "\t-d DELAY Set delay between status updates," " in seconds.\n" "\t-f FILE Set FILE to be continuously polled and" " displayed.\n" "\t-h Print this usage information. \n" "Copyright 2016, Jeffrey E. Bedard <jefbed@gmail.com>\n" "Project page: https://github.com/jefbed/xstatus\n"; int main(int argc, char ** argv) { char *filename=DEFAULTF; uint8_t delay=1; int opt; while((opt = getopt(argc, argv, "d:f:h")) != -1) { switch(opt) { case 'd': delay=atoi(optarg); break; case 'f': filename=optarg; break; case 'h': default: write(2, helptext, sizeof(helptext)); exit(0); } } run_xstatus(filename, delay); }
Revert "Changed macro to look specifically for NS_STRING_ENUM"
// // SDLMacros.h // SmartDeviceLink-iOS // // Created by Muller, Alexander (A.) on 10/17/16. // Copyright © 2016 smartdevicelink. All rights reserved. // #ifndef SDLMacros_h #define SDLMacros_h // Resolves issue of pre-xcode 8 versions due to NS_STRING_ENUM unavailability. #ifndef SDL_SWIFT_ENUM #if __has_attribute(NS_STRING_ENUM) #define SDL_SWIFT_ENUM NS_STRING_ENUM #else #define SDL_SWIFT_ENUM #endif #endif #endif /* SDLMacros_h */
// // SDLMacros.h // SmartDeviceLink-iOS // // Created by Muller, Alexander (A.) on 10/17/16. // Copyright © 2016 smartdevicelink. All rights reserved. // #ifndef SDLMacros_h #define SDLMacros_h // Resolves issue of pre-xcode 8 versions due to NS_STRING_ENUM unavailability. #ifndef SDL_SWIFT_ENUM #if __has_attribute(swift_wrapper) #define SDL_SWIFT_ENUM NS_STRING_ENUM #else #define SDL_SWIFT_ENUM #endif #endif #endif /* SDLMacros_h */
Move types declarations to new file
typedef struct { uint8_t Length; //Length of frame, if it's equal to 0, frame is not ready uint8_t *Frame; //Response frame content } MODBUSResponseStatus; //Type containing information about frame that is set up at slave side typedef struct { uint8_t Address; uint16_t *Registers; uint16_t RegisterCount; MODBUSResponseStatus Response; } MODBUSSlaveStatus; //Type containing slave device configuration data
Remove unnecessary const qualifier in function declaration
#pragma once #include "address.h" #include "options.h" #include "cartridge/cartridge.h" #include <vector> #include <memory> class Video; class CPU; class Serial; class Input; class Timer; class MMU { public: MMU(std::shared_ptr<Cartridge> inCartridge, CPU& inCPU, Video& inVideo, Input& input, Serial& serial, Timer& timer, Options& options); auto read(const Address& address) const -> u8; void write(const Address& address, u8 byte); private: auto boot_rom_active() const -> bool; auto read_io(const Address& address) const -> u8; void write_io(const Address& address, u8 byte); auto memory_read(const Address& address) const -> u8; void memory_write(const Address& address, u8 byte); void dma_transfer(const u8 byte); std::shared_ptr<Cartridge> cartridge; CPU& cpu; Video& video; Input& input; Serial& serial; Timer& timer; Options& options; std::vector<u8> memory; friend class Debugger; };
#pragma once #include "address.h" #include "options.h" #include "cartridge/cartridge.h" #include <vector> #include <memory> class Video; class CPU; class Serial; class Input; class Timer; class MMU { public: MMU(std::shared_ptr<Cartridge> inCartridge, CPU& inCPU, Video& inVideo, Input& input, Serial& serial, Timer& timer, Options& options); auto read(const Address& address) const -> u8; void write(const Address& address, u8 byte); private: auto boot_rom_active() const -> bool; auto read_io(const Address& address) const -> u8; void write_io(const Address& address, u8 byte); auto memory_read(const Address& address) const -> u8; void memory_write(const Address& address, u8 byte); void dma_transfer(u8 byte); std::shared_ptr<Cartridge> cartridge; CPU& cpu; Video& video; Input& input; Serial& serial; Timer& timer; Options& options; std::vector<u8> memory; friend class Debugger; };
Include shannon.h instead of entropy.h
// Copyright 2016 ELIFE. All rights reserved. // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. #pragma once #include <inform/dist.h> #include <inform/entropy.h> #include <inform/state_encoding.h> #include <inform/active_info.h> #include <inform/entropy_rate.h> #include <inform/transfer_entropy.h>
// Copyright 2016 ELIFE. All rights reserved. // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. #pragma once #include <inform/dist.h> #include <inform/shannon.h> #include <inform/state_encoding.h> #include <inform/active_info.h> #include <inform/entropy_rate.h> #include <inform/transfer_entropy.h>
Add NXP LPC clock control driver
/* * Copyright (c) 2020, NXP * * SPDX-License-Identifier: Apache-2.0 */ #ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_ #define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_ #define MCUX_FLEXCOMM0_CLK 0 #define MCUX_FLEXCOMM1_CLK 1 #define MCUX_FLEXCOMM2_CLK 2 #define MCUX_FLEXCOMM3_CLK 3 #define MCUX_FLEXCOMM4_CLK 4 #define MCUX_FLEXCOMM5_CLK 5 #define MCUX_FLEXCOMM6_CLK 6 #define MCUX_FLEXCOMM7_CLK 7 #define MCUX_HS_SPI_CLK 8 #endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_ */
Use gsl_rng_uniform instead of gsl_rng_get
// // RandomnessDelegate.h // jdemon // // Created by Mark Larus on 3/19/13. // Copyright (c) 2013 Kenyon College. All rights reserved. // #ifndef __jdemon__RandomnessDelegate__ #define __jdemon__RandomnessDelegate__ #include <gsl/gsl_rng.h> #include <stdexcept> namespace Randomness { class Delegate { protected: Delegate() {} public: virtual bool binaryEventWithProbability(double probabilityOfHappening) = 0; virtual int randomIntegerFromInclusiveRange(int begin, int end) = 0; }; class GSLDelegate : public Delegate { gsl_rng *RNG; public: bool binaryEventWithProbability( double probabilityOfHappening ) { return gsl_rng_get(RNG) < probabilityOfHappening ? 1 : 0; }; int randomIntegerFromInclusiveRange(int begin, int end) { if (end<begin) { throw std::runtime_error("Invalid RNG range. 'begin' must be less than 'end'"); } return (int)gsl_rng_uniform_int(RNG, end-begin) + begin; } GSLDelegate(gsl_rng *r) : RNG(r) {} }; } #endif /* defined(__jdemon__RandomnessDelegate__) */
// // RandomnessDelegate.h // jdemon // // Created by Mark Larus on 3/19/13. // Copyright (c) 2013 Kenyon College. All rights reserved. // #ifndef __jdemon__RandomnessDelegate__ #define __jdemon__RandomnessDelegate__ #include <gsl/gsl_rng.h> #include <stdexcept> namespace Randomness { class Delegate { protected: Delegate() {} public: virtual bool binaryEventWithProbability(double probabilityOfHappening) = 0; virtual int randomIntegerFromInclusiveRange(int begin, int end) = 0; }; class GSLDelegate : public Delegate { gsl_rng *RNG; public: bool binaryEventWithProbability( double probabilityOfHappening ) { return gsl_rng_uniform(RNG) < probabilityOfHappening ? 1 : 0; }; int randomIntegerFromInclusiveRange(int begin, int end) { if (end<begin) { throw std::runtime_error("Invalid RNG range. 'begin' must be less than 'end'"); } return (int)gsl_rng_uniform_int(RNG, end-begin) + begin; } GSLDelegate(gsl_rng *r) : RNG(r) {} }; } #endif /* defined(__jdemon__RandomnessDelegate__) */
Mark a test as unsupported on darwin.
// RUN: %clang_cfi -lm -o %t1 %s // RUN: %t1 c 1 2>&1 | FileCheck --check-prefix=CFI %s // RUN: %t1 s 2 2>&1 | FileCheck --check-prefix=CFI %s // This test uses jump tables containing PC-relative references to external // symbols, which the Mach-O object writer does not currently support. // XFAIL: darwin #include <stdlib.h> #include <stdio.h> #include <math.h> int main(int argc, char **argv) { // CFI: 1 fprintf(stderr, "1\n"); double (*fn)(double); if (argv[1][0] == 's') fn = sin; else fn = cos; fn(atof(argv[2])); // CFI: 2 fprintf(stderr, "2\n"); }
// RUN: %clang_cfi -lm -o %t1 %s // RUN: %t1 c 1 2>&1 | FileCheck --check-prefix=CFI %s // RUN: %t1 s 2 2>&1 | FileCheck --check-prefix=CFI %s // This test uses jump tables containing PC-relative references to external // symbols, which the Mach-O object writer does not currently support. // The test passes on i386 Darwin and fails on x86_64, hence unsupported instead of xfail. // UNSUPPORTED: darwin #include <stdlib.h> #include <stdio.h> #include <math.h> int main(int argc, char **argv) { // CFI: 1 fprintf(stderr, "1\n"); double (*fn)(double); if (argv[1][0] == 's') fn = sin; else fn = cos; fn(atof(argv[2])); // CFI: 2 fprintf(stderr, "2\n"); }
Add example for help output
#include <argparse.h> #include <stdio.h> int main(int argc, char **argv) { args *args = args_new(); args_add_option(args, option_new("f", "feature", "description of feature")); args_help(args, stdout); args_free(args); }
Add flags to stage Skia API changes
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_SUPPORT_DEPRECATED_CLIPOPS // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_SUPPORT_DEPRECATED_CLIPOPS // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_SUPPORT_LEGACY_GETBLENDMODE #define SK_SUPPORT_LEGACY_SETFILTERQUALITY #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
Add flag to stage api change
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Staging flags #define SK_LEGACY_PATH_ARCTO_ENDPOINT #define SK_SUPPORT_LEGACY_PAINT_QUALITY_APIS // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
Remove texts for unserstanding to Wiki pages
#ifndef GPIOLIB_H #define GPIOLIB_H #define FORWARD 1 #define BACKWARD 0 namespace GPIO { int init(); //direction is either FORWARD or BACKWARD. speed can be an integer ranging from 0 to 100. int controlLeft(int direction,int speed); int controlRight(int direction,int speed); int stopLeft(); int stopRight(); int resetCounter(); void getCounter(int *countLeft,int *countRight); //angle is available in the range of -90 to 90. int turnTo(int angle); void delay(int milliseconds); } #endif
#ifndef GPIOLIB_H #define GPIOLIB_H #define FORWARD 1 #define BACKWARD 0 namespace GPIO { int init(); int controlLeft(int direction,int speed); int controlRight(int direction,int speed); int stopLeft(); int stopRight(); int resetCounter(); void getCounter(int *countLeft,int *countRight); int turnTo(int angle); void delay(int milliseconds); } #endif
Change uuid to char* from int for Windows
/* $Id: wUuid.h,v 1.1.2.2 2012/03/20 11:15:17 emmapollock Exp $ * * OpenMAMA: The open middleware agnostic messaging API * Copyright (C) 2011 NYSE Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef WUUID_H__ #define WUUID_H__ #include "wombat/port.h" typedef int wUuid; COMMONExpDLL void wUuid_generate_time (wUuid myUuid); COMMONExpDLL void wUuid_unparse (wUuid myUuid, char* out); #endif /* WUUID_H__ */
/* $Id: wUuid.h,v 1.1.2.2 2012/03/20 11:15:17 emmapollock Exp $ * * OpenMAMA: The open middleware agnostic messaging API * Copyright (C) 2011 NYSE Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef WUUID_H__ #define WUUID_H__ #include "wombat/port.h" typedef char* wUuid; COMMONExpDLL void wUuid_generate_time (wUuid myUuid); COMMONExpDLL void wUuid_unparse (wUuid myUuid, char* out); #endif /* WUUID_H__ */
Maintain the legacy behavior for WebP loop count
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 #endif // SkUserConfigManual_DEFINED
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_TEST_UTILS 1 #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Disable these Ganesh features #define SK_DISABLE_REDUCE_OPLIST_SPLITTING // Check error is expensive. HWUI historically also doesn't check its allocations #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_SUPPORT_DEPRECATED_CLIPOPS // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_AA_CHOICE #define SK_SUPPORT_LEGACY_AAA_CHOICE #define SK_DISABLE_DAA // skbug.com/6886 // b/145995037 #define SK_LEGACY_WEBP_LOOP_COUNT #endif // SkUserConfigManual_DEFINED
Add prototypes of response-building functions
#define _SLAVEREGISTERS #include <inttypes.h> //Functions needed from other modules extern void MODBUSBuildException( uint8_t, uint8_t ); //Functions for parsing requests extern void MODBUSParseRequest03( union MODBUSParser *Parser ); extern void MODBUSParseRequest06( union MODBUSParser *Parser ); extern void MODBUSParseRequest16( union MODBUSParser *Parser );
#define _SLAVEREGISTERS #include <inttypes.h> //Functions needed from other modules extern void MODBUSBuildException( uint8_t, uint8_t ); //Functions for parsing requests extern void MODBUSParseRequest03( union MODBUSParser *Parser ); extern void MODBUSParseRequest06( union MODBUSParser *Parser ); extern void MODBUSParseRequest16( union MODBUSParser *Parser ); //Functions for building responses extern void MODBUSBuildResponse03( union MODBUSParser *Parser ); extern void MODBUSBuildResponse06( union MODBUSParser *Parser ); extern void MODBUSBuildResponse16( union MODBUSParser *Parser );
Remove unused include of <vector>
/************************************************* * Configuration Handling Header File * * (C) 1999-2007 Jack Lloyd * *************************************************/ #ifndef BOTAN_POLICY_CONF_H__ #define BOTAN_POLICY_CONF_H__ #include <botan/mutex.h> #include <string> #include <vector> #include <map> namespace Botan { /************************************************* * Library Configuration Settings * *************************************************/ class BOTAN_DLL Config { public: Config(); ~Config(); void load_defaults(); std::string get(const std::string&, const std::string&) const; bool is_set(const std::string&, const std::string&) const; void set(const std::string&, const std::string&, const std::string&, bool = true); std::string option(const std::string&) const; u32bit option_as_time(const std::string&) const; void set_option(const std::string, const std::string&); void add_alias(const std::string&, const std::string&); std::string deref_alias(const std::string&) const; void load_inifile(const std::string&); private: Config(const Config&) {} Config& operator=(const Config&) { return (*this); } std::map<std::string, std::string> settings; Mutex* mutex; }; /************************************************* * Hook for the global config * *************************************************/ BOTAN_DLL Config& global_config(); } #endif
/************************************************* * Configuration Handling Header File * * (C) 1999-2008 Jack Lloyd * *************************************************/ #ifndef BOTAN_POLICY_CONF_H__ #define BOTAN_POLICY_CONF_H__ #include <botan/mutex.h> #include <string> #include <map> namespace Botan { /************************************************* * Library Configuration Settings * *************************************************/ class BOTAN_DLL Config { public: Config(); ~Config(); void load_defaults(); std::string get(const std::string&, const std::string&) const; bool is_set(const std::string&, const std::string&) const; void set(const std::string&, const std::string&, const std::string&, bool = true); std::string option(const std::string&) const; u32bit option_as_time(const std::string&) const; void set_option(const std::string, const std::string&); void add_alias(const std::string&, const std::string&); std::string deref_alias(const std::string&) const; void load_inifile(const std::string&); private: Config(const Config&) {} Config& operator=(const Config&) { return (*this); } std::map<std::string, std::string> settings; Mutex* mutex; }; /************************************************* * Hook for the global config * *************************************************/ BOTAN_DLL Config& global_config(); } #endif
Add CRC16 checksum calculation function
#include "modlib.h" uint16_t MODBUSSwapEndian( uint16_t Data ) { //Change big-endian to little-endian and vice versa unsigned char Swap; //Create 2 bytes long union union Conversion { uint16_t Data; unsigned char 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; }
#include "modlib.h" uint16_t MODBUSSwapEndian( uint16_t Data ) { //Change big-endian to little-endian and vice versa unsigned char Swap; //Create 2 bytes long union union Conversion { uint16_t Data; unsigned char 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 CRC16( uint16_t *Data, uint16_t Length ) { //Calculate CRC16 checksum using given data and length uint16_t CRC = 0xFFFF; uint16_t i; unsigned char 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 // Else LSB is not set CRC >>= 1; } } return CRC; }
Fix header methods to be inline
#ifndef _INC_UTILS_H #define _INC_UTILS_H #include "basetypes.h" void *advancePtr(void *vp, SizeType len) { return (void*)((unsigned char *)(vp) + len); } const void *advancePtr(const void *vp, SizeType len) { return (void*)((unsigned char *)(vp) + len); } #endif//_INC_UTILS_H
#ifndef _INC_UTILS_H #define _INC_UTILS_H #include "basetypes.h" inline void *advancePtr(void *vp, SizeType len) { return (void*)((unsigned char *)(vp) + len); } inline const void *advancePtr(const void *vp, SizeType len) { return (void*)((unsigned char *)(vp) + len); } #endif//_INC_UTILS_H
Fix the handling of signedness, which caused a nasty bug
/* Bernstein's hash */ int djb_hash(const char* str, int len, int hash) { while (len--) { hash = (hash * 33) ^ *str++; } return hash; }
/* Bernstein's hash */ int djb_hash(const unsigned char* str, int len, int hash) { while (len--) { hash = (hash * 33) ^ *str++; } return hash; }
Document where our hash function comes from
int hashByteString(const char* str, int len) { int hash = 0; while (len--) { hash = (hash * 33) ^ *str++; } return hash; }
/* Bernstein's hash */ int hashByteString(const char* str, int len) { int hash = 0; while (len--) { hash = (hash * 33) ^ *str++; } return hash; }
Fix comment in header guard.
/* libcopy -- journal support * (c) 2011 Michał Górny * 2-clause BSD-licensed */ #pragma once #ifndef _ATOMIC_INSTALL_JOURNAL_H #define _ATOMIC_INSTALL_JOURNAL_H typedef struct ai_journal *journal_t; int ai_journal_create(const char *journal_path, const char *location); int ai_journal_open(const char *journal_path, journal_t *ret); int ai_journal_close(journal_t j); const char *ai_journal_get_files(journal_t j); #endif /*_ATOMIC_INSTALL_COPY_H*/
/* libcopy -- journal support * (c) 2011 Michał Górny * 2-clause BSD-licensed */ #pragma once #ifndef _ATOMIC_INSTALL_JOURNAL_H #define _ATOMIC_INSTALL_JOURNAL_H typedef struct ai_journal *journal_t; int ai_journal_create(const char *journal_path, const char *location); int ai_journal_open(const char *journal_path, journal_t *ret); int ai_journal_close(journal_t j); const char *ai_journal_get_files(journal_t j); #endif /*_ATOMIC_INSTALL_JOURNAL_H*/
Use strlen instead of sizeof
#include <openssl/aes.h> #include <openssl/rand.h> #include <stdio.h> #include <string.h> #include "crypt.h" typedef unsigned char aes_t; void generate_bytes(aes_t *buf) { if (!RAND_bytes(buf, sizeof(buf))) { fprintf(stderr, "[!] Could not generate key"); } } aes_t *encrypt(char *plaintext, aes_t *key, aes_t *iv) { aes_t *ciphertext = (aes_t *) malloc(BUFFER_SIZE); AES_KEY wctx; AES_set_encrypt_key(key, KEY_SIZE * 8, &wctx); AES_cbc_encrypt((aes_t *)plaintext, ciphertext, sizeof(ciphertext), &wctx, iv, AES_ENCRYPT); memset(iv, 0x00, AES_BLOCK_SIZE); return ciphertext; } char *decrypt(aes_t *ciphertext, aes_t *key, aes_t *iv) { aes_t *plaintext = (aes_t *) malloc(BUFFER_SIZE); AES_KEY wctx; AES_set_decrypt_key(key, KEY_SIZE * 8, &wctx); AES_cbc_encrypt(ciphertext, plaintext, sizeof(plaintext), &wctx, iv, AES_DECRYPT); memset(iv, 0x00, AES_BLOCK_SIZE); return (char *) plaintext; }
#include <openssl/aes.h> #include <openssl/rand.h> #include <stdio.h> #include <string.h> #include "crypt.h" typedef unsigned char aes_t; void generate_bytes(aes_t *buf) { if (!RAND_bytes(buf, sizeof(buf))) { fprintf(stderr, "[!] Could not generate key"); } } aes_t *encrypt(char *plaintext, aes_t *key, aes_t *iv) { aes_t *ciphertext = (aes_t *) malloc(BUFFER_SIZE); AES_KEY wctx; AES_set_encrypt_key(key, KEY_SIZE * 8, &wctx); AES_cbc_encrypt((aes_t *)plaintext, ciphertext, strlen(plaintext), &wctx, iv, AES_ENCRYPT); memset(iv, 0x00, AES_BLOCK_SIZE); return ciphertext; } char *decrypt(aes_t *ciphertext, aes_t *key, aes_t *iv) { aes_t *plaintext = (aes_t *) malloc(BUFFER_SIZE); AES_KEY wctx; AES_set_decrypt_key(key, KEY_SIZE * 8, &wctx); AES_cbc_encrypt(ciphertext, plaintext, strlen((char *)ciphertext), &wctx, iv, AES_DECRYPT); memset(iv, 0x00, AES_BLOCK_SIZE); return (char *) plaintext; }
Change parent of QFAppScriptDispatcherWrapper from QQuickItem to QObject
#ifndef QFAPPSCRIPTDISPATCHERWRAPPER_H #define QFAPPSCRIPTDISPATCHERWRAPPER_H #include <QQuickItem> #include <QPointer> #include "qfappdispatcher.h" class QFAppScriptDispatcherWrapper : public QQuickItem { Q_OBJECT public: QFAppScriptDispatcherWrapper(); QString type() const; void setType(const QString &type); QFAppDispatcher *dispatcher() const; void setDispatcher(QFAppDispatcher *dispatcher); public slots: void dispatch(QJSValue arguments); private: QString m_type; QPointer<QFAppDispatcher> m_dispatcher; }; #endif // QFAPPSCRIPTDISPATCHERWRAPPER_H
#ifndef QFAPPSCRIPTDISPATCHERWRAPPER_H #define QFAPPSCRIPTDISPATCHERWRAPPER_H #include <QQuickItem> #include <QPointer> #include "qfappdispatcher.h" class QFAppScriptDispatcherWrapper : public QObject { Q_OBJECT public: QFAppScriptDispatcherWrapper(); QString type() const; void setType(const QString &type); QFAppDispatcher *dispatcher() const; void setDispatcher(QFAppDispatcher *dispatcher); public slots: void dispatch(QJSValue arguments); private: QString m_type; QPointer<QFAppDispatcher> m_dispatcher; }; #endif // QFAPPSCRIPTDISPATCHERWRAPPER_H
Add file testing all forms of for loop
int sum = 0; void test_sum(){ if(sum == 45) printf("Ok!\n"); else printf("Wrong!\n"); sum = 0; } int main(){ int x; for(int x; x < 10; x++) sum += x; test_sum(); for(x = 0; x < 10; x++) sum += x; test_sum(); x = 0; for(;x < 10; x++) sum += x; test_sum(); x = 0; for(;; x++){ if( x >= 10) break; sum += x; } test_sum(); x = 0; for(;;){ if( x >= 10) break; sum += x; x++; } test_sum(); x = 0; for(;x < 10;){ sum += x; x++; } test_sum(); sum = 0; for(int x = 0;;x++){ if( x >= 10) break; sum += x; } test_sum(); for(x = 0;;x++){ if( x >= 10) break; sum += x; } test_sum(); sum = 0; for(int x = 0;x < 10;){ sum += x; x++; } test_sum(); sum = 0; for(x = 0;x < 10;){ sum += x; x++; } test_sum(); for(int x;;){ if( x >= 10) break; sum += x; x++; } test_sum(); for(x = 0;;){ if( x >= 10) break; sum += x; x++; } test_sum(); return 0; }
Allow .exe extension to ld to fix test with mingw.
// REQUIRES: clang-driver // REQUIRES: powerpc-registered-target // REQUIRES: nvptx-registered-target // // Verify that CUDA device commands do not get OpenMP flags. // // RUN: %clang -no-canonical-prefixes -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \ // RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE // // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" {{.*}}"-m" "elf64lppc"
// REQUIRES: clang-driver // REQUIRES: powerpc-registered-target // REQUIRES: nvptx-registered-target // // Verify that CUDA device commands do not get OpenMP flags. // // RUN: %clang -no-canonical-prefixes -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \ // RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE // // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc"
Switch MACHINE to "pc98" on FreeBSD/pc98. Add copyright.
/*- * This file is in the public domain. */ /* $FreeBSD$ */ #include <i386/param.h>
/*- * Copyright (c) 2005 TAKAHASHI Yoshihiro. * 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$ */ #define MACHINE "pc98" #include <i386/param.h>
Add missing 'empty' test program.
/* ==================================================================== Copyright (c) 2008 Ian Blumel. All rights reserved. This software is licensed as described in the file LICENSE, which you should have received as part of this distribution. ==================================================================== File: test_basic.c Provides a dumping ground for basic tests of fct. */ #include "fct.h" FCT_BGN() { } FCT_END();
Fix helpFindSign (floats don't have signs....)
#ifndef HELPER_H #define HELPER_H /*Helper function for calculating ABSOLUTE maximum of two floats Will return maximum absolute value (ignores sign) */ float helpFindMaxAbsFloat(float a, float b) { float aAbs = abs(a); float bAbs = abs(b); if (aAbs > bAbs) { return aAbs; } else { return bAbs; } } //Helper function for calculating ABSOLUTE minimum of two floats //Will return minimum absolute value (ignores sign) float helpFindMinAbsFloat(float a, float b) { float aAbs = abs(a); float bAbs = abs(b); if (aAbs < bAbs) { return aAbs; } else { return bAbs; } } //Returns sign of float int helpFindSign(float x) { if (x > 0.0) { return 1; } else if (x < 0.0) { return -1; } else { return 0; } } int helpRoundFloat(float x) { if (x > 0) { return (int)(x+0.5); } else { return (int)(x-0.5); } } #endif
#ifndef HELPER_H #define HELPER_H /*Helper function for calculating ABSOLUTE maximum of two floats Will return maximum absolute value (ignores sign) */ float helpFindMaxAbsFloat(float a, float b) { float aAbs = abs(a); float bAbs = abs(b); if (aAbs > bAbs) { return aAbs; } else { return bAbs; } } //Helper function for calculating ABSOLUTE minimum of two floats //Will return minimum absolute value (ignores sign) float helpFindMinAbsFloat(float a, float b) { float aAbs = abs(a); float bAbs = abs(b); if (aAbs < bAbs) { return aAbs; } else { return bAbs; } } //Returns sign of int int helpFindSign(int x) { if (x > 0.0) { return 1; } else if (x < 0.0) { return -1; } else { return 0; } } int helpRoundFloat(float x) { if (x > 0) { return (int)(x+0.5); } else { return (int)(x-0.5); } } #endif
Test we work with other, more complex types.
#include <stdio.h> #define SWAP(x, y) { \ typeof (x) tmp = y; \ y = x; \ x = tmp; \ } int main() { int a = 1; int b = 2; SWAP(a, b); printf("a: %d, b: %d\n", a, b); return 0; }
#include <stdio.h> #define SWAP(x, y) { \ typeof (x) tmp = y; \ y = x; \ x = tmp; \ } int main() { int a = 1; int b = 2; SWAP(a, b); printf("a: %d, b: %d\n", a, b); float arr[2] = {3.0, 4.0}; SWAP(arr[0], arr[1]); printf("arr[0]: %f, arr[1]: %f\n", arr[0], arr[1]); return 0; }
Create the display, free it at the end, exit with failure if the display doesn't open
/** * Phase 01 - Get a Window that works and can be closed. * * This code won't be structured very well, just trying to get stuff working. */ #include <stdlib.h> int main(int argc, char *argv[]) { return EXIT_SUCCESS; }
/** * Phase 01 - Get a Window that works and can be closed. * * This code won't be structured very well, just trying to get stuff working. */ #include <stdlib.h> #include <X11/Xlib.h> int main(int argc, char *argv[]) { Display *dpy = XOpenDisplay(NULL); if (dpy == NULL) { return EXIT_FAILURE; } XCloseDisplay(dpy); dpy = NULL; return EXIT_SUCCESS; }
Disable warnings about insecure functions
// Copyright 2012-2014 UX Productivity Pty Ltd // // 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 DocFormats_DFTypes_h #define DocFormats_DFTypes_h #ifdef _MSC_VER #define ATTRIBUTE_ALIGNED(n) #define ATTRIBUTE_FORMAT(archetype,index,first) #else #define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n))) #define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first))) #endif #include <sys/types.h> #include <stdint.h> #include <stdarg.h> #endif
// Copyright 2012-2014 UX Productivity Pty Ltd // // 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 DocFormats_DFTypes_h #define DocFormats_DFTypes_h #ifdef _MSC_VER #define ATTRIBUTE_ALIGNED(n) #define ATTRIBUTE_FORMAT(archetype,index,first) #else #define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n))) #define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first))) #endif #ifdef WIN32 #define _CRT_SECURE_NO_WARNINGS #endif #include <sys/types.h> #include <stdint.h> #include <stdarg.h> #endif
Fix issue with mock method.
#ifndef TACHYON_TEST_UTILS_MOCK_QUEUE_H_ #define TACHYON_TEST_UTILS_MOCK_QUEUE_H_ #include "gmock/gmock.h" #include "lib/queue_interface.h" namespace tachyon { namespace testing { // Mock class for queues. template <class T> class MockQueue : public QueueInterface<T> { public: MOCK_METHOD1_T(Enqueue, bool(const T &item)); MOCK_METHOD1_T(EnqueueBlocking, bool(const T &item)); MOCK_METHOD1_T(DequeueNext, bool(T *item)); MOCK_METHOD1_T(DequeueNextBlocking, void(T *item)); MOCK_METHOD0_T(GetOffset, int()); MOCK_METHOD0_T(FreeQueue, void()); }; } // namespace testing } // namespace tachyon #endif // TACHYON_TEST_UTILS_MOCK_QUEUE_H_
#ifndef TACHYON_TEST_UTILS_MOCK_QUEUE_H_ #define TACHYON_TEST_UTILS_MOCK_QUEUE_H_ #include "gmock/gmock.h" #include "lib/queue_interface.h" namespace tachyon { namespace testing { // Mock class for queues. template <class T> class MockQueue : public QueueInterface<T> { public: MOCK_METHOD1_T(Enqueue, bool(const T &item)); MOCK_METHOD1_T(EnqueueBlocking, bool(const T &item)); MOCK_METHOD1_T(DequeueNext, bool(T *item)); MOCK_METHOD1_T(DequeueNextBlocking, void(T *item)); MOCK_CONST_METHOD0_T(GetOffset, int()); MOCK_METHOD0_T(FreeQueue, void()); }; } // namespace testing } // namespace tachyon #endif // TACHYON_TEST_UTILS_MOCK_QUEUE_H_
Fix typo in empty struct test check
// RUN: %layout_check %s // RUN: %check %s struct A { }; // CHEKC: /warning: empty struct/ struct Containter { struct A a; }; struct Pre { int i; struct A a; int j; }; struct Pre p = { 1, /* warn */ 2 }; // CHECK: /warning: missing {} initialiser for empty struct/ struct Pre q = { 1, {}, 2 }; main() { struct A a = { 5 }; // CHECK: /warning: missing {} initialiser for empty struct/ struct A b = {}; struct Containter c = {{}}; c.a = (struct A){}; }
// RUN: %layout_check %s // RUN: %check %s struct A { }; // CHECK: /warning: empty struct/ struct Container { struct A a; }; struct Pre { int i; struct A a; int j; }; struct Pre p = { 1, /* warn */ 2 }; // CHECK: /warning: missing {} initialiser for empty struct/ struct Pre q = { 1, {}, 2 }; main() { struct A a = { 5 }; // CHECK: /warning: missing {} initialiser for empty struct/ struct A b = {}; struct Container c = {{}}; c.a = (struct A){}; }
Add missing egl pipe file
#include "target-helpers/inline_wrapper_sw_helper.h" #include "target-helpers/inline_debug_helper.h" #include "state_tracker/drm_driver.h" #include "i915/drm/i915_drm_public.h" #include "i915/i915_public.h" static struct pipe_screen * create_screen(int fd) { struct brw_winsys_screen *bws; struct pipe_screen *screen; bws = i915_drm_winsys_screen_create(fd); if (!bws) return NULL; screen = i915_screen_create(bws); if (!screen) return NULL; screen = debug_screen_wrap(screen); return screen; } PUBLIC DRM_DRIVER_DESCRIPTOR("i915", "i915", create_screen)
Remove unnecessary default constructor from KytheProtoOutput
// Copyright 2017-2020 The Verible Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_ #define VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_ #include "verilog/tools/kythe/kythe_facts.h" #include "verilog/tools/kythe/kythe_facts_extractor.h" namespace verilog { namespace kythe { class KytheProtoOutput : public KytheOutput { public: KytheProtoOutput() = default; // Output all Kythe facts from the indexing data in proto format. void Emit(const KytheIndexingData& indexing_data); }; } // namespace kythe } // namespace verilog #endif // VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_
// Copyright 2017-2020 The Verible Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_ #define VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_ #include "verilog/tools/kythe/kythe_facts.h" #include "verilog/tools/kythe/kythe_facts_extractor.h" namespace verilog { namespace kythe { class KytheProtoOutput : public KytheOutput { public: // Output all Kythe facts from the indexing data in proto format. void Emit(const KytheIndexingData& indexing_data); }; } // namespace kythe } // namespace verilog #endif // VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_
Split out get_offset(). Eliminated unnecessary call to strlen().
// Copyright 2016, Jeffrey E. Bedard #include "temperature.h" #include "config.h" #include "font.h" #include "util.h" #include <stdio.h> #include <string.h> // Returns x offset for next item uint16_t draw_temp(xcb_connection_t * xc, const uint16_t offset) { const uint8_t v = xstatus_system_value(XSTATUS_SYSFILE_TEMPERATURE)/1000; uint8_t sz = 4; char buf[sz]; const struct JBDim f = xstatus_get_font_size(); sz = snprintf(buf, sz, "%dC", v); xcb_image_text_8(xc, sz, xstatus_get_window(xc), xstatus_get_gc(xc), offset + XSTATUS_CONST_WIDE_PAD, f.h, buf); return f.w * strlen(buf) + offset + XSTATUS_CONST_WIDE_PAD + XSTATUS_CONST_PAD; }
// Copyright 2016, Jeffrey E. Bedard #include "temperature.h" #include "config.h" #include "font.h" #include "util.h" #include <stdio.h> static uint16_t get_offset(const uint16_t fw, const uint16_t offset, const uint8_t len) { return fw * len + offset + XSTATUS_CONST_WIDE_PAD + XSTATUS_CONST_PAD; } // Returns x offset for next item uint16_t draw_temp(xcb_connection_t * xc, const uint16_t offset) { const uint8_t v = xstatus_system_value(XSTATUS_SYSFILE_TEMPERATURE)/1000; uint8_t sz = 4; char buf[sz]; const struct JBDim f = xstatus_get_font_size(); sz = snprintf(buf, sz, "%dC", v); xcb_image_text_8(xc, sz, xstatus_get_window(xc), xstatus_get_gc(xc), offset + XSTATUS_CONST_WIDE_PAD, f.h, buf); return get_offset(f.w, offset, sz); }
Make error domain constants mirror app return codes
// // CDZThingsHubErrorDomain.h // thingshub // // Created by Chris Dzombak on 1/14/14. // Copyright (c) 2014 Chris Dzombak. All rights reserved. // #import "CDZThingsHubApplication.h" extern NSString * const kThingsHubErrorDomain; typedef NS_ENUM(NSInteger, CDZErrorCode) { CDZErrorCodeConfigurationValidationError = CDZThingsHubApplicationReturnCodeConfigError, CDZErrorCodeTestError = -1, };
// // CDZThingsHubErrorDomain.h // thingshub // // Created by Chris Dzombak on 1/14/14. // Copyright (c) 2014 Chris Dzombak. All rights reserved. // #import "CDZThingsHubApplication.h" extern NSString * const kThingsHubErrorDomain; typedef NS_ENUM(NSInteger, CDZErrorCode) { CDZErrorCodeTestError = 0, CDZErrorCodeAuthError = CDZThingsHubApplicationReturnCodeAuthError, CDZErrorCodeConfigurationValidationError = CDZThingsHubApplicationReturnCodeConfigError, CDZErrorCodeSyncFailure = CDZThingsHubApplicationReturnCodeSyncFailed, };
Use the class property instead of getter method
// // IRLSizePrivate.h // IRLSize // // Created by Jeff Kelley on 6/29/16. // Copyright © 2016 Detroit Labs. All rights reserved. // #ifndef IRLSizePrivate_h #define IRLSizePrivate_h typedef float RawLengthMeasurement; // meters typedef struct { RawLengthMeasurement width; RawLengthMeasurement height; } RawSize; #define RAW_SIZE_UNIT [NSUnitLength meters] #endif /* IRLSizePrivate_h */
// // IRLSizePrivate.h // IRLSize // // Created by Jeff Kelley on 6/29/16. // Copyright © 2016 Detroit Labs. All rights reserved. // #ifndef IRLSizePrivate_h #define IRLSizePrivate_h typedef float RawLengthMeasurement; // meters typedef struct { RawLengthMeasurement width; RawLengthMeasurement height; } RawSize; #define RAW_SIZE_UNIT NSUnitLength.meters #endif /* IRLSizePrivate_h */
Allow debug messages using GMATHML_DEBUG environment variable.
#include <gdomdebug.h> #include <glib/gprintf.h> static gboolean debug_enabled = FALSE; void gdom_debug (char const *format, ...) { va_list args; if (!debug_enabled) return; va_start (args, format); g_vprintf (format, args); g_printf ("\n"); va_end (args); } void gdom_debug_enable (void) { debug_enabled = TRUE; }
#include <gdomdebug.h> #include <glib/gprintf.h> #include <stdlib.h> static gboolean debug_checked = FALSE; static gboolean debug_enabled = FALSE; static gboolean _is_debug_enabled () { const char *debug_var; if (debug_checked) return debug_enabled; debug_var = g_getenv ("GMATHML_DEBUG"); debug_enabled = debug_var != NULL ? atoi (debug_var) != 0 : FALSE; debug_checked = TRUE; return debug_enabled; } void gdom_debug (char const *format, ...) { va_list args; if (!_is_debug_enabled()) return; va_start (args, format); g_vprintf (format, args); g_printf ("\n"); va_end (args); } void gdom_debug_enable (void) { debug_enabled = TRUE; debug_checked = TRUE; }
Clean it up so it compiles cleanly and works for REMOTE_ONLY case.
/* libunwind - a platform-independent unwind library Copyright (C) 2004 Hewlett-Packard Co Contributed by David Mosberger-Tang <davidm@hpl.hp.com> This file is part of libunwind. Copyright (c) 2003 Hewlett-Packard Co. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <stdio.h> #include <libunwind.h> extern int verbose; static void *funcs[] = { (void *) &unw_get_reg, (void *) &unw_get_fpreg, (void *) &unw_set_reg, (void *) &unw_set_fpreg, (void *) &unw_resume, (void *) &unw_create_addr_space, (void *) &unw_destroy_addr_space, (void *) &unw_get_accessors, (void *) &unw_flush_cache, (void *) &unw_set_caching_policy, (void *) &unw_regname, (void *) &unw_get_proc_info, (void *) &unw_get_save_loc, (void *) &unw_is_signal_frame, (void *) &unw_get_proc_name }; int test_generic (void) { unw_cursor_t c; if (verbose) printf (__FILE__": funcs[0]=%p\n", funcs[0]); #ifndef UNW_REMOTE_ONLY { ucontext_t uc; unw_getcontext (&uc); unw_init_local (&c, &uc); unw_init_remote (&c, unw_local_addr_space, &uc); } return unw_step (&c); #else return 0; #endif }
Add space between date and time
#pragma once #include <string> #if 0 int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; } int Strnicmp(const char* str1, const char* str2, int count) { int d = 0; while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } return d; } #endif #ifdef _MSC_VER #if _MSC_VER >= 1800 #define SL_CALL __vectorcall #else #define SL_CALL __cdecl #endif #else #define SL_CALL #endif #define COUNT_OF(X) (sizeof(X) / sizeof((X)[0])) #define ZERO_MEM(X, Y) (memset(X, 0, Y)); // For this to work, at least one .cpp file using this macro // needs to be compiled on _every_ build, otherwise it is outdated. #define SL_BUILD_DATE __DATE__ __TIME__
#pragma once #include <string> #if 0 int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; } int Strnicmp(const char* str1, const char* str2, int count) { int d = 0; while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } return d; } #endif #ifdef _MSC_VER #if _MSC_VER >= 1800 #define SL_CALL __vectorcall #else #define SL_CALL __cdecl #endif #else #define SL_CALL #endif #define COUNT_OF(X) (sizeof(X) / sizeof((X)[0])) #define ZERO_MEM(X, Y) (memset(X, 0, Y)); // For this to work, at least one .cpp file using this macro // needs to be compiled on _every_ build, otherwise it is outdated. #define SL_BUILD_DATE __DATE__ " " __TIME__
Add bye to exit words
#include "input.h" #include <ctype.h> #include <stdio.h> #include <string.h> void read_line(char *p) { if (fgets(p, MAX_SIZE, stdin) == NULL){ p[0] = '\0'; return; } remove_space(p); } int is_exit(const char* p) { const char* exit_words[] = { "exit", "quit", }; int len = (int)(sizeof(exit_words) / sizeof(char*)); int i; if (strlen(p) == 0){ return (1); } for (i = 0; i < len; i++){ if (strcmp(p, exit_words[i]) == 0){ return (1); } } return (0); } void remove_space(char* p) { int i, j; i = j = 0; while (p[i] != '\0'){ while (isspace(p[j])){ j++; } while (!isspace(p[j])){ p[i] = p[j]; if (p[i] == '\0'){ break; } else { i++; j++; } } } }
#include "input.h" #include <ctype.h> #include <stdio.h> #include <string.h> void read_line(char *p) { if (fgets(p, MAX_SIZE, stdin) == NULL){ p[0] = '\0'; return; } remove_space(p); } int is_exit(const char* p) { const char* exit_words[] = { "exit", "quit", "bye", }; int len = (int)(sizeof(exit_words) / sizeof(char*)); int i; if (strlen(p) == 0){ return (1); } for (i = 0; i < len; i++){ if (strcmp(p, exit_words[i]) == 0){ return (1); } } return (0); } void remove_space(char* p) { int i, j; i = j = 0; while (p[i] != '\0'){ while (isspace(p[j])){ j++; } while (!isspace(p[j])){ p[i] = p[j]; if (p[i] == '\0'){ break; } else { i++; j++; } } } }
Modify : doc for color
// // UIColor+Speed.h // LYCategory // // CREATED BY LUO YU ON 26/10/2016. // COPYRIGHT © 2016 LUO YU. ALL RIGHTS RESERVED. // #import <UIKit/UIKit.h> @interface UIColor (Speed) - (UIColor *)colorWithR:(CGFloat)redValue G:(CGFloat)greenValue B:(CGFloat)blueValue; @end
// // UIColor+Speed.h // LYCategory // // CREATED BY LUO YU ON 26/10/2016. // COPYRIGHT © 2016 LUO YU. ALL RIGHTS RESERVED. // #import <UIKit/UIKit.h> @interface UIColor (Speed) /** generate color object with red-green-blue values @param redValue red color value, 0~255 @param greenValue green color value, 0~255 @param blueValue blue color value, 0~255 @return color object */ - (UIColor *)colorWithR:(CGFloat)redValue G:(CGFloat)greenValue B:(CGFloat)blueValue; @end
Print grey pixel value as unsigned
#include <stdio.h> #include "stb_image.c" #define FILENAME "wikipedia_barcode.png" int main(int argc, char **argv) { int width, height, bytes_per_pixel; unsigned char *data = stbi_load(FILENAME, &width, &height, &bytes_per_pixel, STBI_default); if (data) { // Run through every pixel and print its greyscale value. for (int row = 0; row < height; row++) { int row_offset = row * width; for (int col = 0; col < width; col++) { char grey = data[row_offset + col]; printf("row %d, col %d: %d\n", row, col, grey); } } stbi_image_free(data); printf("width: %d\nheight: %d\nbytes per pixel: %d\n", width, height, bytes_per_pixel); } else { printf("stbi_load() failed with error: \"%s\"\n", stbi_failure_reason()); } return 0; }
#include <stdio.h> #include "stb_image.c" #define FILENAME "wikipedia_barcode.png" int main(int argc, char **argv) { int width, height, bytes_per_pixel; unsigned char *data = stbi_load(FILENAME, &width, &height, &bytes_per_pixel, STBI_default); if (data) { // Run through every pixel and print its greyscale value. for (int row = 0; row < height; row++) { int row_offset = row * width; for (int col = 0; col < width; col++) { char grey = data[row_offset + col]; printf("row %d, col %d: %u\n", row, col, grey); } } stbi_image_free(data); printf("width: %d\nheight: %d\nbytes per pixel: %d\n", width, height, bytes_per_pixel); } else { printf("stbi_load() failed with error: \"%s\"\n", stbi_failure_reason()); } return 0; }
Add include guard to fix wincon compile.
/* PDCurses */ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ #endif #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ #endif #if defined(PDC_WIDE) && !defined(UNICODE) # define UNICODE #endif #define WIN32_LEAN_AND_MEAN #include <windows.h> #undef MOUSE_MOVED #include <curspriv.h> typedef struct {short r, g, b; bool mapped;} PDCCOLOR; extern PDCCOLOR pdc_color[PDC_MAXCOL]; extern HANDLE pdc_con_out, pdc_con_in; extern DWORD pdc_quick_edit; extern DWORD pdc_last_blink; extern short pdc_curstoreal[16], pdc_curstoansi[16]; extern short pdc_oldf, pdc_oldb, pdc_oldu; extern bool pdc_conemu, pdc_wt, pdc_ansi; extern void PDC_blink_text(void);
/* PDCurses */ #ifndef __PDC_WIN_H__ #define __PDC_WIN_H__ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ #endif #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ #endif #if defined(PDC_WIDE) && !defined(UNICODE) # define UNICODE #endif #define WIN32_LEAN_AND_MEAN #include <windows.h> #undef MOUSE_MOVED #include <curspriv.h> typedef struct {short r, g, b; bool mapped;} PDCCOLOR; extern PDCCOLOR pdc_color[PDC_MAXCOL]; extern HANDLE pdc_con_out, pdc_con_in; extern DWORD pdc_quick_edit; extern DWORD pdc_last_blink; extern short pdc_curstoreal[16], pdc_curstoansi[16]; extern short pdc_oldf, pdc_oldb, pdc_oldu; extern bool pdc_conemu, pdc_wt, pdc_ansi; extern void PDC_blink_text(void); #endif
Fix MISRA rule 8.5 in common code
/* * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef BL2_H__ #define BL2_H__ struct entry_point_info; void bl2_main(void); struct entry_point_info *bl2_load_images(void); #endif /* BL2_H__ */
/* * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef BL2_H__ #define BL2_H__ void bl2_main(void); #endif /* BL2_H__ */
Increase read and write buffer size per peer.
#ifndef CJET_CONFIG_H #define CJET_CONFIG_H #define SERVER_PORT \ 11122 #define LISTEN_BACKLOG \ 40 /* * It is somehow beneficial if this size is 32 bit aligned. */ #define MAX_MESSAGE_SIZE \ 256 /* Linux specific configs */ #define MAX_EPOLL_EVENTS \ 100 #endif
#ifndef CJET_CONFIG_H #define CJET_CONFIG_H #define SERVER_PORT \ 11122 #define LISTEN_BACKLOG \ 40 /* * It is somehow beneficial if this size is 32 bit aligned. */ #define MAX_MESSAGE_SIZE \ 512 /* Linux specific configs */ #define MAX_EPOLL_EVENTS \ 100 #endif
Fix recent test for more diverse environments.
// REQUIRES: arm-registered-target // RUN: %clang -target thumbv7-none-linux-gnueabihf \ // RUN: -mcpu=cortex-a8 -mfloat-abi=hard \ // RUN: -O3 -S -emit-llvm -o - %s | FileCheck %s #include <arm_neon.h> float32x2_t test_fma_order(float32x2_t accum, float32x2_t lhs, float32x2_t rhs) { return vfma_f32(accum, lhs, rhs); // CHECK: call <2 x float> @llvm.fma.v2f32(<2 x float> %lhs, <2 x float> %rhs, <2 x float> %accum) } float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t rhs) { return vfmaq_f32(accum, lhs, rhs); // CHECK: call <4 x float> @llvm.fma.v4f32(<4 x float> %lhs, <4 x float> %rhs, <4 x float> %accum) }
// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \ // RUN: -target-abi aapcs \ // RUN: -target-cpu cortex-a8 \ // RUN: -mfloat-abi hard \ // RUN: -ffreestanding \ // RUN: -O3 -S -emit-llvm -o - %s | FileCheck %s #include <arm_neon.h> float32x2_t test_fma_order(float32x2_t accum, float32x2_t lhs, float32x2_t rhs) { return vfma_f32(accum, lhs, rhs); // CHECK: call <2 x float> @llvm.fma.v2f32(<2 x float> %lhs, <2 x float> %rhs, <2 x float> %accum) } float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t rhs) { return vfmaq_f32(accum, lhs, rhs); // CHECK: call <4 x float> @llvm.fma.v4f32(<4 x float> %lhs, <4 x float> %rhs, <4 x float> %accum) }
Fix license statement in header comment and add SPDS identifier
#ifndef _TESTUTILS_H #define _TESTUTILS_H /* * tslib/tests/testutils.h * * Copyright (C) 2004 Michael Opdenacker <michaelo@handhelds.org> * * This file is placed under the LGPL. * * * Misc utils for ts test programs */ #define RESET "\033[0m" #define RED "\033[31m" #define GREEN "\033[32m" #define BLUE "\033[34m" #define YELLOW "\033[33m" struct ts_button { int x, y, w, h; char *text; int flags; #define BUTTON_ACTIVE 0x00000001 }; void button_draw(struct ts_button *button); int button_handle(struct ts_button *button, int x, int y, unsigned int pressure); void getxy(struct tsdev *ts, int *x, int *y); void ts_flush (struct tsdev *ts); void print_ascii_logo(void); #endif /* _TESTUTILS_H */
#ifndef _TESTUTILS_H #define _TESTUTILS_H /* * tslib/tests/testutils.h * * Copyright (C) 2004 Michael Opdenacker <michaelo@handhelds.org> * * This file is placed under the GPL. * * SPDX-License-Identifier: GPL-2.0+ * * * Misc utils for ts test programs */ #define RESET "\033[0m" #define RED "\033[31m" #define GREEN "\033[32m" #define BLUE "\033[34m" #define YELLOW "\033[33m" struct ts_button { int x, y, w, h; char *text; int flags; #define BUTTON_ACTIVE 0x00000001 }; void button_draw(struct ts_button *button); int button_handle(struct ts_button *button, int x, int y, unsigned int pressure); void getxy(struct tsdev *ts, int *x, int *y); void ts_flush (struct tsdev *ts); void print_ascii_logo(void); #endif /* _TESTUTILS_H */
Add boolean type so yacc productions can return a boolean value. Add parameter mode type so we can tag parameters as IN, OUT, or BOTH.
#define FUNC 1 #define PARAM 2 #define PTR_PARAM 3 struct token { int tok_type; char *val; }; struct node { int node_type; char *type_name; char *id; int is_ptr; int is_const; int is_mapped; int is_array; int extract; struct node *next; struct node *prev; }; union yystype { struct token tok; struct node *node; }; #define YYSTYPE union yystype
#define FUNC 1 #define PARAM 2 #define PTR_PARAM 3 struct token { int tok_type; char *val; }; struct node { int node_type; char *type_name; char *id; int is_ptr; int is_const; int is_const_ptr; int is_mapped; int is_array; int in_param; int out_param; int extract; struct node *next; struct node *prev; }; struct p_mode { int in; int out; }; union yystype { struct token tok; struct node *node; struct p_mode param_mode; int bool; }; #define YYSTYPE union yystype
Add test case for PR2001.
// RUN: clang --emit-llvm-bc -o - %s | opt --std-compile-opts | llvm-dis > %t && // RUN: grep "ret i32" %t | count 1 && // RUN: grep "ret i32 1" %t | count 1 // PR2001 /* Test that the result of the assignment properly uses the value *in the bitfield* as opposed to the RHS. */ static int foo(int i) { struct { int f0 : 2; } x; return (x.f0 = i); } int bar() { return foo(-5) == -1; }
Fix linker warnings in rendering tests
/*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 17:34:48 +0200 (Wed, 31 Mar 2010) $ Version: $Revision: 21985 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef mitkRenderingTestHelper_h #define mitkRenderingTestHelper_h #include <string> #include <vtkSmartPointer.h> #include <vtkRenderWindow.h> #include <mitkRenderWindow.h> class vtkRenderWindow; class vtkRenderer; namespace mitk { class DataStorage; } class MITK_CORE_EXPORT mitkRenderingTestHelper { public: mitkRenderingTestHelper(int width, int height, mitk::DataStorage* ds); ~mitkRenderingTestHelper(); vtkRenderer* GetVtkRenderer(); vtkRenderWindow* GetVtkRenderWindow(); void SaveAsPNG(std::string fileName); protected: mitk::RenderWindow::Pointer m_RenderWindow; }; #endif
/*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 17:34:48 +0200 (Wed, 31 Mar 2010) $ Version: $Revision: 21985 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef mitkRenderingTestHelper_h #define mitkRenderingTestHelper_h #include <string> #include <vtkSmartPointer.h> #include <vtkRenderWindow.h> #include <mitkRenderWindow.h> class vtkRenderWindow; class vtkRenderer; namespace mitk { class DataStorage; } class mitkRenderingTestHelper { public: mitkRenderingTestHelper(int width, int height, mitk::DataStorage* ds); ~mitkRenderingTestHelper(); vtkRenderer* GetVtkRenderer(); vtkRenderWindow* GetVtkRenderWindow(); void SaveAsPNG(std::string fileName); protected: mitk::RenderWindow::Pointer m_RenderWindow; }; #endif
Use 0-padding for i386 and arm print format specifiers
#include <stdio.h> #include <stdarg.h> void print_address(const char *str, int n, ...) { fprintf(stderr, "%s", str); va_list ap; va_start(ap, n); while (n--) { void *p = va_arg(ap, void *); #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "0x%012lx ", (unsigned long) p); #elif defined(__i386__) || defined(__arm__) fprintf(stderr, "0x%8lx ", (unsigned long) p); #elif defined(__mips64) fprintf(stderr, "0x%010lx ", (unsigned long) p); #endif } fprintf(stderr, "\n"); }
#include <stdio.h> #include <stdarg.h> void print_address(const char *str, int n, ...) { fprintf(stderr, "%s", str); va_list ap; va_start(ap, n); while (n--) { void *p = va_arg(ap, void *); #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "0x%012lx ", (unsigned long) p); #elif defined(__i386__) || defined(__arm__) fprintf(stderr, "0x%08lx ", (unsigned long) p); #elif defined(__mips64) fprintf(stderr, "0x%010lx ", (unsigned long) p); #endif } fprintf(stderr, "\n"); }
Fix this test so it doesn't try to open a file to write to the source tree
// RUN: not %clang_cc1 -emit-llvm %s -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s // CHECK: error: Could not read profile: // CHECK-NOT: Assertion failed
// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s // CHECK: error: Could not read profile: // CHECK-NOT: Assertion failed
Switch to use MICROPY_FLOAT_IMPL config define.
// options to control how Micro Python is built #define MICROPY_EMIT_CPYTHON (1) #define MICROPY_ENABLE_LEXER_UNIX (1) #define MICROPY_ENABLE_FLOAT (1) // type definitions for the specific machine #ifdef __LP64__ typedef long machine_int_t; // must be pointer size typedef unsigned long machine_uint_t; // must be pointer size #else // These are definitions for machines where sizeof(int) == sizeof(void*), // regardless for actual size. typedef int machine_int_t; // must be pointer size typedef unsigned int machine_uint_t; // must be pointer size #endif #define BYTES_PER_WORD sizeof(machine_int_t) typedef void *machine_ptr_t; // must be of pointer size typedef const void *machine_const_ptr_t; // must be of pointer size typedef double machine_float_t; machine_float_t machine_sqrt(machine_float_t x);
// options to control how Micro Python is built #define MICROPY_EMIT_CPYTHON (1) #define MICROPY_ENABLE_LEXER_UNIX (1) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) // type definitions for the specific machine #ifdef __LP64__ typedef long machine_int_t; // must be pointer size typedef unsigned long machine_uint_t; // must be pointer size #else // These are definitions for machines where sizeof(int) == sizeof(void*), // regardless for actual size. typedef int machine_int_t; // must be pointer size typedef unsigned int machine_uint_t; // must be pointer size #endif #define BYTES_PER_WORD sizeof(machine_int_t) typedef void *machine_ptr_t; // must be of pointer size typedef const void *machine_const_ptr_t; // must be of pointer size typedef double machine_float_t; machine_float_t machine_sqrt(machine_float_t x);
Add `isEqualToFirebaseModel:` to public header
// // Created by Michael Kuck on 7/7/16. // Copyright (c) 2016 Michael Kuck. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @class FIRDatabaseReference; @class FIRDataSnapshot; //============================================================ //== Public Interface //============================================================ @interface MKFirebaseModel : NSObject @property (nonatomic, readonly) FIRDatabaseReference *firebaseRef; @property (nonatomic, readonly) NSString *identifier; - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithFirebaseRef:(FIRDatabaseReference *)firebaseRef snapshotValue:(NSDictionary *)snapshotValue NS_DESIGNATED_INITIALIZER; - (instancetype)initWithSnapshot:(FIRDataSnapshot *)snapshot; @end NS_ASSUME_NONNULL_END
// // Created by Michael Kuck on 7/7/16. // Copyright (c) 2016 Michael Kuck. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @class FIRDatabaseReference; @class FIRDataSnapshot; //============================================================ //== Public Interface //============================================================ @interface MKFirebaseModel : NSObject @property (nonatomic, readonly) FIRDatabaseReference *firebaseRef; @property (nonatomic, readonly) NSString *identifier; - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithFirebaseRef:(FIRDatabaseReference *)firebaseRef snapshotValue:(NSDictionary *)snapshotValue NS_DESIGNATED_INITIALIZER; - (instancetype)initWithSnapshot:(FIRDataSnapshot *)snapshot; - (BOOL)isEqualToFirebaseModel:(MKFirebaseModel *)firebaseModel; @end NS_ASSUME_NONNULL_END
Put states inside the class
/**************************************************************************** * Copyright 2016 BlueMasters * * 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 SOLENOID__H #define SOLENOID__H #include <Arduino.h> #include "StateMachine.h" #include "LED.h" #include "RFIDSensor.h" #include "WolvesTypes.h" enum solenoidState { SOLENOID_IDLE, SOLENOID_FROZEN, SOLENOID_FIRED, SOLENOID_WAITING }; class Solenoid : public StateMachine { public: Solenoid(int impulsePin, RFIDSensor sensor, LED led) : _impulsePin(impulsePin), _sensor(sensor), _led(led) {}; void begin(); void on(); void off(); void tick(); private: int _impulsePin; RFIDSensor _sensor; LED _led; solenoidState _state; long _timestamp; void fire(long t); void release(long t); }; #endif
/**************************************************************************** * Copyright 2016 BlueMasters * * 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 SOLENOID__H #define SOLENOID__H #include <Arduino.h> #include "StateMachine.h" #include "LED.h" #include "RFIDSensor.h" #include "WolvesTypes.h" class Solenoid : public StateMachine { public: Solenoid(int impulsePin, RFIDSensor sensor, LED led) : _impulsePin(impulsePin), _sensor(sensor), _led(led) {}; void begin(); void on(); void off(); void tick(); private: enum solenoidState { SOLENOID_IDLE, SOLENOID_FROZEN, SOLENOID_FIRED, SOLENOID_WAITING }; int _impulsePin; RFIDSensor _sensor; LED _led; solenoidState _state; long _timestamp; void fire(long t); void release(long t); }; #endif
Remove redundant void argument lists
#ifndef __itkImageFilterMultipleOutputs_h #define __itkImageFilterMultipleOutputs_h #include "itkImageToImageFilter.h" namespace itk { template <class TImage> class ImageFilterMultipleOutputs : public ImageToImageFilter<TImage, TImage> { public: /** Standard class type alias. */ using Self = ImageFilterMultipleOutputs; using Superclass = ImageToImageFilter<TImage, TImage>; using Pointer = SmartPointer<Self>; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ImageFilterMultipleOutputs, ImageToImageFilter); TImage * GetOutput1(); TImage * GetOutput2(); protected: ImageFilterMultipleOutputs(); ~ImageFilterMultipleOutputs() override = default; /** Does the real work. */ void GenerateData() override; /** Create the Output */ DataObject::Pointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx); private: ImageFilterMultipleOutputs(const Self &) = delete; // purposely not implemented void operator=(const Self &) = delete; // purposely not implemented }; } // namespace itk #ifndef ITK_MANUAL_INSTANTIATION # include "ImageFilterMultipleOutputs.hxx" #endif #endif // __itkImageFilterMultipleOutputs_h
#ifndef __itkImageFilterMultipleOutputs_h #define __itkImageFilterMultipleOutputs_h #include "itkImageToImageFilter.h" namespace itk { template <class TImage> class ImageFilterMultipleOutputs : public ImageToImageFilter<TImage, TImage> { public: /** Standard class type alias. */ using Self = ImageFilterMultipleOutputs; using Superclass = ImageToImageFilter<TImage, TImage>; using Pointer = SmartPointer<Self>; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ImageFilterMultipleOutputs, ImageToImageFilter); TImage * GetOutput1(); TImage * GetOutput2(); protected: ImageFilterMultipleOutputs(); ~ImageFilterMultipleOutputs() override = default; /** Does the real work. */ void GenerateData() override; /** Create the Output */ DataObject::Pointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override; private: ImageFilterMultipleOutputs(const Self &) = delete; // purposely not implemented void operator=(const Self &) = delete; // purposely not implemented }; } // namespace itk #ifndef ITK_MANUAL_INSTANTIATION # include "ImageFilterMultipleOutputs.hxx" #endif #endif // __itkImageFilterMultipleOutputs_h
Add allclose function for testing
#pragma once #include <string> #include <sstream> #include <Eigen/Dense> std::string output_matrices(Eigen::MatrixXd expected, Eigen::MatrixXd actual) { std::stringstream ss; ss << "expected:\n" << expected << "\nactual:\n" << actual << std::endl; return ss.str(); }
#pragma once #include <string> #include <sstream> #include <Eigen/Dense> std::string output_matrices(Eigen::MatrixXd expected, Eigen::MatrixXd actual) { std::stringstream ss; ss << "expected:\n" << expected << "\nactual:\n" << actual << std::endl; return ss.str(); } /* * allclose() function to match numpy.allclose * https://stackoverflow.com/questions/15051367/how-to-compare-vectors-approximately-in-eige://stackoverflow.com/questions/15051367/how-to-compare-vectors-approximately-in-eigen */ namespace test { template<typename DerivedA, typename DerivedB> bool allclose(const Eigen::DenseBase<DerivedA>& a, const Eigen::DenseBase<DerivedB>& b, const typename DerivedA::RealScalar& rtol = Eigen::NumTraits<typename DerivedA::RealScalar>::dummy_precision(), const typename DerivedA::RealScalar& atol = Eigen::NumTraits<typename DerivedA::RealScalar>::epsilon()) { return ((a.derived() - b.derived()).array().abs() <= (atol + rtol * b.derived().array().abs())).all(); } } // namespace test
Add an example of M_LET_IF
#include "m-core.h" // Stubs defined for the example. Real code will use soundio library. struct SoundIo { int x; }; struct SoundIoDevice { int x; }; struct SoundIoOutStream { int x; }; static struct SoundIo *soundio_create(void) { return (struct SoundIo *) malloc(sizeof(struct SoundIo)); } static void soundio_destroy(struct SoundIo *s) { free(s); } static struct SoundIoDevice *soundio_get_device(struct SoundIo *io, int def) { (void) io; (void) def; return (struct SoundIoDevice *) malloc(sizeof(struct SoundIoDevice)); } static void soundio_device_unref(struct SoundIoDevice *s) { free(s); } static struct SoundIoOutStream *soundio_outstream_create(struct SoundIoDevice *device) { (void) device ; return (struct SoundIoOutStream *) malloc(sizeof(struct SoundIoOutStream)); } static void soundio_outstream_destroy(struct SoundIoOutStream *s) { free(s); } static bool soundio_wait_events(struct SoundIo *s) { (void) s; return false; } // End of stubs int main(void) { int err = 1; /* Example of using M_LET_IF macro to simplify writing error handling code. The following code creates some object, test if the object creation succeeds, register the destructor, and print an error if something went wrong */ M_LET_IF( struct SoundIo *soundio = soundio_create(), soundio != 0 , soundio_destroy(soundio) , fprintf(stderr, "out of memory for soundio\n") ) M_LET_IF(struct SoundIoDevice *device = soundio_get_device(soundio, -1), device != 0, soundio_device_unref(device), fprintf(stderr, "out of memory for device\n")) M_LET_IF(struct SoundIoOutStream *outstream = soundio_outstream_create(device), outstream != 0, soundio_outstream_destroy(outstream), fprintf(stderr, "out of memory for stream\n")) { err = 0; bool cont = true; while (cont) cont = soundio_wait_events(soundio); } return err; }
Fix for particle firmware v0.6.2
#include "application.h" #ifndef _INCL_MDNS #define _INCL_MDNS #include "Buffer.h" #include "Label.h" #include "Record.h" #include <map> #include <vector> #define MDNS_PORT 5353 #define BUFFER_SIZE 512 #define HOSTNAME "" class MDNS { public: bool setHostname(String hostname); bool addService(String protocol, String service, uint16_t port, String instance, std::vector<String> subServices = std::vector<String>()); void addTXTEntry(String key, String value = NULL); bool begin(); bool processQueries(); private: struct QueryHeader { uint16_t id; uint16_t flags; uint16_t qdcount; uint16_t ancount; uint16_t nscount; uint16_t arcount; }; UDP * udp = new UDP(); Buffer * buffer = new Buffer(BUFFER_SIZE); Label * ROOT = new Label(""); Label * LOCAL = new Label("local", ROOT); Label::Matcher * matcher = new Label::Matcher(); ARecord * aRecord; TXTRecord * txtRecord; std::map<String, Label *> labels; std::vector<Record *> records; String status = "Ok"; QueryHeader readHeader(Buffer * buffer); void getResponses(); void writeResponses(); bool isAlphaDigitHyphen(String string); bool isNetUnicode(String string); }; #endif
#include "application.h" #ifndef _INCL_MDNS #define _INCL_MDNS #include "Buffer.h" #include "Label.h" #include "Record.h" #include <map> #include <vector> #define MDNS_PORT 5353 #define BUFFER_SIZE 512 #define HOSTNAME "" class MDNS { public: bool setHostname(String hostname); bool addService(String protocol, String service, uint16_t port, String instance, std::vector<String> subServices = std::vector<String>()); void addTXTEntry(String key, String value = ""); bool begin(); bool processQueries(); private: struct QueryHeader { uint16_t id; uint16_t flags; uint16_t qdcount; uint16_t ancount; uint16_t nscount; uint16_t arcount; }; UDP * udp = new UDP(); Buffer * buffer = new Buffer(BUFFER_SIZE); Label * ROOT = new Label(""); Label * LOCAL = new Label("local", ROOT); Label::Matcher * matcher = new Label::Matcher(); ARecord * aRecord; TXTRecord * txtRecord; std::map<String, Label *> labels; std::vector<Record *> records; String status = "Ok"; QueryHeader readHeader(Buffer * buffer); void getResponses(); void writeResponses(); bool isAlphaDigitHyphen(String string); bool isNetUnicode(String string); }; #endif
Add a test for caching an empty string
#include <string.h> #include "lib/minunit.h" #include "acacia.h" //#define TEST_KEY "abcd1111" #define TEST_KEY "abcdefghijklmnopqrstuvwxyz" #define TEST_VALUE "foo_bar_baz_111" MU_TEST(test_check) { struct Node *cache = cache_init(); cache_set(TEST_KEY, TEST_VALUE, cache); mu_check(strcmp(cache_get(TEST_KEY, cache), TEST_VALUE) == 0); cache_close(cache); } MU_TEST_SUITE(test_suite) { MU_RUN_TEST(test_check); } int main(int argc, const char *argv[]) { MU_RUN_SUITE(test_suite); MU_REPORT(); return 0; }
#include <string.h> #include "lib/minunit.h" #include "acacia.h" #define TEST_KEY "abcdefghijklmnopqrstuvwxyz" #define TEST_VALUE "foo_bar_baz_111" MU_TEST(test_store_fetch_simple) { struct Node *cache = cache_init(); cache_set(TEST_KEY, TEST_VALUE, cache); mu_check(strcmp(cache_get(TEST_KEY, cache), TEST_VALUE) == 0); cache_close(cache); } MU_TEST(test_store_fetch_empty_string) { struct Node *cache = cache_init(); cache_set("foo", "", cache); mu_check(strcmp(cache_get("foo", cache), "") == 0); cache_close(cache); } MU_TEST_SUITE(test_suite) { MU_RUN_TEST(test_store_fetch_simple); MU_RUN_TEST(test_store_fetch_empty_string); } int main(int argc, const char *argv[]) { MU_RUN_SUITE(test_suite); MU_REPORT(); return 0; }
Fix below warning by including "unistd.h" also
#include <signal.h> #include <stdio.h> #include <errno.h> #include <string.h> // Invokes a process, making sure that the state of the signal // handlers has all been set back to the unix default. int main(int argc, char **argv) { int i; sigset_t blockedsigs; struct sigaction action; // unblock all signals sigemptyset(&blockedsigs); sigprocmask(SIG_BLOCK, NULL, NULL); // reset all signals to SIG_DFL memset(&action, 0, sizeof(action)); action.sa_handler = SIG_DFL; action.sa_flags = 0; sigemptyset(&action.sa_mask); for(i = 0; i < NSIG; ++i) sigaction(i, &action, NULL); execv(argv[1], argv+1); fprintf(stderr, "failed to execv %s\n", argv[1]); return 0; }
#include <signal.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> // Invokes a process, making sure that the state of the signal // handlers has all been set back to the unix default. int main(int argc, char **argv) { int i; sigset_t blockedsigs; struct sigaction action; // unblock all signals sigemptyset(&blockedsigs); sigprocmask(SIG_BLOCK, NULL, NULL); // reset all signals to SIG_DFL memset(&action, 0, sizeof(action)); action.sa_handler = SIG_DFL; action.sa_flags = 0; sigemptyset(&action.sa_mask); for(i = 0; i < NSIG; ++i) sigaction(i, &action, NULL); execv(argv[1], argv+1); fprintf(stderr, "failed to execv %s\n", argv[1]); return 0; }
Remove getPlantName metohod & Add getPlant mathod
#ifndef LAND_H #define LAND_H #include <string> #include "Plant.h" class Land { public: ~Land(); const std::string getPlantName() const { return isStood_? plant_->getName() : "Empty"; } bool put(Plant & plant); bool getStood()const{return isStood_;} private: Plant * plant_ = nullptr; bool isStood_ = false; }; #endif // LAND_H #ifndef MAP_H #define MAP_H #include <vector> class Map { public: // with this constructor, you could get a map with [land_num] empty land Map(int land_num); Land operator[] (int i) { return lands_[i]; } const Land operator[] (int i) const { return lands_[i]; } int size() { return lands_.size(); } bool put(Plant & plant, int position) { return lands_[position].put(plant); } private: constexpr static int max_land_num = 10; std::vector<Land> lands_; }; #endif // MAP_H
#ifndef LAND_H #define LAND_H #include <string> #include "Plant.h" class Land { public: ~Land(); bool put(Plant & plant); bool getStood()const{return isStood_;} Plant & getPlant() { return *plant_; } const Plant & getPlant() const { return *plant_; } private: Plant * plant_ = nullptr; bool isStood_ = false; }; #endif // LAND_H #ifndef MAP_H #define MAP_H #include <vector> class Map { public: // with this constructor, you could get a map with [land_num] empty land Map(int land_num); Land operator[] (int i) { return lands_[i]; } const Land operator[] (int i) const { return lands_[i]; } int size() { return lands_.size(); } bool put(Plant & plant, int position) { return lands_[position].put(plant); } private: constexpr static int max_land_num = 10; std::vector<Land> lands_; }; #endif // MAP_H
Define ODP_THREAD_WORKER and ODP_THREAD_CONTROL as in it's original enum, instead of mangling them.
/* Copyright (c) 2015, ENEA Software AB * Copyright (c) 2015, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef __OFP_ODP_COMPAT__ #define __OFP_ODP_COMPAT__ #if ODP_VERSION == 102 #include "linux.h" #else #include "odp/helper/linux.h" #endif /* odp_version == 102 */ #if ODP_VERSION < 105 typedef uint64_t odp_time_t; #endif /* ODP_VERSION < 105 */ #if ODP_VERSION < 104 && ODP_VERSION > 101 #define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_def_worker(cpumask, num_workers) #elif ODP_VERSION < 102 #define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_count(cpumask) #define ODP_THREAD_WORKER #define ODP_THREAD_CONTROL #endif #endif
/* Copyright (c) 2015, ENEA Software AB * Copyright (c) 2015, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef __OFP_ODP_COMPAT__ #define __OFP_ODP_COMPAT__ #if ODP_VERSION == 102 #include "linux.h" #else #include "odp/helper/linux.h" #endif /* odp_version == 102 */ #if ODP_VERSION < 105 typedef uint64_t odp_time_t; #endif /* ODP_VERSION < 105 */ #if ODP_VERSION < 104 && ODP_VERSION > 101 #define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_def_worker(cpumask, num_workers) #elif ODP_VERSION < 102 #define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_count(cpumask) #define odp_init_local(x) odp_init_local() #define ODP_THREAD_WORKER 0 #define ODP_THREAD_CONTROL 1 #endif #endif
Add conditional definition of PyMPI_MPI_Message and MPI_Message PyMPI_MPI_Message. This is needed for MPI_VERSION<3 and a recent version of mpi4py.
/***** Preamble block ********************************************************* * * This file is part of h5py, a Python interface to the HDF5 library. * * http://www.h5py.org * * Copyright 2008-2013 Andrew Collette and contributors * * License: Standard 3-clause BSD; see "license.txt" for full license terms * and contributor agreement. * ****** End preamble block ****************************************************/ /* Contains compatibility macros and definitions for use by Cython code */ #ifndef H5PY_COMPAT #define H5PY_COMPAT #include <stddef.h> #include "Python.h" #include "numpy/arrayobject.h" #include "hdf5.h" /* The HOFFSET macro can't be used from Cython. */ #define h5py_size_n64 (sizeof(npy_complex64)) #define h5py_size_n128 (sizeof(npy_complex128)) #define h5py_offset_n64_real (HOFFSET(npy_complex64, real)) #define h5py_offset_n64_imag (HOFFSET(npy_complex64, imag)) #define h5py_offset_n128_real (HOFFSET(npy_complex128, real)) #define h5py_offset_n128_imag (HOFFSET(npy_complex128, imag)) #endif
/***** Preamble block ********************************************************* * * This file is part of h5py, a Python interface to the HDF5 library. * * http://www.h5py.org * * Copyright 2008-2013 Andrew Collette and contributors * * License: Standard 3-clause BSD; see "license.txt" for full license terms * and contributor agreement. * ****** End preamble block ****************************************************/ /* Contains compatibility macros and definitions for use by Cython code */ #ifndef H5PY_COMPAT #define H5PY_COMPAT #if (MPI_VERSION < 3) && !defined(PyMPI_HAVE_MPI_Message) typedef void *PyMPI_MPI_Message; #define MPI_Message PyMPI_MPI_Message #endif #include <stddef.h> #include "Python.h" #include "numpy/arrayobject.h" #include "hdf5.h" /* The HOFFSET macro can't be used from Cython. */ #define h5py_size_n64 (sizeof(npy_complex64)) #define h5py_size_n128 (sizeof(npy_complex128)) #define h5py_offset_n64_real (HOFFSET(npy_complex64, real)) #define h5py_offset_n64_imag (HOFFSET(npy_complex64, imag)) #define h5py_offset_n128_real (HOFFSET(npy_complex128, real)) #define h5py_offset_n128_imag (HOFFSET(npy_complex128, imag)) #endif
Use correct syntax, correct weak/strong for [__]strxfrm
/* * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #define L_strlcpy #define Wstrlcpy __strlcpy #include "wstring.c" strong_alias(__strlcpy, strlcpy) #ifdef __LOCALE_C_ONLY weak_alias(strlcpy, strxfrm) #endif #undef L_strlcpy
/* * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #define L_strlcpy #define Wstrlcpy __strlcpy #include "wstring.c" strong_alias(__strlcpy, strlcpy) #ifdef __LOCALE_C_ONLY weak_alias(__strlcpy, __strxfrm) strong_alias(__strxfrm, strxfrm) #endif #undef L_strlcpy
Fix open() syscall in libk
#include <fcntl.h> #include <k/sys.h> int open(const char *path, int oflag, ...) { return MAKE_SYSCALL(open, path, oflag); } int fcntl(int fildes, int cmd, ...) { //FIXME for bash return MAKE_SYSCALL(unimplemented, "fcntl", false); }
#include <fcntl.h> #include <stdarg.h> #include <k/sys.h> int open(const char *path, int oflag, ...) { int mode = 0; if(oflag & O_CREAT) { va_list va; va_start(va, oflag); mode = va_arg(va, int); va_end(va); } return MAKE_SYSCALL(open, path, oflag, mode); } int fcntl(int fildes, int cmd, ...) { //FIXME for bash return MAKE_SYSCALL(unimplemented, "fcntl", false); }
Fix reference typed reply placeholder
// Copyright (c) 2015 GitHub, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #ifndef BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_ #define BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_ #import <Foundation/Foundation.h> #include <string> #include "base/mac/scoped_nsobject.h" #include "brightray/browser/notification.h" namespace brightray { class CocoaNotification : public Notification { public: CocoaNotification(NotificationDelegate* delegate, NotificationPresenter* presenter); ~CocoaNotification(); // Notification: void Show(const base::string16& title, const base::string16& msg, const std::string& tag, const GURL& icon_url, const SkBitmap& icon, bool silent, const bool has_reply, const base::string16 reply_placeholder) override; void Dismiss() override; void NotificationDisplayed(); void NotificationReplied(const std::string reply); NSUserNotification* notification() const { return notification_; } private: base::scoped_nsobject<NSUserNotification> notification_; DISALLOW_COPY_AND_ASSIGN(CocoaNotification); }; } // namespace brightray #endif // BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
// Copyright (c) 2015 GitHub, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #ifndef BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_ #define BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_ #import <Foundation/Foundation.h> #include <string> #include "base/mac/scoped_nsobject.h" #include "brightray/browser/notification.h" namespace brightray { class CocoaNotification : public Notification { public: CocoaNotification(NotificationDelegate* delegate, NotificationPresenter* presenter); ~CocoaNotification(); // Notification: void Show(const base::string16& title, const base::string16& msg, const std::string& tag, const GURL& icon_url, const SkBitmap& icon, bool silent, const bool has_reply, const base::string16& reply_placeholder) override; void Dismiss() override; void NotificationDisplayed(); void NotificationReplied(const std::string reply); NSUserNotification* notification() const { return notification_; } private: base::scoped_nsobject<NSUserNotification> notification_; DISALLOW_COPY_AND_ASSIGN(CocoaNotification); }; } // namespace brightray #endif // BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
Include float.h if present before defining math stuff
#ifndef AL_MATH_DEFS_H #define AL_MATH_DEFS_H #define F_PI (3.14159265358979323846f) #define F_PI_2 (1.57079632679489661923f) #define F_TAU (6.28318530717958647692f) #ifndef FLT_EPSILON #define FLT_EPSILON (1.19209290e-07f) #endif #define DEG2RAD(x) ((ALfloat)(x) * (F_PI/180.0f)) #define RAD2DEG(x) ((ALfloat)(x) * (180.0f/F_PI)) #endif /* AL_MATH_DEFS_H */
#ifndef AL_MATH_DEFS_H #define AL_MATH_DEFS_H #ifdef HAVE_FLOAT_H #include <float.h> #endif #define F_PI (3.14159265358979323846f) #define F_PI_2 (1.57079632679489661923f) #define F_TAU (6.28318530717958647692f) #ifndef FLT_EPSILON #define FLT_EPSILON (1.19209290e-07f) #endif #define DEG2RAD(x) ((ALfloat)(x) * (F_PI/180.0f)) #define RAD2DEG(x) ((ALfloat)(x) * (180.0f/F_PI)) #endif /* AL_MATH_DEFS_H */
Add missing header for -lh5- decoder.
/* Copyright (c) 2011, Simon Howard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LHASA_LHA_LH5_DECODER_H #define LHASA_LHA_LH5_DECODER_H #include "lha_decoder.h" extern LHADecoderType lha_lh5_decoder; #endif /* #ifndef LHASA_LHA_LH5_DECODER_H */
Replace cast by safer access
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <haka/error.h> #include <haka/regexp_module.h> struct regexp_module *regexp_module_load(const char *module_name, struct parameters *args) { struct module *module = module_load(module_name, args); if (module == NULL || module->type != MODULE_REGEXP) { if (module != NULL) module_release(module); error(L"Module %s is not of type MODULE_REGEXP", module_name); return NULL; } return (struct regexp_module *)module; } void regexp_module_release(struct regexp_module *module) { module_release((struct module *)module); }
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <haka/error.h> #include <haka/regexp_module.h> struct regexp_module *regexp_module_load(const char *module_name, struct parameters *args) { struct module *module = module_load(module_name, args); if (module == NULL || module->type != MODULE_REGEXP) { if (module != NULL) module_release(module); error(L"Module %s is not of type MODULE_REGEXP", module_name); return NULL; } return (struct regexp_module *)module; } void regexp_module_release(struct regexp_module *module) { module_release(&module->module); }
Clean up the tickable definition.
// itickable.h // // Interface definition of an object that is updated during the tick cycle. // #ifndef DEMO_ITICKABLE_H #define DEMO_ITICKABLE_H namespace demo { namespace obj { class ITickable { public: // CONSTRUCTORS ~ITickable(); // MEMBER FUNCTIONS /** * Prepare for the next tick cycle. */ virtual void preTick() = 0; /** * Update the object. * @param dt The elapsed time. */ virtual void tick( float dt ) = 0; /** * Clean up after the tick cycle. */ virtual void postTick() = 0; }; // CONSTRUCTORS ITickable::~ITickable() { } } // End nspc obj } // End nspc demo #endif // DEMO_ITICKABLE_H
// itickable.h // // Interface definition of an object that is updated during the tick cycle. // #ifndef DEMO_ITICKABLE_H #define DEMO_ITICKABLE_H namespace demo { namespace obj { class ITickable { public: // CONSTRUCTORS /** * Destruct the tickable. */ ~ITickable(); // MEMBER FUNCTIONS /** * Prepare for the next tick cycle. */ virtual void preTick() = 0; /** * Update the object. * @param dt The elapsed time in seconds. */ virtual void tick( float dt ) = 0; /** * Clean up after the tick cycle. */ virtual void postTick() = 0; }; // CONSTRUCTORS inline ITickable::~ITickable() { } } // End nspc obj } // End nspc demo #endif // DEMO_ITICKABLE_H
Add an important info. for scatter datasource
@import UIKit; @protocol HYPScatterPlotDataSource; @class HYPScatterPoint; @class HYPScatterLabel; @interface HYPScatterPlot : UIView @property (nonatomic) UIColor *averageLineColor; @property (nonatomic) UIColor *xAxisColor; @property (nonatomic) UIColor *yAxisMidGradient; @property (nonatomic) UIColor *yAxisEndGradient; @property (nonatomic, weak) id<HYPScatterPlotDataSource> dataSource; @end @protocol HYPScatterPlotDataSource <NSObject> @required - (NSArray *)scatterPointsForScatterPlot:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)maximumXValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)minimumXValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)maximumYValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)minimumYValue:(HYPScatterPlot *)scatterPlot; @optional - (CGFloat)averageYValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)minimumYLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)maximumYLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)minimumXLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)maximumXLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)averageLabel:(HYPScatterPlot *)scatterPlot; @end
@import UIKit; @protocol HYPScatterPlotDataSource; @class HYPScatterPoint; @class HYPScatterLabel; @interface HYPScatterPlot : UIView @property (nonatomic) UIColor *averageLineColor; @property (nonatomic) UIColor *xAxisColor; @property (nonatomic) UIColor *yAxisMidGradient; @property (nonatomic) UIColor *yAxisEndGradient; @property (nonatomic, weak) id<HYPScatterPlotDataSource> dataSource; @end @protocol HYPScatterPlotDataSource <NSObject> @required /** @return should be a list of HYPScatterPoint objects */ - (NSArray *)scatterPointsForScatterPlot:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)maximumXValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)minimumXValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)maximumYValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterPoint *)minimumYValue:(HYPScatterPlot *)scatterPlot; @optional - (CGFloat)averageYValue:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)minimumYLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)maximumYLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)minimumXLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)maximumXLabel:(HYPScatterPlot *)scatterPlot; - (HYPScatterLabel *)averageLabel:(HYPScatterPlot *)scatterPlot; @end
Add missing extern "C" statements
#ifndef FLASH_WRITER_H #define FLASH_WRITER_H #include <stdint.h> #include <stddef.h> /** Unlocks the flash for programming. */ void flash_writer_unlock(void); /** Locks the flash */ void flash_writer_lock(void); /** Erases the flash page at given address. */ void flash_writer_page_erase(void *page); /** Writes data to given location in flash. */ void flash_writer_page_write(void *page, uint8_t *data, size_t len); #endif /* FLASH_WRITER_H */
#ifndef FLASH_WRITER_H #define FLASH_WRITER_H #include <stdint.h> #include <stddef.h> #ifdef __cplusplus extern "C" { #endif /** Unlocks the flash for programming. */ void flash_writer_unlock(void); /** Locks the flash */ void flash_writer_lock(void); /** Erases the flash page at given address. */ void flash_writer_page_erase(void *page); /** Writes data to given location in flash. */ void flash_writer_page_write(void *page, uint8_t *data, size_t len); #ifdef __cplusplus } #endif #endif /* FLASH_WRITER_H */
Improve compound literal test case.
// RUN: clang -checker-simple -verify %s int* f1() { int x = 0; return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}} } int* f2(int y) { return &y; // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}} } int* f3(int x, int *y) { int w = 0; if (x) y = &w; return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}} } unsigned short* compound_literal() { return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}} }
// RUN: clang -checker-simple -verify %s int* f1() { int x = 0; return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}} } int* f2(int y) { return &y; // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}} } int* f3(int x, int *y) { int w = 0; if (x) y = &w; return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}} } void* compound_literal(int x) { if (x) return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}} struct s { int z; double y; int w; }; return &((struct s){ 2, 0.4, 5 * 8 }); }
Remove unnecessary fields in class.
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_enableSizeButton_clicked(); private: Ui::MainWindow *ui; double **xnPlus, **xnMinus, **ynPlus, **ynMinus; double alpha, beta, epsilon, lyambda, fi; double tau, n; private: void initArrays(); void initTauComboBox(); void initQwtPlot(); double func1(double xn, double yn); double func2(double xn); void buildTrajectory(int numTraj); }; #endif // MAINWINDOW_H
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_enableSizeButton_clicked(); private: Ui::MainWindow *ui; double **xnPlus, **xnMinus, **ynPlus, **ynMinus; private: void initArrays(); void initTauComboBox(); void initQwtPlot(); double func1(double xn, double yn); double func2(double xn); void buildTrajectory(int numTraj); }; #endif // MAINWINDOW_H
Fix import in private HTMLNode header
// // HTMLNode+Private.h // HTMLKit // // Created by Iska on 20/12/15. // Copyright © 2015 BrainCookie. All rights reserved. // ///------------------------------------------------------ /// HTMLKit private header ///------------------------------------------------------ #import <HTMLKit/HTMLKit.h> /** Private HTML Node methods which are not intended for public API. */ @interface HTMLNode () /** A read-write redeclaration of the same property in the public API. */ @property (nonatomic, weak) HTMLDocument *ownerDocument; /** A read-write redeclaration of the same property in the public API. */ @property (nonatomic, weak) HTMLNode *parentNode; /** Designated initializer of the HTML Node, which, however, should not be used directly. It is intended to be called only by subclasses. @abstract Use concrete subclasses of the HTML Node. @param name The node's name. @param type The node's type. @return A new instance of a HTML Node. */ - (instancetype)initWithName:(NSString *)name type:(HTMLNodeType)type NS_DESIGNATED_INITIALIZER; /** Casts this node to a HTML Element. This cast should only be performed after the appropriate check. */ - (HTMLElement *)asElement; /** Returns the same string representation of the DOM tree rooted at this node that is used by html5lib-tests. @disucssion This method is indended for testing purposes. */ - (NSString *)treeDescription; @end
// // HTMLNode+Private.h // HTMLKit // // Created by Iska on 20/12/15. // Copyright © 2015 BrainCookie. All rights reserved. // ///------------------------------------------------------ /// HTMLKit private header ///------------------------------------------------------ #import "HTMLNode.h" /** Private HTML Node methods which are not intended for public API. */ @interface HTMLNode () /** A read-write redeclaration of the same property in the public API. */ @property (nonatomic, weak) HTMLDocument *ownerDocument; /** A read-write redeclaration of the same property in the public API. */ @property (nonatomic, weak) HTMLNode *parentNode; /** Designated initializer of the HTML Node, which, however, should not be used directly. It is intended to be called only by subclasses. @abstract Use concrete subclasses of the HTML Node. @param name The node's name. @param type The node's type. @return A new instance of a HTML Node. */ - (instancetype)initWithName:(NSString *)name type:(HTMLNodeType)type NS_DESIGNATED_INITIALIZER; /** Casts this node to a HTML Element. This cast should only be performed after the appropriate check. */ - (HTMLElement *)asElement; /** Returns the same string representation of the DOM tree rooted at this node that is used by html5lib-tests. @disucssion This method is indended for testing purposes. */ - (NSString *)treeDescription; @end
Revert "No reason for readonly properties to be retained"
// // SGFeature.h // SimpleGeo // // Created by Seth Fitzsimmons on 11/14/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "SGPoint.h" @interface SGFeature : NSObject { NSString* featureId; SGPoint* geometry; NSDictionary* properties; NSString* rawBody; } @property (readonly) NSString* featureId; @property (readonly) SGPoint* geometry; @property (readonly) NSDictionary* properties; @property (readonly) NSString* rawBody; + (SGFeature *)featureWithId:(NSString *)id; + (SGFeature *)featureWithId:(NSString *)id data:(NSDictionary *)data; + (SGFeature *)featureWithId:(NSString *)id data:(NSDictionary *)data rawBody:(NSString *)rawBody; + (SGFeature *)featureWithData:(NSDictionary *)data; - (id)initWithId:(NSString *)id; - (id)initWithId:(NSString *)id data:(NSDictionary *)data; - (id)initWithId:(NSString *)id data:(NSDictionary *)data rawBody:(NSString *)rawBody; @end
// // SGFeature.h // SimpleGeo // // Created by Seth Fitzsimmons on 11/14/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "SGPoint.h" @interface SGFeature : NSObject { NSString* featureId; SGPoint* geometry; NSDictionary* properties; NSString* rawBody; } @property (retain,readonly) NSString* featureId; @property (retain,readonly) SGPoint* geometry; @property (retain,readonly) NSDictionary* properties; @property (retain,readonly) NSString* rawBody; + (SGFeature *)featureWithId:(NSString *)id; + (SGFeature *)featureWithId:(NSString *)id data:(NSDictionary *)data; + (SGFeature *)featureWithId:(NSString *)id data:(NSDictionary *)data rawBody:(NSString *)rawBody; + (SGFeature *)featureWithData:(NSDictionary *)data; - (id)initWithId:(NSString *)id; - (id)initWithId:(NSString *)id data:(NSDictionary *)data; - (id)initWithId:(NSString *)id data:(NSDictionary *)data rawBody:(NSString *)rawBody; @end
Replace malloc + memset with calloc
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <util.h> #include "trie.h" #define char_index(c) c - 97 trie * trie_init(void) { trie *t = emalloc(sizeof(*t)); memset(t, 0, sizeof(*t)); t->children = emalloc(R_SIZE * sizeof(*(t->children))); memset(t->children, 0, sizeof(*(t->children))); return t; } void trie_insert(trie *t, const char *key, size_t value) { const char *c = key; trie *cur_node = t; while (*c) { if (cur_node->children[char_index(*c)] == NULL) cur_node->children[char_index(*c)] = trie_init(); cur_node = cur_node->children[char_index(*c)]; c++; } cur_node->count = value; } size_t trie_get(trie *t, const char *key) { const char *c = key; trie *cur_node = t; while (*c) { if (cur_node->children[char_index(*c)] == NULL) return 0; cur_node = cur_node->children[char_index(*c)]; c++; } return cur_node->count; }
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <util.h> #include "trie.h" #define char_index(c) c - 97 trie * trie_init(void) { trie *t = emalloc(sizeof(*t)); memset(t, 0, sizeof(*t)); t->children = ecalloc(R_SIZE, sizeof(*(t->children))); return t; } void trie_insert(trie *t, const char *key, size_t value) { const char *c = key; trie *cur_node = t; while (*c) { if (cur_node->children[char_index(*c)] == NULL) cur_node->children[char_index(*c)] = trie_init(); cur_node = cur_node->children[char_index(*c)]; c++; } cur_node->count = value; } size_t trie_get(trie *t, const char *key) { const char *c = key; trie *cur_node = t; while (*c) { if (cur_node->children[char_index(*c)] == NULL) return 0; cur_node = cur_node->children[char_index(*c)]; c++; } return cur_node->count; }
Bump Cycles version to 1.11.0 (Blender 2.81)
/* * Copyright 2011-2016 Blender Foundation * * 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 __UTIL_VERSION_H__ #define __UTIL_VERSION_H__ /* Cycles version number */ CCL_NAMESPACE_BEGIN #define CYCLES_VERSION_MAJOR 1 #define CYCLES_VERSION_MINOR 10 #define CYCLES_VERSION_PATCH 0 #define CYCLES_MAKE_VERSION_STRING2(a, b, c) #a "." #b "." #c #define CYCLES_MAKE_VERSION_STRING(a, b, c) CYCLES_MAKE_VERSION_STRING2(a, b, c) #define CYCLES_VERSION_STRING \ CYCLES_MAKE_VERSION_STRING(CYCLES_VERSION_MAJOR, CYCLES_VERSION_MINOR, CYCLES_VERSION_PATCH) CCL_NAMESPACE_END #endif /* __UTIL_VERSION_H__ */
/* * Copyright 2011-2016 Blender Foundation * * 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 __UTIL_VERSION_H__ #define __UTIL_VERSION_H__ /* Cycles version number */ CCL_NAMESPACE_BEGIN #define CYCLES_VERSION_MAJOR 1 #define CYCLES_VERSION_MINOR 11 #define CYCLES_VERSION_PATCH 0 #define CYCLES_MAKE_VERSION_STRING2(a, b, c) #a "." #b "." #c #define CYCLES_MAKE_VERSION_STRING(a, b, c) CYCLES_MAKE_VERSION_STRING2(a, b, c) #define CYCLES_VERSION_STRING \ CYCLES_MAKE_VERSION_STRING(CYCLES_VERSION_MAJOR, CYCLES_VERSION_MINOR, CYCLES_VERSION_PATCH) CCL_NAMESPACE_END #endif /* __UTIL_VERSION_H__ */
Add link to explanation of what we mean by zombie The person triaging / debugging a zombie crash may never have heard of this before.
// Copyright (c) 2010 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 CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #define CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #pragma once #import <Foundation/Foundation.h> // You should think twice every single time you use anything from this // namespace. namespace ObjcEvilDoers { // Enable zombies. Returns NO if it fails to enable. // // When |zombieAllObjects| is YES, all objects inheriting from // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie // is queried to determine whether to make the object a zombie. // // |zombieCount| controls how many zombies to store before freeing the // oldest. Set to 0 to free objects immediately after making them // zombies. BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount); // Disable zombies. void ZombieDisable(); } // namespace ObjcEvilDoers @interface NSObject (CrZombie) - (BOOL)shouldBecomeCrZombie; @end #endif // CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
// Copyright (c) 2010 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 CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #define CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_ #pragma once #import <Foundation/Foundation.h> // You should think twice every single time you use anything from this // namespace. namespace ObjcEvilDoers { // Enable zombie object debugging. This implements a variant of Apple's // NSZombieEnabled which can help expose use-after-free errors where messages // are sent to freed Objective-C objects in production builds. // // Returns NO if it fails to enable. // // When |zombieAllObjects| is YES, all objects inheriting from // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie // is queried to determine whether to make the object a zombie. // // |zombieCount| controls how many zombies to store before freeing the // oldest. Set to 0 to free objects immediately after making them // zombies. BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount); // Disable zombies. void ZombieDisable(); } // namespace ObjcEvilDoers @interface NSObject (CrZombie) - (BOOL)shouldBecomeCrZombie; @end #endif // CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
Fix jade version of class_loader not containing class_loader.hpp
#ifndef ROS_BOOT_H #define ROS_BOOT_H /// PROJECT #include <csapex/core/bootstrap_plugin.h> #include <csapex/core/core_fwd.h> #include <csapex/model/model_fwd.h> #include <csapex/msg/msg_fwd.h> #include <csapex/view/view_fwd.h> /// SYSTEM // clang-format off #include <csapex/utility/suppress_warnings_start.h> #include <pluginlib/class_loader.hpp> #include <csapex/utility/suppress_warnings_end.h> // clang-format on namespace csapex { class RosBoot : public BootstrapPlugin { public: RosBoot(); void boot(csapex::PluginLocator* locator); private: std::vector<std::string> valid_plugin_xml_files_; pluginlib::ClassLoader<CorePlugin> loader_core_; pluginlib::ClassLoader<MessageProvider> loader_msg_; pluginlib::ClassLoader<MessageRenderer> loader_msg_renderer_; pluginlib::ClassLoader<Node> loader_node_; pluginlib::ClassLoader<NodeAdapterBuilder> loader_node_adapter_; pluginlib::ClassLoader<ParameterAdapterBuilder> loader_param_adapter_; pluginlib::ClassLoader<DragIOHandler> loader_drag_io_; }; } // namespace csapex #endif // ROS_BOOT_H
#ifndef ROS_BOOT_H #define ROS_BOOT_H /// PROJECT #include <csapex/core/bootstrap_plugin.h> #include <csapex/core/core_fwd.h> #include <csapex/model/model_fwd.h> #include <csapex/msg/msg_fwd.h> #include <csapex/view/view_fwd.h> /// SYSTEM // clang-format off #include <csapex/utility/suppress_warnings_start.h> #if CLASS_LOADER_USES_HPP #include <pluginlib/class_loader.hpp> #else #include <pluginlib/class_loader.h> #endif #include <csapex/utility/suppress_warnings_end.h> // clang-format on namespace csapex { class RosBoot : public BootstrapPlugin { public: RosBoot(); void boot(csapex::PluginLocator* locator); private: std::vector<std::string> valid_plugin_xml_files_; pluginlib::ClassLoader<CorePlugin> loader_core_; pluginlib::ClassLoader<MessageProvider> loader_msg_; pluginlib::ClassLoader<MessageRenderer> loader_msg_renderer_; pluginlib::ClassLoader<Node> loader_node_; pluginlib::ClassLoader<NodeAdapterBuilder> loader_node_adapter_; pluginlib::ClassLoader<ParameterAdapterBuilder> loader_param_adapter_; pluginlib::ClassLoader<DragIOHandler> loader_drag_io_; }; } // namespace csapex #endif // ROS_BOOT_H