Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Fix TestDebugBreak.py failure with gcc, for loop declarations are not allowed by default with gcc
#ifdef _MSC_VER #include <intrin.h> #define BREAKPOINT_INTRINSIC() __debugbreak() #else #define BREAKPOINT_INTRINSIC() __asm__ __volatile__ ("int3") #endif int bar(int const *foo) { int count = 0; for (int i = 0; i < 10; ++i) { count += 1; BREAKPOINT_INTRINSIC(); count += 1; } return *foo; } int main(int argc, char **argv) { int foo = 42; bar(&foo); return 0; }
#ifdef _MSC_VER #include <intrin.h> #define BREAKPOINT_INTRINSIC() __debugbreak() #else #define BREAKPOINT_INTRINSIC() __asm__ __volatile__ ("int3") #endif int bar(int const *foo) { int count = 0, i = 0; for (; i < 10; ++i) { count += 1; BREAKPOINT_INTRINSIC(); count += 1; } return *foo; } int main(int argc, char **argv) { int foo = 42; bar(&foo); return 0; }
Adjust to changes in slcd library
#include <avr/io.h> #include <util/delay.h> #include "slcd.h" int main() { init_lcd(); uint8_t backlit = 1; while (1) { lcd_clrscr(); lcd_goto(LINE1); lcd_puts("Line 1", backlit); lcd_goto(LINE2); lcd_puts("Line 2", backlit); lcd_goto(LINE3); lcd_puts("Line 3", backlit); lcd_goto(LINE4); lcd_puts("Line 4", backlit); _delay_ms(500); // Blink the backlight for (uint8_t i=0; i<6; i++) { send_byte(0, 0x80 + LINE4 + 6, i%2); _delay_ms(50); } _delay_ms(500); } return 0; }
#include <avr/io.h> #include <util/delay.h> #include "slcd.h" int main() { init_lcd(); uint8_t backlit = 1; while (1) { lcd_clrscr(); lcd_goto(0, 0); lcd_puts("Line 1", backlit); lcd_goto(1, 0); lcd_puts("Line 2", backlit); lcd_goto(2, 0); lcd_puts("Line 3", backlit); lcd_goto(3, 0); lcd_puts("Line 4", backlit); _delay_ms(500); // Blink the backlight for (uint8_t i=0; i<6; i++) { send_byte(0, 0x80 + LCD_LINE3 + 6, i%2); _delay_ms(50); } _delay_ms(500); // Raster the cursor to check the goto function lcd_clrscr(); for (uint8_t i=0; i<LCD_LINES; i++) for (uint8_t j=0; j<LCD_WIDTH; j++) { lcd_goto(i, j); _delay_ms(100); } } return 0; }
Update with new lefty, fixing many bugs and supporting new features
/* $Id$ $Revision$ */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifdef __cplusplus extern "C" { #endif /* Lefteris Koutsofios - AT&T Bell Laboratories */ #ifndef _EXEC_H #define _EXEC_H typedef struct Tonm_t lvar_t; extern Tobj root, null; extern Tobj rtno; extern int Erun; extern int Eerrlevel, Estackdepth, Eshowbody, Eshowcalls, Eoktorun; void Einit(void); void Eterm(void); Tobj Eunit(Tobj); Tobj Efunction(Tobj, char *); #endif /* _EXEC_H */ #ifdef __cplusplus } #endif
/* $Id$ $Revision$ */ /* vim:set shiftwidth=4 ts=8: */ /********************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * * Copyright (c) 1994-2004 AT&T Corp. * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Corp. * * * * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ #ifdef __cplusplus extern "C" { #endif /* Lefteris Koutsofios - AT&T Labs Research */ #ifndef _EXEC_H #define _EXEC_H typedef struct Tonm_t lvar_t; extern Tobj root, null; extern Tobj rtno; extern int Erun; extern int Eerrlevel, Estackdepth, Eshowbody, Eshowcalls, Eoktorun; void Einit (void); void Eterm (void); Tobj Eunit (Tobj); Tobj Efunction (Tobj, char *); #endif /* _EXEC_H */ #ifdef __cplusplus } #endif
Add mutable deep link to sdk header.
#import "DPLTargetViewControllerProtocol.h" #import "DPLDeepLinkRouter.h" #import "DPLRouteHandler.h" #import "DPLDeepLink.h" #import "DPLErrors.h"
#import "DPLTargetViewControllerProtocol.h" #import "DPLDeepLinkRouter.h" #import "DPLRouteHandler.h" #import "DPLDeepLink.h" #import "DPLMutableDeepLink.h" #import "DPLErrors.h"
Rename dbg struct to Debug.
/* Copyright libCellML Contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #pragma once #include <iostream> #include <sstream> namespace libcellml { struct dbg { dbg() = default; ~dbg() { std::cout << mSS.str() << std::endl; } public: dbg &operator<<(const void *p) { const void *address = static_cast<const void *>(p); std::ostringstream ss; ss << address; mSS << ss.str(); return *this; } // accepts just about anything template<class T> dbg &operator<<(const T &x) { mSS << x; return *this; } private: std::ostringstream mSS; }; } // namespace libcellml
/* Copyright libCellML Contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #pragma once #include <iostream> #include <sstream> namespace libcellml { struct Debug { Debug() = default; ~Debug() { std::cout << mSS.str() << std::endl; } Debug &operator<<(const void *p) { const void *address = static_cast<const void *>(p); std::ostringstream ss; ss << address; mSS << ss.str(); return *this; } // accepts just about anything template<class T> Debug &operator<<(const T &x) { mSS << x; return *this; } private: std::ostringstream mSS; }; } // namespace libcellml
Add a linked list to itself
/* last written on 11/09/2017 16:34:14 owner ise2017001 rajaneesh @devrezo on twitter @devrezo on github */ #include <stdio.h> #include <stdlib.h> #include <string.h> struct node { int data; struct node *next; }; struct node *createNode (int value) { struct node *newNode = (struct node *) malloc (sizeof (struct node)); newNode -> data = value; newNode -> next = NULL; return newNode; } void insertNode (struct node **head_ref, struct node **tail_ref, int value) { struct node *newNode = createNode (value); if (*head_ref == NULL) { *head_ref = newNode; *tail_ref = newNode; } else { (*tail_ref) -> next = newNode; *tail_ref = newNode; } } void printList (struct node *head) { while (head != NULL) { printf ("%d -> ", head->data); head = head->next; } printf ("NULL\n"); } void destroyList (struct node *head) { struct node *nextNode = head; while (head != NULL) { nextNode = head -> next; free (head); head = nextNode; } printf("Killed off all her feelings\n" ); } void addToItself (struct node **head_ref) { struct node *headNew = NULL; struct node *tailNew = NULL; struct node *prevNode = NULL; struct node *currentNode = NULL; currentNode = (*head_ref); if (currentNode == NULL) { return; } while (currentNode != NULL) { insertNode (&headNew, &tailNew, currentNode->data); prevNode = currentNode; currentNode = currentNode->next; } prevNode->next = headNew; return; } int main (int argc, char *argv[]) { int value; struct node *head = NULL, *tail = NULL; char buffer[2048]; char *p = NULL; fgets (buffer, 2048, stdin); p = strtok (buffer, "NULL >|\n"); while (p != NULL) { sscanf (p, "%d", &value); insertNode (&head, &tail, value); p = strtok (NULL, "> | NULL \n"); } printList (head); addToItself (&head); printList (head); destroyList (head); head = NULL; tail = NULL; return 0; }
Introduce a PushSubscriptionOptions struct in the Blink API.
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef WebPushSubscriptionOptions_h #define WebPushSubscriptionOptions_h namespace blink { struct WebPushSubscriptionOptions { WebPushSubscriptionOptions() : userVisible(false) { } // Indicates that the subscription will only be used for push messages // that result in UI visible to the user. bool userVisible; }; } // namespace blink #endif // WebPushSubscriptionOptions_h
Fix typo in compareMath doxygen documentation.
/* Copyright libCellML Contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #pragma once #include <string> namespace libcellml { /** * @brief Compare math to determine if it is equal. * * Compare the given math strings to determin if they are equal or not. * The current test is a simplistic comparison of string equality. * * @param math1 The first parameter to compare against parameter two. * @param math2 The second parameter to compare against parameter one. * @return Return @c true if the @p math1 is equal to @p math2, @c false otherwise. */ bool compareMath(const std::string &math1, const std::string &math2); } // namespace libcellml
/* Copyright libCellML Contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #pragma once #include <string> namespace libcellml { /** * @brief Compare math to determine if it is equal. * * Compare the given math strings to determine if they are equal or not. * The current test is a simplistic comparison of string equality. * * @param math1 The first parameter to compare against parameter two. * @param math2 The second parameter to compare against parameter one. * @return Return @c true if the @p math1 is equal to @p math2, @c false otherwise. */ bool compareMath(const std::string &math1, const std::string &math2); } // namespace libcellml
Fix build break from the future.
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_RENDERER_WEBVIEW_COLOR_OVERLAY_H_ #define CHROME_RENDERER_WEBVIEW_COLOR_OVERLAY_H_ #pragma once #include "base/basictypes.h" #include "base/compiler_specific.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageOverlay.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" namespace content { class RenderView; } // This class draws the given color on a PageOverlay of a WebView. class WebViewColorOverlay : public WebKit::WebPageOverlay { public: WebViewColorOverlay(content::RenderView* render_view, SkColor color); virtual ~WebViewColorOverlay(); private: // WebKit::WebPageOverlay implementation: virtual void paintPageOverlay(WebKit::WebCanvas* canvas); content::RenderView* render_view_; SkColor color_; DISALLOW_COPY_AND_ASSIGN(WebViewColorOverlay); }; #endif // CHROME_RENDERER_WEBVIEW_COLOR_OVERLAY_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_RENDERER_WEBVIEW_COLOR_OVERLAY_H_ #define CHROME_RENDERER_WEBVIEW_COLOR_OVERLAY_H_ #pragma once #include "base/basictypes.h" #include "base/compiler_specific.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageOverlay.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" namespace content { class RenderView; } // This class draws the given color on a PageOverlay of a WebView. class WebViewColorOverlay : public WebKit::WebPageOverlay { public: WebViewColorOverlay(content::RenderView* render_view, SkColor color); virtual ~WebViewColorOverlay(); private: // WebKit::WebPageOverlay implementation: virtual void paintPageOverlay(WebKit::WebCanvas* canvas); content::RenderView* render_view_; SkColor color_; DISALLOW_COPY_AND_ASSIGN(WebViewColorOverlay); }; #endif // CHROME_RENDERER_WEBVIEW_COLOR_OVERLAY_H_
Check that bodies and calls but not declarations are marked nounwind when compiling without -fexceptions.
// RUN: %llvmgcc -S -o - %s | grep nounwind | count 2 // RUN: %llvmgcc -S -o - %s | not grep {declare.*nounwind} void f(void); void g(void) { f(); }
Test case for r120740. Radar 8712503.
// RUN: %llvmgcc -S %s -o - | llvm-as -o /dev/null // Don't crash on a common-linkage constant global. extern const int kABSourceTypeProperty; int foo(void) { return kABSourceTypeProperty; } const int kABSourceTypeProperty;
Make sure to do sanity checking before any of the reading.
#include <iobuf/iobuf.h> #include <str/str.h> /** Read the remainder of the \c ibuf into the \c str. */ int ibuf_readall(ibuf* in, str* out) { for (;;) { if (!str_catb(out, in->io.buffer+in->io.bufstart, in->io.buflen-in->io.bufstart)) return 0; in->io.bufstart = in->io.buflen; if (!ibuf_refill(in)) return ibuf_eof(in); } }
#include <iobuf/iobuf.h> #include <str/str.h> /** Read the remainder of the \c ibuf into the \c str. */ int ibuf_readall(ibuf* in, str* out) { if (ibuf_eof(in)) return 1; if (ibuf_error(in)) return 0; for (;;) { if (!str_catb(out, in->io.buffer+in->io.bufstart, in->io.buflen-in->io.bufstart)) return 0; in->io.bufstart = in->io.buflen; if (!ibuf_refill(in)) return ibuf_eof(in); } }
Add default config for USB OTG FS peripheral
/* * Copyright (C) 2019 Koen Zandberg * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @ingroup boards_common_stm32 * @{ * * @file * @brief Common configuration for STM32 OTG FS peripheral * * @author Koen Zandberg <koen@bergzand.net> */ #ifndef CFG_USB_OTG_FS_H #define CFG_USB_OTG_FS_H #include "periph_cpu.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Enable the full speed USB OTG peripheral */ #define STM32_USB_OTG_FS_ENABLED /** * @name common USB OTG FS configuration * @{ */ static const stm32_usb_otg_fshs_config_t stm32_usb_otg_fshs_config[] = { { .periph = (uint8_t *)USB_OTG_FS_PERIPH_BASE, .rcc_mask = RCC_AHB2ENR_OTGFSEN, .phy = STM32_USB_OTG_PHY_BUILTIN, .type = STM32_USB_OTG_FS, .irqn = OTG_FS_IRQn, .ahb = AHB2, .dm = GPIO_PIN(PORT_A, 11), .dp = GPIO_PIN(PORT_A, 12), .af = GPIO_AF10, } }; /** @} */ /** * @brief Number of available USB OTG peripherals */ #define USBDEV_NUMOF ARRAY_SIZE(stm32_usb_otg_fshs_config) #ifdef __cplusplus } #endif #endif /* CFG_USB_OTG_FS_H */ /** @} */
Fix a lexical token ordering issue
/* * 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/. */ #ifndef LEXER_H #define LEXER_H #include <stdlib.h> #include "linked_list.h" enum ctache_token_type { /* Terminals */ CTACHE_TOK_STRING, CTACHE_TOK_SECTION_TAG_START, CTACHE_TOK_CLOSE_TAG_START, CTACHE_TOK_VALUE_TAG_START, CTACHE_TOK_TAG_END, CTACHE_TOK_EOI, /* Non-Terminals */ CTACHE_TOK_TEMPLATE, CTACHE_TOK_TEXT, CTACHE_TOK_TAG, CTACHE_TOK_TAG_START }; #define CTACHE_NUM_TERMINALS (CTACHE_TOK_EOI + 1) #define CTACHE_NUM_NONTERMINALS (CTACHE_TOK_TAG_START - CTACHE_TOK_TEMPLATE + 1) struct ctache_token { char *value; enum ctache_token_type tok_type; }; struct linked_list *ctache_lex(const char *str, size_t str_len); #endif /* LEXER_H */
/* * 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/. */ #ifndef LEXER_H #define LEXER_H #include <stdlib.h> #include "linked_list.h" enum ctache_token_type { /* Terminals */ CTACHE_TOK_SECTION_TAG_START, CTACHE_TOK_CLOSE_TAG_START, CTACHE_TOK_VALUE_TAG_START, CTACHE_TOK_TAG_END, CTACHE_TOK_STRING, CTACHE_TOK_EOI, /* Non-Terminals */ CTACHE_TOK_TEMPLATE, CTACHE_TOK_TEXT, CTACHE_TOK_TAG, CTACHE_TOK_TAG_START }; #define CTACHE_NUM_TERMINALS (CTACHE_TOK_EOI + 1) #define CTACHE_NUM_NONTERMINALS (CTACHE_TOK_TAG_START - CTACHE_TOK_TEMPLATE + 1) struct ctache_token { char *value; enum ctache_token_type tok_type; }; struct linked_list *ctache_lex(const char *str, size_t str_len); #endif /* LEXER_H */
Add a numargs field to struct function, which refers to the number of arguments the function takes.
#include <stdlib.h> #include <stdio.h> struct llnode; struct symbol; struct function; union value; struct variable; struct statement; struct call; struct llnode { struct type* car; struct llnode* cdr; }; struct call { char* name; struct function func; struct symbol* arguments; int numargs; } struct symbol {//I guess this is analogous to a symbol in lisp. char* name; //It has a name, which we use to keep track of it. struct variable* referant; //And an actual value in memory. }; struct function { struct symbol* args; //these are the symbols that the function takes as arguments char* definition; // this is the function's actual definition, left in text form until parsing. }; union value { //we have three primitive types, so every variable's value is one of those types char bit; struct llnode list; struct function func; }; struct variable { //this is essentially an in-program variable union value val; //it has a value, i.e. what it equals char typeid; //and a type id that allows us to correctly extract the value from the union value. };
#include <stdlib.h> #include <stdio.h> struct llnode; struct symbol; struct function; union value; struct variable; struct statement; struct call; struct llnode { struct variable* car; struct llnode* cdr; }; struct call { char* name; struct function func; struct symbol* arguments; int numargs; } struct symbol {//I guess this is analogous to a symbol in lisp. char* name; //It has a name, which we use to keep track of it. struct variable* referant; //And an actual value in memory. }; struct function { struct symbol* args; //these are the symbols that the function takes as arguments char* definition; // this is the function's actual definition, left in text form until parsing. int numargs; }; union value { //we have three primitive types, so every variable's value is one of those types char bit; struct llnode list; struct function func; }; struct variable { //this is essentially an in-program variable union value val; //it has a value, i.e. what it equals char typeid; //and a type id that allows us to correctly extract the value from the union value. };
Fix a typo in the argument type.
/* trace.h * Copyright: (When this is determined...it will go here) * CVS Info * $Id$ * Overview: * Tracing support for runops_cores.c. * Data Structure and Algorithms: * History: * Notes: * References: */ #ifndef PARROT_TRACE_H_GUARD #define PARROT_TRACE_H_GUARD #include "parrot/parrot.h" void trace_op_dump(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *pc); void trace_op(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *code_end, opcode_t *pc); void trace_op_b0(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *pc); void trace_op_b1(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *code_end, code_t *pc); #endif /* * Local variables: * c-indentation-style: bsd * c-basic-offset: 4 * indent-tabs-mode: nil * End: * * vim: expandtab shiftwidth=4: */
/* trace.h * Copyright: (When this is determined...it will go here) * CVS Info * $Id$ * Overview: * Tracing support for runops_cores.c. * Data Structure and Algorithms: * History: * Notes: * References: */ #ifndef PARROT_TRACE_H_GUARD #define PARROT_TRACE_H_GUARD #include "parrot/parrot.h" void trace_op_dump(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *pc); void trace_op(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *code_end, opcode_t *pc); void trace_op_b0(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *pc); void trace_op_b1(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *code_end, opcode_t *pc); #endif /* * Local variables: * c-indentation-style: bsd * c-basic-offset: 4 * indent-tabs-mode: nil * End: * * vim: expandtab shiftwidth=4: */
Use pair<'const' Key, Value> in defining MaterialMap type
#pragma once #include <string> #include <map> #include <Eigen/Dense> typedef std::map<std::string, Eigen::Vector4d, std::less<std::string>, Eigen::aligned_allocator< std::pair<std::string, Eigen::Vector4d> > > MaterialMap;
#pragma once #include <string> #include <map> #include <Eigen/Dense> typedef std::map<std::string, Eigen::Vector4d, std::less<std::string>, Eigen::aligned_allocator< std::pair<const std::string, Eigen::Vector4d> > > MaterialMap;
Print an error when lstopo fails to export to X...
/* * 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 */
Support wu-ftpd-like chrooting in /etc/passwd. If home directory ends with "/./", it's chrooted to.
/* Copyright (C) 2002-2003 Timo Sirainen */ #include "config.h" #undef HAVE_CONFIG_H #ifdef USERDB_PASSWD #include "common.h" #include "userdb.h" #include <pwd.h> static void passwd_lookup(const char *user, userdb_callback_t *callback, void *context) { struct user_data data; struct passwd *pw; pw = getpwnam(user); if (pw == NULL) { if (errno != 0) i_error("getpwnam(%s) failed: %m", user); else if (verbose) i_info("passwd(%s): unknown user", user); callback(NULL, context); return; } memset(&data, 0, sizeof(data)); data.uid = pw->pw_uid; data.gid = pw->pw_gid; data.virtual_user = data.system_user = pw->pw_name; data.home = pw->pw_dir; callback(&data, context); } struct userdb_module userdb_passwd = { NULL, NULL, passwd_lookup }; #endif
/* Copyright (C) 2002-2003 Timo Sirainen */ #include "config.h" #undef HAVE_CONFIG_H #ifdef USERDB_PASSWD #include "common.h" #include "userdb.h" #include <pwd.h> static void passwd_lookup(const char *user, userdb_callback_t *callback, void *context) { struct user_data data; struct passwd *pw; size_t len; pw = getpwnam(user); if (pw == NULL) { if (errno != 0) i_error("getpwnam(%s) failed: %m", user); else if (verbose) i_info("passwd(%s): unknown user", user); callback(NULL, context); return; } memset(&data, 0, sizeof(data)); data.uid = pw->pw_uid; data.gid = pw->pw_gid; data.virtual_user = data.system_user = pw->pw_name; len = strlen(pw->pw_dir); if (len < 3 || strcmp(pw->pw_dir + len - 3, "/./") != 0) data.home = pw->pw_dir; else { /* wu-ftpd uses <chroot>/./<dir>. We don't support the dir after chroot, but this should work well enough. */ data.home = t_strndup(pw->pw_dir, len-3); data.chroot = TRUE; } callback(&data, context); } struct userdb_module userdb_passwd = { NULL, NULL, passwd_lookup }; #endif
Add RETJMP for jumping to dynamic addresses
#pragma once #include <stdint.h> #define ASMJMP(a) _asm { mov CPatcher::uJumpBuffer, a } _asm { jmp CPatcher::uJumpBuffer } typedef void (*tfnHookFunc)(void); class CPatcher { public: static void InstallHook(uint32_t uAddress, void (*pfnFunc)(void)); static void UninstallHook(uint32_t uAddress, uint8_t uFirstByte, uint32_t uOtherBytes); static void InstallCallHook(uint32_t uAddress, void (*pfnFunc)(void)); static void InstallMethodHook(uint32_t uAddress, void (*pfnFunc)(void)); static void UnprotectAll(void); static uint32_t uJumpBuffer; };
#pragma once #include <stdint.h> #define ASMJMP(a) _asm { mov CPatcher::uJumpBuffer, a } _asm { jmp CPatcher::uJumpBuffer } #define RETJMP(a) _asm { push a } _asm { ret } typedef void (*tfnHookFunc)(void); class CPatcher { public: static void InstallHook(uint32_t uAddress, void (*pfnFunc)(void)); static void UninstallHook(uint32_t uAddress, uint8_t uFirstByte, uint32_t uOtherBytes); static void InstallCallHook(uint32_t uAddress, void (*pfnFunc)(void)); static void InstallMethodHook(uint32_t uAddress, void (*pfnFunc)(void)); static void UnprotectAll(void); static uint32_t uJumpBuffer; };
Use an unsigned long offset instead of int.
/* * OsmTileSource.h * RunParticles * * Created by Doug Letterman on 6/30/14. * Copyright 2014 Doug Letterman. All rights reserved. * */ #ifndef OSMTILESOURCE_H #define OSMTILESOURCE_H #include <QObject> #include <QNetworkAccessManager> #include <QNetworkReply> #include "Singleton.h" #include "math.h" struct OsmTile { unsigned int x, y, z; }; template<typename T> struct OsmTileHash { std::size_t operator()(const T& t) const { unsigned int offset = 0; for (unsigned int i=1; i < t.z; i++) { offset += pow(2, 2*i); } unsigned int edge = pow(2, t.z); return std::size_t(offset + t.x * edge + t.y); } }; class OsmTileSource : public QObject { Q_OBJECT public: void getTile(int x, int y, int z); signals: void tileReady(int x, int y, int z); public slots: void onRequestFinished(QNetworkReply *reply); protected: }; #endif
/* * OsmTileSource.h * RunParticles * * Created by Doug Letterman on 6/30/14. * Copyright 2014 Doug Letterman. All rights reserved. * */ #ifndef OSMTILESOURCE_H #define OSMTILESOURCE_H #include <QObject> #include <QNetworkAccessManager> #include <QNetworkReply> #include "Singleton.h" #include "math.h" struct OsmTile { unsigned int x, y, z; }; template<typename T> struct OsmTileHash { std::size_t operator()(const T& t) const { unsigned long offset = 0; for (int i=1; i < t.z; i++) { offset += pow(2, 2*i); } int edge = pow(2, t.z); return std::size_t(offset + t.x * edge + t.y); } }; class OsmTileSource : public QObject { Q_OBJECT public: void getTile(int x, int y, int z); signals: void tileReady(int x, int y, int z); public slots: void onRequestFinished(QNetworkReply *reply); protected: }; #endif
Add definitions for atio and atol.
#ifndef _FXCG_STDLIB_H #define _FXCG_STDLIB_H #ifdef __cplusplus extern "C" { #endif #include <stddef.h> long abs(long n); void free(void *p); void *malloc(size_t sz); void *realloc(void *p, size_t sz); int rand(void); void srand(unsigned seed); long strtol(const char *str, char **str_end, int base); void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *)); void exit(int status); #ifdef __cplusplus } #endif #endif
#ifndef _FXCG_STDLIB_H #define _FXCG_STDLIB_H #ifdef __cplusplus extern "C" { #endif #include <stddef.h> long abs(long n); void free(void *p); void *malloc(size_t sz); void *realloc(void *p, size_t sz); int rand(void); void srand(unsigned seed); long strtol(const char *str, char **str_end, int base); #define atoi(s) ((int)strtol(s, NULL, 10)) #define atol(s) strtol(s, NULL, 10) void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *)); void exit(int status); #ifdef __cplusplus } #endif #endif
Change dlopening of libs to call libraries with their major version on linux systems
#if HAVE_CONFIG_H #include "config.h" #endif #include "dl.h" #include "util/macro.h" #include "util/logging.h" #include <stdlib.h> #include <dlfcn.h> #include <string.h> // Note the dlopen takes just the name part. "aacs", internally we // translate to "libaacs.so" "libaacs.dylib" or "aacs.dll". void *dl_dlopen ( const char* name ) { char *path; int len; void *result; #ifdef __APPLE__ len = strlen(name) + 3 + 6 + 1; path = (char *) malloc(len); if (!path) return NULL; snprintf(path, len, "lib%s.dylib", name); #else len = strlen(name) + 3 + 3 + 1; path = (char *) malloc(len); if (!path) return NULL; snprintf(path, len, "lib%s.so", name); #endif DEBUG(DBG_BDPLUS, "searching for library '%s' ...\n", path); result = dlopen(path, RTLD_LAZY); if (!result) { DEBUG(DBG_FILE | DBG_CRIT, "can't open library '%s': %s\n", path, dlerror()); } free(path); return result; } void *dl_dlsym ( void* handle, const char* symbol ) { void *result = dlsym(handle, symbol); if (!result) { DEBUG(DBG_FILE | DBG_CRIT, "dlsym(%p, '%s') failed: %s\n", handle, symbol, dlerror()); } return result; } int dl_dlclose ( void* handle ) { return dlclose(handle); }
#if HAVE_CONFIG_H #include "config.h" #endif #include "dl.h" #include "util/macro.h" #include "util/logging.h" #include <stdlib.h> #include <dlfcn.h> #include <string.h> void *dl_dlopen ( const char* path ) { DEBUG(DBG_BDPLUS, "searching for library '%s' ...\n", path); void *result = dlopen(path, RTLD_LAZY); if (!result) { DEBUG(DBG_FILE | DBG_CRIT, "can't open library '%s': %s\n", path, dlerror()); } return result; } void *dl_dlsym ( void* handle, const char* symbol ) { void *result = dlsym(handle, symbol); if (!result) { DEBUG(DBG_FILE | DBG_CRIT, "dlsym(%p, '%s') failed: %s\n", handle, symbol, dlerror()); } return result; } int dl_dlclose ( void* handle ) { return dlclose(handle); }
Fix build on older MSVC.
#pragma once // Clobber previous definitions with extreme prejudice #ifdef UNUSED # undef UNUSED #endif #ifdef likely # undef likely #endif #ifdef unlikely # undef unlikely #endif #ifdef alignment # undef alignment #endif #define UNUSED __pragma(warning(disable:4100)) #define unlikely(x) (x) #define likely(x) (x) #define alignment(x) __declspec(align(x)) #if (_MSC_VER >= 1400) # define restrict __restrict #else # define restrict #endif #if (MSC_VER <= 1500) && !defined(cplusplus) # define inline __inline #endif #pragma warning(disable:4201 4214) #ifndef HAVE_STDINT_H # include "platform/os/stdint_msvc.h" #endif #if !defined(HAVE_STDBOOL_H) && !defined(cplusplus) # include <Windows.h> typedef BOOL bool; # define true TRUE # define false FALSE #endif
#pragma once // Clobber previous definitions with extreme prejudice #ifdef UNUSED # undef UNUSED #endif #ifdef likely # undef likely #endif #ifdef unlikely # undef unlikely #endif #ifdef alignment # undef alignment #endif #define unlikely(x) (x) #define likely(x) (x) #define alignment(x) __declspec(align(x)) #if (_MSC_VER >= 1300) # define UNUSED __pragma(warning(disable:4100)) #else # define UNUSED #endif #if (_MSC_VER >= 1400) # define restrict __restrict #else # define restrict #endif #if (MSC_VER <= 1500) && !defined(cplusplus) # define inline __inline #endif #pragma warning(disable:4201 4214) #ifndef HAVE_STDINT_H # include "platform/os/stdint_msvc.h" #endif #if !defined(HAVE_STDBOOL_H) && !defined(cplusplus) # include <Windows.h> typedef BOOL bool; # define true TRUE # define false FALSE #endif
Fix spacing in parameter for readability
#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 * k); void ListNode_Destroy(ListNode* n); ListNode* List_Search(List* l, void* k, int (f)(void*, void*)); void List_Insert(List* l, ListNode* n); void List_Delete(List* l, ListNode* n); #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* k); void ListNode_Destroy(ListNode* n); ListNode* List_Search(List* l, void* k, int (f)(void*, void*)); void List_Insert(List* l, ListNode* n); void List_Delete(List* l, ListNode* n); #endif
Remove redundant void argument lists
// // Created by Mathew Seng on 2019-06-03. // #ifndef ExampleCostFunction_h #define ExampleCostFunction_h #include "itkSingleValuedCostFunction.h" namespace itk { class ExampleCostFunction2 : public SingleValuedCostFunction { public: /** Standard class typedefs. */ typedef ExampleCostFunction2 Self; typedef SingleValuedCostFunction Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ExampleCostFunction2, SingleValuedCostfunction); unsigned int GetNumberOfParameters(void) const override { return 2; } // itk::CostFunction MeasureType GetValue(const ParametersType & parameters) const override { return pow(parameters[0] + 5, 2) + pow(parameters[1] - 7, 2) + 5; } void GetDerivative(const ParametersType &, DerivativeType & /*derivative*/) const override { throw itk::ExceptionObject(__FILE__, __LINE__, "No derivative is available for this cost function."); } protected: ExampleCostFunction2() = default; ; ~ExampleCostFunction2() override = default; ; private: ExampleCostFunction2(const Self &) = delete; // purposely not implemented void operator=(const Self &) = delete; // purposely not implemented }; } // end namespace itk #endif
// // Created by Mathew Seng on 2019-06-03. // #ifndef ExampleCostFunction_h #define ExampleCostFunction_h #include "itkSingleValuedCostFunction.h" namespace itk { class ExampleCostFunction2 : public SingleValuedCostFunction { public: /** Standard class typedefs. */ typedef ExampleCostFunction2 Self; typedef SingleValuedCostFunction Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ExampleCostFunction2, SingleValuedCostfunction); unsigned int GetNumberOfParameters() const override { return 2; } // itk::CostFunction MeasureType GetValue(const ParametersType & parameters) const override { return pow(parameters[0] + 5, 2) + pow(parameters[1] - 7, 2) + 5; } void GetDerivative(const ParametersType &, DerivativeType & /*derivative*/) const override { throw itk::ExceptionObject(__FILE__, __LINE__, "No derivative is available for this cost function."); } protected: ExampleCostFunction2() = default; ; ~ExampleCostFunction2() override = default; ; private: ExampleCostFunction2(const Self &) = delete; // purposely not implemented void operator=(const Self &) = delete; // purposely not implemented }; } // end namespace itk #endif
Update file, Alura, Introdução a C, Aula 1
#include <stdio.h> int main() { // imprime o cabecalho do nosso jogo printf("******************************************\n"); printf("* Bem vindo ao nosso jogo de adivinhação *\n"); printf("******************************************\n"); }
#include <stdio.h> int main() { // imprime o cabecalho do nosso jogo printf("******************************************\n"); printf("* Bem vindo ao nosso jogo de adivinhação *\n"); printf("******************************************\n"); int numerosecreto = 42; printf("O número %d é o secreto. Não conta pra ninguém!\n", numerosecreto); }
Allow test subsystem to set off clone bombs
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2010, 2012, 2013, 2014 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/system.h> inherit LIB_INITD; inherit UTILITY_COMPILE; static void create() { KERNELD->set_global_access("Test", 1); load_dir("obj", 1); load_dir("sys", 1); }
/* * This file is part of Kotaka, a mud library for DGD * http://github.com/shentino/kotaka * * Copyright (C) 2010, 2012, 2013, 2014 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/system.h> inherit LIB_INITD; inherit UTILITY_COMPILE; static void create() { KERNELD->set_global_access("Test", 1); load_dir("obj", 1); load_dir("sys", 1); } void bomb(int quota) { if (quota) { quota--; clone_object("obj/bomb"); call_out("bomb", 0, quota); } }
Set MAX_FILE_NAME appropiately with LFN and FATFS
/* * Copyright (c) 2016 Intel Corporation. * * SPDX-License-Identifier: Apache-2.0 */ #ifndef ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ #define ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ #ifdef __cplusplus extern "C" { #endif #if defined(CONFIG_FILE_SYSTEM_LITTLEFS) #define MAX_FILE_NAME 256 #else /* FAT_FS */ #define MAX_FILE_NAME 12 /* Uses 8.3 SFN */ #endif struct fs_mount_t; /** * @brief File object representing an open file * * @param Pointer to FATFS file object structure * @param mp Pointer to mount point structure */ struct fs_file_t { void *filep; const struct fs_mount_t *mp; }; /** * @brief Directory object representing an open directory * * @param dirp Pointer to directory object structure * @param mp Pointer to mount point structure */ struct fs_dir_t { void *dirp; const struct fs_mount_t *mp; }; #ifdef __cplusplus } #endif #endif /* ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ */
/* * Copyright (c) 2016 Intel Corporation. * * SPDX-License-Identifier: Apache-2.0 */ #ifndef ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ #define ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ #ifdef __cplusplus extern "C" { #endif #if defined(CONFIG_FILE_SYSTEM_LITTLEFS) #define MAX_FILE_NAME 256 #elif defined(CONFIG_FAT_FILESYSTEM_ELM) #if defined(CONFIG_FS_FATFS_LFN) #define MAX_FILE_NAME CONFIG_FS_FATFS_MAX_LFN #else /* CONFIG_FS_FATFS_LFN */ #define MAX_FILE_NAME 12 /* Uses 8.3 SFN */ #endif /* CONFIG_FS_FATFS_LFN */ #else /* filesystem selection */ /* Use standard 8.3 when no filesystem is explicitly selected */ #define MAX_FILE_NAME 12 #endif /* filesystem selection */ struct fs_mount_t; /** * @brief File object representing an open file * * @param Pointer to FATFS file object structure * @param mp Pointer to mount point structure */ struct fs_file_t { void *filep; const struct fs_mount_t *mp; }; /** * @brief Directory object representing an open directory * * @param dirp Pointer to directory object structure * @param mp Pointer to mount point structure */ struct fs_dir_t { void *dirp; const struct fs_mount_t *mp; }; #ifdef __cplusplus } #endif #endif /* ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ */
Add unit tests for list sorting.
#include "test_lib.h" #include "test_helpers.h" #include "commit.h" #include <git/odb.h> #include <git/commit.h> BEGIN_TEST(list_sort_test) git_commit_list list; git_commit_node *n; int i, t; time_t previous_time; #define TEST_SORTED() \ previous_time = 0;\ for (n = list.head; n != NULL; n = n->next)\ {\ must_be_true(n->commit->commit_time >= previous_time);\ previous_time = n->commit->commit_time;\ } memset(&list, 0x0, sizeof(git_commit_list)); srand(time(NULL)); for (t = 0; t < 20; ++t) { const int test_size = rand() % 500 + 500; // Purely random sorting test for (i = 0; i < test_size; ++i) { git_commit *c = git__malloc(sizeof(git_commit)); c->commit_time = (time_t)rand(); git_commit_list_append(&list, c); } git_commit_list_sort(&list); TEST_SORTED(); git_commit_list_clear(&list, 1); } // Try to sort list with all dates equal. for (i = 0; i < 200; ++i) { git_commit *c = git__malloc(sizeof(git_commit)); c->commit_time = 0; git_commit_list_append(&list, c); } git_commit_list_sort(&list); TEST_SORTED(); git_commit_list_clear(&list, 1); // Try to sort empty list git_commit_list_sort(&list); TEST_SORTED(); END_TEST
Add normal information to terrain.
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Base class for a terrain subsystem. // // ============================================================================= #ifndef CH_TERRAIN_H #define CH_TERRAIN_H #include "core/ChShared.h" #include "subsys/ChApiSubsys.h" namespace chrono { class CH_SUBSYS_API ChTerrain : public ChShared { public: ChTerrain() {} virtual ~ChTerrain() {} virtual void Update(double time) {} virtual void Advance(double step) {} virtual double GetHeight(double x, double y) const = 0; }; } // end namespace chrono #endif
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Base class for a terrain subsystem. // // ============================================================================= #ifndef CH_TERRAIN_H #define CH_TERRAIN_H #include "core/ChShared.h" #include "core/ChVector.h" #include "subsys/ChApiSubsys.h" namespace chrono { class CH_SUBSYS_API ChTerrain : public ChShared { public: ChTerrain() {} virtual ~ChTerrain() {} virtual void Update(double time) {} virtual void Advance(double step) {} virtual double GetHeight(double x, double y) const = 0; //// TODO: make this a pure virtual function... virtual ChVector<> GetNormal(double x, double y) const { return ChVector<>(0, 0, 1); } }; } // end namespace chrono #endif
Add a wrapper between Seen_table and pymue.SeenTable
#ifndef PYMUE_SEEN_TABLE_WRAPPER #define PYMUE_SEEN_TABLE_WRAPPER #include <memory> #include "seen_table.h" namespace pymue { class Seen_table_wrapper { private: std::shared_ptr<mue::Seen_table> _seen_table; Seen_table_wrapper(mue::Seen_table&& seen_table) : _seen_table(new mue::Seen_table(std::move(seen_table))) { } public: Seen_table_wrapper(int num_teams) : _seen_table(new mue::Seen_table(num_teams)) { } Seen_table_wrapper clone() const { return Seen_table_wrapper(_seen_table->clone()); } int generation() const { return _seen_table->generation(); } bool seen(mue::Team_id a, mue::Team_id b, mue::Team_id c) const { return _seen_table->seen(a, b, c); } void add_meeting(mue::Team_id a, mue::Team_id b, mue::Team_id c) { _seen_table->add_meeting(a, b, c); } }; } #endif
Add missing include, fix variable name.
#pragma once #include <string> #include <memory> #include <stdexcept> namespace JWTXX { enum class Algorithm { HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512, none }; class Key { public: struct Error : std::runtime_error { Error(const std::string& message) : runtime_error(error) {} }; Key(Algorithm alg, const std::string& keyData); std::string sign(const void* data, size_t size) const; bool verify(const void* data, size_t size, const std::string& signature) const; struct Impl; private: std::unique_ptr<Impl> m_impl; }; class JWT { public: typedef std::unordered_map<std::string, std::string> Pairs; JWT(const std::string& token, Key key); JWT(Algorithm alg, Pairs claims, Pairs header = Pairs()); Algorithm alg() const { return m_alg; } const Pairs& claims() const { return m_claims; } const Pairs& header() const { return m_header; } std::string claim(const std::string& name) const; std::string token(const std::string& keyData) const; private: Algorithm m_alg; Pairs m_header; Pairs m_claims; }; }
#pragma once #include <string> #include <unordered_map> #include <memory> #include <stdexcept> namespace JWTXX { enum class Algorithm { HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512, none }; class Key { public: struct Error : std::runtime_error { Error(const std::string& message) : runtime_error(message) {} }; Key(Algorithm alg, const std::string& keyData); std::string sign(const void* data, size_t size) const; bool verify(const void* data, size_t size, const std::string& signature) const; struct Impl; private: std::unique_ptr<Impl> m_impl; }; class JWT { public: typedef std::unordered_map<std::string, std::string> Pairs; JWT(const std::string& token, Key key); JWT(Algorithm alg, Pairs claims, Pairs header = Pairs()); Algorithm alg() const { return m_alg; } const Pairs& claims() const { return m_claims; } const Pairs& header() const { return m_header; } std::string claim(const std::string& name) const; std::string token(const std::string& keyData) const; private: Algorithm m_alg; Pairs m_header; Pairs m_claims; }; }
Add a new testcase where a points-to or esafe edge is not being added properly
#include "../small1/testharness.h" #include "../small1/testkinds.h" #ifndef ERROR #define __WILD #endif // NUMERRORS 1 typedef struct foo Foo; struct bar { Foo * __WILD next; }; struct foo { int *base; unsigned int length; struct bar link; }; int main() { struct foo s, *sptr = &s; if(HAS_KIND(sptr->base, WILD_KIND)) E(1); //ERROR(1):Error 1 }
Test for struct in GNU ?: expressions
// RUN: %check -e %s main() { struct A { int i; } a, b, c; a = b ? : c; // CHECK: error: struct involved in if-expr }
Check ifndef NULL before define NULL, because clang stddef.h defines NULL
#define NULL ((void *)0) #define MIN(_a, _b) \ ({ \ __typeof__(_a) __a = (_a); \ __typeof__(_b) __b = (_b); \ __a <= __b ? __a : __b; \ }) #define MAX(_a, _b) \ ({ \ __typeof__(_a) __a = (_a); \ __typeof__(_b) __b = (_b); \ __a >= __b ? __a : __b; \ }) #define NELEM(x) (sizeof(x)/sizeof((x)[0])) #define cmpswap(ptr, old, new) __sync_bool_compare_and_swap(ptr, old, new) #define subfetch(ptr, val) __sync_sub_and_fetch(ptr, val) #define fetchadd(ptr, val) __sync_fetch_and_add(ptr, val) #define __offsetof offsetof
#ifndef NULL #define NULL ((void *)0) #endif #define MIN(_a, _b) \ ({ \ __typeof__(_a) __a = (_a); \ __typeof__(_b) __b = (_b); \ __a <= __b ? __a : __b; \ }) #define MAX(_a, _b) \ ({ \ __typeof__(_a) __a = (_a); \ __typeof__(_b) __b = (_b); \ __a >= __b ? __a : __b; \ }) #define NELEM(x) (sizeof(x)/sizeof((x)[0])) #define cmpswap(ptr, old, new) __sync_bool_compare_and_swap(ptr, old, new) #define subfetch(ptr, val) __sync_sub_and_fetch(ptr, val) #define fetchadd(ptr, val) __sync_fetch_and_add(ptr, val) #define __offsetof offsetof
Add initial code to list IPv4 addresses
#include <arpa/inet.h> #include <net/if.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #if INET_ADDRSTRLEN > INET6_ADDRSTRLEN #define BUF_LEN #INET_ADDRSTRLEN #else #define BUF_LEN INET6_ADDRSTRLEN #endif int main() { if (access("/proc/net", R_OK)) { goto errorout; } if (access("/proc/net/if_inet6", R_OK)) { goto errorout; } int ipv4_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if (ipv4_fd == -1) { goto errorout; } struct ifconf stuff; stuff.ifc_len = 0; stuff.ifc_buf = NULL; if (ioctl(ipv4_fd, SIOCGIFCONF, &stuff)) { goto errorout; } if (!(stuff.ifc_buf = malloc(stuff.ifc_len))) { goto errorout; } if (ioctl(ipv4_fd, SIOCGIFCONF, &stuff)) { goto errorout; } int i, len; char addr[BUF_LEN]; for (i = 0, len = stuff.ifc_len / sizeof(struct ifreq); i < len; ++i) { if (!strncmp(stuff.ifc_req[i].ifr_name, "lo", 2)) { continue; } struct sockaddr_in *sockaddr = (struct sockaddr_in*) &stuff.ifc_req[i].ifr_addr; printf("%s\t%s\n", inet_ntop(AF_INET, &sockaddr->sin_addr, addr, BUF_LEN), stuff.ifc_req[i].ifr_name); } return 0; errorout: perror("something went wrong"); exit(EXIT_FAILURE); }
Add target triple in test
// RUN: %clang_cc1 -S -fno-preserve-as-comments %s -o - | FileCheck %s --check-prefix=NOASM --check-prefix=CHECK // RUN: %clang_cc1 -S %s -o - | FileCheck %s --check-prefix=ASM --check-prefix=CHECK // CHECK-LABEL: main // CHECK: #APP // ASM: #comment // NOASM-NOT: #comment // CHECK: #NO_APP int main() { __asm__("/*comment*/"); return 0; }
// RUN: %clang_cc1 -S -triple=x86_64-unknown-unknown -fno-preserve-as-comments %s -o - | FileCheck %s --check-prefix=NOASM --check-prefix=CHECK // RUN: %clang_cc1 -S %s -triple=x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=ASM --check-prefix=CHECK // CHECK-LABEL: main // CHECK: #APP // ASM: #comment // NOASM-NOT: #comment // CHECK: #NO_APP int main() { __asm__("/*comment*/"); return 0; }
Make this test a bit stricter by checking clang's output too.
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -emit-llvm-bc -o %t.bc %s // RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NO-BC %s // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-BC %s int f(void); #ifdef BITCODE // CHECK-BC: 'f': symbol multiply defined int f(void) { return 42; } #else // CHECK-NO-BC-LABEL: define i32 @g // CHECK-NO-BC: ret i32 42 int g(void) { return f(); } // CHECK-NO-BC-LABEL: define i32 @f #endif
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -emit-llvm-bc -o %t.bc %s // RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NO-BC %s // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-BC %s int f(void); #ifdef BITCODE // CHECK-BC: fatal error: cannot link module {{.*}}'f': symbol multiply defined int f(void) { return 42; } #else // CHECK-NO-BC-LABEL: define i32 @g // CHECK-NO-BC: ret i32 42 int g(void) { return f(); } // CHECK-NO-BC-LABEL: define i32 @f #endif
Add solution to Exercise 1-12.
/* Exercise 1-12: Write a program that prints its input one word per line. */ #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { int16_t character; bool in_whitespace; while ((character = getchar()) != EOF) { if ((character == ' ') || (character == '\t')) { if (in_whitespace == false) { putchar('\n'); in_whitespace = true; } } else { putchar(character); in_whitespace = false; } } return EXIT_SUCCESS; }
Fix an outdated comment in a test. NFC.
// RUN: %clang_analyze_cc1 -w -x c -analyzer-checker=core -analyzer-output=text -verify %s // Avoid the crash when finding the expression for tracking the origins // of the null pointer for path notes. Apparently, not much actual tracking // needs to be done in this example. void pr34373() { int *a = 0; // expected-note{{'a' initialized to a null pointer value}} (a + 0)[0]; // expected-warning{{Array access results in a null pointer dereference}} // expected-note@-1{{Array access results in a null pointer dereference}} }
// RUN: %clang_analyze_cc1 -w -x c -analyzer-checker=core -analyzer-output=text -verify %s // Avoid the crash when finding the expression for tracking the origins // of the null pointer for path notes. void pr34373() { int *a = 0; // expected-note{{'a' initialized to a null pointer value}} (a + 0)[0]; // expected-warning{{Array access results in a null pointer dereference}} // expected-note@-1{{Array access results in a null pointer dereference}} }
Add test of newly checked in Union support!
union X; struct Empty {}; union F {}; union Q { union Q *X; }; union X { char C; int A, Z; long long B; void *b1; struct { int A; long long Z; } Q; }; union X foo(union X A) { A.C = 123; A.A = 39249; //A.B = (void*)123040123321; A.B = 12301230123123LL; A.Z = 1; return A; }
Fix the two-step-macro behavior, tests pass
#import <Foundation/Foundation.h> #define EEEPrepareBlockSelf() __weak __typeof__(self) __weakSelf = self #define EEEUseBlockSelf() __typeof__(__weakSelf) __weak blockSelf = __weakSelf @class EEEInjector; @class EEEOperation; @interface EEEOperationCenter : NSObject @property(nonatomic, strong) NSOperationQueue *mainCommandQueue; @property(nonatomic, strong) NSOperationQueue *backgroundCommandQueue; @property NSInteger maxConcurrentOperationCount; + (EEEOperationCenter *)currentOperationCenter; + (EEEOperationCenter *)setCurrentOperationCenter:(EEEOperationCenter *)defaultCenter; - (id)initWithInjector:(EEEInjector *)injector; - (id)queueOperation:(EEEOperation *)operation; - (id)inlineOperation:(EEEOperation *)operation withTimeout:(NSTimeInterval)seconds; @end
#import <Foundation/Foundation.h> #define EEEPrepareBlockSelf() __weak __typeof__(self) __weakSelf = self #define EEEUseBlockSelf() __strong __typeof__(__weakSelf) blockSelf = __weakSelf @class EEEInjector; @class EEEOperation; @interface EEEOperationCenter : NSObject @property(nonatomic, strong) NSOperationQueue *mainCommandQueue; @property(nonatomic, strong) NSOperationQueue *backgroundCommandQueue; @property NSInteger maxConcurrentOperationCount; + (EEEOperationCenter *)currentOperationCenter; + (EEEOperationCenter *)setCurrentOperationCenter:(EEEOperationCenter *)defaultCenter; - (id)initWithInjector:(EEEInjector *)injector; - (id)queueOperation:(EEEOperation *)operation; - (id)inlineOperation:(EEEOperation *)operation withTimeout:(NSTimeInterval)seconds; @end
Add prototypes for setbuffer() and setlinebuf(). Questionable as these should probably be replaced with ANSI stype setbuf() calls.
#ifndef FIX_STDIO_H #define FIX_STDIO_H #include <stdio.h> #if defined(__cplusplus) extern "C" { #endif /* For some reason the stdio.h on OSF1 fails to provide prototypes for popen() and pclose() if _POSIX_SOURCE is defined. */ #if defined(OSF1) #if defined(__STDC__) || defined(__cplusplus) FILE *popen( char *, char * ); int pclose( FILE *__stream ); #else FILE *popen(); int pclose(); #endif #endif /* OSF1 */ /* For some reason the stdio.h on Ultrix 4.3 fails to provide a prototype for pclose() if _POSIX_SOURCE is defined - even though it does provide a prototype for popen(). */ #if defined(ULTRIX43) #if defined(__STDC__) || defined(__cplusplus) int pclose( FILE *__stream ); #else int pclose(); #endif #endif /* ULTRIX43 */ #if defined(__cplusplus) } #endif #endif
#ifndef FIX_STDIO_H #define FIX_STDIO_H #include <stdio.h> #if defined(__cplusplus) extern "C" { #endif /* For some reason the stdio.h on OSF1 fails to provide prototypes for popen() and pclose() if _POSIX_SOURCE is defined. */ #if defined(OSF1) #if defined(__STDC__) || defined(__cplusplus) FILE *popen( char *, char * ); int pclose( FILE *__stream ); extern void setbuffer(FILE*, char*, int); extern void setlinebuf(FILE*); #else FILE *popen(); int pclose(); extern void setbuffer(); extern void setlinebuf(); #endif #endif /* OSF1 */ /* For some reason the stdio.h on Ultrix 4.3 fails to provide a prototype for pclose() if _POSIX_SOURCE is defined - even though it does provide a prototype for popen(). */ #if defined(ULTRIX43) #if defined(__STDC__) || defined(__cplusplus) int pclose( FILE *__stream ); #else int pclose(); #endif #endif /* ULTRIX43 */ #if defined(__cplusplus) } #endif #endif
Revert "mv example source code"
#include <stdio.h> #include <string.h> #include "../src/mlist.h" int main (int argc, char *argv[]) { mlist_t *list; int *n; char *c; char *s = NULL; const char *name = "cubicdaiya"; list = mlist_create(); n = mlist_palloc(list, sizeof(int)); list = mlist_extend(list); c = mlist_palloc(list, sizeof(char)); list = mlist_extend(list); s = mlist_palloc(list, strlen(name) + 1); list = mlist_extend(list); *n = 5; *c = 'a'; strncpy(s, name, strlen(name) + 1); printf("n = %d\n", *n); printf("c = %c\n", *c); printf("name = %s\n", s); mlist_destroy(list); return 0; }
#include <stdio.h> #include <string.h> #include "mlist.h" int main (int argc, char *argv[]) { mlist_t *list; int *n; char *c; char *s = NULL; const char *name = "cubicdaiya"; list = mlist_create(); n = mlist_palloc(list, sizeof(int)); list = mlist_extend(list); c = mlist_palloc(list, sizeof(char)); list = mlist_extend(list); s = mlist_palloc(list, strlen(name) + 1); list = mlist_extend(list); *n = 5; *c = 'a'; strncpy(s, name, strlen(name) + 1); printf("n = %d\n", *n); printf("c = %c\n", *c); printf("name = %s\n", s); mlist_destroy(list); return 0; }
Add framework version info to umbrella header
// Douglas Hill, May 2015 // https://github.com/douglashill/DHScatterGraph #import <DHScatterGraph/DHScatterGraphLineAttributes.h> #import <DHScatterGraph/DHScatterGraphPointSet.h> #import <DHScatterGraph/DHScatterGraphView.h>
// Douglas Hill, May 2015 // https://github.com/douglashill/DHScatterGraph extern double const DHScatterGraphVersionNumber; extern unsigned char const DHScatterGraphVersionString[]; #import <DHScatterGraph/DHScatterGraphLineAttributes.h> #import <DHScatterGraph/DHScatterGraphPointSet.h> #import <DHScatterGraph/DHScatterGraphView.h>
Add a PID implementation that doesn't independently keep track of time
#ifndef PIDEXTERNALTIME_H #define PIDEXTERNALTIME_H #include "Arduino.h" #include "util/PIDparameters.h" class PIDexternaltime{ private: PIDparameters* param; float setPoint; float previous; float acc; boolean stopped; public: PIDexternaltime(PIDparameters* pid): param(pid), setPoint(0), previous(0), acc(0), stopped(true) {} void tune(PIDparameters* pid){ param = pid; } void clearAccumulator(){ train(0); } void train(float out){ acc = constrain(out, param->lowerBound, param->upperBound); } void set(float input){ setPoint = input; stopped = false; } void stop() { clearAccumulator(); stopped = true; } /** * Update the PID controller * current - the current process value * ms - milliseconds since last update */ float update(float current, float ms){ uint32_t cTime = micros(); if(stopped) { time = cTime; previous = 0; return 0; } const float dt = min(ms/1000.0, 1.0); //convert to seconds, cap at 1 const float error = setPoint-current; const float newAcc = acc + param->I*error*dt; const float output = param->P * error + newAcc + param->D * (previous-current)/dt; previous = current; if (output > param->upperBound) { acc = min(acc, newAcc); //only let acc decrease return param->upperBound; } else if (output < param->lowerBound) { acc = max(acc, newAcc); //only let acc increase return param->lowerBound; } //to prevent integral windup, we only change the integral if the output //is not fully saturated acc = newAcc; return output; } }; #endif
Add a missing copyright for Doug. There are other files missing this copyright in -stable.
#include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <stdarg.h> #include <stdlib.h> int semctl(int semid, int semnum, int cmd, ...) { va_list ap; union semun semun; union semun *semun_ptr; va_start(ap, cmd); if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL || cmd == SETVAL || cmd == SETALL) { semun = va_arg(ap, union semun); semun_ptr = &semun; } else { semun_ptr = NULL; } va_end(ap); return (__semctl(semid, semnum, cmd, semun_ptr)); }
/*- * Copyright (c) 2002 Doug Rabson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <stdarg.h> #include <stdlib.h> int semctl(int semid, int semnum, int cmd, ...) { va_list ap; union semun semun; union semun *semun_ptr; va_start(ap, cmd); if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL || cmd == SETVAL || cmd == SETALL) { semun = va_arg(ap, union semun); semun_ptr = &semun; } else { semun_ptr = NULL; } va_end(ap); return (__semctl(semid, semnum, cmd, semun_ptr)); }
Use the right type for the csync_vio_method_handle_t.
/* * libcsync -- a library to sync a directory with another * * Copyright (c) 2008 by Andreas Schneider <mail@cynapses.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * vim: ft=c.doxygen ts=2 sw=2 et cindent */ #ifndef _CSYNC_VIO_HANDLE_H #define _CSYNC_VIO_HANDLE_H typedef void *csync_vio_method_handle_t; typedef struct csync_vio_handle_s csync_vio_handle_t; #endif /* _CSYNC_VIO_HANDLE_H */
/* * libcsync -- a library to sync a directory with another * * Copyright (c) 2008 by Andreas Schneider <mail@cynapses.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * vim: ft=c.doxygen ts=2 sw=2 et cindent */ #ifndef _CSYNC_VIO_HANDLE_H #define _CSYNC_VIO_HANDLE_H typedef void csync_vio_method_handle_t; typedef struct csync_vio_handle_s csync_vio_handle_t; #endif /* _CSYNC_VIO_HANDLE_H */
Rework and kill pointless static variable -Erik
/* * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath) * * * Dale Schumacher 399 Beacon Ave. * (alias: Dalnefre') St. Paul, MN 55104 * dal@syntel.UUCP United States of America * "It's not reality that's important, but how you perceive things." */ #include <stdio.h> static int _bsearch; /* index of element found, or where to * insert */ char *bsearch(key, base, num, size, cmp) register char *key; /* item to search for */ register char *base; /* base address */ int num; /* number of elements */ register int size; /* element size in bytes */ register int (*cmp) (); /* comparison function */ { register int a, b, c, dir; a = 0; b = num - 1; while (a <= b) { c = (a + b) >> 1; /* == ((a + b) / 2) */ if ((dir = (*cmp) (key, (base + (c * size))))) { if (dir < 0) b = c - 1; else /* (dir > 0) */ a = c + 1; } else { _bsearch = c; return (base + (c * size)); } } _bsearch = b; return (NULL); }
/* * This file originally lifted in toto from 'Dlibs' on the atari ST (RdeBath) * * * Dale Schumacher 399 Beacon Ave. * (alias: Dalnefre') St. Paul, MN 55104 * dal@syntel.UUCP United States of America * "It's not reality that's important, but how you perceive things." * * Reworked by Erik Andersen <andersen@uclibc.org> */ #include <stdio.h> void * bsearch (const void *key, const void *base, size_t num, size_t size, int (*cmp) (const void *, const void *)) { int dir; size_t a, b, c; const void *p; a = 0; b = num; while (a < b) { c = (a + b) >> 1; /* == ((a + b) / 2) */ p = (void *)(((const char *) base) + (c * size)); dir = (*cmp)(key, p); if (dir < 0) { b = c; } else if (dir > 0) { a = c + 1; } else { return (void *)p; } } return NULL; }
Test to see what jenkins will do
static char startmessage[] = "Linux Backup Client"; #include<stdio.h> #include<string.h> #include"db.h" int main(int argc, char **argv) { int argindex = 0; puts(startmessage); for(argindex = 1; argindex < argc; argindex++) { if(strcmp(argv[argindex], "version") == 0) { puts("This should display version"); } else if(strcmp(argv[argindex], "new") == 0) { puts("This should create a new block"); printf("Creating new block with name '%s'\n", argv[argindex + 1]); ++argindex; write_database(argv[argindex + 1]); } else if(strcmp(argv[argindex], "create") == 0) { if(create_database(argv[argindex + 1])) { puts("Cannot open file."); } ++argindex; } else { printf("Command '%s' not regognized\n", argv[argindex]); } } return 0; }
static char startmessage[] = "Linux Backup Client"; #include<stdio.h> #include<string.h> #include"db.h" int main(int argc, char **argv) { THIS WILL BREAK THE BUILD! int argindex = 0; puts(startmessage); for(argindex = 1; argindex < argc; argindex++) { if(strcmp(argv[argindex], "version") == 0) { puts("This should display version"); } else if(strcmp(argv[argindex], "new") == 0) { puts("This should create a new block"); printf("Creating new block with name '%s'\n", argv[argindex + 1]); ++argindex; write_database(argv[argindex + 1]); } else if(strcmp(argv[argindex], "create") == 0) { if(create_database(argv[argindex + 1])) { puts("Cannot open file."); } ++argindex; } else { printf("Command '%s' not regognized\n", argv[argindex]); } } return 0; }
Make library type checkbox part of the library record.
testScreens: setup: stuffCheckBox Go to Field [ ] If [ tempSetup::InventoryLibaryYN = "" ] Set Field [ tempSetup::layoutLtagK; "" ] Set Field [ tempSetup::layoutRtagK; "" ] Set Field [ tempSetup::layoutLtagN; "" ] Set Field [ tempSetup::layoutRtagN; "" ] Else Set Field [ tempSetup::layoutLtagK; "moreltagNKs2" ] Set Field [ tempSetup::layoutRtagK; "moreReferenceMenu2SkeywordOrNode1" ] Set Field [ tempSetup::layoutLtagN; "moreltagNKs2" ] Set Field [ tempSetup::layoutRtagN; "moreReferenceMenu2SkeywordOrNode1" ] End If May 4, 平成27 21:28:07 Library.fp7 - stuffCheckBox -1-
changeLibraryOrLibraryName: stuffCheckBox # #Exit the checkbox. Go to Field [ ] # #Set default layouts for a reference library. If [ tempSetup::InventoryLibaryYN = "" ] Set Field [ tempSetup::layoutLtagK; "" ] Set Field [ tempSetup::layoutRtagK; "" ] Set Field [ tempSetup::layoutLtagN; "" ] Set Field [ tempSetup::layoutRtagN; "" ] # #Designate library as a reference library. Set Field [ sectionAttributionInfo::order; "" ] Else # #Set default layouts for a stuff/inventory library. Set Field [ tempSetup::layoutLtagK; "moreltagNKs2" ] Set Field [ tempSetup::layoutRtagK; "moreReferenceMenu2SkeywordOrNode1" ] Set Field [ tempSetup::layoutLtagN; "moreltagNKs2" ] Set Field [ tempSetup::layoutRtagN; "moreReferenceMenu2SkeywordOrNode1" ] # #Designate library as a stuff/inventory library. Set Field [ sectionAttributionInfo::order; 1 ] End If December 27, ଘ౮27 19:05:50 Library.fp7 - stuffCheckBox -1-
Fix logic error in check() function.
//===- Error.h --------------------------------------------------*- C++ -*-===// // // The LLVM Linker // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLD_COFF_ERROR_H #define LLD_COFF_ERROR_H #include "lld/Core/LLVM.h" #include "llvm/Support/Error.h" namespace lld { namespace coff { LLVM_ATTRIBUTE_NORETURN void error(const Twine &Msg); void error(std::error_code EC, const Twine &Prefix); void error(llvm::Error E, const Twine &Prefix); template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) { error(V.getError(), Prefix); } template <class T> T check(Expected<T> E, const Twine &Prefix) { if (!E) return std::move(*E); error(E.takeError(), Prefix); return T(); } } // namespace coff } // namespace lld #endif
//===- Error.h --------------------------------------------------*- C++ -*-===// // // The LLVM Linker // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLD_COFF_ERROR_H #define LLD_COFF_ERROR_H #include "lld/Core/LLVM.h" #include "llvm/Support/Error.h" namespace lld { namespace coff { LLVM_ATTRIBUTE_NORETURN void error(const Twine &Msg); void error(std::error_code EC, const Twine &Prefix); void error(llvm::Error E, const Twine &Prefix); template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) { error(V.getError(), Prefix); } template <class T> T check(Expected<T> E, const Twine &Prefix) { if (E) return std::move(*E); error(E.takeError(), Prefix); return T(); } } // namespace coff } // namespace lld #endif
Add routines to print sparse data structures
#if defined(CRAY_T3E) || defined(CRAY_T3D) int ONBITMASK( int *len ) #else int onbitmask_( int *len ) #endif { unsigned int mask; mask = ~((~0) << *len); return ((int)mask); }
#include <stdio.h> void c_print_sparsemat( int, int, int *, int *, int, double * ); #if defined(CRAY_T3E) || defined(CRAY_T3D) int ONBITMASK( int *len ) #else int onbitmask_( int *len ) #endif { unsigned int mask; mask = ~((~0) << *len); return ((int)mask); } #ifdef NOCOMPILE void print_sparsemat_( int *nc, int *nr, int *cpi, int *ir, int *nnz, double *v ) { c_print_sparsemat( *nc, *nr, cpi, ir, *nnz, v ); } void c_print_sparsemat( int nc, int nr, int *cpi, int *ir, int nnz, double *v ) { int ic, colmax, cvlo, cvhi, ncv; int npr, hasprint, ii2r, iiv, iir, mask16bit; int ilab; colmax = nc < 6 ? nc : 6; mask16bit = ~((~0) << 16); /* printf("\n"); for (ic=0; ic<colmax; ++ic) { printf(" %3d %3d ", cpi[2*ic], cpi[2*ic+1] ); } printf("\n"); */ ii2r = sizeof(int)/2; /* num of labels packed per int - 16 bits per label */ npr = 1; hasprint = 1; while (hasprint) { hasprint = 0; for (ic=0; ic<colmax; ++ic) { cvlo = cpi[2*ic]; cvhi = cpi[2*ic+1]; ncv = cvhi - cvlo + 1; if ((cvlo>0)&&(ncv>=npr)) { iiv = cvlo + npr - 1; iir = iiv/ii2r + ((iiv%ii2r) ? 1 : 0); ilab = (ir[iir-1] >> (16*(iiv%ii2r))) & mask16bit; printf(" %2d %8.4f", ilab, v[iiv-1] ); ++hasprint; } else { printf(" "); } } printf("\n"); ++npr; } } #endif
Add 2D Array - DS Challenge
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int main(){ int arr[6][6]; int max = 0; int sum = 0; int n = 0; for(int arr_i = 0; arr_i < 6; arr_i++){ for(int arr_j = 0; arr_j < 6; arr_j++){ scanf("%d",&arr[arr_i][arr_j]); } } for(int arr_i = 2, mid = arr_i + 1; arr_i < 5; arr_i++){ for(int arr_j = 0; arr_j < 3; arr_j++){ if(arr_i == mid) { sum += arr[mid][arr_j + 1]; break; } else { sum += arr[arr_i][arr_j]; max = (sum > max) ? sum : max; } } } printf("%i\n", max); return max; }
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int hourglass(int *array); int main(){ int arr[6][6]; int max = 0; int sum = 0; int n = 0; int i = 0; int j = 0; for(int row = 0; row < 6; row++){ for(int column = 0; column < 6; column++){ scanf("%d", &arr[row][column]); } } while(n < 16) { for(int row = i; row < i + 3; row++){ for(int column = j; column < j + 3; column++){ if(row == i + 1) { sum += arr[i + 1][j + 1]; break; } sum += arr[row][column]; } } if(j + 3 < 6) { j++; } else { j = 0; i++; } if(sum > max || n == 0) { max = sum; sum = 0; } else { sum = 0; } n++; } printf("%i\n", max); return max; }
Return errorlevel with macro EXIT_SUCCESS.
#include <stdio.h> #include <stdlib.h> #include <string.h> /* * ʾǺ궨ʱõһּ * 1) ĺһǸ * 2) ΪͨԺǿ׳Ҫ󣬲ܶԺʹ÷κμ */ #define PRINT_GREETINGS do { \ printf("Hi there!\n"); \ } while (0) int main(const int argc, const char* const* argv) { // Invoke function via macro PRINT_GREETINGS; return 0; }
#include <stdio.h> #include <stdlib.h> #include <string.h> /* * ʾǺ궨ʱõһּ * 1) ĺһǸ * 2) ΪͨԺǿ׳Ҫ󣬲ܶԺʹ÷κμ */ #define PRINT_GREETINGS do { \ printf("Hi there!\n"); \ } while (0) int main(const int argc, const char* const* argv) { // Invoke function via macro PRINT_GREETINGS; return EXIT_SUCCESS; }
Make it work under MPW too.
/* * macsetfiletype - Set the mac's idea of file type * */ #include <Files.h> #include <pascal.h> int setfiletype(name, creator, type) char *name; long creator, type; { FInfo info; unsigned char *pname; pname = c2pstr(name); if ( GetFInfo(pname, 0, &info) < 0 ) return -1; info.fdType = type; info.fdCreator = creator; return SetFInfo(pname, 0, &info); }
/* * macsetfiletype - Set the mac's idea of file type * */ #include "macdefs.h" int setfiletype(name, creator, type) char *name; long creator, type; { FInfo info; unsigned char *pname; pname = (StringPtr) c2pstr(name); if ( GetFInfo(pname, 0, &info) < 0 ) return -1; info.fdType = type; info.fdCreator = creator; return SetFInfo(pname, 0, &info); }
Fix copy_from_user_nmi() return if range is not ok
/* * User address space access functions. * * For licencing details see kernel-base/COPYING */ #include <linux/highmem.h> #include <linux/module.h> #include <asm/word-at-a-time.h> #include <linux/sched.h> /* * We rely on the nested NMI work to allow atomic faults from the NMI path; the * nested NMI paths are careful to preserve CR2. */ unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n) { unsigned long ret; if (__range_not_ok(from, n, TASK_SIZE)) return 0; /* * Even though this function is typically called from NMI/IRQ context * disable pagefaults so that its behaviour is consistent even when * called form other contexts. */ pagefault_disable(); ret = __copy_from_user_inatomic(to, from, n); pagefault_enable(); return ret; } EXPORT_SYMBOL_GPL(copy_from_user_nmi);
/* * User address space access functions. * * For licencing details see kernel-base/COPYING */ #include <linux/highmem.h> #include <linux/module.h> #include <asm/word-at-a-time.h> #include <linux/sched.h> /* * We rely on the nested NMI work to allow atomic faults from the NMI path; the * nested NMI paths are careful to preserve CR2. */ unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n) { unsigned long ret; if (__range_not_ok(from, n, TASK_SIZE)) return n; /* * Even though this function is typically called from NMI/IRQ context * disable pagefaults so that its behaviour is consistent even when * called form other contexts. */ pagefault_disable(); ret = __copy_from_user_inatomic(to, from, n); pagefault_enable(); return ret; } EXPORT_SYMBOL_GPL(copy_from_user_nmi);
Declare bswap functions as static inline
/* * * Copyright 2017 Asylo authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_ #define ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_ #include <stdint.h> #ifdef __cplusplus extern "C" { #endif inline uint16_t bswap_16(uint16_t n) { return __builtin_bswap16(n); } inline uint32_t bswap_32(uint32_t n) { return __builtin_bswap32(n); } inline uint64_t bswap_64(uint64_t n) { return __builtin_bswap64(n); } #ifdef __cplusplus } #endif #endif // ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_
/* * * Copyright 2017 Asylo authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_ #define ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_ #include <stdint.h> #ifdef __cplusplus extern "C" { #endif static inline uint16_t bswap_16(uint16_t n) { return __builtin_bswap16(n); } static inline uint32_t bswap_32(uint32_t n) { return __builtin_bswap32(n); } static inline uint64_t bswap_64(uint64_t n) { return __builtin_bswap64(n); } #ifdef __cplusplus } #endif #endif // ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_
Remove the unused bidir functions from path tracer
#ifndef PATH_INTEGRATOR_H #define PATH_INTEGRATOR_H #include "surface_integrator.h" #include "renderer/renderer.h" /* * Surface integrator that uses Path tracing for computing illumination at a point on the surface */ class PathIntegrator : public SurfaceIntegrator { const int min_depth, max_depth; public: /* * Create the path tracing integrator and set the min and max depth for paths * rays are randomly stopped by Russian roulette after reaching min_depth and are stopped * at max_depth */ PathIntegrator(int min_depth, int max_depth); /* * Compute the illumination at a point on a surface in the scene */ Colorf illumination(const Scene &scene, const Renderer &renderer, const RayDifferential &ray, DifferentialGeometry &dg, Sampler &sampler, MemoryPool &pool) const override; private: /* * Trace a camera path starting from the first hit at dg returning the throughput of the * path and the BSDF of the last object hit and the direction we hit it from so that we * can connect the path to a light path */ Colorf trace_camera(const Scene &scene, const Renderer &renderer, const RayDifferential &ray, DifferentialGeometry &dg, Sampler &sampler, MemoryPool &pool, BSDF *&bsdf, Vector &w_o) const; /* * Trace a light path returning the illumination along the path and the BSDF of * of the last object hit and the direction we hit it from so that we */ Colorf trace_light(const Scene &scene, const Renderer &renderer, Sampler &sampler, MemoryPool &pool, BSDF *&bsdf, Vector &w_o) const; }; #endif
#ifndef PATH_INTEGRATOR_H #define PATH_INTEGRATOR_H #include "surface_integrator.h" #include "renderer/renderer.h" /* * Surface integrator that uses Path tracing for computing illumination at a point on the surface */ class PathIntegrator : public SurfaceIntegrator { const int min_depth, max_depth; public: /* * Create the path tracing integrator and set the min and max depth for paths * rays are randomly stopped by Russian roulette after reaching min_depth and are stopped * at max_depth */ PathIntegrator(int min_depth, int max_depth); /* * Compute the illumination at a point on a surface in the scene */ Colorf illumination(const Scene &scene, const Renderer &renderer, const RayDifferential &ray, DifferentialGeometry &dg, Sampler &sampler, MemoryPool &pool) const override; }; #endif
Fix solution to Exercise 1-2.
/* * A solution to Exercise 1-2 in The C Programming Language (Second Edition). * * 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 <stdio.h> #include <stdlib.h> int main(void) { puts("\\a produces an audible or visual alert: \a"); puts("\\f produces a formfeed: \f"); puts("\\r produces a carriage return: \rlololol"); puts("\\v produces a vertical tab: \t"); return EXIT_SUCCESS; }
/* * A solution to Exercise 1-2 in The C Programming Language (Second Edition). * * 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 <stdio.h> #include <stdlib.h> int main(void) { puts("An audible or visual alert: \a"); puts("A form feed: \f"); puts("A carriage return: \r"); puts("A vertical tab: \v"); return EXIT_SUCCESS; }
Fix the buxton_debug macro to support arguments
/* * This file is part of buxton. * * Copyright (C) 2013 Intel Corporation * * buxton 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. */ #pragma once #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef DEBUG #define buxton_debug() buxton_log() #else #define buxton_debug do {} while(0); #endif /* DEBUG */ void buxton_log(const char* fmt, ...); /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * * Local variables: * c-basic-offset: 8 * tab-width: 8 * indent-tabs-mode: t * End: * * vi: set shiftwidth=8 tabstop=8 noexpandtab: * :indentSize=8:tabSize=8:noTabs=false: */
/* * This file is part of buxton. * * Copyright (C) 2013 Intel Corporation * * buxton 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. */ #pragma once #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef DEBUG #define buxton_debug(...) buxton_log(__VA_ARGS__) #else #define buxton_debug(...) do {} while(0); #endif /* DEBUG */ void buxton_log(const char* fmt, ...); /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * * Local variables: * c-basic-offset: 8 * tab-width: 8 * indent-tabs-mode: t * End: * * vi: set shiftwidth=8 tabstop=8 noexpandtab: * :indentSize=8:tabSize=8:noTabs=false: */
Add car to system res
/* * system_res.h * * Author: Ben Lai, Ming Tsang, Peggy Lau * Copyright (c) 2014-2015 HKUST SmartCar Team * Refer to LICENSE for details */ namespace camera { struct SystemRes { }; }
/* * system_res.h * * Author: Ben Lai, Ming Tsang, Peggy Lau * Copyright (c) 2014-2015 HKUST SmartCar Team * Refer to LICENSE for details */ namespace camera { class Car; } namespace camera { struct SystemRes { Car *car; }; }
Update threshold for second window
#ifndef EVENT_DETECTION_H # define EVENT_DETECTION_H # include "scrappie_structures.h" typedef struct { size_t window_length1; size_t window_length2; float threshold1; float threshold2; float peak_height; } detector_param; static detector_param const event_detection_defaults = { .window_length1 = 3, .window_length2 = 6, .threshold1 = 1.4f, .threshold2 = 1.1f, .peak_height = 0.2f }; event_table detect_events(raw_table const rt, detector_param const edparam); #endif /* EVENT_DETECTION_H */
#ifndef EVENT_DETECTION_H # define EVENT_DETECTION_H # include "scrappie_structures.h" typedef struct { size_t window_length1; size_t window_length2; float threshold1; float threshold2; float peak_height; } detector_param; static detector_param const event_detection_defaults = { .window_length1 = 3, .window_length2 = 6, .threshold1 = 1.4f, .threshold2 = 9.0f, .peak_height = 0.2f }; event_table detect_events(raw_table const rt, detector_param const edparam); #endif /* EVENT_DETECTION_H */
Initialize FixedVector's member in its null constructor to eliminate a Wall warning.
#pragma once template <typename T, unsigned int N> struct FixedVector { T data[N]; __host__ __device__ FixedVector() { } __host__ __device__ FixedVector(T init) { for(unsigned int i = 0; i < N; i++) data[i] = init; } __host__ __device__ FixedVector operator+(const FixedVector& bs) const { FixedVector output; for(unsigned int i = 0; i < N; i++) output.data[i] = data[i] + bs.data[i]; return output; } __host__ __device__ bool operator<(const FixedVector& bs) const { for(unsigned int i = 0; i < N; i++) { if(data[i] < bs.data[i]) return true; else if(bs.data[i] < data[i]) return false; } return false; } __host__ __device__ bool operator==(const FixedVector& bs) const { for(unsigned int i = 0; i < N; i++) { if(!(data[i] == bs.data[i])) return false; } return true; } };
#pragma once template <typename T, unsigned int N> struct FixedVector { T data[N]; __host__ __device__ FixedVector() : data() { } __host__ __device__ FixedVector(T init) { for(unsigned int i = 0; i < N; i++) data[i] = init; } __host__ __device__ FixedVector operator+(const FixedVector& bs) const { FixedVector output; for(unsigned int i = 0; i < N; i++) output.data[i] = data[i] + bs.data[i]; return output; } __host__ __device__ bool operator<(const FixedVector& bs) const { for(unsigned int i = 0; i < N; i++) { if(data[i] < bs.data[i]) return true; else if(bs.data[i] < data[i]) return false; } return false; } __host__ __device__ bool operator==(const FixedVector& bs) const { for(unsigned int i = 0; i < N; i++) { if(!(data[i] == bs.data[i])) return false; } return true; } };
Return success rather than failure from shutdown() on FileDescriptor, since it is entirely immaterial.
#ifndef FILE_DESCRIPTOR_H #define FILE_DESCRIPTOR_H #include <io/channel.h> class FileDescriptor : public Channel { LogHandle log_; protected: int fd_; public: FileDescriptor(int); ~FileDescriptor(); virtual Action *close(EventCallback *); virtual Action *read(size_t, EventCallback *); virtual Action *write(Buffer *, EventCallback *); virtual bool shutdown(bool, bool) { return (false); } }; #endif /* !FILE_DESCRIPTOR_H */
#ifndef FILE_DESCRIPTOR_H #define FILE_DESCRIPTOR_H #include <io/channel.h> class FileDescriptor : public Channel { LogHandle log_; protected: int fd_; public: FileDescriptor(int); ~FileDescriptor(); virtual Action *close(EventCallback *); virtual Action *read(size_t, EventCallback *); virtual Action *write(Buffer *, EventCallback *); virtual bool shutdown(bool, bool) { return (true); } }; #endif /* !FILE_DESCRIPTOR_H */
Fix typo in r375186. Unbreaks tests.
// RUN: %clang_analyze_cc1 -analyzer-checker=core \ // RUN: -analyzer-dump-egraph=%t.dot %s // RUN: cat %t.dot | FileCheck %s // RUN: %clang_analyze_cc1 -analyzer-checker=core \ // RUN: -analyzer-dump-egraph=%t.dot \ // RUN: -trim-egraph %s // RUN: cat %t.dot | FileCheck %s // REQUIRES: asserts int getJ(); int foo() { int *x = 0, *y = 0; char c = '\x13'; return *x + *y; } // CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null, \"node_id\": 1, \"is_sink\":0, \"has_report\": 0 \}\l&nbsp;&nbsp;],\l&nbsp;&nbsp;\"program_state\": null // CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"BlockEntrance\", \"block_id\": 1 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, \"file\": \"{{(.+)}}dump_egraph.c\" \} // CHECK: \"pretty\": \"'\\\\x13'\" // CHECK: \"has_report\": 1
// RUN: %clang_analyze_cc1 -analyzer-checker=core \ // RUN: -analyzer-dump-egraph=%t.dot %s // RUN: cat %t.dot | FileCheck %s // RUN: %clang_analyze_cc1 -analyzer-checker=core \ // RUN: -analyzer-dump-egraph=%t.dot \ // RUN: -trim-egraph %s // RUN: cat %t.dot | FileCheck %s // REQUIRES: asserts int getJ(); int foo() { int *x = 0, *y = 0; char c = '\x13'; return *x + *y; } // CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 \}\l&nbsp;&nbsp;],\l&nbsp;&nbsp;\"program_state\": null // CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"BlockEntrance\", \"block_id\": 1 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, \"file\": \"{{(.+)}}dump_egraph.c\" \} // CHECK: \"pretty\": \"'\\\\x13'\" // CHECK: \"has_report\": 1
Use __func__ instead of __FUNCTION__
#ifndef LOG_TESTFW_H #define LOG_TESTFW_H #include <stdio.h> #define NEUTRAL "\x1B[0m" #define GREEN "\x1B[32m" #define RED "\x1B[31m" void testfw_add(void (*)(int*), const char*); int testfw_run(); #define TEST(name) void name(int*); void __attribute__((constructor)) pre_##name() {testfw_add(name, #name);} void name(int* __errors __attribute__((unused))) #define FAILED(name) fprintf(stderr, "[ %sFAILED%s ] %s (%s:%d)\n", RED, NEUTRAL, name, __FILE__, __LINE__) #define PASSED(name) printf("[ %sPASSED%s ] %s\n", GREEN, NEUTRAL, name); #define ASSERT(stmt) if (!(stmt)) {++(*__errors); FAILED(__FUNCTION__);} #endif
#ifndef LOG_TESTFW_H #define LOG_TESTFW_H #include <stdio.h> #define NEUTRAL "\x1B[0m" #define GREEN "\x1B[32m" #define RED "\x1B[31m" void testfw_add(void (*)(int*), const char*); int testfw_run(); #define TEST(name) void name(int*); void __attribute__((constructor)) pre_##name() {testfw_add(name, #name);} void name(int* __errors __attribute__((unused))) #define FAILED(name) fprintf(stderr, "[ %sFAILED%s ] %s (%s:%d)\n", RED, NEUTRAL, name, __FILE__, __LINE__) #define PASSED(name) printf("[ %sPASSED%s ] %s\n", GREEN, NEUTRAL, name); #define ASSERT(stmt) if (!(stmt)) {++(*__errors); FAILED(__func__);} #endif
Add test for hexadecimal numbers with upper and lower case
/* name: TEST062 description: Test for hexadecimal numbers in upper and lower case error: output: G2 I F "main { \ h #I1 } */ int main(void) { return 0xa == 0xA && 0xb == 0xB && 0xc == 0xC && 0xd == 0xD && 0xe == 0xE && 0xf == 0xF; }
Enable slice support in config.
// This file contains default configuration settings for MicroPython. // You can override any of these options using mpconfigport.h file located // in a directory of your port. #include <mpconfigport.h> #ifndef INT_FMT // printf format spec to use for machine_int_t and friends #ifdef __LP64__ // Archs where machine_int_t == long, long != int #define UINT_FMT "%lu" #define INT_FMT "%ld" #else // Archs where machine_int_t == int #define UINT_FMT "%u" #define INT_FMT "%d" #endif #endif //INT_FMT // Any options not explicitly set in mpconfigport.h will get default // values below. // Whether to collect memory allocation stats #ifndef MICROPY_MEM_STATS #define MICROPY_MEM_STATS (1) #endif
// This file contains default configuration settings for MicroPython. // You can override any of these options using mpconfigport.h file located // in a directory of your port. #include <mpconfigport.h> #ifndef INT_FMT // printf format spec to use for machine_int_t and friends #ifdef __LP64__ // Archs where machine_int_t == long, long != int #define UINT_FMT "%lu" #define INT_FMT "%ld" #else // Archs where machine_int_t == int #define UINT_FMT "%u" #define INT_FMT "%d" #endif #endif //INT_FMT // Any options not explicitly set in mpconfigport.h will get default // values below. // Whether to collect memory allocation stats #ifndef MICROPY_MEM_STATS #define MICROPY_MEM_STATS (1) #endif // Whether to support slice object and correspondingly // slice subscript operators #ifndef MICROPY_ENABLE_SLICE #define MICROPY_ENABLE_SLICE (1) #endif
Index schedule not the main struct
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <area51/hashmap.h> #include <area51/list.h> #include <area51/log.h> #include <libxml/xmlreader.h> #include <nre/reference.h> #include <nre/schedule.h> /* * Callback to add a schedule to the crs locations map */ static bool indexAll(void *k, void *v, void *c) { int *ridId = k; struct Schedule *sched = v; struct Schedules *s = c; Node *n = list_getHead(&sched->locations); while (list_isNode(n)) { struct SchedLoc *sl = (struct SchedLoc *) n; n = list_getNext(n); struct LocationRef *l = hashmapGet(s->ref->tiploc, &sl->tpl); if (l && l->crs > 0) hashmapAddList(s->crs, &l->crs, s); } return true; } /** * Index all schedules adding them to the crs hashmap so we have a list of entries for each station * @param s */ void indexSchedules(struct Schedules *s) { logconsole("Indexing %d schedules", hashmapSize(s->schedules)); // Run through each crs hashmapForEach(s->schedules, indexAll, s); }
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <area51/hashmap.h> #include <area51/list.h> #include <area51/log.h> #include <nre/reference.h> #include <nre/schedule.h> /* * Callback to add a schedule to the crs locations map */ static bool indexAll(void *k, void *v, void *c) { int *ridId = k; struct Schedule *sched = v; struct Schedules *s = c; Node *n = list_getHead(&sched->locations); while (list_isNode(n)) { struct SchedLoc *sl = (struct SchedLoc *) n; n = list_getNext(n); struct LocationRef *l = hashmapGet(s->ref->tiploc, &sl->tpl); if (l && l->crs > 0) hashmapAddList(s->crs, &l->crs, sched); } return true; } /** * Index all schedules adding them to the crs hashmap so we have a list of entries for each station * @param s */ void indexSchedules(struct Schedules *s) { logconsole("Indexing %d schedules", hashmapSize(s->schedules)); // Run through each crs hashmapForEach(s->schedules, indexAll, s); }
Disable crange while fixing bugs in other systems.
#define TREE // A mapping of a chunk of an address space to // a specific memory object. enum vmatype { PRIVATE, COW}; struct vma { uptr va_start; // start of mapping uptr va_end; // one past the last byte enum vmatype va_type; struct vmnode *n; struct spinlock lock; // serialize fault/unmap char lockname[16]; }; // A memory object (physical pages or inode). enum vmntype { EAGER, ONDEMAND}; struct vmnode { u64 npages; char *page[128]; u64 ref; enum vmntype type; struct inode *ip; u64 offset; u64 sz; }; // An address space: a set of vmas plus h/w page table. // The elements of e[] are not ordered by address. struct vmap { #ifdef TREE // struct node* root; struct crange* cr; #else struct vma* e[16]; #endif struct spinlock lock; // serialize map/lookup/unmap u64 ref; u64 alloc; pml4e_t *pml4; // Page table char lockname[16]; };
//#define TREE // A mapping of a chunk of an address space to // a specific memory object. enum vmatype { PRIVATE, COW}; struct vma { uptr va_start; // start of mapping uptr va_end; // one past the last byte enum vmatype va_type; struct vmnode *n; struct spinlock lock; // serialize fault/unmap char lockname[16]; }; // A memory object (physical pages or inode). enum vmntype { EAGER, ONDEMAND}; struct vmnode { u64 npages; char *page[128]; u64 ref; enum vmntype type; struct inode *ip; u64 offset; u64 sz; }; // An address space: a set of vmas plus h/w page table. // The elements of e[] are not ordered by address. struct vmap { #ifdef TREE // struct node* root; struct crange* cr; #else struct vma* e[16]; #endif struct spinlock lock; // serialize map/lookup/unmap u64 ref; u64 alloc; pml4e_t *pml4; // Page table char lockname[16]; };
Revert "client version to 1.0.1"
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 0 #define CLIENT_VERSION_REVISION 1 #define CLIENT_VERSION_BUILD 0 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
#ifndef CLIENTVERSION_H #define CLIENTVERSION_H // // client versioning // // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 0 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H
Add macro to know if "real" is double.
#pragma once #include <stdint.h> #include <climits> //#define TYPE_DOUBLE #ifdef TYPE_DOUBLE using real = double; #else using real = float; #endif
#pragma once #include <stdint.h> #include <climits> //#define TYPE_DOUBLE #ifdef TYPE_DOUBLE using real = double; #define AT_IS_TYPE_DOUBLE (true) #else using real = float; #define AT_IS_TYPE_DOUBLE (false) #endif
Revert to old pre-1.0 meta directory
/* * License: BSD-style license * Copyright: Radek Podgorny <radek@podgorny.cz>, * Bernd Schubert <bernd-schubert@gmx.de> */ #ifndef UNIONFS_H #define UNIONFS_H #define PATHLEN_MAX 1024 #define HIDETAG "_HIDDEN~" #define METANAME ".unionfs-fuse" #define METADIR (METANAME "/") // string concetanation! // fuse meta files, we might want to hide those #define FUSE_META_FILE ".fuse_hidden" #define FUSE_META_LENGTH 12 // file access protection mask #define S_PROT_MASK (S_ISUID| S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) typedef struct { char *path; int path_len; // strlen(path) int fd; // used to prevent accidental umounts of path unsigned char rw; // the writable flag } branch_entry_t; #endif
/* * License: BSD-style license * Copyright: Radek Podgorny <radek@podgorny.cz>, * Bernd Schubert <bernd-schubert@gmx.de> */ #ifndef UNIONFS_H #define UNIONFS_H #define PATHLEN_MAX 1024 #define HIDETAG "_HIDDEN~" #define METANAME ".unionfs" #define METADIR (METANAME "/") // string concetanation! // fuse meta files, we might want to hide those #define FUSE_META_FILE ".fuse_hidden" #define FUSE_META_LENGTH 12 // file access protection mask #define S_PROT_MASK (S_ISUID| S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) typedef struct { char *path; int path_len; // strlen(path) int fd; // used to prevent accidental umounts of path unsigned char rw; // the writable flag } branch_entry_t; #endif
Change version string to reflect the release of beta 2.
#ifndef HEADER_OPENSSLV_H #define HEADER_OPENSSLV_H /* Numeric release version identifier: * MMNNFFRBB: major minor fix final beta/patch * For example: * 0.9.3-dev 0x00903000 * 0.9.3beta1 0x00903001 * 0.9.3beta2-dev 0x00903002 * 0.9.3beta2 0x00903002 (same as ...beta2-dev) * 0.9.3 0x00903100 * 0.9.3a 0x00903101 * 0.9.4 0x00904100 * 1.2.3z 0x1020311a * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) */ #define OPENSSL_VERSION_NUMBER 0x00905002L #define OPENSSL_VERSION_TEXT "OpenSSL 0.9.5beta2-dev 24 Feb 2000" #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT #endif /* HEADER_OPENSSLV_H */
#ifndef HEADER_OPENSSLV_H #define HEADER_OPENSSLV_H /* Numeric release version identifier: * MMNNFFRBB: major minor fix final beta/patch * For example: * 0.9.3-dev 0x00903000 * 0.9.3beta1 0x00903001 * 0.9.3beta2-dev 0x00903002 * 0.9.3beta2 0x00903002 (same as ...beta2-dev) * 0.9.3 0x00903100 * 0.9.3a 0x00903101 * 0.9.4 0x00904100 * 1.2.3z 0x1020311a * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) */ #define OPENSSL_VERSION_NUMBER 0x00905002L #define OPENSSL_VERSION_TEXT "OpenSSL 0.9.5beta2 27 Feb 2000" #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT #endif /* HEADER_OPENSSLV_H */
Add code and data segments definitions.
#ifndef __BOOT_H__ #define __BOOT_H__ /* multiboot definitions */ #define MB_HEADER_MAGIC 0x1BADB002 #define MB_BOOT_MAGIC 0x2BADB002 #define MB_PAGE_ALIGN 0x00000001 #define MB_MEMORY_INFO 0x00000002 /* common boot definitions */ #define BOOT_TIME_STACK_SIZE 0x4000 #endif /*__BOOT_H__*/
#ifndef __BOOT_H__ #define __BOOT_H__ /* multiboot definitions */ #define MB_HEADER_MAGIC 0x1BADB002 #define MB_BOOT_MAGIC 0x2BADB002 #define MB_PAGE_ALIGN 0x00000001 #define MB_MEMORY_INFO 0x00000002 /* common boot definitions */ #define BOOT_TIME_STACK_SIZE 0x4000 #define BOOT_CS_ENTRY 1 #define BOOT_CS (BOOT_CS_ENTRY << 3) #define BOOT_DS_ENTRY 2 #define BOOT_DS (BOOT_DS_ENTRY << 3) #define PTE_INIT_ATTR 0x00000003 #define PDE_INIT_ATTR 0x00000003 #endif /*__BOOT_H__*/
Fix memory leak by making dtor virtual
/* * Unit tests for libkvkontakte. * Copyright (C) 2015 Alexander Potashev <aspotashev@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef VKTESTBASE_H #define VKTESTBASE_H #include <libkvkontakte/apppermissions.h> #include <QtCore/QObject> #include <QtCore/QVector> namespace Vkontakte { class VkApi; } class VkTestBase : public QObject { Q_OBJECT public: VkTestBase(); ~VkTestBase(); protected: void authenticate(Vkontakte::AppPermissions::Value permissions); QString accessToken() const; private: QString getSavedToken() const; Vkontakte::VkApi *m_vkapi; }; #endif // VKTESTBASE_H
/* * Unit tests for libkvkontakte. * Copyright (C) 2015 Alexander Potashev <aspotashev@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef VKTESTBASE_H #define VKTESTBASE_H #include <libkvkontakte/apppermissions.h> #include <QtCore/QObject> #include <QtCore/QVector> namespace Vkontakte { class VkApi; } class VkTestBase : public QObject { Q_OBJECT public: VkTestBase(); virtual ~VkTestBase(); protected: void authenticate(Vkontakte::AppPermissions::Value permissions); QString accessToken() const; private: QString getSavedToken() const; Vkontakte::VkApi *m_vkapi; }; #endif // VKTESTBASE_H
Remove padding from vertex buffers
#pragma once #include "pixelboost/graphics/device/bufferFormats.h" namespace pb { class GraphicsDevice; struct Vertex_P3 { float position[3]; float __padding; }; struct Vertex_P3_UV { float position[3]; float uv[2]; float __padding[3]; // for 32-byte alignment }; struct Vertex_P3_C4 { float position[3]; float color[4]; }; struct Vertex_P3_C4_UV { float position[3]; float uv[2]; float color[4]; float __padding[2]; // for 48-byte alignment }; struct Vertex_P3_N3_UV { float position[3]; float normal[3]; float uv[2]; }; struct Vertex_P3_N3_UV_BW { float position[3]; float normal[3]; float uv[2]; char bones[4]; float boneWeights[4]; }; class VertexBuffer { protected: VertexBuffer(GraphicsDevice* device, BufferFormat bufferFormat, VertexFormat vertexFormat, int maxSize); ~VertexBuffer(); public: BufferFormat GetBufferFormat(); VertexFormat GetVertexFormat(); int GetMaxSize(); int GetCurrentSize(); void* GetData(); void Lock(); void Unlock(int numElements=-1); private: GraphicsDevice* _Device; BufferFormat _BufferFormat; VertexFormat _VertexFormat; int _MaxSize; int _CurrentSize; void* _Data; int _Locked; friend class GraphicsDevice; }; }
#pragma once #include "pixelboost/graphics/device/bufferFormats.h" namespace pb { class GraphicsDevice; struct Vertex_P3 { float position[3]; }; struct Vertex_P3_UV { float position[3]; float uv[2]; }; struct Vertex_P3_C4 { float position[3]; float color[4]; }; struct Vertex_P3_C4_UV { float position[3]; float uv[2]; float color[4]; }; struct Vertex_P3_N3_UV { float position[3]; float normal[3]; float uv[2]; }; struct Vertex_P3_N3_UV_BW { float position[3]; float normal[3]; float uv[2]; char bones[4]; float boneWeights[4]; }; class VertexBuffer { protected: VertexBuffer(GraphicsDevice* device, BufferFormat bufferFormat, VertexFormat vertexFormat, int maxSize); ~VertexBuffer(); public: BufferFormat GetBufferFormat(); VertexFormat GetVertexFormat(); int GetMaxSize(); int GetCurrentSize(); void* GetData(); void Lock(); void Unlock(int numElements=-1); private: GraphicsDevice* _Device; BufferFormat _BufferFormat; VertexFormat _VertexFormat; int _MaxSize; int _CurrentSize; void* _Data; int _Locked; friend class GraphicsDevice; }; }
Change how CSS would be used
#include <chopsui.h> void say_hi_clicked(sui_t *button, sui_event_t *event) { sui_alert("Hello world!"); } void exit_clicked(sui_t *button, sui_event_t *event) { sui_exit(); } int main(int argc, char **argv) { init_sui(); sui_t *window = sui_load("window.sui"); sui_load_css("window.css"); sui_add_handler(window, exit_clicked); sui_add_handler(window, say_hi_clicked); sui_show(window); sui_run(); return 0; }
#include <chopsui.h> void say_hi_clicked(sui_t *button, sui_event_t *event) { sui_alert("Hello world!"); } void exit_clicked(sui_t *button, sui_event_t *event) { sui_exit(); } int main(int argc, char **argv) { init_sui(); sui_t *window = sui_load("window.sui"); sui_css_t *css = sui_load_css("window.css"); sui_add_handler(window, exit_clicked); sui_add_handler(window, say_hi_clicked); sui_style(window, css); sui_show(window); sui_run(); return 0; }
Fix undefined reference to "midisend" when using ALSA
#include <alsa/asoundlib.h> snd_seq_t *hdl; static snd_midi_event_t *mbuf; static int midiport; /* open */ int midiopen(void) { snd_midi_event_new(32, &mbuf); if (snd_seq_open(&hdl, "default", SND_SEQ_OPEN_OUTPUT, 0) != 0) { return 1; } else { snd_seq_set_client_name(hdl, "svmidi"); if ((midiport = snd_seq_create_simple_port(hdl, "svmidi", SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ, SND_SEQ_PORT_TYPE_APPLICATION)) < 0) { return 1; } return 0; } } /* send message */ void _midisend(unsigned char message[], size_t count) { snd_seq_event_t ev; snd_midi_event_encode(mbuf, message, count, &ev); snd_seq_ev_set_subs(&ev); snd_seq_ev_set_direct(&ev); snd_seq_ev_set_source(&ev, midiport); snd_seq_event_output_direct(hdl, &ev); } /* close */ void midiclose(void) { snd_midi_event_free(mbuf); snd_seq_close(hdl); }
#include <alsa/asoundlib.h> snd_seq_t *hdl; static snd_midi_event_t *mbuf; static int midiport; /* open */ int midiopen(void) { snd_midi_event_new(32, &mbuf); if (snd_seq_open(&hdl, "default", SND_SEQ_OPEN_OUTPUT, 0) != 0) { return 1; } else { snd_seq_set_client_name(hdl, "svmidi"); if ((midiport = snd_seq_create_simple_port(hdl, "svmidi", SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ, SND_SEQ_PORT_TYPE_APPLICATION)) < 0) { return 1; } return 0; } } /* send message */ void midisend(unsigned char message[], size_t count) { snd_seq_event_t ev; snd_midi_event_encode(mbuf, message, count, &ev); snd_seq_ev_set_subs(&ev); snd_seq_ev_set_direct(&ev); snd_seq_ev_set_source(&ev, midiport); snd_seq_event_output_direct(hdl, &ev); } /* close */ void midiclose(void) { snd_midi_event_free(mbuf); snd_seq_close(hdl); }
Add scroll layer click config override helpers
#pragma once #include <pebble.h> #include "simply/simply.h" static inline ClickConfigProvider scroll_layer_click_config_provider_accessor(ClickConfigProvider provider) { static ClickConfigProvider s_provider; if (provider) { s_provider = provider; } return s_provider; } static inline void scroll_layer_click_config(void *context) { window_set_click_context(BUTTON_ID_UP, context); window_set_click_context(BUTTON_ID_DOWN, context); scroll_layer_click_config_provider_accessor(NULL)(context); } static inline void scroll_layer_set_click_config_provider_onto_window(ScrollLayer *scroll_layer, ClickConfigProvider click_config_provider, Window *window, void *context) { scroll_layer_set_click_config_onto_window(scroll_layer, window); scroll_layer_click_config_provider_accessor(window_get_click_config_provider(window)); window_set_click_config_provider_with_context(window, click_config_provider, context); }
Use an unordered map to track clients.
#ifndef VAST_QUERY_SEARCH_H #define VAST_QUERY_SEARCH_H #include <unordered_map> #include <cppa/cppa.hpp> #include <ze/event.h> #include <vast/query/query.h> namespace vast { namespace query { class search : public cppa::sb_actor<search> { friend class cppa::sb_actor<search>; public: search(cppa::actor_ptr archive, cppa::actor_ptr index); private: std::vector<cppa::actor_ptr> queries_; std::multimap<cppa::actor_ptr, cppa::actor_ptr> clients_; cppa::actor_ptr archive_; cppa::actor_ptr index_; cppa::behavior init_state; }; } // namespace query } // namespace vast #endif
#ifndef VAST_QUERY_SEARCH_H #define VAST_QUERY_SEARCH_H #include <unordered_map> #include <cppa/cppa.hpp> #include <ze/event.h> #include <vast/query/query.h> namespace vast { namespace query { class search : public cppa::sb_actor<search> { friend class cppa::sb_actor<search>; public: search(cppa::actor_ptr archive, cppa::actor_ptr index); private: std::vector<cppa::actor_ptr> queries_; std::unordered_multimap<cppa::actor_ptr, cppa::actor_ptr> clients_; cppa::actor_ptr archive_; cppa::actor_ptr index_; cppa::behavior init_state; }; } // namespace query } // namespace vast #endif
Fix Uninitialized Value compiler warning in the scoped_timer
/* * Copyright 2011-2013 Blender Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __UTIL_TIME_H__ #define __UTIL_TIME_H__ CCL_NAMESPACE_BEGIN /* Give current time in seconds in double precision, with good accuracy. */ double time_dt(); /* Sleep for the specified number of seconds */ void time_sleep(double t); class scoped_timer { public: scoped_timer(double *value) : value_(value) { if(value_ != NULL) { time_start_ = time_dt(); } } ~scoped_timer() { if(value_ != NULL) { *value_ = time_dt() - time_start_; } } protected: double *value_; double time_start_; }; CCL_NAMESPACE_END #endif
/* * Copyright 2011-2013 Blender Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __UTIL_TIME_H__ #define __UTIL_TIME_H__ CCL_NAMESPACE_BEGIN /* Give current time in seconds in double precision, with good accuracy. */ double time_dt(); /* Sleep for the specified number of seconds */ void time_sleep(double t); class scoped_timer { public: scoped_timer(double *value) : value_(value) { time_start_ = time_dt(); } ~scoped_timer() { if(value_ != NULL) { *value_ = time_dt() - time_start_; } } protected: double *value_; double time_start_; }; CCL_NAMESPACE_END #endif
Change visibility of the destructor to public.
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef TESTING_PLATFORM_TEST_H_ #define TESTING_PLATFORM_TEST_H_ #include <gtest/gtest.h> #if defined(GTEST_OS_MAC) #ifdef __OBJC__ @class NSAutoreleasePool; #else class NSAutoreleasePool; #endif // The purpose of this class us to provide a hook for platform-specific // operations across unit tests. For example, on the Mac, it creates and // releases an outer NSAutoreleasePool for each test case. For now, it's only // implemented on the Mac. To enable this for another platform, just adjust // the #ifdefs and add a platform_test_<platform>.cc implementation file. class PlatformTest : public testing::Test { protected: PlatformTest(); virtual ~PlatformTest(); private: NSAutoreleasePool* pool_; }; #else typedef testing::Test PlatformTest; #endif // GTEST_OS_MAC #endif // TESTING_PLATFORM_TEST_H_
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef TESTING_PLATFORM_TEST_H_ #define TESTING_PLATFORM_TEST_H_ #include <gtest/gtest.h> #if defined(GTEST_OS_MAC) #ifdef __OBJC__ @class NSAutoreleasePool; #else class NSAutoreleasePool; #endif // The purpose of this class us to provide a hook for platform-specific // operations across unit tests. For example, on the Mac, it creates and // releases an outer NSAutoreleasePool for each test case. For now, it's only // implemented on the Mac. To enable this for another platform, just adjust // the #ifdefs and add a platform_test_<platform>.cc implementation file. class PlatformTest : public testing::Test { public: virtual ~PlatformTest(); protected: PlatformTest(); private: NSAutoreleasePool* pool_; }; #else typedef testing::Test PlatformTest; #endif // GTEST_OS_MAC #endif // TESTING_PLATFORM_TEST_H_
Fix Epiphany GCC 5 link error
#include <stdint.h> #define SKIP 77 struct status { uint32_t done; uint32_t _pad1; uint32_t returncode; uint32_t _pad2; } __attribute__((packed)); volatile struct status *epiphany_status = (struct status *) 0x8f200000; volatile char *epiphany_results = (char *) 0x8f300000; int main(int argc, char *argv[]) { epiphany_status->returncode = SKIP; epiphany_status->done = 1; return SKIP; }
#include <stdint.h> #define SKIP 77 struct status { uint32_t done; uint32_t _pad1; uint32_t returncode; uint32_t _pad2; } __attribute__((packed)); volatile struct status *epiphany_status = (struct status *) 0x8f200000; volatile char *epiphany_results = (char *) 0x8f300000; /* HACK: Provide symbol to work around GCC 5 link error for * math/check_p_{max,min} */ float *ai; int main(int argc, char *argv[]) { epiphany_status->returncode = SKIP; epiphany_status->done = 1; return SKIP; }
Add a test case for r185707/PR16547.
// RUN: rm -fR %T/dir // RUN: mkdir %T/dir // RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T/dir %s // Currently this test mainly checks that the HTML diagnostics doesn't crash // when handling macros will calls with macros. We should actually validate // the output, but that requires being able to match against a specifically // generate HTML file. #define DEREF(p) *p = 0xDEADBEEF void has_bug(int *p) { DEREF(p); } #define CALL_HAS_BUG(q) has_bug(q) void test_call_macro() { CALL_HAS_BUG(0); }
// RUN: rm -fR %T/dir // RUN: mkdir %T/dir // RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T/dir %s // RUN: ls %T/dir | grep report // PR16547: Test relative paths // RUN: cd %T/dir // RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o testrelative %s // RUN: ls %T/dir/testrelative | grep report // REQUIRES: shell // Currently this test mainly checks that the HTML diagnostics doesn't crash // when handling macros will calls with macros. We should actually validate // the output, but that requires being able to match against a specifically // generate HTML file. #define DEREF(p) *p = 0xDEADBEEF void has_bug(int *p) { DEREF(p); } #define CALL_HAS_BUG(q) has_bug(q) void test_call_macro() { CALL_HAS_BUG(0); }
Allow suppression of "deprecated header" warning
/*------------------------------------------------------------------------- * * FILE * pqxx/util.h * * DESCRIPTION * Various utility definitions for libpqxx * * Copyright (c) 2001-2004, Jeroen T. Vermeulen <jtv@xs4all.nl> * * See COPYING for copyright license. If you did not receive a file called * COPYING with this source code, please notify the distributor of this mistake, * or contact the author. * *------------------------------------------------------------------------- */ #ifndef PQXX_UTIL_H #define PQXX_UTIL_H #if defined(PQXX_HAVE_CPP_WARNING) #warning "Deprecated libpqxx header included. Use headers without '.h'" #elif defined(PQXX_HAVE_CPP_PRAGMA_MESSAGE) #pragma message("Deprecated libpqxx header included. Use headers without '.h'") #endif #define PQXX_DEPRECATED_HEADERS #include "pqxx/util" #endif
/*------------------------------------------------------------------------- * * FILE * pqxx/util.h * * DESCRIPTION * Various utility definitions for libpqxx * * Copyright (c) 2001-2004, Jeroen T. Vermeulen <jtv@xs4all.nl> * * See COPYING for copyright license. If you did not receive a file called * COPYING with this source code, please notify the distributor of this mistake, * or contact the author. * *------------------------------------------------------------------------- */ #ifndef PQXX_UTIL_H #define PQXX_UTIL_H #if !defined(PQXXYES_I_KNOW_DEPRECATED_HEADER) #define PQXXYES_I_KNOW_DEPRECATED_HEADER #if defined(PQXX_HAVE_CPP_WARNING) #warning "Deprecated libpqxx header included. Use headers without '.h'" #elif defined(PQXX_HAVE_CPP_PRAGMA_MESSAGE) #pragma message("Deprecated libpqxx header included. Use headers without '.h'") #endif #endif #define PQXX_DEPRECATED_HEADERS #include "pqxx/util" #endif
Add lo_keyboard_did_hide() and improve comment
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright 2013 LibreOffice contributors. * * 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/. */ #ifndef INCLUDED_TOUCH_TOUCH_H #define INCLUDED_TOUCH_TOUCH_H #include <config_features.h> #if !HAVE_FEATURE_DESKTOP // Functions to be implemented by the upper/medium layers on // non-desktop touch-based platforms, with the same API on each such // platform. Note that these are just declared here in this header in // the "touch" module, the per-platform implementations are elsewhere. #ifdef __cplusplus extern "C" { #endif void lo_show_keyboard(); void lo_hide_keyboard(); #ifdef __cplusplus } #endif #endif // HAVE_FEATURE_DESKTOP #endif // INCLUDED_TOUCH_TOUCH_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright 2013 LibreOffice contributors. * * 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/. */ #ifndef INCLUDED_TOUCH_TOUCH_H #define INCLUDED_TOUCH_TOUCH_H #include <config_features.h> #if !HAVE_FEATURE_DESKTOP // Functions to be implemented by the app-specifc upper or less // app-specific but platform-specific medium layer on touch-based // platforms. The same API is used on each such platform. There are // called from low level LibreOffice code. Note that these are just // declared here in this header in the "touch" module, the // per-platform implementations are elsewhere. #ifdef __cplusplus extern "C" { #endif void lo_show_keyboard(); void lo_hide_keyboard(); // Functions to be implemented in the medium platform-specific layer // to be called from the app-specific UI layer. void lo_keyboard_did_hide(); #ifdef __cplusplus } #endif #endif // HAVE_FEATURE_DESKTOP #endif // INCLUDED_TOUCH_TOUCH_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Change of the default msg
#include <stdlib.h> #include <stdio.h> #include "logging.h" int log_fail(char* msg) { perror(msg); // TODO fix log to file return 0; } int log_success(char* msg) { printf("%s\n", msg); return 0; }
#include <stdlib.h> #include <stdio.h> #include "logging.h" int log_fail(char* msg) { perror(msg); // TODO fix log to file return 0; } int log_success(char* msg) { printf("SUCCESS: %s\n", msg); return 0; }
Increase max length of a network message to support larger records
#pragma once #define NETWORK_MAX_MESSAGE_LENGTH 65535 #include <sys/types.h> namespace pb { class NetworkMessage { public: NetworkMessage(); NetworkMessage(const NetworkMessage& src); ~NetworkMessage(); bool ReadChar(char& value); bool ReadByte(__uint8_t& value); bool ReadInt(__int32_t& value); bool ReadFloat(float& value); bool ReadString(const char*& value); bool WriteChar(char value); bool WriteByte(__uint8_t value); bool WriteInt(__int32_t value); bool WriteFloat(float value); bool WriteString(const char* value); bool SetData(__int32_t length, char* data); void SetProtocol(__uint32_t protocol); __uint32_t GetProtocol(); int GetDataLength(); int GetMessageLength(); int ConstructMessage(char* buffer, __int32_t maxLength); private: bool HasRemaining(__int32_t length); __uint32_t _Protocol; char* _Buffer; int _Offset; __int32_t _Length; }; }
#pragma once #define NETWORK_MAX_MESSAGE_LENGTH 262140 #include <sys/types.h> namespace pb { class NetworkMessage { public: NetworkMessage(); NetworkMessage(const NetworkMessage& src); ~NetworkMessage(); bool ReadChar(char& value); bool ReadByte(__uint8_t& value); bool ReadInt(__int32_t& value); bool ReadFloat(float& value); bool ReadString(const char*& value); bool WriteChar(char value); bool WriteByte(__uint8_t value); bool WriteInt(__int32_t value); bool WriteFloat(float value); bool WriteString(const char* value); bool SetData(__int32_t length, char* data); void SetProtocol(__uint32_t protocol); __uint32_t GetProtocol(); int GetDataLength(); int GetMessageLength(); int ConstructMessage(char* buffer, __int32_t maxLength); private: bool HasRemaining(__int32_t length); __uint32_t _Protocol; char* _Buffer; int _Offset; __int32_t _Length; }; }
Add list function declarations, node structure
// // lineart.h // LineArt // // Created by Allek Mott on 10/1/15. // Copyright © 2015 Loop404. All rights reserved. // #ifndef lineart_h #define lineart_h #include <stdio.h> #define MAX_LINE_LENGTH 200 // data structure for line // (x1, y1) = inital point // (x2, y2) = final point struct line { int x1; int y1; int x2; int y2; }; // data structure for point (x, y) struct point { int x; int y; }; // Generate displacement value for new line int genDifference(); // Easy line resetting/initialization void easyLine(struct line *l, int x1, int y1, int x2, int y2); // Calculates midpoint of line l, // stores in point p void getMidpoint(struct line *l, struct point *p); // Generate next line in sequence void genNextLine(struct line *previous, struct line *current, int lineNo); #endif /* lineart_h */
// // lineart.h // LineArt // // Created by Allek Mott on 10/1/15. // Copyright © 2015 Loop404. All rights reserved. // #ifndef lineart_h #define lineart_h #include <stdio.h> #define MAX_LINE_LENGTH 200 // data structure for line // (x1, y1) = inital point // (x2, y2) = final point struct line { int x1; int y1; int x2; int y2; }; // data structure for point (x, y) struct point { int x; int y; }; // data structure for node // in linked list of lines struct node { struct line *line; struct node *next; }; // Generate displacement value for new line int genDifference(); // Easy line resetting/initialization void easyLine(struct line *l, int x1, int y1, int x2, int y2); // Calculates midpoint of line l, // stores in point p void getMidpoint(struct line *l, struct point *p); // Generate next line in sequence void genNextLine(struct line *previous, struct line *current, int lineNo); void freeLineNode(struct node *node); void freeLineList(struct node *root); #endif /* lineart_h */
Remove pointless const from function declarations.
#ifndef CONSTBITS_H #define CONSTBITS_H #include "adt/obst.h" #include "tv.h" typedef struct bitinfo { ir_tarval* z; /* safe zeroes, 0 = bit is zero, 1 = bit maybe is 1 */ ir_tarval* o; /* safe ones, 0 = bit maybe is zero, 1 = bit is 1 */ } bitinfo; /* Get analysis information for node irn */ bitinfo* get_bitinfo(ir_node const* const irn); /* Set analysis information for node irn */ int set_bitinfo(ir_node* const irn, ir_tarval* const z, ir_tarval* const o); /* Compute value range fixpoint aka which bits of value are constant zero/one. * The result is available via links to bitinfo*, allocated on client_obst. */ void constbits_analyze(ir_graph* const irg, struct obstack *client_obst); /* Clears the bit information for the given graph. * * This does not affect the obstack passed to constbits_analyze. */ void constbits_clear(ir_graph* const irg); #endif
#ifndef CONSTBITS_H #define CONSTBITS_H #include "adt/obst.h" #include "tv.h" typedef struct bitinfo { ir_tarval* z; /* safe zeroes, 0 = bit is zero, 1 = bit maybe is 1 */ ir_tarval* o; /* safe ones, 0 = bit maybe is zero, 1 = bit is 1 */ } bitinfo; /* Get analysis information for node irn */ bitinfo* get_bitinfo(ir_node const* irn); /* Set analysis information for node irn */ int set_bitinfo(ir_node* irn, ir_tarval* z, ir_tarval* o); /* Compute value range fixpoint aka which bits of value are constant zero/one. * The result is available via links to bitinfo*, allocated on client_obst. */ void constbits_analyze(ir_graph* irg, struct obstack *client_obst); /* Clears the bit information for the given graph. * * This does not affect the obstack passed to constbits_analyze. */ void constbits_clear(ir_graph* irg); #endif
Remove DISABLE_WIDEVINE_CDM_CANPLAYTYPE as we should start using canPlayType now
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef WIDEVINE_CDM_VERSION_H_ #define WIDEVINE_CDM_VERSION_H_ #include "third_party/widevine/cdm/widevine_cdm_common.h" // Indicates that the Widevine CDM is available. #define WIDEVINE_CDM_AVAILABLE // TODO(ddorwin): Remove when we have CDM availability detection // (http://crbug.com/224793). #define DISABLE_WIDEVINE_CDM_CANPLAYTYPE // Indicates that ISO BMFF CENC support is available in the Widevine CDM. // Must be enabled if any of the codecs below are enabled. #define WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE // Indicates that AVC1 decoding is available for ISO BMFF CENC. #define WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE // Indicates that AAC decoding is available for ISO BMFF CENC. #define WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE #endif // WIDEVINE_CDM_VERSION_H_
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef WIDEVINE_CDM_VERSION_H_ #define WIDEVINE_CDM_VERSION_H_ #include "third_party/widevine/cdm/widevine_cdm_common.h" // Indicates that the Widevine CDM is available. #define WIDEVINE_CDM_AVAILABLE // Indicates that AVC1 decoding is available for ISO BMFF CENC. #define WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE // Indicates that AAC decoding is available for ISO BMFF CENC. #define WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE #endif // WIDEVINE_CDM_VERSION_H_
Fix block property type in NSCache.
// // NSCache+BlocksKit.h // %PROJECT // #import "BKGlobals.h" /** NSCache with block adding of objects This category allows you to conditionally add objects to an instance of NSCache using blocks. Both the normal delegation pattern and a block callback for NSCache's one delegate method are allowed. These methods emulate Rails caching behavior. Created by Igor Evsukov and contributed to BlocksKit. */ @interface NSCache (BlocksKit) /** Returns the value associated with a given key. If there is no object for that key, it uses the result of the block, saves that to the cache, and returns it. This mimics the cache behavior of Ruby on Rails. The following code: @products = Rails.cache.fetch('products') do Product.all end becomes: NSMutableArray *products = [cache objectForKey:@"products" withGetter:^id{ return [Product all]; }]; @return The value associated with *key*, or the object returned by the block if no value is associated with *key*. @param key An object identifying the value. @param getterBlock A block used to get an object if there is no value in the cache. */ - (id)objectForKey:(id)key withGetter:(BKReturnBlock)getterBlock; /** Called when an object is about to be evicted from the cache. This block callback is an analog for the cache:willEviceObject: method of NSCacheDelegate. */ @property (copy) BKSenderBlock willEvictBlock; @end
// // NSCache+BlocksKit.h // %PROJECT // #import "BKGlobals.h" /** NSCache with block adding of objects This category allows you to conditionally add objects to an instance of NSCache using blocks. Both the normal delegation pattern and a block callback for NSCache's one delegate method are allowed. These methods emulate Rails caching behavior. Created by Igor Evsukov and contributed to BlocksKit. */ @interface NSCache (BlocksKit) /** Returns the value associated with a given key. If there is no object for that key, it uses the result of the block, saves that to the cache, and returns it. This mimics the cache behavior of Ruby on Rails. The following code: @products = Rails.cache.fetch('products') do Product.all end becomes: NSMutableArray *products = [cache objectForKey:@"products" withGetter:^id{ return [Product all]; }]; @return The value associated with *key*, or the object returned by the block if no value is associated with *key*. @param key An object identifying the value. @param getterBlock A block used to get an object if there is no value in the cache. */ - (id)objectForKey:(id)key withGetter:(BKReturnBlock)getterBlock; /** Called when an object is about to be evicted from the cache. This block callback is an analog for the cache:willEviceObject: method of NSCacheDelegate. */ @property (copy) void(^willEvictBlock)(NSCache *, id); @end
Add missing header and fix build on FreeBSD
#ifndef NEWSBOAT_QUEUEMANAGER_H_ #define NEWSBOAT_QUEUEMANAGER_H_ #include <memory> #include <string> namespace newsboat { class ConfigContainer; class ConfigPaths; class RssFeed; class QueueManager { ConfigContainer* cfg = nullptr; ConfigPaths* paths = nullptr; public: QueueManager(ConfigContainer* cfg, ConfigPaths* paths); void enqueue_url(const std::string& url, const std::string& title, const time_t pubDate, std::shared_ptr<RssFeed> feed); void autoenqueue(std::shared_ptr<RssFeed> feed); private: std::string generate_enqueue_filename(const std::string& url, const std::string& title, const time_t pubDate, std::shared_ptr<RssFeed> feed); }; } #endif /* NEWSBOAT_QUEUEMANAGER_H_ */
#ifndef NEWSBOAT_QUEUEMANAGER_H_ #define NEWSBOAT_QUEUEMANAGER_H_ #include <ctime> #include <memory> #include <string> namespace newsboat { class ConfigContainer; class ConfigPaths; class RssFeed; class QueueManager { ConfigContainer* cfg = nullptr; ConfigPaths* paths = nullptr; public: QueueManager(ConfigContainer* cfg, ConfigPaths* paths); void enqueue_url(const std::string& url, const std::string& title, const time_t pubDate, std::shared_ptr<RssFeed> feed); void autoenqueue(std::shared_ptr<RssFeed> feed); private: std::string generate_enqueue_filename(const std::string& url, const std::string& title, const time_t pubDate, std::shared_ptr<RssFeed> feed); }; } #endif /* NEWSBOAT_QUEUEMANAGER_H_ */
Add a simple test program to read the GPIO signal.
#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "input.h" int main(int argc, char **argv) { unsigned long high, low, err; struct gpio_req req; int fd; int old; int res; struct hardware hw; res = read_hardware_parameters("hardware.txt", &hw); if (res) return res; fd = init_hardware(hw.pin); if (fd < 0) return fd; /* errno */ high = low = err = 0; old = 0; for (;;) { req.gp_pin = hw.pin; if (ioctl(fd, GPIOGET, &req) < 0) { perror("ioctl(GPIOGET)"); /* whoops */ exit(1); } if ((req.gp_value != old && old == 0) || (high + low > hw.freq)) { printf("%lu %lu %lu\n", err, high, low); high = low = 0; } if (req.gp_value == GPIO_PIN_HIGH) high++; else if (req.gp_value == GPIO_PIN_LOW) low++; else err++; /* Houston? */ old = req.gp_value; (void)usleep(1000000.0 / hw.freq); /* us */ } if (close(fd)) perror("close"); return 0; }
Update Skia milestone to 73
/* * 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 72 #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 73 #endif
Fix error message in version check
#ifdef __GNUC__ #if __clang__ #if __cplusplus >= 201103L && !__has_include(<initializer_list>) #warning "Your compiler supports C++11 but your C++ standard library does not. If your system has libc++ installed (as should be the case on e.g. Mac OSX), try adding -stdlib=libc++ to your CFLAGS (ignore the other warning that says to use CXXFLAGS)." #endif #endif #endif #include "capnp/dynamic.h" static_assert(CAPNP_VERSION >= 5000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.4 and then re-install this python library");
#ifdef __GNUC__ #if __clang__ #if __cplusplus >= 201103L && !__has_include(<initializer_list>) #warning "Your compiler supports C++11 but your C++ standard library does not. If your system has libc++ installed (as should be the case on e.g. Mac OSX), try adding -stdlib=libc++ to your CFLAGS (ignore the other warning that says to use CXXFLAGS)." #endif #endif #endif #include "capnp/dynamic.h" static_assert(CAPNP_VERSION >= 5000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.5 and then re-install this python library");
Remove arg{c,v} params for main() since they are unneeded
#include <stdio.h> #include <stdlib.h> #include <curl/curl.h> int main (int argc, char ** argv) { CURL * handle; CURLcode res; curl_global_init(CURL_GLOBAL_ALL); handle = curl_easy_init(); if ( handle ) { curl_easy_setopt(handle, CURLOPT_URL, "http://icanhazip.com"); curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1); res = curl_easy_perform(handle); if ( ! res == CURLE_OK ) { curl_easy_cleanup(handle); curl_global_cleanup(); fputs("Could not check IP address\n", stderr); exit(1); } } curl_easy_cleanup(handle); curl_global_cleanup(); return 0; } // vim: set tabstop=4 shiftwidth=4 expandtab
#include <stdio.h> #include <stdlib.h> #include <curl/curl.h> int main () { CURL * handle; CURLcode res; curl_global_init(CURL_GLOBAL_ALL); handle = curl_easy_init(); if ( handle ) { curl_easy_setopt(handle, CURLOPT_URL, "http://icanhazip.com"); curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1); res = curl_easy_perform(handle); if ( ! res == CURLE_OK ) { curl_easy_cleanup(handle); curl_global_cleanup(); fputs("Could not check IP address\n", stderr); exit(1); } } curl_easy_cleanup(handle); curl_global_cleanup(); return 0; } // vim: set tabstop=4 shiftwidth=4 expandtab