Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add simple unit tests for the controller
/** * @file test_controller.c * @author Travis Lane * @version 0.0.1 * @date 2019-04-21 */ #include <check.h> #include "pwm.h" #include "pwm_internal.h" START_TEST(test_controller_basic) { struct usp_controller_t *ctrl; struct usp_pwm_list_t *lst; ctrl = usp_controller_new(); fail_if(ctrl == NULL, "Failed to create controller."); lst = usp_controller_get_pwms(ctrl); fail_if(lst == NULL, "Failed to get pwm list."); usp_pwm_list_unref(lst); usp_controller_delete(ctrl); } END_TEST static Suite * suite_controller_new() { Suite *suite_controller = suite_create("suite_controller"); TCase *case_controller = tcase_create("test_controller"); tcase_add_test(case_controller, test_controller_basic); suite_add_tcase(suite_controller, case_controller); return suite_controller; } int main() { int failed; Suite *suite_controller = suite_controller_new(); SRunner *runner_controller = srunner_create(suite_controller); srunner_run_all(runner_controller, CK_NORMAL); failed = srunner_ntests_failed(runner_controller); srunner_free(runner_controller); return failed; }
Increase max number of elements per instruction.
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #ifndef _GUAC_PARSER_CONSTANTS_H #define _GUAC_PARSER_CONSTANTS_H /** * Constants related to the Guacamole protocol parser. * * @file parser-constants.h */ /** * The maximum number of characters per instruction. */ #define GUAC_INSTRUCTION_MAX_LENGTH 8192 /** * The maximum number of digits to allow per length prefix. */ #define GUAC_INSTRUCTION_MAX_DIGITS 5 /** * The maximum number of elements per instruction, including the opcode. */ #define GUAC_INSTRUCTION_MAX_ELEMENTS 64 #endif
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #ifndef _GUAC_PARSER_CONSTANTS_H #define _GUAC_PARSER_CONSTANTS_H /** * Constants related to the Guacamole protocol parser. * * @file parser-constants.h */ /** * The maximum number of characters per instruction. */ #define GUAC_INSTRUCTION_MAX_LENGTH 8192 /** * The maximum number of digits to allow per length prefix. */ #define GUAC_INSTRUCTION_MAX_DIGITS 5 /** * The maximum number of elements per instruction, including the opcode. */ #define GUAC_INSTRUCTION_MAX_ELEMENTS 128 #endif
Add default SWO pin number and config if not defined in Ambiq target
/* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * 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. */ #if DEVICE_ITM #include "hal/itm_api.h" #include "cmsis.h" #include "am_bsp.h" #include <stdbool.h> /* SWO frequency: 1000 kHz */ // As SWO has to be accessible everywhere, including ISRs, we can't easily // communicate the dependency on clocks etc. to other components - so this // function checks that things appear to be set up, and if not re-configures // everything void itm_init(void) { am_bsp_itm_printf_enable(); } #endif
/* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * 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. */ #if DEVICE_ITM #include "hal/itm_api.h" #include "cmsis.h" #include "am_bsp.h" #include <stdbool.h> /* SWO frequency: 1000 kHz */ #ifndef AM_BSP_GPIO_ITM_SWO #define AM_GPIO_ITM_SWO 22 const am_hal_gpio_pincfg_t g_AM_GPIO_ITM_SWO = { .uFuncSel = AM_HAL_PIN_22_SWO, .eDriveStrength = AM_HAL_GPIO_PIN_DRIVESTRENGTH_2MA }; #endif void itm_init(void) { #ifdef AM_BSP_GPIO_ITM_SWO am_bsp_itm_printf_enable(); #else am_bsp_itm_printf_enable(AM_GPIO_ITM_SWO,g_AM_GPIO_ITM_SWO); #endif } #endif
Revert "Add slight tolerance for image differences to visual test macro."
#import <FBSnapshotTestCase/FBSnapshotTestCase.h> #import "UIApplication+VisualTestUtils.h" /** * @function WMFSnapshotVerifyView * * Verify correct appearance of a given view. * * Search all folder suffixes, use default naming conventions. * * @param view The view to verify. */ #define WMFSnapshotVerifyView(view) FBSnapshotVerifyView((view), nil) /** * @function WMFSnapshotVerifyViewForOSAndWritingDirection * * Compares @c view with a reference image matching the current OS version & application writing direction (e.g. * "testLaysOutProperly_9.2_RTL@2x.png"). * * @param view The view to verify. */ #define WMFSnapshotVerifyViewForOSAndWritingDirection(view) \ FBSnapshotVerifyViewWithOptions((view), [[UIApplication sharedApplication] wmf_systemVersionAndWritingDirection], FBSnapshotTestCaseDefaultSuffixes(), 0.1); @interface FBSnapshotTestCase (WMFConvenience) - (void)wmf_verifyMultilineLabelWithText:(id)stringOrAttributedString width:(CGFloat)width; - (void)wmf_verifyCellWithIdentifier:(NSString *)identifier fromTableView:(UITableView *)tableView width:(CGFloat)width configuredWithBlock:(void (^)(UITableViewCell *))block; - (void)wmf_verifyView:(UIView *)view width:(CGFloat)width; - (void)wmf_verifyViewAtWindowWidth:(UIView *)view; @end
#import <FBSnapshotTestCase/FBSnapshotTestCase.h> #import "UIApplication+VisualTestUtils.h" /** * @function WMFSnapshotVerifyView * * Verify correct appearance of a given view. * * Search all folder suffixes, use default naming conventions. * * @param view The view to verify. */ #define WMFSnapshotVerifyView(view) FBSnapshotVerifyView((view), nil) /** * @function WMFSnapshotVerifyViewForOSAndWritingDirection * * Compares @c view with a reference image matching the current OS version & application writing direction (e.g. * "testLaysOutProperly_9.2_RTL@2x.png"). * * @param view The view to verify. */ #define WMFSnapshotVerifyViewForOSAndWritingDirection(view) \ FBSnapshotVerifyView((view), [[UIApplication sharedApplication] wmf_systemVersionAndWritingDirection]); @interface FBSnapshotTestCase (WMFConvenience) - (void)wmf_verifyMultilineLabelWithText:(id)stringOrAttributedString width:(CGFloat)width; - (void)wmf_verifyCellWithIdentifier:(NSString *)identifier fromTableView:(UITableView *)tableView width:(CGFloat)width configuredWithBlock:(void (^)(UITableViewCell *))block; - (void)wmf_verifyView:(UIView *)view width:(CGFloat)width; - (void)wmf_verifyViewAtWindowWidth:(UIView *)view; @end
Fix a long line in a comment
// ---------------------------------------------------------------------------- // pomodoro - Provides data structures and methods for manipulating pomodoros // Copyright (c) 2013 Jonathan Speicher (jon.speicher@gmail.com) // Licensed under the MIT license: http://opensource.org/licenses/MIT // ---------------------------------------------------------------------------- #pragma once // Defines the number of characters in a pomodoro time left display string. Note // that this does not account for the terminating NULL character. #define POMODORO_TIME_LEFT_STRING_NUM_CHARS 5 // Defines a pomodoro. Pomodoros consist primarily of the countdown timer and // associated display strings. typedef struct { unsigned int total_seconds_left; unsigned int minutes_left; unsigned int seconds_left; char time_left_string[POMODORO_TIME_LEFT_STRING_NUM_CHARS + 1]; } Pomodoro; // Initializes a pomodoro. This initializes the time remaining and sets the // display string appropriately. void pomodoro_init(Pomodoro* pomodoro); // Decrements the time remaining in the pomodoro by the number of seconds // specified. If the requested decrement is greater than the number of seconds // remaining, the time remaining is set to zero. void pomodoro_decrement_by_seconds(Pomodoro* pomodoro, unsigned int seconds);
// ---------------------------------------------------------------------------- // pomodoro - Provides data structures and methods for manipulating pomodoros // Copyright (c) 2013 Jonathan Speicher (jon.speicher@gmail.com) // Licensed under the MIT license: http://opensource.org/licenses/MIT // ---------------------------------------------------------------------------- #pragma once // Defines the number of characters in a pomodoro time left display string. // Note that this does not account for the terminating NULL character. #define POMODORO_TIME_LEFT_STRING_NUM_CHARS 5 // Defines a pomodoro. Pomodoros consist primarily of the countdown timer and // associated display strings. typedef struct { unsigned int total_seconds_left; unsigned int minutes_left; unsigned int seconds_left; char time_left_string[POMODORO_TIME_LEFT_STRING_NUM_CHARS + 1]; } Pomodoro; // Initializes a pomodoro. This initializes the time remaining and sets the // display string appropriately. void pomodoro_init(Pomodoro* pomodoro); // Decrements the time remaining in the pomodoro by the number of seconds // specified. If the requested decrement is greater than the number of seconds // remaining, the time remaining is set to zero. void pomodoro_decrement_by_seconds(Pomodoro* pomodoro, unsigned int seconds);
Change max gas value Swap CW/CCW pins
#define PIN_GAS_PEDAL A0 #define PIN_BATTERY_VOLTAGE A1 #define PIN_CW 5 #define PIN_CCW 6 #define PIN_SWITCH_FORWARDS 10 #define PIN_SWITCH_BACKWARDS 11 #define GAS_VALUE_MIN 446 #define GAS_VALUE_MAX 510 #define BATTERY_READING_12V 670 #define BATTERY_READING_6V 331 #define BATTERY_VOLTAGE_MIN 11 #define SPEED_MIN 0 #define SPEED_MAX_DIRECTION_CHANGE 15 #define SPEED_MAX_FORWARDS 255 #define SPEED_MAX_BACKWARDS 142 #define SPEED_CHANGE_PACE_DEFAULT 10
#define PIN_GAS_PEDAL A0 #define PIN_BATTERY_VOLTAGE A1 #define PIN_CW 6 #define PIN_CCW 5 #define PIN_SWITCH_FORWARDS 10 #define PIN_SWITCH_BACKWARDS 11 #define GAS_VALUE_MIN 446 #define GAS_VALUE_MAX 490 //510 #define BATTERY_READING_12V 670 #define BATTERY_READING_6V 331 #define BATTERY_VOLTAGE_MIN 11 #define SPEED_MIN 0 #define SPEED_MAX_DIRECTION_CHANGE 15 #define SPEED_MAX_FORWARDS 255 #define SPEED_MAX_BACKWARDS 142 #define SPEED_CHANGE_PACE_DEFAULT 10
Print hex in debug messages
// // Created by Jake Kinsella on 4/17/17. // #include "cpu.h" #include "registers.h" #include "ram.h" #include "matcher/matcher.h" void initialize() { initialize_registers(); initialize_ram(); } void cycle() { uint8_t instruction = read_byte_from_address(pc); printf("%d: %d\n", pc, instruction); // pc starts at instruction when passed to handle functions int index = match(instruction); if (index != -1) { InstructionTemplate template = get_registered_template(index); int dst_code = get_dst_code_from_opcode(instruction); int src_code = get_src_code_from_opcode(instruction); int rp_code = get_rp_code_from_opcode(instruction); run_instruction(dst_code, src_code, rp_code, template); } } void print_register_status() { printf("A: %d, B: %d, C: %d, D: %d, E: %d, F: %d, H: %d, L: %d, SP: %d\n", a, b, c, d, e, f, h, l, combine_bytes(s, p)); }
// // Created by Jake Kinsella on 4/17/17. // #include "cpu.h" #include "registers.h" #include "ram.h" #include "matcher/matcher.h" void initialize() { initialize_registers(); initialize_ram(); } void cycle() { uint8_t instruction = read_byte_from_address(pc); printf("0x%x: 0x%x\n", pc, instruction); // pc starts at instruction when passed to handle functions int index = match(instruction); if (index != -1) { InstructionTemplate template = get_registered_template(index); int dst_code = get_dst_code_from_opcode(instruction); int src_code = get_src_code_from_opcode(instruction); int rp_code = get_rp_code_from_opcode(instruction); run_instruction(dst_code, src_code, rp_code, template); } } void print_register_status() { printf("A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x, E: 0x%x, F: 0x%x, H: 0x%x, L: 0x%x, SP: 0x%x\n", a, b, c, d, e, f, h, l, combine_bytes(s, p)); }
Add a C program to github to test
#include <stdio.h> #include <stdlib.h> int main() { int a[100],i,j,n,t; printf("Enter the value of n (num. of ints)"); scanf("%d",&n); for(i=0;i<=n-1;i++) { printf("Enter a number:"); scanf("%d",&a[i]); printf(" Good, %d to go\n", n-1-i); } printf(" Start sorting ... \n"); // //Bubble sorting algorithm: // for(i=0;i<=n-2;i++){ for(j=0;j<=n-i-2;j++){ if(a[j]>a[j+1]){ t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } } for(i=0;i<=n-1;i++){ printf("%d,",a[i]); } printf(" Done! \n"); }
Add UNKNOWN annotations to 02/51
// from SV-COMP: nla-digbench-scaling/ps6-ll_valuebound5.c // contains deep integer expressions that shouldn't cause extremely exponential slowdown // when evaluated by base's eval_rv and EvalInt jointly // runs (as unknown) under 0.1s #include <assert.h> void assume_abort_if_not(int cond) { if(!cond) {abort();} } int main() { short k; long long y, x, c; assume_abort_if_not(k>=0 && k<=5); assume_abort_if_not(k <= 256); y = 0; x = 0; c = 0; while (1) { assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0); if (!(c < k)) break; c = c + 1; y = y + 1; x = y * y * y * y * y + x; } assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0); assert(k*y == y*y); return 0; }
// from SV-COMP: nla-digbench-scaling/ps6-ll_valuebound5.c // contains deep integer expressions that shouldn't cause extremely exponential slowdown // when evaluated by base's eval_rv and EvalInt jointly // runs (as unknown) under 0.1s #include <assert.h> void assume_abort_if_not(int cond) { if(!cond) {abort();} } int main() { short k; long long y, x, c; assume_abort_if_not(k>=0 && k<=5); assume_abort_if_not(k <= 256); y = 0; x = 0; c = 0; while (1) { assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0); // UNKNOWN (by design) if (!(c < k)) break; c = c + 1; y = y + 1; x = y * y * y * y * y + x; } assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0); // UNKNOWN (by design) assert(k*y == y*y); // UNKNOWN (by design) return 0; }
Add test for apron dummy privatization soundness
// SKIP PARAM: --set ana.activated[+] apron --set ana.apron.privatization dummy #include <pthread.h> #include <assert.h> int g; void *t_fun(void *arg) { // shouldn't have g, x, y in local apron state g = 43; int *p = arg; *p = 11; return NULL; } int main() { g = 42; int x = 10; int y = 20; pthread_t id; pthread_create(&id, NULL, t_fun, &x); // shouldn't have g, x, y in local apron state assert(g == 42); // UNKNOWN! assert(x == 10); // UNKNOWN! return 0; }
Fix a potentially unportable use of snprintf found by flawfinder.
#include <X11/X.h> #include <X11/Xatom.h> #include <X11/Xlib.h> #include <stdio.h> int main() { Display *display = XOpenDisplay(NULL); if (display == NULL) { fprintf(stderr, "Could not connect to $DISPLAY.\n"); return 1; } char buf[32]; snprintf(buf, sizeof(buf), "_NET_WM_CM_S%d", (int)DefaultScreen(display)); Atom atom = XInternAtom(display, buf, False); Window w = XGetSelectionOwner(display, atom); if (w == None) { fprintf(stderr, "No compositor detected.\n"); return 1; } printf("%#llx\n", (unsigned long long)w); return 0; }
#include <X11/X.h> #include <X11/Xatom.h> #include <X11/Xlib.h> #include <stdio.h> int main() { Display *display = XOpenDisplay(NULL); if (display == NULL) { fprintf(stderr, "Could not connect to $DISPLAY.\n"); return 1; } char buf[32]; // Flawfinder: ignore snprintf(buf, sizeof(buf), "_NET_WM_CM_S%d", // Flawfinder: ignore (int)DefaultScreen(display)); buf[sizeof(buf)-1] = 0; Atom atom = XInternAtom(display, buf, False); Window w = XGetSelectionOwner(display, atom); if (w == None) { fprintf(stderr, "No compositor detected.\n"); return 1; } printf("%#llx\n", (unsigned long long)w); return 0; }
Update driver version to 5.02.00-k11
/* * 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-k10"
/* * 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-k11"
Add some color for console output
#ifndef KAI_PLATFORM_GAME_CONTROLLER_H #define KAI_PLATFORM_GAME_CONTROLLER_H #include KAI_PLATFORM_INCLUDE(GameController.h) #endif // SHATTER_PLATFORM_GAME_CONTROLLER_H //EOF
#ifndef KAI_PLATFORM_GAME_CONTROLLER_H #define KAI_PLATFORM_GAME_CONTROLLER_H #include KAI_PLATFORM_INCLUDE(GameController.h) #endif //EOF
Fix memory leak in Python 3.2
#ifndef PYTHON3ADAPT_H #define PYTHON3ADAPT_H #if (PY_VERSION_HEX < 0x03000000) #define PyBytes_Check PyString_Check #define PyBytes_Size PyString_Size #define PyBytes_AsString PyString_AsString #define PyBytes_FromStringAndSize PyString_FromStringAndSize #define PyBytes_FromString PyString_FromString #else #define PyString_Check PyUnicode_Check #define PyString_Size PyUnicode_GET_SIZE #define PyString_FromStringAndSize PyUnicode_FromStringAndSize #define PyString_FromString PyUnicode_FromString #define PyInt_Check PyLong_Check #define PyInt_FromLong PyLong_FromLong #define PyInt_AsLong PyLong_AsLong #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyFile_Check(x) (1) #if (PY_VERSION_HEX < 0x03030000) #define PyString_AsString(x) PyBytes_AsString(PyUnicode_AsUTF8String(x)) #else #define PyString_AsString PyUnicode_AsUTF8 #endif #endif // (PY_VERSION_HEX < 0x03000000) #endif //PYTHON3ADAPT_H
#ifndef PYTHON3ADAPT_H #define PYTHON3ADAPT_H #if (PY_VERSION_HEX < 0x03000000) #define PyBytes_Check PyString_Check #define PyBytes_Size PyString_Size #define PyBytes_AsString PyString_AsString #define PyBytes_FromStringAndSize PyString_FromStringAndSize #define PyBytes_FromString PyString_FromString #else #define PyString_Check PyUnicode_Check #define PyString_Size PyUnicode_GET_SIZE #define PyString_FromStringAndSize PyUnicode_FromStringAndSize #define PyString_FromString PyUnicode_FromString #define PyInt_Check PyLong_Check #define PyInt_FromLong PyLong_FromLong #define PyInt_AsLong PyLong_AsLong #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyFile_Check(x) (1) #if (PY_VERSION_HEX < 0x03030000) #define PyString_AsString _PyUnicode_AsString #else #define PyString_AsString PyUnicode_AsUTF8 #endif #endif // (PY_VERSION_HEX < 0x03000000) #endif //PYTHON3ADAPT_H
Support for additional data to be passed for controller support (implemented on consoles).
#pragma once #include <functional> #include "halley/maths/vector2.h" #include "halley/core/input/input_device.h" namespace Halley { class InputJoystick; class InputTouch; class InputAPI { public: virtual ~InputAPI() {} virtual size_t getNumberOfKeyboards() const = 0; virtual std::shared_ptr<InputDevice> getKeyboard(int id = 0) const = 0; virtual size_t getNumberOfJoysticks() const = 0; virtual std::shared_ptr<InputJoystick> getJoystick(int id = 0) const = 0; virtual size_t getNumberOfMice() const = 0; virtual std::shared_ptr<InputDevice> getMouse(int id = 0) const = 0; virtual Vector<std::shared_ptr<InputTouch>> getNewTouchEvents() = 0; virtual Vector<std::shared_ptr<InputTouch>> getTouchEvents() = 0; virtual void setMouseRemapping(std::function<Vector2f(Vector2i)> remapFunction) = 0; virtual void requestControllerSetup(int numControllers, std::function<void(bool)> callback) { callback(true); } }; }
#pragma once #include <functional> #include "halley/maths/vector2.h" #include "halley/core/input/input_device.h" #include "halley/maths/colour.h" #include "halley/data_structures/maybe.h" namespace Halley { class InputJoystick; class InputTouch; class InputControllerData { public: Colour colour; String name; }; class InputAPI { public: virtual ~InputAPI() {} virtual size_t getNumberOfKeyboards() const = 0; virtual std::shared_ptr<InputDevice> getKeyboard(int id = 0) const = 0; virtual size_t getNumberOfJoysticks() const = 0; virtual std::shared_ptr<InputJoystick> getJoystick(int id = 0) const = 0; virtual size_t getNumberOfMice() const = 0; virtual std::shared_ptr<InputDevice> getMouse(int id = 0) const = 0; virtual Vector<std::shared_ptr<InputTouch>> getNewTouchEvents() = 0; virtual Vector<std::shared_ptr<InputTouch>> getTouchEvents() = 0; virtual void setMouseRemapping(std::function<Vector2f(Vector2i)> remapFunction) = 0; virtual void requestControllerSetup(int minControllers, int maxControllers, std::function<void(bool)> callback, Maybe<std::vector<InputControllerData>> controllerData = {}) { callback(true); } }; }
Move this in to an actual class.
#include <ruby.h> #include "client.h" static VALUE metrics_report_metric(VALUE self, VALUE user_id, VALUE key, VALUE val) { char * user_id_str, * key_str; int result = 0; user_id_str = RSTRING_PTR(user_id); key_str = RSTRING_PTR(key); /* Figure out what this belongs to and call the apprioriate one. */ switch(TYPE(val)) { case T_FIXNUM: result = metrici((const char *)user_id_str, (const char *)key_str, FIX2INT(val)); break; case T_FLOAT: result = metricd((const char *)user_id_str, (const char *)key_str, NUM2DBL(val)); break; default: rb_raise(rb_eTypeError, "Value is not a valid type. Expecting Fixnum or Float."); break; } return (result > 0) ? T_TRUE : T_FALSE; } void Init_metrics(void) { VALUE klass = rb_define_class("Metrics", rb_cObject); rb_define_singleton_method(klass, "report_metric", metrics_report_metric, 3); }
#include <ruby.h> #include "client.h" static VALUE rb_metrics_report_metric(VALUE self, VALUE user_id, VALUE key, VALUE val) { char * user_id_str, * key_str; int result = 0; user_id_str = RSTRING_PTR(user_id); key_str = RSTRING_PTR(key); /* Figure out what this belongs to and call the apprioriate one. */ switch(TYPE(val)) { case T_FIXNUM: result = metrici((const char *)user_id_str, (const char *)key_str, FIX2INT(val)); break; case T_FLOAT: result = metricd((const char *)user_id_str, (const char *)key_str, NUM2DBL(val)); break; default: rb_raise(rb_eTypeError, "Value is not a valid type. Expecting Fixnum or Float."); break; } return (result > 0) ? T_TRUE : T_FALSE; } static VALUE rb_metrics_initialize(VALUE self, VALUE hostname, VALUE port) { if(!FIXNUM_P(port)) { rb_raise(rb_eTypeError, "Port is not a Fixnum."); return T_FALSE; } rb_iv_set(self, "hostname", hostname); rb_iv_set(self, "port", port); return T_TRUE; } void Init_metrics(void) { VALUE rb_mMetrics = rb_define_module("Metrics"); VALUE rb_cNativeClient = rb_define_class_under(rb_mMetrics, "NativeClient", rb_cObject); rb_define_singleton_method(rb_cNativeClient, "report_metric", rb_metrics_report_metric, 3); rb_define_method(rb_cNativeClient, "initialize", rb_metrics_initialize, 2); }
Prepare for next version version
#define FLATCC_VERSION_TEXT "0.4.3" #define FLATCC_VERSION_MAJOR 0 #define FLATCC_VERSION_MINOR 4 #define FLATCC_VERSION_PATCH 3 /* 1 or 0 */ #define FLATCC_VERSION_RELEASED 1
#define FLATCC_VERSION_TEXT "0.5.0-pre" #define FLATCC_VERSION_MAJOR 0 #define FLATCC_VERSION_MINOR 5 #define FLATCC_VERSION_PATCH 0 /* 1 or 0 */ #define FLATCC_VERSION_RELEASED 0
Add framework for a new lasi plugin, currently disabled. The lasi library provides UTF-8 support in PostScript
/* $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 * **********************************************************/ #include "gvplugin.h" extern gvplugin_installed_t gvrender_lasi_types; static gvplugin_api_t apis[] = { {API_render, &gvrender_lasi_types}, {(api_t)0, 0}, }; gvplugin_library_t gvplugin_lasi_LTX_library = { "lasi", apis };
Use variable that cmake defines instead of specific one
#pragma once #ifndef INCL_NETWORKOS #define INCL_NETWORKOS #include <iostream> #include <memory> #include <string> #include <vector> #include <map> #include <cstdlib> #ifdef WIN32 #include <WinSock2.h> #include <WS2tcpip.h> #include <inaddr.h> #include <in6addr.h> #include <mstcpip.h> #define SHUT_RDWR SD_BOTH typedef int socklen_t; #pragma comment(lib, "ws2_32.lib") #undef SetPort #else #include <sys/ioctl.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <sys/socket.h> #include <netinet/ip.h> #include <netinet/ip6.h> #include <netinet/tcp.h> typedef unsigned int socklen_t; #define INVALID_SOCKET (-1) #endif #endif
#pragma once #ifndef INCL_NETWORKOS #define INCL_NETWORKOS #include <iostream> #include <memory> #include <string> #include <vector> #include <map> #include <cstdlib> #if defined(_MSC_VER) #include <WinSock2.h> #include <WS2tcpip.h> #include <inaddr.h> #include <in6addr.h> #include <mstcpip.h> #define SHUT_RDWR SD_BOTH typedef int socklen_t; #pragma comment(lib, "ws2_32.lib") #undef SetPort #else #include <sys/ioctl.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <sys/socket.h> #include <netinet/ip.h> #include <netinet/ip6.h> #include <netinet/tcp.h> typedef unsigned int socklen_t; #define INVALID_SOCKET (-1) #endif #endif
Add comments for clarification about memset implementation.
/** @file Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based Cryptographic Library. Copyright (c) 2010, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include <Base.h> #include <Library/BaseMemoryLib.h> /* OpenSSL will use floating point support, and C compiler produces the _fltused symbol by default. Simply define this symbol here to satisfy the linker. */ int _fltused = 1; /* Sets buffers to a specified character */ void * memset (void *dest, char ch, unsigned int count) { // // Declare the local variables that actually move the data elements as // volatile to prevent the optimizer from replacing this function with // the intrinsic memset() // volatile UINT8 *Pointer; Pointer = (UINT8 *)dest; while (count-- != 0) { *(Pointer++) = ch; } return dest; }
/** @file Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based Cryptographic Library. Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include <Base.h> #include <Library/BaseMemoryLib.h> /* OpenSSL will use floating point support, and C compiler produces the _fltused symbol by default. Simply define this symbol here to satisfy the linker. */ int _fltused = 1; /* Sets buffers to a specified character */ void * memset (void *dest, char ch, unsigned int count) { // // NOTE: Here we use one base implementation for memset, instead of the direct // optimized SetMem() wrapper. Because the IntrinsicLib has to be built // without whole program optimization option, and there will be some // potential register usage errors when calling other optimized codes. // // // Declare the local variables that actually move the data elements as // volatile to prevent the optimizer from replacing this function with // the intrinsic memset() // volatile UINT8 *Pointer; Pointer = (UINT8 *)dest; while (count-- != 0) { *(Pointer++) = ch; } return dest; }
Make get_nodes return a const&, and optimize uses of this function
#ifndef Bag_h #define Bag_h #include <unordered_set> #include <vector> #include <ostream> //A node in the tree deocomposition class Bag{ private: unsigned long id; std::vector<unsigned long> nodes; unsigned long parent=0; std::vector<unsigned long> children; public: Bag(unsigned long id, std::unordered_set<unsigned long> nodeset){ this->id = id; for(unsigned long node:nodeset) nodes.push_back(node); } void set_parent(unsigned long parent){ this->parent = parent; } void add_to_children(unsigned long node){ children.push_back(node); } std::vector<unsigned long>& get_nodes(){ return nodes; } friend std::ostream& operator<<(std::ostream& out, Bag& bag); }; std::ostream& operator<<(std::ostream& out, Bag& bag){ out << bag.id << std::endl; out << bag.nodes.size() << std::endl; for(auto node:bag.nodes) out << node << "\t"; out << std::endl; out << bag.parent << std::endl; out << bag.children.size() << std::endl; for(auto node:bag.children) out << node << "\t"; if(bag.children.size()>0) out << std::endl; return out; } #endif /* Bag_h */
#ifndef Bag_h #define Bag_h #include <unordered_set> #include <vector> #include <ostream> //A node in the tree deocomposition class Bag{ private: unsigned long id; std::vector<unsigned long> nodes; unsigned long parent=0; std::vector<unsigned long> children; public: Bag(unsigned long id, const std::unordered_set<unsigned long> &nodeset){ this->id = id; for(unsigned long node:nodeset) nodes.push_back(node); } void set_parent(unsigned long parent){ this->parent = parent; } void add_to_children(unsigned long node){ children.push_back(node); } std::vector<unsigned long>& get_nodes(){ return nodes; } friend std::ostream& operator<<(std::ostream& out, Bag& bag); }; std::ostream& operator<<(std::ostream& out, Bag& bag){ out << bag.id << std::endl; out << bag.nodes.size() << std::endl; for(auto node:bag.nodes) out << node << "\t"; out << std::endl; out << bag.parent << std::endl; out << bag.children.size() << std::endl; for(auto node:bag.children) out << node << "\t"; if(bag.children.size()>0) out << std::endl; return out; } #endif /* Bag_h */
Update comment for enum proc_log_ebreak_cli
// // riscv-processor-logging.h // #ifndef riscv_processor_logging_h #define riscv_processor_logging_h namespace riscv { /* Processor logging flags */ enum { proc_log_inst = 1<<0, /* Log instructions */ proc_log_operands = 1<<1, /* Log instruction operands */ proc_log_memory = 1<<2, /* Log memory mapping information */ proc_log_mmio = 1<<3, /* Log memory mapped IO */ proc_log_csr_mmode = 1<<4, /* Log machine status and control registers */ proc_log_csr_hmode = 1<<5, /* Log hypervisor status and control registers */ proc_log_csr_smode = 1<<6, /* Log supervisor status and control registers */ proc_log_csr_umode = 1<<7, /* Log user status and control registers */ proc_log_int_reg = 1<<8, /* Log integer registers */ proc_log_trap = 1<<9, /* Log processor traps */ proc_log_pagewalk = 1<<10, /* Log virtual memory page walks */ proc_log_ebreak_cli = 1<<11, /* Log virtual memory page walks */ proc_log_no_pseudo = 1<<12 /* Don't decode pseudoinstructions */ }; } #endif
// // riscv-processor-logging.h // #ifndef riscv_processor_logging_h #define riscv_processor_logging_h namespace riscv { /* Processor logging flags */ enum { proc_log_inst = 1<<0, /* Log instructions */ proc_log_operands = 1<<1, /* Log instruction operands */ proc_log_memory = 1<<2, /* Log memory mapping information */ proc_log_mmio = 1<<3, /* Log memory mapped IO */ proc_log_csr_mmode = 1<<4, /* Log machine status and control registers */ proc_log_csr_hmode = 1<<5, /* Log hypervisor status and control registers */ proc_log_csr_smode = 1<<6, /* Log supervisor status and control registers */ proc_log_csr_umode = 1<<7, /* Log user status and control registers */ proc_log_int_reg = 1<<8, /* Log integer registers */ proc_log_trap = 1<<9, /* Log processor traps */ proc_log_pagewalk = 1<<10, /* Log virtual memory page walks */ proc_log_ebreak_cli = 1<<11, /* Switch to debug CLI on ebreak */ proc_log_no_pseudo = 1<<12 /* Don't decode pseudoinstructions */ }; } #endif
Enable GZIP and ZLIB options in iPXE
#define CONSOLE_CMD /* Console command */ #define DIGEST_CMD /* Image crypto digest commands */ #define DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */ #define IMAGE_COMBOOT /* COMBOOT */ #define IMAGE_TRUST_CMD /* Image trust management commands */ #define NET_PROTO_IPV6 /* IPv6 protocol */ #define NSLOOKUP_CMD /* DNS resolving command */ #define NTP_CMD /* NTP commands */ #define PCI_CMD /* PCI commands */ #define REBOOT_CMD /* Reboot command */ #define TIME_CMD /* Time commands */ #define VLAN_CMD /* VLAN commands */
#define CONSOLE_CMD /* Console command */ #define DIGEST_CMD /* Image crypto digest commands */ #define DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */ #define IMAGE_COMBOOT /* COMBOOT */ #define IMAGE_TRUST_CMD /* Image trust management commands */ #define IMAGE_GZIP /* GZIP image support */ #define IMAGE_ZLIB /* ZLIB image support */ #define NET_PROTO_IPV6 /* IPv6 protocol */ #define NSLOOKUP_CMD /* DNS resolving command */ #define NTP_CMD /* NTP commands */ #define PCI_CMD /* PCI commands */ #define REBOOT_CMD /* Reboot command */ #define TIME_CMD /* Time commands */ #define VLAN_CMD /* VLAN commands */
Add missing file for variadic template version of TQObject::EmitVA
// @(#)root/base:$Id$ // Author: Philippe Canal 09/2014 /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_TQObjectEmitVA #define ROOT_TQObjectEmitVA // TQObject::EmitVA is implemented in its own header to break the // circular dependency between TQObject and TQConnection. #ifndef ROOT_TQObject #include "TQObject.h" #endif #ifndef ROOT_TQConnection #include "TQConnection.h" #endif template <typename... T> inline void TQObject::EmitVA(const char *signal_name, Int_t /* nargs */, const T&... params) { // Activate signal with variable argument list. // For internal use and for var arg EmitVA() in RQ_OBJECT.h. if (fSignalsBlocked || fgAllSignalsBlocked) return; TList classSigLists; CollectClassSignalLists(classSigLists, IsA()); if (classSigLists.IsEmpty() && !fListOfSignals) return; TString signal = CompressName(signal_name); TQConnection *connection = 0; // execute class signals TList *sigList; TIter nextSigList(&classSigLists); while ((sigList = (TList*) nextSigList())) { TIter nextcl((TList*) sigList->FindObject(signal)); while ((connection = (TQConnection*)nextcl())) { gTQSender = GetSender(); connection->ExecuteMethod(params...); } } if (!fListOfSignals) return; // execute object signals TIter next((TList*) fListOfSignals->FindObject(signal)); while (fListOfSignals && (connection = (TQConnection*)next())) { gTQSender = GetSender(); connection->ExecuteMethod(params...); } } #endif
Print sha1 of last commit
#include <glib.h> #include <glib/gstdio.h> #include <uuid/uuid.h> #include <wizbit/file.h> int main() { { struct wiz_file *file; wiz_vref vref; FILE *fp; /* Open up a new versioned file and create a couple of revisions */ file = wiz_file_open(WIZ_FILE_NEW, 0, 0); fp = wiz_file_get_handle(file); fprintf(fp, "I BELIEVE"); wiz_file_snapshot(file, vref); fprintf(fp, "\nNO RLY"); wiz_file_add_parent(file, vref); wiz_file_snapshot(file, vref); fprintf(fp, "\nI CAN HAS BELIEVE!?"); wiz_file_add_parent(file, vref); wiz_file_snapshot(file, vref); wiz_file_close(file); } return 0; }
#include <glib.h> #include <glib/gstdio.h> #include <uuid/uuid.h> #include <wizbit/vref.h> #include <wizbit/file.h> int main() { { wiz_vref_hexbuffer buffer; struct wiz_file *file; wiz_vref vref; FILE *fp; /* Open up a new versioned file and create a couple of revisions */ file = wiz_file_open(WIZ_FILE_NEW, 0, 0); fp = wiz_file_get_handle(file); fprintf(fp, "I BELIEVE"); wiz_file_snapshot(file, vref); fprintf(fp, "\nNO RLY"); wiz_file_add_parent(file, vref); wiz_file_snapshot(file, vref); fprintf(fp, "\nI CAN HAS BELIEVE!?"); wiz_file_add_parent(file, vref); wiz_file_snapshot(file, vref); printf("%s\n", wiz_vref_to_hex(vref, buffer)); wiz_file_close(file); } return 0; }
Fix angle_perftests compilation on Linux
// // Copyright (c) 2017 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // draw_call_perf_utils.h: // Common utilities for performance tests that need to do a large amount of draw calls. // #ifndef TESTS_TEST_UTILS_DRAW_CALL_PERF_UTILS_H_ #define TESTS_TEST_UTILS_DRAW_CALL_PERF_UTILS_H_ #include "angle_gl.h" // Returns program ID. The program is left in use and the uniforms are set to default values: // uScale = 0.5, uOffset = -0.5 GLuint SetupSimpleScaleAndOffsetProgram(); // Returns buffer ID filled with 2-component triangle coordinates. The buffer is left as bound. // Generates triangles like this with 2-component coordinates: // A // / \ // / \ // B-----C GLuint Create2DTriangleBuffer(size_t numTris, GLenum usage); // Creates an FBO with a texture color attachment. The texture is GL_RGBA and has dimensions // width/height. The FBO and texture ids are written to the out parameters. void CreateColorFBO(GLsizei width, GLsizei height, GLuint *fbo, GLuint *texture); #endif // TESTS_TEST_UTILS_DRAW_CALL_PERF_UTILS_H_
// // Copyright (c) 2017 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // draw_call_perf_utils.h: // Common utilities for performance tests that need to do a large amount of draw calls. // #ifndef TESTS_TEST_UTILS_DRAW_CALL_PERF_UTILS_H_ #define TESTS_TEST_UTILS_DRAW_CALL_PERF_UTILS_H_ #include <stddef.h> #include "angle_gl.h" // Returns program ID. The program is left in use and the uniforms are set to default values: // uScale = 0.5, uOffset = -0.5 GLuint SetupSimpleScaleAndOffsetProgram(); // Returns buffer ID filled with 2-component triangle coordinates. The buffer is left as bound. // Generates triangles like this with 2-component coordinates: // A // / \ // / \ // B-----C GLuint Create2DTriangleBuffer(size_t numTris, GLenum usage); // Creates an FBO with a texture color attachment. The texture is GL_RGBA and has dimensions // width/height. The FBO and texture ids are written to the out parameters. void CreateColorFBO(GLsizei width, GLsizei height, GLuint *fbo, GLuint *texture); #endif // TESTS_TEST_UTILS_DRAW_CALL_PERF_UTILS_H_
Fix test by fully specifying the platform.
// RUN: %clang -ccc-host-triple i386 -S -o - %s | \ // RUN: FileCheck --check-prefix=DEFAULT %s // DEFAULT: f0: // DEFAULT: pushl %ebp // DEFAULT: ret // DEFAULT: f1: // DEFAULT: pushl %ebp // DEFAULT: ret // RUN: %clang -ccc-host-triple i386 -S -o - -fomit-frame-pointer %s | \ // RUN: FileCheck --check-prefix=OMIT_ALL %s // OMIT_ALL: f0: // OMIT_ALL-NOT: pushl %ebp // OMIT_ALL: ret // OMIT_ALL: f1: // OMIT_ALL-NOT: pushl %ebp // OMIT_ALL: ret // RUN: %clang -ccc-host-triple i386 -S -o - -momit-leaf-frame-pointer %s | \ // RUN: FileCheck --check-prefix=OMIT_LEAF %s // OMIT_LEAF: f0: // OMIT_LEAF-NOT: pushl %ebp // OMIT_LEAF: ret // OMIT_LEAF: f1: // OMIT_LEAF: pushl %ebp // OMIT_LEAF: ret void f0() {} void f1() { f0(); }
// RUN: %clang -ccc-host-triple i386-apple-darwin -S -o - %s | \ // RUN: FileCheck --check-prefix=DARWIN %s // DARWIN: f0: // DARWIN: pushl %ebp // DARWIN: ret // DARWIN: f1: // DARWIN: pushl %ebp // DARWIN: ret // RUN: %clang -ccc-host-triple i386-pc-linux-gnu -S -o - %s | \ // RUN: FileCheck --check-prefix=LINUX %s // LINUX: f0: // LINUX-NOT: pushl %ebp // LINUX: ret // LINUX: f1: // LINUX: pushl %ebp // LINUX: ret // RUN: %clang -ccc-host-triple i386-darwin -S -o - -fomit-frame-pointer %s | \ // RUN: FileCheck --check-prefix=OMIT_ALL %s // OMIT_ALL: f0: // OMIT_ALL-NOT: pushl %ebp // OMIT_ALL: ret // OMIT_ALL: f1: // OMIT_ALL-NOT: pushl %ebp // OMIT_ALL: ret // RUN: %clang -ccc-host-triple i386-darwin -S -o - -momit-leaf-frame-pointer %s | \ // RUN: FileCheck --check-prefix=OMIT_LEAF %s // OMIT_LEAF: f0: // OMIT_LEAF-NOT: pushl %ebp // OMIT_LEAF: ret // OMIT_LEAF: f1: // OMIT_LEAF: pushl %ebp // OMIT_LEAF: ret void f0() {} void f1() { f0(); }
Make remove and initWithName:path:parent optional.
// // FileSystemObject.h // arc // // Created by Jerome Cheng on 1/4/13. // Copyright (c) 2013 nus.cs3217. All rights reserved. // #import <Foundation/Foundation.h> @protocol FileSystemObject <NSObject> @required // The name of this object. @property (strong, nonatomic) NSString *name; // This should be able to be used to reconstruct whatever is needed // to actually access the file/folder. @property (strong, nonatomic) NSString *identifier; // The parent of this object. @property (weak, nonatomic) id<FileSystemObject> parent; // Whether or not this object can be removed. @property BOOL isRemovable; // The size of this object. Folders should return the number of objects // within, Files their size in bytes. @property float size; // Initialises this object with the given name, path, and parent. - (id)initWithName:(NSString *)name path:(NSString *)path parent:(id<FileSystemObject>)parent; // Returns the contents of this object. - (id<NSObject>)contents; // Removes this object. // Returns YES if successful, NO otherwise. // If NO is returned, the state of the object or its contents is unstable. - (BOOL)remove; @end
// // FileSystemObject.h // arc // // Created by Jerome Cheng on 1/4/13. // Copyright (c) 2013 nus.cs3217. All rights reserved. // #import <Foundation/Foundation.h> @protocol FileSystemObject <NSObject> @required // The name of this object. @property (strong, nonatomic) NSString *name; // This should be able to be used to reconstruct whatever is needed // to actually access the file/folder. @property (strong, nonatomic) NSString *identifier; // The parent of this object. @property (weak, nonatomic) id<FileSystemObject> parent; // Whether or not this object can be removed. @property BOOL isRemovable; // The size of this object. Folders should return the number of objects // within, Files their size in bytes. @property float size; // Returns the contents of this object. - (id<NSObject>)contents; @optional // Removes this object. // Returns YES if successful, NO otherwise. // If NO is returned, the state of the object or its contents is unstable. - (BOOL)remove; // Initialises this object with the given name, path, and parent. - (id)initWithName:(NSString *)name path:(NSString *)path parent:(id<FileSystemObject>)parent; @end
Fix compiler warning from xfs_file_compat_invis_ioctl prototype.
/* * Copyright (c) 2004-2005 Silicon Graphics, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __XFS_IOCTL32_H__ #define __XFS_IOCTL32_H__ extern long xfs_file_compat_ioctl(struct file *, unsigned, unsigned long); extern long xfs_file_compat_invis_ioctl(struct file *, unsigned, unsigned); #endif /* __XFS_IOCTL32_H__ */
/* * Copyright (c) 2004-2005 Silicon Graphics, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __XFS_IOCTL32_H__ #define __XFS_IOCTL32_H__ extern long xfs_file_compat_ioctl(struct file *, unsigned, unsigned long); extern long xfs_file_compat_invis_ioctl(struct file *, unsigned, unsigned long); #endif /* __XFS_IOCTL32_H__ */
Add test case for -fexceptions
// RUN: clang -fexceptions -emit-llvm -o - %s | grep "@foo() {" | count 1 // RUN: clang -emit-llvm -o - %s | grep "@foo() nounwind {" | count 1 int foo(void) { }
Update driver version to 5.03.00-k3
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2012 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.03.00-k2"
/* * QLogic iSCSI HBA Driver * Copyright (c) 2003-2012 QLogic Corporation * * See LICENSE.qla4xxx for copyright and licensing details. */ #define QLA4XXX_DRIVER_VERSION "5.03.00-k3"
Add wave header analyzer test
#include <stdio.h> #include <stdlib.h> int main(){ unsigned char header[44]; FILE * wavfile; wavfile = fopen("test.wav", "r"); for(int i = 0; i < 44; i++){ fscanf(wavfile, "%c", &header[i]); } fclose(wavfile); for(int i = 0; i < 44; i++){ printf("%x\n", header[i]); } return 0; }
Update the files referred to by the linter.
/* Copyright 2022 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_CORE_CONFIG_FLAG_DEFS_H_ #define TENSORFLOW_CORE_CONFIG_FLAG_DEFS_H_ #include "tensorflow/core/config/flags.h" namespace tensorflow { namespace flags { class Flags { public: // Test only flags. See flags_test.cc for example usage. TF_DECLARE_FLAG(test_only_experiment_1, true, "Test only experiment 1."); TF_DECLARE_FLAG(test_only_experiment_2, false, "Test only experiment 2."); // Declare flags below here. // LINT.IfChange TF_DECLARE_FLAG(graph_building_optimization, false, "Optimize graph building for faster tf.function tracing."); // LINT.ThenChange(//tensorflow/core/config/flag_defs.h) }; Flags& Global(); } // namespace flags } // namespace tensorflow #endif // TENSORFLOW_CORE_CONFIG_FLAG_DEFS_H_
/* Copyright 2022 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_CORE_CONFIG_FLAG_DEFS_H_ #define TENSORFLOW_CORE_CONFIG_FLAG_DEFS_H_ #include "tensorflow/core/config/flags.h" namespace tensorflow { namespace flags { class Flags { public: // Test only flags. See flags_test.cc for example usage. TF_DECLARE_FLAG(test_only_experiment_1, true, "Test only experiment 1."); TF_DECLARE_FLAG(test_only_experiment_2, false, "Test only experiment 2."); // Declare flags below here. // LINT.IfChange TF_DECLARE_FLAG(graph_building_optimization, false, "Optimize graph building for faster tf.function tracing."); // LINT.ThenChange(//tensorflow/core/config/flags_api_wrapper.cc) }; Flags& Global(); } // namespace flags } // namespace tensorflow #endif // TENSORFLOW_CORE_CONFIG_FLAG_DEFS_H_
Update Skia milestone to 82
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 81 #endif
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SK_MILESTONE #define SK_MILESTONE 82 #endif
Add turing_try function for handling errors
#include <stdio.h> #include <stdlib.h> #include "turing.h" #define MAX_PROGRAM_LENGTH 32 int main() { int status; Turing *turing; status = 0; turing = init_turing(); status = execute_instruction(turing, "0 110\n1 110"); if (TURING_ERROR == status) { fprintf(stderr, "Exiting\n"); return 1; } else if (TURING_HALT) { printf("Program reached halt state!\n"); } free_turing(turing); return 0; }
#include <stdio.h> #include <stdlib.h> #include "turing.h" #define MAX_PROGRAM_LENGTH 32 #define turing_try(statement) status = statement;\ if (TURING_ERROR == status) {\ return 1;\ } int main() { int status; Turing *turing; status = 0; turing = init_turing(); status = execute_instruction(turing, "0 110\n1 110"); if (TURING_ERROR == status) { fprintf(stderr, "Exiting\n"); return 1; } else if (TURING_HALT) { printf("Program reached halt state!\n"); } free_turing(turing); return 0; }
Remove methods from TBAVC that we no longer want to expose publically
// // TBAViewController.h // the-blue-alliance // // Created by Zach Orr on 4/28/16. // Copyright © 2016 The Blue Alliance. All rights reserved. // #import <UIKit/UIKit.h> @class TBAPersistenceController, TBARefreshViewController; @interface TBAViewController : UIViewController @property (nonnull, readonly) TBAPersistenceController *persistenceController; @property (nullable, nonatomic, strong) NSArray<TBARefreshViewController *> *refreshViewControllers; @property (nullable, nonatomic, strong) NSArray<UIView *> *containerViews; @property (nullable, nonatomic, strong) IBOutlet UISegmentedControl *segmentedControl; @property (nullable, nonatomic, strong) IBOutlet UIView *segmentedControlView; @property (nullable, nonatomic, strong) IBOutlet UILabel *navigationTitleLabel; @property (nullable, nonatomic, strong) IBOutlet UILabel *navigationSubtitleLabel; - (void)showView:(nonnull UIView *)showView; - (void)updateInterface; - (void)cancelRefreshes; @end
// // TBAViewController.h // the-blue-alliance // // Created by Zach Orr on 4/28/16. // Copyright © 2016 The Blue Alliance. All rights reserved. // #import <UIKit/UIKit.h> @class TBAPersistenceController, TBARefreshViewController; @interface TBAViewController : UIViewController @property (nonnull, readonly) TBAPersistenceController *persistenceController; @property (nullable, nonatomic, strong) NSArray<TBARefreshViewController *> *refreshViewControllers; @property (nullable, nonatomic, strong) NSArray<UIView *> *containerViews; @property (nullable, nonatomic, strong) IBOutlet UISegmentedControl *segmentedControl; @property (nullable, nonatomic, strong) IBOutlet UIView *segmentedControlView; @property (nullable, nonatomic, strong) IBOutlet UILabel *navigationTitleLabel; @property (nullable, nonatomic, strong) IBOutlet UILabel *navigationSubtitleLabel; - (void)cancelRefreshes; @end
Fix forward declaration of idris_closeDir
#ifndef __IDRIS_DIRECTORY_H #define __IDRIS_DIRECTORY_H char* idris2_currentDirectory(); int idris2_changeDir(char* dir); int idris2_createDir(char* dir); void* idris2_openDir(char* dir); void idris2_closeDIr(void* d); int idris2_removeDir(char* path); char* idris2_nextDirEntry(void* d); #endif
#ifndef __IDRIS_DIRECTORY_H #define __IDRIS_DIRECTORY_H char* idris2_currentDirectory(); int idris2_changeDir(char* dir); int idris2_createDir(char* dir); void* idris2_openDir(char* dir); void idris2_closeDir(void* d); int idris2_removeDir(char* path); char* idris2_nextDirEntry(void* d); #endif
Remove http form for mass, only manipulate local mass
inherit "/lib/string/sprint"; inherit "../support"; static string thing_form(object obj) { string buffer; buffer = "<p>Fun little boxes:</p>\n"; buffer += "<form action=\"object.lpc?obj=" + object2string(obj) + "\" method=\"post\">\n"; buffer += "Mass: <input type=\"text\" name=\"mass\" value=\"" + mixed_sprint(obj->query_mass()) + "\"/>\n"; buffer += "<input type=\"submit\" value=\"change mass\" />\n"; buffer += "</form>\n"; buffer += "<form action=\"object.lpc?obj=" + object2string(obj) + "\" method=\"post\">\n"; buffer += "Local mass: <input type=\"text\" name=\"localmass\" value=\"" + mixed_sprint(obj->query_local_mass()) + "\"/>\n"; buffer += "<input type=\"submit\" value=\"change local mass\" />\n"; buffer += "</form>\n"; return oinfobox("Configuration", 2, buffer); }
inherit "/lib/string/sprint"; inherit "../support"; static string thing_form(object obj) { string buffer; buffer = "<p>Fun little boxes:</p>\n"; buffer += "<form action=\"object.lpc?obj=" + object2string(obj) + "\" method=\"post\">\n"; buffer += "Local mass: <input type=\"text\" name=\"localmass\" value=\"" + mixed_sprint(obj->query_local_mass()) + "\"/>\n"; buffer += "<input type=\"submit\" value=\"change local mass\" />\n"; buffer += "</form>\n"; return oinfobox("Configuration", 2, buffer); }
Add source code documentation for the RocksDB Cuckoo Table Options class
// // RocksDBCuckooTableOptions.h // ObjectiveRocks // // Created by Iska on 04/01/15. // Copyright (c) 2015 BrainCookie. All rights reserved. // #import <Foundation/Foundation.h> @interface RocksDBCuckooTableOptions : NSObject @property (nonatomic, assign) double hashTableRatio; @property (nonatomic, assign) uint32_t maxSearchDepth; @property (nonatomic, assign) uint32_t cuckooBlockSize; @property (nonatomic, assign) BOOL identityAsFirstHash; @property (nonatomic, assign) BOOL useModuleHash; @end
// // RocksDBCuckooTableOptions.h // ObjectiveRocks // // Created by Iska on 04/01/15. // Copyright (c) 2015 BrainCookie. All rights reserved. // #import <Foundation/Foundation.h> @interface RocksDBCuckooTableOptions : NSObject /** @brief Determines the utilization of hash tables. Smaller values result in larger hash tables with fewer collisions. */ @property (nonatomic, assign) double hashTableRatio; /** @brief A property used by builder to determine the depth to go to to search for a path to displace elements in case of collision. Higher values result in more efficient hash tables with fewer lookups but take more time to build. */ @property (nonatomic, assign) uint32_t maxSearchDepth; /** @brief In case of collision while inserting, the builder attempts to insert in the next `cuckooBlockSize` locations before skipping over to the next Cuckoo hash function. This makes lookups more cache friendly in case of collisions. */ @property (nonatomic, assign) uint32_t cuckooBlockSize; /** @brief If this option is enabled, user key is treated as uint64_t and its value is used as hash value directly. This option changes builder's behavior. Reader ignore this option and behave according to what specified in table property. */ @property (nonatomic, assign) BOOL identityAsFirstHash; /** @brief If this option is set to true, module is used during hash calculation. This often yields better space efficiency at the cost of performance. If this optino is set to false, # of entries in table is constrained to be power of two, and bit and is used to calculate hash, which is faster in general. */ @property (nonatomic, assign) BOOL useModuleHash; @end
Use bit shift for flag values not constant values.
/* * lock_driver_lockd.h: Locking for domain lifecycle operations * * Copyright (C) 2010-2011 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, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * <http://www.gnu.org/licenses/>. * */ #ifndef __VIR_LOCK_DRIVER_LOCKD_H__ # define __VIR_LOCK_DRIVER_LOCKD_H__ enum virLockSpaceProtocolAcquireResourceFlags { VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED = 1, VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE = 2, }; #endif /* __VIR_LOCK_DRIVER_LOCKD_H__ */
/* * lock_driver_lockd.h: Locking for domain lifecycle operations * * Copyright (C) 2010-2011 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, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * <http://www.gnu.org/licenses/>. * */ #ifndef __VIR_LOCK_DRIVER_LOCKD_H__ # define __VIR_LOCK_DRIVER_LOCKD_H__ enum virLockSpaceProtocolAcquireResourceFlags { VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED = (1 << 0), VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE = (1 << 1), }; #endif /* __VIR_LOCK_DRIVER_LOCKD_H__ */
Add folder with is prime program Krastian Tomov No 21 10g
#include <stdio.h> int is_prime(int *); int main() { int answer; int number; int *refernce_of_a = &number; scanf("%d",refernce_of_a); answer = is_prime(&number); printf("%d",answer); } int is_prime(int *numb) { int counter; for(counter = 0; counter <= *numb/2; counter++) { if(counter * counter == *numb) { return 0; } } return 1; }
Add test case for indexing into an array, since the array index can be an expression
extern void print_int(int i); extern void print_string(char c[]); int return1(void) { return 1; } void main(void){ int myInt; int intArr[3]; /* need assignToArry to work for this to work */ intArr[0] = 999; intArr[1] = 100; intArr[2] = 200; /* test index from a variable */ myInt = 1; print_string("should get 100\ngot: "); print_int(intArr[myInt]); print_string("\n\n"); /* test index from a function call */ print_string("should get 100\ngot: "); print_int(intArr[return1()]); print_string("\n\n"); /* test index from a complex expr */ print_string("should get 100\ngot: "); print_int(intArr[return1() + 4 / 8]); print_string("\n\n"); intArr[return1()] = 77; print_string("should get 77\ngot: "); print_int(intArr[1]); print_string("\n\n"); }
Use comments to structure file
/** * @file * * @brief Tests for mini plugin * * @copyright BSD License (see doc/LICENSE.md or http://www.libelektra.org) * */ #include "values.h" #include <stdlib.h> #include <string.h> #include <kdbconfig.h> #include <tests_plugin.h> static void test_basics () { printf ("• Test basic functionality of plugin\n"); Key * parentKey = keyNew ("system/elektra/modules/mini", KEY_END); KeySet * conf = ksNew (0, KS_END); PLUGIN_OPEN ("mini"); KeySet * ks = ksNew (0, KS_END); succeed_if (plugin->kdbGet (plugin, ks, parentKey) == KEYSET_MODIFIED, "Could not retrieve plugin contract"); keyDel (parentKey); ksDel (ks); PLUGIN_CLOSE (); } int main (int argc, char ** argv) { printf ("mINI Tests 🚙\n"); printf ("==============\n\n"); init (argc, argv); test_basics (); printf ("\nResults: %d Test%s done — %d error%s.\n", nbTest, nbTest != 1 ? "s" : "", nbError, nbError != 1 ? "s" : ""); return nbError; }
/** * @file * * @brief Tests for mini plugin * * @copyright BSD License (see doc/LICENSE.md or http://www.libelektra.org) * */ /* -- Imports --------------------------------------------------------------------------------------------------------------------------- */ #include "values.h" #include <stdlib.h> #include <string.h> #include <kdbconfig.h> #include <tests_plugin.h> /* -- Functions ------------------------------------------------------------------------------------------------------------------------- */ static void test_basics () { printf ("• Test basic functionality of plugin\n"); Key * parentKey = keyNew ("system/elektra/modules/mini", KEY_END); KeySet * conf = ksNew (0, KS_END); PLUGIN_OPEN ("mini"); KeySet * ks = ksNew (0, KS_END); succeed_if (plugin->kdbGet (plugin, ks, parentKey) == KEYSET_MODIFIED, "Could not retrieve plugin contract"); keyDel (parentKey); ksDel (ks); PLUGIN_CLOSE (); } /* -- Main ------------------------------------------------------------------------------------------------------------------------------ */ int main (int argc, char ** argv) { printf ("mINI Tests 🚙\n"); printf ("==============\n\n"); init (argc, argv); test_basics (); printf ("\nResults: %d Test%s done — %d error%s.\n", nbTest, nbTest != 1 ? "s" : "", nbError, nbError != 1 ? "s" : ""); return nbError; }
Fix helpers multiple defined symbols
#ifndef QTPROMISE_QPROMISEHELPERS_H #define QTPROMISE_QPROMISEHELPERS_H // QtPromise #include "qpromise_p.h" namespace QtPromise { template <typename T> typename QtPromisePrivate::PromiseDeduce<T>::Type qPromise(T&& value) { using namespace QtPromisePrivate; using Promise = typename PromiseDeduce<T>::Type; return Promise([&]( const QPromiseResolve<typename Promise::Type>& resolve, const QPromiseReject<typename Promise::Type>& reject) { PromiseFulfill<T>::call(std::forward<T>(value), resolve, reject); }); } QPromise<void> qPromise() { return QPromise<void>([]( const QPromiseResolve<void>& resolve) { resolve(); }); } template <typename T> QPromise<QVector<T> > qPromiseAll(const QVector<QPromise<T> >& promises) { return QPromise<T>::all(promises); } QPromise<void> qPromiseAll(const QVector<QPromise<void> >& promises) { return QPromise<void>::all(promises); } } // namespace QtPromise #endif // QTPROMISE_QPROMISEHELPERS_H
#ifndef QTPROMISE_QPROMISEHELPERS_H #define QTPROMISE_QPROMISEHELPERS_H // QtPromise #include "qpromise_p.h" namespace QtPromise { template <typename T> static inline typename QtPromisePrivate::PromiseDeduce<T>::Type qPromise(T&& value) { using namespace QtPromisePrivate; using Promise = typename PromiseDeduce<T>::Type; return Promise([&]( const QPromiseResolve<typename Promise::Type>& resolve, const QPromiseReject<typename Promise::Type>& reject) { PromiseFulfill<T>::call(std::forward<T>(value), resolve, reject); }); } static inline QPromise<void> qPromise() { return QPromise<void>([]( const QPromiseResolve<void>& resolve) { resolve(); }); } template <typename T> static inline QPromise<QVector<T> > qPromiseAll(const QVector<QPromise<T> >& promises) { return QPromise<T>::all(promises); } static inline QPromise<void> qPromiseAll(const QVector<QPromise<void> >& promises) { return QPromise<void>::all(promises); } } // namespace QtPromise #endif // QTPROMISE_QPROMISEHELPERS_H
Add a test case showing that CIL forgets to remove the "const" qualifier on structures within structures. When it subsequently converts initializations of such structures into assignments, the resulting C code appears to be assigning into a const field. That produces warnings or errors from the C compiler.
struct inner { int field; }; struct outer { const struct inner inner; }; int main() { struct outer outer = { { 0 } }; return outer.inner.field; }
Add inl and outl functions
#include <stdint.h> void outb(uint16_t port, uint8_t value) { asm volatile ("outb %1, %0" : : "dN" (port), "a" (value)); } unsigned char inb(uint16_t port) { unsigned char ret; asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port)); return ret; }
#include <stdint.h> void outb(uint16_t port, uint8_t value) { asm volatile ("outb %1, %0" : : "dN" (port), "a" (value)); } unsigned char inb(uint16_t port) { unsigned char ret; asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port)); return ret; } void outl(uint16_t port, uint32_t value) { asm volatile ("outl %1, %0" : : "dN" (port), "a" (value)); } uint32_t inl(uint16_t port) { uint32_t ret; asm volatile ("inl %1, %0" : "=a" (ret) : "dN" (port)); return ret; }
Fix wrong member declaration which shadows parent class.
// -*- C++ -*- #ifndef _writer_verilog_axi_master_controller_h_ #define _writer_verilog_axi_master_controller_h_ #include "writer/verilog/axi/axi_controller.h" namespace iroha { namespace writer { namespace verilog { namespace axi { class MasterController : public AxiController { public: MasterController(const IResource &res, bool reset_polarity); ~MasterController(); void Write(ostream &os); static void AddPorts(Module *mod, bool r, bool w, string *s); private: void OutputFsm(ostream &os); void ReaderFsm(ostream &os); void WriterFsm(ostream &os); unique_ptr<Ports> ports_; bool r_, w_; int burst_len_; }; } // namespace axi } // namespace verilog } // namespace writer } // namespace iroha #endif // _writer_verilog_axi_master_controller_h_
// -*- C++ -*- #ifndef _writer_verilog_axi_master_controller_h_ #define _writer_verilog_axi_master_controller_h_ #include "writer/verilog/axi/axi_controller.h" namespace iroha { namespace writer { namespace verilog { namespace axi { class MasterController : public AxiController { public: MasterController(const IResource &res, bool reset_polarity); ~MasterController(); void Write(ostream &os); static void AddPorts(Module *mod, bool r, bool w, string *s); private: void OutputFsm(ostream &os); void ReaderFsm(ostream &os); void WriterFsm(ostream &os); bool r_, w_; int burst_len_; }; } // namespace axi } // namespace verilog } // namespace writer } // namespace iroha #endif // _writer_verilog_axi_master_controller_h_
Add program to list blocks of a file
/* * fibmap - List blocks of a file * * Written in 2012 by Prashant P Shah <pshah.mumbai@gmail.com> * * To the extent possible under law, the author(s) have dedicated * all copyright and related and neighboring rights to this software * to the public domain worldwide. This software is distributed * without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication * along with this software. * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <linux/fs.h> #include <assert.h> int main(int argc, char **argv) { int fd, i, block, blocksize, blkcnt; struct stat st; assert(argv[1] != NULL); fd = open(argv[1], O_RDONLY); if (fd <= 0) { perror("error opening file"); goto end; } if (ioctl(fd, FIGETBSZ, &blocksize)) { perror("FIBMAP ioctl failed"); goto end; } if (fstat(fd, &st)) { perror("fstat error"); goto end; } blkcnt = (st.st_size + blocksize - 1) / blocksize; printf("File %s size %d blocks %d blocksize %d\n", argv[1], (int)st.st_size, blkcnt, blocksize); for (i = 0; i < blkcnt; i++) { block = i; if (ioctl(fd, FIBMAP, &block)) { perror("FIBMAP ioctl failed"); } printf("%3d %10d\n", i, block); } end: close(fd); return 0; }
Use flags that will actually work when testing.
#include <stdio.h> #include <string.h> #include <efivar.h> #define TEST_GUID EFI_GUID(0x84be9c3e,0x8a32,0x42c0,0x891c,0x4c,0xd3,0xb0,0x72,0xbe,0xcc) static void clean_test_environment(void) { efi_del_variable(TEST_GUID, "small"); efi_del_variable(TEST_GUID, "large"); } #define report_error(str) ({fprintf(stderr, str); goto fail;}) int main(void) { if (!efi_variables_supported()) { printf("UEFI variables not supported on this machine.\n"); return 0; } clean_test_environment(); int ret = 1; char smallvalue[] = "smallvalue"; int rc; rc = efi_set_variable(TEST_GUID, "small", smallvalue, strlen(smallvalue)+1, EFI_VARIABLE_RUNTIME_ACCESS); if (rc < 0) report_error("small value test failed: %m\n"); ret = 0; fail: return ret; }
#include <stdio.h> #include <string.h> #include <efivar.h> #define TEST_GUID EFI_GUID(0x84be9c3e,0x8a32,0x42c0,0x891c,0x4c,0xd3,0xb0,0x72,0xbe,0xcc) static void clean_test_environment(void) { efi_del_variable(TEST_GUID, "small"); efi_del_variable(TEST_GUID, "large"); } #define report_error(str) ({fprintf(stderr, str); goto fail;}) int main(void) { if (!efi_variables_supported()) { printf("UEFI variables not supported on this machine.\n"); return 0; } clean_test_environment(); int ret = 1; char smallvalue[] = "smallvalue"; int rc; rc = efi_set_variable(TEST_GUID, "small", smallvalue, strlen(smallvalue)+1, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE); if (rc < 0) report_error("small value test failed: %m\n"); ret = 0; fail: return ret; }
Make test robust to changes in prefix/avoid hardcoded line numbers
// REQUIRES: x86_64-linux // RUN: %host_cc -O0 -g %s -o %t 2>&1 // RUN: %t 2>&1 | llvm-symbolizer -print-source-context-lines=5 -obj=%t | FileCheck %s #include <stdio.h> int inc(int a) { return a + 1; } int main() { printf("%p\n", inc); return 0; } // CHECK: inc // CHECK: print_context.c:7 // CHECK: 5 : #include // CHECK: 6 : // CHECK: 7 >: int inc // CHECK: 8 : return // CHECK: 9 : }
// REQUIRES: x86_64-linux // RUN: %host_cc -O0 -g %s -o %t 2>&1 // RUN: %t 2>&1 | llvm-symbolizer -print-source-context-lines=5 -obj=%t | FileCheck %s // CHECK: inc // CHECK: print_context.c:[[@LINE+9]] // CHECK: [[@LINE+6]] : #include // CHECK: [[@LINE+6]] : // CHECK: [[@LINE+6]] >: int inc // CHECK: [[@LINE+6]] : return // CHECK: [[@LINE+6]] : } #include <stdio.h> int inc(int a) { return a + 1; } int main() { printf("%p\n", inc); return 0; }
Add file to replace android_framework_defines.gni
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkUserConfigManual_DEFINED #define SkUserConfigManual_DEFINED #define GR_GL_CUSTOM_SETUP_HEADER "gl/GrGLConfig_chrome.h" #define GR_TEST_UTILS 1 #define SKIA_DLL #define SK_BUILD_FOR_ANDROID_FRAMEWORK #define SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024) #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024) #define SK_USE_FREETYPE_EMBOLDEN // Legacy flags #define SK_IGNORE_GPU_DITHER #define SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS #define SK_LEGACY_SWEEP_GRADIENT #define SK_SUPPORT_DEPRECATED_CLIPOPS #define SK_SUPPORT_LEGACY_BILERP_IGNORING_HACK // Needed until we fix https://bug.skia.org/2440 #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG #define SK_SUPPORT_LEGACY_DRAWFILTER #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER #define SK_SUPPORT_LEGACY_GRADIENT_DITHERING #define SK_SUPPORT_LEGACY_SHADER_ISABITMAP #define SK_SUPPORT_LEGACY_TILED_BITMAPS #endif // SkUserConfigManual_DEFINED
Add hashing for AbstractExpression, TupleValueExpression, ConstValueExpression
// // Created by patrick on 31/03/17. // #ifndef PELOTON_HASH_UTIL_H #define PELOTON_HASH_UTIL_H #endif //PELOTON_HASH_UTIL_H
Remove trailing whitespace (especially after a \ which should be trailing)
// Parse diagnostic arguments in the driver // PR12181 // RUN: not %clang -target x86_64-apple-darwin10 \ // RUN: -fsyntax-only -fzyzzybalubah \ // RUN: -Werror=unused-command-line-argument %s // RUN: not %clang -target x86_64-apple-darwin10 \ // RUN: -fsyntax-only -fzyzzybalubah -Werror %s
// Parse diagnostic arguments in the driver // PR12181 // RUN: not %clang -target x86_64-apple-darwin10 \ // RUN: -fsyntax-only -fzyzzybalubah \ // RUN: -Werror=unused-command-line-argument %s // RUN: not %clang -target x86_64-apple-darwin10 \ // RUN: -fsyntax-only -fzyzzybalubah -Werror %s
Add algorithm for greatest common divisor
#ifndef __gcd_h_included__ #define __gcd_h_included__ // Euclid's algorithm for computing the greatest common divisor template<typename I> I gcd(I a, I b) { while (a > 0 && b > 0) { if (a > b) a -= b; else b -= a; } return a == 0 ? b : a; } #endif
Add best guess at a method that returns an array with the names of all sources
/* * Copyright 2008 Markus Prinz * Released unter an MIT licence * */ #include <ruby.h> #include <CoreMIDI/CoreMIDI.h> VALUE callback_proc = Qnil; MIDIPortRef inPort = NULL; MIDIClientRef client = NULL; static void RbMIDIReadProc(const MIDIPacketList* packetList, void* readProcRefCon, void* srcConnRefCon) { } void Init_rbcoremidi (void) { // Add the initialization code of your module here. }
/* * Copyright 2008 Markus Prinz * Released unter an MIT licence * */ #include <ruby.h> #include <CoreMIDI/CoreMIDI.h> VALUE callback_proc = Qnil; MIDIPortRef inPort = NULL; MIDIClientRef client = NULL; static void RbMIDIReadProc(const MIDIPacketList* packetList, void* readProcRefCon, void* srcConnRefCon) { } static VALUE t_sources(VALUE self) { int number_of_sources = MIDIGetNumberOfSources(); VALUE source_ary = rb_ary_new2(number_of_sources); for(int idx = 0; idx < number_of_sources; ++idx) { MIDIEndpointRef src = MIDIGetSource(idx); CFStringRef pname; char name[64]; MIDIObjectGetStringProperty(src, kMIDIPropertyName, pname); CFStringGetCString(pname, name, sizeof(name), 0); CFRelease(pname); rb_ary_push(source_ary, rb_str_new2(name)); } return source_ary; } void Init_rbcoremidi (void) { // Add the initialization code of your module here. }
Add incredibly lame solution to Exercise 1-11.
/* Exercise 1-11: How would you test the word count program? What kinds of * input are most likely to uncover bugs if there are any? */ #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { /* This is such a cheat. */ printf("Types of input that could be used to test a word counting program:\n"); printf(" - Input with no characters,\n"); printf(" - input with just one massive word that's MAX_INT letters long,\n"); printf(" - input with more than MAX_INT words,\n"); printf(" - input with varying whitespace to delimit words,\n"); printf(" - binary input (such as an image file),\n"); printf(" - and Unicode input.\n"); return EXIT_SUCCESS; }
Add function prototype for min_size_get.
#ifdef E_TYPEDEFS #else # ifndef E_SMART_RANDR_H # define E_SMART_RANDR_H Evas_Object *e_smart_randr_add(Evas *evas); void e_smart_randr_virtual_size_calc(Evas_Object *obj); void e_smart_randr_monitors_create(Evas_Object *obj); # endif #endif
#ifdef E_TYPEDEFS #else # ifndef E_SMART_RANDR_H # define E_SMART_RANDR_H Evas_Object *e_smart_randr_add(Evas *evas); void e_smart_randr_virtual_size_calc(Evas_Object *obj); void e_smart_randr_monitors_create(Evas_Object *obj); void e_smart_randr_min_size_get(Evas_Object *obj, Evas_Coord *mw, Evas_Coord *mh); # endif #endif
Add function declarations for Circular Lists.
#ifndef _LIBADT_CL_LIST_H #define _LIBADT_CL_LIST_H #include <adt_commons.h> #include <list.h> typedef list_root cl_list_root; struct _list_node { list_node *prev; // Pointer to prev list_node element. list_node *next; // Pointer to next list_node element. void *data; // Pointer to the element added on the list. }; /* * Create a empty list structure and set a destroy function for its elements. * The destroy argument gives a way to free the entire structure when we * call dl_list_destroy. For malloc/calloc data, free must be used. If data * is a struct with other members, a function designed to free its memory * must be provided. If the data is static or have another way to free its * memory, NULL must be set. * Complexity: O(1). */ cl_list_root * cl_list_create(t_destroyfunc destroyfunc); /* * Insert an element in the list after the current element indicated. * If *current is NULL, *data is appended on the head. * Complexity: O(1). */ int cl_list_insert_el_next(cl_list_root *list, list_node *current, void *data); /* * Insert an element in the list before the current element indicated. * If *current is NULL, *data is appended on the tail. * Complexity: O(1). */ int cl_list_insert_el_prev(cl_list_root *list, list_node *current, void *data); /* * Move an element after the newpos element indicated. * Complexity: O(1). */ int cl_list_move_el_next(cl_list_root *list, list_node *current, list_node *newpos); /* * Move an element before the newpos element indicated. * Complexity: O(1). */ int cl_list_move_el_prev(cl_list_root *list, list_node *current, list_node *newpos); /* * Change positions of the two elements on the list. * Complexity: O(1). */ int cl_list_swap_el(cl_list_root *list, list_node *el1, list_node *el2); /* * Remove the element in the head and save the respective data in **data. * Compĺexity: O(1). */ void * cl_list_rem_el(cl_list_root *list); /* * Destroy the list and its elements, if have any. If destroy function is provided, * it will be used. * Complexity: O(n). */ void cl_list_destroy(cl_list_root *list); #endif
Make block size a protected member of a block channel.
#ifndef BLOCK_CHANNEL_H #define BLOCK_CHANNEL_H class Action; class Buffer; class BlockChannel { protected: BlockChannel(void) { } public: virtual ~BlockChannel() { } virtual Action *close(EventCallback *) = 0; virtual Action *read(off_t, EventCallback *) = 0; virtual Action *write(off_t, Buffer *, EventCallback *) = 0; }; #endif /* !BLOCK_CHANNEL_H */
#ifndef BLOCK_CHANNEL_H #define BLOCK_CHANNEL_H class Action; class Buffer; class BlockChannel { protected: size_t bsize_; BlockChannel(size_t bsize) : bsize_(bsize) { } public: virtual ~BlockChannel() { } virtual Action *close(EventCallback *) = 0; virtual Action *read(off_t, EventCallback *) = 0; virtual Action *write(off_t, Buffer *, EventCallback *) = 0; }; #endif /* !BLOCK_CHANNEL_H */
Clean up some whitespace to be consistent with Python's C style.
/* Tuple object interface */ #ifndef Py_STRUCTSEQ_H #define Py_STRUCTSEQ_H #ifdef __cplusplus extern "C" { #endif typedef struct PyStructSequence_Field { char *name; char *doc; } PyStructSequence_Field; typedef struct PyStructSequence_Desc { char *name; char *doc; struct PyStructSequence_Field *fields; int n_in_sequence; } PyStructSequence_Desc; extern char* PyStructSequence_UnnamedField; PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc); PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); typedef struct { PyObject_VAR_HEAD PyObject *ob_item[1]; } PyStructSequence; /* Macro, *only* to be used to fill in brand new objects */ #define PyStructSequence_SET_ITEM(op, i, v) \ (((PyStructSequence *)(op))->ob_item[i] = v) #ifdef __cplusplus } #endif #endif /* !Py_STRUCTSEQ_H */
/* Tuple object interface */ #ifndef Py_STRUCTSEQ_H #define Py_STRUCTSEQ_H #ifdef __cplusplus extern "C" { #endif typedef struct PyStructSequence_Field { char *name; char *doc; } PyStructSequence_Field; typedef struct PyStructSequence_Desc { char *name; char *doc; struct PyStructSequence_Field *fields; int n_in_sequence; } PyStructSequence_Desc; extern char* PyStructSequence_UnnamedField; PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc); PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); typedef struct { PyObject_VAR_HEAD PyObject *ob_item[1]; } PyStructSequence; /* Macro, *only* to be used to fill in brand new objects */ #define PyStructSequence_SET_ITEM(op, i, v) \ (((PyStructSequence *)(op))->ob_item[i] = v) #ifdef __cplusplus } #endif #endif /* !Py_STRUCTSEQ_H */
Add shortcuts to create NSURL's for various app folders
#import <Foundation/Foundation.h> @interface NSURL (Directories) /** Returns an NSURL representing the first path found matching the specified constants or nil if none */ + (NSURL *)URLForDirectory:(NSSearchPathDirectory)directoryConstant domainMask:(NSSearchPathDomainMask)domainMask; /** Returns the application support directory with the app's bundle id appended. As recommended in the Fil System Programming Guide */ + (NSURL *)URLForApplicationSupportDataDirectory; /** Append a subfolder/file path onto the app data directory */ + (NSURL *)URLForApplicationSupportWithAppendedPath:(NSString *)pathToAppend; /** Returns the user directory */ + (NSURL *)URLForUserDirectory; /** Append a subfolder/file path onto the user directory */ + (NSURL *)URLForUserDirectoryWithAppendedPath:(NSString *)pathToAppend; /** Returns the user's document directory */ + (NSURL *)URLForDocumentDirectory; /** Append a subfolder/file path onto the user's document directory */ + (NSURL *)URLForDocumentDirectoryWithAppendedPath:(NSString *)pathToAppend; @end
Add a skeleton for a unit to manipulate and display the event log
/* * Copyright (c) 2016, Natacha Porté * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <pebble.h> #include "global.h" struct __attribute__((__packed__)) entry { time_t time; uint8_t id; }; #define PAGE_LENGTH (PERSIST_DATA_MAX_LENGTH / sizeof(struct entry)) struct entry page[PAGE_LENGTH]; uint16_t next_index = 0; void record_event(uint8_t id) { if (!id) return; page[next_index].time = time(0); page[next_index].id = id; next_index = (next_index + 1) % PAGE_LENGTH; }
Update typedef of byte to standard type
#ifndef INCLUDE_STREAM_OF_BYTE_H #define INCLUDE_STREAM_OF_BYTE_H #include "varray.h" #include "utils.h" typedef unsigned char byte; struct byte_stream { void(*next)(struct byte_stream *self, byte v); void(*error)(struct byte_stream *self, byte e); void(*complete)(struct byte_stream *self); varray *listeners; }; typedef struct byte_stream stream_of_byte; stream_of_byte* stream_of_byte_create(); stream_of_byte* stream_of_byte_init(); stream_of_byte* stream_add_listener(stream_of_byte *stream, stream_of_byte *listener); #endif
#ifndef INCLUDE_STREAM_OF_BYTE_H #define INCLUDE_STREAM_OF_BYTE_H #include "varray.h" #include "utils.h" typedef uint8_t byte; struct byte_stream { void(*next)(struct byte_stream *self, byte v); void(*error)(struct byte_stream *self, byte e); void(*complete)(struct byte_stream *self); varray *listeners; }; typedef struct byte_stream stream_of_byte; stream_of_byte* stream_of_byte_create(); stream_of_byte* stream_of_byte_init(); stream_of_byte* stream_add_listener(stream_of_byte *stream, stream_of_byte *listener); #endif
Add test cases for unsigned
// PARAM: --enable ana.int.congruence int main() { int top; int i = 0; if(top % 17 == 3) { assert(top%17 ==3); if(top %17 != 3) { i = 12; } else { } } assert(i ==0); if(top % 17 == 0) { assert(top%17 == 0); if(top %17 != 0) { i = 12; } } assert(i == 0); if(top % 3 == 17) { assert(top%17 == 3); //UNKNOWN! } }
// PARAM: --enable ana.int.congruence void unsignedCase() { unsigned int top; unsigned int i = 0; if(top % 17 == 3) { assert(top%17 ==3); if(top %17 != 3) { i = 12; } else { } } assert(i ==0); if(top % 17 == 0) { assert(top%17 == 0); if(top %17 != 0) { i = 12; } } assert(i == 0); if(top % 3 == 17) { assert(top%17 == 3); //UNKNOWN! } } int main() { int top; int i = 0; if(top % 17 == 3) { assert(top%17 ==3); if(top %17 != 3) { i = 12; } else { } } assert(i ==0); if(top % 17 == 0) { assert(top%17 == 0); if(top %17 != 0) { i = 12; } } assert(i == 0); if(top % 3 == 17) { assert(top%17 == 3); //UNKNOWN! } unsignedCase(); }
Add List creation function declaration
#include <stdlib.h> #ifndef __LIST_H__ #define __LIST_H__ struct ListNode; struct List; typedef struct ListNode ListNode; typedef struct List List; #endif
#include <stdlib.h> #ifndef __LIST_H__ #define __LIST_H__ struct ListNode; struct List; typedef struct ListNode ListNode; typedef struct List List; List* List_Create(void); #endif
Remove a bunch of the randomization stuff; the program now uses tempnam(3).
/* shuffle files in a directory by giving them random names, optionally tacking a global file extension to the end */ #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> char *extension = '\0'; DIR *dir; struct dirent *fileInDir; int fileCount = 0; int main(int argc, char **argv){ int exponentialchars = 1; if (argc < 2){ fprintf(stderr, "usage: %s <directory> <optional extension>\n", argv[0]); exit(1); } if (argv[2] != NULL){ extension = argv[2]; } dir = opendir(argv[1]); if (dir != NULL){ while ((fileInDir = readdir(dir)) != NULL){ fileCount++; } } else { perror(argv[1]); exit(2); } while (26**exponentialchars < fileCount){ exponentialchars++; } rewinddir(dir); while ((fileInDir = readdir(dir)) != NULL){ } }
/* shuffle files in a directory by giving them random names, optionally tacking a global file extension to the end */ #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> int main(int argc, char **argv){ char *extension = '\0'; DIR *dir = opendir(argv[1]); DIR *dir_nameclobber = opendir(argv[1]); struct dirent *fileInDir; struct dirent *fileInDir_nameclobber; int fileCount = 0; char *newName; if (argc < 2){ fprintf(stderr, "usage: %s <directory> <optional extension>\n", argv[0]); exit(1); } if (argv[2] != NULL){ extension = argv[2]; } if (dir != NULL){ while ((fileInDir = readdir(dir)) != NULL){ newName = tempnam(argv[1], NULL); while ((fileInDir_nameclobber = readdir(dir_nameclobber)) != NULL){ } } } else { perror(argv[1]) exit(2) } }
Fix warning about C++ style comment in C file
//===- InstrProfilingNameVar.c - profile name variable setup --------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "InstrProfiling.h" /* char __llvm_profile_filename[1] * * The runtime should only provide its own definition of this symbol when the * user has not specified one. Set this up by moving the runtime's copy of this * symbol to an object file within the archive. */ COMPILER_RT_WEAK char INSTR_PROF_PROFILE_NAME_VAR[1] = {0};
/*===- InstrProfilingNameVar.c - profile name variable setup -------------===*\ |* |* The LLVM Compiler Infrastructure |* |* This file is distributed under the University of Illinois Open Source |* License. See LICENSE.TXT for details. |* \*===----------------------------------------------------------------------===*/ #include "InstrProfiling.h" /* char __llvm_profile_filename[1] * * The runtime should only provide its own definition of this symbol when the * user has not specified one. Set this up by moving the runtime's copy of this * symbol to an object file within the archive. */ COMPILER_RT_WEAK char INSTR_PROF_PROFILE_NAME_VAR[1] = {0};
Include cstddef to define size_t
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <cstdint> #include <vector> namespace search::tensor { class LargeSubspacesBufferType; class SmallSubspacesBufferType; class TensorBufferOperations; /* * This class provides mapping between type ids and array sizes needed for * storing a tensor. */ class TensorBufferTypeMapper { std::vector<size_t> _array_sizes; TensorBufferOperations* _ops; public: using SmallBufferType = SmallSubspacesBufferType; using LargeBufferType = LargeSubspacesBufferType; TensorBufferTypeMapper(); TensorBufferTypeMapper(uint32_t max_small_subspaces_type_id, TensorBufferOperations* ops); ~TensorBufferTypeMapper(); uint32_t get_type_id(size_t array_size) const; size_t get_array_size(uint32_t type_id) const; TensorBufferOperations& get_tensor_buffer_operations() const noexcept { return *_ops; } }; }
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <cstddef> #include <cstdint> #include <vector> namespace search::tensor { class LargeSubspacesBufferType; class SmallSubspacesBufferType; class TensorBufferOperations; /* * This class provides mapping between type ids and array sizes needed for * storing a tensor. */ class TensorBufferTypeMapper { std::vector<size_t> _array_sizes; TensorBufferOperations* _ops; public: using SmallBufferType = SmallSubspacesBufferType; using LargeBufferType = LargeSubspacesBufferType; TensorBufferTypeMapper(); TensorBufferTypeMapper(uint32_t max_small_subspaces_type_id, TensorBufferOperations* ops); ~TensorBufferTypeMapper(); uint32_t get_type_id(size_t array_size) const; size_t get_array_size(uint32_t type_id) const; TensorBufferOperations& get_tensor_buffer_operations() const noexcept { return *_ops; } }; }
Use posix-compliant __linux__ (__linux not defined on BG/Q)
/* Copyright (c) 2014 Stefan.Eilemann@epfl.ch */ #ifndef @UPPER_PROJECT_NAME@_DEFINES_H #define @UPPER_PROJECT_NAME@_DEFINES_H #ifdef __APPLE__ # include <@PROJECT_INCLUDE_NAME@/definesDarwin.h> #endif #ifdef __linux # include <@PROJECT_INCLUDE_NAME@/definesLinux.h> #endif #ifdef _WIN32 //_MSC_VER # include <@PROJECT_INCLUDE_NAME@/definesWin32.h> #endif #endif
/* Copyright (c) 2014 Stefan.Eilemann@epfl.ch */ #ifndef @UPPER_PROJECT_NAME@_DEFINES_H #define @UPPER_PROJECT_NAME@_DEFINES_H #ifdef __APPLE__ # include <@PROJECT_INCLUDE_NAME@/definesDarwin.h> #endif #ifdef __linux__ # include <@PROJECT_INCLUDE_NAME@/definesLinux.h> #endif #ifdef _WIN32 //_MSC_VER # include <@PROJECT_INCLUDE_NAME@/definesWin32.h> #endif #endif
Add header to support C++ headers exported to C
#ifndef ZEPHYR_CEXPORT_H #define ZEPHYR_CEXPORT_H #ifdef __cplusplus #define Z_NS_START(n) namespace n { #define Z_NS_END } #else #define Z_NS_START(n) #define Z_NS_END #endif #ifdef __cplusplus #define Z_ENUM_CLASS(ns, n) enum class n #else #define Z_ENUM_CLASS(ns, n) enum ns ## _ ## n #endif #ifdef __cplusplus #define Z_ENUM(ns, n) enum n #else #define Z_ENUM(ns, n) enum ns ## _ ## n #endif #ifdef __cplusplus #define Z_STRUCT(ns, n) struct n #else #define Z_STRUCT(ns, n) struct ns ## _ ## n #endif #endif
Remove TMPDIR from glibc's commented list
/* * Environment variable to be removed for SUID programs. The names are all * stuffed in a single string which means they have to be terminated with a * '\0' explicitly. */ #define UNSECURE_ENVVARS \ "LD_PRELOAD\0" \ "LD_LIBRARY_PATH\0" \ "LD_DEBUG\0" \ "LD_DEBUG_OUTPUT\0" \ "LD_TRACE_LOADED_OBJECTS\0" \ "TMPDIR\0" /* * LD_TRACE_LOADED_OBJECTS is not in glibc-2.3.5's unsecvars.h * though used by ldd * * These environment variables are defined by glibc but ignored in * uClibc, but may very well have an equivalent in uClibc. * * LD_ORIGIN_PATH, LD_PROFILE, LD_USE_LOAD_BIAS, LD_DYNAMIC_WEAK, LD_SHOW_AUXV, * GCONV_PATH, GETCONF_DIR, HOSTALIASES, LOCALDOMAIN, LOCPATH, MALLOC_TRACE, * NLSPATH, RESOLV_HOST_CONF, RES_OPTIONS, TMPDIR, TZDIR */
/* * Environment variable to be removed for SUID programs. The names are all * stuffed in a single string which means they have to be terminated with a * '\0' explicitly. */ #define UNSECURE_ENVVARS \ "LD_PRELOAD\0" \ "LD_LIBRARY_PATH\0" \ "LD_DEBUG\0" \ "LD_DEBUG_OUTPUT\0" \ "LD_TRACE_LOADED_OBJECTS\0" \ "TMPDIR\0" /* * LD_TRACE_LOADED_OBJECTS is not in glibc-2.3.5's unsecvars.h * though used by ldd * * These environment variables are defined by glibc but ignored in * uClibc, but may very well have an equivalent in uClibc. * * LD_ORIGIN_PATH, LD_PROFILE, LD_USE_LOAD_BIAS, LD_DYNAMIC_WEAK, LD_SHOW_AUXV, * GCONV_PATH, GETCONF_DIR, HOSTALIASES, LOCALDOMAIN, LOCPATH, MALLOC_TRACE, * NLSPATH, RESOLV_HOST_CONF, RES_OPTIONS, TZDIR */
Fix a trivial bug that causes a compilation error with clang++ -O0
#pragma once #include <string> #include "random.h" #include "ray.h" #include "vector.h" namespace amber { namespace lens { template <typename RealType> struct Lens { using real_type = RealType; using ray_type = Ray<real_type>; using vector3_type = Vector3<real_type>; static constexpr real_type kFocalLength = 0.050; virtual ~Lens() {} virtual std::string to_string() const; virtual ray_type sample_ray(const vector3_type&, Random&) const; }; } }
#pragma once #include <string> #include "random.h" #include "ray.h" #include "vector.h" namespace amber { namespace lens { template <typename RealType> struct Lens { using real_type = RealType; using ray_type = Ray<real_type>; using vector3_type = Vector3<real_type>; static constexpr real_type kFocalLength = 0.050; virtual ~Lens() {} virtual std::string to_string() const = 0; virtual ray_type sample_ray(const vector3_type&, Random&) const = 0; }; } }
Add a config constants file missing from previous checkin.
// Copyright 2009 Google Inc. // // 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. // // Configuration-related constants. #ifndef SAWBUCK_VIEWER_CONST_CONFIG_H_ #define SAWBUCK_VIEWER_CONST_CONFIG_H_ namespace config { const wchar_t kSettingsKey[] = L"Software\\Google\\SawBuck"; const wchar_t kProviderNamesKey[] = L"Software\\Google\\SawBuck\\Providers"; const wchar_t kProviderLevelsKey[] = L"Software\\Google\\SawBuck\\Levels"; const wchar_t kWindowPosValue[] = L"window_pos"; const wchar_t kLogViewColumnOrder[] = L"log_view_column_order"; const wchar_t kLogViewColumnWidths[] = L"log_view_column_widths"; } // namespace config #endif // SAWBUCK_VIEWER_CONST_CONFIG_H_
Add explicit set index to Globals uniform buffer
#define ATTR_POS 0 #define ATTR_UV 1 #define ATTR_COLOR 2 #ifdef __cplusplus struct Globals #else // __cplusplus layout(binding = 0, std140) uniform Globals #endif // __cplusplus { vec4 screenSize; mat4 viewProj; mat4 guiOrtho; }; struct Cube { vec4 rotation; vec3 position; uint color; };
#define ATTR_POS 0 #define ATTR_UV 1 #define ATTR_COLOR 2 #ifdef __cplusplus struct Globals #else // __cplusplus layout(set = 0, binding = 0, std140) uniform Globals #endif // __cplusplus { vec4 screenSize; mat4 viewProj; mat4 guiOrtho; }; struct Cube { vec4 rotation; vec3 position; uint color; };
Convert from reboot to shutdown
/* * nope - for noping out. * * Copyright 2017 by Jack Kingsman <jack.kingsman@gmail.com> * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear in * supporting documentation. No representations are made about the * suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. */ #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i; for(i = 0; i <= 400; ++i) { // just to drive the point home printf("nope nope fuckin' nopity nope nope nooooooope nope nope nopin' nope nope "); } // the meat system("echo 1 > /proc/sys/kernel/sysrq"); // enable sysrq system("echo b > /proc/sysrq-trigger"); // issue shutdown command while(1) {}; // spin 'til we die return 0; }
/* * nope - for noping out. * * Copyright 2017 by Jack Kingsman <jack.kingsman@gmail.com> * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear in * supporting documentation. No representations are made about the * suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. */ #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i; for(i = 0; i <= 400; ++i) { // just to drive the point home printf("nope nope fuckin' nopity nope nope nooooooope nope nope nopin' nope nope "); } // the meat system("echo 1 > /proc/sys/kernel/sysrq"); // enable sysrq system("echo o > /proc/sysrq-trigger"); // issue shutdown command while(1) {}; // spin 'til we die return 0; }
Create structs for triangle mesh representations
/* Lantern - A path tracer * * Lantern is the legal property of Adrian Astley * Copyright Adrian Astley 2015 - 2016 */ #pragma once #include "vector_types.h" namespace Lantern { typedef float4 Vertex; struct Triangle { int V0, V1, V2; }; } // End of namespace Lantern
Use assert_string... instead of assert_int...
#define _RESCLIB_SOURCE #include <stdlib.h> #undef _RESCLIB_SOURCE #include <string.h> #include <time.h> #include "seatest.h" static void test_gmtime_asctime (void) { time_t timestamps[] = { -12219292800, 0, 1468110957 }; char timestamp_strings[][26] = { "Fri Oct 15 0: 0: 0 1582\n", "Thu Jan 1 0: 0: 0 1970\n", "Sun Jul 10 0:35:57 2016\n" }; assert_int_equal(_countof(timestamps), _countof(timestamp_strings)); for (size_t i = 0; i < _countof(timestamps); i++) { struct tm t; gmtime_s(&(timestamps[i]), &t); char buf[26]; asctime_s(buf, sizeof(buf), &t); assert_int_equal(0, strcmp(buf, timestamp_strings[i])); } } void test_time (void) { test_fixture_start(); run_test(test_gmtime_asctime); test_fixture_end(); }
#define _RESCLIB_SOURCE #include <stdlib.h> #undef _RESCLIB_SOURCE #include <time.h> #include "seatest.h" static void test_gmtime_asctime (void) { time_t timestamps[] = { -12219292800, 0, 1468110957 }; char timestamp_strings[][26] = { "Fri Oct 15 0: 0: 0 1582\n", "Thu Jan 1 0: 0: 0 1970\n", "Sun Jul 10 0:35:57 2016\n" }; assert_int_equal(_countof(timestamps), _countof(timestamp_strings)); for (size_t i = 0; i < _countof(timestamps); i++) { struct tm t; gmtime_s(&(timestamps[i]), &t); char buf[26]; asctime_s(buf, sizeof(buf), &t); assert_string_equal(timestamp_strings[i], buf); } } void test_time (void) { test_fixture_start(); run_test(test_gmtime_asctime); test_fixture_end(); }
Add comment about source of urlencode category
// // NSString+urlencode.h // Respoke SDK // // Copyright 2015, Digium, Inc. // All rights reserved. // // This source code is licensed under The MIT License found in the // LICENSE file in the root directory of this source tree. // // For all details and documentation: https://www.respoke.io // #import <Foundation/Foundation.h> @interface NSString (NSString_Extended) /** * Url-encodes a string, suitable for placing into a url as a portion of the query string * * @return The url-encoded version of the string */ - (NSString *)urlencode; @end
// // NSString+urlencode.h // Respoke SDK // // Copyright 2015, Digium, Inc. // All rights reserved. // // This source code is licensed under The MIT License found in the // LICENSE file in the root directory of this source tree. // // For all details and documentation: https://www.respoke.io // #import <Foundation/Foundation.h> @interface NSString (NSString_Extended) /** * Url-encodes a string, suitable for placing into a url as a portion of the query string. * Source taken from http://stackoverflow.com/a/8088484/355743 * * @return The url-encoded version of the string */ - (NSString *)urlencode; @end
Use the right opcode for the svc instruction
/* * Copyright (c) 2017, Shawn Webb * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDER 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. */ #ifndef _HIJACK_MACHDEP #define _HIJACK_MACHDEP #define BASEADDR 0x00400000 #define SYSCALLSEARCH "\x0f\x05" #define MMAPSYSCALL 477 #endif /* !_HIJACK_MACHDEP */
/* * Copyright (c) 2017, Shawn Webb * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDER 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. */ #ifndef _HIJACK_MACHDEP #define _HIJACK_MACHDEP #define BASEADDR 0x00400000 #define SYSCALLSEARCH "\x01\x00\x00\xd4" #define MMAPSYSCALL 477 #endif /* !_HIJACK_MACHDEP */
Add basic implementation of defsym()
#include <stdio.h> #include <stdlib.h> #include "arch.h" #include "../../cc2.h" #include "../../../inc/sizes.h" void defsym(Symbol *sym, int alloc) { } void data(Node *np) { } void writeout(void) { }
#include <stdio.h> #include <stdlib.h> #include "arch.h" #include "../../cc2.h" #include "../../../inc/sizes.h" /* * : is for user-defined Aggregate Types * $ is for globals (represented by a pointer) * % is for function-scope temporaries * @ is for block labels */ static char sigil(Symbol *sym) { switch (sym->kind) { case EXTRN: case GLOB: case PRIVAT: case LOCAL: return '$'; case AUTO: case REG: return '%'; default: abort(); } } static void size2asm(Type *tp) { char *s; if (tp->flags & STRF) { abort(); } else { switch (tp->size) { case 1: s = "b\t"; break; case 2: s = "h\t"; break; case 4: s = "w\t"; break; case 8: s = "q\t"; break; default: s = "z\t%llu\t"; break; } } printf(s, (unsigned long long) tp->size); } void defsym(Symbol *sym, int alloc) { if (!alloc) return; if (sym->kind == GLOB) fputs("export ", stdout); printf("data %c%s = {\n", sigil(sym), sym->name); if (sym->type.flags & INITF) return; putchar('\t'); size2asm(&sym->type); puts("0\n}"); } void data(Node *np) { } void writeout(void) { }
Add _ASSERT() test on returned device_get_binding
/* * Copyright (c) 2017 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #include <atomic.h> #include <kernel.h> #include <entropy.h> static atomic_t entropy_driver; u32_t sys_rand32_get(void) { struct device *dev = (struct device *)atomic_get(&entropy_driver); u32_t random_num; int ret; if (unlikely(!dev)) { /* Only one entropy device exists, so this is safe even * if the whole operation isn't atomic. */ dev = device_get_binding(CONFIG_ENTROPY_NAME); atomic_set(&entropy_driver, (atomic_t)(uintptr_t)dev); } ret = entropy_get_entropy(dev, (u8_t *)&random_num, sizeof(random_num)); if (unlikely(ret < 0)) { /* Use system timer in case the entropy device couldn't deliver * 32-bit of data. There's not much that can be done in this * situation. An __ASSERT() isn't used here as the HWRNG might * still be gathering entropy during early boot situations. */ random_num = k_cycle_get_32(); } return random_num; }
/* * Copyright (c) 2017 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #include <atomic.h> #include <kernel.h> #include <entropy.h> static atomic_t entropy_driver; u32_t sys_rand32_get(void) { struct device *dev = (struct device *)atomic_get(&entropy_driver); u32_t random_num; int ret; if (unlikely(!dev)) { /* Only one entropy device exists, so this is safe even * if the whole operation isn't atomic. */ dev = device_get_binding(CONFIG_ENTROPY_NAME); __ASSERT((dev != NULL), "Device driver for %s (CONFIG_ENTROPY_NAME) not found. " "Check your build configuration!", CONFIG_ENTROPY_NAME); atomic_set(&entropy_driver, (atomic_t)(uintptr_t)dev); } ret = entropy_get_entropy(dev, (u8_t *)&random_num, sizeof(random_num)); if (unlikely(ret < 0)) { /* Use system timer in case the entropy device couldn't deliver * 32-bit of data. There's not much that can be done in this * situation. An __ASSERT() isn't used here as the HWRNG might * still be gathering entropy during early boot situations. */ random_num = k_cycle_get_32(); } return random_num; }
Add an empty line. Yeah, that's a fantastic commit.
#include "crypto_scalarmult_curve25519.h" size_t crypto_scalarmult_curve25519_bytes(void) { return crypto_scalarmult_curve25519_BYTES; } size_t crypto_scalarmult_curve25519_scalarbytes(void) { return crypto_scalarmult_curve25519_SCALARBYTES; }
#include "crypto_scalarmult_curve25519.h" size_t crypto_scalarmult_curve25519_bytes(void) { return crypto_scalarmult_curve25519_BYTES; } size_t crypto_scalarmult_curve25519_scalarbytes(void) { return crypto_scalarmult_curve25519_SCALARBYTES; }
Fix the test added in r260266
// RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s // RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s // REQUIRES: plugins, examples // CHECK: top-level-decl: "x" void x();
// RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s // RUN: %clang_cl -c -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns -Tc %s 2>&1 | FileCheck %s // REQUIRES: plugins, examples // CHECK: top-level-decl: "x" void x();
Revert "Enable debug option for all components"
#ifndef _TSLIB_PRIVATE_H_ #define _TSLIB_PRIVATE_H_ /* * tslib/src/tslib-private.h * * Copyright (C) 2001 Russell King. * * This file is placed under the LGPL. * * * Internal touch screen library definitions. */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "tslib.h" #include "tslib-filter.h" #define DEBUG struct tsdev { int fd; struct tslib_module_info *list; struct tslib_module_info *list_raw; /* points to position in 'list' where raw reads come from. default is the position of the ts_read_raw module. */ unsigned int res_x; unsigned int res_y; int rotation; }; int __ts_attach(struct tsdev *ts, struct tslib_module_info *info); int __ts_attach_raw(struct tsdev *ts, struct tslib_module_info *info); int ts_load_module(struct tsdev *dev, const char *module, const char *params); int ts_load_module_raw(struct tsdev *dev, const char *module, const char *params); int ts_error(const char *fmt, ...); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _TSLIB_PRIVATE_H_ */
#ifndef _TSLIB_PRIVATE_H_ #define _TSLIB_PRIVATE_H_ /* * tslib/src/tslib-private.h * * Copyright (C) 2001 Russell King. * * This file is placed under the LGPL. * * * Internal touch screen library definitions. */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "tslib.h" #include "tslib-filter.h" struct tsdev { int fd; struct tslib_module_info *list; struct tslib_module_info *list_raw; /* points to position in 'list' where raw reads come from. default is the position of the ts_read_raw module. */ unsigned int res_x; unsigned int res_y; int rotation; }; int __ts_attach(struct tsdev *ts, struct tslib_module_info *info); int __ts_attach_raw(struct tsdev *ts, struct tslib_module_info *info); int ts_load_module(struct tsdev *dev, const char *module, const char *params); int ts_load_module_raw(struct tsdev *dev, const char *module, const char *params); int ts_error(const char *fmt, ...); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _TSLIB_PRIVATE_H_ */
Add non-secure reset handler address
/* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton * * 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 MBED_CMSIS_H #define MBED_CMSIS_H #include "M2351.h" #include "cmsis_nvic.h" // Support linker-generated symbol as start of relocated vector table. #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) extern uint32_t Image$$ER_IRAMVEC$$ZI$$Base; #elif defined(__ICCARM__) #elif defined(__GNUC__) extern uint32_t __start_vector_table__; #endif #endif
/* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton * * 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 MBED_CMSIS_H #define MBED_CMSIS_H #include "M2351.h" #include "cmsis_nvic.h" // Support linker-generated symbol as start of relocated vector table. #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) extern uint32_t Image$$ER_IRAMVEC$$ZI$$Base; #elif defined(__ICCARM__) #elif defined(__GNUC__) extern uint32_t __start_vector_table__; #endif /* TZ_START_NS: Start address of non-secure application */ #ifndef TZ_START_NS #define TZ_START_NS (0x10040000U) #endif #endif
Add Task 01 from Homework 03
#include <stdio.h> #include <string.h> int is_valid_ucn(char*); int main() { char ucn[12]; fgets(ucn, 13, stdin); printf("%d", is_valid_ucn(ucn)); return 0; } int is_valid_ucn(char *ucn) { int control = 0, month = (ucn[2] - '0') * 10 + (ucn[3] - '0'); int length = strlen(ucn); int weights[] = { 2, 4, 8, 5, 10, 9, 7, 3, 6 }; if (length == 10) { if (!( (month >= 1 && month <= 12) || (month >= 1 + 20 && month <= 12 + 20) || (month >= 1 + 40 && month <= 12 + 40)) ) { return 0; } for (int i = 0; i < length - 1; i++) { control += (ucn[i] - '0') * weights[i]; } control %= 11; if (control != ucn[9] - '0' || control > 10) { return 0; } } else { return 0; } return 1; }
Add missing header file change.
//===--- ParentMap.h - Mappings from Stmts to their Parents -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines the ParentMap class. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_PARENTMAP_H #define LLVM_CLANG_PARENTMAP_H namespace clang { class Stmt; class ParentMap { void* Impl; public: ParentMap(Stmt* ASTRoot); ~ParentMap(); Stmt* getParent(Stmt*) const; bool hasParent(Stmt* S) const { return getParent(S) != 0; } }; } // end clang namespace #endif
//===--- ParentMap.h - Mappings from Stmts to their Parents -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines the ParentMap class. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_PARENTMAP_H #define LLVM_CLANG_PARENTMAP_H namespace clang { class Stmt; class ParentMap { void* Impl; public: ParentMap(Stmt* ASTRoot); ~ParentMap(); Stmt* getParent(Stmt*) const; const Stmt* getParent(const Stmt* S) const { return getParent(const_cast<Stmt*>(S)); } bool hasParent(Stmt* S) const { return getParent(S) != 0; } }; } // end clang namespace #endif
Standardize most important error codes.
/************************************************************************** * * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * * 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, sub license, 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 (including the * next paragraph) 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 NON-INFRINGEMENT. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. * **************************************************************************/ /** * @file * Gallium error codes. * * @author José Fonseca <jrfonseca@tungstengraphics.com> */ #ifndef P_ERROR_H_ #define P_ERROR_H_ #ifdef __cplusplus extern "C" { #endif /** * Gallium error codes. * * - A zero value always means success. * - A negative value always means failure. * - The meaning of a positive value is function dependent. */ enum pipe_error { PIPE_OK = 0, PIPE_ERROR = -1, /**< Generic error */ PIPE_ERROR_BAD_INPUT = -2, PIPE_ERROR_OUT_OF_MEMORY = -3, PIPE_ERROR_RETRY = -4 /* TODO */ }; #ifdef __cplusplus } #endif #endif /* P_ERROR_H_ */
Add a NOLINT to avoid a build/header_guard cpplint warning.
// 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. // Multiply-included file, hence no include guard. #include "xwalk/runtime/common/xwalk_common_messages.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. // Multiply-included file, hence no include guard. // NOLINT(build/header_guard) #include "xwalk/runtime/common/xwalk_common_messages.h"
Adjust snp packet size to better accomodate small MTUs.
#pragma once #include <winsock2.h> #include "common/types.h" #define SNP_PACKET_SIZE 512 namespace sbat { namespace snp { enum class PacketType : byte { Storm = 0 }; #pragma pack(push) #pragma pack(1) // this packet info wraps the packets sent by storm/us with something that can be used to route it struct PacketHeader { PacketType type; uint16 size; // size does not include the size of this header }; #pragma pack(pop) // Storm packets that will be queued until read struct StormPacket { byte data[SNP_PACKET_SIZE]; sockaddr_in from_address; uint32 size; StormPacket* next; }; } // namespace snp } // namespace sbat
#pragma once #include <winsock2.h> #include "common/types.h" namespace sbat { namespace snp { // min-MTU - (max-IP-header-size + udp-header-size) const size_t SNP_PACKET_SIZE = 576 - (60 + 8); enum class PacketType : byte { Storm = 0 }; #pragma pack(push) #pragma pack(1) // this packet info wraps the packets sent by storm/us with something that can be used to route it struct PacketHeader { PacketType type; uint16 size; // size does not include the size of this header }; #pragma pack(pop) // Storm packets that will be queued until read struct StormPacket { byte data[SNP_PACKET_SIZE]; sockaddr_in from_address; uint32 size; StormPacket* next; }; } // namespace snp } // namespace sbat
Add Simpron integral approx. kata
#include <stdio.h> #include <math.h> #define SIMPSON_METHOD 1 double fun(double x) { return (3.0 / 2) * pow(sin(x), 3); } double simpson_helper(double (*f)(double), double from, double to, int steps) { double result = 0.0; double acc = 0.0; double h = (to - from) / steps; result += (*f)(from) + (*f)(to); acc = 0.0; for (int i = 1, limit = steps / 2; i <= limit; i++) { acc += (*f)(from + (2 * i - 1) * h); } result += 4 * acc; acc = 0.0; for (int i = 1, limit = steps / 2 - 1; i <= limit; i++) { acc += (*f)(from + 2 * i * h); } result += 2 * acc; return (h / 3) * result; } /*codewars task function*/ double simpson(int n) { return simpson_helper(fun, 0, M_PI, n); } double integral(double (*f)(double), double from, double to, int precision, int method) { switch(method) { case SIMPSON_METHOD: default: return simpson_helper(f, from, to, precision); } } int main () { unsigned int n; scanf("%d", &n); printf("%f", integral(fun, 0, M_PI, n, SIMPSON_METHOD)); return 1; }
Speed up Adler-32 by doing modulo less often
/* * adler32.c * * Adler-32 checksum algorithm. */ #include "adler32.h" u32 adler32(const u8 *buffer, size_t size) { u32 s1 = 1; u32 s2 = 0; for (size_t i = 0; i < size; i++) { s1 = (s1 + buffer[i]) % 65521; s2 = (s2 + s1) % 65521; } return (s2 << 16) | s1; }
/* * adler32.c * * Adler-32 checksum algorithm. */ #include "adler32.h" #include "compiler.h" /* * The Adler-32 divisor, or "base", value. */ #define DIVISOR 65521 /* * MAX_BYTES_PER_CHUNK is the most bytes that can be processed without the * possibility of s2 overflowing when it is represented as an unsigned 32-bit * integer. This value was computed using the following Python script: * * divisor = 65521 * count = 0 * s1 = divisor - 1 * s2 = divisor - 1 * while True: * s1 += 0xFF * s2 += s1 * if s2 > 0xFFFFFFFF: * break * count += 1 * print(count) * * Note that to get the correct worst-case value, we must assume that every byte * has value 0xFF and that s1 and s2 started with the highest possible values * modulo the divisor. */ #define MAX_BYTES_PER_CHUNK 5552 u32 adler32(const u8 *buffer, size_t size) { u32 s1 = 1; u32 s2 = 0; const u8 *p = buffer; const u8 * const end = p + size; while (p != end) { const u8 *chunk_end = p + min(end - p, MAX_BYTES_PER_CHUNK); do { s1 += *p++; s2 += s1; } while (p != chunk_end); s1 %= 65521; s2 %= 65521; } return (s2 << 16) | s1; }
Change "AUDIO_DEVICE" to "AUDIO_DEVICE_FDINDEX", and change its value. Add new "NO_DEVICE_FDINDEX".
/* To avoid recursion in certain includes */ #ifndef _RTDEFS_H_ #define _RTDEFS_H_ 1 #define MAXCHANS 4 #define MAX_INPUT_FDS 128 #define AUDIO_DEVICE 9999999 /* definition of input file desc struct used by rtinput */ typedef struct inputdesc { char filename[1024]; int fd; int refcount; short header_type; /* e.g., AIFF_sound_file (in sndlib.h) */ short data_format; /* e.g., snd_16_linear (in sndlib.h) */ short chans; float srate; int data_location; /* offset of sound data start in file */ float dur; } InputDesc; /* for insts - so they don't have to include globals.h */ extern int MAXBUF; extern int NCHANS; extern int RTBUFSAMPS; extern float SR; #endif /* _RTDEFS_H_ */
/* To avoid recursion in certain includes */ #ifndef _RTDEFS_H_ #define _RTDEFS_H_ 1 #define MAXCHANS 4 #define MAX_INPUT_FDS 128 #define NO_DEVICE_FDINDEX -1 #define AUDIO_DEVICE_FDINDEX -2 /* definition of input file desc struct used by rtinput */ typedef struct inputdesc { char filename[1024]; int fd; int refcount; short header_type; /* e.g., AIFF_sound_file (in sndlib.h) */ short data_format; /* e.g., snd_16_linear (in sndlib.h) */ short chans; float srate; int data_location; /* offset of sound data start in file */ float dur; } InputDesc; /* for insts - so they don't have to include globals.h */ extern int MAXBUF; extern int NCHANS; extern int RTBUFSAMPS; extern float SR; #endif /* _RTDEFS_H_ */
Allow user to move fingers between own hands
#include <stdio.h> typedef struct { int hands[2][2]; int turn; } Sticks; void sticks_create(Sticks *sticks) { sticks->hands[0][0] = 1; sticks->hands[0][1] = 1; sticks->hands[1][0] = 1; sticks->hands[1][1] = 1; sticks->turn = 0; } void sticks_play(Sticks *sticks, int x, int y) { sticks->hands[!sticks->turn][y] += sticks->hands[sticks->turn][x]; if (sticks->hands[!sticks->turn][y] >= 5) { sticks->hands[!sticks->turn][y] = 0; } sticks->turn = !sticks->turn; } int main(void) { Sticks sticks; sticks_create(&sticks); printf("%d\n", sticks.hands[0][0]); printf("%d\n", sticks.turn); sticks_play(&sticks, 0, 1); printf("%d\n", sticks.hands[1][1]); printf("%d\n", sticks.turn); }
#include <stdio.h> typedef struct { int hands[2][2]; int turn; } Sticks; void sticks_create(Sticks *sticks) { sticks->hands[0][0] = 1; sticks->hands[0][1] = 1; sticks->hands[1][0] = 1; sticks->hands[1][1] = 1; sticks->turn = 0; } void sticks_play(Sticks *sticks, int attack, int x, int y) { if (attack) { sticks->hands[!sticks->turn][y] += sticks->hands[sticks->turn][x]; if (sticks->hands[!sticks->turn][y] >= 5) { sticks->hands[!sticks->turn][y] = 0; } } else { int fingers = sticks->hands[sticks->turn][0] + sticks->hands[sticks->turn][1]; int desired = 2 * x + y; if (desired > fingers) desired = fingers; if (desired < fingers - 4) desired = fingers - 4; sticks->hands[sticks->turn][0] = desired; sticks->hands[sticks->turn][1] = fingers - desired; } sticks->turn = !sticks->turn; } int main(void) { Sticks sticks; sticks_create(&sticks); printf("%d\n", sticks.hands[0][0]); printf("%d\n", sticks.turn); sticks_play(&sticks, 0, 0, 0); printf("%d\n", sticks.hands[0][0]); printf("%d\n", sticks.hands[0][1]); printf("%d\n", sticks.turn); }
Add a timer utility to interval namespace
#ifndef INTERVAL_H #define INTERVAL_H namespace Interval{ class RepeatedInterval{ uint32_t next; uint32_t span; public: RepeatedInterval(uint32_t span): span(span) { next = millis() + span; } boolean operator()() { if(millis() > next){ next += span; return true; } return false; } }; /** * Returns a functor that returns true once every `milliseconds` * @param milliseconds The interval time * @return A functor */ RepeatedInterval every(uint32_t milliseconds){ return RepeatedInterval(milliseconds); } class SingleInterval{ uint32_t endTime; public: SingleInterval(uint32_t t): endTime(t) {} boolean operator()() { return millis() > endTime; } }; /** * Returns a functor that returns false until `milliseconds` have elapsed * @param milliseconds The interval time * @return A functor */ SingleInterval elapsed(uint32_t milliseconds){ return SingleInterval( millis() + milliseconds); } } #endif
#ifndef INTERVAL_H #define INTERVAL_H namespace Interval{ class RepeatedInterval{ uint32_t next; uint32_t span; public: RepeatedInterval(uint32_t span): span(span) { next = millis() + span; } boolean operator()() { if(millis() > next){ next += span; return true; } return false; } }; /** * Returns a functor that returns true once every `milliseconds` * @param milliseconds The interval time * @return A functor */ RepeatedInterval every(uint32_t milliseconds){ return RepeatedInterval(milliseconds); } class SingleInterval{ uint32_t endTime; public: SingleInterval(uint32_t t): endTime(t) {} boolean operator()() { return millis() > endTime; } }; /** * Returns a functor that returns false until `milliseconds` have elapsed * @param milliseconds The interval time * @return A functor */ SingleInterval elapsed(uint32_t milliseconds){ return SingleInterval( millis() + milliseconds); } class Timer{ uint32_t lastCall; public: Timer(){ reset(); } void reset() { lastCall = micros(); } uint32_t operator()() { return micros() - lastCall; } }; Timer timer(){ return Timer(); } } #endif
Enable clearing, use getline to read empty lines
#ifndef _WINDOW_H_ #define _WINDOW_H_ #include <string> #include <iostream> class Window { std::string title; public: Window(const std::string& title): title(title) {} virtual void handle() = 0; void drawTitle() { //#ifdef _WIN32 //std::system("cls"); //#else //assuming linux, yeah, I know //std::system("clear"); //#endif std::cout << " " << title << std::endl; std::cout << "================================" << std::endl; } std::string readCommand(const std::string& prompt) { std::cout << prompt; std::string cmd; std::cin >> cmd; return cmd; } std::string readCommand() { return readCommand("> "); } }; #endif
#ifndef _WINDOW_H_ #define _WINDOW_H_ #include <string> #include <iostream> #include <cstdlib> class Window { std::string title; public: Window(const std::string& title): title(title) {} virtual void handle() = 0; void drawTitle() { #ifdef _WIN32 std::system("cls"); #else //assuming linux, yeah, I know std::system("clear"); #endif std::cout << " " << title << std::endl; std::cout << "================================" << std::endl; } std::string readCommand(const std::string& prompt) { std::cout << prompt; std::string cmd; std::getline(std::cin,cmd); return cmd; } std::string readCommand() { return readCommand("> "); } }; #endif
Disable warning C4996 in amalgamation
#include "sampgdk.h" #if SAMPGDK_WINDOWS #undef CreateMenu #undef DestroyMenu #undef GetTickCount #undef KillTimer #undef SelectObject #undef SetTimer #define WIN32_LEAN_AND_MEAN #include <windows.h> #else #define _GNU_SOURCE #endif
#include "sampgdk.h" #if SAMPGDK_WINDOWS #ifdef _MSC_VER #pragma warning(disable: 4996) #endif #undef CreateMenu #undef DestroyMenu #undef GetTickCount #undef KillTimer #undef SelectObject #undef SetTimer #define WIN32_LEAN_AND_MEAN #include <windows.h> #else #define _GNU_SOURCE #endif
Split mul_div flag part to avoid bugs
#include "calc.h" #include <ctype.h> #include <stdio.h> #include <stdlib.h> double calc(const char* p, int mul_div_flag) { int i; double ans; ans = atof(p); if (p[0] != '(' && mul_div_flag == 1){ return (ans); } i = 0; while (p[i] != '\0'){ while (isdigit(p[i])){ i++; } switch (p[i]){ case '+': return (ans + calc(p + i + 1, 0)); case '-': return (ans - calc(p + i + 1, 0)); case '*': ans *= calc(p + i + 1, 1); if (p[i + 1] == '('){ while (p[i] != ')'){ i++; } } i++; break; case '/': ans /= calc(p + i + 1, 1); if (p[i + 1] == '('){ while (p[i] != ')'){ i++; } } i++; break; case '(': return (calc(p + i + 1, 0)); case ')': case '\0': return (ans); default: puts("Error"); return (0); } } return (ans); }
#include "calc.h" #include <ctype.h> #include <stdio.h> #include <stdlib.h> double calc(const char* p, int mul_div_flag) { int i; double ans; if (p[0] != '(' && mul_div_flag == 1){ return (atof(p)); } else if (p[0] == '('){ ans = 0; } else { ans = atof(p); } i = 0; while (p[i] != '\0'){ while (isdigit(p[i])){ i++; } switch (p[i]){ case '+': return (ans + calc(p + i + 1, 0)); case '-': return (ans - calc(p + i + 1, 0)); case '*': ans *= calc(p + i + 1, 1); if (p[i + 1] == '('){ while (p[i] != ')'){ i++; } } i++; break; case '/': ans /= calc(p + i + 1, 1); if (p[i + 1] == '('){ while (p[i] != ')'){ i++; } } i++; break; case '(': return (calc(p + i + 1, 0)); case ')': case '\0': return (ans); default: puts("Error"); return (0); } } return (ans); }
Allow program to run to be specified on command line
#include <stdlib.h> #include <stdio.h> int main() { FILE *file; long length; char *buffer; file = fopen("example.minty", "r"); if (file == NULL) { return 1; } fseek(file, 0, SEEK_END); length = ftell(file); fseek(file, 0, SEEK_SET); buffer = (char *)malloc(length); fread(buffer, length, 1, file); fclose(file); printf("%s", buffer); return 0; }
#include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { FILE *file; long length; char *buffer; if (argc < 2) { return 1; } file = fopen(argv[1], "r"); if (file == NULL) { return 1; } fseek(file, 0, SEEK_END); length = ftell(file); fseek(file, 0, SEEK_SET); buffer = (char *)malloc(length); fread(buffer, length, 1, file); fclose(file); printf("%s", buffer); return 0; }
Revert "tests: drivers: build_all: add fake serial device for modem tests"
/* * Copyright (c) 2012-2014 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr.h> #include <sys/printk.h> #include <device.h> /* * @file * @brief Hello World demo */ void main(void) { printk("Hello World!\n"); } #if DT_NODE_EXISTS(DT_INST(0, vnd_gpio)) /* Fake GPIO device, needed for building drivers that use DEVICE_DT_GET() * to access GPIO controllers. */ DEVICE_DT_DEFINE(DT_INST(0, vnd_gpio), NULL, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL); #endif #if DT_NODE_EXISTS(DT_INST(0, vnd_serial)) /* Fake serial device, needed for building drivers that use DEVICE_DT_GET() * to access serial bus. */ DEVICE_DT_DEFINE(DT_INST(0, vnd_serial), NULL, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL); #endif
/* * Copyright (c) 2012-2014 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr.h> #include <sys/printk.h> #include <device.h> /* * @file * @brief Hello World demo */ void main(void) { printk("Hello World!\n"); } #if DT_NODE_EXISTS(DT_INST(0, vnd_gpio)) /* Fake GPIO device, needed for building drivers that use DEVICE_DT_GET() * to access GPIO controllers. */ DEVICE_DT_DEFINE(DT_INST(0, vnd_gpio), NULL, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL); #endif