Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Revert back to method, since it's not strictly a getter.
// // PMDisplaySheet.h // This file is part of the "SWApplicationSupport" project, and is distributed under the MIT License. // // Created by Samuel Williams on 10/07/05. // Copyright 2005 Samuel Williams. All rights reserved. // #import <Cocoa/Cocoa.h> @class SWSheetController; @protocol SWSheetDelegate - (void) sheetController: (SWSheetController*)controller didEndWithResult:(NSInteger) result; @end @interface SWSheetController : NSWindowController @property(nonatomic,strong) IBOutlet NSWindow * parent; @property(nonatomic,unsafe_unretained) id delegate; // Override this to perform setup of the sheet before it is used: - (void)prepareSheet; // Override this to return the name of the nib that contains the sheet - (NSString *) nibName; - (IBAction) showSheet: (id)sender; - (IBAction) cancelSheet: (id) sender; - (IBAction) processSheet: (id) sender; - (void) sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(id)contextInfo; /* Convenience function */ @property (nonatomic, readonly, strong) NSManagedObjectContext *managedObjectContext; @end @interface NSObject (SWSheetControllerDelegate) - (void) sheetController: (SWSheetController*)controller didEndWithResult:(NSInteger) result; @end
// // PMDisplaySheet.h // This file is part of the "SWApplicationSupport" project, and is distributed under the MIT License. // // Created by Samuel Williams on 10/07/05. // Copyright 2005 Samuel Williams. All rights reserved. // #import <Cocoa/Cocoa.h> @class SWSheetController; @protocol SWSheetDelegate - (void) sheetController: (SWSheetController*)controller didEndWithResult:(NSInteger) result; @end @interface SWSheetController : NSWindowController @property(nonatomic,strong) IBOutlet NSWindow * parent; @property(nonatomic,unsafe_unretained) id delegate; // Override this to perform setup of the sheet before it is used: - (void)prepareSheet; // Override this to return the name of the nib that contains the sheet - (NSString *) nibName; - (IBAction) showSheet: (id)sender; - (IBAction) cancelSheet: (id) sender; - (IBAction) processSheet: (id) sender; - (void) sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(id)contextInfo; /* Convenience function */ - (NSManagedObjectContext *)managedObjectContext; @end @interface NSObject (SWSheetControllerDelegate) - (void) sheetController: (SWSheetController*)controller didEndWithResult:(NSInteger) result; @end
Revert constexpr so that upgrade detection works
#pragma once // const float in a header file can lead to duplication of the storage // but I don't really care in this case. Just don't do it with a header // that is included hundreds of times. constexpr float kCurrentVersion = 1.55f; // Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version // increment that won't trigger the new-version checks, handy for minor // releases that I don't want to bother users about. //#define VERSION_SUFFIX 'b'
#pragma once // const float in a header file can lead to duplication of the storage // but I don't really care in this case. Just don't do it with a header // that is included hundreds of times. // constexpr might help avoid that, but then it breaks my fragile upgrade-needed // detection code, so this should be left as const. const float kCurrentVersion = 1.55f; // Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version // increment that won't trigger the new-version checks, handy for minor // releases that I don't want to bother users about. //#define VERSION_SUFFIX 'b'
Add a descriptor for binary streams.
#ifndef TUVOK_BSTREAM_H #define TUVOK_BSTREAM_H #include <cstdlib> struct BStreamDescriptor { uint64_t elements; ///< number of elements in the stream size_t components; size_t width; ///< byte width bool is_signed; bool fp; ///< is it floating point? bool big_endian; size_t timesteps; }; #endif /* For more information, please see: http://software.sci.utah.edu The MIT License Copyright (c) 2012 Scientific Computing and Imaging Institute, Interactive Visualization and Data Analysis Group. 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. */
Handle MSVC's definition of __cplusplus
/* * Copyright 2018 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #if __cplusplus < 201103L #define THRUST_CPP03 #define THRUST_CPP_DIALECT 2003 #elif __cplusplus < 201402L #define THRUST_CPP11 #define THRUST_CPP_DIALECT 2011 #elif __cplusplus < 201703L #define THRUST_CPP14 #define THRUST_CPP_DIALECT 2014 #else #define THRUST_CPP17 #define THRUST_CPP_DIALECT 2017 #endif
/* * Copyright 2018 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #ifdef _MSC_VER #define THRUST_CPP_VER _MSVC_LANG #else #define THRUST_CPP_VER __cplusplus #endif #if THRUST_CPP_VER < 201103L #define THRUST_CPP03 #define THRUST_CPP_DIALECT 2003 #elif THRUST_CPP_VER < 201402L #define THRUST_CPP11 #define THRUST_CPP_DIALECT 2011 #elif THRUST_CPP_VER < 201703L #define THRUST_CPP14 #define THRUST_CPP_DIALECT 2014 #else #define THRUST_CPP17 #define THRUST_CPP_DIALECT 2017 #endif #undef THRUST_CPP_VER
Set ARC property semantics to "copy" for block.
#import <Foundation/Foundation.h> typedef void (^JCNotificationBannerTapHandlingBlock)(); @interface JCNotificationBanner : NSObject @property (nonatomic) NSString* title; @property (nonatomic) NSString* message; @property (nonatomic, strong) JCNotificationBannerTapHandlingBlock tapHandler; - (JCNotificationBanner*) initWithTitle:(NSString*)title message:(NSString*)message tapHandler:(JCNotificationBannerTapHandlingBlock)tapHandler; @end
#import <Foundation/Foundation.h> typedef void (^JCNotificationBannerTapHandlingBlock)(); @interface JCNotificationBanner : NSObject @property (nonatomic) NSString* title; @property (nonatomic) NSString* message; @property (nonatomic, copy) JCNotificationBannerTapHandlingBlock tapHandler; - (JCNotificationBanner*) initWithTitle:(NSString*)title message:(NSString*)message tapHandler:(JCNotificationBannerTapHandlingBlock)tapHandler; @end
Fix broken LBR fixup code
/* * User address space access functions. * * For licencing details see kernel-base/COPYING */ #include <linux/highmem.h> #include <linux/module.h> #include <asm/word-at-a-time.h> #include <linux/sched.h> /* * best effort, GUP based copy_from_user() that is NMI-safe */ unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n) { unsigned long offset, addr = (unsigned long)from; unsigned long size, len = 0; struct page *page; void *map; int ret; if (__range_not_ok(from, n, TASK_SIZE) == 0) return len; do { ret = __get_user_pages_fast(addr, 1, 0, &page); if (!ret) break; offset = addr & (PAGE_SIZE - 1); size = min(PAGE_SIZE - offset, n - len); map = kmap_atomic(page); memcpy(to, map+offset, size); kunmap_atomic(map); put_page(page); len += size; to += size; addr += size; } while (len < n); return len; } EXPORT_SYMBOL_GPL(copy_from_user_nmi);
/* * User address space access functions. * * For licencing details see kernel-base/COPYING */ #include <linux/highmem.h> #include <linux/module.h> #include <asm/word-at-a-time.h> #include <linux/sched.h> /* * best effort, GUP based copy_from_user() that is NMI-safe */ unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n) { unsigned long offset, addr = (unsigned long)from; unsigned long size, len = 0; struct page *page; void *map; int ret; if (__range_not_ok(from, n, TASK_SIZE)) return len; do { ret = __get_user_pages_fast(addr, 1, 0, &page); if (!ret) break; offset = addr & (PAGE_SIZE - 1); size = min(PAGE_SIZE - offset, n - len); map = kmap_atomic(page); memcpy(to, map+offset, size); kunmap_atomic(map); put_page(page); len += size; to += size; addr += size; } while (len < n); return len; } EXPORT_SYMBOL_GPL(copy_from_user_nmi);
Test that a global is marked constant when it can be.
// RUN: %llvmgcc -xc %s -S -o - | grep 'ctor_.* constant ' // The synthetic global made by the CFE for big initializer should be marked // constant. void bar(); void foo() { char Blah[] = "asdlfkajsdlfkajsd;lfkajds;lfkjasd;flkajsd;lkfja;sdlkfjasd"; bar(Blah); }
Change allocation header member padding type from char to unsigned short
#ifndef STACKALLOCATOR_H #define STACKALLOCATOR_H #include "Allocator.h" class StackAllocator : public Allocator { protected: void* m_start_ptr; std::size_t m_offset; public: StackAllocator(const std::size_t totalSize); virtual ~StackAllocator(); virtual void* Allocate(const std::size_t size, const short alignment = 0); virtual void Free(const std::size_t size); virtual void Init() override; private: StackAllocator(StackAllocator &stackAllocator); struct AllocationHeader { char padding; }; }; #endif /* STACKALLOCATOR_H */
#ifndef STACKALLOCATOR_H #define STACKALLOCATOR_H #include "Allocator.h" class StackAllocator : public Allocator { protected: void* m_start_ptr; std::size_t m_offset; public: StackAllocator(const std::size_t totalSize); virtual ~StackAllocator(); virtual void* Allocate(const std::size_t size, const short alignment = 0); virtual void Free(void* ptr); virtual void Init() override; private: StackAllocator(StackAllocator &stackAllocator); struct AllocationHeader { unsigned short padding; }; }; #endif /* STACKALLOCATOR_H */
Update readstat_lseek header signature on Windows
int readstat_open(const char *filename); int readstat_close(int fd); #ifdef _AIX off64_t readstat_lseek(int fildes, off64_t offset, int whence); #else off_t readstat_lseek(int fildes, off_t offset, int whence); #endif readstat_error_t readstat_update_progress(int fd, size_t file_size, readstat_progress_handler progress_handler, void *user_ctx);
int readstat_open(const char *filename); int readstat_close(int fd); #if defined _WIN32 || defined __CYGWIN__ _off64_t readstat_lseek(int fildes, _off64_t offset, int whence); #elif defined _AIX off64_t readstat_lseek(int fildes, off64_t offset, int whence); #else off_t readstat_lseek(int fildes, off_t offset, int whence); #endif readstat_error_t readstat_update_progress(int fd, size_t file_size, readstat_progress_handler progress_handler, void *user_ctx);
Create data directory on startup
#include <stdlib.h> #include <pwd.h> #include <string.h> #include <gtk/gtk.h> #include "gh-main-window.h" char * data_dir_path () { uid_t uid = getuid (); struct passwd *pw = getpwuid (uid); char *home_dir = pw->pw_dir; char *data_dir = "/.ghighlighter-c"; int length = strlen (home_dir); length = length + strlen (data_dir); char *result = malloc (length + sizeof (char)); strcat (result, home_dir); strcat (result, data_dir); return result; } int main (int argc, char *argv[]) { char *data_dir = data_dir_path (); free (data_dir); GtkWidget *window; gtk_init (&argc, &argv); window = gh_main_window_create (); gtk_widget_show_all (window); gtk_main (); return 0; }
#include <stdlib.h> #include <pwd.h> #include <string.h> #include <sys/stat.h> #include <gtk/gtk.h> #include "gh-main-window.h" char * data_dir_path () { uid_t uid = getuid (); struct passwd *pw = getpwuid (uid); char *home_dir = pw->pw_dir; char *data_dir = "/.ghighlighter-c"; int length = strlen (home_dir); length = length + strlen (data_dir); char *result = malloc (length + sizeof (char)); strcat (result, home_dir); strcat (result, data_dir); return result; } void setup_environment (char *data_dir) { mkdir (data_dir, 0755); } int main (int argc, char *argv[]) { char *data_dir = data_dir_path (); setup_environment (data_dir); free (data_dir); GtkWidget *window; gtk_init (&argc, &argv); window = gh_main_window_create (); gtk_widget_show_all (window); gtk_main (); return 0; }
Add a protocol for exposing RestKit object mapping and request information with the model implementations.
// // BCObjectModeling.h // ClearCostMobile // // Created by Seth Kingsley on 2/6/13. // Copyright (c) 2013 Monkey Republic Design, LLC. All rights reserved. // #import <Foundation/Foundation.h> @class RKObjectMapping, RKObjectManager; @protocol BCObjectModeling <NSObject> + (RKObjectMapping *)objectMapping; + (void)registerWithObjectManager:(RKObjectManager *)objectManager; @end
Add a note about clearing complex_hilbert's imaginary input
#ifndef ALCOMPLEX_H #define ALCOMPLEX_H #include <complex> #include "alspan.h" /** * Iterative implementation of 2-radix FFT (In-place algorithm). Sign = -1 is * FFT and 1 is iFFT (inverse). Fills the buffer with the Discrete Fourier * Transform (DFT) of the time domain data stored in the buffer. The buffer is * an array of complex numbers, and MUST BE power of two. */ void complex_fft(const al::span<std::complex<double>> buffer, const double sign); /** * Calculate the complex helical sequence (discrete-time analytical signal) of * the given input using the discrete Hilbert transform (In-place algorithm). * Fills the buffer with the discrete-time analytical signal stored in the * buffer. The buffer is an array of complex numbers and MUST BE power of two. */ void complex_hilbert(const al::span<std::complex<double>> buffer); #endif /* ALCOMPLEX_H */
#ifndef ALCOMPLEX_H #define ALCOMPLEX_H #include <complex> #include "alspan.h" /** * Iterative implementation of 2-radix FFT (In-place algorithm). Sign = -1 is * FFT and 1 is iFFT (inverse). Fills the buffer with the Discrete Fourier * Transform (DFT) of the time domain data stored in the buffer. The buffer is * an array of complex numbers, and MUST BE power of two. */ void complex_fft(const al::span<std::complex<double>> buffer, const double sign); /** * Calculate the complex helical sequence (discrete-time analytical signal) of * the given input using the discrete Hilbert transform (In-place algorithm). * Fills the buffer with the discrete-time analytical signal stored in the * buffer. The buffer is an array of complex numbers and MUST BE power of two, * and the imaginary components should be cleared to 0. */ void complex_hilbert(const al::span<std::complex<double>> buffer); #endif /* ALCOMPLEX_H */
Remove superfluous call to OPENSSL_cpuid_setup
/* * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include "internal/cryptlib.h" #include "eng_int.h" void ENGINE_load_builtin_engines(void) { /* Some ENGINEs need this */ OPENSSL_cpuid_setup(); OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); } #if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)) \ && !OPENSSL_API_1_1_0 void ENGINE_setup_bsd_cryptodev(void) { } #endif
/* * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include "internal/cryptlib.h" #include "eng_int.h" void ENGINE_load_builtin_engines(void) { OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); } #if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)) \ && !OPENSSL_API_1_1_0 void ENGINE_setup_bsd_cryptodev(void) { } #endif
Add preprocessor check to determine enabled roles are valid
#ifndef MBED_BLE_ROLES_H__ #define MBED_BLE_ROLES_H__ #ifdef BLE_ROLE_PERIPHERAL #ifndef BLE_ROLE_OBSERVER #error "BLE role 'PERIPHERAL' depends on role 'OBSERVER'" #endif // BLE_ROLE_OBSERVER #endif // BLE_ROLE_PERIPHERAL #ifdef BLE_ROLE_CENTRAL #ifndef BLE_ROLE_BROADCASTER #error "BLE role 'CENTRAL' depends on role 'BROADCASTER'" #endif // BLE_ROLE_BROADCASTER #endif // BLE_ROLE_CENTRAL #ifdef BLE_ROLE_SECURITY #ifndef BLE_ROLE_PERIPHERAL #error "BLE role 'SECURITY' depends on role 'PERIPHERAL'" #endif // BLE_ROLE_PERIPHERAL #endif // BLE_ROLE_SECURITY #ifdef BLE_ROLE_PRIVACY #ifndef BLE_ROLE_SECURITY #error "BLE role 'PRIVACY' depends on role 'SECURITY'" #endif // BLE_ROLE_SECURITY #endif // BLE_ROLE_PRIVACY #ifdef BLE_ROLE_GATT_CLIENT #ifndef BLE_ROLE_PERIPHERAL #error "BLE role 'GATT CLIENT' depends on role 'PERIPHERAL'" #endif // BLE_ROLE_PERIPHERAL #ifndef BLE_ROLE_BROADCASTER #error "BLE role 'GATT CLIENT' depends on role 'BROADCASTER'" #endif // BLE_ROLE_BROADCASTER #endif // BLE_ROLE_GATT_CLIENT #ifdef BLE_ROLE_GATT_SERVER #ifndef BLE_ROLE_SECURITY #error "BLE role 'GATT SERVER' depends on role 'SECURITY'" #endif // BLE_ROLE_SECURITY #endif // BLE_ROLE_GATT_SERVER #endif // MBED_BLE_ROLES_H__
Use aligned(LINE_SIZE_BYTES) attribute instead of manually adjusted padding
#ifndef __THREAD_INFO_H #define __THREAD_INFO_H #include "globals.h" #include "sift_writer.h" #include "bbv_count.h" #include "pin.H" #include <deque> typedef struct { Sift::Writer *output; std::deque<ADDRINT> *dyn_address_queue; Bbv *bbv; UINT64 thread_num; ADDRINT bbv_base; UINT64 bbv_count; ADDRINT bbv_last; BOOL bbv_end; UINT64 blocknum; UINT64 icount; UINT64 icount_detailed; UINT64 icount_reported; ADDRINT last_syscall_number; ADDRINT last_syscall_returnval; UINT64 flowcontrol_target; ADDRINT tid_ptr; ADDRINT last_routine; ADDRINT last_call_site; BOOL last_syscall_emulated; BOOL running; #if defined(TARGET_IA32) uint8_t __pad[29]; #elif defined(TARGET_INTEL64) uint8_t __pad[53]; #endif } __attribute__((packed)) thread_data_t; extern thread_data_t *thread_data; void initThreads(); #endif // __THREAD_INFO_H
#ifndef __THREAD_INFO_H #define __THREAD_INFO_H #include "globals.h" #include "sift_writer.h" #include "bbv_count.h" #include "pin.H" #include <deque> typedef struct { Sift::Writer *output; std::deque<ADDRINT> *dyn_address_queue; Bbv *bbv; UINT64 thread_num; ADDRINT bbv_base; UINT64 bbv_count; ADDRINT bbv_last; BOOL bbv_end; UINT64 blocknum; UINT64 icount; UINT64 icount_detailed; UINT64 icount_reported; ADDRINT last_syscall_number; ADDRINT last_syscall_returnval; UINT64 flowcontrol_target; ADDRINT tid_ptr; ADDRINT last_routine; ADDRINT last_call_site; BOOL last_syscall_emulated; BOOL running; } __attribute__((packed,aligned(LINE_SIZE_BYTES))) thread_data_t; extern thread_data_t *thread_data; void initThreads(); #endif // __THREAD_INFO_H
Include header file changes missed from last checkin
/** * Appcelerator Titanium Mobile * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the Apache Public License * Please see the LICENSE included with this distribution for details. */ #ifdef USE_TI_UISCROLLABLEVIEW #import "TiUIView.h" @interface TiUIScrollableView : TiUIView<UIScrollViewDelegate> { @private UIScrollView *scrollview; UIPageControl *pageControl; int currentPage; // Duplicate some info, just in case we're not showing the page control BOOL showPageControl; CGFloat pageControlHeight; BOOL handlingPageControlEvent; CGFloat maxScale; CGFloat minScale; // Have to correct for an apple goof; rotation stops scrolling, AND doesn't move to the next page. BOOL rotatedWhileScrolling; // See the code for why we need this... int lastPage; int cacheSize; } -(void)manageRotation; -(UIScrollView*)scrollview; @end #endif
/** * Appcelerator Titanium Mobile * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the Apache Public License * Please see the LICENSE included with this distribution for details. */ #ifdef USE_TI_UISCROLLABLEVIEW #import "TiUIView.h" @interface TiUIScrollableView : TiUIView<UIScrollViewDelegate> { @private UIScrollView *scrollview; UIPageControl *pageControl; int currentPage; // Duplicate some info, just in case we're not showing the page control BOOL showPageControl; CGFloat pageControlHeight; BOOL handlingPageControlEvent; // Have to correct for an apple goof; rotation stops scrolling, AND doesn't move to the next page. BOOL rotatedWhileScrolling; // See the code for why we need this... int lastPage; int cacheSize; } -(void)manageRotation; -(UIScrollView*)scrollview; @end #endif
Add Chapter 27, exercise 13
/* Chapter 27, exercise 13: define an input operation that reads an arbitrarily long sequence of whitespace-terminated characters into a zero-terminated array of chars */ #include<stdlib.h> #include<string.h> #include<stdio.h> #include<ctype.h> char* get_word() { int max = 8; char* word = (char*)malloc(max); int count = 0; int x; while ((x=getchar())!=EOF && isgraph(x)) { if (count == max-1) { /* double capacity */ max += max; word = (char*)realloc(word,max); if (word==0) exit(EXIT_FAILURE); } word[count++] = x; } word[count] = 0; return word; } int main() { while (1) { char* word = get_word(); if (!strcmp(word,"quit")) break; printf("%s\n",word); } }
Use the correct format specifier for size_t in fz_strdup.
#include "fitz_base.h" void * fz_malloc(int n) { void *p = malloc(n); if (!p) fz_throw("cannot malloc %d bytes", n); return p; } void * fz_realloc(void *p, int n) { void *np = realloc(p, n); if (np == nil) fz_throw("cannot realloc %d bytes", n); return np; } void fz_free(void *p) { free(p); } char * fz_strdup(char *s) { char *ns = strdup(s); if (!ns) fz_throw("cannot strdup %d bytes", strlen(s) + 1); return ns; }
#include "fitz_base.h" void * fz_malloc(int n) { void *p = malloc(n); if (!p) fz_throw("cannot malloc %d bytes", n); return p; } void * fz_realloc(void *p, int n) { void *np = realloc(p, n); if (np == nil) fz_throw("cannot realloc %d bytes", n); return np; } void fz_free(void *p) { free(p); } char * fz_strdup(char *s) { char *ns = strdup(s); if (!ns) fz_throw("cannot strdup %lu bytes", (unsigned long)strlen(s) + 1); return ns; }
Remove usage of a deprecated TestServer constructor.
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ #define WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ #include "net/base/load_flags.h" #include "net/test/test_server.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/appcache/appcache_interfaces.h" class UnittestTestServer : public net::TestServer { public: UnittestTestServer() : net::TestServer(net::TestServer::TYPE_HTTP, FilePath(FILE_PATH_LITERAL("webkit/data"))) { } }; #endif // WEBKIT_GLUE_UNITTEST_TEST_SERVER_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 WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ #define WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ #include "net/base/load_flags.h" #include "net/test/test_server.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/appcache/appcache_interfaces.h" class UnittestTestServer : public net::TestServer { public: UnittestTestServer() : net::TestServer(net::TestServer::TYPE_HTTP, net::TestServer::kLocalhost, FilePath(FILE_PATH_LITERAL("webkit/data"))) { } }; #endif // WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__
Structure to hold average energies for each cell. Should be sendt to OCDB via the shuttle.
#ifndef ALIHLTPHOSNODULECELLAVERAGEENERGYDATASTRUCT_H #define ALIHLTPHOSNODULECELLAVERAGEENERGYDATASTRUCT_H /*************************************************************************** * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. * * * * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ #include "AliHLTPHOSCommonDefs.h" //#include "AliHLTPHOSValidCellDataStruct.h" struct AliHLTPHOSModuleCellAverageEnergyDataStruct { AliHLTUInt8_t fModuleID; // AliHLTUInt16_t fCnt; // AliHLTUInt16_t fValidData[N_ROWS_MOD*N_COLUMNS_MOD*N_GAINS]; AliHLTPHOSValidCellDataStruct fValidData[N_MODULES*N_ROWS_MOD*N_COLUMNS_MOD*N_GAINS]; Double_t fAverageEnergies[N_ROWS_MOD][N_COLUMNS_MOD][N_GAINS]; }; #endif
Add 'extern' declaration to strict equality test block
// Copyright 2014-present 650 Industries. // Copyright 2014-present Andrew Toulouse. #import <Foundation/Foundation.h> @class BKDelta; typedef BOOL (^delta_calculator_equality_test_t)(id a, id b); const delta_calculator_equality_test_t BKDeltaCalculatorStrictEqualityTest; @interface BKDeltaCalculator : NSObject + (instancetype)defaultCalculator; + (instancetype)deltaCalculatorWithEqualityTest:(delta_calculator_equality_test_t)equalityTest; - (instancetype)initWithEqualityTest:(delta_calculator_equality_test_t)equalityTest; /** Resolve differences between two versions of an array. @param oldArray the array representing the "old" version of the array @param newArray the array representing the "new" version of the array. @return A delta object containing NSIndexSets representing added, moved, removed, and unchanged elements. */ - (BKDelta *)deltaFromOldArray:(NSArray *)oldArray toNewArray:(NSArray *)newArray; @end
// Copyright 2014-present 650 Industries. // Copyright 2014-present Andrew Toulouse. #import <Foundation/Foundation.h> @class BKDelta; typedef BOOL (^delta_calculator_equality_test_t)(id a, id b); extern const delta_calculator_equality_test_t BKDeltaCalculatorStrictEqualityTest; @interface BKDeltaCalculator : NSObject + (instancetype)defaultCalculator; + (instancetype)deltaCalculatorWithEqualityTest:(delta_calculator_equality_test_t)equalityTest; - (instancetype)initWithEqualityTest:(delta_calculator_equality_test_t)equalityTest; /** Resolve differences between two versions of an array. @param oldArray the array representing the "old" version of the array @param newArray the array representing the "new" version of the array. @return A delta object containing NSIndexSets representing added, moved, removed, and unchanged elements. */ - (BKDelta *)deltaFromOldArray:(NSArray *)oldArray toNewArray:(NSArray *)newArray; @end
Add documentation link to article on runloop
// OCHamcrest by Jon Reid, http://qualitycoding.org/about/ // Copyright 2016 hamcrest.org. See LICENSE.txt #import <Foundation/Foundation.h> /*! * @abstract Runs runloop until fulfilled, or timeout is reached. */ @interface HCRunloopRunner : NSObject - (instancetype)initWithFulfillmentBlock:(BOOL (^)())fulfillmentBlock; - (void)runUntilFulfilledOrTimeout:(CFTimeInterval)timeout; @end
// OCHamcrest by Jon Reid, http://qualitycoding.org/about/ // Copyright 2016 hamcrest.org. See LICENSE.txt #import <Foundation/Foundation.h> /*! * @abstract Runs runloop until fulfilled, or timeout is reached. * @discussion Based on http://bou.io/CTTRunLoopRunUntil.html */ @interface HCRunloopRunner : NSObject - (instancetype)initWithFulfillmentBlock:(BOOL (^)())fulfillmentBlock; - (void)runUntilFulfilledOrTimeout:(CFTimeInterval)timeout; @end
Add some sample code for efi_get_next_variable_name()
/* * libefivar - library for the manipulation of EFI variables * Copyright 2012 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License. * * 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, see <http://www.gnu.org/licenses/>. */ #include "efivar.h" int main(void) { return 0; }
/* * libefivar - library for the manipulation of EFI variables * Copyright 2012 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License. * * 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, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include "efivar.h" int main(void) { efi_guid_t *guid; char *name; int rc; while ((rc = efi_get_next_variable_name(&guid, &name)) > 0) { printf("name: \"%s\"\n", name); } return 0; }
Fix for Solaris type conversion.
/* * ClusteredPoller * * Created by Jakob Borg. * Copyright 2011 Nym Networks. See LICENSE for terms. */ #include "cltime.h" #include <stddef.h> #include <sys/time.h> curms_t curms(void) { struct timeval now; gettimeofday(&now, NULL); return now.tv_sec * 1000 + now.tv_usec / 1000; }
/* * ClusteredPoller * * Created by Jakob Borg. * Copyright 2011 Nym Networks. See LICENSE for terms. */ #include "cltime.h" #include <stddef.h> #include <sys/time.h> curms_t curms(void) { struct timeval now; gettimeofday(&now, NULL); return (curms_t) now.tv_sec * 1000 + (curms_t) now.tv_usec / 1000; }
Add @private indicator to instance variable.
// // FileSystem.h // arc // // Created by Jerome Cheng on 19/3/13. // Copyright (c) 2013 nus.cs3217. All rights reserved. // #import <Foundation/Foundation.h> #import "Folder.h" @interface FileSystem : NSObject { Folder *_rootFolder; // The root folder. } // Returns the root folder of the entire file system. - (Folder*)getRootFolder; // Returns the single FileSystem instance. + (FileSystem*)getInstance; @end
// // FileSystem.h // arc // // Created by Jerome Cheng on 19/3/13. // Copyright (c) 2013 nus.cs3217. All rights reserved. // #import <Foundation/Foundation.h> #import "Folder.h" @interface FileSystem : NSObject { @private Folder *_rootFolder; // The root folder. } // Returns the root folder of the entire file system. - (Folder*)getRootFolder; // Returns the single FileSystem instance. + (FileSystem*)getInstance; @end
Use stdint.h for unsigned integer typedefs
#ifndef _ARDUINO_COMPAT_H #define _ARDUINO_COMPAT_H #include <stdio.h> #include <stdlib.h> //#include <sys/types.h> //#include <sys/stat.h> #include <fcntl.h> #include <ctype.h> #include <string.h> #include <iostream> using namespace std; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; typedef bool boolean; typedef iostream Stream; #endif
#ifndef _ARDUINO_COMPAT_H #define _ARDUINO_COMPAT_H #include <stdio.h> #include <stdlib.h> #include <stdint.h> //#include <sys/types.h> //#include <sys/stat.h> #include <fcntl.h> #include <ctype.h> #include <string.h> #include <iostream> using namespace std; typedef bool boolean; typedef iostream Stream; #endif
Add original source from 2014. Split from 9tcfg.
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> void usage(char *progname) { printf("usage: %s filename [address]\n", progname); } void prepare_filebuf(char **fb, long size) { *fb = (char*) malloc(size); } int main(int argc, char *argv[]) { int fd; struct stat statbuf; char *filebuf; if (argc <= 1) { usage(argv[0]); exit(1); } if ((fd = open(argv[1], O_RDONLY)) == -1) { perror("Error openinig file"); exit(2); } fstat(fd, &statbuf); if (argc == 3) filebuf = (char*) strtol(argv[2], NULL, 16); else prepare_filebuf(&filebuf, statbuf.st_size); printf("file is %ld bytes long, will load at %p\n", (long) statbuf.st_size, filebuf); if (read(fd, filebuf, statbuf.st_size) == -1) { perror("Error reading file"); exit(3); } }
Add daemon to touch down all touched objects in the background
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2012 Raymond Jennings * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero 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, see <http://www.gnu.org/licenses/>. */ #include <kotaka/paths.h> #include <bigstruct/paths.h> #include <status.h> inherit SECOND_AUTO; object queue; static void create() { queue = new_object(BIGSTRUCT_DEQUE_LWO); } void queue_touch(object obj) { if (queue->empty()) { call_out("touch", 0); } queue->push_back(obj); } static void touch() { object obj; obj = queue->get_front(); queue->pop_front(); if (obj) { obj->_F_dummy(); } if (!queue->empty()) { call_out("touch", 0); } }
Add example of C++ 'static const' issue
/* * C++ 'static const' works differently from C 'static const'. * This example compiles with gcc but not with g++. G++ will * issue errors. */ /* $ g++ -o /tmp/foo cxx_static_const.c -lm cxx_static_const.c:2:26: error: uninitialized const ‘N1’ [-fpermissive] static const struct node N1; ^ cxx_static_const.c:1:21: note: ‘const struct node’ has no user-provided default constructor struct node; struct node { const struct node *other; }; ^ cxx_static_const.c:1:47: note: and the implicitly-defined constructor does not initialize ‘const node* node::other’ struct node; struct node { const struct node *other; }; ^ cxx_static_const.c:3:26: error: uninitialized const ‘N2’ [-fpermissive] static const struct node N2; ^ cxx_static_const.c:1:21: note: ‘const struct node’ has no user-provided default constructor struct node; struct node { const struct node *other; }; ^ cxx_static_const.c:1:47: note: and the implicitly-defined constructor does not initialize ‘const node* node::other’ struct node; struct node { const struct node *other; }; ^ cxx_static_const.c:4:26: error: redefinition of ‘const node N1’ static const struct node N1 = { &N2 }; ^ cxx_static_const.c:2:26: error: ‘const node N1’ previously declared here static const struct node N1; ^ cxx_static_const.c:5:26: error: redefinition of ‘const node N2’ static const struct node N2 = { &N1 }; ^ cxx_static_const.c:3:26: error: ‘const node N2’ previously declared here static const struct node N2; */ struct node; struct node { const struct node *other; }; static const struct node N1; static const struct node N2; static const struct node N1 = { &N2 }; static const struct node N2 = { &N1 }; int main(int argc, char *argv[]) { (void) argc; (void) argv; return 0; }
Make it more ovious we are not incrementing and decrementing chars
#include <stdio.h> main() { char ch0 = 'a'; char ch1 = 'b'; char ch2 = 'c'; char *p = &ch1; printf("%d, %c, %c\n", p, *p, ch1); ++p; printf("%d, %c, %c\n", p, *p, ch1); printf("%d, %d, %d\n", &ch0, &ch1, &ch2); // Prevent the compiler from optimizing away the char constants }
#include <stdio.h> main() { char ch0 = 'e'; char ch1 = 'v'; char ch2 = 'i'; char *p = &ch1; printf("%d, %c, %c\n", p, *p, ch1); ++p; printf("%d, %c, %c\n", p, *p, ch1); printf("%d, %d, %d\n", &ch0, &ch1, &ch2); // Prevent the compiler from optimizing away the char constants }
Test case for noinline attribute.
// RUN: %llvmgxx -c -emit-llvm %s -o - | llvm-dis | grep llvm.noinline int bar(int x, int y); __attribute__((noinline)) int bar(int x, int y) { return x + y; } int foo(int a, int b) { return bar(b, a); }
Add the AutoFillDialog header, needed by the cross-platform implementations to implement the autofill dialog.
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_H_ #define CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_H_ #include <vector> #include "chrome/browser/autofill/autofill_profile.h" // Shows the AutoFill dialog, which allows the user to edit profile information. // |profiles| is a vector of autofill profiles that contains the current profile // information. The dialog fills out the profile fields using this data. Any // changes made to the profile information through the dialog should be // transferred back into |profiles|. void ShowAutoFillDialog(const std::vector<AutoFillProfile>& profiles); #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_H_
Add AIX specific include files.
#ifndef _CONDOR_GETMNT_H #define _CONDOR_GETMNT_H #if defined(ULTRIX42) || defined(ULTRIX43) #include <sys/mount.h> #endif #if !defined(OSF1) #include <mntent.h> #endif #if !defined(NMOUNT) #define NMOUNT 256 #endif #if !defined(ULTRIX42) && !defined(ULTRIX43) struct fs_data_req { dev_t dev; char *devname; char *path; }; struct fs_data { struct fs_data_req fd_req; }; #define NOSTAT_MANY 0 #endif #if NMOUNT < 256 #undef NMOUNT #define NMOUNT 256 #endif #endif /* _CONDOR_GETMNT_H */
#ifndef _CONDOR_GETMNT_H #define _CONDOR_GETMNT_H #if defined(ULTRIX42) || defined(ULTRIX43) #include <sys/mount.h> #endif #if !defined(OSF1) && !defined(AIX32) #include <mntent.h> #endif #if defined(AIX32) # include <sys/mntctl.h> # include <sys/vmount.h> # include <sys/sysmacros.h> #endif #if !defined(NMOUNT) #define NMOUNT 256 #endif #if !defined(ULTRIX42) && !defined(ULTRIX43) struct fs_data_req { dev_t dev; char *devname; char *path; }; struct fs_data { struct fs_data_req fd_req; }; #define NOSTAT_MANY 0 #endif #if NMOUNT < 256 #undef NMOUNT #define NMOUNT 256 #endif #endif /* _CONDOR_GETMNT_H */
Use the VTK wrapping of the string class header file.
// -*- c++ -*- /*========================================================================= Program: Visualization Toolkit Module: Tokenizer.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /* * Copyright 2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the * U.S. Government. Redistribution and use in source and binary forms, with * or without modification, are permitted provided that this Notice and any * statement of authorship are reproduced on all copies. */ #include <vtkConfigure.h> #include <string> class Tokenizer { public: Tokenizer(const char *s, const char *delim = " \t\n"); Tokenizer(const vtkstd::string &s, const char *delim = " \t\n"); vtkstd::string GetNextToken(); vtkstd::string GetRemainingString() const; bool HasMoreTokens() const; void Reset(); private: vtkstd::string FullString; vtkstd::string Delim; vtkstd::string::size_type Position; };
// -*- c++ -*- /*========================================================================= Program: Visualization Toolkit Module: Tokenizer.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /* * Copyright 2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the * U.S. Government. Redistribution and use in source and binary forms, with * or without modification, are permitted provided that this Notice and any * statement of authorship are reproduced on all copies. */ #include <vtkConfigure.h> #include <vtkstd/string> class Tokenizer { public: Tokenizer(const char *s, const char *delim = " \t\n"); Tokenizer(const vtkstd::string &s, const char *delim = " \t\n"); vtkstd::string GetNextToken(); vtkstd::string GetRemainingString() const; bool HasMoreTokens() const; void Reset(); private: vtkstd::string FullString; vtkstd::string Delim; vtkstd::string::size_type Position; };
Test that we're not forwarding on -g options to the non integrated assembler.
// Check that we don't try to forward -Xclang or -mlinker-version to GCC. // PR12920 -- Check also we may not forward W_Group options to GCC. // // RUN: %clang -target powerpc-unknown-unknown \ // RUN: %s \ // RUN: -Wall -Wdocumentation \ // RUN: -Xclang foo-bar \ // RUN: -march=x86_64 \ // RUN: -mlinker-version=10 -### 2> %t // RUN: FileCheck < %t %s // // clang-cc1 // CHECK: "-Wall" "-Wdocumentation" // CHECK: "-o" "{{[^"]+}}.o" // // gcc-ld // CHECK: gcc{{[^"]*}}" // CHECK-NOT: "-mlinker-version=10" // CHECK-NOT: "-Xclang" // CHECK-NOT: "foo-bar" // CHECK-NOT: "-Wall" // CHECK-NOT: "-Wdocumentation" // CHECK: -march // CHECK-NOT: "-mlinker-version=10" // CHECK-NOT: "-Xclang" // CHECK-NOT: "foo-bar" // CHECK-NOT: "-Wall" // CHECK-NOT: "-Wdocumentation" // CHECK: "-o" "a.out"
// Check that we don't try to forward -Xclang or -mlinker-version to GCC. // PR12920 -- Check also we may not forward W_Group options to GCC. // // RUN: %clang -target powerpc-unknown-unknown \ // RUN: %s \ // RUN: -Wall -Wdocumentation \ // RUN: -Xclang foo-bar \ // RUN: -march=x86_64 \ // RUN: -mlinker-version=10 -### 2> %t // RUN: FileCheck < %t %s // // clang-cc1 // CHECK: "-Wall" "-Wdocumentation" // CHECK: "-o" "{{[^"]+}}.o" // // gcc-ld // CHECK: gcc{{[^"]*}}" // CHECK-NOT: "-mlinker-version=10" // CHECK-NOT: "-Xclang" // CHECK-NOT: "foo-bar" // CHECK-NOT: "-Wall" // CHECK-NOT: "-Wdocumentation" // CHECK: -march // CHECK-NOT: "-mlinker-version=10" // CHECK-NOT: "-Xclang" // CHECK-NOT: "foo-bar" // CHECK-NOT: "-Wall" // CHECK-NOT: "-Wdocumentation" // CHECK: "-o" "a.out" // Check that we're not forwarding -g options to the assembler // RUN: %clang -g -target x86_64-unknown-linux-gnu -no-integrated-as -c %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-ASM %s // CHECK-ASM: as // CHECK-ASM-NOT: "-g"
Include the necessary headers to make the swift-runtime-reporting test work.
// library.h // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // // ----------------------------------------------------------------------------- // From swift's include/swift/Runtime/Debug.h file. struct RuntimeErrorDetails { uintptr_t version; const char *errorType; const char *currentStackDescription; uintptr_t framesToSkip; void *memoryAddress; struct Thread { const char *description; uint64_t threadID; uintptr_t numFrames; void **frames; }; uintptr_t numExtraThreads; Thread *threads; struct FixIt { const char *filename; uintptr_t startLine; uintptr_t startColumn; uintptr_t endLine; uintptr_t endColumn; const char *replacementText; }; struct Note { const char *description; uintptr_t numFixIts; FixIt *fixIts; }; uintptr_t numFixIts; FixIt *fixIts; uintptr_t numNotes; Note *notes; }; enum: uintptr_t { RuntimeErrorFlagNone = 0, RuntimeErrorFlagFatal = 1 << 0 }; extern "C" void _swift_runtime_on_report(uintptr_t flags, const char *message, RuntimeErrorDetails *details);
// library.h // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // // ----------------------------------------------------------------------------- #include <stdint.h> // From swift's include/swift/Runtime/Debug.h file. struct RuntimeErrorDetails { uintptr_t version; const char *errorType; const char *currentStackDescription; uintptr_t framesToSkip; void *memoryAddress; struct Thread { const char *description; uint64_t threadID; uintptr_t numFrames; void **frames; }; uintptr_t numExtraThreads; Thread *threads; struct FixIt { const char *filename; uintptr_t startLine; uintptr_t startColumn; uintptr_t endLine; uintptr_t endColumn; const char *replacementText; }; struct Note { const char *description; uintptr_t numFixIts; FixIt *fixIts; }; uintptr_t numFixIts; FixIt *fixIts; uintptr_t numNotes; Note *notes; }; enum: uintptr_t { RuntimeErrorFlagNone = 0, RuntimeErrorFlagFatal = 1 << 0 }; extern "C" void _swift_runtime_on_report(uintptr_t flags, const char *message, RuntimeErrorDetails *details);
Resolve compilation issue due to missing math.h inclusion
/* * Modified version of Keypoint.h * Source location: https://github.com/pippy360/transformationInvariantImageSearch/blob/master/fullEndToEndDemo/src/Keypoint.h */ #pragma once #ifndef REVERSE_IMAGE_SEARCH_KEYPOINT_H #define REVERSE_IMAGE_SEARCH_KEYPOINT_H #include <iostream> #include <sstream> using namespace std; class KeyPoint { public: double x_, y_; KeyPoint(double x, double y) { x_ = x; y_ = y; }; /** * Convert a KeyPoint to a string * @return string */ string ToString() { std::ostringstream string_stream_; string_stream_<< "KeyPoint[ " << x_ << ", " << y_ << "]"; return string_stream_.str(); } }; namespace hash { template <> struct hash<KeyPoint> { std::size_t operator()(const KeyPoint &k) const { using std::hash; return ((hash<double>()(k.x_) ^ (hash<double>()(k.y_) << 1)) >> 1); } }; } #endif
/* * Modified version of Keypoint.h * Source location: https://github.com/pippy360/transformationInvariantImageSearch/blob/master/fullEndToEndDemo/src/Keypoint.h */ #pragma once #ifndef REVERSE_IMAGE_SEARCH_KEYPOINT_H #define REVERSE_IMAGE_SEARCH_KEYPOINT_H #include <iostream> #include <sstream> #include <math.h> using namespace std; class KeyPoint { public: double x_, y_; KeyPoint(double x, double y) { x_ = x; y_ = y; }; /** * Convert a KeyPoint to a string * @return string */ string ToString() { std::ostringstream string_stream_; string_stream_<< "KeyPoint[ " << x_ << ", " << y_ << "]"; return string_stream_.str(); } }; namespace std { template <> struct hash<KeyPoint> { std::size_t operator()(const KeyPoint &k) const { using std::hash; return ((hash<double>()(k.x_) ^ (hash<double>()(k.y_) << 1)) >> 1); } }; } #endif
Add prototype to judge marked point
#ifndef _FAKE_LOCK_SCREEN_PATTERN_H_ #define _FAKE_LOCK_SCREEN_PATTERN_H_ #include <gtk/gtk.h> #if !GTK_CHECK_VERSION(3, 0, 0) typedef struct { gdouble red; gdouble green; gdouble blue; gdouble alpha; } GdkRGBA; #endif void flsp_draw_circle(cairo_t *context, gint x, gint y, gint radius, GdkRGBA circle, GdkRGBA border); #endif
#ifndef _FAKE_LOCK_SCREEN_PATTERN_H_ #define _FAKE_LOCK_SCREEN_PATTERN_H_ #include <gtk/gtk.h> #if !GTK_CHECK_VERSION(3, 0, 0) typedef struct { gdouble red; gdouble green; gdouble blue; gdouble alpha; } GdkRGBA; #endif void flsp_draw_circle(cairo_t *context, gint x, gint y, gint radius, GdkRGBA circle, GdkRGBA border); gboolean is_marked(gint x, gint y, gint *marked, void *user_data); #endif
Fix a memory leak in tests
/* * Copyright © 2009 CNRS * Copyright © 2009-2010 INRIA * Copyright © 2009-2010 Université Bordeaux 1 * See COPYING in top-level directory. */ #include <private/config.h> #include <hwloc.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> int main(void) { hwloc_topology_t topology; hwloc_bitmap_t cpuset; hwloc_obj_t obj; hwloc_topology_init(&topology); hwloc_topology_load(topology); hwloc_topology_check(topology); cpuset = hwloc_bitmap_alloc(); hwloc_bitmap_set(cpuset, 0); obj = hwloc_topology_insert_misc_object_by_cpuset(topology, cpuset, "test"); hwloc_topology_insert_misc_object_by_parent(topology, obj, "test2"); hwloc_topology_check(topology); hwloc_topology_destroy(topology); return 0; }
/* * Copyright © 2009 CNRS * Copyright © 2009-2010 INRIA * Copyright © 2009-2010 Université Bordeaux 1 * See COPYING in top-level directory. */ #include <private/config.h> #include <hwloc.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> int main(void) { hwloc_topology_t topology; hwloc_bitmap_t cpuset; hwloc_obj_t obj; hwloc_topology_init(&topology); hwloc_topology_load(topology); hwloc_topology_check(topology); cpuset = hwloc_bitmap_alloc(); hwloc_bitmap_set(cpuset, 0); obj = hwloc_topology_insert_misc_object_by_cpuset(topology, cpuset, "test"); hwloc_bitmap_free(cpuset); hwloc_topology_insert_misc_object_by_parent(topology, obj, "test2"); hwloc_topology_check(topology); hwloc_topology_destroy(topology); return 0; }
Add convenience functions for UART0
#ifndef _UART_H_ #define _UART_H_ #include "mk20dx256.h" void uart_setup(UART_MemMapPtr base, int baud); void uart_putchar(UART_MemMapPtr base, char ch); void uart_putline(UART_MemMapPtr base, char * str); #endif
#ifndef _UART_H_ #define _UART_H_ #include "mk20dx256.h" #include "pins.h" void uart_setup(UART_MemMapPtr base, int baud); void uart_putchar(UART_MemMapPtr base, char ch); void uart_putline(UART_MemMapPtr base, char * str); /* * Convenience function to setup UART0 on pins 0 and 1 with 115200 baud */ inline static void uart0_setup_default() { PIN0_PORT_PCR = PORT_PCR_MUX(3); PIN1_PORT_PCR = PORT_PCR_MUX(3); uart_setup(UART0_BASE_PTR, 115200); } inline static void uart0_putchar(char ch) { uart_putchar(UART0_BASE_PTR, ch); } inline static void uart0_putline(char * str) { uart_putline(UART0_BASE_PTR, str); } #endif
Make powerpc compile. Needs this header...
/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _SYS_MSG_H # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead." #endif #include <bits/types.h> /* Define options for message queue functions. */ #define MSG_NOERROR 010000 /* no error if message is too big */ #ifdef __USE_GNU # define MSG_EXCEPT 020000 /* recv any msg except of specified type */ #endif /* Types used in the structure definition. */ typedef unsigned long int msgqnum_t; typedef unsigned long int msglen_t; /* Structure of record for one message inside the kernel. The type `struct msg' is opaque. */ struct msqid_ds { struct ipc_perm msg_perm; /* structure describing operation permission */ unsigned int __unused1; __time_t msg_stime; /* time of last msgsnd command */ unsigned int __unused2; __time_t msg_rtime; /* time of last msgrcv command */ unsigned int __unused3; __time_t msg_ctime; /* time of last change */ unsigned long __msg_cbytes; /* current number of bytes on queue */ msgqnum_t msg_qnum; /* number of messages currently on queue */ msglen_t msg_qbytes; /* max number of bytes allowed on queue */ __pid_t msg_lspid; /* pid of last msgsnd() */ __pid_t msg_lrpid; /* pid of last msgrcv() */ unsigned long __unused4; unsigned long __unused5; }; #ifdef __USE_MISC # define msg_cbytes __msg_cbytes /* ipcs ctl commands */ # define MSG_STAT 11 # define MSG_INFO 12 /* buffer for msgctl calls IPC_INFO, MSG_INFO */ struct msginfo { int msgpool; int msgmap; int msgmax; int msgmnb; int msgmni; int msgssz; int msgtql; unsigned short int msgseg; }; #endif /* __USE_MISC */
Remove absolute path from r202733.
// RUN: rm -f %t // RUN: not %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.dia > /dev/null 2>&1 // RUN: c-index-test -read-diagnostics %t.dia 2>&1 | FileCheck %s // RUN: c-index-test -read-diagnostics %S/Inputs/serialized-diags-stable.dia 2>&1 | FileCheck %s int foo() { // CHECK: serialized-diags-stable.c:[[@LINE+2]]:1: warning: control reaches end of non-void function [-Wreturn-type] [Semantic Issue] // CHECK-NEXT: Number FIXITs = 0 } // CHECK: serialized-diags-stable.c:[[@LINE+5]]:13: error: redefinition of 'bar' as different kind of symbol [] [Semantic Issue] // CHECK-NEXT: Number FIXITs = 0 // CHECK-NEXT: +-/Volumes/Lore/llvm-public/clang/test/Misc/serialized-diags-stable.c:[[@LINE+2]]:6: note: previous definition is here [] [] // CHECK-NEXT: Number FIXITs = 0 void bar() {} typedef int bar; // CHECK-LABEL: Number of diagnostics: 2
// RUN: rm -f %t // RUN: not %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.dia > /dev/null 2>&1 // RUN: c-index-test -read-diagnostics %t.dia 2>&1 | FileCheck %s // RUN: c-index-test -read-diagnostics %S/Inputs/serialized-diags-stable.dia 2>&1 | FileCheck %s int foo() { // CHECK: serialized-diags-stable.c:[[@LINE+2]]:1: warning: control reaches end of non-void function [-Wreturn-type] [Semantic Issue] // CHECK-NEXT: Number FIXITs = 0 } // CHECK: serialized-diags-stable.c:[[@LINE+5]]:13: error: redefinition of 'bar' as different kind of symbol [] [Semantic Issue] // CHECK-NEXT: Number FIXITs = 0 // CHECK-NEXT: +-serialized-diags-stable.c:[[@LINE+2]]:6: note: previous definition is here [] [] // CHECK-NEXT: Number FIXITs = 0 void bar() {} typedef int bar; // CHECK-LABEL: Number of diagnostics: 2
Add assertion about result of multiplication to test
#include<stdio.h> #include<assert.h> int main() { int i,k,j; if (k == 5) { assert(k == 5); return 0; } assert(k != 5); // simple arithmetic i = k + 1; assert(i != 6); i = k - 1; assert(i != 4); i = k * 2; assert(i != 10); // UNKNOWN! k could be -2147483643; i = k / 2; assert(i != 2); // UNKNOWN! k could be 4 return 0; }
#include<stdio.h> #include<assert.h> int main() { int i,k,j; if (k == 5) { assert(k == 5); return 0; } assert(k != 5); // simple arithmetic i = k + 1; assert(i != 6); i = k - 1; assert(i != 4); i = k * 3; // multiplication with odd numbers is injective assert(i != 15); i = k * 2; // multiplication with even numbers is not-injective assert(i != 10); // UNKNOWN! k could be -2147483643; i = k / 2; assert(i != 2); // UNKNOWN! k could be 4 return 0; }
Raise limit on number of filter bands.
#include <objlib.h> #define MAXFILTS 30 class VOCODE2 : public Instrument { int skip, numfilts, branch; float amp, aamp, pctleft, noise_amp, hipass_mod_amp; float *in, *amparray, amptabs[2]; SubNoiseL *noise; Butter *modulator_filt[MAXFILTS], *carrier_filt[MAXFILTS], *hipassmod; Balance *balancer[MAXFILTS]; public: VOCODE2(); virtual ~VOCODE2(); int init(float *, int); int run(); };
#include <objlib.h> #define MAXFILTS 200 class VOCODE2 : public Instrument { int skip, numfilts, branch; float amp, aamp, pctleft, noise_amp, hipass_mod_amp; float *in, *amparray, amptabs[2]; SubNoiseL *noise; Butter *modulator_filt[MAXFILTS], *carrier_filt[MAXFILTS], *hipassmod; Balance *balancer[MAXFILTS]; public: VOCODE2(); virtual ~VOCODE2(); int init(float *, int); int run(); };
Add macro to set static members on lua classes
/*ckwg +5 * Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to * KITWARE_LICENSE.TXT for licensing information, or contact General Counsel, * Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065. */ #ifndef VISTK_LUA_PIPELINE_LUA_STATIC_MEMBER_H #define VISTK_LUA_PIPELINE_LUA_STATIC_MEMBER_H #include "lua_include.h" #include <cstring> /** * \file lua_static_member.h * * \brief Helpers setting static members on objects in Lua. */ #define LUA_STATIC_boolean(var) var #define LUA_STATIC_cfunction(var) &var #define LUA_STATIC_integer(var) var #define LUA_STATIC_literal(var) var #define LUA_STATIC_lstring(var) var, strlen(var) #define LUA_STATIC_number(var) var #define LUA_STATIC_string(var) var.c_str() #define LUA_STATIC_MEMBER(interp, type, var, name) \ do \ { \ lua_push##type(interp, LUA_STATIC_##type(var)); \ lua_setfield(L, -2, name); \ } while (false) #endif // VISTK_LUA_PIPELINE_LUA_STATIC_MEMBER_H
Handle lld not being found in PATH.
// RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s // AS_LINK: bin/clang{{.*}} "-cc1as" // AS_LINK: bin/lld{{.*}} "-flavor" "gnu" "-target" "amdgcn--amdhsa"
// RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s // AS_LINK: bin/clang{{.*}} "-cc1as" // AS_LINK: lld{{.*}} "-flavor" "gnu" "-target" "amdgcn--amdhsa"
Add regression test for r305179.
// test for r305179 // RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | grep '*** IR Dump After Function Integration/Inlining ***' void foo() {}
Add this FreeBSD standard header.
/* * Copyright (c) 2002 David O'Brien <obrien@FreeBSD.org>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _FLOATINGPOINT_H_ #define _FLOATINGPOINT_H_ #include <machine/ieeefp.h> #endif /* !_FLOATINGPOINT_H_ */
Test now passes. I'll hold off merging it with the BasicStore test until we know this is a stable change.
// RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s // XFAIL struct tea_cheese { unsigned magic; }; typedef struct tea_cheese kernel_tea_cheese_t; extern kernel_tea_cheese_t _wonky_gesticulate_cheese; // This test case exercises the ElementRegion::getRValueType() logic. void foo( void ) { kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese; struct load_wine *cmd = (void*) &wonky[1]; cmd = cmd; char *p = (void*) &wonky[1]; *p = 1; kernel_tea_cheese_t *q = &wonky[1]; kernel_tea_cheese_t r = *q; // expected-warning{{out-of-bound memory position}} }
// RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s struct tea_cheese { unsigned magic; }; typedef struct tea_cheese kernel_tea_cheese_t; extern kernel_tea_cheese_t _wonky_gesticulate_cheese; // This test case exercises the ElementRegion::getRValueType() logic. void foo( void ) { kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese; struct load_wine *cmd = (void*) &wonky[1]; cmd = cmd; char *p = (void*) &wonky[1]; *p = 1; kernel_tea_cheese_t *q = &wonky[1]; kernel_tea_cheese_t r = *q; // expected-warning{{out-of-bound memory position}} }
Disable SPI/Timer/RTC hal from microbit board.
#ifndef NRF51_HAL_CONF_H__ #define NRF51_HAL_CONF_H__ #define HAL_UART_MODULE_ENABLED #define HAL_SPI_MODULE_ENABLED #define HAL_TIME_MODULE_ENABLED #define HAL_RTC_MODULE_ENABLED #define HAL_TIMER_MODULE_ENABLED #endif // NRF51_HAL_CONF_H__
#ifndef NRF51_HAL_CONF_H__ #define NRF51_HAL_CONF_H__ #define HAL_UART_MODULE_ENABLED // #define HAL_SPI_MODULE_ENABLED #define HAL_TIME_MODULE_ENABLED // #define HAL_RTC_MODULE_ENABLED // #define HAL_TIMER_MODULE_ENABLED #endif // NRF51_HAL_CONF_H__
Fix constness to avoid a compiler warning.
/* + */ #include "dpl/acc.h" #include "dpl/defs.h" #include "dpl/utils.h" int dpl_acc_durance (DplIter *iter, time_t *dur) { DplEntry *task; *dur = 0; time_t begin, end; while (dpl_iter_next (iter, &task) == DPL_OK) { dpl_entry_begin_get (task, &begin); DPL_FORWARD_ERROR (dpl_entry_work_end_get (task, &end)); *dur += (end - begin); } return DPL_OK; }
/* + */ #include "dpl/acc.h" #include "dpl/defs.h" #include "dpl/utils.h" int dpl_acc_durance (DplIter *iter, time_t *dur) { const DplEntry *task; *dur = 0; time_t begin, end; while (dpl_iter_next (iter, &task) == DPL_OK) { dpl_entry_begin_get (task, &begin); DPL_FORWARD_ERROR (dpl_entry_work_end_get (task, &end)); *dur += (end - begin); } return DPL_OK; }
Add API for datatype conversion.
#ifndef _NPY_ARRAY_CONVERT_DATATYPE_H_ #define _NPY_ARRAY_CONVERT_DATATYPE_H_ NPY_NO_EXPORT PyObject * PyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran); #endif
#ifndef _NPY_ARRAY_CONVERT_DATATYPE_H_ #define _NPY_ARRAY_CONVERT_DATATYPE_H_ NPY_NO_EXPORT PyObject * PyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran); NPY_NO_EXPORT int PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp); NPY_NO_EXPORT PyArray_VectorUnaryFunc * PyArray_GetCastFunc(PyArray_Descr *descr, int type_num); NPY_NO_EXPORT int PyArray_CanCastSafely(int fromtype, int totype); NPY_NO_EXPORT Bool PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to); NPY_NO_EXPORT int PyArray_ObjectType(PyObject *op, int minimum_type); NPY_NO_EXPORT PyArrayObject ** PyArray_ConvertToCommonType(PyObject *op, int *retn); NPY_NO_EXPORT int PyArray_ValidType(int type); #endif
Define the board height and width.
#include <stdlib.h> /** * @author: Hendrik Werner */ typedef struct Position { int row; int col; } Position; int main() { return EXIT_SUCCESS; }
#include <stdlib.h> /** * @author: Hendrik Werner */ #define BOARD_HEIGHT 50 #define BOARD_WIDTH 50 typedef struct Position { int row; int col; } Position; int main() { return EXIT_SUCCESS; }
Fix a Hand type compiling errors in GNU compiler
#ifndef PHEVALUATOR_HAND_H #define PHEVALUATOR_HAND_H #ifdef __cplusplus #include <vector> #include <array> #include <string> #include "card.h" namespace phevaluator { class Hand { public: Hand() {} Hand(const std::vector<Card>& cards); Hand(const Card& card); Hand& operator+=(const Card& card); Hand operator+(const Card& card); const unsigned char& getSize() const { return size_; } const int& getSuitHash() const { return suitHash_; } const std::array<int, 4>& getSuitBinary() const { return suitBinary_; } const std::array<unsigned char, 13> getQuinary() const { return quinary_; } private: unsigned char size_ = 0; int suitHash_ = 0; std::array<int, 4> suitBinary_{0}; std::array<unsigned char, 13> quinary_{0}; }; } // namespace phevaluator #endif // __cplusplus #endif // PHEVALUATOR_HAND_H
#ifndef PHEVALUATOR_HAND_H #define PHEVALUATOR_HAND_H #ifdef __cplusplus #include <vector> #include <array> #include <string> #include "card.h" namespace phevaluator { class Hand { public: Hand() {} Hand(const std::vector<Card>& cards); Hand(const Card& card); Hand& operator+=(const Card& card); Hand operator+(const Card& card); const unsigned char& getSize() const { return size_; } const int& getSuitHash() const { return suitHash_; } const std::array<int, 4>& getSuitBinary() const { return suitBinary_; } const std::array<unsigned char, 13> getQuinary() const { return quinary_; } private: unsigned char size_ = 0; int suitHash_ = 0; std::array<int, 4> suitBinary_{{0}}; std::array<unsigned char, 13> quinary_{{0}}; }; } // namespace phevaluator #endif // __cplusplus #endif // PHEVALUATOR_HAND_H
Add comment to Attack() return values
#pragma once #include "Monster.h" class cAggressiveMonster : public cMonster { typedef cMonster super; public: cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void InStateChasing(std::chrono::milliseconds a_Dt) override; virtual void EventSeePlayer(cEntity *) override; virtual bool Attack(std::chrono::milliseconds a_Dt); } ;
#pragma once #include "Monster.h" class cAggressiveMonster : public cMonster { typedef cMonster super; public: cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void InStateChasing(std::chrono::milliseconds a_Dt) override; virtual void EventSeePlayer(cEntity *) override; /** Try to perform attack returns true if attack was deemed successful (hit player, fired projectile, creeper exploded, etc.) even if it didn't actually do damage return false if e.g. the mob is still in cooldown from a previous attack */ virtual bool Attack(std::chrono::milliseconds a_Dt); } ;
Update driver version to 5.02.00-k13
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2010 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k12"
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2010 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.02.00-k13"
REMOVE syns state from Door
#ifndef SSPAPPLICATION_ENTITIES_DOORENTITY_H #define SSPAPPLICATION_ENTITIES_DOORENTITY_H #include "Entity.h" #include <vector> struct DoorSyncState { int entityID; bool isOpened; }; struct ElementState { int entityID; EVENT desiredState; bool desiredStateReached; }; class DoorEntity : public Entity { private: std::vector<ElementState> m_subjectStates; bool m_isOpened; float m_minRotation; float m_maxRotation; float m_rotateTime; float m_rotatePerSec; bool m_needSync; public: DoorEntity(); virtual ~DoorEntity(); int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp, std::vector<ElementState> subjectStates, float rotateTime = 1.0f, float minRotation = 0.0f, float maxRotation = DirectX::XM_PI / 2.0f); int Update(float dT, InputHandler* inputHandler); int React(int entityID, EVENT reactEvent); bool SetIsOpened(bool isOpened); bool GetIsOpened(); }; #endif
#ifndef SSPAPPLICATION_ENTITIES_DOORENTITY_H #define SSPAPPLICATION_ENTITIES_DOORENTITY_H #include "Entity.h" #include <vector> struct ElementState { int entityID; EVENT desiredState; bool desiredStateReached; }; class DoorEntity : public Entity { private: std::vector<ElementState> m_subjectStates; bool m_isOpened; float m_minRotation; float m_maxRotation; float m_rotateTime; float m_rotatePerSec; bool m_needSync; public: DoorEntity(); virtual ~DoorEntity(); int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp, std::vector<ElementState> subjectStates, float rotateTime = 1.0f, float minRotation = 0.0f, float maxRotation = DirectX::XM_PI / 2.0f); int Update(float dT, InputHandler* inputHandler); int React(int entityID, EVENT reactEvent); bool SetIsOpened(bool isOpened); bool GetIsOpened(); }; #endif
Set MIDPOINT to 90 instead of 128 (servo lib goes from 0 to 180)
#ifndef __MOTORS_H_ #define __MOTORS_H_ #include <Servo.h> #define MIDPOINT 128 class Motors { private: Servo port, vertical, starbord; int port_pin, vertical_pin, starbord_pin; public: Motors(int p_pin, int v_pin, int s_pin); void reset(); void go(int p, int v, int s); void stop(); }; #endif
#ifndef __MOTORS_H_ #define __MOTORS_H_ #include <Servo.h> #define MIDPOINT 90 class Motors { private: Servo port, vertical, starbord; int port_pin, vertical_pin, starbord_pin; public: Motors(int p_pin, int v_pin, int s_pin); void reset(); void go(int p, int v, int s); void stop(); }; #endif
Add TypeSet type as set of Types
/* * opencog/atoms/base/types.h * * Copyright (C) 2002-2007 Novamente LLC * All Rights Reserved * * Written by Thiago Maia <thiago@vettatech.com> * Andre Senna <senna@vettalabs.com> * * 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. */ /** * basic type definitions. */ #ifndef _OPENCOG_TYPES_H #define _OPENCOG_TYPES_H namespace opencog { /** \addtogroup grp_atomspace * @{ */ //! type of Atoms, represented as short integer (16 bits) typedef unsigned short Type; /** @}*/ } // namespace opencog #endif // _OPENCOG_TYPES_H
/* * opencog/atoms/base/types.h * * Copyright (C) 2002-2007 Novamente LLC * All Rights Reserved * * Written by Thiago Maia <thiago@vettatech.com> * Andre Senna <senna@vettalabs.com> * * 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. */ /** * basic type definitions. */ #ifndef _OPENCOG_TYPES_H #define _OPENCOG_TYPES_H #include <set> namespace opencog { /** \addtogroup grp_atomspace * @{ */ //! type of Atoms, represented as short integer (16 bits) typedef unsigned short Type; //! Set of atom types typedef std::set<Type> TypeSet; /** @}*/ } // namespace opencog #endif // _OPENCOG_TYPES_H
Configure internal regulators at startup
/* mbed Microcontroller Library * Copyright (c) 2021 ARM Limited * Copyright (c) 2021 Embedded Planet, Inc. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <stdint.h> #include "subtarget_init.h" #include "nrf.h" /** * Override the subtarget sdk init startup hook (specific to nRF2) * This will configure the internal regulator to operate at 3.3V */ void subtarget_sdk_init(void) { if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VOUT_3V3) { NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} NRF_UICR->REGOUT0 = UICR_REGOUT0_VOUT_3V3; NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} // Trigger a soft reset so that the settings take effect NVIC_SystemReset(); } }
Add override specifier to the destructor.
/* Copyright 2018 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_MICRO_MICRO_ERROR_REPORTER_H_ #define TENSORFLOW_LITE_MICRO_MICRO_ERROR_REPORTER_H_ #include "tensorflow/lite/core/api/error_reporter.h" #include "tensorflow/lite/micro/compatibility.h" #include "tensorflow/lite/micro/debug_log.h" namespace tflite { class MicroErrorReporter : public ErrorReporter { public: ~MicroErrorReporter() {} int Report(const char* format, va_list args) override; private: TF_LITE_REMOVE_VIRTUAL_DELETE }; } // namespace tflite #endif // TENSORFLOW_LITE_MICRO_MICRO_ERROR_REPORTER_H_
/* Copyright 2018 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_MICRO_MICRO_ERROR_REPORTER_H_ #define TENSORFLOW_LITE_MICRO_MICRO_ERROR_REPORTER_H_ #include "tensorflow/lite/core/api/error_reporter.h" #include "tensorflow/lite/micro/compatibility.h" #include "tensorflow/lite/micro/debug_log.h" namespace tflite { class MicroErrorReporter : public ErrorReporter { public: ~MicroErrorReporter() override {} int Report(const char* format, va_list args) override; private: TF_LITE_REMOVE_VIRTUAL_DELETE }; } // namespace tflite #endif // TENSORFLOW_LITE_MICRO_MICRO_ERROR_REPORTER_H_
Allow hard reset of an object by destructing and recreating
#include <kotaka/paths.h> #include <game/paths.h> #include <kotaka/log.h> inherit LIB_WIZBIN; atomic void main(string args) { proxy_call("destruct_object", args); proxy_call("compile_object", args); }
Fix incorrect usage of 2 different clocks to a single uniform clock
#pragma once #include <chrono> #include <functional> #include <thread> #include <atomic> class Tick { public: Tick(std::chrono::microseconds timeBetweenTicks, std::function<void()>&& onTick) : timeBetweenTicks_(timeBetweenTicks) , onTick_(std::move(onTick)) , active_(true) , timerThread_([this] { Loop(); }) // note initialization order is very important here; // thread should start last {} void Deactivate() { active_ = false; timerThread_.join(); } private: void Loop() const { while (active_) { for (auto start = std::chrono::steady_clock::now(), now = start; now < start + timeBetweenTicks_; now = std::chrono::high_resolution_clock::now()) { /* Until next tick */ } onTick_(); // may take significant time! } } const std::function<void()> onTick_; const std::chrono::microseconds timeBetweenTicks_; std::atomic<bool> active_; std::thread timerThread_; };
#pragma once #include <chrono> #include <functional> #include <thread> #include <atomic> using Clock = std::chrono::steady_clock; class Tick { public: Tick(std::chrono::microseconds timeBetweenTicks, std::function<void()>&& onTick) : timeBetweenTicks_(timeBetweenTicks) , onTick_(std::move(onTick)) , active_(true) , timerThread_([this] { Loop(); }) // note initialization order is very important here; // thread should start last {} void Deactivate() { active_ = false; timerThread_.join(); } private: void Loop() const { while (active_) { for (auto start = Clock::now(), now = start; now < start + timeBetweenTicks_; now = Clock::now()) { /* Until next tick */ } onTick_(); // may take significant time! } } const std::function<void()> onTick_; const std::chrono::microseconds timeBetweenTicks_; std::atomic<bool> active_; std::thread timerThread_; };
Reduce Even More Memory Usage
#ifndef CUBE_H #define CUBE_H #include "stdafx.h" using namespace std; class Cube { public: typedef float * Array; //static int locAmbient, locDiffuse, locSpecular, locEyeLight, locLight, locTexture; //static int locMVP, locMV, locNM; int numFrame; GLuint shader, textureID; static bool readTexture;//, readShader; Array final_vert, final_text, norm_final; GLuint vertbuffID[1], normbuffID[1], texbuffID[1]; int total, vsize, nsize, tsize; Cube(void); static GLuint loadShaderPair(char *, char *); void init(float[]); void bind(GLenum, GLenum); void draw(GLGeometryTransform); }; #endif
#ifndef CUBE_H #define CUBE_H #include "stdafx.h" using namespace std; class Cube { public: typedef float * Array; static int locAmbient, locDiffuse, locSpecular, locEyeLight, locLight, locTexture; static int locMVP, locMV, locNM; int numFrame; static GLuint shader, textureID; static bool readTexture, readShader; Array final_vert, final_text, norm_final; GLuint vertbuffID[1], normbuffID[1], texbuffID[1]; int total, vsize, nsize, tsize; Cube(void); static GLuint loadShaderPair(char *, char *); void init(float[]); void bind(GLenum, GLenum); void draw(GLGeometryTransform); }; #endif
Remove Wcatch-value and unify way to check if files are read.
#ifndef TEST_UTILS_H #define TEST_UTILS_H #include <fplll.h> using namespace std; using namespace fplll; /** @brief Read matrix from `input_filename`. @param A matrix @param input_filename @return zero if the file is correctly read, 1 otherwise. */ template <class ZT> int read_matrix(ZZ_mat<ZT> &A, const char *input_filename) { int status = 0; ifstream is(input_filename); if (!is) { status = 1; cerr << "Could not open file " << input_filename << "." << endl; } // throw std::runtime_error("could not open input file"); is >> A; return status; } /** @brief Read vector from `input_filename` into `b`. @param b vector @param input_filename filename @return zero if the file is correctly read, 1 otherwise. */ template <class ZT> int read_vector(vector<Z_NR<ZT>> &b, const char *input_filename) { int status = 0; ifstream is; is.exceptions(std::ifstream::failbit | std::ifstream::badbit); try { is.open(input_filename); is >> b; is.close(); } catch (ifstream::failure e) { status = 1; cerr << "Error by reading " << input_filename << "." << endl; } return status; } #endif /* TEST_UTILS_H */
#ifndef TEST_UTILS_H #define TEST_UTILS_H #include <fplll.h> using namespace std; using namespace fplll; #define read_file(X, input_filename) {\ ifstream is;\ is.exceptions(std::ifstream::failbit | std::ifstream::badbit);\ try {\ is.open(input_filename);\ is >> X;\ is.close();\ }\ catch (const ifstream::failure&) {\ status = 1;\ cerr << "Error by reading " << input_filename << "." << endl;\ }\ } /** @brief Read matrix from `input_filename`. @param A matrix @param input_filename @return zero if the file is correctly read, 1 otherwise. */ template <class ZT> int read_matrix(ZZ_mat<ZT> &A, const char *input_filename) { int status = 0; read_file(A, input_filename); return status; } /** @brief Read vector from `input_filename` into `b`. @param b vector @param input_filename filename @return zero if the file is correctly read, 1 otherwise. */ template <class ZT> int read_vector(vector<Z_NR<ZT>> &b, const char *input_filename) { int status = 0; read_file(b, input_filename); return status; } #endif /* TEST_UTILS_H */
Add prototypes for SceGpu MMU functions
/** * \kernelgroup{SceGpuEs4} * \usage{psp2kern/gpu_es4.h,SceGpuEs4ForDriver} */ #ifndef _PSP2_KERNEL_GPU_ES4_ #define _PSP2_KERNEL_GPU_ES4_ #include <psp2kern/types.h> #ifdef __cplusplus extern "C" { #endif int PVRSRVGetMiscInfoKM(void *info); int ksceGpuGetRegisterDump(void *dst, SceSize size); #ifdef __cplusplus } #endif #endif /* _PSP2_KERNEL_GPU_ES4_ */
/** * \kernelgroup{SceGpuEs4} * \usage{psp2kern/gpu_es4.h,SceGpuEs4ForDriver} */ #ifndef _PSP2_KERNEL_GPU_ES4_ #define _PSP2_KERNEL_GPU_ES4_ #include <psp2kern/types.h> #ifdef __cplusplus extern "C" { #endif int PVRSRVGetMiscInfoKM(void *info); int ksceGpuGetRegisterDump(void *dst, SceSize size); int ksceGpuMmuMapMemory(void *mmuContext, uint32_t vaddr, void *base, uint32_t size, uint32_t flags); int ksceGpuMmuUnmapMemory(void *mmuContext, uint32_t vaddr, uint32_t size); #ifdef __cplusplus } #endif #endif /* _PSP2_KERNEL_GPU_ES4_ */
Use fscanf to get the number of cities
#include "string.h" #include "stdio.h" #include "stdlib.h" #define DATA_FILE_NAME "nqmq.dat" #define DATA_LINE_MAX_LEN 80 char **cities; char *distances; int main(int argc, char *argv[]) { // Step 1: Read file into cities array and distances adjacency matrix char line[DATA_LINE_MAX_LEN]; FILE *data_file; data_file = fopen(DATA_FILE_NAME, "r"); // The first line will be the number of cities fgets(line, DATA_LINE_MAX_LEN, data_file); int num_cities = atoi(line); // Allocate space for the city names cities = malloc(sizeof(char*) * num_cities); // Read in all cities for (int i = 0; i < num_cities; ++i) { fgets(line, DATA_LINE_MAX_LEN, data_file); cities[i] = malloc(strlen(line) * sizeof(char)); strcpy(cities[i], line); } // Clean things up for (int i = 0; i < num_cities; ++i) free(cities[i]); free(cities); return 0; }
#include "string.h" #include "stdio.h" #include "stdlib.h" #define DATA_FILE_NAME "nqmq.dat" #define DATA_LINE_MAX_LEN 80 char **cities; char *distances; int main(int argc, char *argv[]) { // Step 1: Read file into cities array and distances adjacency matrix char line[DATA_LINE_MAX_LEN]; FILE *data_file; int num_cities = 0; data_file = fopen(DATA_FILE_NAME, "r"); // The first line will be the number of cities fscanf(data_file, "%d", &num_cities); // Allocate space for the city names cities = malloc(sizeof(char*) * num_cities); // Read in all cities for (int i = 0; i < num_cities; ++i) { fgets(line, DATA_LINE_MAX_LEN, data_file); cities[i] = malloc(strlen(line) * sizeof(char)); strcpy(cities[i], line); } // Clean things up for (int i = 0; i < num_cities; ++i) free(cities[i]); free(cities); return 0; }
Add a (public) header to detect common CPU archs.
/* * This set (target) cpu specific macros: * - NPY_TARGET_CPU: target CPU type */ #ifndef _NPY_CPUARCH_H_ #define _NPY_CPUARCH_H_ #if defined ( _i386_ ) || defined( __i386__ ) /* __i386__ is defined by gcc and Intel compiler on Linux, _i386_ by VS compiler */ #define NPY_TARGET_CPU NPY_X86 #elif defined(__x86_64__) || defined(__amd64__) /* both __x86_64__ and __amd64__ are defined by gcc */ #define NPY_TARGET_CPU NPY_AMD64 #elif defined(__ppc__) || defined(__powerpc__) /* __ppc__ is defined by gcc, I remember having seen __powerpc__ once, * but can't find it ATM */ #define NPY_TARGET_CPU NPY_PPC #elif defined(__sparc__) || defined(__sparc) /* __sparc__ is defined by gcc and Forte (e.g. Sun) compilers */ #define NPY_TARGET_CPU NPY_SPARC #elif defined(__s390__) #define NPY_TARGET_CPU NPY_S390 #elif defined(__parisc__) /* XXX: Not sure about this one... */ #define NPY_TARGET_CPU NPY_PA_RISC #else #error Unknown CPU, please report this to numpy maintainers with \ information about your platform #endif #endif
Update ROOT version files to v5.34/24.
#ifndef ROOT_RVersion #define ROOT_RVersion /* Version information automatically generated by installer. */ /* * These macros can be used in the following way: * * #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4) * #include <newheader.h> * #else * #include <oldheader.h> * #endif * */ #define ROOT_RELEASE "5.34/23" #define ROOT_RELEASE_DATE "Nov 7 2014" #define ROOT_RELEASE_TIME "15:06:58" #define ROOT_SVN_REVISION 49361 #define ROOT_GIT_COMMIT "v5-34-22-106-g4a0dea3" #define ROOT_GIT_BRANCH "heads/v5-34-00-patches" #define ROOT_VERSION_CODE 336407 #define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) #endif
#ifndef ROOT_RVersion #define ROOT_RVersion /* Version information automatically generated by installer. */ /* * These macros can be used in the following way: * * #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4) * #include <newheader.h> * #else * #include <oldheader.h> * #endif * */ #define ROOT_RELEASE "5.34/24" #define ROOT_RELEASE_DATE "Dec 2 2014" #define ROOT_RELEASE_TIME "18:12:03" #define ROOT_SVN_REVISION 49361 #define ROOT_GIT_COMMIT "v5-34-23-79-gbc6a48d" #define ROOT_GIT_BRANCH "heads/v5-34-00-patches" #define ROOT_VERSION_CODE 336408 #define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) #endif
Add guards to avoid multiple includes.
#include <stdio.h> #define major 1 #define minor 0 #define patch 0 #define ver(arg) #arg #define ver2(arg) ver(arg) #define maj ver2(major) #define min ver2(minor) #define pat ver2(patch) #define dot "." #define VERSION (maj dot min dot pat)
/* @file version.h @brief Defines macros to create version number string @license MIT LICENSE @authors Prakhar Nigam, https://github.com/prakharnigam electrogeek, https://github.com/Nishant-Mishra */ #ifndef __VERSION_H__ #define __VERSION_H__ #ifdef __cplusplus extern "C" { #endif #define major 1 #define minor 0 #define patch 0 #define ver(arg) #arg #define ver2(arg) ver(arg) #define maj ver2(major) #define min ver2(minor) #define pat ver2(patch) #define dot "." #define VERSION (maj dot min dot pat) #ifdef __cplusplus } // extern "C" #endif #endif /* __VERSION_H__ */
Add a s16 (signed 16-bit int) for symmetry with u8/u16
#pragma once #include <cstdint> #include <cstdlib> using uint = unsigned int; using u8 = uint8_t; using u16 = uint16_t; using s8 = int8_t; const int GAMEBOY_WIDTH = 160; const int GAMEBOY_HEIGHT = 144; const int CLOCK_RATE = 4194304; template <typename... T> void unused(T&&...) {} #define fatal_error() log_error("Fatal error: %s:%d", __FILE__, __LINE__); exit(1); enum class GBColor { Color0, /* White */ Color1, /* Light gray */ Color2, /* Dark gray */ Color3, /* Black */ }; enum class Color { White, LightGray, DarkGray, Black, }; struct BGPalette { Color color0 = Color::White; Color color1 = Color::LightGray; Color color2 = Color::DarkGray; Color color3 = Color::Black; }; struct Noncopyable { Noncopyable& operator=(const Noncopyable&) = delete; Noncopyable(const Noncopyable&) = delete; Noncopyable() = default; };
#pragma once #include <cstdint> #include <cstdlib> using uint = unsigned int; using u8 = uint8_t; using u16 = uint16_t; using s8 = int8_t; using s16 = uint16_t; const int GAMEBOY_WIDTH = 160; const int GAMEBOY_HEIGHT = 144; const int CLOCK_RATE = 4194304; template <typename... T> void unused(T&&...) {} #define fatal_error() log_error("Fatal error: %s:%d", __FILE__, __LINE__); exit(1); enum class GBColor { Color0, /* White */ Color1, /* Light gray */ Color2, /* Dark gray */ Color3, /* Black */ }; enum class Color { White, LightGray, DarkGray, Black, }; struct BGPalette { Color color0 = Color::White; Color color1 = Color::LightGray; Color color2 = Color::DarkGray; Color color3 = Color::Black; }; struct Noncopyable { Noncopyable& operator=(const Noncopyable&) = delete; Noncopyable(const Noncopyable&) = delete; Noncopyable() = default; };
Remove reference to h5 header
#pragma once #include <iomanip> #include "H5Cpp.h" #include "logger.h" // N-wide hex output with 0x template <unsigned int N> std::ostream &hexn(std::ostream &out) { return out << "0x" << std::hex << std::setw(N) << std::setfill('0'); } inline int mymod(int a, int b) { int c = a % b; if (c < 0) c += b; return c; }
#pragma once #include <iomanip> #include "logger.h" // N-wide hex output with 0x template <unsigned int N> std::ostream &hexn(std::ostream &out) { return out << "0x" << std::hex << std::setw(N) << std::setfill('0'); } inline int mymod(int a, int b) { int c = a % b; if (c < 0) c += b; return c; }
Add new example for gmio_stl_infos_get()
/* ----------------------------------------------------------------------------- * * Example: read a STL file * * Just give a filepath and an initialized gmio_stl_mesh_creator object to * gmio_stl_read_file(). * The gmio_stl_mesh_creator object holds pointers to the callbacks invoked * during the read operation. * These callbacks creates the final mesh object. * * Note if you want to have control over the stream to be used, call * gmio_stl_read() instead. * * -------------------------------------------------------------------------- */ #include <gmio_core/error.h> #include <gmio_stl/stl_infos.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> static const char* gmio_stl_format_to_str(enum gmio_stl_format format) { switch (format) { case GMIO_STL_FORMAT_UNKNOWN: return "UNKNOWN"; case GMIO_STL_FORMAT_ASCII: return "STL ASCII"; case GMIO_STL_FORMAT_BINARY_LE: return "STL BINARY LITTLE-ENDIAN"; case GMIO_STL_FORMAT_BINARY_BE: return "STL BINARY BIG-ENDIAN"; } } static void print_stl_infos(const struct gmio_stl_infos* infos) { printf("File: %s\n" "Format: %s\n" "Size: %uKo\n" "Facets: %u\n", filepath, gmio_stl_format_to_str(infos->format), infos->size / 1024, infos->facet_count); if (infos->format == GMIO_STL_FORMAT_ASCII) { printf("Solid name: %s\n", infos->stla_solidname); } else if (infos->format == GMIO_STL_FORMAT_BINARY_LE || infos->format == GMIO_STL_FORMAT_BINARY_BE) { printf("Header: %80.80s\n", infos->stlb_header.data); } } int main(int argc, char** argv) { int error = 0; if (argc > 1) { /* Path to the STL file */ const char* filepath = argv[1]; /* Read-only standard stream on the STL file */ FILE* file = fopen(filepath, "rb"); if (file != NULL) { /* gmio stream interface object */ struct gmio_stream stream = gmio_stream_stdio(file); /* Will holds informations about the STL file */ struct gmio_stl_infos infos = {0}; /* Retrieve STL informations */ error = gmio_stl_infos_get( &infos, &stream, GMIO_STL_INFO_FLAG_ALL, NULL); if (error == GMIO_ERROR_OK) print_stl_infos(&infos); else fprintf(stderr, "gmio error: 0x%X\n", error); fclose(file); } } return error; }
Add newline to end of file.
// 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 VIEWS_CONTROLS_MENU_NATIVE_MENU_HOST_DELEGATE_H_ #define VIEWS_CONTROLS_MENU_NATIVE_MENU_HOST_DELEGATE_H_ namespace views { namespace internal { class NativeMenuHostDelegate { public: virtual ~NativeMenuHostDelegate() {} }; } // namespace internal } // namespace views #endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_HOST_DELEGATE_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 VIEWS_CONTROLS_MENU_NATIVE_MENU_HOST_DELEGATE_H_ #define VIEWS_CONTROLS_MENU_NATIVE_MENU_HOST_DELEGATE_H_ namespace views { namespace internal { class NativeMenuHostDelegate { public: virtual ~NativeMenuHostDelegate() {} }; } // namespace internal } // namespace views #endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_HOST_DELEGATE_H_
Change partner preference Int to Bool values
// Copyright (c) 2015 TeamSnap. All rights reserved. // #import <Foundation/Foundation.h> #import "TSDKCollectionObject.h" #import "TSDKObjectsRequest.h" @interface TSDKPartnerPreferences : TSDKCollectionObject @property (nonatomic, assign) NSInteger canDisplayPartner; //Example: 0 @property (nonatomic, strong, nullable) NSString * partnerName; //Example: **NULL** @property (nonatomic, strong, nullable) NSString * userId; //Example: <null> @property (nonatomic, assign) NSInteger userIsPartner; //Example: 0 @property (nonatomic, strong, nullable) NSString * partnerId; //Example: <null> @end
// Copyright (c) 2015 TeamSnap. All rights reserved. // #import <Foundation/Foundation.h> #import "TSDKCollectionObject.h" #import "TSDKObjectsRequest.h" @interface TSDKPartnerPreferences : TSDKCollectionObject @property (nonatomic, assign) BOOL canDisplayPartner; //Example: 0 @property (nonatomic, strong, nullable) NSString * partnerName; //Example: **NULL** @property (nonatomic, strong, nullable) NSString * userId; //Example: <null> @property (nonatomic, assign) BOOL userIsPartner; //Example: 0 @property (nonatomic, strong, nullable) NSString * partnerId; //Example: <null> @end
Add sys/stat.h to headers for mkfifo declaration.
/** * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ #ifndef STDAFX_H #define STDAFX_H // Common include file for all source code in Util #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <Psapi.h> #ifdef __cplusplus #pragma warning(disable:4995) /* suppress #pragma deprecated warnings from standard C++ headers */ #endif /* ifdef __cplusplus */ #else #include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <fcntl.h> #include <sys/socket.h> #include <sys/un.h> #include <arpa/inet.h> #include <netinet/tcp.h> #include <signal.h> #include <unistd.h> #include <dirent.h> #include <spawn.h> #endif #include <assert.h> // Include these so that cpptask fails if libraries not present #include <fudge/fudge.h> #include <log4cxx/log4cxx.h> #endif /* ifndef STDAFX_H */
/** * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ #ifndef STDAFX_H #define STDAFX_H // Common include file for all source code in Util #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <Psapi.h> #ifdef __cplusplus #pragma warning(disable:4995) /* suppress #pragma deprecated warnings from standard C++ headers */ #endif /* ifdef __cplusplus */ #else #include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <fcntl.h> #include <sys/socket.h> #include <sys/un.h> #include <arpa/inet.h> #include <netinet/tcp.h> #include <signal.h> #include <unistd.h> #include <dirent.h> #include <spawn.h> #include <sys/stat.h> #endif #include <assert.h> // Include these so that cpptask fails if libraries not present #include <fudge/fudge.h> #include <log4cxx/log4cxx.h> #endif /* ifndef STDAFX_H */
Use weak reference in object factory to avoid cyclical references
#import <Foundation/Foundation.h> @class JSObjectionInjector; @interface JSObjectFactory : NSObject @property (nonatomic, readonly, strong) JSObjectionInjector *injector; - (id)initWithInjector:(JSObjectionInjector *)injector; - (id)getObject:(id)classOrProtocol; - (id)objectForKeyedSubscript: (id)key; - (id)getObjectWithArgs:(id)classOrProtocol, ... NS_REQUIRES_NIL_TERMINATION; @end
#import <Foundation/Foundation.h> @class JSObjectionInjector; @interface JSObjectFactory : NSObject @property (nonatomic, readonly, weak) JSObjectionInjector *injector; - (id)initWithInjector:(JSObjectionInjector *)injector; - (id)getObject:(id)classOrProtocol; - (id)objectForKeyedSubscript: (id)key; - (id)getObjectWithArgs:(id)classOrProtocol, ... NS_REQUIRES_NIL_TERMINATION; @end
Add passing of information to prepareforsegue method
// // ResultsMapViewController.h // bikepath // // Created by Farheen Malik on 8/14/14. // Copyright (c) 2014 Bike Path. All rights reserved. // #import <UIKit/UIKit.h> #import <GoogleMaps/GoogleMaps.h> @interface ResultsMapViewController : UIViewController <GMSMapViewDelegate> @property (strong, nonatomic) IBOutlet GMSMapView *mapView; - (IBAction)unwindToSearchPage:(UIStoryboardSegue *)segue; @end
// // ResultsMapViewController.h // bikepath // // Created by Farheen Malik on 8/14/14. // Copyright (c) 2014 Bike Path. All rights reserved. // #import <UIKit/UIKit.h> #import <GoogleMaps/GoogleMaps.h> #import "SearchItem.h" @interface ResultsMapViewController : UIViewController <GMSMapViewDelegate> @property (strong, nonatomic) IBOutlet GMSMapView *mapView; - (IBAction)unwindToSearchPage:(UIStoryboardSegue *)segue; @property (nonatomic, strong) SearchItem *item; @end
Use quotes for include so that UnitTest header is found locally.
#include <unittest++/UnitTest++.h> /* * This file provides a transitive include for the UnitTest++ library * so that you don't need to remember how to include it yourself. This * file also provides you with a reference for using UnitTest++. * * == BASIC REFERENCE == * - TEST(NAME_OF_TEST) { body_of_test } * - TEST_FIXTURE(NAME_OF_FIXTURE,NAME_OF_TEST){ body_of_test } * * == CHECK MACRO REFERENCE == * - CHECK(EXPR); * - CHECK_EQUAL(EXPECTED,ACTUAL); * - CHECK_CLOSE(EXPECTED,ACTUAL,EPSILON); * - CHECK_ARRAY_EQUAL(EXPECTED,ACTUAL,LENGTH); * - CHECK_ARRAY_CLOSE(EXPECTED,ACTUAL,LENGTH,EPSILON); * - CHECK_ARRAY2D_EQUAL(EXPECTED,ACTUAL,ROWCOUNT,COLCOUNT); * - CHECK_ARRAY2D_CLOSE(EXPECTED,ACTUAL,ROWCOUNT,COLCOUNT,EPSILON); * - CHECK_THROW(EXPR,EXCEPTION_TYPE_EXPECTED); * * == TIME CONSTRAINTS == * * - UNITTEST_TIME_CONSTRAINT(TIME_IN_MILLISECONDS); * - UNITTEST_TIME_CONSTRAINT_EXEMPT(); * * == MORE INFO == * See: http://unittest-cpp.sourceforge.net/UnitTest++.html */
#include "unittest++/UnitTest++.h" /* * This file provides a transitive include for the UnitTest++ library * so that you don't need to remember how to include it yourself. This * file also provides you with a reference for using UnitTest++. * * == BASIC REFERENCE == * - TEST(NAME_OF_TEST) { body_of_test } * - TEST_FIXTURE(NAME_OF_FIXTURE,NAME_OF_TEST){ body_of_test } * * == CHECK MACRO REFERENCE == * - CHECK(EXPR); * - CHECK_EQUAL(EXPECTED,ACTUAL); * - CHECK_CLOSE(EXPECTED,ACTUAL,EPSILON); * - CHECK_ARRAY_EQUAL(EXPECTED,ACTUAL,LENGTH); * - CHECK_ARRAY_CLOSE(EXPECTED,ACTUAL,LENGTH,EPSILON); * - CHECK_ARRAY2D_EQUAL(EXPECTED,ACTUAL,ROWCOUNT,COLCOUNT); * - CHECK_ARRAY2D_CLOSE(EXPECTED,ACTUAL,ROWCOUNT,COLCOUNT,EPSILON); * - CHECK_THROW(EXPR,EXCEPTION_TYPE_EXPECTED); * * == TIME CONSTRAINTS == * * - UNITTEST_TIME_CONSTRAINT(TIME_IN_MILLISECONDS); * - UNITTEST_TIME_CONSTRAINT_EXEMPT(); * * == MORE INFO == * See: http://unittest-cpp.sourceforge.net/UnitTest++.html */
Add exclamation mark to unknown to indicate it should always be unknown
// PARAM: --set ana.int.interval true --set solver "'td3'" #include<pthread.h> #include<assert.h> int glob1 = 0; pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; void *t_fun(void *arg) { int t; pthread_mutex_lock(&mutex1); if(t == 42) { glob1 = 1; } t = glob1; assert(t == 0); //UNKNOWN assert(t == 1); //UNKNOWN glob1 = 0; pthread_mutex_unlock(&mutex1); return NULL; } int main(void) { pthread_t id; assert(glob1 == 0); pthread_create(&id, NULL, t_fun, NULL); pthread_mutex_lock(&mutex1); assert(glob1 == 0); pthread_mutex_unlock(&mutex1); pthread_join (id, NULL); return 0; }
// PARAM: --set ana.int.interval true --set solver "'td3'" #include<pthread.h> #include<assert.h> int glob1 = 0; pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; void *t_fun(void *arg) { int t; pthread_mutex_lock(&mutex1); if(t == 42) { glob1 = 1; } t = glob1; assert(t == 0); //UNKNOWN! assert(t == 1); //UNKNOWN! glob1 = 0; pthread_mutex_unlock(&mutex1); return NULL; } int main(void) { pthread_t id; assert(glob1 == 0); pthread_create(&id, NULL, t_fun, NULL); pthread_mutex_lock(&mutex1); assert(glob1 == 0); pthread_mutex_unlock(&mutex1); pthread_join (id, NULL); return 0; }
Revert "Testing GPG key on github"
#ifndef A_FILTER_HDR #define A_FILTER_HDR #include "u_vector.h" namespace a { struct source; struct filterInstance { virtual void filter(float *buffer, size_t samples, bool strero, float sampleRate) = 0; virtual ~filterInstance(); }; struct filter { virtual void init(source *); virtual filterInstance *create() = 0; virtual ~filter(); }; struct echoFilter; struct echoFilterInstance : filterInstance { virtual void filter(float *buffer, size_t samples, bool stereo, float sampleRate); virtual ~echoFilterInstance(); echoFilterInstance(echoFilter *parent); private: u::vector<float> m_buffer; echoFilter *m_parent; size_t m_offset; }; struct echoFilter : filter { virtual void init(source *sourcer_); virtual filterInstance *create(); echoFilter(); void setParams(float delay, float decay); private: friend struct echoFilterInstance; float m_delay; float m_decay; }; } #endif
#ifndef A_FILTER_HDR #define A_FILTER_HDR #include "u_vector.h" namespace a { struct source; struct filterInstance { virtual void filter(float *buffer, size_t samples, bool strero, float sampleRate) = 0; virtual ~filterInstance(); }; struct filter { virtual void init(source *audioSource); virtual filterInstance *create() = 0; virtual ~filter(); }; struct echoFilter; struct echoFilterInstance : filterInstance { virtual void filter(float *buffer, size_t samples, bool stereo, float sampleRate); virtual ~echoFilterInstance(); echoFilterInstance(echoFilter *parent); private: u::vector<float> m_buffer; echoFilter *m_parent; size_t m_offset; }; struct echoFilter : filter { virtual void init(source *sourcer_); virtual filterInstance *create(); echoFilter(); void setParams(float delay, float decay); private: friend struct echoFilterInstance; float m_delay; float m_decay; }; } #endif
Add test for var_eq unsoundness with dereferenced floats
// PARAM: --enable ana.int.interval --enable ana.int.def_exc --enable ana.sv-comp.functions --set ana.activated[+] var_eq --set ana.activated[+] region #include <goblint.h> int isNan(float arg) { float x; return arg != arg; } int main(){ struct blub { float f; } s; float fs[3]; float top; // float may be NaN here, therefore the comaprison should be unknown __goblint_check(top == top); //UNKNOWN! __goblint_check(s.f == s.f); //UNKNOWN! __goblint_check(fs[1] == fs[1]); //UNKNOWN! int r = isNan(top); if(r) { __goblint_check(1); } else { __goblint_check(1); } }
// PARAM: --enable ana.int.interval --enable ana.int.def_exc --enable ana.sv-comp.functions --set ana.activated[+] var_eq --set ana.activated[+] region #include <goblint.h> int isNan(float arg) { float x; return arg != arg; } int main(){ struct blub { float f; } s; float fs[3]; float top; // float may be NaN here, therefore the comaprison should be unknown __goblint_check(top == top); //UNKNOWN! __goblint_check(s.f == s.f); //UNKNOWN! __goblint_check(fs[1] == fs[1]); //UNKNOWN! int r = isNan(top); if(r) { __goblint_check(1); } else { __goblint_check(1); } float *p = &top; float *q = &fs; __goblint_check(*p == *p); //UNKNOWN! __goblint_check(q[1] == q[1]); //UNKNOWN! return 0; }
Change Win32 dlerror message to:
/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.4 2004/11/17 08:30:08 neilc Exp $ */ #include <windows.h> char *dlerror(void); int dlclose(void *handle); void *dlsym(void *handle, const char *symbol); void *dlopen(const char *path, int mode); char * dlerror(void) { return "error"; } int dlclose(void *handle) { return FreeLibrary((HMODULE) handle) ? 0 : 1; } void * dlsym(void *handle, const char *symbol) { return (void *) GetProcAddress((HMODULE) handle, symbol); } void * dlopen(const char *path, int mode) { return (void *) LoadLibrary(path); }
/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.5 2004/12/02 19:38:50 momjian Exp $ */ #include <windows.h> char *dlerror(void); int dlclose(void *handle); void *dlsym(void *handle, const char *symbol); void *dlopen(const char *path, int mode); char * dlerror(void) { return "dynamic load error"; } int dlclose(void *handle) { return FreeLibrary((HMODULE) handle) ? 0 : 1; } void * dlsym(void *handle, const char *symbol) { return (void *) GetProcAddress((HMODULE) handle, symbol); } void * dlopen(const char *path, int mode) { return (void *) LoadLibrary(path); }
Fix crash in Scrumptious app.
/* * Copyright 2012 Facebook * * 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. */ #import <UIKit/UIKit.h> #import "SCViewController.h" @interface SCMealViewController : UIViewController @property (strong, nonatomic) SelectItemCallback selectItemCallback; @end
/* * Copyright 2012 Facebook * * 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. */ #import <UIKit/UIKit.h> #import "SCViewController.h" @interface SCMealViewController : UIViewController @property (copy, nonatomic) SelectItemCallback selectItemCallback; @end
Change session length to 1h
/* * Copyright 2016 Adam Chyła, adam@chyla.org * All rights reserved. Distributed under the terms of the MIT License. */ #pragma once namespace apache { namespace analyzer { namespace detail { constexpr int SESSION_LENGTH = 60; } } }
/* * Copyright 2016 Adam Chyła, adam@chyla.org * All rights reserved. Distributed under the terms of the MIT License. */ #pragma once namespace apache { namespace analyzer { namespace detail { constexpr int SESSION_LENGTH = 3600; } } }
Define alphabet and number of tree layers
#include<stdio.h> #include<stdlib.h> int main (int argc, char *argv[]){ if(argc != 3){ printf("Number of parameters should be 2 (filename, cardinality)."); exit(1); } //open file and get file length FILE *file; file = fopen(argv[1],"r"); if(file == NULL){ printf("File couldn't be opened."); exit(1); } fseek(file, 0, SEEK_END); int fileLength = ftell(file); fseek(file, 0, SEEK_SET); //save data from file to array char inputStream[fileLength]; //printf("length: %d \n", fileLength); int i = 0; int character; while((character = fgetc(file)) != EOF){ inputStream[i] = character; i++; } /*int j; for(j=0; j < fileLength; j++){ char a = inputStream[j]; printf("Znak: %c \n", a); }*/ fclose(file); }
#include<stdio.h> #include<stdlib.h> #include<math.h> int main (int argc, char *argv[]){ if(argc != 3){ printf("Number of parameters should be 2 (filename, arity)."); exit(1); } int alphabet[128] = {0}; int arity = atoi(argv[2]); int treeLayers = ceil(7/log2(arity)); printf("Number of layers: %d \n", treeLayers); //open file and get file length FILE *file; file = fopen(argv[1],"r"); if(file == NULL){ printf("File couldn't be opened."); exit(1); } fseek(file, 0, SEEK_END); int fileLength = ftell(file); fseek(file, 0, SEEK_SET); //save data from file to array char inputStream[fileLength]; printf("length: %d \n", fileLength); int i = 0; int character; int numOfChar = 0; while((character = fgetc(file)) != EOF){ inputStream[i] = character; if(alphabet[character]==0){ alphabet[character]=1; numOfChar++; } i++; } char charOfAlphabet[numOfChar]; int j; int k = 0; for (j = 0; j < 128; j++){ if(alphabet[j]==1){ charOfAlphabet[k] = j; k++; } } //for(j=0; j < fileLength; j++){ // int a = inputStream[j]; //printf("Znak: %d \n", a); //} fclose(file); }
Make assert do the right thing
/* * $Id$ */ #include <errno.h> #include <time.h> /* from libvarnish/argv.c */ void FreeArgv(char **argv); char **ParseArgv(const char *s, int comment); /* from libvarnish/time.c */ void TIM_format(time_t t, char *p); time_t TIM_parse(const char *p); /* from libvarnish/version.c */ void varnish_version(const char *); /* from libvarnish/assert.c */ #ifdef WITHOUT_ASSERTS #define assert(e) ((void)0) #else /* WITH_ASSERTS */ #define assert(e) \ do { \ if (e) \ lbv_assert(__func__, __FILE__, __LINE__, #e, errno); \ } while (0) #endif void lbv_assert(const char *, const char *, int, const char *, int); /* Assert zero return value */ #define AZ(foo) do { assert((foo) == 0); } while (0)
/* * $Id$ */ #include <errno.h> #include <time.h> /* from libvarnish/argv.c */ void FreeArgv(char **argv); char **ParseArgv(const char *s, int comment); /* from libvarnish/time.c */ void TIM_format(time_t t, char *p); time_t TIM_parse(const char *p); /* from libvarnish/version.c */ void varnish_version(const char *); /* from libvarnish/assert.c */ #ifdef WITHOUT_ASSERTS #define assert(e) ((void)0) #else /* WITH_ASSERTS */ #define assert(e) \ do { \ if (!(e)) \ lbv_assert(__func__, __FILE__, __LINE__, #e, errno); \ } while (0) #endif void lbv_assert(const char *, const char *, int, const char *, int); /* Assert zero return value */ #define AZ(foo) do { assert((foo) == 0); } while (0)
Add --without-expat support to ./configure
/* $Id$ $Revision$ */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifdef __cplusplus extern "C" { #endif #ifndef CONVERT_H #define CONVERT_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef USE_CGRAPH #include <cgraph.h> #include <cghdr.h> #else #include <agraph.h> #endif #include <stdio.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif #include <string.h> extern void gv_to_gxl(Agraph_t *, FILE *); #ifdef HAVE_LIBEXPAT extern Agraph_t *gxl_to_gv(FILE *); #endif #endif #ifdef __cplusplus } #endif
/* $Id$ $Revision$ */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifdef __cplusplus extern "C" { #endif #ifndef CONVERT_H #define CONVERT_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef USE_CGRAPH #include <cgraph.h> #include <cghdr.h> #else #include <agraph.h> #endif #include <stdio.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif #include <string.h> extern void gv_to_gxl(Agraph_t *, FILE *); #ifdef HAVE_EXPAT extern Agraph_t *gxl_to_gv(FILE *); #endif #endif #ifdef __cplusplus } #endif
Replace spaces with "%20" in a string
#include <stdio.h> int main(int argc, char** argv) { if (argc < 2) { printf("Too few arguments\n"); return 1; } char* word = argv[1]; // Length AFTER replacing ' ' with "%20", counting '\0' int rlen = 1; // Determine length of new word for (int i = 0; word[i]; ++i) { rlen += (word[i] == ' ') ? 3 : 1; } char rstr[rlen]; int ridx = 0; for (int i = 0; word[i]; ++i) { if (word[i] == ' ') { rstr[ridx] = '%'; rstr[ridx + 1] = '2'; rstr[ridx + 2] = '0'; ridx += 3; } else { rstr[ridx] = word[i]; ridx += 1; } } // Always null terminate :) rstr[rlen - 1] = '\0'; printf("Replaced string is %s.\n", rstr); return 0; }
Increase refill and add logging.
// Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved. // Please see the AUTHORS file for details. Use of this source code is governed // by a BSD license that can be found in the LICENSE file. #ifndef SCALLOC_ALLOCATORS_PAGE_HEAP_H_ #define SCALLOC_ALLOCATORS_PAGE_HEAP_H_ #include "common.h" #include "distributed_queue.h" namespace scalloc { class PageHeap { public: static void InitModule(); static PageHeap* GetHeap(); void* Get(); void Put(void* p); void AsyncRefill(); private: static const size_t kPageHeapBackends = 4; static const size_t kPageRefill = 4; static PageHeap page_heap_ cache_aligned; DistributedQueue page_pool_ cache_aligned; }; always_inline PageHeap* PageHeap::GetHeap() { return &page_heap_; } always_inline void PageHeap::Put(void* p) { page_pool_.Enqueue(p); } always_inline void* PageHeap::Get() { REDO: void* result = page_pool_.Dequeue(); if (UNLIKELY(result == NULL)) { AsyncRefill(); goto REDO; } return result; } } // namespace scalloc #endif // SCALLOC_ALLOCATORS_PAGE_HEAP_H_
// Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved. // Please see the AUTHORS file for details. Use of this source code is governed // by a BSD license that can be found in the LICENSE file. #ifndef SCALLOC_ALLOCATORS_PAGE_HEAP_H_ #define SCALLOC_ALLOCATORS_PAGE_HEAP_H_ #include "common.h" #include "distributed_queue.h" namespace scalloc { class PageHeap { public: static void InitModule(); static PageHeap* GetHeap(); void* Get(); void Put(void* p); void AsyncRefill(); private: static const size_t kPageHeapBackends = 4; static const size_t kPageRefill = 24; static PageHeap page_heap_ cache_aligned; DistributedQueue page_pool_ cache_aligned; }; always_inline PageHeap* PageHeap::GetHeap() { return &page_heap_; } always_inline void PageHeap::Put(void* p) { LOG(kTrace, "[PageHeap]: put: %p", p); page_pool_.Enqueue(p); } always_inline void* PageHeap::Get() { REDO: void* result = page_pool_.Dequeue(); if (UNLIKELY(result == NULL)) { AsyncRefill(); goto REDO; } LOG(kTrace, "[PageHeap]: get: %p", result); return result; } } // namespace scalloc #endif // SCALLOC_ALLOCATORS_PAGE_HEAP_H_
Fix include path to make build work
#ifndef EGLTYPEDEFS_INCLUDED #define EGLTYPEDEFS_INCLUDED #include <GL/egl.h> typedef struct _egl_config _EGLConfig; typedef struct _egl_context _EGLContext; typedef struct _egl_display _EGLDisplay; typedef struct _egl_driver _EGLDriver; typedef struct _egl_mode _EGLMode; typedef struct _egl_screen _EGLScreen; typedef struct _egl_surface _EGLSurface; typedef void (*_EGLProc)(); typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy); #endif /* EGLTYPEDEFS_INCLUDED */
#ifndef EGLTYPEDEFS_INCLUDED #define EGLTYPEDEFS_INCLUDED #include <GLES/egl.h> typedef struct _egl_config _EGLConfig; typedef struct _egl_context _EGLContext; typedef struct _egl_display _EGLDisplay; typedef struct _egl_driver _EGLDriver; typedef struct _egl_mode _EGLMode; typedef struct _egl_screen _EGLScreen; typedef struct _egl_surface _EGLSurface; typedef void (*_EGLProc)(); typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy); #endif /* EGLTYPEDEFS_INCLUDED */
Clean yacc file, move other functions out of it.
#include <stdio.h> #include "y.tab.h" int main(int argc, char ** argv) { if(argc > 1) { yyin = fopen(argv[1], "r"); if(yyin == NULL) { printf("File doesn't exits.\n"); return 1; } strcpy(file_name, argv[1]); if(argc > 2) { if(strcmp(argv[2], "-print-tree") == 0) is_to_print = true; } } read_file(); yyparse(); if(!has_error) printf("\033[1;32mCompile Success!\033[0m\n"); return 0; }
#include <stdio.h> #include "list.h" #include "syntax.h" #include "scc_yacc.hpp" extern FILE * yyin; extern char *file_content[1024]; extern char file_name[1024]; extern int yyparse(); void read_file() { for(int i = 0; !feof(yyin); i++) { file_content[i] = (char * )malloc(1024 * sizeof(char)); fgets(file_content[i], 1024, yyin); file_content[i][strlen(file_content[i]) - 1] = '\0'; } fseek(yyin, 0, 0); } int main(int argc, char ** argv) { // read from file if(argc > 1) { strcpy(file_name, argv[1]); yyin = fopen(argv[1], "r"); if(yyin == NULL) { printf("File doesn't exits.\n"); return 1; } } // TODO: macro expansion // grammer analysis read_file(); if(yyparse() != 0) return 0; // semantic analysis printf("\033[1;32mCompile Success!\033[0m\n"); return 0; }
Move forward decls in right namespace.
#ifndef VAST_UTIL_BROCCOLI_H #define VAST_UTIL_BROCCOLI_H #include <ze/fwd.h> #include "vast/util/server.h" // Forward declaration. struct bro_conn; namespace vast { namespace util { namespace broccoli { struct connection; typedef util::server<connection> server; typedef std::function<void(ze::event)> event_handler; /// Initializes Broccoli. This function must be called before any other call /// into the Broccoli library. /// @param messages If `true`, show message contents and protocol details. /// @param calltrace If `true`, enable call tracing. void init(bool messages = false, bool calltrace = false); /// A Broccoli connection actor. struct connection : cppa::sb_actor<connection> { /// Spawns a new Broccoli connection. /// @param The input stream to read data from. /// @param The output stream to read data from. connection( cppa::network::input_stream_ptr in, cppa::network::output_stream_ptr out); struct bro_conn* bc_; cppa::network::input_stream_ptr in_; cppa::network::output_stream_ptr out_; event_handler event_handler_; //std::vector<ze::event> events_; cppa::behavior init_state; }; } // namespace broccoli } // namespace vast } // namespace util #endif
#ifndef VAST_UTIL_BROCCOLI_H #define VAST_UTIL_BROCCOLI_H #include <ze/fwd.h> #include "vast/util/server.h" namespace vast { namespace util { namespace broccoli { // Forward declarations. struct bro_conn; struct connection; typedef util::server<connection> server; typedef std::function<void(ze::event)> event_handler; /// Initializes Broccoli. This function must be called before any other call /// into the Broccoli library. /// @param messages If `true`, show message contents and protocol details. /// @param calltrace If `true`, enable call tracing. void init(bool messages = false, bool calltrace = false); /// A Broccoli connection actor. struct connection : cppa::sb_actor<connection> { /// Spawns a new Broccoli connection. /// @param The input stream to read data from. /// @param The output stream to read data from. connection( cppa::network::input_stream_ptr in, cppa::network::output_stream_ptr out); struct bro_conn* bc_; cppa::network::input_stream_ptr in_; cppa::network::output_stream_ptr out_; event_handler event_handler_; //std::vector<ze::event> events_; cppa::behavior init_state; }; } // namespace broccoli } // namespace vast } // namespace util #endif
Define the user defined functions
/***************************************************************************** * PROGRAM NAME: CUDFunction.h * PROGRAMMER: Wei Sun wsun@vt.edu * PURPOSE: Define the user defined function object *****************************************************************************/ #ifndef COPASI_CUDFunction #define COPASI_CUDFunction #include <string> #include "copasi.h" #include "utilities/utilities.h" #include "function/CBaseFunction.h" #include "CNodeO.h" class CUDFunction: public CBaseFunction { private: /** * The vector of nodes of the binary tree of the function */ CCopasiVectorS < CNodeO > mNodes; /** * Internal variable */ unsigned C_INT32 mNidx; public: /** * Default constructor */ CUDFunction(); /** * This creates a user defined function with a name an description * @param "const string" &name * @param "const string" &description */ CUDFunction(const string & name, const string & description); /** * Destructor */ ~CUDFunction(); /** * Delete */ void cleanup(); /** * Copy */ void copy(const CUDFunction & in); /** * Loads an object with data coming from a CReadConfig object. * (CReadConfig object reads an input stream) * @param pconfigbuffer reference to a CReadConfig object. * @return Fail */ C_INT32 load(CReadConfig & configbuffer, CReadConfig::Mode mode = CReadConfig::LOOP); /** * Saves the contents of the object to a CWriteConfig object. * (Which usually has a file attached but may also have socket) * @param pconfigbuffer reference to a CWriteConfig object. * @return Fail */ C_INT32 save(CWriteConfig & configbuffer); /** * This retrieves the node tree of the function * @return "CCopasiVectorS < CNodeO > &" */ CCopasiVectorS < CNodeO > & nodes(); private: /** * This clears all nodes of the function tree */ void clearNodes(); /** * This connects the nodes to build the binary function tree */ C_INT32 connectNodes(); CNodeO * parseExpression(C_INT16 priority); CNodeO * parsePrimary(); }; #endif
Split every node into two based on node data
#include <stdio.h> #include <stdlib.h> #include <string.h> struct node { int data; struct node *next; }; struct node *createNode (int value) { struct node *newNode = (struct node *) malloc (sizeof (struct node)); newNode -> data = value; newNode -> next = NULL; return newNode; } void insertNode (struct node **head_ref, struct node **tail_ref, int value) { struct node *newNode = createNode (value); if (*head_ref == NULL) { *head_ref = newNode; *tail_ref = newNode; } else { (*tail_ref) -> next = newNode; *tail_ref = newNode; } } void printList (struct node *head) { while (head != NULL) { printf ("%d -> ", head->data); head = head->next; } printf ("NULL\n"); } void destroyList (struct node *head) { struct node *nextNode = head; while (head != NULL) { nextNode = head -> next; free (head); head = nextNode; } printf("Destroyed it\n" ); } void splitEveryNodeOnOddEvenData (struct node **head_ref) { struct node *currentNode = NULL; struct node *nextNode = NULL; struct node *newNode = NULL; int element; currentNode = (*head_ref); if (currentNode == NULL) { return; } while (currentNode != NULL) { nextNode = currentNode->next; element = currentNode->data; if (element % 2 == 0) { newNode = createNode (element/2); currentNode->data /= 2; } else { newNode = createNode (element - element/2); currentNode->data /= 2; } currentNode->next = newNode; newNode->next = nextNode; currentNode = nextNode; } } int main (int argc, char *argv[]) { int value; struct node *head = NULL; struct node *tail = NULL; char buffer[2048]; char *p = NULL; fgets (buffer, 2048, stdin); p = strtok (buffer, "NULL > | \n"); while (p != NULL) { sscanf (p, "%d", &value); insertNode (&head, &tail, value); p = strtok (NULL, "NULL null | > \n"); } printList (head); splitEveryNodeOnOddEvenData (&head); printList (head); destroyList (head); head = NULL; tail = NULL; return 0; }
Exit with an error code when an error occurs.
#include <stdio.h> #include "libsass/sass_interface.h" int main(int argc, char** argv) { if (argc < 2) { printf("Usage: sassc [INPUT FILE]\n"); return 0; } struct sass_file_context* ctx = sass_new_file_context(); ctx->options.include_paths = ""; ctx->options.image_path = "images"; ctx->options.output_style = SASS_STYLE_NESTED; ctx->input_path = argv[1]; sass_compile_file(ctx); if (ctx->error_status) { if (ctx->error_message) printf("%s", ctx->error_message); else printf("An error occured; no error message available.\n"); } else if (ctx->output_string) { printf("%s", ctx->output_string); } else { printf("Unknown internal error.\n"); } sass_free_file_context(ctx); return 0; }
#include <stdio.h> #include "libsass/sass_interface.h" int main(int argc, char** argv) { int ret; if (argc < 2) { printf("Usage: sassc [INPUT FILE]\n"); return 0; } struct sass_file_context* ctx = sass_new_file_context(); ctx->options.include_paths = ""; ctx->options.image_path = "images"; ctx->options.output_style = SASS_STYLE_NESTED; ctx->input_path = argv[1]; sass_compile_file(ctx); if (ctx->error_status) { if (ctx->error_message) printf("%s", ctx->error_message); else printf("An error occured; no error message available.\n"); ret = 1; } else if (ctx->output_string) { printf("%s", ctx->output_string); ret = 0; } else { printf("Unknown internal error.\n"); ret = 2; } sass_free_file_context(ctx); return ret; }
Add witness lifter path sensitive unsound branch test
// PARAM: --enable ana.sv-comp.enabled --enable ana.sv-comp.functions --set ana.specification 'CHECK( init(main()), LTL(G ! call(reach_error())) )' --enable ana.int.interval // previously both branches dead // simplified from 28-race_reach/06-cond_racing1 #include <pthread.h> #include <assert.h> int __VERIFIER_nondet_int(); pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int main() { int i = __VERIFIER_nondet_int(); if (i) pthread_mutex_lock(&mutex); if (i) assert(1); // reachable else assert(1); // reachable assert(1); // reachable return 0; }
Add source code documentation for the Prefix Extractor class
// // RocksDBPrefixExtractor.h // ObjectiveRocks // // Created by Iska on 26/12/14. // Copyright (c) 2014 BrainCookie. All rights reserved. // #import <Foundation/Foundation.h> typedef NS_ENUM(NSUInteger, RocksDBPrefixType) { RocksDBPrefixFixedLength }; @interface RocksDBPrefixExtractor : NSObject + (instancetype)prefixExtractorWithType:(RocksDBPrefixType)type length:(size_t)length; - (instancetype)initWithName:(NSString *)name transformBlock:(id (^)(id key))transformBlock prefixCandidateBlock:(BOOL (^)(id key))prefixCandidateBlock validPrefixBlock:(BOOL (^)(id prefix))validPrefixBlock; @end
// // RocksDBPrefixExtractor.h // ObjectiveRocks // // Created by Iska on 26/12/14. // Copyright (c) 2014 BrainCookie. All rights reserved. // #import <Foundation/Foundation.h> /** Constants for the built-in prefix extractors. */ typedef NS_ENUM(NSUInteger, RocksDBPrefixType) { /** @brief Extract a fixed-length prefix for each key. */ RocksDBPrefixFixedLength }; /** `RocksDBIterator` supports iterating inside a key-prefix by providing a `RocksDBPrefixExtractor`. The `RocksDBPrefixExtractor` defines a Slice-Transform function that is applied to each key when itarating the DB in order to extract the prefix for the prefix-seek API. */ @interface RocksDBPrefixExtractor : NSObject /** Intializes a new instance of the prefix extarctor with the given type and length. @param type The type of the prefix extractor. @param length The length of the desired prefix. @return A newly-initialized instance of a prefix extractor. */ + (instancetype)prefixExtractorWithType:(RocksDBPrefixType)type length:(size_t)length; /** Intializes a new instance of the prefix extarctor with the given transformation functions. @param transformBlock A block to apply to each key to extract the prefix. @param prefixCandidateBlock A block that is applied to each key before the transformation in order to filter out keys that are not viable candidates for the custom prefix format, e.g. key length is smaller than the target prefix length. @param validPrefixBlock A block that is applied to each key after the transformation in order to perform extra checks to verify that the extracted prefix is valid. @return A newly-initialized instance of a prefix extractor. */ - (instancetype)initWithName:(NSString *)name transformBlock:(id (^)(id key))transformBlock prefixCandidateBlock:(BOOL (^)(id key))prefixCandidateBlock validPrefixBlock:(BOOL (^)(id prefix))validPrefixBlock; @end
Add an MP test that uses imb instead of deps
// Test if message passing works // Should on x86, not on arm // Basically always just doesn't see the write at all. // Probably need to loop. // On ARM: // mp - observed // mp+ctrl - observed // mp+addr - not observed :( was hoping to // mp+sync+addr - not observed; good! #include "atomic.h" #include <stdio.h> #include <assert.h> volatile long data PADDED = 1; volatile long ready PADDED = 0; volatile long *pdata; volatile int foo; int thread0() { // Trying a bunch of things to see if I can get that ready write // to happen before the data one, but I haven't managed. // extern int go; /* durrrr */ // data = go * go + 1; *pdata = 1; // smp_mb(); ready = 1; return 0; } int thread1() { int rready; while (!(rready = ready)); ctrl_isync(rready); int rdata = data; return ((!!rdata)<<1) | rready; } void reset() { pdata = &data; assert(data != 0); ready = 0; data = 0; } // Formatting results int result_counts[4]; void process_results(int *r) { int idx = r[1]; result_counts[idx]++; } void summarize_results() { for (int r0 = 0; r0 <= 1; r0++) { for (int r1 = 0; r1 <= 1; r1++) { int idx = (r1<<1) | r0; printf("ready=%d data=%d: %d\n", r0, r1, result_counts[idx]); } } printf("&data = %p, &ready=%p\n", &data, &ready); } typedef int (test_fn)(); test_fn *test_fns[] = {thread0, thread1}; int thread_count = 2;
Add forgotten function in DX11 implementation
#ifndef __IM_WINDOW_MANAGER_DX11_H__ #define __IM_WINDOW_MANAGER_DX11_H__ #include "ImwConfig.h" #include "ImwWindowManager.h" namespace ImWindow { class ImwWindowManagerDX11 : public ImwWindowManager { public: ImwWindowManagerDX11(); virtual ~ImwWindowManagerDX11(); protected: virtual ImwPlatformWindow* CreatePlatformWindow(bool bMain, ImwPlatformWindow* pParent, bool bDragWindow); virtual void LogFormatted(const char* pStr); virtual void InternalRun(); virtual ImVec2 GetCursorPos(); virtual bool IsLeftClickDown(); }; } #endif //__IM_WINDOW_MANAGER_DX11_H__
#ifndef __IM_WINDOW_MANAGER_DX11_H__ #define __IM_WINDOW_MANAGER_DX11_H__ #include "ImwConfig.h" #include "ImwWindowManager.h" namespace ImWindow { class ImwWindowManagerDX11 : public ImwWindowManager { public: ImwWindowManagerDX11(); virtual ~ImwWindowManagerDX11(); protected: virtual bool CanCreateMultipleWindow() { return true; } virtual ImwPlatformWindow* CreatePlatformWindow(bool bMain, ImwPlatformWindow* pParent, bool bDragWindow); virtual void LogFormatted(const char* pStr); virtual void InternalRun(); virtual ImVec2 GetCursorPos(); virtual bool IsLeftClickDown(); }; } #endif //__IM_WINDOW_MANAGER_DX11_H__