Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Remove user from mobile list when disinhabiting
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2012 Raymond Jennings * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <kotaka/paths.h> #include <text/paths.h> inherit LIB_RAWVERB; void main(object actor, string args) { if (query_user()->query_body()) { query_user()->set_body(nil); } else { query_user()->quit(); } }
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2012 Raymond Jennings * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <kotaka/paths.h> #include <text/paths.h> #include <kotaka/assert.h> inherit LIB_RAWVERB; void main(object actor, string args) { object body; object user; user = query_user(); body = user->query_body(); if (body) { object *mobiles; ASSERT(actor == body); mobiles = body->query_property("mobiles"); body->set_property("mobiles", mobiles - ({ nil, user })); } else { query_user()->quit(); } }
Reorder the includes of the master include in alphabetical order.
/*! * Master header of the nstl library. * * @author Louis Dionne */ #ifndef NSTL_H #define NSTL_H #include <nstl/operator.h> #include <nstl/type.h> #include <nstl/primitive.h> #include <nstl/pair.h> #include <nstl/algorithm.h> #include <nstl/vector.h> #endif /* !NSTL_H */
/*! * Master header of the nstl library. * * @author Louis Dionne */ #ifndef NSTL_H #define NSTL_H #include <nstl/algorithm.h> #include <nstl/operator.h> #include <nstl/pair.h> #include <nstl/primitive.h> #include <nstl/type.h> #include <nstl/vector.h> #endif /* !NSTL_H */
Document local persisted logging API.
@class UINavigationController, UIViewController; @interface ARAnalyticalProvider : NSObject /// Init - (id)initWithIdentifier:(NSString *)identifier; /// Set a per user property - (void)identifyUserWithID:(NSString *)userID andEmailAddress:(NSString *)email; - (void)setUserProperty:(NSString *)property toValue:(NSString *)value; /// Submit user events - (void)event:(NSString *)event withProperties:(NSDictionary *)properties; - (void)incrementUserProperty:(NSString *)counterName byInt:(NSNumber *)amount; /// Submit errors - (void)error:(NSError *)error withMessage:(NSString *)message; /// Monitor Navigation changes as page view - (void)monitorNavigationViewController:(UINavigationController *)controller; /// Submit an event with a time interval - (void)logTimingEvent:(NSString *)event withInterval:(NSNumber *)interval; /// Submit an event with a time interval and extra properties /// @warning the properites must not contain the key string `length`. - (void)logTimingEvent:(NSString *)event withInterval:(NSNumber *)interval properties:(NSDictionary *)properties; /// Pass a specific event for showing a page - (void)didShowNewPageView:(NSString *)pageTitle; /// Submit a string to the provider's logging system - (void)remoteLog:(NSString *)parsedString; - (void)localLog:(NSString *)message; - (NSArray *)messagesForProcessID:(NSUInteger)processID; @end
@class UINavigationController, UIViewController; @interface ARAnalyticalProvider : NSObject /// Init - (id)initWithIdentifier:(NSString *)identifier; /// Set a per user property - (void)identifyUserWithID:(NSString *)userID andEmailAddress:(NSString *)email; - (void)setUserProperty:(NSString *)property toValue:(NSString *)value; /// Submit user events - (void)event:(NSString *)event withProperties:(NSDictionary *)properties; - (void)incrementUserProperty:(NSString *)counterName byInt:(NSNumber *)amount; /// Submit errors - (void)error:(NSError *)error withMessage:(NSString *)message; /// Monitor Navigation changes as page view - (void)monitorNavigationViewController:(UINavigationController *)controller; /// Submit an event with a time interval - (void)logTimingEvent:(NSString *)event withInterval:(NSNumber *)interval; /// Submit an event with a time interval and extra properties /// @warning the properites must not contain the key string `length`. - (void)logTimingEvent:(NSString *)event withInterval:(NSNumber *)interval properties:(NSDictionary *)properties; /// Pass a specific event for showing a page - (void)didShowNewPageView:(NSString *)pageTitle; /// Submit a string to the provider's logging system - (void)remoteLog:(NSString *)parsedString; /// Submit a string to the local persisted logging system - (void)localLog:(NSString *)message; /// Retrieve messages provided to the local persisted logging system originating from a specified process. - (NSArray *)messagesForProcessID:(NSUInteger)processID; @end
Clean unused argument in bx_exc_bindings
#include "bindex.h" VALUE bx_mBindex; static VALUE bx_current_bindings(VALUE self) { return current_bindings(); } static VALUE bx_exc_set_backtrace(VALUE self, VALUE bt) { /* rb_check_backtrace can raise an exception, if the input arguments are not * to its likings. Set the bindings afterwards, so we don't waste when not * needed. */ VALUE backtrace = rb_iv_set(self, "bt", rb_check_backtrace(bt)); rb_iv_set(self, "bindings", current_bindings()); return backtrace; } static VALUE bx_exc_bindings(VALUE self, VALUE bt) { VALUE bindings; bindings = rb_iv_get(self, "bindings"); if (NIL_P(bindings)) { bindings = rb_ary_new(); } return bindings; } void Init_cruby(void) { bx_mBindex = rb_define_module("Bindex"); rb_define_singleton_method(bx_mBindex, "current_bindings", bx_current_bindings, 0); rb_define_method(rb_eException, "set_backtrace", bx_exc_set_backtrace, 1); rb_define_method(rb_eException, "bindings", bx_exc_bindings, 0); }
#include "bindex.h" VALUE bx_mBindex; static VALUE bx_current_bindings(VALUE self) { return current_bindings(); } static VALUE bx_exc_set_backtrace(VALUE self, VALUE bt) { /* rb_check_backtrace can raise an exception, if the input arguments are not * to its likings. Set the bindings afterwards, so we don't waste when not * needed. */ VALUE backtrace = rb_iv_set(self, "bt", rb_check_backtrace(bt)); rb_iv_set(self, "bindings", current_bindings()); return backtrace; } static VALUE bx_exc_bindings(VALUE self) { VALUE bindings; bindings = rb_iv_get(self, "bindings"); if (NIL_P(bindings)) { bindings = rb_ary_new(); } return bindings; } void Init_cruby(void) { bx_mBindex = rb_define_module("Bindex"); rb_define_singleton_method(bx_mBindex, "current_bindings", bx_current_bindings, 0); rb_define_method(rb_eException, "set_backtrace", bx_exc_set_backtrace, 1); rb_define_method(rb_eException, "bindings", bx_exc_bindings, 0); }
Add global __RESTKIT__ define for aiding conditional compilation
// // RestKit.h // RestKit // // Created by Blake Watters on 2/19/10. // Copyright (c) 2009-2012 RestKit. 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. // #import "ObjectMapping.h" #import "Network.h" #import "Support.h" #import "CoreData.h" /** Set the App logging component. This header file is generally only imported by apps that are pulling in all of RestKit. By setting the log component to App here, we allow the app developer to use RKLog() in their own app. */ #undef RKLogComponent #define RKLogComponent RKlcl_cApp
// // RestKit.h // RestKit // // Created by Blake Watters on 2/19/10. // Copyright (c) 2009-2012 RestKit. 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 _RESTKIT_ #define _RESTKIT_ #import "ObjectMapping.h" #import "Network.h" #import "Support.h" #import "CoreData.h" /** Set the App logging component. This header file is generally only imported by apps that are pulling in all of RestKit. By setting the log component to App here, we allow the app developer to use RKLog() in their own app. */ #undef RKLogComponent #define RKLogComponent RKlcl_cApp #endif /* _RESTKIT_ */
Revert to lowercase macro arguments
// http://stackoverflow.com/a/7933931/141220 #define TDTSuppressPerformSelectorLeakWarning(CODE) \ do { \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ CODE; \ _Pragma("clang diagnostic pop") \ } while (0)
// http://stackoverflow.com/a/7933931/141220 #define TDTSuppressPerformSelectorLeakWarning(code) \ do { \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ code; \ _Pragma("clang diagnostic pop") \ } while (0)
Clear bit when writing to VDP2(TVMD)
/* * Copyright (c) 2012-2016 Israel Jacquez * See LICENSE for details. * * Israel Jacquez <mrkotfw@gmail.com> */ #include <vdp2/tvmd.h> #include "vdp-internal.h" void vdp2_tvmd_display_clear(void) { _state_vdp2()->regs.tvmd &= 0x7FFF; /* Change the DISP bit during VBLANK */ vdp2_tvmd_vblank_in_wait(); MEMORY_WRITE(16, VDP2(TVMD), _state_vdp2()->regs.tvmd); }
/* * Copyright (c) 2012-2016 Israel Jacquez * See LICENSE for details. * * Israel Jacquez <mrkotfw@gmail.com> */ #include <vdp2/tvmd.h> #include "vdp-internal.h" void vdp2_tvmd_display_clear(void) { _state_vdp2()->regs.tvmd &= 0x7EFF; /* Change the DISP bit during VBLANK */ vdp2_tvmd_vblank_in_wait(); MEMORY_WRITE(16, VDP2(TVMD), _state_vdp2()->regs.tvmd); }
Add 1 more macro for debugging 3 things.
// // SRDebug.h // Sensorama // // Created by Wojciech Adam Koszek (h) on 09/04/2016. // Copyright © 2016 Wojciech Adam Koszek. All rights reserved. // #ifndef SRDebug_h #define SRDebug_h #define SRPROBE0() do { \ NSLog(@"%s", __func__); \ } while (0) #define SRPROBE1(x1) do { \ NSLog(@"%s %s=%@", __func__, #x1, (x1)); \ } while (0) #define SRPROBE2(x1, x2) do { \ NSLog(@"%s %s=%@ %s=%@", __func__, #x1, (x1), #x2, (x2)); \ } while (0) #define SRDEBUG if (1) NSLog #endif /* SRDebug_h */
// // SRDebug.h // Sensorama // // Created by Wojciech Adam Koszek (h) on 09/04/2016. // Copyright © 2016 Wojciech Adam Koszek. All rights reserved. // #ifndef SRDebug_h #define SRDebug_h #define SRPROBE0() do { \ NSLog(@"%s", __func__); \ } while (0) #define SRPROBE1(x1) do { \ NSLog(@"%s %s=%@", __func__, #x1, (x1)); \ } while (0) #define SRPROBE2(x1, x2) do { \ NSLog(@"%s %s=%@ %s=%@", __func__, #x1, (x1), #x2, (x2)); \ } while (0) #define SRPROBE3(x1, x2, x3) do { \ NSLog(@"%s %s=%@ %s=%@ %s=%@", __func__, #x1, (x1), #x2, (x2), #x3, (x3)); \ } while (0) #define SRDEBUG if (1) NSLog #endif /* SRDebug_h */
Add test intended for commit in r231317
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-apple-darwin // expected-error@+1 {{argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment and section separated by a comma}} #pragma data_seg(".my_const") int a = 1; #pragma data_seg("__THINGY,thingy") int b = 1;
Check against sum, 30 second improvement
#include <stdio.h> #define CAP 8 const int currency[CAP] = {1, 2, 5, 10, 20, 50, 100, 200}; int total[CAP] = {0, 0, 0, 0, 0, 0, 0, 0}; const int limit = 200; static inline int calculate_total(void) { int sum = 0; for (int i=0; i < CAP; i++) sum += total[i]; return sum; } int main(int argc, char *argv[]) { int ways = 0; int idx = 0; while (total[idx] <= limit && (idx != CAP)) { total[idx] += currency[idx]; int sum = calculate_total(); if (sum == limit) ways++; if (total[idx] < limit) idx = 0; else if (total[idx] >= limit) { total[idx] = 0; idx++; } } printf("Answer: %d\n", ways); return 0; }
#include <stdio.h> #define CAP 8 const int currency[CAP] = {1, 2, 5, 10, 20, 50, 100, 200}; int total[CAP] = {0, 0, 0, 0, 0, 0, 0, 0}; const int limit = 200; static inline int calculate_total(void) { int sum = 0; for (int i=0; i < CAP; i++) sum += total[i]; return sum; } int main(int argc, char *argv[]) { int ways = 0; int idx = 0; while (total[idx] <= limit && (idx != CAP)) { total[idx] += currency[idx]; int sum = calculate_total(); if (sum < limit) idx = 0; else { if (sum == limit) ways++; total[idx] = 0; idx++; } } printf("Answer: %d\n", ways); return 0; }
Handle instances when "realloc()" fails.
/* * A simple Brainfuck interpreter. * * This file was written by Damien Dart, <damiendart@pobox.com>. This is free * and unencumbered software released into the public domain. For more * information, please refer to the accompanying "UNLICENCE" file. */ #include <errno.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "brainfuck.h" int main(void) { char character = 0; char *commands = NULL; uint32_t number_of_commands = 0; while((character = getchar()) != EOF) { if ((character == '>') || (character == '<') || (character == '+') || (character == '-') || (character == '.') || (character == ',') || (character == '[') || (character == ']')) { char *temp = realloc(commands, ++number_of_commands * sizeof(char)); if (temp == NULL) { free(commands); perror("Unable to create command list"); exit(EXIT_FAILURE); } commands = temp; commands[number_of_commands - 1] = character; } } commands = realloc(commands, ++number_of_commands * sizeof(char)); commands[number_of_commands - 1] = '\0'; brainfuck_evaluate(commands); free(commands); return EXIT_SUCCESS; }
/* * A simple Brainfuck interpreter. * * This file was written by Damien Dart, <damiendart@pobox.com>. This is free * and unencumbered software released into the public domain. For more * information, please refer to the accompanying "UNLICENCE" file. */ #include <errno.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "brainfuck.h" void *realloc2(void *, size_t); int main(void) { char character = 0; char *commands = NULL; uint32_t number_of_commands = 0; while((character = getchar()) != EOF) { commands = realloc2(commands, ++number_of_commands * sizeof(char)); commands[number_of_commands - 1] = character; } commands = realloc2(commands, ++number_of_commands * sizeof(char)); commands[number_of_commands - 1] = '\0'; brainfuck_evaluate(commands); free(commands); return EXIT_SUCCESS; } void *realloc2(void *ptr, size_t size) { char *new_obj = realloc(ptr, size); if (new_obj == NULL) { free(ptr); strerror(errno); exit(EXIT_FAILURE); } return new_obj; }
Fix copy paste error in file header
/*===-- vectorize_ocaml.c - LLVM OCaml Glue ---------------------*- C++ -*-===*\ |* *| |* The LLVM Compiler Infrastructure *| |* *| |* This file is distributed under the University of Illinois Open Source *| |* License. See LICENSE.TXT for details. *| |* *| |*===----------------------------------------------------------------------===*| |* *| |* This file glues LLVM's OCaml interface to its C interface. These functions *| |* are by and large transparent wrappers to the corresponding C functions. *| |* *| |* Note that these functions intentionally take liberties with the CAMLparamX *| |* macros, since most of the parameters are not GC heap objects. *| |* *| \*===----------------------------------------------------------------------===*/ #include "llvm-c/Core.h" #include "caml/mlvalues.h" #include "caml/misc.h" /* * Do not move directly into external. This function is here to pull in * -lLLVMTransformUtils, which would otherwise be not linked on static builds, * as ld can't see the reference from OCaml code. */ /* llmodule -> llmodule */ CAMLprim LLVMModuleRef llvm_clone_module(LLVMModuleRef M) { return LLVMCloneModule(M); }
/*===-- transform_utils_ocaml.c - LLVM OCaml Glue ---------------*- C++ -*-===*\ |* *| |* The LLVM Compiler Infrastructure *| |* *| |* This file is distributed under the University of Illinois Open Source *| |* License. See LICENSE.TXT for details. *| |* *| |*===----------------------------------------------------------------------===*| |* *| |* This file glues LLVM's OCaml interface to its C interface. These functions *| |* are by and large transparent wrappers to the corresponding C functions. *| |* *| |* Note that these functions intentionally take liberties with the CAMLparamX *| |* macros, since most of the parameters are not GC heap objects. *| |* *| \*===----------------------------------------------------------------------===*/ #include "llvm-c/Core.h" #include "caml/mlvalues.h" #include "caml/misc.h" /* * Do not move directly into external. This function is here to pull in * -lLLVMTransformUtils, which would otherwise be not linked on static builds, * as ld can't see the reference from OCaml code. */ /* llmodule -> llmodule */ CAMLprim LLVMModuleRef llvm_clone_module(LLVMModuleRef M) { return LLVMCloneModule(M); }
Add a non-ip network string xmit concept
/* Copyright 2019 Lenovo */ #include <arpa/inet.h> #include <crypt.h> #include <net/if.h> #include <sys/socket.h> #include <stdio.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #define OUI_ETHERTYPE 0x88b7 #define MAXPACKET 1024 #define CHDR "\xa4\x8c\xdb\x30\x01" int get_interface_index(int sock, char *interface) { struct ifreq req; memset(&req, 0, sizeof(req)); strncpy(req.ifr_name, interface, IFNAMSIZ); if (ioctl(sock, SIOCGIFINDEX, &req) < 0) { return -1; } return req.ifr_ifindex; } unsigned char* genpasswd() { unsigned char * passwd; int urandom; passwd = calloc(33, sizeof(char)); urandom = open("/dev/urandom", O_RDONLY); read(urandom, passwd, 32); close(urandom); for (urandom = 0; urandom < 32; urandom++) { passwd[urandom] = 0x30 + (passwd[urandom] >> 2); } return passwd; } int parse_macaddr(char* macaddr) { unsigned char *curr; unsigned char idx; curr = strtok(macaddr, ":-"); idx = 0; while (curr != NULL) { macaddr[idx++] = strtoul(curr, NULL, 16); curr = strtok(NULL, ":-"); } } int main(int argc, char* argv[]) { int sock; int iface; unsigned char* passwd; unsigned char* macaddr; unsigned char buffer[MAXPACKET]; passwd = genpasswd(); if (argc < 3) { fprintf(stderr, "Missing interface name and target MAC\n"); exit(1); } printf("%s\n", argv[2]); parse_macaddr(argv[2]); printf("%s\n", argv[2]); sock = socket(AF_PACKET, SOCK_DGRAM, htons(OUI_ETHERTYPE)); if (sock < 0) { fprintf(stderr, "Unable to open socket (run as root?)\n"); exit(1); } iface = get_interface_index(sock, argv[1]); if (iface < 0) { fprintf(stderr, "Unable to find specified interface '%s'\n", argv[1]); exit(1); } }
Fix test to use %t for newly created files.
// REQUIRES: shell // RUN: mkdir -p out.dir // RUN: cat %s > out.dir/test.c // RUN: %clang -E -MMD %s -o out.dir/test // RUN: test ! -f %out.d // RUN: test -f out.dir/test.d // RUN: rm -rf out.dir/test.d out.dir/ out.d int main (void) { return 0; }
// REQUIRES: shell // RUN: mkdir -p %t/out.dir // RUN: cat %s > %t/out.dir/test.c // RUN: %clang -E -MMD %s -o %t/out.dir/test // RUN: test ! -f %out.d // RUN: test -f %t/out.dir/test.d // RUN: rm -rf %t/out.dir/test.d %t/out.dir/ out.d int main (void) { return 0; }
Test incomplete tenative multi-dimension expressions
// RUN: %ucc -fsyntax-only %s int a[][2]; int main() { a[0][0] = 3; /* this tests a bug where the above assignment would attempt to check integer * promotions (on a dereference of an array in the LHS), and attempt to find * the size of `a` before it had been completed. integer promotions are now * handled properly */ }
Add newline to remove compiler warning.
#ifndef LOCATION_OPENLOCATIONCODE_CODEAREA_H_ #define LOCATION_OPENLOCATIONCODE_CODEAREA_H_ #include <cstdlib> namespace openlocationcode { struct LatLng { double latitude; double longitude; }; class CodeArea { public: CodeArea(double latitude_lo, double longitude_lo, double latitude_hi, double longitude_hi, size_t code_length); double GetLatitudeLo() const; double GetLongitudeLo() const; double GetLatitudeHi() const; double GetLongitudeHi() const; size_t GetCodeLength() const; LatLng GetCenter() const; private: double latitude_lo_; double longitude_lo_; double latitude_hi_; double longitude_hi_; size_t code_length_; }; } // namespace openlocationcode #endif // LOCATION_OPENLOCATIONCODE_CODEAREA_H_
#ifndef LOCATION_OPENLOCATIONCODE_CODEAREA_H_ #define LOCATION_OPENLOCATIONCODE_CODEAREA_H_ #include <cstdlib> namespace openlocationcode { struct LatLng { double latitude; double longitude; }; class CodeArea { public: CodeArea(double latitude_lo, double longitude_lo, double latitude_hi, double longitude_hi, size_t code_length); double GetLatitudeLo() const; double GetLongitudeLo() const; double GetLatitudeHi() const; double GetLongitudeHi() const; size_t GetCodeLength() const; LatLng GetCenter() const; private: double latitude_lo_; double longitude_lo_; double latitude_hi_; double longitude_hi_; size_t code_length_; }; } // namespace openlocationcode #endif // LOCATION_OPENLOCATIONCODE_CODEAREA_H_
Add end of line at end.
// RUN: clang -triple x86_64-unknown-unknown -emit-llvm -o %t %s && // RUN: grep 'define signext i8 @f0()' %t && // RUN: grep 'define signext i16 @f1()' %t && // RUN: grep 'define i32 @f2()' %t && // RUN: grep 'define float @f3()' %t && // RUN: grep 'define double @f4()' %t && // RUN: grep 'define x86_fp80 @f5()' %t && // RUN: grep 'define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8\* %a4)' %t && // RUN: grep 'define void @f7(i32 %a0)' %t char f0(void) { } short f1(void) { } int f2(void) { } float f3(void) { } double f4(void) { } long double f5(void) { } void f6(char a0, short a1, int a2, long long a3, void *a4) { } typedef enum { A, B, C } E; void f7(E a0) { }
// RUN: clang -triple x86_64-unknown-unknown -emit-llvm -o %t %s && // RUN: grep 'define signext i8 @f0()' %t && // RUN: grep 'define signext i16 @f1()' %t && // RUN: grep 'define i32 @f2()' %t && // RUN: grep 'define float @f3()' %t && // RUN: grep 'define double @f4()' %t && // RUN: grep 'define x86_fp80 @f5()' %t && // RUN: grep 'define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8\* %a4)' %t && // RUN: grep 'define void @f7(i32 %a0)' %t char f0(void) { } short f1(void) { } int f2(void) { } float f3(void) { } double f4(void) { } long double f5(void) { } void f6(char a0, short a1, int a2, long long a3, void *a4) { } typedef enum { A, B, C } E; void f7(E a0) { }
Make xwait return exit status
#if !defined(XV6_USER) #include <sys/wait.h> #define xfork() fork() static inline void xwait() { int status; if (wait(&status) < 0) edie("wait"); if (!WIFEXITED(status)) die("bad status %u", status); } #define mtenable(x) do { } while(0) #define mtenable_type(x, y) do { } while (0) #define mtdisable(x) do { } while(0) #define xpthread_join(tid) pthread_join(tid, nullptr); #define xthread_create(ptr, x, fn, arg) \ pthread_create((ptr), 0, (fn), (arg)) #else // Must be xv6 #define xfork() fork(0) #define xwait() wait(-1) #define xpthread_join(tid) wait(tid) #endif
#pragma once #include "libutil.h" #if !defined(XV6_USER) #include <sys/wait.h> #define xfork() fork() static inline int xwait() { int status; if (wait(&status) < 0) edie("wait"); if (!WIFEXITED(status)) die("bad status %u", status); return WEXITSTATUS(status); } #define mtenable(x) do { } while(0) #define mtenable_type(x, y) do { } while (0) #define mtdisable(x) do { } while(0) #define xpthread_join(tid) pthread_join(tid, nullptr); #define xthread_create(ptr, x, fn, arg) \ pthread_create((ptr), 0, (fn), (arg)) #else // Must be xv6 extern "C" int wait(int); #define xfork() fork(0) static inline int xwait() { if (wait(-1) < 0) edie("wait"); return 0; } #define xpthread_join(tid) wait(tid) #endif
Add a backport of G_DBUS_METHOD_INVOCATION_HANDLED
/* * Copyright © 2019 Red Hat, Inc * * This program 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/>. * * Authors: * Alexander Larsson <alexl@redhat.com> */ #ifndef __FLATPAK_UTILS_BASE_H__ #define __FLATPAK_UTILS_BASE_H__ #include <glib.h> char *flatpak_get_timezone (void); char * flatpak_readlink (const char *path, GError **error); char * flatpak_resolve_link (const char *path, GError **error); char * flatpak_canonicalize_filename (const char *path); void flatpak_close_fds_workaround (int start_fd); #endif /* __FLATPAK_UTILS_BASE_H__ */
/* * Copyright © 2019 Red Hat, Inc * * This program 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/>. * * Authors: * Alexander Larsson <alexl@redhat.com> */ #ifndef __FLATPAK_UTILS_BASE_H__ #define __FLATPAK_UTILS_BASE_H__ #include <glib.h> #include <gio/gio.h> #ifndef G_DBUS_METHOD_INVOCATION_HANDLED # define G_DBUS_METHOD_INVOCATION_HANDLED TRUE # define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE #endif char *flatpak_get_timezone (void); char * flatpak_readlink (const char *path, GError **error); char * flatpak_resolve_link (const char *path, GError **error); char * flatpak_canonicalize_filename (const char *path); void flatpak_close_fds_workaround (int start_fd); #endif /* __FLATPAK_UTILS_BASE_H__ */
Use MemAvailable for "free mem"
#ifndef SYSSTATS_H #define SYSSTATS_H #include <stdbool.h> #include <ncurses.h> #include <sys/timerfd.h> #include "../util/file_utils.h" #define MAXTOT 16 #define BASE 1024 #define MAXPIDS "/proc/sys/kernel/pid_max" #define MEMFREE "MemFree:" #define SECS 60 #define TIME_READ_DEFAULT 0 #define SYS_TIMER_EXPIRED_SEC 0 #define SYS_TIMER_EXPIRED_NSEC 0 #define SYS_TIMER_LENGTH 1 #define PTY_BUFFER_SZ 64 #define NRPTYS "/proc/sys/kernel/pty/nr" typedef struct { char *fstype; uid_t euid; int max_pids; long memtotal; char **current_pids; } sysaux; void build_sys_info(WINDOW *system_window, char *fstype); char *mem_avail(unsigned long memory, unsigned long base); void current_uptime(WINDOW *system_window, unsigned long seconds, int y, int x); int nr_ptys(void); bool is_sysfield_timer_expired(int sys_timer_fd); int set_sys_timer(struct itimerspec *sys_timer); int max_pids(void); #endif
#ifndef SYSSTATS_H #define SYSSTATS_H #include <stdbool.h> #include <ncurses.h> #include <sys/timerfd.h> #include "../util/file_utils.h" #define MAXTOT 16 #define BASE 1024 #define MAXPIDS "/proc/sys/kernel/pid_max" #define MEMFREE "MemAvailable:" #define SECS 60 #define TIME_READ_DEFAULT 0 #define SYS_TIMER_EXPIRED_SEC 0 #define SYS_TIMER_EXPIRED_NSEC 0 #define SYS_TIMER_LENGTH 1 #define PTY_BUFFER_SZ 64 #define NRPTYS "/proc/sys/kernel/pty/nr" typedef struct { char *fstype; uid_t euid; int max_pids; long memtotal; char **current_pids; } sysaux; void build_sys_info(WINDOW *system_window, char *fstype); char *mem_avail(unsigned long memory, unsigned long base); void current_uptime(WINDOW *system_window, unsigned long seconds, int y, int x); int nr_ptys(void); bool is_sysfield_timer_expired(int sys_timer_fd); int set_sys_timer(struct itimerspec *sys_timer); int max_pids(void); #endif
Use the correct type for the linked list pointer.
/* WebVTT parser Copyright 2011 Mozilla Foundation */ #ifndef _WEBVTT_H_ #define _WEBVTT_H_ /* webvtt files are a sequence of cues each cue has a start and end time for presentation and some text content (which my be marked up) there may be other attributes, but we ignore them we store these in a linked list */ struct webvtt_cue { char *text; /** text value of the cue */ long start, end; /** timestamps in milliseconds */ struct cue *next; /** pointer to the next cue */ }; typedef struct webvtt_cue webvtt_cue; /* context structure for our parser */ typedef struct webvtt_parser webvtt_parser; /* allocate and initialize a parser context */ webvtt_parser *webvtt_parse_new(void); /* shut down and release a parser context */ void webvtt_parse_free(webvtt_parser *ctx); /* read a webvtt file from an open file */ struct webvtt_cue * webvtt_parse_file(webvtt_parser *ctx, FILE *in); /* read a webvtt file from a named file */ struct webvtt_cue * webvtt_parse_filename(webvtt_parser *ctx, const char *filename); #endif /* _WEBVTT_H_ */
/* WebVTT parser Copyright 2011 Mozilla Foundation */ #ifndef _WEBVTT_H_ #define _WEBVTT_H_ /* webvtt files are a sequence of cues each cue has a start and end time for presentation and some text content (which my be marked up) there may be other attributes, but we ignore them we store these in a linked list */ typedef struct webvtt_cue webvtt_cue; struct webvtt_cue { char *text; /** text value of the cue */ long start, end; /** timestamps in milliseconds */ webvtt_cue *next; /** pointer to the next cue */ }; /* context structure for our parser */ typedef struct webvtt_parser webvtt_parser; /* allocate and initialize a parser context */ webvtt_parser *webvtt_parse_new(void); /* shut down and release a parser context */ void webvtt_parse_free(webvtt_parser *ctx); /* read a webvtt file from an open file */ struct webvtt_cue * webvtt_parse_file(webvtt_parser *ctx, FILE *in); /* read a webvtt file from a named file */ struct webvtt_cue * webvtt_parse_filename(webvtt_parser *ctx, const char *filename); #endif /* _WEBVTT_H_ */
Make close button properties optional.
// // YTConnector.h // AKYouTube // // Created by Anton Pomozov on 10.09.13. // Copyright (c) 2013 Akademon Ltd. All rights reserved. // #import <Foundation/Foundation.h> @class YTConnector; @protocol YTLoginViewControllerInterface <NSObject> @property (nonatomic, strong, readonly) UIWebView *webView; @property (nonatomic, assign) BOOL shouldPresentCloseButton; @property (nonatomic, strong) UIImage *closeButtonImageName; @end @protocol YTConnectorDelegate <NSObject> - (void)presentLoginViewControler:(UIViewController<YTLoginViewControllerInterface> *)loginViewController; - (void)connectionEstablished; - (void)connectionDidFailWithError:(NSError *)error; - (void)appDidFailAuthorize; - (void)userRejectedApp; @end @interface YTConnector : NSObject @property (nonatomic, weak) id<YTConnectorDelegate> delegate; + (YTConnector *)sharedInstance; - (void)connectWithClientId:(NSString *)clientId andClientSecret:(NSString *)clientSecret; - (void)authorizeAppWithScopesList:(NSString *)scopesList inLoginViewController:(UIViewController<YTLoginViewControllerInterface> *)loginViewController; @end
// // YTConnector.h // AKYouTube // // Created by Anton Pomozov on 10.09.13. // Copyright (c) 2013 Akademon Ltd. All rights reserved. // #import <Foundation/Foundation.h> @class YTConnector; @protocol YTLoginViewControllerInterface <NSObject> @property (nonatomic, strong, readonly) UIWebView *webView; @optional @property (nonatomic, assign) BOOL shouldPresentCloseButton; @property (nonatomic, strong) UIImage *closeButtonImageName; @end @protocol YTConnectorDelegate <NSObject> - (void)presentLoginViewControler:(UIViewController<YTLoginViewControllerInterface> *)loginViewController; - (void)connectionEstablished; - (void)connectionDidFailWithError:(NSError *)error; - (void)appDidFailAuthorize; - (void)userRejectedApp; @end @interface YTConnector : NSObject @property (nonatomic, weak) id<YTConnectorDelegate> delegate; + (YTConnector *)sharedInstance; - (void)connectWithClientId:(NSString *)clientId andClientSecret:(NSString *)clientSecret; - (void)authorizeAppWithScopesList:(NSString *)scopesList inLoginViewController:(UIViewController<YTLoginViewControllerInterface> *)loginViewController; @end
Fix crash wrong order of member initialization.
#ifndef FUNCTION_DECLARATION_H #define FUNCTION_DECLARATION_H #include "AstNode.h" namespace liquid { class FunctionDeclaration : public Statement { friend class ClassDeclaration; Identifier* type; Identifier* id; VariableList* arguments; Block* block; YYLTYPE location; public: FunctionDeclaration( Identifier* type, Identifier* id, VariableList* arguments, Block* block, YYLTYPE loc ) : type( type ), id( id ), arguments( arguments ), block( block ), location( loc ) {} FunctionDeclaration( Identifier* id, VariableList* arguments, Block* block, YYLTYPE loc ) : type( new Identifier( "var", location ) ), id( id ), arguments( arguments ), block( block ), location( loc ) {} virtual ~FunctionDeclaration(); virtual llvm::Value* codeGen( CodeGenContext& context ); NodeType getType() { return NodeType::function; } Identifier* getId() { return id; } virtual std::string toString(); virtual void Accept( Visitor& v ) { v.VisitFunctionDeclaration( this ); } virtual VariableList* getParameter() { return arguments; } virtual Block* getBody() { return block; } virtual Identifier* getRetType() { return type; } YYLTYPE getlocation() { return location; } }; } #endif // FUNCTION_DECLARATION_H
#ifndef FUNCTION_DECLARATION_H #define FUNCTION_DECLARATION_H #include "AstNode.h" namespace liquid { class FunctionDeclaration : public Statement { friend class ClassDeclaration; Identifier* type; Identifier* id; VariableList* arguments; Block* block; YYLTYPE location; public: FunctionDeclaration( Identifier* type, Identifier* id, VariableList* arguments, Block* block, YYLTYPE loc ) : type( type ), id( id ), arguments( arguments ), block( block ), location( loc ) {} FunctionDeclaration( Identifier* id, VariableList* arguments, Block* block, YYLTYPE loc ) : type(new Identifier("var", loc)), id(id), arguments(arguments), block(block), location(loc) {} virtual ~FunctionDeclaration(); virtual llvm::Value* codeGen( CodeGenContext& context ); NodeType getType() { return NodeType::function; } Identifier* getId() { return id; } virtual std::string toString(); virtual void Accept( Visitor& v ) { v.VisitFunctionDeclaration( this ); } virtual VariableList* getParameter() { return arguments; } virtual Block* getBody() { return block; } virtual Identifier* getRetType() { return type; } YYLTYPE getlocation() { return location; } }; } #endif // FUNCTION_DECLARATION_H
Add MPS compile time option for enabling/disabling assertions
/* * Copyright The Mbed TLS Contributors * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ /** * \file common.h * * \brief Common functions and macros used by MPS */ #ifndef MBEDTLS_MPS_COMMON_H #define MBEDTLS_MPS_COMMON_H /* To be populated */ #endif /* MBEDTLS_MPS_COMMON_H */
/* * Copyright The Mbed TLS Contributors * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ /** * \file common.h * * \brief Common functions and macros used by MPS */ #ifndef MBEDTLS_MPS_COMMON_H #define MBEDTLS_MPS_COMMON_H /** * \name SECTION: MPS Configuration * * \{ */ /*! This flag enables/disables assertions on the internal state of MPS. * * Assertions are sanity checks that should never trigger when MPS * is used within the bounds of its API and preconditions. * * Enabling this increases security by limiting the scope of * potential bugs, but comes at the cost of increased code size. * * Note: So far, there is no guiding principle as to what * expected conditions merit an assertion, and which don't. * * Comment this to disable assertions. */ #define MBEDTLS_MPS_ENABLE_ASSERTIONS /* \} name SECTION: MPS Configuration */ #endif /* MBEDTLS_MPS_COMMON_H */
Add RDA5981 exif logic for I2S module
/* mbed Microcontroller Library * Copyright (c) 2006-2013 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "rda5981x_i2s.h" #include "arch/rda5981/irq.h" #define RDA_EXIF_INTST (RDA_EXIF->MISCSTCFG) static uint8_t is_exif_irq_set = 0; static void rda_exif_isr(int irq, void *context, void *arg) { uint32_t int_status = RDA_EXIF_INTST & 0xFFFF0000; if(int_status & 0x00FC0000) { rda_i2s_irq_handler(int_status); } } void rda_exif_irq_set(void) { if(0 == is_exif_irq_set) { is_exif_irq_set = 1; irq_attach(RDA_IRQ_EXIF, (uint32_t)rda_exif_isr,(void*)0); up_enable_irq(RDA_IRQ_EXIF); } }
Remove signature of deleted function
/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (C) 2017, James R. Barlow (https://github.com/jbarlow83/) */ #pragma once #include "pikepdf.h" py::object fspath(py::object filename); FILE *portable_fopen(py::object filename, const char* mode); void portable_unlink(py::object filename);
/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (C) 2017, James R. Barlow (https://github.com/jbarlow83/) */ #pragma once #include "pikepdf.h" py::object fspath(py::object filename); FILE *portable_fopen(py::object filename, const char* mode);
Remove unnecessary import for 'mach-o/arch.h'
// // src/tbd/symbol.h // tbd // // Created by inoahdev on 4/24/17. // Copyright © 2017 inoahdev. All rights reserved. // #pragma once #include <mach-o/arch.h> #include <string> #include "flags.h" class symbol { public: explicit symbol(const char *string, bool weak, int flags_length) noexcept; void add_architecture(int number) noexcept; inline const bool weak() const noexcept { return weak_; } inline const char *string() const noexcept { return string_; } inline const flags &flags() const noexcept { return flags_; } inline const bool operator==(const char *string) const noexcept { return strcmp(string_, string) == 0; } inline const bool operator==(const symbol &symbol) const noexcept { return strcmp(string_, symbol.string_) == 0; } inline const bool operator!=(const char *string) const noexcept { return strcmp(string_, string) != 0; } inline const bool operator!=(const symbol &symbol) const noexcept { return strcmp(string_, symbol.string_) != 0; } private: const char *string_; bool weak_; class flags flags_; };
// // src/tbd/symbol.h // tbd // // Created by inoahdev on 4/24/17. // Copyright © 2017 inoahdev. All rights reserved. // #pragma once #include <string> #include "flags.h" class symbol { public: explicit symbol(const char *string, bool weak, int flags_length) noexcept; void add_architecture(int number) noexcept; inline const bool weak() const noexcept { return weak_; } inline const char *string() const noexcept { return string_; } inline const flags &flags() const noexcept { return flags_; } inline const bool operator==(const char *string) const noexcept { return strcmp(string_, string) == 0; } inline const bool operator==(const symbol &symbol) const noexcept { return strcmp(string_, symbol.string_) == 0; } inline const bool operator!=(const char *string) const noexcept { return strcmp(string_, string) != 0; } inline const bool operator!=(const symbol &symbol) const noexcept { return strcmp(string_, symbol.string_) != 0; } private: const char *string_; bool weak_; class flags flags_; };
Enable including all bindings in implicit bindings
#ifndef SAUCE_SAUCE_INTERNAL_IMPLICIT_BINDINGS_H_ #define SAUCE_SAUCE_INTERNAL_IMPLICIT_BINDINGS_H_ // #include <sauce/internal/bindings/all.h> namespace sauce { namespace internal { /** * Attempts to supply a Binding to Bindings when none is found for a dependency. */ struct ImplicitBindings {}; } namespace i = ::sauce::internal; } #endif // SAUCE_SAUCE_INTERNAL_IMPLICIT_BINDINGS_H_
#ifndef SAUCE_SAUCE_INTERNAL_IMPLICIT_BINDINGS_H_ #define SAUCE_SAUCE_INTERNAL_IMPLICIT_BINDINGS_H_ #include <sauce/internal/bindings/all.h> namespace sauce { namespace internal { /** * Attempts to supply a Binding to Bindings when none is found for a dependency. */ struct ImplicitBindings {}; } namespace i = ::sauce::internal; } #endif // SAUCE_SAUCE_INTERNAL_IMPLICIT_BINDINGS_H_
Update RingOpenGL - Add Function (Source Code) : void glAccum(GLenum op,GLfloat value)
#include "ring.h" /* OpenGL 2.1 Extension Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com> */ #include <GL/glew.h> #include <GL/glut.h> RING_API void ringlib_init(RingState *pRingState) { }
#include "ring.h" /* OpenGL 2.1 Extension Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com> */ #include <GL/glew.h> #include <GL/glut.h> RING_FUNC(ring_glAccum) { if ( RING_API_PARACOUNT != 2 ) { RING_API_ERROR(RING_API_MISS2PARA); return ; } if ( ! RING_API_ISNUMBER(1) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } if ( ! RING_API_ISNUMBER(2) ) { RING_API_ERROR(RING_API_BADPARATYPE); return ; } glAccum( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2)); } RING_API void ringlib_init(RingState *pRingState) { ring_vm_funcregister("glaccum",ring_glAccum); }
Update the version number of release.
#define MAJOR_VERSION 3 #define MINOR_VERSION 1 #define BUILD_VERSION 0 #define BUILD_REVISION 5172 #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) #define REVISION_STRING MACRO_STRINGIFY(BUILD_REVISION) #define VERSION_STRING MACRO_STRINGIFY(MAJOR_VERSION) "." MACRO_STRINGIFY(MINOR_VERSION) "." MACRO_STRINGIFY(BUILD_VERSION) "." MACRO_STRINGIFY(BUILD_REVISION)
#define MAJOR_VERSION 3 #define MINOR_VERSION 2 #define BUILD_VERSION 6 #define BUILD_REVISION 45159 #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) #define REVISION_STRING MACRO_STRINGIFY(BUILD_REVISION) #define VERSION_STRING MACRO_STRINGIFY(MAJOR_VERSION) "." MACRO_STRINGIFY(MINOR_VERSION) "." MACRO_STRINGIFY(BUILD_VERSION) "." MACRO_STRINGIFY(BUILD_REVISION)
Add recursive divide and conquer algorithm for arrays
#include <stdio.h> #include <stdlib.h> #include <time.h> #define N 100 typedef int Item; Item max(Item *, int, int); int main(void) { int i; Item m, a[N]; srand(time(NULL)); for (i = 0; i < N; ++i) { a[i] = rand() % 1000; } m = max(a, 0, N-1); printf("Max array value is: %d\n", m); return 0; } Item max(Item a[], int l, int r) { Item u, v; int m = (l+r)/2; if (l == r) return a[l]; u = max(a, l, m); v = max(a, m+1, r); if (u > v) return u; else return v; }
Fix signed and unsigned comparison
#include <stdlib.h> #include <string.h> #include "rna_transcription.h" char *to_rna(const char *dna) { size_t len = strlen(dna); char *rna = malloc(sizeof(char) * len); for (int i = 0; i < len; i++) { switch (dna[i]) { case 'G': rna[i] = 'C'; break; case 'C': rna[i] = 'G'; break; case 'T': rna[i] = 'A'; break; case 'A': rna[i] = 'U'; break; default: free(rna); return NULL; } } return rna; }
#include <stdlib.h> #include <string.h> #include "rna_transcription.h" char *to_rna(const char *dna) { size_t len = strlen(dna); char *rna = malloc(sizeof(char) * len); for (size_t i = 0; i < len; i++) { switch (dna[i]) { case 'G': rna[i] = 'C'; break; case 'C': rna[i] = 'G'; break; case 'T': rna[i] = 'A'; break; case 'A': rna[i] = 'U'; break; default: free(rna); return NULL; } } return rna; }
Work around missing parsing functionality
#ifndef VAST_CONCEPT_PARSEABLE_VAST_KEY_H #define VAST_CONCEPT_PARSEABLE_VAST_KEY_H #include "vast/key.h" #include "vast/concept/parseable/core/choice.h" #include "vast/concept/parseable/core/list.h" #include "vast/concept/parseable/core/operators.h" #include "vast/concept/parseable/core/parser.h" #include "vast/concept/parseable/core/plus.h" #include "vast/concept/parseable/string/char_class.h" namespace vast { struct key_parser : parser<key_parser> { using attribute = key; template <typename Iterator, typename Attribute> bool parse(Iterator& f, Iterator const& l, Attribute& a) const { using namespace parsers; static auto p = +(alnum | chr{'_'} | chr{':'}) % '.'; return p.parse(f, l, a); } }; template <> struct parser_registry<key> { using type = key_parser; }; namespace parsers { static auto const key = make_parser<vast::key>(); } // namespace parsers } // namespace vast #endif
#ifndef VAST_CONCEPT_PARSEABLE_VAST_KEY_H #define VAST_CONCEPT_PARSEABLE_VAST_KEY_H #include "vast/key.h" #include "vast/concept/parseable/core/choice.h" #include "vast/concept/parseable/core/list.h" #include "vast/concept/parseable/core/operators.h" #include "vast/concept/parseable/core/parser.h" #include "vast/concept/parseable/core/plus.h" #include "vast/concept/parseable/string/char_class.h" namespace vast { struct key_parser : parser<key_parser> { using attribute = key; template <typename Iterator, typename Attribute> bool parse(Iterator& f, Iterator const& l, Attribute& a) const { // FIXME: we currently cannot parse character sequences into containers, // e.g., (alpha | '_') >> +(alnum ...). Until we have enhanced the // framework, we'll just bail out when we find a colon at the beginning. if (f != l && *f == ':') return false; using namespace parsers; static auto p = +(alnum | chr{'_'} | chr{':'}) % '.'; return p.parse(f, l, a); } }; template <> struct parser_registry<key> { using type = key_parser; }; namespace parsers { static auto const key = make_parser<vast::key>(); } // namespace parsers } // namespace vast #endif
Solve Easy Fibonacci in c
#include <stdio.h> int main() { int n, a, b, x, i; scanf("%d", &n); if (n == 0) { printf("0\n"); return 0; } a = 1; b = 1; printf("0"); for (i = 1; i < n; i++) { printf(" %d", a); x = a; a = b; b = b + x; } printf("\n"); return 0; }
Add start of desktop shell code.
#include "e.h" #include "e_comp_wl.h" #include "e_mod_main.h" #include "e_desktop_shell_protocol.h" EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Desktop_Shell" }; EAPI void * e_modapi_init(E_Module *m) { E_Wayland_Desktop_Shell *shell = NULL; /* try to allocate space for the shell structure */ if (!(shell = E_NEW(E_Wayland_Desktop_Shell, 1))) return NULL; /* tell the shell what compositor to use */ shell->compositor = _e_wl_comp; /* setup compositor shell interface functions */ _e_wl_comp->shell_interface.shell = shell; return m; err: /* reset compositor shell interface */ _e_wl_comp->shell_interface.shell = NULL; /* free the allocated shell structure */ E_FREE(shell); return NULL; } EAPI int e_modapi_shutdown(E_Module *m EINA_UNUSED) { /* nothing to do here as shell will get the destroy callback from * the compositor and we can cleanup there */ return 1; }
Add standard integer/floating point types
//// // __| | | _ _| __ / __| \ | // \__ \ __ | | / _| . | // ____/ _| _| ___| ____| ___| _|\_| // // Copyright (c) 2017 Jacob Hauberg Hansen // // This library is free software; you can redistribute and modify it // under the terms of the MIT license. See LICENSE for details. // #ifndef zint_h #define zint_h #include <stdint.h> typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t i8; typedef int16_t i16; typedef int32_t i32; typedef int64_t i64; typedef float f32; typedef double f64; #endif /* zint_h */
Add back Luke test of a function followed by its concrete implementation.
/* Header testing function definitions parsing. */ //Defining a standard function. void f(int, int); inline int g(char *ch, char **str); // Defining a function pointer. int(*fnPtr)(char, float); // Adding dllexport and stdcall annotation to a function. int __declspec(dllexport) __stdcall function1();
/* Header testing function definitions parsing. */ //Defining a standard function. void f(int, int); // Defining a function with its implementation following inline int g(char *ch, char **str) { JUNK { } int localVariable = 1; } // Defining a function pointer. int(*fnPtr)(char, float); // Adding dllexport and stdcall annotation to a function. int __declspec(dllexport) __stdcall function1();
Add example of ALGO_FOR_EACH and ALGO_REDUCE
/* Based on https://en.cppreference.com/w/cpp/algorithm/for_each Need to be built in C11 mode */ #include <stdio.h> #include "m-array.h" #include "m-algo.h" /* Define a dynamic array of int */ ARRAY_DEF(vector_int, int) #define M_OPL_vector_int_t() ARRAY_OPLIST(vector_int) /* Define operator increment on int */ #define INC(n) (n)++ int main(void) { M_LET( (nums, 3, 4, 2, 8, 15, 267), vector_int_t) { // Print the array before printf ("before:"); ALGO_FOR_EACH(nums, vector_int_t, M_PRINT, " "); printf ("\n"); // Increment each element of the array ALGO_FOR_EACH(nums, vector_int_t, INC); // Print the array after printf ("after: "); ALGO_FOR_EACH(nums, vector_int_t, M_PRINT, " "); printf ("\n"); // Sum the elements of the array int sum = 0; ALGO_REDUCE(sum, nums, vector_int_t, add); M_PRINT("sum = ", sum, "\n"); } return 0; }
Update License to match other licenses
/* * 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 _OS_FAULT_H #define _OS_FAULT_H #ifdef __cplusplus extern "c" { #endif void __assert_func(const char *, int, const char *, const char *) __attribute((noreturn)); #ifdef __cplusplus } #endif #endif /* _OS_FAULT_H */
/* * 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 _OS_FAULT_H #define _OS_FAULT_H #ifdef __cplusplus extern "c" { #endif void __assert_func(const char *, int, const char *, const char *) __attribute((noreturn)); #ifdef __cplusplus } #endif #endif /* _OS_FAULT_H */
Move assert test of EOF to after testing if a filter is done.
#include "fitz_base.h" #include "fitz_stream.h" fz_error fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) { fz_error reason; unsigned char *oldrp; unsigned char *oldwp; assert(!out->eof); oldrp = in->rp; oldwp = out->wp; if (f->done) return fz_iodone; reason = f->process(f, in, out); assert(in->rp <= in->wp); assert(out->wp <= out->ep); f->consumed = in->rp > oldrp; f->produced = out->wp > oldwp; f->count += out->wp - oldwp; /* iodone or error */ if (reason != fz_ioneedin && reason != fz_ioneedout) { if (reason != fz_iodone) reason = fz_rethrow(reason, "cannot process filter"); out->eof = 1; f->done = 1; } return reason; } fz_filter * fz_keepfilter(fz_filter *f) { f->refs ++; return f; } void fz_dropfilter(fz_filter *f) { if (--f->refs == 0) { if (f->drop) f->drop(f); fz_free(f); } }
#include "fitz_base.h" #include "fitz_stream.h" fz_error fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) { fz_error reason; unsigned char *oldrp; unsigned char *oldwp; oldrp = in->rp; oldwp = out->wp; if (f->done) return fz_iodone; assert(!out->eof); reason = f->process(f, in, out); assert(in->rp <= in->wp); assert(out->wp <= out->ep); f->consumed = in->rp > oldrp; f->produced = out->wp > oldwp; f->count += out->wp - oldwp; /* iodone or error */ if (reason != fz_ioneedin && reason != fz_ioneedout) { if (reason != fz_iodone) reason = fz_rethrow(reason, "cannot process filter"); out->eof = 1; f->done = 1; } return reason; } fz_filter * fz_keepfilter(fz_filter *f) { f->refs ++; return f; } void fz_dropfilter(fz_filter *f) { if (--f->refs == 0) { if (f->drop) f->drop(f); fz_free(f); } }
Remove canopy_os_assert implementation because linux implementation now just expands to assert macro in header file
// Copyright 2015 SimpleThings, 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. // Linux implementation of OS Abstraction Layer for Canopy #include <canopy_os.h> #include <assert.h> #include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> void canopy_os_assert(int condition) { assert(condition); } void * canopy_os_alloc(size_t size) { return malloc(size); } void * canopy_os_calloc(int count, size_t size) { return calloc(count, size); } void canopy_os_free(void *ptr) { free(ptr); } void canopy_os_log(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); }
// Copyright 2015 SimpleThings, 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. // Linux implementation of OS Abstraction Layer for Canopy #include <canopy_os.h> #include <assert.h> #include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> void * canopy_os_alloc(size_t size) { return malloc(size); } void * canopy_os_calloc(int count, size_t size) { return calloc(count, size); } void canopy_os_free(void *ptr) { free(ptr); } void canopy_os_log(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); }
Update Skia milestone to 105
/* * 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 104 #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 105 #endif
Add dummy implementation of game_logic.h for testing
#include "game_logic.h" new_game_result bship_logic_new_game(void){ new_game_result r; r.gid = 5; r.pid = 7; return r; } plyr_id bship_logic_join_game(game_id gid) { if(gid != 5) return ERR_NO_SUCH_GAME; return 8; } int bship_logic_submit_grid(plyr_id pid, grid _g) { if(pid < 7 || pid > 8) return ERR_INVALID_PLYR_ID; return 0; } int bship_logic_bomb_position(plyr_id pid, int x, int y) { if(pid < 7 || pid > 8) return ERR_INVALID_PLYR_ID; if(x < 0 || y < 0) return ERR_INVALID_BOMB_TARGET; return 0; } get_game_end_result bship_logic_get_game_end(plyr_id pid) { get_game_end_result g; g.won = 0; g.game_over = 0; return g; } static plyr_id stored_pid = 0; static plyr_state stored_state; static void* stored_user; int bship_logic_request_notify(plyr_id pid, plyr_state state, void *user) { if(stored_pid > 0) bship_logic_notification(stored_pid, stored_state, stored_user, 1); stored_pid = pid; stored_state = state; stored_user = user; return 0; }
Add address as property of Search Item object
// // SearchItem.h // bikepath // // Created by Farheen Malik on 8/15/14. // Copyright (c) 2014 Bike Path. All rights reserved. // #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> #import <GoogleMaps/GoogleMaps.h> @interface SearchItem : NSObject @property NSString *searchQuery; @property CLLocationDegrees lati; @property CLLocationDegrees longi; @property CLLocationCoordinate2D position; @property (readonly) NSDate *creationDate; @end
// // SearchItem.h // bikepath // // Created by Farheen Malik on 8/15/14. // Copyright (c) 2014 Bike Path. All rights reserved. // #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> #import <GoogleMaps/GoogleMaps.h> @interface SearchItem : NSObject @property NSString *searchQuery; @property CLLocationDegrees lati; @property CLLocationDegrees longi; @property CLLocationCoordinate2D position; @property NSString *address; @property (readonly) NSDate *creationDate; @end
Rename parameter to not be the same as the name of the function that does it
#pragma once #include "../main.h" class Socket { public: virtual ~Socket() {} virtual unsigned int apiVersion() = 0; virtual void connect(const std::string& server, const std::string& port, const std::string& bind = "") {} virtual std::string receive() { return ""; } virtual void send(const std::string& data) {} virtual void closeConnection() {} bool isConnected() { return connected; } protected: bool connected; };
#pragma once #include "../main.h" class Socket { public: virtual ~Socket() {} virtual unsigned int apiVersion() = 0; virtual void connect(const std::string& server, const std::string& port, const std::string& bindAddr = "") {} virtual std::string receive() { return ""; } virtual void send(const std::string& data) {} virtual void closeConnection() {} bool isConnected() { return connected; } protected: bool connected; };
Fix linker warnings in rendering tests
/*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 17:34:48 +0200 (Wed, 31 Mar 2010) $ Version: $Revision: 21985 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef mitkRenderingTestHelper_h #define mitkRenderingTestHelper_h #include <string> #include <vtkSmartPointer.h> #include <vtkRenderWindow.h> #include <mitkRenderWindow.h> class vtkRenderWindow; class vtkRenderer; namespace mitk { class DataStorage; } class MITK_CORE_EXPORT mitkRenderingTestHelper { public: mitkRenderingTestHelper(int width, int height, mitk::DataStorage* ds); ~mitkRenderingTestHelper(); vtkRenderer* GetVtkRenderer(); vtkRenderWindow* GetVtkRenderWindow(); void SaveAsPNG(std::string fileName); protected: mitk::RenderWindow::Pointer m_RenderWindow; }; #endif
/*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 17:34:48 +0200 (Wed, 31 Mar 2010) $ Version: $Revision: 21985 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef mitkRenderingTestHelper_h #define mitkRenderingTestHelper_h #include <string> #include <vtkSmartPointer.h> #include <vtkRenderWindow.h> #include <mitkRenderWindow.h> class vtkRenderWindow; class vtkRenderer; namespace mitk { class DataStorage; } class mitkRenderingTestHelper { public: mitkRenderingTestHelper(int width, int height, mitk::DataStorage* ds); ~mitkRenderingTestHelper(); vtkRenderer* GetVtkRenderer(); vtkRenderWindow* GetVtkRenderWindow(); void SaveAsPNG(std::string fileName); protected: mitk::RenderWindow::Pointer m_RenderWindow; }; #endif
Add needed extern "C" to hgl winsys
/************************************************************************** * * Copyright 2009 Artur Wyszynski <harakash@gmail.com> * Copyright 2013 Alexander von Gluck IV <kallisti5@unixzen.com> * * 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 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 * THE COPYRIGHT HOLDERS, AUTHORS 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. * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * **************************************************************************/ #ifndef _HGL_SOFTWAREWINSYS_H #define _HGL_SOFTWAREWINSYS_H struct sw_winsys; struct sw_winsys* hgl_create_sw_winsys(void); #endif
/************************************************************************** * * Copyright 2009 Artur Wyszynski <harakash@gmail.com> * Copyright 2013 Alexander von Gluck IV <kallisti5@unixzen.com> * * 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 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 * THE COPYRIGHT HOLDERS, AUTHORS 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. * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * **************************************************************************/ #ifndef _HGL_SOFTWAREWINSYS_H #define _HGL_SOFTWAREWINSYS_H #ifdef __cplusplus extern "C" { #endif struct sw_winsys; struct sw_winsys* hgl_create_sw_winsys(void); #ifdef __cplusplus } #endif #endif
Disable unsupported Inet configuration breaking iOS integration.
/* * * Copyright (c) 2016-2017 Nest Labs, Inc. * 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. */ /** * @file * Project-specific configuration file for iOS builds. * */ #ifndef WEAVEPROJECTCONFIG_H #define WEAVEPROJECTCONFIG_H #endif /* WEAVEPROJECTCONFIG_H */
/* * * Copyright (c) 2016-2017 Nest Labs, Inc. * 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. */ /** * @file * Project-specific configuration file for iOS builds. * */ #ifndef WEAVEPROJECTCONFIG_H #define WEAVEPROJECTCONFIG_H #define INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT 0 #endif /* WEAVEPROJECTCONFIG_H */
Clean up instance variables and imports
#pragma once #include "../3RVX/Window.h" class NotifyIcon; class Settings; class UpdaterWindow : public Window { public: UpdaterWindow(); ~UpdaterWindow(); void DoModal(); private: HICON _smallIcon; HICON _largeIcon; NotifyIcon *_notifyIcon; HMENU _menu; UINT _menuFlags; Settings *_settings; std::pair<int, int> _version; std::wstring _versionString; void InstallUpdate(); virtual LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); public: static const int MENU_INSTALL = 0; static const int MENU_IGNORE = 1; static const int MENU_REMIND = 2; };
#pragma once #include "../../3RVX/Window.h" #include "Version.h" class NotifyIcon; class Settings; class UpdaterWindow : public Window { public: UpdaterWindow(); ~UpdaterWindow(); void DoModal(); private: HICON _smallIcon; HICON _largeIcon; NotifyIcon *_notifyIcon; HMENU _menu; UINT _menuFlags; Settings *_settings; Version _version; void InstallUpdate(); virtual LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); public: static const int MENU_INSTALL = 0; static const int MENU_IGNORE = 1; static const int MENU_REMIND = 2; };
Remove pathname dependence. Also rewrite test to use FileCheck at the same time.
// RUN: %clang_cc1 -std=c99 %s -emit-llvm -o - | grep -v llvm.isunordered | not grep call _Bool A, B, C, D, E, F; void TestF(float X, float Y) { A = __builtin_isgreater(X, Y); B = __builtin_isgreaterequal(X, Y); C = __builtin_isless(X, Y); D = __builtin_islessequal(X, Y); E = __builtin_islessgreater(X, Y); F = __builtin_isunordered(X, Y); } void TestD(double X, double Y) { A = __builtin_isgreater(X, Y); B = __builtin_isgreaterequal(X, Y); C = __builtin_isless(X, Y); D = __builtin_islessequal(X, Y); E = __builtin_islessgreater(X, Y); F = __builtin_isunordered(X, Y); }
// RUN: %clang_cc1 -std=c99 %s -emit-llvm -o - | FileCheck %s // CHECK: @Test // CHECK-NOT: call _Bool A, B, C, D, E, F; void TestF(float X, float Y) { A = __builtin_isgreater(X, Y); B = __builtin_isgreaterequal(X, Y); C = __builtin_isless(X, Y); D = __builtin_islessequal(X, Y); E = __builtin_islessgreater(X, Y); F = __builtin_isunordered(X, Y); } void TestD(double X, double Y) { A = __builtin_isgreater(X, Y); B = __builtin_isgreaterequal(X, Y); C = __builtin_isless(X, Y); D = __builtin_islessequal(X, Y); E = __builtin_islessgreater(X, Y); F = __builtin_isunordered(X, Y); }
Change test now %ebx is callee-save
// RUN: %ucc -DFIRST -S -o- %s | grep -F 'movl (%%rax), %%eax' // RUN: %ucc -DSECOND -S -o- %s | grep -F 'movl 4(%%rbx), %%ebx' #ifdef FIRST f(int *p) { return *p; // should see that p isn't used after/.retains==1 and not create a new reg, // but re-use the current } #elif defined(SECOND) struct A { int i, j; }; g(struct A *p) { return p->i + p->j; } #else # error neither #endif
// RUN: %ucc -DFIRST -S -o- %s | grep -F 'movl (%%rax), %%eax' // RUN: %ucc -DSECOND -S -o- %s | grep -F 'movl 4(%%rcx), %%ecx' #ifdef FIRST f(int *p) { return *p; // should see that p isn't used after/.retains==1 and not create a new reg, // but re-use the current } #elif defined(SECOND) struct A { int i, j; }; g(struct A *p) { return p->i + p->j; } #else # error neither #endif
Add json-scanner.h to the exported headers
#ifndef __JSON_GLIB_H__ #define __JSON_GLIB_H__ #include <json-glib/json-types.h> #include <json-glib/json-generator.h> #include <json-glib/json-parser.h> #include <json-glib/json-version.h> #endif /* __JSON_GLIB_H__ */
#ifndef __JSON_GLIB_H__ #define __JSON_GLIB_H__ #include <json-glib/json-types.h> #include <json-glib/json-scanner.h> #include <json-glib/json-generator.h> #include <json-glib/json-parser.h> #include <json-glib/json-version.h> #endif /* __JSON_GLIB_H__ */
Remove the include for json-scanner.h
#ifndef __JSON_GLIB_H__ #define __JSON_GLIB_H__ #include <json-glib/json-types.h> #include <json-glib/json-scanner.h> #include <json-glib/json-generator.h> #include <json-glib/json-parser.h> #include <json-glib/json-version.h> #include <json-glib/json-enum-types.h> #endif /* __JSON_GLIB_H__ */
#ifndef __JSON_GLIB_H__ #define __JSON_GLIB_H__ #include <json-glib/json-types.h> #include <json-glib/json-generator.h> #include <json-glib/json-parser.h> #include <json-glib/json-version.h> #include <json-glib/json-enum-types.h> #endif /* __JSON_GLIB_H__ */
Add convenience macros for generation locally handled errors
// // NSTLocalFileError.h // Pods // // Created by Anatoly Shcherbinin on 5.04.22. // #ifndef NSTLocalFileError_h #define NSTLocalFileError_h ///Quick error domain for errors that should be generated and handled localy in one source file #define NSTLocalFileErrorDomain (@__FILE_NAME__) ///Convenience method for generation errors with localized description ///Generated error will have file name where occured as domain and code as line #define NSTLocalFileErrorWithMessage(message) _localFileErrorWithMessage(NSTLocalFileErrorDomain, __LINE__, (message)) ///Convenience method for generation errors with cpecefied code ///Can be used if error handled in the same file and error handling if depends on code #define NSTLocalFileErrorWithCode(code) _localFileErrorWithMessage(NSTLocalFileErrorDomain, (code), nil) CF_INLINE NSError *_localFileErrorWithMessage(NSErrorDomain domain, NSInteger code, NSString *message) { return [NSError errorWithDomain:domain code:code userInfo:( nil == message ? nil : @ { NSLocalizedDescriptionKey: message } )]; } #endif /* NSTLocalFileError_h */
Exit the tests with success if they aren't failing
#include <assert.h> #include "../src/chip8.c" void test_clear_screen(void) { int i; chip8_t * chip8 = chip8_new(); chip8->memory[0x200] = 0x00; chip8->memory[0x201] = 0xE0; chip8_fetch_current_opcode(chip8); chip8_decode_current_opcode(chip8); i = 0; while (i < 64 * 32) { assert(chip8->memory[i++] == 0); } } void test_instruction_jump(void) { chip8_t * chip8 = chip8_new(); chip8->memory[0x200] = 0x11; chip8->memory[0x201] = 0x23; chip8_fetch_current_opcode(chip8); chip8_decode_current_opcode(chip8); assert(chip8->program_counter == 0x123); } int main(int argc, char ** argv) { test_clear_screen(); test_instruction_jump(); }
#include <assert.h> #include "../src/chip8.c" void test_clear_screen(void) { int i; chip8_t * chip8 = chip8_new(); chip8->memory[0x200] = 0x00; chip8->memory[0x201] = 0xE0; chip8_fetch_current_opcode(chip8); chip8_decode_current_opcode(chip8); i = 0; while (i < 64 * 32) { assert(chip8->memory[i++] == 0); } } void test_instruction_jump(void) { chip8_t * chip8 = chip8_new(); chip8->memory[0x200] = 0x11; chip8->memory[0x201] = 0x23; chip8_fetch_current_opcode(chip8); chip8_decode_current_opcode(chip8); assert(chip8->program_counter == 0x123); } int main(int argc, char ** argv) { test_clear_screen(); test_instruction_jump(); return 0; }
Add logging to syscall arg compare for debugging purposes
#include "plrCompare.h" int plrC_compareArgs(const syscallArgs_t *args1, const syscallArgs_t *args2) { int foundDiff = 0; if (args1->addr != args2->addr) { foundDiff = 1; } else if (args1->arg[0] != args2->arg[0]) { foundDiff = 2; } else if (args1->arg[1] != args2->arg[1]) { foundDiff = 3; } else if (args1->arg[2] != args2->arg[2]) { foundDiff = 4; } else if (args1->arg[3] != args2->arg[3]) { foundDiff = 5; } else if (args1->arg[4] != args2->arg[4]) { foundDiff = 6; } else if (args1->arg[5] != args2->arg[5]) { foundDiff = 7; } return foundDiff; }
#include "plrCompare.h" #include <stdio.h> int plrC_compareArgs(const syscallArgs_t *args1, const syscallArgs_t *args2) { int faultVal = 0; #define CompareElement(elem, faultBit) \ if (args1->elem != args2->elem) { \ faultVal |= 1 << faultBit; \ printf("Argument miscompare in " #elem ", 0x%lX != 0x%lX\n", \ (unsigned long)args1->elem, (unsigned long)args2->elem); \ } CompareElement(addr, 0); CompareElement(arg[0], 1); CompareElement(arg[1], 2); CompareElement(arg[2], 3); CompareElement(arg[3], 4); CompareElement(arg[4], 5); CompareElement(arg[5], 6); return faultVal; }
Fix inhibit_loop_to_libcall compilation on e2k
/** * @file * @brief * * @author Anton Kozlov * @date 21.07.2015 */ #ifndef STR_INHIBIT_LIBCALL_H_ #define STR_INHIBIT_LIBCALL_H_ /* FIXME __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) * can be not supported in cross-compiler */ #define HAVE_CC_INHIBIT_LOOP_TO_LIBCALL 1 #ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL # define inhibit_loop_to_libcall \ __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) #else # define inhibit_loop_to_libcall #endif #endif /* STR_INHIBIT_LIBCALL_H_ */
/** * @file * @brief * * @author Anton Kozlov * @date 21.07.2015 */ #ifndef STR_INHIBIT_LIBCALL_H_ #define STR_INHIBIT_LIBCALL_H_ /* FIXME __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) * can be not supported in cross-compiler */ #ifndef __e2k__ #define HAVE_CC_INHIBIT_LOOP_TO_LIBCALL 1 #endif /* __e2k__ */ #ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL # define inhibit_loop_to_libcall \ __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) #else # define inhibit_loop_to_libcall #endif #endif /* STR_INHIBIT_LIBCALL_H_ */
Remove unnecessary includes and newlines
#pragma once #include <iostream> #include <fstream> #include <string> #include <unordered_map> #include <algorithm> //#include <locale> class ConfigFileReader { public: ConfigFileReader(const char* file_name); std::string find(std::string key); private: std::ifstream iniFile; std::unordered_map<std::string, std::string> hashmap; };
#pragma once #include <iostream> #include <fstream> #include <string> #include <unordered_map> #include <algorithm> class ConfigFileReader { public: ConfigFileReader(const char* file_name); std::string find(std::string key); private: std::ifstream iniFile; std::unordered_map<std::string, std::string> hashmap; };
Convert also 0x80..0x9f characters to '?'
/* Copyright (c) 2004 Timo Sirainen */ #include "lib.h" #include "str.h" #include "str-sanitize.h" void str_sanitize_append(string_t *dest, const char *src, size_t max_len) { const char *p; for (p = src; *p != '\0'; p++) { if ((unsigned char)*p < 32) break; } str_append_n(dest, src, (size_t)(p - src)); for (; *p != '\0' && max_len > 0; p++, max_len--) { if ((unsigned char)*p < 32) str_append_c(dest, '?'); else str_append_c(dest, *p); } if (*p != '\0') { str_truncate(dest, str_len(dest)-3); str_append(dest, "..."); } } const char *str_sanitize(const char *src, size_t max_len) { string_t *str; str = t_str_new(I_MIN(max_len, 256)); str_sanitize_append(str, src, max_len); return str_c(str); }
/* Copyright (c) 2004 Timo Sirainen */ #include "lib.h" #include "str.h" #include "str-sanitize.h" void str_sanitize_append(string_t *dest, const char *src, size_t max_len) { const char *p; for (p = src; *p != '\0'; p++) { if (((unsigned char)*p & 0x7f) < 32) break; } str_append_n(dest, src, (size_t)(p - src)); for (; *p != '\0' && max_len > 0; p++, max_len--) { if (((unsigned char)*p & 0x7f) < 32) str_append_c(dest, '?'); else str_append_c(dest, *p); } if (*p != '\0') { str_truncate(dest, str_len(dest)-3); str_append(dest, "..."); } } const char *str_sanitize(const char *src, size_t max_len) { string_t *str; str = t_str_new(I_MIN(max_len, 256)); str_sanitize_append(str, src, max_len); return str_c(str); }
Fix os.copyfile with spaces in argument paths.
/** * \file os_copyfile.c * \brief Copy a file from one location to another. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project */ #include <stdlib.h> #include "premake.h" int os_copyfile(lua_State* L) { int z; const char* src = luaL_checkstring(L, 1); const char* dst = luaL_checkstring(L, 2); #if PLATFORM_WINDOWS z = CopyFileA(src, dst, FALSE); #else lua_pushfstring(L, "cp %s %s", src, dst); z = (system(lua_tostring(L, -1)) == 0); #endif if (!z) { lua_pushnil(L); lua_pushfstring(L, "unable to copy file to '%s'", dst); return 2; } else { lua_pushboolean(L, 1); return 1; } }
/** * \file os_copyfile.c * \brief Copy a file from one location to another. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project */ #include <stdlib.h> #include "premake.h" int os_copyfile(lua_State* L) { int z; const char* src = luaL_checkstring(L, 1); const char* dst = luaL_checkstring(L, 2); #if PLATFORM_WINDOWS z = CopyFileA(src, dst, FALSE); #else lua_pushfstring(L, "cp \"%s\" \"%s\"", src, dst); z = (system(lua_tostring(L, -1)) == 0); #endif if (!z) { lua_pushnil(L); lua_pushfstring(L, "unable to copy file to '%s'", dst); return 2; } else { lua_pushboolean(L, 1); return 1; } }
Add more features ( made it more functional )
#ifndef ROLE_H_ #define ROLE_H_ #include "State.h" class Role{ public: State& state; int x,y; Role(State _state, int _id = 0, int _x = 0, int _y = 0) : state(_state), id(_id), x(_x), y(_y) {} int getID(){ return id; } virtual void move() = 0; private: //changing id is impossible int id; }; #endif
#ifndef ROLE_H_ #define ROLE_H_ #include "State.h" #include "Location.h" #include <vector> // this class is partial abstract class Role { public: // reference to the main state State& state; // neighbors std::vector<int> neighbors; private: // position of the ant int x, y; // ant's id int id; public: // -- virtual functions that will be implemented separately // communicate virtual void receive ( int msg ) { // do nothing } // action move virtual int move() = 0; void run(void) const { int result = move(); if ( 0 < result and result < TDIRECTION ) { state.makeMove( getLocation(), result ); } } // helper functions // return location of the ant Location getLocation(void) const { return Location( x, y ); } // return the id of the ant int getID() const { return id; } // constructor Role(State _state, int _id = 0, int _x = 0, int _y = 0) : state(_state), id(_id), x(_x), y(_y) {} }; #endif
Fix those functions not being virtual.
class dccChat : public Module { public: void onDCCReceive(std::string dccid, std::string message); }; class dccSender : public Module { public: void dccSend(std::string dccid, std::string message); };
class dccChat : public Module { public: virtual void onDCCReceive(std::string dccid, std::string message); }; class dccSender : public Module { public: virtual void dccSend(std::string dccid, std::string message); virtual bool hookDCCMessage(std::string modName, std::string hookMsg); };
Remove override form Begin Auto End methods of QtCreator plugin as they don't override anymore
%{Cpp:LicenseTemplate}\ #ifndef %{GUARD} #define %{GUARD} #include <Cutelyst/Controller> %{JS: Cpp.openNamespaces('%{Class}')}\ using namespace Cutelyst; class %{CN} : public Controller { Q_OBJECT @if %{CustomNamespace} C_NAMESPACE("%{CustomNamespaceValue}") @endif public: explicit %{CN}(QObject *parent = 0); C_ATTR(index, :Path) void index(Context *c); private Q_SLOTS: @if %{BeginMethod} bool Begin(Context *c) override; @endif @if %{AutoMethod} bool Auto(Context *c) override; @endif @if %{EndMethod} bool End(Context *c) override; @endif }; %{JS: Cpp.closeNamespaces('%{Class}')} #endif // %{GUARD}\
%{Cpp:LicenseTemplate}\ #ifndef %{GUARD} #define %{GUARD} #include <Cutelyst/Controller> %{JS: Cpp.openNamespaces('%{Class}')}\ using namespace Cutelyst; class %{CN} : public Controller { Q_OBJECT @if %{CustomNamespace} C_NAMESPACE("%{CustomNamespaceValue}") @endif public: explicit %{CN}(QObject *parent = 0); C_ATTR(index, :Path) void index(Context *c); private Q_SLOTS: @if %{BeginMethod} bool Begin(Context *c); @endif @if %{AutoMethod} bool Auto(Context *c); @endif @if %{EndMethod} bool End(Context *c); @endif }; %{JS: Cpp.closeNamespaces('%{Class}')} #endif // %{GUARD}\
Fix this test to work for arm and on all platforms.
// RUN: %clang_cc1 -emit-llvm -march=armv7a %s // XFAIL: * // XTARGET: arm typedef struct __simd128_uint16_t { __neon_uint16x8_t val; } uint16x8_t; void b(uint16x8_t sat, uint16x8_t luma) { __asm__("vmov.16 %1, %0 \n\t" "vtrn.16 %0, %1 \n\t" :"=w"(luma), "=w"(sat) :"0"(luma) ); }
// RUN: %clang -S -emit-llvm -arch arm -march=armv7a %s typedef unsigned short uint16_t; typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t; void b(uint16x8_t sat, uint16x8_t luma) { __asm__("vmov.16 %1, %0 \n\t" "vtrn.16 %0, %1 \n\t" :"=w"(luma), "=w"(sat) :"0"(luma) ); }
Make the demo use the popover
/* * This file is part of ui-tests * * Copyright © 2016 Ikey Doherty <ikey@solus-project.com> * * 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. */ #include "util.h" #include <stdlib.h> BUDGIE_BEGIN_PEDANTIC #include "popover.h" BUDGIE_END_PEDANTIC int main(int argc, char **argv) { gtk_init(&argc, &argv); return EXIT_FAILURE; } /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * * Local variables: * c-basic-offset: 8 * tab-width: 8 * indent-tabs-mode: nil * End: * * vi: set shiftwidth=8 tabstop=8 expandtab: * :indentSize=8:tabSize=8:noTabs=true: */
/* * This file is part of ui-tests * * Copyright © 2016 Ikey Doherty <ikey@solus-project.com> * * 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. */ #include "util.h" #include <stdlib.h> BUDGIE_BEGIN_PEDANTIC #include "popover.h" BUDGIE_END_PEDANTIC int main(int argc, char **argv) { gtk_init(&argc, &argv); GtkWidget *window = NULL; window = budgie_popover_new(); g_signal_connect(window, "destroy", gtk_main_quit, NULL); gtk_widget_show_all(window); gtk_main(); return EXIT_SUCCESS; } /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * * Local variables: * c-basic-offset: 8 * tab-width: 8 * indent-tabs-mode: nil * End: * * vi: set shiftwidth=8 tabstop=8 expandtab: * :indentSize=8:tabSize=8:noTabs=true: */
Allow allocation of a Sparc TargetMachine.
//===-- llvm/Target/TargetMachineImpls.h - Target Descriptions --*- C++ -*-===// // // This file defines the entry point to getting access to the various target // machine implementations available to LLVM. // //===----------------------------------------------------------------------===// #ifndef LLVM_TARGET_TARGETMACHINEIMPLS_H #define LLVM_TARGET_TARGETMACHINEIMPLS_H namespace TM { enum { PtrSizeMask = 1, PtrSize32 = 0, PtrSize64 = 1, EndianMask = 2, LittleEndian = 0, BigEndian = 2, }; } class TargetMachine; // allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine // that implements the Sparc backend. // TargetMachine *allocateSparcTargetMachine(); // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine // that implements the X86 backend. The X86 target machine can run in // "emulation" mode, where it is capable of emulating machines of larger pointer // size and different endianness if desired. // TargetMachine *allocateX86TargetMachine(unsigned Configuration = TM::PtrSize32|TM::LittleEndian); #endif
//===-- llvm/Target/TargetMachineImpls.h - Target Descriptions --*- C++ -*-===// // // This file defines the entry point to getting access to the various target // machine implementations available to LLVM. // //===----------------------------------------------------------------------===// #ifndef LLVM_TARGET_TARGETMACHINEIMPLS_H #define LLVM_TARGET_TARGETMACHINEIMPLS_H namespace TM { enum { PtrSizeMask = 1, PtrSize32 = 0, PtrSize64 = 1, EndianMask = 2, LittleEndian = 0, BigEndian = 2, }; } class TargetMachine; // allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine // that implements the Sparc backend. // TargetMachine *allocateSparcTargetMachine(unsigned Configuration = TM::PtrSize64|TM::BigEndian); // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine // that implements the X86 backend. The X86 target machine can run in // "emulation" mode, where it is capable of emulating machines of larger pointer // size and different endianness if desired. // TargetMachine *allocateX86TargetMachine(unsigned Configuration = TM::PtrSize32|TM::LittleEndian); #endif
Add resource message bearing some abstract integer.
// // Copyright (C) 2008 SIPez LLC. // Licensed to SIPfoundry under a Contributor Agreement. // // Copyright (C) 2008 SIPfoundry Inc. // Licensed by SIPfoundry under the LGPL license. // // $$ /////////////////////////////////////////////////////////////////////////////// #ifndef _MpIntResourceMsg_h_ #define _MpIntResourceMsg_h_ // SYSTEM INCLUDES // APPLICATION INCLUDES #include "mp/MpResourceMsg.h" // DEFINES // MACROS // EXTERNAL FUNCTIONS // EXTERNAL VARIABLES // CONSTANTS // STRUCTS // TYPEDEFS // FORWARD DECLARATIONS /// Message used to pass an integer value to resource. class MpIntResourceMsg : public MpResourceMsg { /* //////////////////////////// PUBLIC //////////////////////////////////// */ public: /* ============================ CREATORS ================================== */ ///@name Creators //@{ /// Constructor MpIntResourceMsg(MpResourceMsgType type, const UtlString& targetResourceName, int data) : MpResourceMsg(type, targetResourceName) , mData(data) { }; /// Copy constructor MpIntResourceMsg(const MpIntResourceMsg &msg) : MpResourceMsg(msg) , mData(msg.mData) { }; /// @copydoc MpResourceMsg::createCopy() OsMsg* createCopy() const { return new MpIntResourceMsg(*this); } //@} /* ============================ MANIPULATORS ============================== */ ///@name Manipulators //@{ /// Assignment operator MpIntResourceMsg& operator=(const MpIntResourceMsg& rhs) { if(&rhs == this) { return(*this); } MpResourceMsg::operator=(rhs); mData = rhs.mData; return *this; } //@} /* ============================ ACCESSORS ================================= */ ///@name Accessors //@{ /// Return contained integer. int getData() const {return mData;} //@} /* ============================ INQUIRY =================================== */ ///@name Inquiry //@{ //@} /* //////////////////////////// PROTECTED ///////////////////////////////// */ protected: /* //////////////////////////// PRIVATE /////////////////////////////////// */ private: int mData; ///< Integer to be passed to resource. }; /* ============================ INLINE METHODS ============================ */ #endif // _MpIntResourceMsg_h_
Add UEFI2.6 MemoryAttributes Table definition.
/** @file GUIDs used for UEFI Memory Attributes Table in the UEFI 2.6 specification. Copyright (c) 2016, 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. **/ #ifndef __UEFI_MEMORY_ATTRIBUTES_TABLE_H__ #define __UEFI_MEMORY_ATTRIBUTES_TABLE_H__ #define EFI_MEMORY_ATTRIBUTES_TABLE_GUID {\ 0xdcfa911d, 0x26eb, 0x469f, {0xa2, 0x20, 0x38, 0xb7, 0xdc, 0x46, 0x12, 0x20} \ } typedef struct { UINT32 Version; UINT32 NumberOfEntries; UINT32 DescriptorSize; UINT32 Reserved; //EFI_MEMORY_DESCRIPTOR Entry[1]; } EFI_MEMORY_ATTRIBUTES_TABLE; #define EFI_MEMORY_ATTRIBUTES_TABLE_VERSION 0x00000001 extern EFI_GUID gEfiMemoryAttributesTableGuid; #endif
Update test to match recent llvm-gcc change.
// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | FileCheck %s // PR 5406 // XFAIL: * // XTARGET: arm typedef struct { char x[3]; } A0; void foo (int i, ...); // CHECK: call arm_aapcscc void (i32, ...)* @foo(i32 1, i32 {{.*}}) nounwind int main (void) { A0 a3; a3.x[0] = 0; a3.x[0] = 0; a3.x[2] = 26; foo (1, a3 ); return 0; }
// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | FileCheck %s // PR 5406 // XFAIL: * // XTARGET: arm typedef struct { char x[3]; } A0; void foo (int i, ...); // CHECK: call void (i32, ...)* @foo(i32 1, i32 {{.*}}) nounwind int main (void) { A0 a3; a3.x[0] = 0; a3.x[0] = 0; a3.x[2] = 26; foo (1, a3 ); return 0; }
Add ExperimentSuit to test PExperment and PTrial
#include <cxxtest/TestSuite.h> #include "../log/EyeLog.h" class ExperimentSuite: public CxxTest::TestSuite { public: bool entryVecsAreEqual(const PEntryVec& v1, const PEntryVec& v2) { if (v1.size() != v2.size()) return false; for (auto i = PEntryVec::size_type(0); i < v1.size(); i++) { if (v1[i]->compare(*v2[i]) != 0) return false; } return true; } void testMetaComparison() { TS_TRACE("Testing PExperiment comparisons"); PEntryVec meta; PEntryVec metacp; meta.push_back(new PGazeEntry(LGAZE, 0, 10, 10, 0)); meta.push_back(new PGazeEntry(RGAZE, 0, 10, 10, 0)); meta.push_back(new PGazeEntry(LGAZE, 1, 10, 10, 0)); meta.push_back(new PGazeEntry(RGAZE, 1, 10, 10, 0)); meta.push_back(new PMessageEntry(2, "Hi")); metacp = copyPEntryVec(meta); PExperiment expmeta (meta); PExperiment expmetacp(metacp); // Test whether two identical are identical TS_ASSERT_EQUALS(expmeta, expmetacp); metacp.push_back(new PTrialEntry()); // Test whether a length difference compares as unequal TS_ASSERT_DIFFERS(expmeta, PExperiment(metacp)); destroyPEntyVec(metacp); metacp = copyPEntryVec(meta); delete metacp[3]; // note that in the next the pupil size if different metacp[3] = new PGazeEntry(RGAZE, 1, 10, 10, 1); TS_ASSERT_DIFFERS(expmeta, PExperiment(metacp)); destroyPEntyVec(metacp); destroyPEntyVec(meta); } };
Add note to help FreeBSD users.
/* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #include "e.h" #include <execinfo.h> /* a tricky little devil, requires e and it's libs to be built * with the -rdynamic flag to GCC for any sort of decent output. */ void e_sigseg_act(int x, siginfo_t *info, void *data){ void *array[255]; size_t size; write(2, "**** SEGMENTATION FAULT ****\n", 29); write(2, "**** Printing Backtrace... *****\n\n", 34); size = backtrace(array, 255); backtrace_symbols_fd(array, size, 2); exit(-11); }
/* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 * NOTE TO FreeBSD users. Install libexecinfo from * ports/devel/libexecinfo and add -lexecinfo to LDFLAGS * to add backtrace support. */ #include "e.h" #include <execinfo.h> /* a tricky little devil, requires e and it's libs to be built * with the -rdynamic flag to GCC for any sort of decent output. */ void e_sigseg_act(int x, siginfo_t *info, void *data){ void *array[255]; size_t size; write(2, "**** SEGMENTATION FAULT ****\n", 29); write(2, "**** Printing Backtrace... *****\n\n", 34); size = backtrace(array, 255); backtrace_symbols_fd(array, size, 2); exit(-11); }
Use nullptr instead of 0
/* The Halfling Project - A Graphics Engine and Projects * * The Halfling Project is the legal property of Adrian Astley * Copyright Adrian Astley 2013 */ #ifndef COMMON_D3D_UTIL_H #define COMMON_D3D_UTIL_H #include "common/dxerr.h" //--------------------------------------------------------------------------------------- // Simple d3d error checker //--------------------------------------------------------------------------------------- #if defined(DEBUG) | defined(_DEBUG) #ifndef HR #define HR(x) { \ HRESULT hr = (x); \ if (FAILED(hr)) { \ DXTrace(__FILEW__, (DWORD)__LINE__, hr, L#x, true); \ } \ } #endif #else #ifndef HR #define HR(x) (x) #endif #endif //--------------------------------------------------------------------------------------- // Convenience macro for releasing COM objects. //--------------------------------------------------------------------------------------- #define ReleaseCOM(x) { if(x){ x->Release(); x = 0; } } #endif
/* The Halfling Project - A Graphics Engine and Projects * * The Halfling Project is the legal property of Adrian Astley * Copyright Adrian Astley 2013 */ #ifndef COMMON_D3D_UTIL_H #define COMMON_D3D_UTIL_H #include "common/dxerr.h" //--------------------------------------------------------------------------------------- // Simple d3d error checker //--------------------------------------------------------------------------------------- #if defined(DEBUG) | defined(_DEBUG) #ifndef HR #define HR(x) { \ HRESULT hr = (x); \ if (FAILED(hr)) { \ DXTrace(__FILEW__, (DWORD)__LINE__, hr, L#x, true); \ } \ } #endif #else #ifndef HR #define HR(x) (x) #endif #endif //--------------------------------------------------------------------------------------- // Convenience macro for releasing COM objects. //--------------------------------------------------------------------------------------- #define ReleaseCOM(x) { if(x){ x->Release(); x = nullptr; } } #endif
Add container_of and length_of macros to base
size_t align_to(size_t offset, size_t align);
#define container_of(p,T,memb) (T *)((char *)(p) - offsetof(T,member)) #define length_of(array) (sizeof (array) / sizeof 0[array]) size_t align_to(size_t offset, size_t align);
Debug level 1 now only shows error messages (and no backgrounding in gmetad).
/** * @file debug_msg.c Debug Message function */ /* $Id$ */ #include "gangliaconf.h" int debug_level = 0; /** * @fn void debug_msg(const char *format, ...) * Prints the message to STDERR if DEBUG is #defined * @param format The format of the msg (see printf manpage) * @param ... Optional arguments */ void debug_msg(const char *format, ...) { if (debug_level && format) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); fprintf(stderr,"\n"); va_end(ap); } return; }
/** * @file debug_msg.c Debug Message function */ /* $Id$ */ #include "gangliaconf.h" int debug_level = 0; /** * @fn void debug_msg(const char *format, ...) * Prints the message to STDERR if DEBUG is #defined * @param format The format of the msg (see printf manpage) * @param ... Optional arguments */ void debug_msg(const char *format, ...) { if (debug_level > 1 && format) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); fprintf(stderr,"\n"); va_end(ap); } return; }
Fix a memory leak in t-factor.
/* Copyright (C) 2011 Sebastian Pancratz This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <http://www.gnu.org/licenses/>. */ #include <gmp.h> #include <stdlib.h> #include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" void fmpz_poly_factor_clear(fmpz_poly_factor_t fac) { if (fac->alloc) { slong i; for (i = 0; i < fac->alloc; i++) { fmpz_poly_clear(fac->p + i); } fmpz_clear(&(fac->c)); flint_free(fac->p); flint_free(fac->exp); fac->p = NULL; fac->exp = NULL; } }
/* Copyright (C) 2011 Sebastian Pancratz This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <http://www.gnu.org/licenses/>. */ #include <gmp.h> #include <stdlib.h> #include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" void fmpz_poly_factor_clear(fmpz_poly_factor_t fac) { if (fac->alloc) { slong i; for (i = 0; i < fac->alloc; i++) { fmpz_poly_clear(fac->p + i); } flint_free(fac->p); flint_free(fac->exp); fac->p = NULL; fac->exp = NULL; } fmpz_clear(&(fac->c)); }
Update GITTreeEntry tests to use GHUnit framework instead of SenTestKit
// // GITTreeEntryTests.h // CocoaGit // // Created by Geoffrey Garside on 06/10/2008. // Copyright 2008 ManicPanda.com. All rights reserved. // #import <SenTestingKit/SenTestingKit.h> @class GITRepo, GITTree; @interface GITTreeEntryTests : GHTestCase { GITRepo * repo; GITTree * tree; NSUInteger entryMode; NSString * entryName; NSString * entrySHA1; NSString * entryLine; } @property(readwrite,retain) GITRepo * repo; @property(readwrite,retain) GITTree * tree; @property(readwrite,assign) NSUInteger entryMode; @property(readwrite,copy) NSString * entryName; @property(readwrite,copy) NSString * entrySHA1; @property(readwrite,copy) NSString * entryLine; - (void)testShouldParseEntryLine; - (void)testShouldInitWithModeNameAndHash; - (void)testShouldInitWithModeStringNameAndHash; @end
// // GITTreeEntryTests.h // CocoaGit // // Created by Geoffrey Garside on 06/10/2008. // Copyright 2008 ManicPanda.com. All rights reserved. // #import <GHUnit/GHUnit.h> @class GITRepo, GITTree; @interface GITTreeEntryTests : GHTestCase { GITRepo * repo; GITTree * tree; NSUInteger entryMode; NSString * entryName; NSString * entrySHA1; NSString * entryLine; } @property(readwrite,retain) GITRepo * repo; @property(readwrite,retain) GITTree * tree; @property(readwrite,assign) NSUInteger entryMode; @property(readwrite,copy) NSString * entryName; @property(readwrite,copy) NSString * entrySHA1; @property(readwrite,copy) NSString * entryLine; - (void)testShouldParseEntryLine; - (void)testShouldInitWithModeNameAndHash; - (void)testShouldInitWithModeStringNameAndHash; @end
Remove older benchmarking loop and do correct error handling with real parse interface.
#include <stdio.h> #include <stdlib.h> #include "udon.h" int main (int argc, char *argv[]) { int i; int found = 0; if(argc < 2) return 1; UdonParser *udon = udon_new_parser_from_file(argv[1]); if(udon == NULL) { udon_emit_error(stderr); return udon_error_value(); } for(i=0; i<10000; i++) { found += udon_parse(udon); udon_reset_parser(udon); } udon_free_parser(udon); printf("%d\n", found); }
#include <stdio.h> #include <stdlib.h> #include "udon.h" int main (int argc, char *argv[]) { int i; if(argc < 2) return 1; UdonParser *udon = udon_new_parser_from_file(argv[1]); if(udon == NULL) { udon_emit_error(stderr); return udon_error_value(); } int res = udon_parse(udon); if(res) udon_emit_error(stderr); udon_reset_parser(udon); udon_free_parser(udon); return res; }
Add a support tool to generate Util.Systems.Constants package
/* Generate a package from system header definitions -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> int main(void) { printf("-- Generated by utildgen.c from system bfd.h\n"); printf("with Interfaces.C;\n"); printf("package Util.Systems.Constants is\n"); printf("\n"); printf("\n -- Flags used when opening a file with open/creat.\n"); printf(" O_RDONLY : constant Interfaces.C.int := 8#%06o#;\n", O_RDONLY); printf(" O_WRONLY : constant Interfaces.C.int := 8#%06o#;\n", O_WRONLY); printf(" O_RDWR : constant Interfaces.C.int := 8#%06o#;\n", O_RDWR); printf(" O_CREAT : constant Interfaces.C.int := 8#%06o#;\n", O_CREAT); printf(" O_EXCL : constant Interfaces.C.int := 8#%06o#;\n", O_EXCL); printf(" O_TRUNC : constant Interfaces.C.int := 8#%06o#;\n", O_TRUNC); printf(" O_APPEND : constant Interfaces.C.int := 8#%06o#;\n", O_APPEND); printf("\n"); printf(" -- Flags used by fcntl\n"); printf(" F_SETFL : constant Interfaces.C.int := %d;\n", F_SETFL); printf(" FD_CLOEXEC : constant Interfaces.C.int := %d;\n", FD_CLOEXEC); printf("\n"); printf("end Util.Systems.Constants;\n"); return 0; }
Print an error when lstopo fails to export to XML
/* * Copyright © 2009 CNRS * Copyright © 2009-2010 INRIA. All rights reserved. * Copyright © 2009 Université Bordeaux 1 * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. */ #include <private/autogen/config.h> #ifdef HWLOC_HAVE_XML #include <hwloc.h> #include <string.h> #include "lstopo.h" void output_xml(hwloc_topology_t topology, const char *filename, int logical __hwloc_attribute_unused, int legend __hwloc_attribute_unused, int verbose_mode __hwloc_attribute_unused) { if (!filename || !strcasecmp(filename, "-.xml")) filename = "-"; hwloc_topology_export_xml(topology, filename); } #endif /* HWLOC_HAVE_XML */
/* * Copyright © 2009 CNRS * Copyright © 2009-2010 INRIA. All rights reserved. * Copyright © 2009 Université Bordeaux 1 * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. */ #include <private/autogen/config.h> #ifdef HWLOC_HAVE_XML #include <hwloc.h> #include <string.h> #include "lstopo.h" void output_xml(hwloc_topology_t topology, const char *filename, int logical __hwloc_attribute_unused, int legend __hwloc_attribute_unused, int verbose_mode __hwloc_attribute_unused) { if (!filename || !strcasecmp(filename, "-.xml")) filename = "-"; if (hwloc_topology_export_xml(topology, filename) < 0) { fprintf(stderr, "Failed to export XML to %s (%s)\n", filename, strerror(errno)); return; } } #endif /* HWLOC_HAVE_XML */
Set up the getxattr function
// // main.c // fast-xattr-test // // Created by David Schlachter on 2015-07-09. // Copyright (c) 2015 David Schlachter. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); return 0; }
// // main.c // fast-xattr-test // // Created by David Schlachter on 2015-07-09. // Copyright (c) 2015 David Schlachter. All rights reserved. // #include <stdio.h> #include <sys/xattr.h> #include <stdlib.h> int main(int argc, const char * argv[]) { const char *path; const char *name; void *value = malloc(15); size_t size; u_int32_t position; int options = 0; path = argv[1]; name = argv[2]; size = 14; position = 0; if (!getxattr(path, name, value, size, position, options)) { return 0; } else { return 1; }; }
Fix regression test to work with iconv filter enabled
#include <stdio.h> #include <stdlib.h> #include <parserutils/parserutils.h> #include "input/filter.h" #include "testutils.h" static void *myrealloc(void *ptr, size_t len, void *pw) { UNUSED(pw); return realloc(ptr, len); } int main(int argc, char **argv) { parserutils_filter *input; parserutils_filter_optparams params; if (argc != 2) { printf("Usage: %s <filename>\n", argv[0]); return 1; } assert(parserutils_initialise(argv[1], myrealloc, NULL) == PARSERUTILS_OK); assert(parserutils_filter_create("UTF-8", myrealloc, NULL, &input) == PARSERUTILS_OK); params.encoding.name = "GBK"; assert(parserutils_filter_setopt(input, PARSERUTILS_FILTER_SET_ENCODING, &params) == PARSERUTILS_BADENCODING); params.encoding.name = "GBK"; assert(parserutils_filter_setopt(input, PARSERUTILS_FILTER_SET_ENCODING, &params) == PARSERUTILS_BADENCODING); parserutils_filter_destroy(input); assert(parserutils_finalise(myrealloc, NULL) == PARSERUTILS_OK); printf("PASS\n"); return 0; }
#include <stdio.h> #include <stdlib.h> #include <parserutils/parserutils.h> #include "input/filter.h" #include "testutils.h" static void *myrealloc(void *ptr, size_t len, void *pw) { UNUSED(pw); return realloc(ptr, len); } int main(int argc, char **argv) { parserutils_filter *input; parserutils_filter_optparams params; parserutils_error expected; #ifdef WITH_ICONV_FILTER expected = PARSERUTILS_OK; #else expected = PARSERUTILS_BADENCODING; #endif if (argc != 2) { printf("Usage: %s <filename>\n", argv[0]); return 1; } assert(parserutils_initialise(argv[1], myrealloc, NULL) == PARSERUTILS_OK); assert(parserutils_filter_create("UTF-8", myrealloc, NULL, &input) == PARSERUTILS_OK); params.encoding.name = "GBK"; assert(parserutils_filter_setopt(input, PARSERUTILS_FILTER_SET_ENCODING, &params) == expected); params.encoding.name = "GBK"; assert(parserutils_filter_setopt(input, PARSERUTILS_FILTER_SET_ENCODING, &params) == expected); parserutils_filter_destroy(input); assert(parserutils_finalise(myrealloc, NULL) == PARSERUTILS_OK); printf("PASS\n"); return 0; }
Fix missing comment in header.
// Copyright (c) 2021 The Orbit Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef USER_SPACE_INSTRUMENTATION_ATTACH_H_ #define USER_SPACE_INSTRUMENTATION_ATTACH_H_ #include <sys/types.h> #include "OrbitBase/Result.h" namespace orbit_user_space_instrumentation { [[nodiscard]] ErrorMessageOr<void> AttachAndStopProcess(pid_t pid); [[nodiscard]] ErrorMessageOr<void> DetachAndContinueProcess(pid_t pid); } // namespace orbit_user_space_instrumentation #endif // USER_SPACE_INSTRUMENTATION_ATTACH_H_
// Copyright (c) 2021 The Orbit Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef USER_SPACE_INSTRUMENTATION_ATTACH_H_ #define USER_SPACE_INSTRUMENTATION_ATTACH_H_ #include <sys/types.h> #include "OrbitBase/Result.h" namespace orbit_user_space_instrumentation { // Attaches to and stops all threads of the process `pid` using `PTRACE_ATTACH`. Being attached to a // process using this function is a precondition for using any of the tooling provided here. [[nodiscard]] ErrorMessageOr<void> AttachAndStopProcess(pid_t pid); // Detaches from all threads of the process `pid` and continues the execution. [[nodiscard]] ErrorMessageOr<void> DetachAndContinueProcess(pid_t pid); } // namespace orbit_user_space_instrumentation #endif // USER_SPACE_INSTRUMENTATION_ATTACH_H_
Fix typo in include file names.
/*- * Copyright (c) 2015 Alexander Nasonov. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE 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 HOLDERS 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 RGPH_H_INCLUDED #define RGPH_H_INCLUDED #include <rhph_defs.h> #include <rhph_hash.h> #include <rhph_graph.h> #endif /* !RGPH_H_INCLUDED */
/*- * Copyright (c) 2015 Alexander Nasonov. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE 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 HOLDERS 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 RGPH_H_INCLUDED #define RGPH_H_INCLUDED #include <rgph_defs.h> #include <rgph_hash.h> #include <rgph_graph.h> #endif /* !RGPH_H_INCLUDED */
Use vector_get rather than accessing array directly
#include "location.h" #include "inventory.h" #include "person.h" void location_init(struct location *location, char *name, char *description) { location->name = name; location->description = description; inventory_init(&location->inventory); vector_init(&location->people, sizeof(struct person *)); } void location_free(struct location *location) { for (int i = 0; i < location->people.size; i++) { person_free(location->people.data[i]); } vector_free(&location->people); inventory_free(&location->inventory); }
#include "location.h" #include "inventory.h" #include "person.h" void location_init(struct location *location, char *name, char *description) { location->name = name; location->description = description; inventory_init(&location->inventory); vector_init(&location->people, sizeof(struct person *)); } void location_free(struct location *location) { for (int i = 0; i < location->people.size; i++) { person_free(vector_get(&location->people, i)); } vector_free(&location->people); inventory_free(&location->inventory); }
Solve Fibonacci, How Many Calls? in c
#include <stdio.h> #include <string.h> long int f[39]; long int r[39]; long int fib(long int n) { if (n == 0) { return f[0]; } if (f[n] != 0) { return f[n]; } f[n] = fib(n - 1) + fib(n - 2); r[n] = r[n - 1] + r[n - 2] + 2; return f[n]; } int main() { int i, j; long int n; memset(f, 0, sizeof(f)); memset(r, 0, sizeof(r)); f[1] = 1; scanf("%d", &i); while (i--) { scanf("%ld", &n); printf("fib(%ld) = %ld calls = %ld\n", n, r[n], fib(n)); } return 0; }
Support GNU extensions on non-GNU platforms
/* -*- c -*- */ /* Project: libFIRM File name: ir/ana/gnu_ext.c Purpose: Provide some GNU CC extensions to the rest of the world Author: Florian Modified by: Created: Sat Nov 13 19:35:27 CET 2004 CVS-ID: $Id$ Copyright: (c) 1999-2005 Universitt Karlsruhe Licence: This file is protected by the GPL - GNU GENERAL PUBLIC LICENSE. */ # ifdef HAVE_CONFIG_H # include "config.h" # endif /* gnu_ext: Provide some GNU CC extensions to the rest of the world */ /* Includes */ /* Local Defines: */ # if defined (__GNUC__) /* then we're all set */ # else /* defined __GNUC__ */ # define __FUNCTION__ "::" # define __PRETTY_FUNCTION__ ":::" # endif /* define __GNUC__ */ /* Local Data Types: */ /* Local Variables: */ /* Local Prototypes: */ /* =================================================== Local Implementation: =================================================== */ /* =================================================== Exported Implementation: =================================================== */ /* $Log$ Revision 1.1 2005/01/14 14:15:19 liekweg Support GNU extensions on non-GNU platforms */
Fix bugs with libc, executor
#include <stdio.h> int main(int argc, char ** argv){ printf("Test\n"); return 0; }
#include <stdlib.h> #include <stdio.h> int main(int argc, char ** argv){ printf("Test\n"); void* test = malloc(1024*1024); if(test > 0){ printf("Malloc\n"); free(test); printf("Free\n"); }else{ printf("Malloc Failed\n"); } return 0; }
Fix printf() by adding CR manually
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> struct termios orig_termios; void disable_raw_mode() { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } void enable_raw_mode() { tcgetattr(STDIN_FILENO, &orig_termios); atexit(disable_raw_mode); struct termios raw = orig_termios; raw.c_iflag &= ~(ICRNL | IXON); raw.c_oflag &= ~(OPOST); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enable_raw_mode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') { if (iscntrl(c)) { printf("%d\n", c); } else { printf("%d ('%c')\n", c, c); } } return 0; }
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> struct termios orig_termios; void disable_raw_mode() { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } void enable_raw_mode() { tcgetattr(STDIN_FILENO, &orig_termios); atexit(disable_raw_mode); struct termios raw = orig_termios; raw.c_iflag &= ~(ICRNL | IXON); raw.c_oflag &= ~(OPOST); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); } int main() { enable_raw_mode(); char c; while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') { if (iscntrl(c)) { printf("%d\r\n", c); } else { printf("%d ('%c')\r\n", c, c); } } return 0; }
Fix missing parenthesis around f as parameter
#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); void List_Destroy(List* l); ListNode* ListNode_Create(void *); void ListNode_Destroy(ListNode* n); ListNode* List_Search(List* l, void* k, int f(void*, void*)); #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); void List_Destroy(List* l); ListNode* ListNode_Create(void *); void ListNode_Destroy(ListNode* n); ListNode* List_Search(List* l, void* k, int (f)(void*, void*)); #endif
Add test for delete connection method
#include "kms-endpoint.h" #include <glib.h> int main(int argc, char **argv) { GObject *ep; GValue val = G_VALUE_INIT; GError *err = NULL; KmsConnection *conn = NULL; g_type_init(); ep = g_object_new(KMS_TYPE_ENDPOINT, "localname", "test_ep", NULL); if (ep == NULL) { g_print("Create endpont is: NULL\n"); return 1; } g_value_init(&val, G_TYPE_STRING); g_object_get_property(ep, "localname", &val); g_print("Created ep with localname: %s\n", g_value_get_string(&val)); conn = kms_endpoint_create_connection(KMS_ENDPOINT(ep), KMS_CONNECTION_TYPE_RTP, &err); if (conn == NULL) { g_print("Connection can not be created: %s\n", err->message);; g_error_free(err); goto end; } end: g_object_unref(ep); return 0; }
#include "kms-endpoint.h" #include <glib.h> int main(int argc, char **argv) { GObject *ep; GValue val = G_VALUE_INIT; GError *err = NULL; KmsConnection *conn = NULL; g_type_init(); ep = g_object_new(KMS_TYPE_ENDPOINT, "localname", "test_ep", NULL); if (ep == NULL) { g_print("Create endpont is: NULL\n"); return 1; } g_value_init(&val, G_TYPE_STRING); g_object_get_property(ep, "localname", &val); g_print("Created ep with localname: %s\n", g_value_get_string(&val)); conn = kms_endpoint_create_connection(KMS_ENDPOINT(ep), KMS_CONNECTION_TYPE_RTP, &err); if (conn == NULL) { g_print("Connection can not be created: %s\n", err->message);; g_error_free(err); goto end; } g_object_get_property(G_OBJECT(conn), "id", &val); g_print("Created local connection with id: %s\n", g_value_get_string(&val)); if (!kms_endpoint_delete_connection(KMS_ENDPOINT(ep), conn, &err)) { g_printerr("Connection can not be deleted: %s", err->message); g_error_free(err); goto end; } end: g_object_unref(ep); return 0; }
Add passing problem parameters as program arguments
/* headers */ #include <stdlib.h> #include <time.h> #include "lattice.h" #include "clusters.h" #include "io_helpers.h" /* main body function */ int main() { int L; /* square lattice size */ double p; /* occupation probability of each lattice site */ int *lattice; /* lattice array */ /* initialize random number generator seed */ srand(time(NULL)); /* allocate lattice */ L = 10; lattice = allocate_lattice(L, L); /* populate lattice with given probability */ p = 0.4; populate_lattice(p, lattice, L, L); /* print the generated lattice for visualization */ print_lattice(lattice, L, L, 1); /* label clusters and print result */ label_clusters(lattice, L, L); print_lattice(lattice, L, L, 1); /* free memory before leaving */ free(lattice); return 0; }
/* headers */ #include <stdlib.h> #include <time.h> #include "lattice.h" #include "clusters.h" #include "io_helpers.h" /* main body function */ int main(int argc, char ** argv) { int L; /* square lattice size */ double p; /* occupation probability of each lattice site */ int *lattice; /* lattice array */ /* read input arguments; if none provided fallback to default values */ if (argc == 3) { L = atoi(argv[1]); p = atof(argv[2]); } else { L = 10; p = 0.4; } /* initialize random number generator seed */ srand(time(NULL)); /* allocate lattice */ lattice = allocate_lattice(L, L); /* populate lattice with given probability */ populate_lattice(p, lattice, L, L); /* print the generated lattice for visualization */ print_lattice(lattice, L, L, 1); /* label clusters and print result */ label_clusters(lattice, L, L); print_lattice(lattice, L, L, 1); /* free memory before leaving */ free(lattice); return 0; }
Fix this test on machines that don't run clang -cc1as when asked to assemble.
// RUN: %clang -### %s -c -o tmp.o -Wa,--noexecstack 2>&1 | grep "mnoexecstack"
// RUN: %clang -### %s -c -o tmp.o -triple i686-pc-linux-gnu -integrated-as -Wa,--noexecstack 2>&1 | grep "mnoexecstack"
Disable threading in a test. NFC.
#include "Inputs/zeroFunctionFile.h" int foo(int x) { return NOFUNCTIONS(x); } int main() { return foo(2); } // RUN: llvm-profdata merge %S/Inputs/zeroFunctionFile.proftext -o %t.profdata // RUN: llvm-cov report %S/Inputs/zeroFunctionFile.covmapping -instr-profile %t.profdata 2>&1 | FileCheck --check-prefix=REPORT --strict-whitespace %s // REPORT: 0 0 - 0 0 - 0 0 - 0 0 - // REPORT-NO: 0% // RUN: llvm-cov show %S/Inputs/zeroFunctionFile.covmapping -format html -instr-profile %t.profdata -o %t.dir // RUN: FileCheck %s -input-file=%t.dir/index.html -check-prefix=HTML // HTML: <td class='column-entry-green'><pre>- (0/0) // HTML-NO: 0.00% (0/0)
#include "Inputs/zeroFunctionFile.h" int foo(int x) { return NOFUNCTIONS(x); } int main() { return foo(2); } // RUN: llvm-profdata merge %S/Inputs/zeroFunctionFile.proftext -o %t.profdata // RUN: llvm-cov report %S/Inputs/zeroFunctionFile.covmapping -instr-profile %t.profdata 2>&1 | FileCheck --check-prefix=REPORT --strict-whitespace %s // REPORT: 0 0 - 0 0 - 0 0 - 0 0 - // REPORT-NO: 0% // RUN: llvm-cov show -j 1 %S/Inputs/zeroFunctionFile.covmapping -format html -instr-profile %t.profdata -o %t.dir // RUN: FileCheck %s -input-file=%t.dir/index.html -check-prefix=HTML // HTML: <td class='column-entry-green'><pre>- (0/0) // HTML-NO: 0.00% (0/0)
Add button driving and reset encoder warning when bot picked up
task blink(); task usercontrol(){ int DY, DT; bool isReset = false; startTask(blink); //Enable Positioning System startTask(positionsystem); while(true){ //Driving DY = threshold(PAIRED_CH2^2 / MAX_POWER, 5); DT = threshold(PAIRED_CH1^2 / MAX_POWER, 5); drive(DY, DT); //Mogo mogo(threshold(PAIRED_CH3, 15)); //Arm arm((PAIRED_BTN6U - PAIRED_BTN6D) * MAX_POWER); //Lift lift((PAIRED_BTN7U - PAIRED_BTN7D) * MAX_POWER); //Intake intake((PAIRED_BTN5U - PAIRED_BTN5D) * MAX_POWER); //Reset (can be done multiple times, only required once) if(SensorValue[resetButton]){ resetAll(); isReset = true; stopTask(blink); SensorValue[resetLED] = false; waitUntil(!SensorValue[resetButton]); } } } task blink(){ while(true){ SensorValue[resetLED] = !SensorValue[resetLED]; wait1Msec(1000); } }
task blink(); task usercontrol(){ int DY, DT; bool isReset = false; startTask(blink); //Enable Positioning System startTask(positionsystem); while(true){ //Driving DY = threshold(PAIRED_CH2^2 / MAX_POWER, 5) + ((PAIRED_BTN8U - PAIRED_BTN8D) * MAX_POWER); DT = threshold(PAIRED_CH1^2 / MAX_POWER, 5) + ((PAIRED_BTN8R - PAIRED_BTN8L) * MAX_POWER); drive(DY, DT); //Mogo mogo(threshold(PAIRED_CH3, 15)); //Arm arm((PAIRED_BTN6U - PAIRED_BTN6D) * MAX_POWER); //Lift lift((PAIRED_BTN7U - PAIRED_BTN7D) * MAX_POWER); //Intake intake((PAIRED_BTN5U - PAIRED_BTN5D) * MAX_POWER); //Reset (can be done multiple times, only required once) if(abs(SensorValue[aclZ]) > 50){ startTask(blink); } if(SensorValue[resetButton]){ resetAll(); isReset = true; stopTask(blink); SensorValue[resetLED] = false; waitUntil(!SensorValue[resetButton]); } } } task blink(){ while(true){ SensorValue[resetLED] = !SensorValue[resetLED]; wait1Msec(1000); } }
Make diego happy before he notices.
/* * Principal component analysis * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * * 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 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /** * @file pca.h * Principal component analysis */ struct PCA *ff_pca_init(int n); void ff_pca_free(struct PCA *pca); void ff_pca_add(struct PCA *pca, double *v); int ff_pca(struct PCA *pca, double *eigenvector, double *eigenvalue);
/* * Principal component analysis * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> * * 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 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /** * @file pca.h * Principal component analysis */ #ifndef FFMPEG_PCA_H #define FFMPEG_PCA_H struct PCA *ff_pca_init(int n); void ff_pca_free(struct PCA *pca); void ff_pca_add(struct PCA *pca, double *v); int ff_pca(struct PCA *pca, double *eigenvector, double *eigenvalue); #endif /* FFMPEG_PCA_H */
Tweak to test commiting from submodule
/* Config (Singleton), extends ofxXMLSettings Loads app configuration properties from xml file. */ #pragma once #ifndef BBC_CONFIG #define BBC_CONFIG #include "XmlSettingsEx.h" #define CONFIG_GET(_key, _attr, _def) bbc::utils::Config::instance()->getAttribute("config:"_key, _attr, _def) namespace bbc { namespace utils { class Config : public XmlSettingsEx { public: static string data_file_path; static Config* instance(); // pointer to itself bool load_success; protected: Config(); // protected constuctor }; } } #endif
/* Config (Singleton), extends ofxXMLSettings Loads app configuration properties from xml file. */ #pragma once #ifndef BBC_CONFIG #define BBC_CONFIG #include "XmlSettingsEx.h" #define CONFIG_GET(_key, _attr, _def) bbc::utils::Config::instance()->getAttribute("config:"_key, _attr, _def) namespace bbc { namespace utils { class Config : public XmlSettingsEx { public: static string data_file_path; static Config* instance(); // pointer to itself bool load_success; protected: Config(); // hidden constuctor }; } } #endif
Implement classof for SetCondInst so that instcombine doesn't break on dyn_cast<SetCondInst>
//===-- llvm/iBinary.h - Binary Operator node definitions --------*- C++ -*--=// // // This file contains the declarations of all of the Binary Operator classes. // //===----------------------------------------------------------------------===// #ifndef LLVM_IBINARY_H #define LLVM_IBINARY_H #include "llvm/InstrTypes.h" //===----------------------------------------------------------------------===// // Classes to represent Binary operators //===----------------------------------------------------------------------===// // // All of these classes are subclasses of the BinaryOperator class... // class GenericBinaryInst : public BinaryOperator { public: GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2, const std::string &Name = "") : BinaryOperator(Opcode, S1, S2, Name) { } }; class SetCondInst : public BinaryOperator { BinaryOps OpType; public: SetCondInst(BinaryOps opType, Value *S1, Value *S2, const std::string &Name = ""); // getInverseCondition - Return the inverse of the current condition opcode. // For example seteq -> setne, setgt -> setle, setlt -> setge, etc... // BinaryOps getInverseCondition() const; }; #endif
//===-- llvm/iBinary.h - Binary Operator node definitions --------*- C++ -*--=// // // This file contains the declarations of all of the Binary Operator classes. // //===----------------------------------------------------------------------===// #ifndef LLVM_IBINARY_H #define LLVM_IBINARY_H #include "llvm/InstrTypes.h" //===----------------------------------------------------------------------===// // Classes to represent Binary operators //===----------------------------------------------------------------------===// // // All of these classes are subclasses of the BinaryOperator class... // class GenericBinaryInst : public BinaryOperator { public: GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2, const std::string &Name = "") : BinaryOperator(Opcode, S1, S2, Name) { } }; class SetCondInst : public BinaryOperator { BinaryOps OpType; public: SetCondInst(BinaryOps opType, Value *S1, Value *S2, const std::string &Name = ""); // getInverseCondition - Return the inverse of the current condition opcode. // For example seteq -> setne, setgt -> setle, setlt -> setge, etc... // BinaryOps getInverseCondition() const; // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SetCondInst *) { return true; } static inline bool classof(const Instruction *I) { return I->getOpcode() == SetEQ || I->getOpcode() == SetNE || I->getOpcode() == SetLE || I->getOpcode() == SetGE || I->getOpcode() == SetLT || I->getOpcode() == SetGT; } static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } }; #endif
Use fmtlib's sprintf instead of tinyformat
#pragma once #define TINYFORMAT_USE_VARIADIC_TEMPLATES #ifdef __GNUC__ // Tinyformat has a number of non-annotated switch fallthrough cases #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif #include "dependencies/tinyformat/tinyformat.h" #ifdef __GNUC__ #pragma GCC diagnostic pop #endif #include "library/strings.h" namespace OpenApoc { template <typename... Args> static UString format(const UString &fmt, Args &&... args) { return tfm::format(fmt.cStr(), std::forward<Args>(args)...); } UString tr(const UString &str, const UString domain = "ufo_string"); } // namespace OpenApoc
#pragma once #include "fmt/printf.h" #include "library/strings.h" namespace OpenApoc { template <typename... Args> static UString format(const UString &fmt, Args &&... args) { return fmt::sprintf(fmt.str(), std::forward<Args>(args)...); } UString tr(const UString &str, const UString domain = "ufo_string"); } // namespace OpenApoc template <> struct fmt::formatter<OpenApoc::UString> : formatter<std::string> { template <typename FormatContext> auto format(const OpenApoc::UString &s, FormatContext &ctx) { return formatter<std::string>::format(s.str(), ctx); } };
Fix basic type redefinition errors
#pragma once #include <string> #include <cstdlib> // Integer types typedef char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef long int32_t; typedef unsigned long uint32_t; typedef long long int64_t; typedef unsigned long long uint64_t; #ifndef _swap_int template <typename T> void _swap_int(T& a, T& b) { T t(a); a = b; b = t; } #endif // !_swap_int
#pragma once #include <string> #include <cstdlib> // Integer types #ifdef int8_t typedef char int8_t; #endif // !int8_t #ifdef uint8_t typedef unsigned char uint8_t; #endif // !uint8_t #ifdef int16_t typedef short int16_t; #endif // !int16_t #ifdef uint16_t typedef unsigned short uint16_t; #endif // !uint16_t #ifdef int32_t typedef long int32_t; #endif // !int32_t #ifdef uint32_t typedef unsigned long uint32_t; #endif // !uint32_t #ifdef int64_t typedef long long int64_t; #endif // !int64_t #ifdef uint64_t typedef unsigned long long uint64_t; #endif // !uint64_t #ifndef _swap_int template <typename T> void _swap_int(T& a, T& b) { T t(a); a = b; b = t; } #endif // !_swap_int
Fix Valgrind complaint about unitialized heap memory
#include "syshead.h" #include "skbuff.h" struct sk_buff *alloc_skb(unsigned int size) { struct sk_buff *skb = malloc(sizeof(struct sk_buff)); skb->data = malloc(size); skb->head = skb->data; skb->tail = skb->data; skb->end = skb->tail + size; return skb; } void *skb_reserve(struct sk_buff *skb, unsigned int len) { skb->data += len; skb->tail += len; return skb->data; } uint8_t *skb_push(struct sk_buff *skb, unsigned int len) { skb->data -= len; skb->len += len; return skb->data; } void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) { skb->dst = dst; }
#include "syshead.h" #include "skbuff.h" struct sk_buff *alloc_skb(unsigned int size) { struct sk_buff *skb = malloc(sizeof(struct sk_buff)); memset(skb, 0, sizeof(struct sk_buff)); skb->data = malloc(size); memset(skb->data, 0, size); skb->head = skb->data; skb->tail = skb->data; skb->end = skb->tail + size; return skb; } void *skb_reserve(struct sk_buff *skb, unsigned int len) { skb->data += len; skb->tail += len; return skb->data; } uint8_t *skb_push(struct sk_buff *skb, unsigned int len) { skb->data -= len; skb->len += len; return skb->data; } void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) { skb->dst = dst; }