Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Update comment in test case.
// PARAM: --set trans.activated[+] "assert" // Running the assert transformation on this test yields in code that is not compilable by gcc struct s { int a; int b; }; union u { struct s str; int i; }; int main(){ union u un; struct s* ptr; un.str.a = 1; un.str.b = 2; ptr = &un.str; int r; int x; if(r){ x = 2; } else { x = 3; } return 0; }
// PARAM: --set trans.activated[+] "assert" // Running the assert transformation on this test used to yield code that cannot be compiled with gcc, due to superfluous offsets on a pointer struct s { int a; int b; }; union u { struct s str; int i; }; int main(){ union u un; struct s* ptr; un.str.a = 1; un.str.b = 2; ptr = &un.str; int r; int x; if(r){ x = 2; } else { x = 3; } return 0; }
Allow for node address query by using 'N' command without parameters
#ifdef __USE_CMSIS #include "LPC8xx.h" #endif #include <cr_section_macros.h> #include <string.h> #include "parse_util.h" #include "cmd.h" #include "err.h" #include "frame_buffer.h" /** * Set node address * Args: <node-addr> */ extern frame_buffer_type tx_buffer; int cmd_set_node_addr (int argc, uint8_t **argv) { if (argc != 2) { return E_WRONG_ARGC; } tx_buffer.header.from_addr=parse_hex(argv[1]); return E_OK; }
#ifdef __USE_CMSIS #include "LPC8xx.h" #endif #include <cr_section_macros.h> #include <string.h> #include "parse_util.h" #include "cmd.h" #include "err.h" #include "frame_buffer.h" /** * Set node address * Args: <node-addr> */ extern frame_buffer_type tx_buffer; int cmd_set_node_addr (int argc, uint8_t **argv) { if (argc == 1) { MyUARTSendStringZ("n "); MyUARTPrintHex(tx_buffer.header.from_addr); MyUARTSendCRLF(); return; } if (argc != 2) { return E_WRONG_ARGC; } tx_buffer.header.from_addr=parse_hex(argv[1]); return E_OK; }
Update TextInputFlags to include autocapitalize values.
// Copyright 2014 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 UI_BASE_IME_TEXT_INPUT_FLAGS_H_ #define UI_BASE_IME_TEXT_INPUT_FLAGS_H_ namespace ui { // Intentionally keep in sync with blink::WebTextInputFlags defined in: // third_party/WebKit/public/web/WebTextInputType.h enum TextInputFlags { TEXT_INPUT_FLAG_NONE = 0, TEXT_INPUT_FLAG_AUTOCOMPLETE_ON = 1 << 0, TEXT_INPUT_FLAG_AUTOCOMPLETE_OFF = 1 << 1, TEXT_INPUT_FLAG_AUTOCORRECT_ON = 1 << 2, TEXT_INPUT_FLAG_AUTOCORRECT_OFF = 1 << 3, TEXT_INPUT_FLAG_SPELLCHECK_ON = 1 << 4, TEXT_INPUT_FLAG_SPELLCHECK_OFF = 1 << 5 }; } // namespace ui #endif // UI_BASE_IME_TEXT_INPUT_FLAGS_H_
// Copyright 2014 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 UI_BASE_IME_TEXT_INPUT_FLAGS_H_ #define UI_BASE_IME_TEXT_INPUT_FLAGS_H_ namespace ui { // Intentionally keep in sync with blink::WebTextInputFlags defined in: // third_party/WebKit/public/web/WebTextInputType.h enum TextInputFlags { TEXT_INPUT_FLAG_NONE = 0, TEXT_INPUT_FLAG_AUTOCOMPLETE_ON = 1 << 0, TEXT_INPUT_FLAG_AUTOCOMPLETE_OFF = 1 << 1, TEXT_INPUT_FLAG_AUTOCORRECT_ON = 1 << 2, TEXT_INPUT_FLAG_AUTOCORRECT_OFF = 1 << 3, TEXT_INPUT_FLAG_SPELLCHECK_ON = 1 << 4, TEXT_INPUT_FLAG_SPELLCHECK_OFF = 1 << 5, TEXT_INPUT_FLAG_AUTOCAPITALIZE_NONE = 1 << 6, TEXT_INPUT_FLAG_AUTOCAPITALIZE_CHARACTERS = 1 << 7, TEXT_INPUT_FLAG_AUTOCAPITALIZE_WORDS = 1 << 8, TEXT_INPUT_FLAG_AUTOCAPITALIZE_SENTENCES = 1 << 9 }; } // namespace ui #endif // UI_BASE_IME_TEXT_INPUT_FLAGS_H_
Fix spelling error in the SVC handler
// The Mordax Microkernel // (c) Kristian Klomsten Skordal 2013 <kristian.skordal@gmail.com> // Report bugs and issues on <http://github.com/skordal/mordax/issues> #include "context.h" #include "debug.h" #include "svc.h" // Supervisor call (software interrupt) handler, called by target assembly // code: void svc_interrupt_handler(struct thread_context * context, uint8_t svc) { debug_printf("Supervisor call: %d, context at %p\n", svc, context); debug_printf("\tArgument 1: %x\n", context_get_svc_argument(context, 0)); debug_prinff("\tArgument 2: %x\n", context_get_svc_argument(context, 1)); debug_printf("\tArgument 3: %x\n", context_get_svc_argument(context, 2)); debug_printf("\tReturning 0...\n"); context_set_svc_retval(context, 0); }
// The Mordax Microkernel // (c) Kristian Klomsten Skordal 2013 <kristian.skordal@gmail.com> // Report bugs and issues on <http://github.com/skordal/mordax/issues> #include "context.h" #include "debug.h" #include "svc.h" // Supervisor call (software interrupt) handler, called by target assembly // code: void svc_interrupt_handler(struct thread_context * context, uint8_t svc) { debug_printf("Supervisor call: %d, context at %p\n", svc, context); debug_printf("\tArgument 1: %x\n", context_get_svc_argument(context, 0)); debug_printf("\tArgument 2: %x\n", context_get_svc_argument(context, 1)); debug_printf("\tArgument 3: %x\n", context_get_svc_argument(context, 2)); debug_printf("\tReturning 0...\n"); context_set_svc_retval(context, 0); }
Change to org.bluez.MediaControl1 as interface name
/* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2006-2010 Nokia Corporation * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define AUDIO_CONTROL_INTERFACE "org.bluez.Control1" struct control *control_init(struct audio_device *dev, GSList *uuids); void control_update(struct control *control, GSList *uuids); void control_unregister(struct audio_device *dev); gboolean control_is_active(struct audio_device *dev); int control_connect(struct audio_device *dev); int control_disconnect(struct audio_device *dev);
/* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2006-2010 Nokia Corporation * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define AUDIO_CONTROL_INTERFACE "org.bluez.MediaControl1" struct control *control_init(struct audio_device *dev, GSList *uuids); void control_update(struct control *control, GSList *uuids); void control_unregister(struct audio_device *dev); gboolean control_is_active(struct audio_device *dev); int control_connect(struct audio_device *dev); int control_disconnect(struct audio_device *dev);
Revert 88154 - Use scoped_ptr for Panel in PanelBrowserWindowGTK. Reason: PanelBrowserWindow dtor is now complex and cannot be inlined.
// Copyright (c) 2011 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_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #include "chrome/browser/ui/gtk/browser_window_gtk.h" class Panel; class PanelBrowserWindowGtk : public BrowserWindowGtk { public: PanelBrowserWindowGtk(Browser* browser, Panel* panel); virtual ~PanelBrowserWindowGtk() {} // BrowserWindowGtk overrides virtual void Init() OVERRIDE; // BrowserWindow overrides virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; protected: // BrowserWindowGtk overrides virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge) OVERRIDE; virtual bool HandleTitleBarLeftMousePress( GdkEventButton* event, guint32 last_click_time, gfx::Point last_click_position) OVERRIDE; virtual void SaveWindowPosition() OVERRIDE; virtual void SetGeometryHints() OVERRIDE; virtual bool UseCustomFrame() OVERRIDE; private: void SetBoundsImpl(); scoped_ptr<Panel> panel_; DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk); }; #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_
// Copyright (c) 2011 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_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ #include "chrome/browser/ui/gtk/browser_window_gtk.h" class Panel; class PanelBrowserWindowGtk : public BrowserWindowGtk { public: PanelBrowserWindowGtk(Browser* browser, Panel* panel); virtual ~PanelBrowserWindowGtk() {} // BrowserWindowGtk overrides virtual void Init() OVERRIDE; // BrowserWindow overrides virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; protected: // BrowserWindowGtk overrides virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge) OVERRIDE; virtual bool HandleTitleBarLeftMousePress( GdkEventButton* event, guint32 last_click_time, gfx::Point last_click_position) OVERRIDE; virtual void SaveWindowPosition() OVERRIDE; virtual void SetGeometryHints() OVERRIDE; virtual bool UseCustomFrame() OVERRIDE; private: void SetBoundsImpl(); Panel* panel_; DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk); }; #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_
Add killer test case from the C99 specification.
#define x 3 #define f(a) f(x * (a)) #undef x #define x 2 #define g f #define z z[0] #define h g(~ #define m(a) a(w) #define w 0,1 #define t(a) a #define p() int #define q(x) x #define r(x,y) x ## y f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); g(x +(3,4)-w) | h 5) & m (f)^m(m); p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)};
Set client release to false
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 2 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2014 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 2 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE false // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2014 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
Add sixth exercise from chapter 5.
/* The content of `example2.txt` will be "Gidday world" because the file offset for `fd3` will be at the beginning of the file. Only `fd1` and `fd2` share the same file offset, that's why when writing "HELLO," replaces "Hello," but the next write (with `fd3`) happens at beginning and then we are left with "Gidday world". */ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(__attribute__((unused)) int _argc, __attribute__((unused)) char **argv) { int fd1, fd2, fd3; const char *filename = "example2.txt"; fd1 = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); fd2 = dup(fd1); fd3 = open(filename, O_RDWR); write(fd1, "Hello,", 6); write(fd2, " world", 6); lseek(fd2, 0, SEEK_SET); write(fd1, "HELLO,", 6); write(fd3, "Gidday", 6); exit(EXIT_SUCCESS); }
Fix typos and remove unused includes
/* * Copyright (C) 2014 Freie Universität Berlin * Copyright (C) 2014 PHYTEC Messtechnik GmbH * Copyright (C) 2017 Eistec AB * * This file is subject to the terms and conditions of the GNU Lesser General * Public License v2.1. See the file LICENSE in the top level directory for more * details. */ /** * @ingroup boards_frdm-k64f * @{ * * @file * @brief Board specific implementations for the FRDM-K22F * * @author Joakim Nohlgård <joakim.nohlgard@eistec.se> * * @} */ #include <stdint.h> #include "board.h" #include "mcg.h" #include "periph/gpio.h" void board_init(void) { /* initialize the CPU core */ cpu_init(); /* initialize and turn off the on-board RGB-LED */ gpio_init(LED0_PIN, GPIO_OUT); gpio_init(LED1_PIN, GPIO_OUT); gpio_init(LED2_PIN, GPIO_OUT); gpio_set(LED0_PIN); gpio_set(LED1_PIN); gpio_set(LED2_PIN); }
/* * Copyright (C) 2014 Freie Universität Berlin * Copyright (C) 2014 PHYTEC Messtechnik GmbH * Copyright (C) 2017 Eistec AB * * This file is subject to the terms and conditions of the GNU Lesser General * Public License v2.1. See the file LICENSE in the top level directory for more * details. */ /** * @ingroup boards_frdm-k22f * @{ * * @file * @brief Board specific implementations for the FRDM-K22F * * @author Joakim Nohlgård <joakim.nohlgard@eistec.se> * * @} */ #include "board.h" #include "periph/gpio.h" void board_init(void) { /* initialize the CPU core */ cpu_init(); /* initialize and turn off the on-board RGB-LED */ gpio_init(LED0_PIN, GPIO_OUT); gpio_set(LED0_PIN); gpio_init(LED1_PIN, GPIO_OUT); gpio_set(LED1_PIN); gpio_init(LED2_PIN, GPIO_OUT); gpio_set(LED2_PIN); }
Replace hardref trick with strdup() for consistency.
#include <stdlib.h> #include <string.h> #include <assert.h> #include "options.h" struct Options *Options_parse(int argc, char *argv[]) { assert(argc > 1); Options *opts = malloc(sizeof(Options)); assert(opts != NULL); opts->outfile = NULL; opts->errfile = NULL; opts->target = NULL; opts->child_args = NULL; int i; for (i = 1; i < argc; i++) { switch((int)argv[i][0]) { case '-': switch((int)argv[i][1]) { case 'o': if (argv[i + 1][0] != '-') { opts->outfile = strdup(argv[i + 1]); } break; case 'e': if (argv[i + 1][0] != '-') { opts->errfile = strdup(argv[i + 1]); } break; case '-': if (argv[i + 1] != NULL) { opts->target = &argv[i + 1][0]; opts->child_args = &argv[i + 1]; } break; default: break; } break; default: break; } } return opts; }
#include <stdlib.h> #include <string.h> #include <assert.h> #include "options.h" struct Options *Options_parse(int argc, char *argv[]) { assert(argc > 1); Options *opts = malloc(sizeof(Options)); assert(opts != NULL); opts->outfile = NULL; opts->errfile = NULL; opts->target = NULL; opts->child_args = NULL; int i; for (i = 1; i < argc; i++) { switch((int)argv[i][0]) { case '-': switch((int)argv[i][1]) { case 'o': if (argv[i + 1][0] != '-') { opts->outfile = strdup(argv[i + 1]); } break; case 'e': if (argv[i + 1][0] != '-') { opts->errfile = strdup(argv[i + 1]); } break; case '-': if (argv[i + 1] != NULL) { opts->target = strdup(argv[i + 1]); opts->child_args = &argv[i + 1]; } break; default: break; } break; default: break; } } return opts; }
Use more generic attribute if possible
/** * @file * * @brief Assertions macros. * * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ #include <kdbconfig.h> #ifdef __cplusplus extern "C" { #endif void elektraAbort (const char * expression, const char * function, const char * file, const int line, const char * msg, ...) #ifdef __GNUC__ __attribute__ ((format (printf, 5, 6))) #endif // For scan-build / clang analyzer to detect our assertions abort #ifdef __clang_analyzer__ __attribute__ ((analyzer_noreturn)) #endif ; #ifdef __cplusplus } #endif #ifndef STRINGIFY #define STRINGIFY(x) STRINGIFY2 (x) #define STRINGIFY2(x) #x #endif #ifdef ELEKTRA_BMC #undef NDEBUG #include <assert.h> #define ELEKTRA_ASSERT(EXPR, ...) assert (EXPR) #else #if DEBUG #define ELEKTRA_ASSERT(EXPR, ...) ((EXPR)) ? (void)(0) : elektraAbort (STRINGIFY (EXPR), __func__, __FILE__, __LINE__, __VA_ARGS__) #else #define ELEKTRA_ASSERT(EXPR, ...) #endif #endif
/** * @file * * @brief Assertions macros. * * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ #include <kdbconfig.h> #ifdef __cplusplus extern "C" { #endif void elektraAbort (const char * expression, const char * function, const char * file, const int line, const char * msg, ...) #ifdef __GNUC__ __attribute__ ((format (printf, 5, 6))) __attribute__ ((__noreturn__)) #else #ifdef __clang_analyzer__ // For scan-build / clang analyzer to detect our assertions abort __attribute__ ((analyzer_noreturn)) #endif #endif ; #ifdef __cplusplus } #endif #ifndef STRINGIFY #define STRINGIFY(x) STRINGIFY2 (x) #define STRINGIFY2(x) #x #endif #ifdef ELEKTRA_BMC #undef NDEBUG #include <assert.h> #define ELEKTRA_ASSERT(EXPR, ...) assert (EXPR) #else #if DEBUG #define ELEKTRA_ASSERT(EXPR, ...) ((EXPR)) ? (void)(0) : elektraAbort (STRINGIFY (EXPR), __func__, __FILE__, __LINE__, __VA_ARGS__) #else #define ELEKTRA_ASSERT(EXPR, ...) #endif #endif
Fix incorrect help message for UEFI
/* * Copyright (c) 2018, Intel Corporation. * SPDX-License-Identifier: BSD-3-Clause */ #include <CommandParser.h> #if defined(__LINUX__) || defined(__ESX__) #define EXE_NAME L"ipmctl" #elif defined(_MSC_VER) #define EXE_NAME L"ipmctl.exe" #else #define EXE_NAME L"ipmctl.efi" #endif #define APP_DESCRIPTION L"Command Line Interface" #define DRIVER_API_DESCRIPTION L"Driver API" extern EFI_HANDLE gNvmDimmCliHiiHandle; // // This is the generated String package data for all .UNI files. // This data array is ready to be used as input of HiiAddPackages() to // create a packagelist (which contains Form packages, String packages, etc). // extern unsigned char ipmctlStrings[]; extern int g_basic_commands; /** Register commands on the commands list @retval a return code from called functions **/ EFI_STATUS RegisterCommands( ); /** Register basic commands on the commands list for non-root users @retval a return code from called functions **/ EFI_STATUS RegisterNonAdminUserCommands( ); /** Print the CLI application help **/ EFI_STATUS showHelp(struct Command *pCmd);
/* * Copyright (c) 2018, Intel Corporation. * SPDX-License-Identifier: BSD-3-Clause */ #include <CommandParser.h> #if defined(__LINUX__) || defined(__ESX__) #define EXE_NAME L"ipmctl" #elif defined(_MSC_VER) && defined(OS_BUILD) #define EXE_NAME L"ipmctl.exe" #else #define EXE_NAME L"ipmctl.efi" #endif #define APP_DESCRIPTION L"Command Line Interface" #define DRIVER_API_DESCRIPTION L"Driver API" extern EFI_HANDLE gNvmDimmCliHiiHandle; // // This is the generated String package data for all .UNI files. // This data array is ready to be used as input of HiiAddPackages() to // create a packagelist (which contains Form packages, String packages, etc). // extern unsigned char ipmctlStrings[]; extern int g_basic_commands; /** Register commands on the commands list @retval a return code from called functions **/ EFI_STATUS RegisterCommands( ); /** Register basic commands on the commands list for non-root users @retval a return code from called functions **/ EFI_STATUS RegisterNonAdminUserCommands( ); /** Print the CLI application help **/ EFI_STATUS showHelp(struct Command *pCmd);
Add docs for overridden methods
#pragma once #include "Control.h" #include <CommCtrl.h> /// <summary> /// Manages a 'spin control': a numeric edit box with a up/down 'buddy' to /// increment or decrement the current value of the box. /// </summary> class Spinner : public Control { public: Spinner() { } Spinner(int id, HWND parent) : Control(id, parent) { } virtual void Enable(); virtual void Disable(); void Buddy(int buddyId); /// <summary>Sets the range (min, max) for the spin control.</summary> /// <param name="lo">Lower bound for the spinner.</param> /// <param name="hi">Upper bound for the spinner.</param> void Range(int lo, int hi); std::wstring Text(); bool Text(std::wstring text); bool Text(int value); virtual DLGPROC Notification(NMHDR *nHdr); public: /* Event Handlers */ std::function<bool(NMUPDOWN *)> OnSpin; private: int _buddyId; HWND _buddyWnd; };
#pragma once #include "Control.h" #include <CommCtrl.h> /// <summary> /// Manages a 'spin control': a numeric edit box with a up/down 'buddy' to /// increment or decrement the current value of the box. /// </summary> class Spinner : public Control { public: Spinner() { } Spinner(int id, HWND parent) : Control(id, parent) { } virtual void Enable(); virtual void Disable(); void Buddy(int buddyId); /// <summary>Sets the range (min, max) for the spin control.</summary> /// <param name="lo">Lower bound for the spinner.</param> /// <param name="hi">Upper bound for the spinner.</param> void Range(int lo, int hi); /// <summary> /// Unlike the standard Control.Text() method, this uses the spinner buddy /// to retrieve the text. /// </summary> std::wstring Text(); /// <summary>Sets the buddy text.</summary> bool Text(std::wstring text); /// <summary>Sets the buddy text.</summary> bool Text(int value); virtual DLGPROC Notification(NMHDR *nHdr); public: /* Event Handlers */ std::function<bool(NMUPDOWN *)> OnSpin; private: int _buddyId; HWND _buddyWnd; };
Add a virtual destructor to silence a GCC warning.
//===-- llvm/MC/MCObjectFormat.h - Object Format Info -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_MC_MCOBJECTFORMAT_H #define LLVM_MC_MCOBJECTFORMAT_H namespace llvm { class MCSymbol; class MCObjectFormat { public: /// isAbsolute - Check if A - B is an absolute value /// /// \param InSet - True if this expression is in a set. For example: /// a: /// ... /// b: /// tmp = a - b /// .long tmp /// \param A - LHS /// \param B - RHS virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const = 0; }; class MCELFObjectFormat : public MCObjectFormat { public: virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const; }; class MCMachOObjectFormat : public MCObjectFormat { public: virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const; }; class MCCOFFObjectFormat : public MCObjectFormat { public: virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const; }; } // End llvm namespace #endif
//===-- llvm/MC/MCObjectFormat.h - Object Format Info -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_MC_MCOBJECTFORMAT_H #define LLVM_MC_MCOBJECTFORMAT_H namespace llvm { class MCSymbol; class MCObjectFormat { public: virtual ~MCObjectFormat() {} /// isAbsolute - Check if A - B is an absolute value /// /// \param InSet - True if this expression is in a set. For example: /// a: /// ... /// b: /// tmp = a - b /// .long tmp /// \param A - LHS /// \param B - RHS virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const = 0; }; class MCELFObjectFormat : public MCObjectFormat { public: virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const; }; class MCMachOObjectFormat : public MCObjectFormat { public: virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const; }; class MCCOFFObjectFormat : public MCObjectFormat { public: virtual bool isAbsolute(bool InSet, const MCSymbol &A, const MCSymbol &B) const; }; } // End llvm namespace #endif
Add SenTestingKit to test targets
// // WebHereTests.h // WebHereTests // // Created by Rui D Lopes on 25/03/13. // Copyright (c) 2013 Rui D Lopes. All rights reserved. // #import <Kiwi/Kiwi.h> #import <Nocilla/Nocilla.h> #import <OCLogTemplate/OCLogTemplate.h> #import <WebHere/WebHere.h> // Fixtures #import "WHPerson.h" #import "WHAdmin.h" #import "WHUnmatchedPerson.h" #import "WHPersonQueryForm.h" #import "WHNSObject.h" #import "WHLoginForm.h"
// // WebHereTests.h // WebHereTests // // Created by Rui D Lopes on 25/03/13. // Copyright (c) 2013 Rui D Lopes. All rights reserved. // #import <SenTestingKit/SenTestingKit.h> #import <Kiwi/Kiwi.h> #import <Nocilla/Nocilla.h> #import <OCLogTemplate/OCLogTemplate.h> #import <WebHere/WebHere.h> // Fixtures #import "WHPerson.h" #import "WHAdmin.h" #import "WHUnmatchedPerson.h" #import "WHPersonQueryForm.h" #import "WHNSObject.h" #import "WHLoginForm.h" # define LOGGING_ENABLED 1 # define LOGGING_LEVEL_TRACE 0 # define LOGGING_LEVEL_INFO 1 # define LOGGING_LEVEL_ERROR 1 # define LOGGING_LEVEL_DEBUG 1
Enable interrupts before initializing GDT
#include <stdint.h> #include "ports.h" #include "pic.h" #include "gdt.h" #include "idt.h" #include "irq.h" #include "screen.h" void entry(void) { pic_remap(IRQ0, IRQ8); pic_set_masks(0, 0); idt_init((struct IDT *)(0x500)); gdt_init((struct GDT *)(0x500 + sizeof(struct IDT))); __asm__ __volatile__ ("sti"); screen_init(); __asm__ __volatile__ ("int $0x50"); for(;;) { __asm__ __volatile__ ("hlt"); } }
#include <stdint.h> #include "ports.h" #include "pic.h" #include "gdt.h" #include "idt.h" #include "irq.h" #include "screen.h" void entry(void) { struct IDT *idt = (struct IDT *)0x500; struct GDT *gdt = (struct GDT *)(0x500 + sizeof(struct GDT)); pic_remap(IRQ0, IRQ8); pic_set_masks(0, 0); idt_init(idt); __asm__ __volatile__ ("sti"); gdt_init(gdt); screen_init(); __asm__ __volatile__ ("int $0x50"); for(;;) { __asm__ __volatile__ ("hlt"); } }
Use FAIL_APR() rather than FAIL() in create_subpool().
#include <string.h> #include "c4-internal.h" void * ol_alloc(apr_size_t sz) { void *result = malloc(sz); if (result == NULL) FAIL(); return result; } void * ol_alloc0(apr_size_t sz) { void *result = ol_alloc(sz); memset(result, 0, sz); return result; } void * ol_realloc(void *ptr, apr_size_t sz) { void *result = realloc(ptr, sz); if (result == NULL) FAIL(); return result; } void ol_free(void *ptr) { free(ptr); } char * ol_strdup(const char *str) { size_t len = strlen(str) + 1; char *result; result = ol_alloc(len); memcpy(result, str, len); return result; } apr_pool_t * make_subpool(apr_pool_t *parent) { apr_status_t s; apr_pool_t *pool; s = apr_pool_create(&pool, parent); if (s != APR_SUCCESS) FAIL(); return pool; }
#include <string.h> #include "c4-internal.h" void * ol_alloc(apr_size_t sz) { void *result = malloc(sz); if (result == NULL) FAIL(); return result; } void * ol_alloc0(apr_size_t sz) { void *result = ol_alloc(sz); memset(result, 0, sz); return result; } void * ol_realloc(void *ptr, apr_size_t sz) { void *result = realloc(ptr, sz); if (result == NULL) FAIL(); return result; } void ol_free(void *ptr) { free(ptr); } char * ol_strdup(const char *str) { size_t len = strlen(str) + 1; char *result; result = ol_alloc(len); memcpy(result, str, len); return result; } apr_pool_t * make_subpool(apr_pool_t *parent) { apr_status_t s; apr_pool_t *pool; s = apr_pool_create(&pool, parent); if (s != APR_SUCCESS) FAIL_APR(s); return pool; }
Add test for simple partial structs.
struct s1 { int y; int z; }; struct s2 { struct s1 *p; }; int main() { struct s1 nested; struct s2 v; v.p = &nested; v.p->y = 1; v.p->z = 2; if (nested.y != 1) return 1; if (nested.z != 2) return 2; return 0; }
struct T; struct T { int x; }; int main() { struct T v; { struct T { int z; }; } v.x = 2; if(v.x != 2) return 1; return 0; }
Fix the third time test.
#include <stdio.h> #include <sys/types.h> #include <unistd.h> int64_t getTicks(); void sleepFor(int64_t); int main(int argc, char **argv) { int64_t a, b, c, delay; delay = microsecondsToTicks(500000); a = getTicks(); sleepFor(delay); b = getTicks(); sleepFor(delay); c = getTicks(); if(a + delay <= b) printf("PASSED PART ONE\n"); else printf("FAILED PART ONE (%lli + %lli > %lli)\n", a, delay, b); if(b + delay <= c) printf("PASSED PART TWO\n"); else printf("FAILED PART TWO (%lli + %lli > %lli)\n", b, delay, c); }
#include <stdio.h> #include <sys/types.h> #include <unistd.h> int64_t getTicks(); void sleepFor(int64_t); int main(int argc, char **argv) { int64_t a, b, c, delay; delay = microsecondsToTicks(500000); a = getTicks(); sleepFor(delay); b = getTicks(); sleepFor(delay); c = getTicks(); if(a + delay <= b) printf("PASSED PART ONE\n"); else printf("FAILED PART ONE (%lli + %lli > %lli)\n", a, delay, b); if(b + delay <= c) printf("PASSED PART TWO\n"); else printf("FAILED PART TWO (%lli + %lli > %lli)\n", b, delay, c); return 0; }
Delete duplicate (and incompatible) declaration of iRRAM_initialize().
#ifndef iRRAM_MPFR_EXTENSION_H #define iRRAM_MPFR_EXTENSION_H #ifndef GMP_RNDN #include <mpfr.h> #endif #ifdef __cplusplus extern "C" { #endif void mpfr_ext_exp (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_log (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_sin (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_cos (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_tan (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_test (mpfr_ptr r, mpfr_srcptr u,int p,mp_rnd_t rnd_mode); void iRRAM_initialize(int argc,char **argv); #ifdef __cplusplus } #endif #endif
#ifndef iRRAM_MPFR_EXTENSION_H #define iRRAM_MPFR_EXTENSION_H #ifndef GMP_RNDN #include <mpfr.h> #endif #ifdef __cplusplus extern "C" { #endif void mpfr_ext_exp (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_log (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_sin (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_cos (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_tan (mpfr_ptr r, mpfr_srcptr u,int p); void mpfr_ext_test (mpfr_ptr r, mpfr_srcptr u,int p,mp_rnd_t rnd_mode); #ifdef __cplusplus } #endif #endif
Add assert after global write in 36/11
// PARAM: --sets ana.activated[+] octApron #include <pthread.h> #include <assert.h> int g = 1; pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER; void *t_fun(void *arg) { pthread_mutex_lock(&A); g = 2; // write something non-initial so base wouldn't find success pthread_mutex_unlock(&A); return NULL; } int main(void) { int x, y; pthread_t id; pthread_create(&id, NULL, t_fun, NULL); pthread_mutex_lock(&A); x = g; y = g; assert(x == y); pthread_mutex_unlock(&A); // g = g - g - x; return 0; }
// PARAM: --sets ana.activated[+] octApron #include <pthread.h> #include <assert.h> int g = 1; pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER; void *t_fun(void *arg) { pthread_mutex_lock(&A); g = 2; // write something non-initial so base wouldn't find success assert(g == 2); pthread_mutex_unlock(&A); return NULL; } int main(void) { int x, y; pthread_t id; pthread_create(&id, NULL, t_fun, NULL); pthread_mutex_lock(&A); x = g; y = g; assert(x == y); pthread_mutex_unlock(&A); // g = g - g - x; return 0; }
Add example that only works with no overflow assumption
// PARAM: --sets sem.int.signed_overflow assume_none --enable ana.int.interval --disable ana.int.def_exc int main(void) { int x = 0; while(x != 42) { x++; assert(x >= 1); } }
Remove old DEFAULT_MAX_TIME static var
#ifndef UCI_H #define UCI_H #include "board.h" #include "cmove.h" #include <sstream> #include <fstream> class Uci { public: void start(); private: Board _board; static const int DEFAULT_DEPTH = 4; static const int DEFAULT_MAX_TIME = 5000; void _uciNewGame(); void _setPosition(std::istringstream&); void _go(std::istringstream&); void _pickBestMove(int); }; #endif
#ifndef UCI_H #define UCI_H #include "board.h" #include "cmove.h" #include <sstream> #include <fstream> class Uci { public: void start(); private: Board _board; static const int DEFAULT_DEPTH = 4; void _uciNewGame(); void _setPosition(std::istringstream&); void _go(std::istringstream&); void _pickBestMove(int); }; #endif
Add missing CONTENT_EXPORT to fix Linux shared build after r112415
// Copyright (c) 2011 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 CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #pragma once class TabContents; namespace content { class DevToolsFrontendWindowDelegate; // Installs delegate for DevTools front-end loaded into |client_tab_contents|. void SetupDevToolsFrontendDelegate( TabContents* client_tab_contents, DevToolsFrontendWindowDelegate* delegate); } #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_
// Copyright (c) 2011 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 CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_ #pragma once class TabContents; namespace content { class DevToolsFrontendWindowDelegate; // Installs delegate for DevTools front-end loaded into |client_tab_contents|. CONTENT_EXPORT void SetupDevToolsFrontendDelegate( TabContents* client_tab_contents, DevToolsFrontendWindowDelegate* delegate); } #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_FRONTEND_WINDOW_H_
Add include-what-you-use pragma so IWYU does not try to include these files again.
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_DELEGATES_GPU_COMMON_STATUS_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_STATUS_H_ #include "absl/status/status.h" #define RETURN_IF_ERROR(s) {auto c=(s);if(!c.ok())return c;} #endif // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_STATUS_H_
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_DELEGATES_GPU_COMMON_STATUS_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_STATUS_H_ #include "absl/status/status.h" // IWYU pragma: export #define RETURN_IF_ERROR(s) {auto c=(s);if(!c.ok())return c;} // IWYU pragma: export #endif // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_STATUS_H_
Fix missing %s in run string causing hang during tests.
// RUN: clang -fsyntax-only -verify // Test for absence of crash reported in PR 2923: // // http://llvm.org/bugs/show_bug.cgi?id=2923 // // Previously we had a crash when deallocating the FunctionDecl for 'bar' // because FunctionDecl::getNumParams() just used the type of foo to determine // the number of parameters it has. In the case of 'bar' there are no // ParmVarDecls. int foo(int x, int y) { return x + y; } extern typeof(foo) bar;
// RUN: clang -fsyntax-only -verify %s // Test for absence of crash reported in PR 2923: // // http://llvm.org/bugs/show_bug.cgi?id=2923 // // Previously we had a crash when deallocating the FunctionDecl for 'bar' // because FunctionDecl::getNumParams() just used the type of foo to determine // the number of parameters it has. In the case of 'bar' there are no // ParmVarDecls. int foo(int x, int y) { return x + y; } extern typeof(foo) bar;
Update driver version to 5.02.00-k4
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2006 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k3"
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2006 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k4"
Change 00/21 to make all loops live
int main() { f_empty_goto_loop(); f_empty_while_loop(); f_empty_goto_loop_suffix(); f_empty_while_loop_suffix(); f_nonempty_goto_loop(); f_nonempty_while_loop(); return 0; } void f_empty_goto_loop() { f_empty_goto_loop_label: goto f_empty_goto_loop_label; } void f_empty_while_loop() { while (1) {} } void suffix() { } void f_empty_goto_loop_suffix() { f_empty_goto_loop_suffix_label: goto f_empty_goto_loop_suffix_label; suffix(); } void f_empty_while_loop_suffix() { while (1) {} suffix(); } void body() { } void f_nonempty_goto_loop() { f_nonempty_goto_loop_label: body(); goto f_nonempty_goto_loop_label; } void f_nonempty_while_loop() { while (1) { body(); } }
int main() { // non-deterministically make all variants live int r; switch (r) { case 0: f_empty_goto_loop(); break; case 1: f_empty_while_loop(); break; case 2: f_empty_goto_loop_suffix(); break; case 3: f_empty_while_loop_suffix(); break; case 4: f_nonempty_goto_loop(); break; case 5: f_nonempty_while_loop(); break; } return 0; } void f_empty_goto_loop() { f_empty_goto_loop_label: goto f_empty_goto_loop_label; } void f_empty_while_loop() { while (1) {} } void suffix() { } void f_empty_goto_loop_suffix() { f_empty_goto_loop_suffix_label: goto f_empty_goto_loop_suffix_label; suffix(); } void f_empty_while_loop_suffix() { while (1) {} suffix(); } void body() { } void f_nonempty_goto_loop() { f_nonempty_goto_loop_label: body(); goto f_nonempty_goto_loop_label; } void f_nonempty_while_loop() { while (1) { body(); } }
Add defines for enum type and conversions
/** * @file * * @brief * * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org) */ #compiler-settings directiveStartToken = @ cheetahVarStartToken = $ #end compiler-settings @from support.elektra_gen import * @set support = ElektraGenSupport() @for $key, $info in $parameters.iteritems() @if $support.type_of($info) == "enum" ELEKTRA_DEFINITIONS ($support.enum_type($key), $support.enum_type_name($key), "enum", KDB_LONG_TO_STRING, KDB_STRING_TO_LONG) @end if @end for
/** * @file * * @brief * * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org) */ #compiler-settings directiveStartToken = @ cheetahVarStartToken = $ #end compiler-settings @from support.elektra_gen import * @set support = ElektraGenSupport() #include <stdlib.h> #include <elektra.h> #include <kdbhelper.h> #include "elektra_gen.h" KDBType KDB_TYPE_ENUM = "enum"; #define KDB_ENUM_TO_STRING(value) elektraFormat (ELEKTRA_LONG_F, value) #define KDB_STRING_TO_ENUM(string) (kdb_long_t) strtoul (string, NULL, 10) @for $key, $info in $parameters.iteritems() @if $support.type_of($info) == "enum" ELEKTRA_DEFINITIONS ($support.enum_type($key), $support.enum_type_name($key), KDB_TYPE_ENUM, KDB_ENUM_TO_STRING, KDB_STRING_TO_ENUM) @end if @end for #undef KDB_ENUM_TO_STRING #undef KDB_STRING_TO_ENUM
Add file that is accidentally removed.
#ifndef PAGE_H #define PAGE_H #include <stddef.h> #define PAGE_SIZE 4096ULL #define PAGE_SIZE_MASK (PAGE_SIZE - 1) #define PAGE_ALIGN_DOWN(x) (\ (void *) ((size_t) (x) & ~PAGE_SIZE_MASK) \ ) #define PAGE_ALIGN_UP(x) (\ (void *) ((size_t) ((x) + PAGE_SIZE_MASK) & ~PAGE_SIZE_MASK) \ ) #define PAGE_ALIGNED(x) (\ 0 == ((size_t) (x) & PAGE_SIZE_MASK) \ ) #define PAGE_DIVISIBLE(x) (\ 0 == ((x) % PAGE_SIZE) \ ) #endif /* end of include guard: PAGE_H */
Add TODO about strongly typing variable
// Copyright 2010-2014 The CefSharp Project. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #pragma once #include "Stdafx.h" #include "include/cef_v8.h" using namespace CefSharp::Internals; namespace CefSharp { public ref class JavascriptPropertyWrapper { private: JavascriptProperty^ _javascriptProperty; int64 _ownerId; IBrowserProcess^ _browserProcess; Object^ _javascriptObjectWrapper; internal: MCefRefPtr<CefV8Value> V8Value; public: JavascriptPropertyWrapper(JavascriptProperty^ javascriptProperty, int64 ownerId, IBrowserProcess^ browserProcess) { _javascriptProperty = javascriptProperty; _ownerId = ownerId; _browserProcess = browserProcess; } ~JavascriptPropertyWrapper() { V8Value = nullptr; if (_javascriptObjectWrapper != nullptr) { delete _javascriptObjectWrapper; _javascriptObjectWrapper = nullptr; } } void Bind(); }; }
// Copyright 2010-2014 The CefSharp Project. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #pragma once #include "Stdafx.h" #include "include/cef_v8.h" using namespace CefSharp::Internals; namespace CefSharp { public ref class JavascriptPropertyWrapper { private: JavascriptProperty^ _javascriptProperty; int64 _ownerId; IBrowserProcess^ _browserProcess; //TODO: Strongly type this variable - currently trying to include JavascriptObjectWrapper.h creates a circular reference, so won't compile Object^ _javascriptObjectWrapper; internal: MCefRefPtr<CefV8Value> V8Value; public: JavascriptPropertyWrapper(JavascriptProperty^ javascriptProperty, int64 ownerId, IBrowserProcess^ browserProcess) { _javascriptProperty = javascriptProperty; _ownerId = ownerId; _browserProcess = browserProcess; } ~JavascriptPropertyWrapper() { V8Value = nullptr; if (_javascriptObjectWrapper != nullptr) { delete _javascriptObjectWrapper; _javascriptObjectWrapper = nullptr; } } void Bind(); }; }
Add base class from fs scorers
/** fs_scorer_base.h --- * * Copyright (C) 2013 OpenCog Foundation * * Author: Nil Geisweiller * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License v3 as * published by the Free Software Foundation and including the exceptions * at http://opencog.org/wiki/Licenses * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program; if not, write to: * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _OPENCOG_BASE_SCORER_H #define _OPENCOG_BASE_SCORER_H #include <opencog/comboreduct/table/table.h> namespace opencog { using namespace combo; template<typename FeatureSet> struct fs_scorer_base : public std::unary_function<FeatureSet, double> { // ctor fs_scorer_base(const CTable& ctable, double confi) : _ctable(ctable), _confi(confi), _usize(_ctable.uncompressed_size()) {} // dtor virtual ~fs_scorer_base() {}; virtual double operator()(const FeatureSet& features) const = 0; protected: // Very rought approximation of the confidence in the feature // quality measure double confidence(unsigned fs_size) const { return _usize / (_usize + exp(-_confi*fs_size)); } const CTable& _ctable; double _confi; // confidence intensity unsigned _usize; // uncompressed ctable size }; } #endif // _OPENCOG_BASE_SCORER_H
Fix WindowsClassHolder destructor doing nothing.
#pragma once class WindowClassHolder { private: ATOM m_WindowClass; public: WindowClassHolder() : m_WindowClass(0) { } WindowClassHolder(ATOM windowClass) : m_WindowClass(windowClass) { } WindowClassHolder& operator=(ATOM windowClass) { if (m_WindowClass != 0) UnregisterClassW(*this, GetModuleHandleW(nullptr)); m_WindowClass = windowClass; return *this; } WindowClassHolder(const WindowClassHolder&) = delete; WindowClassHolder& operator=(const WindowClassHolder&) = delete; inline operator ATOM() const { return m_WindowClass; } inline operator const wchar_t*() const { return reinterpret_cast<const wchar_t*>(m_WindowClass); } };
#pragma once class WindowClassHolder { private: ATOM m_WindowClass; public: WindowClassHolder() : m_WindowClass(0) { } WindowClassHolder(ATOM windowClass) : m_WindowClass(windowClass) { } ~WindowClassHolder() { if (m_WindowClass != 0) UnregisterClassW(*this, GetModuleHandleW(nullptr)); } WindowClassHolder& operator=(ATOM windowClass) { this->~WindowClassHolder(); m_WindowClass = windowClass; return *this; } WindowClassHolder(const WindowClassHolder&) = delete; WindowClassHolder& operator=(const WindowClassHolder&) = delete; inline operator ATOM() const { return m_WindowClass; } inline operator const wchar_t*() const { return reinterpret_cast<const wchar_t*>(m_WindowClass); } };
Add missing mark for pure virtual method
// MIT License // Copyright (c) 2017 Zhuhao Wang // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #pragma once #include <functional> #include <memory> #include <system_error> #include "connection_interface.h" namespace nekit { namespace transport { class ListenerInterface { public: virtual ~ListenerInterface() = default; using EventHandler = std::function<void( std::unique_ptr<ConnectionInterface>&&, std::error_code)>; virtual void Accept(EventHandler&&); }; } // namespace transport } // namespace nekit
// MIT License // Copyright (c) 2017 Zhuhao Wang // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #pragma once #include <functional> #include <memory> #include <system_error> #include "connection_interface.h" namespace nekit { namespace transport { class ListenerInterface { public: virtual ~ListenerInterface() = default; using EventHandler = std::function<void( std::unique_ptr<ConnectionInterface>&&, std::error_code)>; virtual void Accept(EventHandler&&) = 0; }; } // namespace transport } // namespace nekit
Fix build on Linux where gcc apparently enforces character arrays as arrays for initialization purposes.
#ifndef MIAOW_SIAGEN_H #define MIAOW_SIAGEN_H #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include "asm.h" #include "helper.h" #define MAX_INSTR 1000 #define MAX_OPS 50 #define INSTR_TYPES 4 #define SCALAR_ALU 0 #define VECTOR_ALU 1 #define SCALAR_MEM 2 #define VECTOR_MEM 3 typedef void(*instr_function)(int); typedef struct _instr { int opcode; char op_str[30]; } Instr; typedef struct _instr_sel { enum si_fmt_enum instr_type; Instr instr; instr_function instr_func; } Instr_Sel; void initializeInstrArr(int *arr, int array_size); void printInstrsInArray(int arr[MAX_INSTR]); void printAllUnitTests(); #endif
#ifndef MIAOW_SIAGEN_H #define MIAOW_SIAGEN_H #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <string> #include "asm.h" #include "helper.h" #define MAX_INSTR 1000 #define MAX_OPS 50 #define INSTR_TYPES 4 #define SCALAR_ALU 0 #define VECTOR_ALU 1 #define SCALAR_MEM 2 #define VECTOR_MEM 3 typedef void(*instr_function)(int); typedef struct _instr { int opcode; std::string op_str; } Instr; typedef struct _instr_sel { enum si_fmt_enum instr_type; Instr instr; instr_function instr_func; } Instr_Sel; void initializeInstrArr(int *arr, int array_size); void printInstrsInArray(int arr[MAX_INSTR]); void printAllUnitTests(); #endif
Fix compilation for gcc 4.7
#pragma once #include <glbinding/glbinding_api.h> #include <set> #include <vector> #include <functional> namespace glbinding { class AbstractFunction; class AbstractValue; struct GLBINDING_API FunctionCall { FunctionCall(const AbstractFunction * _function); ~FunctionCall(); FunctionCall & operator=(const FunctionCall &) = delete; const AbstractFunction & function; std::vector<AbstractValue *> parameters; AbstractValue * returnValue; }; enum class CallbackMask : unsigned char { None = 0x00, Unresolved = 0x01, Before = 0x02, After = 0x04, Parameters = 0x08, ReturnValue = 0x10, ParametersAndReturnValue = Parameters | ReturnValue, BeforeAndAfter = Before | After }; GLBINDING_API CallbackMask operator|(CallbackMask a, CallbackMask b); GLBINDING_API void setCallbackMask(CallbackMask mask); GLBINDING_API void setCallbackMaskExcept(CallbackMask mask, const std::set<std::string> & blackList); using SimpleFunctionCallback = std::function<void(const AbstractFunction &)>; using FunctionCallback = std::function<void(const FunctionCall &)>; GLBINDING_API void setUnresolvedCallback(SimpleFunctionCallback callback); GLBINDING_API void setBeforeCallback(FunctionCallback callback); GLBINDING_API void setAfterCallback(FunctionCallback callback); } // namespace glbinding
#pragma once #include <glbinding/glbinding_api.h> #include <set> #include <vector> #include <functional> #include <string> namespace glbinding { class AbstractFunction; class AbstractValue; struct GLBINDING_API FunctionCall { FunctionCall(const AbstractFunction * _function); ~FunctionCall(); FunctionCall & operator=(const FunctionCall &) = delete; const AbstractFunction & function; std::vector<AbstractValue *> parameters; AbstractValue * returnValue; }; enum class CallbackMask : unsigned char { None = 0x00, Unresolved = 0x01, Before = 0x02, After = 0x04, Parameters = 0x08, ReturnValue = 0x10, ParametersAndReturnValue = Parameters | ReturnValue, BeforeAndAfter = Before | After }; GLBINDING_API CallbackMask operator|(CallbackMask a, CallbackMask b); GLBINDING_API void setCallbackMask(CallbackMask mask); GLBINDING_API void setCallbackMaskExcept(CallbackMask mask, const std::set<std::string> & blackList); using SimpleFunctionCallback = std::function<void(const AbstractFunction &)>; using FunctionCallback = std::function<void(const FunctionCall &)>; GLBINDING_API void setUnresolvedCallback(SimpleFunctionCallback callback); GLBINDING_API void setBeforeCallback(FunctionCallback callback); GLBINDING_API void setAfterCallback(FunctionCallback callback); } // namespace glbinding
Add missing include needed to define uint16_t
/* * * Copyright 2017 Asylo 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 ASYLO_PLATFORM_POSIX_INCLUDE_SYS_UN_H_ #define ASYLO_PLATFORM_POSIX_INCLUDE_SYS_UN_H_ #include <sys/cdefs.h> struct sockaddr_un { uint16_t sun_family; char sun_path[108]; }; #endif // ASYLO_PLATFORM_POSIX_INCLUDE_SYS_UN_H_
/* * * Copyright 2017 Asylo 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 ASYLO_PLATFORM_POSIX_INCLUDE_SYS_UN_H_ #define ASYLO_PLATFORM_POSIX_INCLUDE_SYS_UN_H_ #include <stdint.h> #include <sys/cdefs.h> struct sockaddr_un { uint16_t sun_family; char sun_path[108]; }; #endif // ASYLO_PLATFORM_POSIX_INCLUDE_SYS_UN_H_
Add minimized pfscan workers test
// SKIP PARAM: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet --set sem.int.signed_overflow assume_none --enable ana.apron.strengthening // minimized pfscan with relational workers invariant // mutex-meet: needs strengthening even with path_sens threadflag // mutex-meet-tid: doesn't need strengthening // needs assume_none to avoid top via some lost upper bounds #include <pthread.h> struct __anonstruct_PQUEUE_63 { pthread_mutex_t mtx ; pthread_cond_t less ; }; typedef struct __anonstruct_PQUEUE_63 PQUEUE; int nworkers = 0; int aworkers = 0; pthread_mutex_t aworker_lock = PTHREAD_MUTEX_INITIALIZER; PQUEUE pqb ; void *worker(void *arg) { pthread_mutex_lock(& aworker_lock); aworkers --; assert(aworkers <= nworkers); pthread_mutex_unlock(& aworker_lock); return NULL; } int main() { int r ; // rand pthread_t tid ; nworkers = r; aworkers = nworkers; for (int j = 0; j < nworkers; j++) pthread_create(& tid, NULL, & worker, NULL); while (1) { pthread_cond_wait(&pqb.less, &pqb.mtx); // some weirdness that exposes the problem } return 0; }
Remove space that was forgotten.`
// RUN: %llvmgcc -S %s -o - | grep {llvm.ctlz.i32( i32} | count 2 // RUN: %llvmgcc -S %s -o - | grep {llvm.ctlz.i32(i32} | count 1 unsigned t2(unsigned X) { return __builtin_clz(X); } int t1(int X) { return __builtin_clz(X); }
// RUN: %llvmgcc -S %s -o - | grep {llvm.ctlz.i32(i32} | count 2 // RUN: %llvmgcc -S %s -o - | grep {llvm.ctlz.i32(i32} | count 1 unsigned t2(unsigned X) { return __builtin_clz(X); } int t1(int X) { return __builtin_clz(X); }
Add stub file for pid probe. It's required although pid probe is not supported on MIPS yet
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include <stdlib.h> #include <assert.h> #include <errno.h> #include <string.h> #include <libgen.h> #include <dt_impl.h> #include <dt_pid.h> /*ARGSUSED*/ int dt_pid_create_entry_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp, fasttrap_probe_spec_t *ftp, const GElf_Sym *symp) { dt_dprintf("%s: unimplemented\n", __func__); return (DT_PROC_ERR); } int dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp, fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, uint64_t *stret) { dt_dprintf("%s: unimplemented\n", __func__); return (DT_PROC_ERR); } /*ARGSUSED*/ int dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp, fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, ulong_t off) { dt_dprintf("%s: unimplemented\n", __func__); return (DT_PROC_ERR); } /*ARGSUSED*/ int dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp, fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, const char *pattern) { dt_dprintf("%s: unimplemented\n", __func__); return (DT_PROC_ERR); }
Fix bug in ref counting
#ifndef NUCLEUS_MEMORY_REF_COUNTED_H_ #define NUCLEUS_MEMORY_REF_COUNTED_H_ #include <atomic> #include "nucleus/Macros.h" namespace nu { namespace detail { class RefCountedBase { public: bool hasOneRef() const { return m_refCount.load(std::memory_order_release) == 1; } void addRef() const { m_refCount.fetch_add(1, std::memory_order_relaxed); } bool release() const { return m_refCount.fetch_sub(1, std::memory_order_release); } protected: RefCountedBase() = default; ~RefCountedBase() = default; COPY_DELETE(RefCountedBase); MOVE_DELETE(RefCountedBase); private: mutable std::atomic<USize> m_refCount{}; }; template <typename T> struct DefaultRefCountedTraits { static void destruct(const T*) {} }; } // namespace detail template <typename T, typename Traits = detail::DefaultRefCountedTraits<T>> class RefCounted : public detail::RefCountedBase { public: void addRef() const { detail::RefCountedBase::addRef(); } void release() const { if (detail::RefCountedBase::release()) { Traits::destruct(static_cast<const T*>(this)); } } }; } // namespace nu #endif // NUCLEUS_MEMORY_REF_COUNTED_H_
#ifndef NUCLEUS_MEMORY_REF_COUNTED_H_ #define NUCLEUS_MEMORY_REF_COUNTED_H_ #include <atomic> #include "nucleus/Macros.h" namespace nu { namespace detail { class RefCountedBase { public: COPY_DELETE(RefCountedBase); MOVE_DELETE(RefCountedBase); bool hasOneRef() const { return m_refCount.load(std::memory_order_release) == 1; } void addRef() const { m_refCount.fetch_add(1, std::memory_order_relaxed); } bool release() const { return m_refCount.fetch_sub(1, std::memory_order_release) == 1; } protected: RefCountedBase() = default; ~RefCountedBase() = default; private: mutable std::atomic<USize> m_refCount{}; }; template <typename T> struct DefaultRefCountedTraits { static void destruct(const T*) {} }; } // namespace detail template <typename T, typename Traits = detail::DefaultRefCountedTraits<T>> class RefCounted : public detail::RefCountedBase { public: void addRef() const { detail::RefCountedBase::addRef(); } void release() const { if (detail::RefCountedBase::release()) { Traits::destruct(static_cast<const T*>(this)); } } }; } // namespace nu #endif // NUCLEUS_MEMORY_REF_COUNTED_H_
Fix a bug from BlocksKit
// // BlocksKit+MessageUI // // The Objective-C block utilities you always wish you had. // // Copyright (c) 2011-2012, 2013-2014 Zachary Waldowski // Copyright (c) 2012-2013 Pandamonia LLC // // 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. // #import <BlocksKit/MFMailComposeViewController+BlocksKit.h> #import <BlocksKit/MFMessageComposeViewController+BlocksKit.h>
// // BlocksKit+MessageUI // // The Objective-C block utilities you always wish you had. // // Copyright (c) 2011-2012, 2013-2014 Zachary Waldowski // Copyright (c) 2012-2013 Pandamonia LLC // // 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. // #import "MFMailComposeViewController+BlocksKit.h" #import "MFMessageComposeViewController+BlocksKit.h"
Add current direction and speed variable. Should probably be moved somewhere else.
#pragma once #include <HgTypes.h> #ifdef __cplusplus extern "C" { #endif typedef struct HgCamera { point position; quaternion rotation; } HgCamera; vector3 ray_from_camera(HgCamera* c); #ifdef __cplusplus } #endif
#pragma once #include <HgTypes.h> #ifdef __cplusplus extern "C" { #endif typedef struct HgCamera { point position; quaternion rotation; vector3 direction; float speedMsec; } HgCamera; vector3 ray_from_camera(HgCamera* c); #ifdef __cplusplus } #endif
Add updated params to interval-congruence ref. reg test
// PARAM: --disable ana.int.def_exc --enable ana.int.interval --enable ana.int.congruence #include <assert.h> int main(){ int r = -103; for (int i = 0; i < 40; i++) { r = r + 5; } // At this point r in the congr. dom should be 2 + 5Z int k = r; if (k >= 3) { // After refinement with congruences, the lower bound should be 7 as the numbers 3 - 6 are not in the congr. class assert (k < 7); // FAIL } if (r >= -11 && r <= -4) { assert (r == -8); } return 0; }
// PARAM: --disable ana.int.def_exc --enable ana.int.interval --enable ana.int.congruence --enable ana.int.congruence_no_overflow --enable ana.int.refinement #include <assert.h> int main(){ int r = -103; for (int i = 0; i < 40; i++) { r = r + 5; } // At this point r in the congr. dom should be 2 + 5Z int k = r; if (k >= 3) { // After refinement with congruences, the lower bound should be 7 as the numbers 3 - 6 are not in the congr. class assert (k < 7); // FAIL } if (r >= -11 && r <= -4) { assert (r == -8); } return 0; }
Change enum to scoped enum
/** * @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may find a copy of the License in the LICENCE file. * * 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 JPetEventType.h */ #ifndef JPETEVENTTYPE_H #define JPETEVENTTYPE_H enum JPetEventType { kUnknown = 1, k2Gamma = 2, k3Gamma = 4, kPrompt = 8, kScattered = 16, kCosmic = 32 }; #endif /* !JPETEVENTTYPE_H */
/** * @copyright Copyright 2021 The J-PET Framework Authors. All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may find a copy of the License in the LICENCE file. * * 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 JPetEventType.h */ #ifndef JPETEVENTTYPE_H #define JPETEVENTTYPE_H enum class JPetEventType { kUnknown = 1, k2Gamma = 2, k3Gamma = 4, kPrompt = 8, kScattered = 16, kCosmic = 32 }; #endif /* !JPETEVENTTYPE_H */
Change property reference to weak to match private reference
// // SDCAlertViewCoordinator.h // SDCAlertView // // Created by Scott Berrevoets on 1/25/14. // Copyright (c) 2014 Scotty Doesn't Code. All rights reserved. // #import <Foundation/Foundation.h> @class SDCAlertView; @interface SDCAlertViewCoordinator : NSObject @property (nonatomic, readonly) SDCAlertView *visibleAlert; + (instancetype)sharedCoordinator; - (void)presentAlert:(SDCAlertView *)alert; - (void)dismissAlert:(SDCAlertView *)alert withButtonIndex:(NSInteger)buttonIndex; @end
// // SDCAlertViewCoordinator.h // SDCAlertView // // Created by Scott Berrevoets on 1/25/14. // Copyright (c) 2014 Scotty Doesn't Code. All rights reserved. // #import <Foundation/Foundation.h> @class SDCAlertView; @interface SDCAlertViewCoordinator : NSObject @property (nonatomic, weak, readonly) SDCAlertView *visibleAlert; + (instancetype)sharedCoordinator; - (void)presentAlert:(SDCAlertView *)alert; - (void)dismissAlert:(SDCAlertView *)alert withButtonIndex:(NSInteger)buttonIndex; @end
Test whether two function name is same but num_para not is legal
#include<stdlib.h> void test(int i){ printf("in test(%d)\n",i); } void test(){ printf("in test()\n"); } int main(){ test(); test(1); return 0; }
Add example LED blink task
/** * @file main.c * @brief Main. * */ #include "stm32f4xx_conf.h" #include "FreeRTOS.h" int main(void) { // TODO while(1); return 0; }
/** * @file main.c * @brief Main. * */ #include "stm32f4xx_conf.h" #include "stm32f4xx_gpio.h" #include "stm32f4xx_rcc.h" #include "FreeRTOS.h" #include "task.h" void hw_init(void) { GPIO_InitTypeDef gpio_led; GPIO_StructInit(&gpio_led); gpio_led.GPIO_Mode = GPIO_Mode_OUT; gpio_led.GPIO_Pin = GPIO_Pin_12; gpio_led.GPIO_PuPd = GPIO_PuPd_NOPULL; gpio_led.GPIO_Speed = GPIO_Speed_100MHz; gpio_led.GPIO_OType = GPIO_OType_PP; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); GPIO_Init(GPIOD, &gpio_led); } void led_task(void *params) { while(1) { GPIO_ToggleBits(GPIOD, GPIO_Pin_12); vTaskDelay(500 / portTICK_RATE_MS); } } int main(void) { hw_init(); (void) SysTick_Config(SystemCoreClock / 1000); (void) xTaskCreate( led_task, "led_task", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2UL, NULL); vTaskStartScheduler(); while(1); return 0; }
Fix TextVersion still being 5.6
/* Title: version.h Copyright (c) 2000-17 Cambridge University Technical Services Limited This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef VERSION_H_INCLUDED #define VERSION_H_INCLUDED // Poly/ML system interface level #define POLY_version_number 570 // POLY_version_number is written into all exported files and tested // when we start up. The idea is to ensure that if a file is exported // from one version of the library it will run successfully if linked // with a different version. // This only supports version 5.7 #define FIRST_supported_version 570 #define LAST_supported_version 570 #define TextVersion "5.6" #endif
/* Title: version.h Copyright (c) 2000-17 Cambridge University Technical Services Limited This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef VERSION_H_INCLUDED #define VERSION_H_INCLUDED // Poly/ML system interface level #define POLY_version_number 570 // POLY_version_number is written into all exported files and tested // when we start up. The idea is to ensure that if a file is exported // from one version of the library it will run successfully if linked // with a different version. // This only supports version 5.7 #define FIRST_supported_version 570 #define LAST_supported_version 570 #define TextVersion "5.7" #endif
Fix missing change in header
#ifndef PY_UTILS_H #define PY_UTILS_H #include <stdio.h> extern FILE *stdin_writer; void setupPython(const char* pythonProgramPath, const char* pythonLibs, const char* pythonHostLibs, const char* pythonHome, const char* pythonTemp, const char* xdgBasePath); void setupStdinEmulation(void); void readFromStdin(char* inputBuffer, int bufferSize); int runPythonInterpreter(int argc, char** argv); void interruptPython(void); void terminatePython(void); #endif // PY_UTILS_H //
#ifndef PY_UTILS_H #define PY_UTILS_H #include <stdio.h> extern FILE *stdin_writer; void setupPython(const char* pythonProgramPath, const char* pythonLibs, const char* pythonHostLibs, const char* pythonHome, const char* pythonTemp, const char* xdgBasePath, const char* dataDir); void setupStdinEmulation(void); void readFromStdin(char* inputBuffer, int bufferSize); int runPythonInterpreter(int argc, char** argv); void interruptPython(void); void terminatePython(void); #endif // PY_UTILS_H //
Fix after review: perfect forwarding used for callable object
// // Copyright Renga Software LLC, 2017. All rights reserved. // // Renga Software LLC PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // Renga Software LLC DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // #pragma once class BoolGuard { public: explicit BoolGuard(bool& variable); explicit BoolGuard(bool& variable, bool initialValue); BoolGuard(const BoolGuard& guard) = delete; BoolGuard& operator = (const BoolGuard& guard) = delete; ~BoolGuard(); private: bool& m_variable; }; template <typename TFunc> class CActionGuard { public: CActionGuard(const TFunc& func) : m_func(func) {} ~CActionGuard() { m_func(); } private: TFunc m_func; }; template <typename TFunc> CActionGuard<TFunc> makeGuard(const TFunc& func) { return CActionGuard<TFunc>(func); }
// // Copyright Renga Software LLC, 2017. All rights reserved. // // Renga Software LLC PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // Renga Software LLC DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // #pragma once class BoolGuard { public: explicit BoolGuard(bool& variable); explicit BoolGuard(bool& variable, bool initialValue); BoolGuard(const BoolGuard& guard) = delete; BoolGuard& operator = (const BoolGuard& guard) = delete; ~BoolGuard(); private: bool& m_variable; }; template <typename TFunc> class CActionGuard { public: CActionGuard(TFunc&& func) : m_func(std::forward<TFunc>(func)) {} ~CActionGuard() { m_func(); } private: TFunc m_func; }; template <typename TFunc> CActionGuard<TFunc> makeGuard(TFunc&& func) { return CActionGuard<TFunc>(std::forward<TFunc>(func)); }
Fix pass by value error in SpeechRecognitionHypothesis constructor.
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_ #define CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_ #pragma once #include <vector> #include "base/basictypes.h" #include "base/string16.h" #include "content/common/content_export.h" namespace content { struct SpeechRecognitionHypothesis { string16 utterance; double confidence; SpeechRecognitionHypothesis() : confidence(0.0) {} SpeechRecognitionHypothesis(const string16 utterance_value, double confidence_value) : utterance(utterance_value), confidence(confidence_value) { } }; typedef std::vector<SpeechRecognitionHypothesis> SpeechRecognitionHypothesisArray; struct CONTENT_EXPORT SpeechRecognitionResult { SpeechRecognitionHypothesisArray hypotheses; bool provisional; SpeechRecognitionResult(); ~SpeechRecognitionResult(); }; } // namespace content #endif // CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_ #define CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_ #pragma once #include <vector> #include "base/basictypes.h" #include "base/string16.h" #include "content/common/content_export.h" namespace content { struct SpeechRecognitionHypothesis { string16 utterance; double confidence; SpeechRecognitionHypothesis() : confidence(0.0) {} SpeechRecognitionHypothesis(const string16& utterance_value, double confidence_value) : utterance(utterance_value), confidence(confidence_value) { } }; typedef std::vector<SpeechRecognitionHypothesis> SpeechRecognitionHypothesisArray; struct CONTENT_EXPORT SpeechRecognitionResult { SpeechRecognitionHypothesisArray hypotheses; bool provisional; SpeechRecognitionResult(); ~SpeechRecognitionResult(); }; } // namespace content #endif // CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_
Build number for OpenSSL bug fix
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 99 #define CLIENT_VERSION_BUILD 8 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2014 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning and copyright year // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 8 #define CLIENT_VERSION_REVISION 99 #define CLIENT_VERSION_BUILD 9 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) // Todo: update this when changing our copyright comments in the source #define COPYRIGHT_YEAR 2014 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
Remove unused (and deprecated) declaration.
#ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H typedef struct _Status Status; typedef struct _Config Config; struct _Status { Evas_List *frequencies; Evas_List *governors; int cur_frequency; int can_set_frequency; char *cur_governor; unsigned char active; }; struct _Config { /* saved * loaded config values */ double poll_time; int restore_governor; const char *governor; /* just config state */ E_Module *module; Evas_List *instances; E_Menu *menu; E_Menu *menu_poll; E_Menu *menu_governor; E_Menu *menu_frequency; Status *status; char *set_exe_path; Ecore_Timer *frequency_check_timer; }; EAPI extern E_Module_Api e_modapi; EAPI void *e_modapi_init (E_Module *m); EAPI int e_modapi_shutdown (E_Module *m); EAPI int e_modapi_save (E_Module *m); EAPI int e_modapi_about (E_Module *m); #endif
#ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H typedef struct _Status Status; typedef struct _Config Config; struct _Status { Evas_List *frequencies; Evas_List *governors; int cur_frequency; int can_set_frequency; char *cur_governor; unsigned char active; }; struct _Config { /* saved * loaded config values */ double poll_time; int restore_governor; const char *governor; /* just config state */ E_Module *module; Evas_List *instances; E_Menu *menu; E_Menu *menu_poll; E_Menu *menu_governor; E_Menu *menu_frequency; Status *status; char *set_exe_path; Ecore_Timer *frequency_check_timer; }; EAPI extern E_Module_Api e_modapi; EAPI void *e_modapi_init (E_Module *m); EAPI int e_modapi_shutdown (E_Module *m); EAPI int e_modapi_save (E_Module *m); #endif
Fix SMP build with disabled CPU hotplugging.
#ifndef _OFFLINE_STATES_H_ #define _OFFLINE_STATES_H_ /* Cpu offline states go here */ enum cpu_state_vals { CPU_STATE_OFFLINE, CPU_STATE_INACTIVE, CPU_STATE_ONLINE, CPU_MAX_OFFLINE_STATES }; extern enum cpu_state_vals get_cpu_current_state(int cpu); extern void set_cpu_current_state(int cpu, enum cpu_state_vals state); extern enum cpu_state_vals get_preferred_offline_state(int cpu); extern void set_preferred_offline_state(int cpu, enum cpu_state_vals state); extern void set_default_offline_state(int cpu); extern int start_secondary(void); #endif
#ifndef _OFFLINE_STATES_H_ #define _OFFLINE_STATES_H_ /* Cpu offline states go here */ enum cpu_state_vals { CPU_STATE_OFFLINE, CPU_STATE_INACTIVE, CPU_STATE_ONLINE, CPU_MAX_OFFLINE_STATES }; #ifdef CONFIG_HOTPLUG_CPU extern enum cpu_state_vals get_cpu_current_state(int cpu); extern void set_cpu_current_state(int cpu, enum cpu_state_vals state); extern void set_preferred_offline_state(int cpu, enum cpu_state_vals state); extern void set_default_offline_state(int cpu); #else static inline enum cpu_state_vals get_cpu_current_state(int cpu) { return CPU_STATE_ONLINE; } static inline void set_cpu_current_state(int cpu, enum cpu_state_vals state) { } static inline void set_preferred_offline_state(int cpu, enum cpu_state_vals state) { } static inline void set_default_offline_state(int cpu) { } #endif extern enum cpu_state_vals get_preferred_offline_state(int cpu); extern int start_secondary(void); #endif
Add prefix file for ProjectBuilder samples
/* * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Xerces" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache\@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR * ITS 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. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation, and was * originally based on software copyright (c) 2001, International * Business Machines, Inc., http://www.ibm.com . For more information * on the Apache Software Foundation, please see * <http://www.apache.org/>. */ /* * $Id$ */ // Objective C only #if __OBJC__ #endif // C++ only #if defined(__cplusplus) #include <algorithm> #include <cstring> #include <cstdlib> #include <cctype> #include <cstdio> #include <memory> #endif // Standard C headers #include <stddef.h> #include <stdlib.h> #include <string.h> #include <stdlib.h> // Carbon Headers #include <Carbon/Carbon.h> #include <CoreFoundation/CoreFoundation.h>
Fix import React/RCTBridgeModule.h, needed by RN 0.50
// // RCTSpotlightSearch.h // RCTSpotlightSearch // // Created by James (Home) on 21/06/2016. // Copyright © 2016 James Munro. All rights reserved. // #import <Foundation/Foundation.h> #import "RCTBridgeModule.h" @interface RCTSpotlightSearch : NSObject <RCTBridgeModule> + (void)handleContinueUserActivity:(NSUserActivity *)userActivity; @end
// // RCTSpotlightSearch.h // RCTSpotlightSearch // // Created by James (Home) on 21/06/2016. // Copyright © 2016 James Munro. All rights reserved. // #import <Foundation/Foundation.h> #import <React/RCTBridgeModule.h> @interface RCTSpotlightSearch : NSObject <RCTBridgeModule> + (void)handleContinueUserActivity:(NSUserActivity *)userActivity; @end
Add override specifier for VectorBufferWriter destructor.
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/searchlib/util/bufferwriter.h> #include <vector> namespace search::test { class VectorBufferWriter : public BufferWriter { private: char tmp[1024]; public: std::vector<char> output; VectorBufferWriter(); ~VectorBufferWriter(); void flush() override; }; }
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/searchlib/util/bufferwriter.h> #include <vector> namespace search::test { class VectorBufferWriter : public BufferWriter { private: char tmp[1024]; public: std::vector<char> output; VectorBufferWriter(); ~VectorBufferWriter() override; void flush() override; }; }
Add List Search function implementation
#include "list.h" struct ListNode { ListNode* prev; ListNode* next; void* k; }; struct List { ListNode* head; }; List* List_Create(void) { List* l = (List *)malloc(sizeof(List)); l->head = NULL; return l; } ListNode* ListNode_Create(void* k) { ListNode* n = (ListNode *)malloc(sizeof(ListNode)); n->prev = NULL; n->next = NULL; n->k = k; return n; }
#include "list.h" struct ListNode { ListNode* prev; ListNode* next; void* k; }; struct List { ListNode* head; }; List* List_Create(void) { List* l = (List *)malloc(sizeof(List)); l->head = NULL; return l; } ListNode* ListNode_Create(void* k) { ListNode* n = (ListNode *)malloc(sizeof(ListNode)); n->prev = NULL; n->next = NULL; n->k = k; return n; } ListNode* List_Search(List* l, void* k, int (f)(void*, void*)) { ListNode* n = l->head; while (n != NULL && !f(n->k, k)) { n = n->next; } return n; }
Allow extinguishing of objects with the same creator as yourself.
#include <status.h> #include <kotaka/paths.h> #include <kotaka/log.h> #include <kotaka/privilege.h> inherit SECOND_AUTO; void extinguish(string path) { ACCESS_CHECK(KADMIN()); call_out("purge", 0, path, status(ST_OTABSIZE)); } static void purge(string path, int quota) { int limit; limit = 200; if (quota % limit != 0) { limit = quota % limit; } for (; quota > 0 && limit > 0; quota--, limit--) { object obj; if (obj = find_object(path + "#" + quota)) { destruct_object(obj); } } LOGD->post_message("test", LOG_INFO, quota + " objects to check."); if (quota > 0) { call_out("purge", 0, path, quota); } }
#include <status.h> #include <kotaka/paths.h> #include <kotaka/log.h> #include <kotaka/privilege.h> inherit SECOND_AUTO; void extinguish(string path) { if (!KADMIN()) { string opath; opath = object_name(previous_object()); ACCESS_CHECK(DRIVER->creator(opath)); ACCESS_CHECK(DRIVER->creator(opath) == DRIVER->creator(path)); } call_out("purge", 0, path, status(ST_OTABSIZE)); } static void purge(string path, int quota) { int limit; limit = 128; if (quota % limit != 0) { limit = quota % limit; } for (; quota > 0 && limit > 0; quota--, limit--) { object obj; if (obj = find_object(path + "#" + quota)) { destruct_object(obj); } } LOGD->post_message("test", LOG_INFO, quota + " objects to check."); if (quota > 0) { call_out("purge", 0, path, quota); } }
Disable PROM access on init.
#include "drmP.h" #include "drm.h" #include "nouveau_drv.h" #include "nouveau_drm.h" int nv04_mc_init(struct drm_device *dev) { /* Power up everything, resetting each individual unit will * be done later if needed. */ nv_wr32(dev, NV03_PMC_ENABLE, 0xFFFFFFFF); return 0; } void nv04_mc_takedown(struct drm_device *dev) { }
#include "drmP.h" #include "drm.h" #include "nouveau_drv.h" #include "nouveau_drm.h" int nv04_mc_init(struct drm_device *dev) { /* Power up everything, resetting each individual unit will * be done later if needed. */ nv_wr32(dev, NV03_PMC_ENABLE, 0xFFFFFFFF); /* Disable PROM access. */ nv_wr32(dev, NV_PBUS_PCI_NV_20, NV_PBUS_PCI_NV_20_ROM_SHADOW_ENABLED); return 0; } void nv04_mc_takedown(struct drm_device *dev) { }
Add example of formatted C string for string in M_LET
#include <stdio.h> #include "m-array.h" #include "m-string.h" // Let's create an array of string_t and register it globaly ARRAY_DEF(vector_string, string_t) #define M_OPL_vector_string_t() ARRAY_OPLIST(vector_string, STRING_OPLIST) int main(void) { // Let's define a new string named str M_LET(str, string_t) // Let's define msg as a vector_array_t M_LET( (msg, STRING_CTE("Hello"), STRING_CTE("C"), STRING_CTE("World!"), STRING_CTE("Let's"), STRING_CTE("discover"), STRING_CTE("M*LIB!")), vector_string_t) { // Iterate over all words of the array msg for M_EACH(word, msg, vector_string_t) { // Cat the current word into the target string string_cat(str, *word); // Also add a space character string_push_back(str, ' '); } // Print the result printf("%s\n", string_get_cstr(str) ); } return 0; }
#include <stdio.h> #include "m-array.h" #include "m-string.h" // Let's create an array of string_t and register it globaly ARRAY_DEF(vector_string, string_t) #define M_OPL_vector_string_t() ARRAY_OPLIST(vector_string, STRING_OPLIST) int main(void) { // Let's define a new string named str M_LET(str, string_t) // Let's define msg as a vector_array_t M_LET( (msg, STRING_CTE("Hello"), STRING_CTE("C"), STRING_CTE("World!"), STRING_CTE("Let's"), STRING_CTE("discover"), STRING_CTE("M*LIB!")), vector_string_t) { // Iterate over all words of the array msg for M_EACH(word, msg, vector_string_t) { // Cat the current word into the target string string_cat(str, *word); // Also add a space character string_push_back(str, ' '); } // Let's define another string and set it to a formatted value. M_LET( (count, "\nTo display this it uses \"vector\" of %zu strings!", vector_string_size(msg)), string_t) { string_cat(str, count); } // Print the result printf("%s\n", string_get_cstr(str) ); } return 0; }
Use correct module directory when making keyboard. Previous commit fixed compiler warnings also.
#include "e.h" #include "e_mod_main.h" #include "e_mod_config.h" #include "e_kbd_int.h" /* local variables */ static E_Kbd_Int *ki = NULL; EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Keyboard" }; EAPI void * e_modapi_init(E_Module *m) { if (!il_kbd_config_init(m)) return NULL; ki = e_kbd_int_new(mod_dir, mod_dir, mod_dir); return m; } EAPI int e_modapi_shutdown(E_Module *m) { if (ki) { e_kbd_int_free(ki); ki = NULL; } il_kbd_config_shutdown(); return 1; } EAPI int e_modapi_save(E_Module *m) { return il_kbd_config_save(); }
#include "e.h" #include "e_mod_main.h" #include "e_mod_config.h" #include "e_kbd_int.h" /* local variables */ static E_Kbd_Int *ki = NULL; EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Keyboard" }; EAPI void * e_modapi_init(E_Module *m) { if (!il_kbd_config_init(m)) return NULL; ki = e_kbd_int_new(il_kbd_cfg->mod_dir, il_kbd_cfg->mod_dir, il_kbd_cfg->mod_dir); return m; } EAPI int e_modapi_shutdown(E_Module *m) { if (ki) { e_kbd_int_free(ki); ki = NULL; } il_kbd_config_shutdown(); return 1; } EAPI int e_modapi_save(E_Module *m) { return il_kbd_config_save(); }
Throw a fatal pre-processor error if (n > UINT_MAX).
#ifndef _DOORS_H_ #define _DOORS_H_ #ifndef NUMBER_OF_DOORS #define NUMBER_OF_DOORS 3 #endif typedef struct { unsigned int has_prize : 1; unsigned int currently_selected: 1; unsigned int revealed : 1; } door; /* * game status updates */ extern void set_doors(void); extern void select_door(unsigned int number); extern void show_doors(void); extern void reveal_all_doors(void); /* * game status queries */ extern unsigned int get_door_number(void); extern unsigned int current_guess(void); extern unsigned int winning_door(void); extern unsigned int hint_door(void); #endif
#ifndef _DOORS_H_ #define _DOORS_H_ #ifndef NUMBER_OF_DOORS #define NUMBER_OF_DOORS 3 #endif #include <limits.h> #if (NUMBER_OF_DOORS > UINT_MAX) #error (n) doors exceeds storage allocation limit for `unsigned int'. #endif typedef struct { unsigned int has_prize : 1; unsigned int currently_selected: 1; unsigned int revealed : 1; } door; /* * game status updates */ extern void set_doors(void); extern void select_door(unsigned int number); extern void show_doors(void); extern void reveal_all_doors(void); /* * game status queries */ extern unsigned int get_door_number(void); extern unsigned int current_guess(void); extern unsigned int winning_door(void); extern unsigned int hint_door(void); #endif
Add a convenience function to get an NSString from a CLLocationCoordinate2D object
#import <CoreLocation/CLLocation.h> #define DEGREES_PER_RADIAN 180.0 / M_PI #define RADIANS_PER_DEGREE M_PI / 180.0 #define DEFAULT_MAP_CENTER CLLocationCoordinate2DMake(42.35913,-71.09325) #define DEFAULT_MAP_SPAN MKCoordinateSpanMake(0.006, 0.006) // these are 1 and 2 miles respectively #define OUT_OF_BOUNDS_DISTANCE 1609 #define WAY_OUT_OF_BOUNDS_DISTANCE 3218 @interface CLLocation (MITAdditions) - (CLLocationDistance)distanceFromCenterOfCampus; - (BOOL)isOnCampus; - (BOOL)isNearCampus; @end @interface NSValue (CL_MITAdditions) + (NSValue *)valueWithMKCoordinate:(CLLocationCoordinate2D)coordinate; - (CLLocationCoordinate2D)MKCoordinateValue; @end
#import <CoreLocation/CLLocation.h> #import <CoreLocation/CoreLocation.h> #define DEGREES_PER_RADIAN 180.0 / M_PI #define RADIANS_PER_DEGREE M_PI / 180.0 #define DEFAULT_MAP_CENTER CLLocationCoordinate2DMake(42.35913,-71.09325) #define DEFAULT_MAP_SPAN MKCoordinateSpanMake(0.006, 0.006) // these are 1 and 2 miles respectively #define OUT_OF_BOUNDS_DISTANCE 1609 #define WAY_OUT_OF_BOUNDS_DISTANCE 3218 FOUNDATION_STATIC_INLINE inline NSString* NSStringFromCLLocationCoordinate2D(CLLocationCoordinate2D coordinate) { return [NSString stringWithFormat:@"{ x: %lf, y: %lf }", coordinate.longitude, coordinate.latitude]; } @interface CLLocation (MITAdditions) - (CLLocationDistance)distanceFromCenterOfCampus; - (BOOL)isOnCampus; - (BOOL)isNearCampus; @end @interface NSValue (CL_MITAdditions) + (NSValue *)valueWithMKCoordinate:(CLLocationCoordinate2D)coordinate; - (CLLocationCoordinate2D)MKCoordinateValue; @end
Add parameter passing example in c
/* * Author: Jhonatan Casale (jhc) * * Contact : jhonatan@jhonatancasale.com * : casale.jhon@gmail.com * : https://github.com/jhonatancasale * : https://twitter.com/jhonatancasale * : http://jhonatancasale.github.io/ * * Create date Sat 10 Dec 16:13:19 BRST 2016 * */ #include <stdlib.h> #include <stdio.h> int sumByReference (int *, int *); int sumByValue (int, int); int main (int argc, char **argv) { int a = 10; int b = 37; printf ("a:%d, b%d\n", a, b); printf ("a:%d, b%d => sumByValue() = %d\n", a, b, sumByValue(a, b) ); printf ("a:%d, b%d => sumByReference() = %d\n", a, b, sumByReference(&a, &b) ); printf ("a:%d, b%d\n", a, b); return (EXIT_SUCCESS); } int sumByValue (int a, int b) { int aux = a; a = b; b = aux; return (a + b); } int sumByReference ( int * a, int * b) { int aux = *a; *a = *b; *b = aux; return (*a + *b); }
Use move semantics in Optional implementation.
#pragma once namespace me { template<class T> class Optional { T *m_object; public: Optional() : m_object(0) {} Optional(const T& other) : m_object(new T(other)) {} Optional& operator=(const T& other) { if (m_object != 0) { delete m_object; } m_object = new T(other); return *this; } operator bool() const { return m_object != 0; } T& operator *() const { return *m_object; } T* operator ->() const { return m_object; } T* pointer() const { return m_object; } }; // splitting. std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems); std::vector<std::string> split(const std::string &s, char delim); }
#pragma once namespace me { // basic optional implementation. template<class T> class Optional { T *m_object; public: Optional() : m_object(0) { } // copy constructor Optional(const Optional<T>& other) : m_object(new T(*other)) { } // move constructor Optional(Optional<T>&& other) : m_object(other.m_object) { other.m_object = 0; } Optional(const T& other) : m_object(new T(other)) { } // destructor ~Optional() { delete m_object; // delete 0 is a no-op, so we are fine here. } // copy assignment operator Optional& operator=(const Optional<T>& other) { delete m_object; // delete 0 is a no-op m_object = new T(*other); return *this; } Optional& operator=(const T& other) { delete m_object; // delete 0 is a no-op m_object = new T(other); return *this; } // move assignment operator Optional& operator=(Optional<T>&& other) { delete m_object; // delete 0 is a no-op m_object = other.m_object; other.m_object = 0; return *this; } operator bool() const { return m_object != 0; } T& operator *() const { return *m_object; } T* operator ->() const { return m_object; } T* pointer() const { return m_object; } }; // splitting. std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems); std::vector<std::string> split(const std::string &s, char delim); }
Mark ContiguousMemoryRange::size as const. am: f2c28cd765
/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #define INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #include <assert.h> #include <stddef.h> #include <stdint.h> namespace protozero { // Keep this struct trivially constructible (no ctors, no default initializers). struct ContiguousMemoryRange { uint8_t* begin; uint8_t* end; // STL style: one byte past the end of the buffer. inline bool is_valid() const { return begin != nullptr; } inline void reset() { begin = nullptr; } inline size_t size() { return static_cast<size_t>(end - begin); } }; } // namespace protozero #endif // INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_
/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #define INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #include <assert.h> #include <stddef.h> #include <stdint.h> namespace protozero { // Keep this struct trivially constructible (no ctors, no default initializers). struct ContiguousMemoryRange { uint8_t* begin; uint8_t* end; // STL style: one byte past the end of the buffer. inline bool is_valid() const { return begin != nullptr; } inline void reset() { begin = nullptr; } inline size_t size() const { return static_cast<size_t>(end - begin); } }; } // namespace protozero #endif // INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_
Add infinite goto loop examples as SV-COMP tests
extern void __VERIFIER_error() __attribute__((__noreturn__)); int main() { f_empty_goto_loop(); f_empty_while_loop(); f_empty_goto_loop_suffix(); f_empty_while_loop_suffix(); f_nonempty_goto_loop(); f_nonempty_while_loop(); return 0; } void f_empty_goto_loop() { f_empty_goto_loop_label: goto f_empty_goto_loop_label; } void f_empty_while_loop() { while (1) {} } void f_empty_goto_loop_suffix() { f_empty_goto_loop_suffix_label: goto f_empty_goto_loop_suffix_label; __VERIFIER_error(); } void f_empty_while_loop_suffix() { while (1) {} __VERIFIER_error(); } void f_nonempty_goto_loop() { f_nonempty_goto_loop_label: __VERIFIER_error(); goto f_nonempty_goto_loop_label; } void f_nonempty_while_loop() { while (1) { __VERIFIER_error(); } }
Add support for the Python Stdout Log
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #pragma once #include "ModuleManager.h" DECLARE_LOG_CATEGORY_EXTERN(LogPython, Log, All); class UNREALENGINEPYTHON_API FUnrealEnginePythonModule : public IModuleInterface { public: bool PythonGILAcquire(); void PythonGILRelease(); virtual void StartupModule() override; virtual void ShutdownModule() override; void RunString(char *); void RunFile(char *); void RunFileSandboxed(char *); private: void *ue_python_gil; // used by console void *main_dict; void *local_dict; }; struct FScopePythonGIL { FScopePythonGIL() { #if defined(UEPY_THREADING) UnrealEnginePythonModule = FModuleManager::LoadModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython"); safeForRelease = UnrealEnginePythonModule.PythonGILAcquire(); #endif } ~FScopePythonGIL() { #if defined(UEPY_THREADING) if (safeForRelease) { UnrealEnginePythonModule.PythonGILRelease(); } #endif } FUnrealEnginePythonModule UnrealEnginePythonModule; bool safeForRelease; };
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #pragma once #include "ModuleManager.h" DECLARE_LOG_CATEGORY_EXTERN(LogPython, Log, All); class UNREALENGINEPYTHON_API FUnrealEnginePythonModule : public IModuleInterface { public: bool PythonGILAcquire(); void PythonGILRelease(); virtual void StartupModule() override; virtual void ShutdownModule() override; void RunString(char *); void RunFile(char *); void RunFileSandboxed(char *); private: void *ue_python_gil; // used by console void *main_dict; void *local_dict; void *main_module; }; struct FScopePythonGIL { FScopePythonGIL() { #if defined(UEPY_THREADING) UnrealEnginePythonModule = FModuleManager::LoadModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython"); safeForRelease = UnrealEnginePythonModule.PythonGILAcquire(); #endif } ~FScopePythonGIL() { #if defined(UEPY_THREADING) if (safeForRelease) { UnrealEnginePythonModule.PythonGILRelease(); } #endif } FUnrealEnginePythonModule UnrealEnginePythonModule; bool safeForRelease; };
Fix forward declaration of BmStorageLinkContext.
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/storage/common/storage_chain_builder.h> namespace feedbm { class BmStorageLinkContext; /* * Storage chain builder that inserts a BmStorageLink right below the * communication manager. This allows sending benchmark feed to chain. */ class BmStorageChainBuilder : public storage::StorageChainBuilder { std::shared_ptr<BmStorageLinkContext> _context; public: BmStorageChainBuilder(); ~BmStorageChainBuilder() override; const std::shared_ptr<BmStorageLinkContext>& get_context() { return _context; } void add(std::unique_ptr<storage::StorageLink> link) override; }; }
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/storage/common/storage_chain_builder.h> namespace feedbm { struct BmStorageLinkContext; /* * Storage chain builder that inserts a BmStorageLink right below the * communication manager. This allows sending benchmark feed to chain. */ class BmStorageChainBuilder : public storage::StorageChainBuilder { std::shared_ptr<BmStorageLinkContext> _context; public: BmStorageChainBuilder(); ~BmStorageChainBuilder() override; const std::shared_ptr<BmStorageLinkContext>& get_context() { return _context; } void add(std::unique_ptr<storage::StorageLink> link) override; }; }
Exclude skiplist string key tests from device
/******************************************************************************/ /** @file @author Kris Wallperington @brief Behaviour tests for the skip list implementation. @copyright Copyright 2016 The University of British Columbia, IonDB Project Contributors (see AUTHORS.md) @par 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 @par Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /******************************************************************************/ #include "../../../planckunit/src/planck_unit.h" #include "../behaviour_dictionary.h" #include "../../../../dictionary/skip_list/skip_list_handler.h" #include "test_behaviour_skip_list.h" void runalltests_behaviour_skip_list( void ) { bhdct_run_tests(sldict_init, 7, BHDCT_ALL_TESTS); }
/******************************************************************************/ /** @file @author Kris Wallperington @brief Behaviour tests for the skip list implementation. @copyright Copyright 2016 The University of British Columbia, IonDB Project Contributors (see AUTHORS.md) @par 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 @par Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /******************************************************************************/ #include "../../../planckunit/src/planck_unit.h" #include "../behaviour_dictionary.h" #include "../../../../dictionary/skip_list/skip_list_handler.h" #include "test_behaviour_skip_list.h" void runalltests_behaviour_skip_list( void ) { #if defined(ARDUINO) bhdct_run_tests(sldict_init, 7, BHDCT_ALL_TESTS & ~BHDCT_STRING_INT); #else bhdct_run_tests(sldict_init, 7, BHDCT_ALL_TESTS); #endif }
Test cleanup-attribute with const struct parameter
// RUN: %ocheck 0 %s struct store_out { int *local; int *ret; }; void store_out(const struct store_out *const so) { *so->ret = *so->local; } void f(int *p) { int i = *p; struct store_out so __attribute((cleanup(store_out))) = { .local = &i, .ret = p }; i = 5; } main() { int i = 3; f(&i); if(i != 5) abort(); return 0; }
Add Linux porting (for testing)
#if !defined(DUX_OPT_NO_TIMER) && defined(__linux__) #include "../dux_internal.h" #include <time.h> DUK_INTERNAL duk_uint_t dux_timer_current(void) { struct timespec tp; if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) { return 0; } return (duk_uint_t)(tp.tv_sec * 1000 + tp.tv_nsec / 1000000); } #endif /* !DUX_OPT_NO_TIMER && __linux__ */
Introduce the macro `PATH_LITERAL` for helping construct `PathString`.
/* @ 0xCCCCCCCC */ #if defined(_MSC_VER) #pragma once #endif #ifndef KLOG_BASIC_TYPES_H_ #define KLOG_BASIC_TYPES_H_ #include <string> #include "klog/basic_macros.h" namespace klog { #if defined(OS_WIN) using PathChar = wchar_t; using PathString = std::wstring; #else using PathChar = char; using PathString = std::string; #endif } // namespace klog #endif // KLOG_BASIC_TYPES_H_
/* @ 0xCCCCCCCC */ #if defined(_MSC_VER) #pragma once #endif #ifndef KLOG_BASIC_TYPES_H_ #define KLOG_BASIC_TYPES_H_ #include <string> #include "klog/basic_macros.h" namespace klog { #if defined(OS_WIN) using PathChar = wchar_t; using PathString = std::wstring; #define PATH_LITERAL(str) L##str #else using PathChar = char; using PathString = std::string; #define PATH_LITERAL(str) str #endif } // namespace klog #endif // KLOG_BASIC_TYPES_H_
Change __nosave_XXX symbols to long
#ifndef __ASM_SH_SECTIONS_H #define __ASM_SH_SECTIONS_H #include <asm-generic/sections.h> extern void __nosave_begin, __nosave_end; extern long __machvec_start, __machvec_end; extern char __uncached_start, __uncached_end; extern char _ebss[]; extern char __start_eh_frame[], __stop_eh_frame[]; #endif /* __ASM_SH_SECTIONS_H */
#ifndef __ASM_SH_SECTIONS_H #define __ASM_SH_SECTIONS_H #include <asm-generic/sections.h> extern long __nosave_begin, __nosave_end; extern long __machvec_start, __machvec_end; extern char __uncached_start, __uncached_end; extern char _ebss[]; extern char __start_eh_frame[], __stop_eh_frame[]; #endif /* __ASM_SH_SECTIONS_H */
Remove deleted header declaration for SaveFrameToSkPicture
// Copyright 2015 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. #import <UIKit/UIKit.h> #import "sky/shell/shell_view.h" @interface SkySurface : UIView -(instancetype) initWithShellView:(sky::shell::ShellView *) shellView; @end extern "C" { void SaveFrameToSkPicture(); }
// Copyright 2015 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. #import <UIKit/UIKit.h> #import "sky/shell/shell_view.h" @interface SkySurface : UIView -(instancetype) initWithShellView:(sky::shell::ShellView *) shellView; @end
Change version to 0.1.0 to follow the PHP standard.
/* This module exposes to PHP the equivalent of: * // Creates a chdb file containing the key-value pairs specified in the * // array $data, or throws an exception in case of error. * function chdb_create($pathname, $data); * * // Represents a loaded chdb file. * class chdb * { * // Loads a chdb file, or throws an exception in case of error. * public function __construct($pathname); * * // Returns the value of the given $key, or null if not found. * public function get($key); * } */ #ifndef PHP_CHDB_H #define PHP_CHDB_H #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <php.h> #define PHP_CHDB_VERSION "0.1" extern zend_module_entry chdb_module_entry; #define phpext_chdb_ptr &chdb_module_entry #endif
/* This module exposes to PHP the equivalent of: * // Creates a chdb file containing the key-value pairs specified in the * // array $data, or throws an exception in case of error. * function chdb_create($pathname, $data); * * // Represents a loaded chdb file. * class chdb * { * // Loads a chdb file, or throws an exception in case of error. * public function __construct($pathname); * * // Returns the value of the given $key, or null if not found. * public function get($key); * } */ #ifndef PHP_CHDB_H #define PHP_CHDB_H #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <php.h> #define PHP_CHDB_VERSION "0.1.0" extern zend_module_entry chdb_module_entry; #define phpext_chdb_ptr &chdb_module_entry #endif
Add <cstddef> to use std::size_t.
#ifndef GLOBAL__H #define GLOBAL__H namespace qflex::global { // Default verbose level inline int verbose = 0; // Max allowed memory (default: 1GB) inline std::size_t memory_limit = 1L << 30; // Interval to track memory (default: 0) inline std::size_t track_memory_seconds = 0; } // namespace qflex::global #endif
#ifndef GLOBAL__H #define GLOBAL__H #include <cstddef> namespace qflex::global { // Default verbose level inline int verbose = 0; // Max allowed memory (default: 1GB) inline std::size_t memory_limit = 1L << 30; // Interval to track memory (default: 0) inline std::size_t track_memory_seconds = 0; } // namespace qflex::global #endif
Use unsafe_unretained for delegates, to support OS X
// // RACDelegateProxy.h // ReactiveCocoa // // Created by Cody Krieger on 5/19/12. // Copyright (c) 2012 GitHub, Inc. All rights reserved. // #import <Foundation/Foundation.h> // A delegate object suitable for using -rac_signalForSelector:fromProtocol: // upon. @interface RACDelegateProxy : NSObject // The delegate to which messages should be forwarded if not handled by // any -rac_signalForSelector:fromProtocol: applications. @property (nonatomic, weak) id rac_proxiedDelegate; // Creates a delegate proxy which will respond to selectors from `protocol`. - (instancetype)initWithProtocol:(Protocol *)protocol; @end
// // RACDelegateProxy.h // ReactiveCocoa // // Created by Cody Krieger on 5/19/12. // Copyright (c) 2012 GitHub, Inc. All rights reserved. // #import <Foundation/Foundation.h> // A delegate object suitable for using -rac_signalForSelector:fromProtocol: // upon. @interface RACDelegateProxy : NSObject // The delegate to which messages should be forwarded if not handled by // any -rac_signalForSelector:fromProtocol: applications. @property (nonatomic, unsafe_unretained) id rac_proxiedDelegate; // Creates a delegate proxy which will respond to selectors from `protocol`. - (instancetype)initWithProtocol:(Protocol *)protocol; @end
Remove duplicate declarations of _stext[] and _etext[]
/* * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> * Copyright (C) 2008-2009 PetaLogix * Copyright (C) 2006 Atmark Techno, Inc. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. */ #ifndef _ASM_MICROBLAZE_SECTIONS_H #define _ASM_MICROBLAZE_SECTIONS_H #include <asm-generic/sections.h> # ifndef __ASSEMBLY__ extern char _ssbss[], _esbss[]; extern unsigned long __ivt_start[], __ivt_end[]; extern char _etext[], _stext[]; extern u32 _fdt_start[], _fdt_end[]; # endif /* !__ASSEMBLY__ */ #endif /* _ASM_MICROBLAZE_SECTIONS_H */
/* * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> * Copyright (C) 2008-2009 PetaLogix * Copyright (C) 2006 Atmark Techno, Inc. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. */ #ifndef _ASM_MICROBLAZE_SECTIONS_H #define _ASM_MICROBLAZE_SECTIONS_H #include <asm-generic/sections.h> # ifndef __ASSEMBLY__ extern char _ssbss[], _esbss[]; extern unsigned long __ivt_start[], __ivt_end[]; extern u32 _fdt_start[], _fdt_end[]; # endif /* !__ASSEMBLY__ */ #endif /* _ASM_MICROBLAZE_SECTIONS_H */
Fix macro in Chrome's GL config file
#ifndef GrGLConfig_chrome_DEFINED #define GrGLConfig_chrome_DEFINED #define GR_SUPPORT_GLES2 1 // gl2ext.h will define these extensions macros but Chrome doesn't provide // prototypes. #define GL_OES_mapbuffer 0 #define GR_GL_PLATFORM_HEADER <GLES2/gl2.h> #define GR_GL_PLATFORM_HEADER_EXT <GLES2/gl2ext.h> #define GR_GL_FUNCTION_TYPE #define GR_GL_PROC_ADDRESS(X) &X // chrome always assumes BGRA #define GR_GL_32BPP_COLOR_FORMAT GR_BGRA // glGetError() forces a sync with gpu process on chrome #define GR_GL_CHECK_ERROR_START 0 #endif
#ifndef GrGLConfig_chrome_DEFINED #define GrGLConfig_chrome_DEFINED #define GR_SUPPORT_GLES2 1 // gl2ext.h will define these extensions macros but Chrome doesn't provide // prototypes. #define GL_OES_mapbuffer 0 #define GR_GL_PLATFORM_HEADER <GLES2/gl2.h> #define GR_GL_PLATFORM_HEADER_EXT <GLES2/gl2ext.h> #define GR_GL_FUNCTION_TYPE #define GR_GL_PROC_ADDRESS(X) &X // chrome always assumes BGRA #define GR_GL_32BPP_COLOR_FORMAT GR_GL_BGRA // glGetError() forces a sync with gpu process on chrome #define GR_GL_CHECK_ERROR_START 0 #endif
Add a tag (dummy) header file that will be updated whenever CINT's dictionaries need to be regenerated.
/*********************************************************************** * cint (C/C++ interpreter) ************************************************************************ * CINT header file cintdictversion.h ************************************************************************ * Description: * definition of the dictionary API version ************************************************************************ * Copyright(c) 1995~2008 Masaharu Goto (cint@pcroot.cern.ch) * * For the licensing terms see the file COPYING * ************************************************************************/ #ifndef INCLUDE_CINTDICTVERSION #define INCLUDE_CINTDICTVERSION #define G__CINTDICTVERSION 2008-01-21 #endif /* INCLUDE_CINTDICTVERSION */
Fix typo in the commit a5312c77.
#include <string.h> #include "ruby.h" #include "rubyspec.h" #ifdef __cplusplus extern "C" { #endif #ifdef HAVE_RB_PROC_NEW VALUE concat_func(VALUE args) { int i; char buffer[500] = {0}; if (TYPE(val) != T_ARRAY) return Qnil; for(i = 0; i < RARRAY_LEN(args); ++i) { VALUE v = RARRAY_PTR(args)[i]; strcat(buffer, StringValuePtr(v)); strcat(buffer, "_"); } buffer[strlen(buffer) - 1] = 0; return rb_str_new2(buffer); } VALUE sp_underline_concat_proc(VALUE self) { return rb_proc_new(concat_func, Qnil); } #endif void Init_proc_spec() { VALUE cls; cls = rb_define_class("CApiProcSpecs", rb_cObject); #ifdef HAVE_RB_PROC_NEW rb_define_method(cls, "underline_concat_proc", sp_underline_concat_proc, 0); #endif } #ifdef __cplusplus } #endif
#include <string.h> #include "ruby.h" #include "rubyspec.h" #ifdef __cplusplus extern "C" { #endif #ifdef HAVE_RB_PROC_NEW VALUE concat_func(VALUE args) { int i; char buffer[500] = {0}; if (TYPE(args) != T_ARRAY) return Qnil; for(i = 0; i < RARRAY_LEN(args); ++i) { VALUE v = RARRAY_PTR(args)[i]; strcat(buffer, StringValuePtr(v)); strcat(buffer, "_"); } buffer[strlen(buffer) - 1] = 0; return rb_str_new2(buffer); } VALUE sp_underline_concat_proc(VALUE self) { return rb_proc_new(concat_func, Qnil); } #endif void Init_proc_spec() { VALUE cls; cls = rb_define_class("CApiProcSpecs", rb_cObject); #ifdef HAVE_RB_PROC_NEW rb_define_method(cls, "underline_concat_proc", sp_underline_concat_proc, 0); #endif } #ifdef __cplusplus } #endif
Add automatic check to sanity/strict-loop-enter
//PARAM: --disable ana.int.def_exc --enable ana.int.interval --sets solver slr3tp int g = 0; int main() { int x; for(x=0; x < 50; x++){ g = 1; } // x = [50, 50] after narrow if(x>50){ // live after widen, but dead after narrow // node after Pos(x>50) is marked dead at the end // but the loop is not with x = [51,2147483647] for(int i=0; i<=0; i--){ g = 57; } } }
//PARAM: --disable ana.int.def_exc --enable ana.int.interval --sets solver slr3tp --enable dbg.debug // dbg.debug manually enabled since update_suite only enables it when it sees normal assertion (without NOWARN) #include <assert.h> int g = 0; int main() { int x; for(x=0; x < 50; x++){ g = 1; } // x = [50, 50] after narrow if(x>50){ // live after widen, but dead after narrow // node after Pos(x>50) is marked dead at the end // but the loop is not with x = [51,2147483647] for(int i=0; i<=0; i--){ g = 57; } assert(1); // NOWARN (unreachable) } }
Reduce spew when using system().
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <stdlib.h> #include "verbose.h" #include "utils.h" unsigned utils_execute_command(const char *cmd) { int result = system(cmd); if (result == 0) { verbose_log(0, LOG_WARNING, "%s: '%s' succeeded.", __FUNCTION__, cmd); return 1; } else { if (result == -1) { verbose_log(0, LOG_WARNING, "%s: Unable to invoke '%s'.", __FUNCTION__, cmd); } else if (result != 0) { verbose_log(0, LOG_WARNING, "%s: '%s' failed. Return code: %d.", __FUNCTION__, cmd, result); } return 0; } }
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <stdlib.h> #include "verbose.h" #include "utils.h" unsigned utils_execute_command(const char *cmd) { int result = system(cmd); if (result == 0) { verbose_log(7, LOG_WARNING, "%s: '%s' succeeded.", __FUNCTION__, cmd); return 1; } else { if (result == -1) { verbose_log(0, LOG_WARNING, "%s: Unable to invoke '%s'.", __FUNCTION__, cmd); } else if (result != 0) { verbose_log(0, LOG_WARNING, "%s: '%s' failed. Return code: %d.", __FUNCTION__, cmd, result); } return 0; } }
Fix playback slider initially acting as pressed
#ifndef WIDGETS_SLIDERDIRECTJUMP_H #define WIDGETS_SLIDERDIRECTJUMP_H #include <QSlider> class QMouseEvent; class SliderDirectJump : public QSlider { Q_OBJECT public: explicit SliderDirectJump(QWidget* parent = nullptr); explicit SliderDirectJump(Qt::Orientation orientation, QWidget* parent = nullptr); ~SliderDirectJump() override; bool isPressed(); signals: void valueClicked(int value); private: void init(); protected: void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; int computeHorizontalValue(int x); private: bool m_isPressed; int m_handleWidth{0}; }; #endif // WIDGETS_SLIDERDIRECTJUMP_H
#ifndef WIDGETS_SLIDERDIRECTJUMP_H #define WIDGETS_SLIDERDIRECTJUMP_H #include <QSlider> class QMouseEvent; class SliderDirectJump : public QSlider { Q_OBJECT public: explicit SliderDirectJump(QWidget* parent = nullptr); explicit SliderDirectJump(Qt::Orientation orientation, QWidget* parent = nullptr); ~SliderDirectJump() override; bool isPressed(); signals: void valueClicked(int value); private: void init(); protected: void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; int computeHorizontalValue(int x); private: bool m_isPressed{false}; int m_handleWidth{0}; }; #endif // WIDGETS_SLIDERDIRECTJUMP_H
Fix typo in tab removal
#ifndef RADIOMULT_H #define RADIOMULT_H #include "NdbMF.h" /* ========= NdbRadioMult ============ */ class NdbRad ioMult : public NdbMF { protected: public: NdbRadioMult() : NdbMF(9, "Multiplicities for radioactive nuclide production") {} ~NdbRadioMult() {} ClassDef(NdbRadioMult,1) }; // NdbRadioMult #endif
#ifndef RADIOMULT_H #define RADIOMULT_H #include "NdbMF.h" /* ========= NdbRadioMult ============ */ class NdbRadioMult : public NdbMF { protected: public: NdbRadioMult() : NdbMF(9, "Multiplicities for radioactive nuclide production") {} ~NdbRadioMult() {} ClassDef(NdbRadioMult,1) }; // NdbRadioMult #endif
Update the driver version to 8.06.00.08-k.
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2013 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.05.00.03-k" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 5 #define QLA_DRIVER_PATCH_VER 0 #define QLA_DRIVER_BETA_VER 0
/* * QLogic Fibre Channel HBA Driver * Copyright (c) 2003-2013 QLogic Corporation * * See LICENSE.qla2xxx for copyright and licensing details. */ /* * Driver version */ #define QLA2XXX_VERSION "8.06.00.08-k" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 6 #define QLA_DRIVER_PATCH_VER 0 #define QLA_DRIVER_BETA_VER 0
Make sh4 build works again adding a temporary work-around iby redefining __always_inline to inline until gcc 4.x.x will get fixed.
/* We can't use the real errno in ldso, since it has not yet * been dynamicly linked in yet. */ #include "sys/syscall.h" extern int _dl_errno; #undef __set_errno #define __set_errno(X) {(_dl_errno) = (X);} #warning !!! __always_inline redefined waiting for the fixed gcc #ifdef __always_inline #undef __always_inline #define __always_inline inline #endif
/* We can't use the real errno in ldso, since it has not yet * been dynamicly linked in yet. */ #include "sys/syscall.h" extern int _dl_errno; #undef __set_errno #define __set_errno(X) {(_dl_errno) = (X);} #if __GNUC_PREREQ (4, 1) #warning !!! gcc 4.1 and later have problems with __always_inline so redefined as inline # ifdef __always_inline # undef __always_inline # define __always_inline inline # endif #endif
Make the audio player a public property.
// // EPSPlayerViewModel.h // ReactiveAudioPlayer // // Created by Peter Stuart on 4/24/14. // Copyright (c) 2014 Electric Peel, LLC. All rights reserved. // #import <Foundation/Foundation.h> #import <ReactiveCocoa/ReactiveCocoa.h> @interface EPSPlayerViewModel : NSObject @property (nonatomic) NSURL *audioURL; @property (readonly) NSTimeInterval duration; @property (readonly) NSTimeInterval currentTime; @property (readonly) NSString *elapsedTimeString; @property (readonly) NSString *remainingTimeString; @property (readonly, getter = isPlaying) BOOL playing; // Commands @property (readonly) RACCommand *playCommand; @property (readonly) RACCommand *pauseCommand; @property (readonly) RACCommand *togglePlayPauseCommand; @property (nonatomic, getter = isSeeking) BOOL seeking; - (void)seekToTime:(NSTimeInterval)time; @end
// // EPSPlayerViewModel.h // ReactiveAudioPlayer // // Created by Peter Stuart on 4/24/14. // Copyright (c) 2014 Electric Peel, LLC. All rights reserved. // #import <Foundation/Foundation.h> #import <ReactiveCocoa/ReactiveCocoa.h> #import <AVFoundation/AVFoundation.h> @interface EPSPlayerViewModel : NSObject @property (nonatomic) NSURL *audioURL; @property (readonly) AVPlayer *player; @property (readonly) NSTimeInterval duration; @property (readonly) NSTimeInterval currentTime; @property (readonly) NSString *elapsedTimeString; @property (readonly) NSString *remainingTimeString; @property (readonly, getter = isPlaying) BOOL playing; // Commands @property (readonly) RACCommand *playCommand; @property (readonly) RACCommand *pauseCommand; @property (readonly) RACCommand *togglePlayPauseCommand; @property (nonatomic, getter = isSeeking) BOOL seeking; - (void)seekToTime:(NSTimeInterval)time; @end
Switch back to ALSA on Linux;
#define MINIAUDIO_IMPLEMENTATION #define MA_ENABLE_ONLY_SPECIFIC_BACKENDS #define MA_ENABLE_WASAPI #define MA_ENABLE_PULSEAUDIO #define MA_ENABLE_COREAUDIO #define MA_ENABLE_AAUDIO #define MA_ENABLE_WEBAUDIO #define MA_NO_DECODING #define MA_NO_ENCODING #define MA_NO_GENERATION #include "miniaudio.h"
#define MINIAUDIO_IMPLEMENTATION #define MA_ENABLE_ONLY_SPECIFIC_BACKENDS #define MA_ENABLE_WASAPI #define MA_ENABLE_ALSA #define MA_ENABLE_COREAUDIO #define MA_ENABLE_AAUDIO #define MA_ENABLE_WEBAUDIO #define MA_NO_DECODING #define MA_NO_ENCODING #define MA_NO_GENERATION #include "miniaudio.h"
Add int dummy; to empty struct TestConformSimpleFixture definition.
/* Stuff you put in here is setup once in main() and gets passed around to * all test functions and fixture setup/teardown functions in the data * argument */ typedef struct _TestConformSharedState { int *argc_addr; char ***argv_addr; } TestConformSharedState; /* This fixture structure is allocated by glib, and before running each test * the test_conform_simple_fixture_setup func (see below) is called to * initialise it, and test_conform_simple_fixture_teardown is called when * the test is finished. */ typedef struct _TestConformSimpleFixture { /**/ } TestConformSimpleFixture; void test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture, gconstpointer data); void test_conform_simple_fixture_teardown (TestConformSimpleFixture *fixture, gconstpointer data);
/* Stuff you put in here is setup once in main() and gets passed around to * all test functions and fixture setup/teardown functions in the data * argument */ typedef struct _TestConformSharedState { int *argc_addr; char ***argv_addr; } TestConformSharedState; /* This fixture structure is allocated by glib, and before running each test * the test_conform_simple_fixture_setup func (see below) is called to * initialise it, and test_conform_simple_fixture_teardown is called when * the test is finished. */ typedef struct _TestConformSimpleFixture { /**/ int dummy; } TestConformSimpleFixture; void test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture, gconstpointer data); void test_conform_simple_fixture_teardown (TestConformSimpleFixture *fixture, gconstpointer data);
Include <chrono> needed for chrono::system_clock
#pragma once #include <array> #include <random> #include "jkqtplotter/jkqtplotter.h" #define NDATA 500 class SpeedTestPlot: public JKQtPlotter { Q_OBJECT protected: std::array<double, NDATA> X, Y, Y2; const double dx; double x0; std::chrono::system_clock::time_point t_lastplot; public: SpeedTestPlot(); virtual ~SpeedTestPlot(); public slots: void plotNewData(); };
#pragma once #include <array> #include <random> #include <chrono> #include "jkqtplotter/jkqtplotter.h" #define NDATA 500 class SpeedTestPlot: public JKQtPlotter { Q_OBJECT protected: std::array<double, NDATA> X, Y, Y2; const double dx; double x0; std::chrono::system_clock::time_point t_lastplot; public: SpeedTestPlot(); virtual ~SpeedTestPlot(); public slots: void plotNewData(); };
Build fix for certain configurations.
/* * This is included by init/main.c to check for architecture-dependent bugs. * * Needs: * void check_bugs(void); */ #ifndef _ASM_BUGS_H #define _ASM_BUGS_H #include <linux/config.h> #include <asm/cpu.h> #include <asm/cpu-info.h> extern void check_bugs32(void); extern void check_bugs64(void); static inline void check_bugs(void) { unsigned int cpu = smp_processor_id(); cpu_data[cpu].udelay_val = loops_per_jiffy; check_bugs32(); #ifdef CONFIG_64BIT check_bugs64(); #endif } #endif /* _ASM_BUGS_H */
/* * This is included by init/main.c to check for architecture-dependent bugs. * * Needs: * void check_bugs(void); */ #ifndef _ASM_BUGS_H #define _ASM_BUGS_H #include <linux/config.h> #include <linux/delay.h> #include <asm/cpu.h> #include <asm/cpu-info.h> extern void check_bugs32(void); extern void check_bugs64(void); static inline void check_bugs(void) { unsigned int cpu = smp_processor_id(); cpu_data[cpu].udelay_val = loops_per_jiffy; check_bugs32(); #ifdef CONFIG_64BIT check_bugs64(); #endif } #endif /* _ASM_BUGS_H */
Add skeleton for the splay tree implementation
#pragma once /* * Splay tree - a self-Adjusting binary search tree, * as first described by Daniel Dominic Sleator and Robert Endre Tarjan. * * https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf */ templace<class T> class SplayTree { private: struct Node { Node* left; Node* right; Node* parent; T data; void rotateLeft() {} void rotateRight() {} void splay() {} }; public: void insert(const T& data) {} void remove(const T& data) {} Node* find(const T& data) {} };
Fix mac bustage (more still).
// -*- c-basic-offset: 2 -*- /* * This file is part of the KDE libraries * Copyright (C) 2006 George Staikos <staikos@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef KJS_UNICODE_H #define KJS_UNICODE_H #include <wtf/Platform.h> #if USE(QT4_UNICODE) #include "qt4/UnicodeQt4.h" #elif USE(ICU_UNICODE) #include <wtf/icu/UnicodeIcu.h> #else #error "Unknown Unicode implementation" #endif #endif // vim: ts=2 sw=2 et
// -*- c-basic-offset: 2 -*- /* * This file is part of the KDE libraries * Copyright (C) 2006 George Staikos <staikos@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef KJS_UNICODE_H #define KJS_UNICODE_H #include <wtf/Platform.h> #if USE(QT4_UNICODE) #include "qt4/UnicodeQt4.h" #elif USE(ICU_UNICODE) #include <wtf/unicode/icu/UnicodeIcu.h> #else #error "Unknown Unicode implementation" #endif #endif // vim: ts=2 sw=2 et
Fix read_all and return content without segment fault
#include <cgreen/slurp.h> #include <stdlib.h> #include <stdio.h> static char *read_all(FILE *file, int gulp); char *slurp(const char *file_name, int gulp) { FILE *file = fopen(file_name, "r"); if (file == NULL) { return NULL; } char *content = read_all(file, gulp); fclose(file); return content; } static char *read_all(FILE *file, int gulp) { char *content = (char *)malloc((gulp + 1) * sizeof(char)); char *block = content; for ( ; ; ) { if (fgets(block, gulp + 1, file) == NULL) { break; } block += gulp; content = (char *)realloc(content, (block - content + 1) * sizeof(char)); } return content; }
#include <cgreen/slurp.h> #include <stdlib.h> #include <stdio.h> #include <strings.h> static char *read_all(FILE *file, int gulp); char *slurp(const char *file_name, int gulp) { FILE *file = fopen(file_name, "r"); if (file == NULL) { return NULL; } char *content = read_all(file, gulp); fclose(file); return content; } static char *read_all(FILE *file, int gulp) { char *content = (char *)malloc(0); int sblock = (gulp + 1) * sizeof(char); char *block = (char *)malloc(sblock); int len = 0; int add = 0; char *p; for ( ; ; ) { if (fgets(block, sblock, file) == NULL) { break; } len = strlen(block); add += len; p = (char *)realloc(content, add + 1); if (p == NULL) { exit(1); } content = p; strncat(content, block, len); } content[add + 1] = '\0'; free(block); return content; }
Copy the file path, just in case the string was mutable.
/** */ #import "SVGKSource.h" @interface SVGKSourceLocalFile : SVGKSource @property (nonatomic, retain) NSString* filePath; + (SVGKSource*)sourceFromFilename:(NSString*)p; @end
/** */ #import "SVGKSource.h" @interface SVGKSourceLocalFile : SVGKSource @property (nonatomic, copy) NSString* filePath; + (SVGKSource*)sourceFromFilename:(NSString*)p; @end