Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Solve The Greatest in c
#include <stdio.h> #include <stdlib.h> int main() { int a, b, c, m; while (scanf("%d %d %d", &a, &b, &c) != EOF) { m = (a + b + abs(a - b)) / 2; m = (m + c + abs(m - c)) / 2; printf("%d eh o maior\n", m); } }
Fix json additional fetch in frontpage
// // RAPRedditLinks.h // redditAPI // // Created by Woudini on 2/3/15. // Copyright (c) 2015 Hi Range. All rights reserved. // #ifndef redditAPI_RAPRedditLinks_h #define redditAPI_RAPRedditLinks_h #define RAPRedditLimit_10_typePrefix_Link_ @"?limit=10?&after=t3_%@" #define RAPSubredditNew @"r/%@/new.json?limit=10" #define RAPSubredditHot @"r/%@/hot.json?limit=10" #define RAPThreadComments @"r/%@/.json" #endif
// // RAPRedditLinks.h // redditAPI // // Created by Woudini on 2/3/15. // Copyright (c) 2015 Hi Range. All rights reserved. // #ifndef redditAPI_RAPRedditLinks_h #define redditAPI_RAPRedditLinks_h #define RAPRedditLimit_10_typePrefix_Link_ @".json?limit=10?&after=t3_%@" #define RAPSubredditNew @"r/%@/new.json?limit=10" #define RAPSubredditHot @"r/%@/hot.json?limit=10" #define RAPThreadComments @"r/%@/.json" #endif
Add list to contain hotkey info
#pragma once #include "afxwin.h" #include "afxcmn.h" class Hotkeys : public CPropertyPage { DECLARE_DYNAMIC(Hotkeys) public: Hotkeys(); virtual ~Hotkeys(); // Dialog Data enum { IDD = IDD_HOTKEYS }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); DECLARE_MESSAGE_MAP() private: void SelectItem(int idx); private: CComboBox _action; CButton _keys; CListCtrl _list; afx_msg void OnBnClickedAdd(); afx_msg void OnBnClickedRemove(); afx_msg void OnLvnItemchangedKeys(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void OnBnClickedKeys(); };
#pragma once #include "afxwin.h" #include "afxcmn.h" #include <vector> #include "HotkeyInfo.h" class Hotkeys : public CPropertyPage { DECLARE_DYNAMIC(Hotkeys) public: Hotkeys(); virtual ~Hotkeys(); enum { IDD = IDD_HOTKEYS }; protected: virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); DECLARE_MESSAGE_MAP() private: std::vector<HotkeyInfo> _keyInfo; void SelectItem(int idx); private: CComboBox _action; CButton _keys; CListCtrl _list; afx_msg void OnBnClickedAdd(); afx_msg void OnBnClickedRemove(); afx_msg void OnLvnItemchangedKeys(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void OnBnClickedKeys(); };
Add transaction main key definitions
/* * waysome - wayland based window manager * * Copyright in alphabetical order: * * Copyright (C) 2014-2015 Julian Ganz * Copyright (C) 2014-2015 Manuel Messner * Copyright (C) 2014-2015 Marcel Müller * Copyright (C) 2014-2015 Matthias Beyer * Copyright (C) 2014-2015 Nadja Sommerfeld * * This file is part of waysome. * * waysome 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. * * waysome is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with waysome. If not, see <http://www.gnu.org/licenses/>. */ /** * @addtogroup serializer_module "Serializer module" * * @{ */ /** * @addtogroup serializer_module_json_backend "Serializer JSON backend" * * @{ */ /** * @addtogroup serializer_module_json_backend_common "JSON backend utils" * * Serializer module JSON backend private utilities * * @{ */ /** * @file keys.h * * This file contains JSON object key definitions. Each define here is one key * in the JSON object the deserializer wants to parse. */ #ifndef __WS_SERIALIZE_JSON_KEYS_H__ #define __WS_SERIALIZE_JSON_KEYS_H__ #define COMMANDS "CMDS" #define UID "UID" #define TYPE "TYPE" #define TYPE_TRANSACTION "transaction" #endif //__WS_SERIALIZE_JSON_KEYS_H__ /** * @} */ /** * @} */ /** * @} */
Remove backwards compatible macro RTC_EXPORT from sdk/.
/* * Copyright 2016 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef SDK_OBJC_BASE_RTCMACROS_H_ #define SDK_OBJC_BASE_RTCMACROS_H_ #define RTC_OBJC_EXPORT __attribute__((visibility("default"))) // TODO(mbonadei): Remove RTC_EXPORT in order to be able to land // https://webrtc-review.googlesource.com/c/src/+/97960. #define RTC_EXPORT RTC_OBJC_EXPORT #if defined(__cplusplus) #define RTC_EXTERN extern "C" RTC_OBJC_EXPORT #else #define RTC_EXTERN extern RTC_OBJC_EXPORT #endif #ifdef __OBJC__ #define RTC_FWD_DECL_OBJC_CLASS(classname) @class classname #else #define RTC_FWD_DECL_OBJC_CLASS(classname) typedef struct objc_object classname #endif #endif // SDK_OBJC_BASE_RTCMACROS_H_
/* * Copyright 2016 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef SDK_OBJC_BASE_RTCMACROS_H_ #define SDK_OBJC_BASE_RTCMACROS_H_ #define RTC_OBJC_EXPORT __attribute__((visibility("default"))) #if defined(__cplusplus) #define RTC_EXTERN extern "C" RTC_OBJC_EXPORT #else #define RTC_EXTERN extern RTC_OBJC_EXPORT #endif #ifdef __OBJC__ #define RTC_FWD_DECL_OBJC_CLASS(classname) @class classname #else #define RTC_FWD_DECL_OBJC_CLASS(classname) typedef struct objc_object classname #endif #endif // SDK_OBJC_BASE_RTCMACROS_H_
Add ref counting to Git class
#include "include/cef_base.h" #include "include/cef_v8.h" namespace v8_extensions { class Git : public CefV8Handler { public: Git(); virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception) OVERRIDE; // Provide the reference counting implementation for this class. IMPLEMENT_REFCOUNTING(Native); }; }
#include "include/cef_base.h" #include "include/cef_v8.h" namespace v8_extensions { class Git : public CefV8Handler { public: Git(); virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception) OVERRIDE; // Provide the reference counting implementation for this class. IMPLEMENT_REFCOUNTING(Git); }; }
Use assert_int_equal not assert_true where possible
#include <stdlib.h> #include "seatest.h" static void test_abs (void) { // abs assert_true(abs(0) == 0); assert_true(abs(1) == 1); assert_true(abs(INT_MAX) == INT_MAX); assert_true(abs(-1) == 1); // labs assert_true(labs(0) == 0); assert_true(labs(1) == 1); assert_true(labs(LONG_MAX) == LONG_MAX); assert_true(labs(-1) == 1); // llabs assert_true(llabs(0) == 0); assert_true(llabs(1) == 1); assert_true(llabs(LLONG_MAX) == LLONG_MAX); assert_true(llabs(-1) == 1); } void test_stdlib (void) { test_fixture_start(); run_test(test_abs); test_fixture_end(); }
#include <stdlib.h> #include "seatest.h" static void test_abs (void) { // abs assert_int_equal(0, abs(0)); assert_int_equal(1, abs(1)); assert_int_equal(INT_MAX, abs(INT_MAX)); assert_int_equal(1, abs(-1)); // labs assert_true(labs(0) == 0); assert_true(labs(1) == 1); assert_true(labs(LONG_MAX) == LONG_MAX); assert_true(labs(-1) == 1); // llabs assert_true(llabs(0) == 0); assert_true(llabs(1) == 1); assert_true(llabs(LLONG_MAX) == LLONG_MAX); assert_true(llabs(-1) == 1); } void test_stdlib (void) { test_fixture_start(); run_test(test_abs); test_fixture_end(); }
Add a missing policy_export include
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_PROVIDER_ANDROID_DELEGATE_H_ #define COMPONENTS_POLICY_CORE_COMMON_POLICY_PROVIDER_ANDROID_DELEGATE_H_ #include "base/compiler_specific.h" namespace policy { // A delegate for the Android policy provider. This class is responsible for // setting policies on the PolicyProviderAndroid and refreshing them on demand. class POLICY_EXPORT PolicyProviderAndroidDelegate { public: // Called to refresh policies. If this method is called, the delegate must // eventually call SetPolicies on the provider. virtual void RefreshPolicies() = 0; // Called before the provider is destroyed. virtual void PolicyProviderShutdown() = 0; protected: virtual ~PolicyProviderAndroidDelegate() {} }; } // namespace policy #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_PROVIDER_ANDROID_DELEGATE_H_
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_PROVIDER_ANDROID_DELEGATE_H_ #define COMPONENTS_POLICY_CORE_COMMON_POLICY_PROVIDER_ANDROID_DELEGATE_H_ #include "base/compiler_specific.h" #include "components/policy/policy_export.h" namespace policy { // A delegate for the Android policy provider. This class is responsible for // setting policies on the PolicyProviderAndroid and refreshing them on demand. class POLICY_EXPORT PolicyProviderAndroidDelegate { public: // Called to refresh policies. If this method is called, the delegate must // eventually call SetPolicies on the provider. virtual void RefreshPolicies() = 0; // Called before the provider is destroyed. virtual void PolicyProviderShutdown() = 0; protected: virtual ~PolicyProviderAndroidDelegate() {} }; } // namespace policy #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_PROVIDER_ANDROID_DELEGATE_H_
Handle network traffic in main loop
/** * @file debug.h * @brief Initializer and main loop of EthShield * * \copyright Copyright 2013 /Dev. All rights reserved. * \license This project is released under MIT license. * * @author Ferdi van der Werf <efcm@slashdev.nl> * @since 0.1.0 */ // Speed of micro-controller (20.0 MHz) #ifndef F_CPU #define F_CPU 20000000 #endif #include <inttypes.h> #include <avr/interrupt.h> #include "net/network.h" #include "utils/logger.h" #include "utils/uptime.h" int main(void) { // Enable interrupts sei(); // Initialize debug logger_init(); // Initialize uptime uptime_init(); // Initialize network chip network_init(); // Infinite loop while (1) { } }
/** * @file debug.h * @brief Initializer and main loop of EthShield * * \copyright Copyright 2013 /Dev. All rights reserved. * \license This project is released under MIT license. * * @author Ferdi van der Werf <efcm@slashdev.nl> * @since 0.1.0 */ // Speed of micro-controller (20.0 MHz) #ifndef F_CPU #define F_CPU 20000000 #endif #include <inttypes.h> #include <avr/interrupt.h> #include "net/network.h" #include "utils/logger.h" #include "utils/uptime.h" int main(void) { // Enable interrupts sei(); // Initialize debug logger_init(); // Initialize uptime uptime_init(); // Initialize network chip network_init(); // Infinite loop while (1) { // Handle network traffic network_backbone(); } }
Refactor Problem 1's solution in C
#include <stdio.h> #define RANGE 1000 unsigned int count_divisibility(unsigned int divisor) { int count = 0; for ( int i = 1 ; i < RANGE ; i++ ) { if ( i % divisor == 0 ) { count++; } } return count; } // Use the identity n(n+1)/2 to calculate the sum unsigned int calculate_divisibility_sum(unsigned int number, unsigned int count) { unsigned int divisibility_sum = 0; divisibility_sum = number * (count * (count + 1)) / 2; return divisibility_sum; } int main() { unsigned short div_three_count = 0, div_five_count = 0, div_fifteen_count = 0; unsigned int div_three_sum, div_five_sum, div_fifteen_sum, total_sum; div_three_count = count_divisibility(3); div_five_count = count_divisibility(5); div_fifteen_count = count_divisibility(15); div_three_sum = calculate_divisibility_sum(3, div_three_count); div_five_sum = calculate_divisibility_sum(5, div_five_count); div_fifteen_sum = calculate_divisibility_sum(15, div_fifteen_count); total_sum = div_three_sum + div_five_sum - div_fifteen_sum; printf("%d", total_sum); return 0; }
#include <stdio.h> #define RANGE 1000 unsigned short count_divisibility(unsigned short divisor) { int count = 0; count = (RANGE - 1) / divisor; return count; } // Use the identity n(n+1)/2 to calculate the sum unsigned int calculate_divisibility_sum(unsigned short number, unsigned short count) { unsigned int divisibility_sum = 0; divisibility_sum = number * (count * (count + 1)) / 2; return divisibility_sum; } int main() { unsigned short div_three_count = 0, div_five_count = 0, div_fifteen_count = 0; unsigned int div_three_sum, div_five_sum, div_fifteen_sum, total_sum; div_three_count = count_divisibility(3); div_five_count = count_divisibility(5); div_fifteen_count = count_divisibility(15); div_three_sum = calculate_divisibility_sum(3, div_three_count); div_five_sum = calculate_divisibility_sum(5, div_five_count); div_fifteen_sum = calculate_divisibility_sum(15, div_fifteen_count); total_sum = div_three_sum + div_five_sum - div_fifteen_sum; printf("%d", total_sum); return 0; }
Drop support for Windows 7.
#pragma once #define NTDDI_VERSION 0x06010000 #define WINVER 0x0601 #define _WIN32_WINNT 0x0601 #include <ShellScalingApi.h> #include <Shlobj.h> #include <ShObjIdl.h> #include <Windows.h> #include <wrl.h> #undef min #undef max #include <algorithm> #include <unordered_map> namespace WRL { using namespace Microsoft::WRL; } #if _DEBUG #define Assert(x) do { if (!(x)) __debugbreak(); } while (false, false) #else #define Assert(x) do { if (false, false) (void)(x); } while (false, false) #endif
#pragma once #define NTDDI_VERSION 0x0A000007 // NTDDI_WIN10_19H1 #define _WIN32_WINNT 0x0A00 // _WIN32_WINNT_WIN10 #define WINVER 0x0A00 #include <ShellScalingApi.h> #include <Shlobj.h> #include <ShObjIdl.h> #include <Windows.h> #include <wrl.h> #undef min #undef max #include <algorithm> #include <unordered_map> namespace WRL { using namespace Microsoft::WRL; } #if _DEBUG #define Assert(x) do { if (!(x)) __debugbreak(); } while (false, false) #else #define Assert(x) do { if (false, false) (void)(x); } while (false, false) #endif
Move to syslog, minor exit bug on usbbridge
// // Created by cyber on 15.08.19. // #ifndef DRONEBRIDGE_DB_COMMON_H #define DRONEBRIDGE_DB_COMMON_H #endif //DRONEBRIDGE_DB_COMMON_H
Use QueryPerformanceCounter() timer instead of GetTickCount()
/* Copyright (C) 2012-2013 Zeex * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <time.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> time_t timer_clock(void) { return GetTickCount(); }
/* Copyright (C) 2012-2013 Zeex * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <time.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> time_t timer_clock(void) { LARGE_INTEGER freq, count; if (!QueryPerformanceFrequency(&freq)) { return 0; } if (!QueryPerformanceCounter(&count)) { return 0; } return (time_t)(1000.0L / freq.QuadPart * count.QuadPart);; }
Convert our own check of OPENSSL_NO_DEPRECATED
/* * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include "internal/cryptlib.h" #include "eng_int.h" void ENGINE_load_builtin_engines(void) { /* Some ENGINEs need this */ OPENSSL_cpuid_setup(); OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); } #if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)) && !defined(OPENSSL_NO_DEPRECATED) void ENGINE_setup_bsd_cryptodev(void) { } #endif
/* * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include "internal/cryptlib.h" #include "eng_int.h" void ENGINE_load_builtin_engines(void) { /* Some ENGINEs need this */ OPENSSL_cpuid_setup(); OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); } #if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)) && OPENSSL_API_COMPAT < 0x10100000L void ENGINE_setup_bsd_cryptodev(void) { } #endif
Include Allegro header so we can use 'bool'.
#ifndef T3F_VIEW_H #define T3F_VIEW_H /* structure holds information about a 3D viewport usually used to represent one player's screen, split screen games will have multiple viewports */ typedef struct { /* offset of viewport */ float offset_x; float offset_y; float width; float height; /* vanishing point */ float vp_x; float vp_y; } T3F_VIEW; extern T3F_VIEW * t3f_default_view; extern T3F_VIEW * t3f_current_view; T3F_VIEW * t3f_create_view(float ox, float oy, float w, float h, float vpx, float vpy); void t3f_destroy_view(T3F_VIEW * vp); void t3f_store_state(T3F_VIEW * sp); void t3f_restore_state(T3F_VIEW * sp); void t3f_select_view(T3F_VIEW * sp); T3F_VIEW * t3f_get_current_view(void); bool t3f_project_coordinates(float vw, float vpx, float vpy, float * x, float * y, float z); float t3f_project_x(float x, float z); float t3f_project_y(float y, float z); #endif
#ifndef T3F_VIEW_H #define T3F_VIEW_H #include <allegro5/allegro5.h> /* structure holds information about a 3D viewport usually used to represent one player's screen, split screen games will have multiple viewports */ typedef struct { /* offset of viewport */ float offset_x; float offset_y; float width; float height; /* vanishing point */ float vp_x; float vp_y; } T3F_VIEW; extern T3F_VIEW * t3f_default_view; extern T3F_VIEW * t3f_current_view; T3F_VIEW * t3f_create_view(float ox, float oy, float w, float h, float vpx, float vpy); void t3f_destroy_view(T3F_VIEW * vp); void t3f_store_state(T3F_VIEW * sp); void t3f_restore_state(T3F_VIEW * sp); void t3f_select_view(T3F_VIEW * sp); T3F_VIEW * t3f_get_current_view(void); bool t3f_project_coordinates(float vw, float vpx, float vpy, float * x, float * y, float z); float t3f_project_x(float x, float z); float t3f_project_y(float y, float z); #endif
Fix MSVC error C2133 : unknown size of multi-dimensional static const arrays (despite supposed support of C99). Have not confirmed if this breaks anything yet.
/* encrypted keys */ static const uint32_t internal_device_number = 0; static const uint8_t internal_dk_list[][21] = { { }, }; static const uint8_t internal_pk_list[][16] = { { }, }; static const uint8_t internal_hc_list[][112] = { { }, }; /* customize this function to "hide" the keys in the binary */ static void decrypt_key(uint8_t *out, const uint8_t *in, size_t size) { memcpy(out, in, size); }
/* encrypted keys */ static const uint32_t internal_device_number = 0; static const uint8_t internal_dk_list[][21] = { { 0 }, }; static const uint8_t internal_pk_list[][16] = { { 0 }, }; static const uint8_t internal_hc_list[][112] = { { 0 }, }; /* customize this function to "hide" the keys in the binary */ static void decrypt_key(uint8_t *out, const uint8_t *in, size_t size) { memcpy(out, in, size); }
Mark functions as override if they override
//Copyright (c) 2018 Ultimaker B.V. //CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef MOCKSOCKET_H #define MOCKSOCKET_H #include <Arcus/Socket.h> //Inheriting from this to be able to swap this socket in the tested class. #include <deque> //History of sent and received messages. namespace cura { /* * \brief Mocks a socket connection from libArcus such that we can test with it * without creating an actual connection. */ class MockSocket : public Arcus::Socket { public: MockSocket(); //virtual ~MockSocket(); virtual void connect(const std::string& address, int port); virtual void listen(const std::string& address, int port); virtual void close(); virtual void reset(); virtual void sendMessage(Arcus::MessagePtr message); virtual Arcus::MessagePtr takeNextMessage(); //virtual Arcus::MessagePtr createMessage(const std::string& type_name); void pushMessageToReceivedQueue(Arcus::MessagePtr message); Arcus::MessagePtr popMessageFromSendQueue(); // void setName(const std::string& new_name); // void printMessages(); std::deque<Arcus::MessagePtr> sent_messages; std::deque<Arcus::MessagePtr> received_messages; }; } //namespace cura #endif //MOCKSOCKET_H
//Copyright (c) 2018 Ultimaker B.V. //CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef MOCKSOCKET_H #define MOCKSOCKET_H #include <Arcus/Socket.h> //Inheriting from this to be able to swap this socket in the tested class. #include <deque> //History of sent and received messages. namespace cura { /* * \brief Mocks a socket connection from libArcus such that we can test with it * without creating an actual connection. */ class MockSocket : public Arcus::Socket { public: MockSocket(); //These functions are overridden to be no-op. void connect(const std::string& address, int port) override; void listen(const std::string& address, int port) override; void close() override; void reset() override; //Catch these functions so that we can see whether they are called. void sendMessage(Arcus::MessagePtr message) override; Arcus::MessagePtr takeNextMessage() override; //Helpers to store the sent and received messages. void pushMessageToReceivedQueue(Arcus::MessagePtr message); Arcus::MessagePtr popMessageFromSendQueue(); std::deque<Arcus::MessagePtr> sent_messages; std::deque<Arcus::MessagePtr> received_messages; }; } //namespace cura #endif //MOCKSOCKET_H
Add LOGFN macro to header.
#ifndef E_MOD_MAIN_H # define E_MOD_MAIN_H # ifndef ECORE_X_RANDR_1_2 # define ECORE_X_RANDR_1_2 ((1 << 16) | 2) # endif # ifndef ECORE_X_RANDR_1_3 # define ECORE_X_RANDR_1_3 ((1 << 16) | 3) # endif # ifndef E_RANDR_12 # define E_RANDR_12 (e_randr_screen_info.rrvd_info.randr_info_12) # endif EAPI extern E_Module_Api e_modapi; EAPI void *e_modapi_init(E_Module *m); EAPI int e_modapi_shutdown(E_Module *m); EAPI int e_modapi_save(E_Module *m); extern const char *mod_dir; /** * @addtogroup Optional_Conf * @{ * * @defgroup Module_Conf_RandR RandR (Screen Resize, Rotate and Mirror) * * Configures size, rotation and mirroring of screen. Uses the X11 * RandR protocol (does not work with NVidia proprietary drivers). * * @} */ #endif
#ifndef E_MOD_MAIN_H # define E_MOD_MAIN_H # define LOGFNS 1 # ifdef LOGFNS # include <stdio.h> # define LOGFN(fl, ln, fn) printf("-CONF-RANDR: %25s: %5i - %s\n", fl, ln, fn); # else # define LOGFN(fl, ln, fn) # endif # ifndef ECORE_X_RANDR_1_2 # define ECORE_X_RANDR_1_2 ((1 << 16) | 2) # endif # ifndef ECORE_X_RANDR_1_3 # define ECORE_X_RANDR_1_3 ((1 << 16) | 3) # endif # ifndef E_RANDR_12 # define E_RANDR_12 (e_randr_screen_info.rrvd_info.randr_info_12) # endif EAPI extern E_Module_Api e_modapi; EAPI void *e_modapi_init(E_Module *m); EAPI int e_modapi_shutdown(E_Module *m); EAPI int e_modapi_save(E_Module *m); extern const char *mod_dir; /** * @addtogroup Optional_Conf * @{ * * @defgroup Module_Conf_RandR RandR (Screen Resize, Rotate and Mirror) * * Configures size, rotation and mirroring of screen. Uses the X11 * RandR protocol (does not work with NVidia proprietary drivers). * * @} */ #endif
Remove another unused private member variable
//===- lld/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.h --------------===// // // The LLVM Linker // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_RELOCATION_HANDLER_H #define LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_RELOCATION_HANDLER_H #include "lld/ReaderWriter/ELFLinkingContext.h" #include <system_error> namespace lld { namespace elf { class AMDGPUTargetHandler; class AMDGPUTargetLayout; class AMDGPUTargetRelocationHandler final : public TargetRelocationHandler { public: AMDGPUTargetRelocationHandler(AMDGPUTargetLayout &layout) : _targetLayout(layout) {} std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, const AtomLayout &, const Reference &) const override; private: AMDGPUTargetLayout &_targetLayout; }; } // elf } // lld #endif
//===- lld/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.h --------------===// // // The LLVM Linker // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_RELOCATION_HANDLER_H #define LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_RELOCATION_HANDLER_H #include "lld/ReaderWriter/ELFLinkingContext.h" #include <system_error> namespace lld { namespace elf { class AMDGPUTargetHandler; class AMDGPUTargetLayout; class AMDGPUTargetRelocationHandler final : public TargetRelocationHandler { public: AMDGPUTargetRelocationHandler(AMDGPUTargetLayout &layout) { } std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, const AtomLayout &, const Reference &) const override; }; } // elf } // lld #endif
Use the member strings since their types on concrete
#ifndef CPR_AUTH_H #define CPR_AUTH_H #include <string> namespace cpr { class Authentication { public: Authentication(const std::string& username, const std::string& password) : username_{username}, password_{password}, auth_string_{username + ":" + password} {} const char* GetAuthString() const; private: std::string username_; std::string password_; std::string auth_string_; }; } #endif
#ifndef CPR_AUTH_H #define CPR_AUTH_H #include <string> namespace cpr { class Authentication { public: Authentication(const std::string& username, const std::string& password) : username_{username}, password_{password}, auth_string_{username_ + ":" + password_} {} const char* GetAuthString() const; private: std::string username_; std::string password_; std::string auth_string_; }; } #endif
Use protothread library which included in RabirdToolkitThirdParties
#ifndef __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #define __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #include <pt.h> class RCoRoutineRunner { public: RCoRoutineRunner(); virtual ~RCoRoutineRunner(); virtual char run(); public: struct pt mPt; }; #endif // __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C
#ifndef __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #define __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #include <pt/pt.h> class RCoRoutineRunner { public: RCoRoutineRunner(); virtual ~RCoRoutineRunner(); virtual char run(); public: struct pt mPt; }; #endif // __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C
Repair on Twin Primes.Homework 2 completed.Stefan Iliev 26 10V
#include<stdio.h> int main() { int printed_numb=0; int x; int prev_number=2; int number=2; int flag; while(printed_numb<10) { flag=0; for(x=2;x<=number/2;x++) { if(number%x==0) { flag=1; break; } } if(flag=0) { if(number==prev_number+2) { printf("%d - ",prev_number); printf("%d\n",number); printed_numb++; } prev_number=number; } number++; } return 0; }
#include<stdio.h> int main() { int printed_numb=0; int x; int prev_number=2; int number=2; int flag; while(printed_numb<10) { flag=0; for(x=2;x<=number/2;x++) { if(number%x==0) { flag=1; break; } } if(flag==0) { if(number==prev_number+2) { printf("%d - ",prev_number); printf("%d\n",number); printed_numb++; } prev_number=number; } number++; } return 0; }
Add an empty iic test case
/* Copyright (c) 2013, laborer (laborer@126.com) * Licensed under the BSD 2-Clause License. */ #include "common.h" #include "iic.h" #include "uart.h" void welcome(void) { uart_baudrate(); uart_init(); uart_putstr("c51drv\n"); } void main(void) { welcome(); while (1); }
Create db table for subscriptions.
#include <sqlite3.h> #include <stdio.h> static sqlite3 *db; int _mqtt_db_create_tables(void); int mqtt_db_open(const char *filename) { if(sqlite3_open(filename, &db) != SQLITE_OK){ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); return 1; } return _mqtt_db_create_tables(); } int mqtt_db_close(void) { sqlite3_close(db); db = NULL; return 0; } int _mqtt_db_create_tables(void) { int rc; char *errmsg = NULL; rc = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS clients(" "id TEXT, " "will INTEGER, will_retain INTEGER, will_qos " "will_topic TEXT, will_message TEXT)", NULL, NULL, &errmsg); if(errmsg) sqlite3_free(errmsg); if(rc == SQLITE_OK){ return 0; }else{ return 1; } }
#include <sqlite3.h> #include <stdio.h> static sqlite3 *db; int _mqtt_db_create_tables(void); int mqtt_db_open(const char *filename) { if(sqlite3_open(filename, &db) != SQLITE_OK){ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); return 1; } return _mqtt_db_create_tables(); } int mqtt_db_close(void) { sqlite3_close(db); db = NULL; return 0; } int _mqtt_db_create_tables(void) { int rc = 0; char *errmsg = NULL; if(sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS clients(" "id TEXT, " "will INTEGER, will_retain INTEGER, will_qos " "will_topic TEXT, will_message TEXT)", NULL, NULL, &errmsg) != SQLITE_OK){ rc = 1; } if(errmsg) sqlite3_free(errmsg); if(sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS subs(" "client_id TEXT, sub TEXT, qos INTEGER)", NULL, NULL, &errmsg) != SQLITE_OK){ rc = 1; } if(errmsg) sqlite3_free(errmsg); return rc; }
Fix invalid read in pseudo observer test
#include <telepathy-logger/channel-factory-internal.h> #include <telepathy-logger/observer-internal.h> static gint factory_counter = 0; static TplChannel * mock_factory (const gchar *chan_type, TpConnection *conn, const gchar *object_path, GHashTable *tp_chan_props, TpAccount *tp_acc, GError **error) { factory_counter += 1; return NULL; } int main (int argc, char **argv) { TplObserver *obs, *obs2; g_type_init (); obs = _tpl_observer_new (); /* TplObserver is a singleton, be sure both references point to the same * memory address */ obs2 = _tpl_observer_new (); g_assert (obs == obs2); /* unref the second singleton pointer and check that the it is still * valid: checking correct object ref-counting after each _dup() call */ g_object_unref (obs2); g_assert (TPL_IS_OBSERVER (obs)); /* it points to the same mem area, it should be still valid */ g_assert (TPL_IS_OBSERVER (obs2)); /* register a ChanFactory and test ObserveChannel() */ _tpl_observer_set_channel_factory (obs, mock_factory); /* proper disposal for the singleton when no references are present */ g_object_unref (obs); g_assert (!TPL_IS_OBSERVER (obs)); return 0; }
#include <telepathy-logger/channel-factory-internal.h> #include <telepathy-logger/observer-internal.h> static gint factory_counter = 0; static TplChannel * mock_factory (const gchar *chan_type, TpConnection *conn, const gchar *object_path, GHashTable *tp_chan_props, TpAccount *tp_acc, GError **error) { factory_counter += 1; return NULL; } int main (int argc, char **argv) { TplObserver *obs, *obs2; g_type_init (); obs = _tpl_observer_new (); /* TplObserver is a singleton, be sure both references point to the same * memory address */ obs2 = _tpl_observer_new (); g_assert (obs == obs2); /* unref the second singleton pointer and check that the it is still * valid: checking correct object ref-counting after each _dup() call */ g_object_unref (obs2); g_assert (TPL_IS_OBSERVER (obs)); /* it points to the same mem area, it should be still valid */ g_assert (TPL_IS_OBSERVER (obs2)); /* register a ChanFactory and test ObserveChannel() */ _tpl_observer_set_channel_factory (obs, mock_factory); /* proper disposal for the singleton when no references are present */ g_object_unref (obs); return 0; }
Fix compile errors with different integer-types
// // include/guard_overflow.h // tbd // // Created by inoahdev on 12/29/18. // Copyright © 2018 - 2019 inoahdev. All rights reserved. // #ifndef GUARD_OVERFLOW_H #define GUARD_OVERFLOW_H #include <stdint.h> #define guard_overflow_add(left_in, right) _Generic((left_in), \ uint32_t *: __builtin_uadd_overflow, \ uint64_t *: __builtin_uaddl_overflow \ ) (*left_in, right, left_in) #define guard_overflow_mul(left_in, right) _Generic((left_in), \ uint32_t *: __builtin_umul_overflow, \ uint64_t *: __builtin_umull_overflow \ ) (*left_in, right, left_in) #define guard_overflow_shift_left(left_in, right) _Generic((left_in), \ uint32_t *: guard_overflow_shift_left_uint32, \ uint64_t *: guard_overflow_shift_left_uint64 \ ) (left_in, right) int guard_overflow_shift_left_uint32(uint32_t *left_in, uint32_t right); int guard_overflow_shift_left_uint64(uint64_t *left_in, uint64_t right); #endif /* GUARD_OVERFLOW_H */
// // include/guard_overflow.h // tbd // // Created by inoahdev on 12/29/18. // Copyright © 2018 - 2019 inoahdev. All rights reserved. // #ifndef GUARD_OVERFLOW_H #define GUARD_OVERFLOW_H #include <stdint.h> #define guard_overflow_add(left_in, right) \ __builtin_add_overflow(*left_in, right, left_in) #define guard_overflow_mul(left_in, right) \ __builtin_mul_overflow(*left_in, right, left_in) #define guard_overflow_shift_left(left_in, right) _Generic((left_in), \ uint32_t *: guard_overflow_shift_left_uint32, \ uint64_t *: guard_overflow_shift_left_uint64 \ ) (left_in, right) int guard_overflow_shift_left_uint32(uint32_t *left_in, uint32_t right); int guard_overflow_shift_left_uint64(uint64_t *left_in, uint64_t right); #endif /* GUARD_OVERFLOW_H */
Fix broken kernel headers preventing ARM build
#ifndef _ROOT_DEV_H_ #define _ROOT_DEV_H_ #include <linux/major.h> enum { Root_NFS = MKDEV(UNNAMED_MAJOR, 255), Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0), Root_RAM1 = MKDEV(RAMDISK_MAJOR, 1), Root_FD0 = MKDEV(FLOPPY_MAJOR, 0), Root_HDA1 = MKDEV(IDE0_MAJOR, 1), Root_HDA2 = MKDEV(IDE0_MAJOR, 2), Root_SDA1 = MKDEV(SCSI_DISK0_MAJOR, 1), Root_SDA2 = MKDEV(SCSI_DISK0_MAJOR, 2), Root_HDC1 = MKDEV(IDE1_MAJOR, 1), Root_SR0 = MKDEV(SCSI_CDROM_MAJOR, 0), }; extern dev_t ROOT_DEV; #endif
#ifndef _ROOT_DEV_H_ #define _ROOT_DEV_H_ #include <linux/major.h> #include <linux/types.h> #include <linux/kdev_t.h> enum { Root_NFS = MKDEV(UNNAMED_MAJOR, 255), Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0), Root_RAM1 = MKDEV(RAMDISK_MAJOR, 1), Root_FD0 = MKDEV(FLOPPY_MAJOR, 0), Root_HDA1 = MKDEV(IDE0_MAJOR, 1), Root_HDA2 = MKDEV(IDE0_MAJOR, 2), Root_SDA1 = MKDEV(SCSI_DISK0_MAJOR, 1), Root_SDA2 = MKDEV(SCSI_DISK0_MAJOR, 2), Root_HDC1 = MKDEV(IDE1_MAJOR, 1), Root_SR0 = MKDEV(SCSI_CDROM_MAJOR, 0), }; extern dev_t ROOT_DEV; #endif
Add documentation for the defines and variables.
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #ifndef GUAC_SSH_TTYMODE_H #define GUAC_SSH_TTYMODE_H #include "config.h" #define GUAC_SSH_TTY_OP_END 0 #define GUAC_SSH_TTY_OP_VERASE 3 #define GUAC_SSH_TERM_DEFAULT_BACKSPACE 127 extern const char GUAC_SSH_TTY_MODES[6]; #endif
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #ifndef GUAC_SSH_TTYMODE_H #define GUAC_SSH_TTYMODE_H #include "config.h" /** * The SSH TTY mode encoding opcode that terminates * the list of TTY modes. */ #define GUAC_SSH_TTY_OP_END 0 /** * The SSH tty mode encoding opcode that configures * the TTY erase code to configure the server * backspace key. */ #define GUAC_SSH_TTY_OP_VERASE 3 /** * The default ASCII code to send for the backspace * key that will be sent to the SSH server. */ #define GUAC_SSH_TERM_DEFAULT_BACKSPACE 127 /** * The array of TTY mode encoding data to send to the * SSH server. These consist of pairs of byte codes * and uint32 (4-byte) values, with a 0 to terminate * the list. */ extern const char GUAC_SSH_TTY_MODES[6]; #endif
Fix libressl patch python 3.6
--- Modules/_ssl.c.orig +++ Modules/_ssl.c @@ -99,7 +99,8 @@ struct py_ssl_library_code { /* Include generated data (error codes) */ #include "_ssl_data.h" -#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER) +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \ + (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER >= 0x2070000fL) # define OPENSSL_VERSION_1_1 1 #endif @@ -133,6 +134,9 @@ struct py_ssl_library_code { /* OpenSSL 1.1.0+ */ #ifndef OPENSSL_NO_SSL2 #define OPENSSL_NO_SSL2 +#endif +#if defined(LIBRESSL_VERSION_NUMBER) && defined(WITH_THREAD) +#define HAVE_OPENSSL_CRYPTO_LOCK #endif #else /* OpenSSL < 1.1.0 */ #if defined(WITH_THREAD)
$OpenBSD: patch-Modules__ssl_c,v 1.2 2018/03/17 22:30:04 sthen Exp $ XXX maybe the second hunk can go away now we have auto-init, I'm not sure exactly what python's lock protects Index: Modules/_ssl.c --- Modules/_ssl.c.orig +++ Modules/_ssl.c @@ -99,7 +99,8 @@ struct py_ssl_library_code { /* Include generated data (error codes) */ #include "_ssl_data.h" -#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER) +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \ + (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER >= 0x2070000fL) # define OPENSSL_VERSION_1_1 1 #endif @@ -133,6 +134,9 @@ struct py_ssl_library_code { /* OpenSSL 1.1.0+ */ #ifndef OPENSSL_NO_SSL2 #define OPENSSL_NO_SSL2 +#endif +#if defined(LIBRESSL_VERSION_NUMBER) && defined(WITH_THREAD) +#define HAVE_OPENSSL_CRYPTO_LOCK #endif #else /* OpenSSL < 1.1.0 */ #if defined(WITH_THREAD)
Add missing file for the MPI test.
#include <stdio.h> #include <stdlib.h> #include <mpi.h> int main (int argc, char *argv[]) { int rank, size, length; char name[BUFSIZ]; MPI_Init (&argc, &argv); MPI_Comm_rank (MPI_COMM_WORLD, &rank); MPI_Comm_size (MPI_COMM_WORLD, &size); MPI_Get_processor_name (name, &length); printf ("%s: hello world from process %d of %d\n", name, rank, size); MPI_Finalize (); return EXIT_SUCCESS; }
Add void to empty function parameter
#define PY_SSIZE_T_CLEAN #include <Python.h> static PyObject* websocket_mask(PyObject* self, PyObject* args) { const char* mask; Py_ssize_t mask_len; const char* data; Py_ssize_t data_len; Py_ssize_t i; PyObject* result; char* buf; if (!PyArg_ParseTuple(args, "s#s#", &mask, &mask_len, &data, &data_len)) { return NULL; } result = PyBytes_FromStringAndSize(NULL, data_len); if (!result) { return NULL; } buf = PyBytes_AsString(result); for (i = 0; i < data_len; i++) { buf[i] = data[i] ^ mask[i % 4]; } return result; } static PyMethodDef methods[] = { {"websocket_mask", websocket_mask, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef speedupsmodule = { PyModuleDef_HEAD_INIT, "speedups", NULL, -1, methods }; PyMODINIT_FUNC PyInit_speedups() { return PyModule_Create(&speedupsmodule); } #else // Python 2.x PyMODINIT_FUNC initspeedups() { Py_InitModule("tornado.speedups", methods); } #endif
#define PY_SSIZE_T_CLEAN #include <Python.h> static PyObject* websocket_mask(PyObject* self, PyObject* args) { const char* mask; Py_ssize_t mask_len; const char* data; Py_ssize_t data_len; Py_ssize_t i; PyObject* result; char* buf; if (!PyArg_ParseTuple(args, "s#s#", &mask, &mask_len, &data, &data_len)) { return NULL; } result = PyBytes_FromStringAndSize(NULL, data_len); if (!result) { return NULL; } buf = PyBytes_AsString(result); for (i = 0; i < data_len; i++) { buf[i] = data[i] ^ mask[i % 4]; } return result; } static PyMethodDef methods[] = { {"websocket_mask", websocket_mask, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef speedupsmodule = { PyModuleDef_HEAD_INIT, "speedups", NULL, -1, methods }; PyMODINIT_FUNC PyInit_speedups(void) { return PyModule_Create(&speedupsmodule); } #else // Python 2.x PyMODINIT_FUNC initspeedups(void) { Py_InitModule("tornado.speedups", methods); } #endif
Remove OSVersion check of import "UIStepper+FlatUI.h"
// // FlatUIKit.h // FlatUI // // Created by Keisuke Kimura on 6/8/13. // Copyright (c) 2013 Keisuke Kimura. All rights reserved. // #ifndef FlatUI_FlatUIKit_h #define FlatUI_FlatUIKit_h #ifndef __IPHONE_5_0 #error "FlatUIKit uses features only available in iOS SDK 5.0 and later." #endif #if TARGET_OS_IPHONE #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #endif #endif #import "FUIAlertView.h" #import "FUIButton.h" #import "FUICellBackgroundView.h" #import "FUISegmentedControl.h" #import "FUISwitch.h" #import "UIBarButtonItem+FlatUI.h" #import "UIColor+FlatUI.h" #import "UIFont+FlatUI.h" #import "UIImage+FlatUI.h" #import "UINavigationBar+FlatUI.h" #import "UIProgressView+FlatUI.h" #import "UISlider+FlatUI.h" #import "UITabBar+FlatUI.h" #import "UITableViewCell+FlatUI.h" #ifdef __IPHONE_6_0 #import "UIStepper+FlatUI.h" #endif
// // FlatUIKit.h // FlatUI // // Created by Keisuke Kimura on 6/8/13. // Copyright (c) 2013 Keisuke Kimura. All rights reserved. // #ifndef FlatUI_FlatUIKit_h #define FlatUI_FlatUIKit_h #ifndef __IPHONE_5_0 #error "FlatUIKit uses features only available in iOS SDK 5.0 and later." #endif #if TARGET_OS_IPHONE #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #endif #endif #import "FUIAlertView.h" #import "FUIButton.h" #import "FUICellBackgroundView.h" #import "FUISegmentedControl.h" #import "FUISwitch.h" #import "UIBarButtonItem+FlatUI.h" #import "UIColor+FlatUI.h" #import "UIFont+FlatUI.h" #import "UIImage+FlatUI.h" #import "UINavigationBar+FlatUI.h" #import "UIProgressView+FlatUI.h" #import "UIStepper+FlatUI.h" #import "UISlider+FlatUI.h" #import "UITabBar+FlatUI.h" #import "UITableViewCell+FlatUI.h"
Add asserts to C sum of even squares
int sum_of_even_squares(int* a, unsigned int length) { int total = 0; for (unsigned int i = 0; i < length; i++) { if (a[i] % 2 == 0) { total += a[i] * a[i]; } } return total; }
int sum_of_even_squares(int* a, unsigned int length) { int total = 0; for (unsigned int i = 0; i < length; i++) { if (a[i] % 2 == 0) { total += a[i] * a[i]; } } return total; } #include <assert.h> static int a[] = {7, 3, -8, 4, 1, 0, 11, 2}; int main() { assert(sum_of_even_squares(a, 0) == 0); assert(sum_of_even_squares(a, 1) == 0); assert(sum_of_even_squares(a, 2) == 0); assert(sum_of_even_squares(a, 3) == 64); assert(sum_of_even_squares(a, 4) == 80); assert(sum_of_even_squares(a, 5) == 80); assert(sum_of_even_squares(a, 6) == 80); assert(sum_of_even_squares(a, 7) == 80); assert(sum_of_even_squares(a, 8) == 84); return 0; }
Use __SIZE_TYPE__ instead of rt_size_t in minilibc.
#ifndef __TYPES_H__ #define __TYPES_H__ #include <rtthread.h> typedef long off_t; typedef rt_size_t size_t; typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */ typedef rt_uint8_t u_char; typedef rt_uint16_t u_short; typedef rt_ubase_t u_int; typedef rt_uint32_t u_long; typedef rt_time_t time_t; typedef int mode_t; typedef unsigned long clockid_t; typedef int pid_t; #ifndef NULL #define NULL RT_NULL #endif #define __u_char_defined #endif
#ifndef __TYPES_H__ #define __TYPES_H__ #include <rtthread.h> typedef long off_t; typedef __SIZE_TYPE__ size_t; typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */ typedef rt_uint8_t u_char; typedef rt_uint16_t u_short; typedef rt_ubase_t u_int; typedef rt_uint32_t u_long; typedef rt_time_t time_t; typedef int mode_t; typedef unsigned long clockid_t; typedef int pid_t; #ifndef NULL #define NULL RT_NULL #endif #define __u_char_defined #endif
Add high and low in iterative
/* * CIS 314 Fall 2015 Lab 1 * Assigned project * * This program reads a sorted array from a file and finds a requested number * using recursive or iterative binary search. The array is read from a file * defined by FILE_NAME, which should be written as the number of elements * followed by the elements themselses. each number can be deliniated with * any whitepace character. Also, the maximum size of the array is defined * as MAX_SIZE. * * NOTE: The array must be sorted!! * */ #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_SIZE 150 #define FILE_NAME "array.dat" //must include quotes // Implement the rest of the program int main(void) { FILE *in_file; int array[MAX_SIZE]; int size; char in_file_name[] = FILE_NAME; printf("\n\n=== CIS314 Fall 2014 - Lab 1: Part 2: Program 2 ===\n\n"); printf("\n\n"); return 0; } int recursiveBinarySearch(int list_of_numbers[], int desired_number, int low_number, int high_number) { } int iterativeBinarySearch(int list_of_numbers[], int desired_number) { }
/* * CIS 314 Fall 2015 Lab 1 * Assigned project * * This program reads a sorted array from a file and finds a requested number * using recursive or iterative binary search. The array is read from a file * defined by FILE_NAME, which should be written as the number of elements * followed by the elements themselses. each number can be deliniated with * any whitepace character. Also, the maximum size of the array is defined * as MAX_SIZE. * * NOTE: The array must be sorted!! * */ #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_SIZE 150 #define FILE_NAME "array.dat" //must include quotes // Implement the rest of the program int main(void) { FILE *in_file; int array[MAX_SIZE]; int size; char in_file_name[] = FILE_NAME; printf("\n\n=== CIS314 Fall 2014 - Lab 1: Part 2: Program 2 ===\n\n"); printf("\n\n"); return 0; } int recursiveBinarySearch(int list_of_numbers[], int desired_number, int low_number, int high_number) { } int iterativeBinarySearch(int list_of_numbers[], int desired_number) { int low = 0; int high = (sizeof(list_of_numbers)/sizeof(list_of_numbers[0])) - 1 }
Set C linkage for win32 [v]asprintf
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2014 Couchbase, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <stdarg.h> #include <platform/visibility.h> PLATFORM_PUBLIC_API int asprintf(char **ret, const char *format, ...); PLATFORM_PUBLIC_API int vasprintf(char **ret, const char *format, va_list ap); /* * We have a fair amount of use of this file in our code base. * Let's just make a dummy file to aviod a lot of #ifdefs */ #ifndef strcasecmp #define strcasecmp(a, b) _stricmp(a, b) #endif #ifndef snprintf #define snprintf _snprintf #endif
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2014 Couchbase, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <stdarg.h> #include <platform/visibility.h> #ifdef __cplusplus extern "C" { #endif PLATFORM_PUBLIC_API int asprintf(char **ret, const char *format, ...); PLATFORM_PUBLIC_API int vasprintf(char **ret, const char *format, va_list ap); #ifdef __cplusplus } #endif /* * We have a fair amount of use of this file in our code base. * Let's just make a dummy file to aviod a lot of #ifdefs */ #ifndef strcasecmp #define strcasecmp(a, b) _stricmp(a, b) #endif #ifndef snprintf #define snprintf _snprintf #endif
Add new class to track OSD assets
#pragma once #pragma comment(lib, "gdiplus.lib") #include <Windows.h> #include <gdiplus.h> #include <vector> #include "../MeterWnd/Meter.h" class OSDSkin { public: OSDSkin(Gdiplus::Bitmap *background, Gdiplus::Bitmap *mask, std::vector<Meter *> meters, std::vector<HICON> iconset) : background(background), mask(mask), meters(meters), iconset(iconset) { } const Gdiplus::Bitmap *background; const Gdiplus::Bitmap *mask; const std::vector<Meter *> meters; const std::vector<HICON> iconset; };
Fix for checking if the database is loaded
/* OpenLieroX reader for IpToCountry database code under LGPL by Albert Zeyer and Dark Charlie */ #ifndef __IPTOCOUNTRY_H__ #define __IPTOCOUNTRY_H__ #include <string> #include "SmartPointer.h" #include "InternDataClass.h" #include "GeoIPDatabase.h" struct SDL_Surface; typedef GeoRecord IpInfo; INTERNDATA_CLASS_BEGIN(IpToCountryDB) private: GeoIPDatabase *m_database; public: IpToCountryDB(const std::string& dbfile); void LoadDBFile(const std::string& dbfile); IpInfo GetInfoAboutIP(const std::string& Address); SmartPointer<SDL_Surface> GetCountryFlag(const std::string& shortcut); int GetProgress() { return 100; } bool Loaded() { return true; } INTERNDATA_CLASS_END extern char *IP_TO_COUNTRY_FILE; extern IpToCountryDB *tIpToCountryDB; #endif
/* OpenLieroX reader for IpToCountry database code under LGPL by Albert Zeyer and Dark Charlie */ #ifndef __IPTOCOUNTRY_H__ #define __IPTOCOUNTRY_H__ #include <string> #include "SmartPointer.h" #include "InternDataClass.h" #include "GeoIPDatabase.h" struct SDL_Surface; typedef GeoRecord IpInfo; INTERNDATA_CLASS_BEGIN(IpToCountryDB) private: GeoIPDatabase *m_database; public: IpToCountryDB(const std::string& dbfile); void LoadDBFile(const std::string& dbfile); IpInfo GetInfoAboutIP(const std::string& Address); SmartPointer<SDL_Surface> GetCountryFlag(const std::string& shortcut); int GetProgress() { return 100; } bool Loaded() { return m_database != NULL && m_database->loaded(); } INTERNDATA_CLASS_END extern char *IP_TO_COUNTRY_FILE; extern IpToCountryDB *tIpToCountryDB; #endif
Address issues found by LGTM
#include <stdio.h> #include <stdarg.h> #include <time.h> #include <unistd.h> #include "log.h" #include "globals.h" void my_log(int priority, const char *format, ...) { va_list ap; va_start(ap, format); #ifndef MINIMALISTIC_BUILD if (globals.no_syslog) { #endif time_t now; struct tm* timeinfo; char timestring[32]; time(&now); timeinfo = localtime(&now); strftime(timestring, sizeof(timestring), "%Y-%m-%d %H:%M:%S", timeinfo); fprintf( stderr, "%s %s[%d]: ", timestring, #ifndef MINIMALISTIC_BUILD globals.daemon_name, #else "ssh-honeypotd", #endif getpid() ); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" vfprintf(stderr, format, ap); #pragma GCC diagnostic pop fprintf(stderr, "\n"); #ifndef MINIMALISTIC_BUILD } else { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" vsyslog(priority, format, ap); #pragma GCC diagnostic pop } #endif va_end(ap); }
#include <stdio.h> #include <stdarg.h> #include <time.h> #include <unistd.h> #include "log.h" #include "globals.h" void my_log(int priority, const char *format, ...) { va_list ap; va_start(ap, format); #ifndef MINIMALISTIC_BUILD if (globals.no_syslog) { #endif time_t now; struct tm timeinfo; char timestring[32]; time(&now); localtime_r(&now, &timeinfo); strftime(timestring, sizeof(timestring), "%Y-%m-%d %H:%M:%S", &timeinfo); fprintf( stderr, "%s %s[%d]: ", timestring, #ifndef MINIMALISTIC_BUILD globals.daemon_name, #else "ssh-honeypotd", #endif getpid() ); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" vfprintf(stderr, format, ap); #pragma GCC diagnostic pop fprintf(stderr, "\n"); #ifndef MINIMALISTIC_BUILD } else { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" vsyslog(priority, format, ap); #pragma GCC diagnostic pop } #endif va_end(ap); }
Revert "Remove public headers from umbrella header"
#import <Foundation/Foundation.h> //! Project version number for Quick. FOUNDATION_EXPORT double QuickVersionNumber; //! Project version string for Quick. FOUNDATION_EXPORT const unsigned char QuickVersionString[]; #import <Quick/QuickSpec.h>
#import <Foundation/Foundation.h> //! Project version number for Quick. FOUNDATION_EXPORT double QuickVersionNumber; //! Project version string for Quick. FOUNDATION_EXPORT const unsigned char QuickVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <Quick/PublicHeader.h> #import <Quick/QuickSpec.h> #import <Quick/QCKDSL.h> #import <Quick/QuickConfiguration.h>
Add typedef block with return value
// // BlockExamples.h // ObjcNullability // // Created by Bryan Luby on 5/21/15. // Copyright (c) 2015 Bryan Luby. All rights reserved. // #import <Foundation/Foundation.h> typedef void(^TestBlock)(NSString * __nonnull stuff); typedef void(^TestBlock2)(NSString * __nullable otherStuff); NS_ASSUME_NONNULL_BEGIN typedef void(^TestBlock3)(NSString *aString); NS_ASSUME_NONNULL_END @interface BlockExamples : NSObject - (void)methodThatTakesABlock:(nullable TestBlock)block; - (void)anotherMethodThatTakesABlock:(nonnull TestBlock2)block; @end
// // BlockExamples.h // ObjcNullability // // Created by Bryan Luby on 5/21/15. // Copyright (c) 2015 Bryan Luby. All rights reserved. // #import <Foundation/Foundation.h> typedef void(^TestBlock)(NSString * __nonnull stuff); typedef void(^TestBlock2)(NSString * __nullable otherStuff); NS_ASSUME_NONNULL_BEGIN typedef void(^TestBlock3)(NSString *aString); NS_ASSUME_NONNULL_END typedef NSString *__nonnull(^TestBlock4)(NSString *__nonnull aString); @interface BlockExamples : NSObject - (void)methodThatTakesABlock:(nullable TestBlock)block; - (void)anotherMethodThatTakesABlock:(nonnull TestBlock2)block; @end
Support code for Storable.hs - defines teh read/writeFooOffPtr functions.
#include "HsFFI.h" void writeIntOffPtr(HsPtr arg1, HsInt arg2, HsInt arg3) { ((typeof(arg3)*)arg1)[arg2] = arg3; } HsInt readIntOffPtr(HsPtr arg1, HsInt arg2) { return ((typeof(readIntOffPtr(arg1,arg2))*)arg1)[arg2]; } void writeCharOffPtr(HsPtr arg1, HsInt arg2, HsChar arg3) { ((typeof(arg3)*)arg1)[arg2] = arg3; } HsChar readCharOffPtr(HsPtr arg1, HsInt arg2) { return ((typeof(readCharOffPtr(arg1,arg2))*)arg1)[arg2]; }
Mark run() as pure virtual function
#ifndef __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #define __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #include <pt/pt.h> class RCoRoutineRunner { public: RCoRoutineRunner(); virtual ~RCoRoutineRunner(); virtual char run(); public: struct pt mPt; }; #endif // __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C
#ifndef __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #define __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C #include <pt/pt.h> class RCoRoutineRunner { public: RCoRoutineRunner(); virtual ~RCoRoutineRunner(); virtual char run() = 0; public: struct pt mPt; }; #endif // __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C
Add some comments to compiler.h
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #pragma once #ifdef __GNUC__ #define GCC_VERSION \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #else #define GCC_VERSION #endif #if GCC_VERSION >= 30400 #define __must_check __attribute__((warn_unused_result)) #else #define __must_check #endif
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #pragma once /** * This header defines some useful attribute by each compiler. It is the * abstract layer of compilers. */ #ifdef __GNUC__ #define GCC_VERSION \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #else #define GCC_VERSION #endif /** * __must_check macro. It make the function's return value must be used, * otherwise it will raise a compile warning. And also Paddle treat all compile * warnings as errors. */ #if GCC_VERSION >= 30400 #define __must_check __attribute__((warn_unused_result)) #else #define __must_check #endif
Remove option argument for transmit mode
// Copyright 2016 Mitchell Kember. Subject to the MIT License. #include "translate.h" #include "transmit.h" #include "util.h" #include <stdio.h> #include <unistd.h> int main(int argc, char **argv) { setup_util(argv[0]); // Initialize options to default values. int mode = 'e'; int time_unit = 0; // Get command line options. int c; extern char *optarg; extern int optind, optopt; while ((c = getopt(argc, argv, "hedt:")) != -1) { switch (c) { case 'h': print_usage(stdout); return 0; case 't': if (!parse_int(&time_unit, optarg)) { return 1; } // fall through case 'e': case 'd': mode = c; break; case '?': return 1; } } // Make sure all arguments were processed. if (optind != argc) { print_usage(stderr); return 1; } // Dispatch to the chosen subprogram. switch (mode) { case 'e': return encode(); case 'd': return decode(); case 't': return transmit(time_unit); } }
// Copyright 2016 Mitchell Kember. Subject to the MIT License. #include "translate.h" #include "transmit.h" #include "util.h" #include <stdio.h> #include <unistd.h> int main(int argc, char **argv) { setup_util(argv[0]); // Initialize the default mode. int mode = 'e'; // Get command line options. int c; extern char *optarg; extern int optind, optopt; while ((c = getopt(argc, argv, "hedt")) != -1) { switch (c) { case 'h': print_usage(stdout); return 0; case 'e': case 'd': case 't': mode = c; break; case '?': return 1; } } // Make sure all arguments were processed. if (optind != argc) { print_usage(stderr); return 1; } // Dispatch to the chosen subprogram. switch (mode) { case 'e': return encode(); case 'd': return decode(); case 't': return transmit(); } }
Correct usage message option list.
#include <stdio.h> #include <stdlib.h> #include <sysexits.h> #include <unistd.h> #include "choices.h" #include "config.h" #include "io.h" #include "ui.h" void usage(); void version(); int main(int argc,char **argv) { int ch; struct choices *cs; while ((ch = getopt(argc, argv, "hv")) != -1) switch (ch) { case 'v': version(); default: usage(); } argc -= optind; argv += optind; cs = get_choices(); put_choice(get_selected(cs)); choices_free(cs); return EX_OK; } void usage() { fprintf(stderr, "usage: pick [-h]\n"); fprintf(stderr, " -h display this help message and exit\n"); fprintf(stderr, " -v display the version and exit\n"); exit(EX_USAGE); } void version() { printf("%s\n", PACKAGE_VERSION); exit(EX_OK); }
#include <stdio.h> #include <stdlib.h> #include <sysexits.h> #include <unistd.h> #include "choices.h" #include "config.h" #include "io.h" #include "ui.h" void usage(); void version(); int main(int argc,char **argv) { int ch; struct choices *cs; while ((ch = getopt(argc, argv, "hv")) != -1) switch (ch) { case 'v': version(); default: usage(); } argc -= optind; argv += optind; cs = get_choices(); put_choice(get_selected(cs)); choices_free(cs); return EX_OK; } void usage() { fprintf(stderr, "usage: pick [-h] [-v]\n"); fprintf(stderr, " -h display this help message and exit\n"); fprintf(stderr, " -v display the version and exit\n"); exit(EX_USAGE); } void version() { printf("%s\n", PACKAGE_VERSION); exit(EX_OK); }
Create code to test timer
#include <stdlib.h> #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { return 0; }
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "timer.h" #include "ports.h" int main(int argc, char *argv[]) { int prt, time; mach_port_t port; tcp_timer_t timer; char buffer[4096]; typeinfo_t tpinfo; timer_message_t* msg = (timer_message_t*)buffer; mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port); timer = start_timer_thread(port); while(1) { scanf("%d", &prt); scanf("%d", &time); if(time == 0) break; add_timer(timer, time, prt, (uintptr_t)(argv[prt % argc])); } while(1) { if(!receive_data(&port, &tpinfo, buffer, 1024)) continue; printf("Received : %d -> \"%s\"\n", msg->port, (char*)msg->data); if(msg->port == 42) break; } return 0; }
Add header with PIMPL helper macros
/* +---------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | | | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file | | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +---------------------------------------------------------------------------+ */ #pragma once /** \file Macros to help implementing the PIMPL idiom and make all * declarations easier to read and less error-prone. */ #define PIMPL_DECLARE_TYPE(_TYPE, _VAR_NAME) void *_VAR_NAME #define PIMPL_CTOR_INIT(_TYPE, _VAR_NAME) _VAR_NAME(NULL) #define PIMPL_DESTROY(_TYPE,_VAR_NAME) \ if (_VAR_NAME) { delete reinterpret_cast<_TYPE*>(_VAR_NAME); _VAR_NAME=NULL; } #define PIMPL_CONSTRUCT(_TYPE,_VAR_NAME) \ PIMPL_DESTROY(_TYPE,_VAR_NAME) \ _VAR_NAME = new _TYPE(); #define PIMPL_GET_REF(_TYPE, _VAR_NAME) (*reinterpret_cast<_TYPE*>(_VAR_NAME)) #define PIMPL_GET_CONSTREF(_TYPE, _VAR_NAME) (*reinterpret_cast<const _TYPE*>(_VAR_NAME))
Add API for NVRAM devices with byte level erase.
/* * Copyright (C) 2015 Eistec AB * * This file is subject to the terms and conditions of the GNU Lesser General * Public License v2.1. See the file LICENSE in the top level directory for more * details. */ /** * @defgroup nvram Non-volatile RAM * @ingroup drivers * @brief Non-volatile RAM interface * * This API is designed around non-volatile memories which do not need blockwise * erase, such as ferro-electric RAM (FRAM) or magneto-resistive RAM (MRAM). * * This interface is not suitable for flash memories. * * @{ * * @file * * @brief Generic non-volatile RAM driver interface * @author Joakim Gebart <joakim.gebart@eistec.se> */ #ifndef DRIVERS_NVRAM_H_ #define DRIVERS_NVRAM_H_ #include <stdint.h> #include <stddef.h> #ifdef __cplusplus extern "C" { #endif /* Forward declaration in order to declare function pointers which take this * type as a parameter within the struct. */ struct nvram; /** * @brief Device descriptor for generic NVRAM devices. */ typedef struct nvram { /** * @brief Pointer to device-specific read function * * Copy data from system memory to NVRAM. * * @param[in] dev Pointer to NVRAM device descriptor * @param[out] dst Pointer to the first byte in the system memory address space * @param[in] src Starting address in the NVRAM device address space * @param[in] len Number of bytes to copy * * @return Number of bytes read on success * @return <0 on errors */ int (*read)(struct nvram *dev, uint8_t *dst, uint32_t src, size_t size); /** * @brief Pointer to device-specific write function * * Copy data from NVRAM to system memory. * * @param[in] dev Pointer to NVRAM device descriptor * @param[in] src Pointer to the first byte in the system memory address space * @param[in] dst Starting address in the NVRAM device address space * @param[in] len Number of bytes to copy * * @return Number of bytes written on success * @return <0 on errors */ int (*write)(struct nvram *dev, uint8_t *src, uint32_t dst, size_t size); /** @brief Device capacity */ size_t size; /** @brief Device-specific parameters, if any. */ void *extra; } nvram_t; #ifdef __cplusplus } #endif #endif /* DRIVERS_NVRAM_H_ */ /** @} */
Add macros that provide an iterator wrapper
#ifndef BALL_CONCEPT_STDITERATORWRAPPER_H #define BALL_CONCEPT_STDITERATORWRAPPER_H #define IteratorWrapper(type)\ template<typename T>\ class type##IteratorWrapper\ {\ public:\ type##IteratorWrapper(T* c) : container_(c) {}\ type##Iterator begin() { return container_->begin##type(); }\ type##Iterator end() { return container_->end##type(); }\ \ private:\ T* container_;\ }; #define ConstIteratorWrapper(type)\ template<typename T>\ class type##ConstIteratorWrapper\ {\ public:\ type##ConstIteratorWrapper(const T* c) : container_(c) {}\ type##ConstIterator begin() { return container_->begin##type(); }\ type##ConstIterator end() { return container_->end##type(); }\ \ private:\ const T* container_;\ }; #define BALL_DECLARE_STD_ITERATOR_WRAPPER(container, type, method_name)\ type##IteratorWrapper< container > method_name () {\ return type##IteratorWrapper< container >(this);\ }\ type##ConstIteratorWrapper< container > method_name () const {\ return type##ConstIteratorWrapper< container >(this);\ } #endif //BALL_CONCEPT_STDITERATORWRAPPER_H
Update testcase for r283948 (NFC)
// Make sure instrumentation data from available_externally functions doesn't // get thrown out and are emitted with the expected linkage. // RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s // CHECK: @__profc_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 // CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section "__DATA,__llvm_prf_data", align 8 inline int foo(void) { return 1; } int main(void) { return foo(); }
// Make sure instrumentation data from available_externally functions doesn't // get thrown out and are emitted with the expected linkage. // RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s // CHECK: @__profc_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 // CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8 inline int foo(void) { return 1; } int main(void) { return foo(); }
Fix number of peripheral vectors for stm32f401xE
/* mbed Microcontroller Library - cmsis_nvic * Copyright (c) 2009-2011 ARM Limited. All rights reserved. * * CMSIS-style functionality to support dynamic vectors */ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H #include <stdint.h> #if defined(STM32F407xx) #define MCU_NUM_PERIPH_VECTORS 82 #elif defined(STM32F401xE) #define MCU_NUM_PERIPH_VECTORS 85 #elif defined(STM32F427xx) || defined(STM32F429xx) #define MCU_NUM_PERIPH_VECTORS 91 #elif defined(STM32F413xx) #define MCU_NUM_PERIPH_VECTORS 102 #else #error "Number of peripheral vectors not defined for this MCU." #endif #define NVIC_USER_IRQ_OFFSET 16 #define NVIC_NUM_VECTORS (16 + MCU_NUM_PERIPH_VECTORS) #include "stm32f4xx.h" #ifdef __cplusplus extern "C" { #endif void NVIC_Relocate(void); void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector); uint32_t NVIC_GetVector(IRQn_Type IRQn); #ifdef __cplusplus } #endif #endif
/* mbed Microcontroller Library - cmsis_nvic * Copyright (c) 2009-2011 ARM Limited. All rights reserved. * * CMSIS-style functionality to support dynamic vectors */ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H #include <stdint.h> #if defined(STM32F401xE) || defined(STM32F407xx) #define MCU_NUM_PERIPH_VECTORS 82 #elif defined(STM32F427xx) || defined(STM32F429xx) #define MCU_NUM_PERIPH_VECTORS 91 #elif defined(STM32F413xx) #define MCU_NUM_PERIPH_VECTORS 102 #else #error "Number of peripheral vectors not defined for this MCU." #endif #define NVIC_USER_IRQ_OFFSET 16 #define NVIC_NUM_VECTORS (16 + MCU_NUM_PERIPH_VECTORS) #include "stm32f4xx.h" #ifdef __cplusplus extern "C" { #endif void NVIC_Relocate(void); void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector); uint32_t NVIC_GetVector(IRQn_Type IRQn); #ifdef __cplusplus } #endif #endif
Add a stupid test (skipped) where goblint crashes.
// SKIP: Low Priority -- this compiles with warnings, but goblint crashes. #include <pthread.h> int data[10]; void *t_fun(int i) { int *x = &data[i]; return NULL; } int main() { pthread_t id; int n = 0; pthread_create(&id, NULL, t_fun, (int*) n); return 0; }
Correct off-by-one error in os_find_self on Linux
#define _XOPEN_SOURCE 500 #include "os_common.h" #include <unistd.h> #include <stdlib.h> char *os_find_self(const char *argv0) { (void)argv0; // PATH_MAX (used by readlink(2)) is not necessarily available size_t size = 2048, used = 0; char *path = NULL; do { size *= 2; path = realloc(path, size); used = readlink("/proc/self/exe", path, size); path[used - 1] = '\0'; } while (used >= size); // path has already been dereferencd - can't be NULL return path; }
#define _XOPEN_SOURCE 500 #include "os_common.h" #include <unistd.h> #include <stdlib.h> char *os_find_self(const char *argv0) { (void)argv0; // PATH_MAX (used by readlink(2)) is not necessarily available size_t size = 2048, used = 0; char *path = NULL; do { size *= 2; path = realloc(path, size); used = readlink("/proc/self/exe", path, size); path[used] = '\0'; } while (used >= size); // path has already been dereferencd - can't be NULL return path; }
Move discovery reply packet construction to the correct file
// homerun.h // HDHomeRun Wrapper #include <stdint.h> #include "libhdhomerun.h" #ifndef HOMERUN_H #define HOMERUN_H int verifyHomerunTuner(int); struct hdhomerun_discover_device_t getValidDevice(); #endif
// network.h // hdpirun // // HDHomeRun wrapper. Wraps library functionality for use // // Author: Robbie Duncan // Copyright: Copyright (c) 2016 Robbie Duncan // License: See LICENSE // #include <stdint.h> #include "libhdhomerun.h" // #ifndef HOMERUN_H #define HOMERUN_H int verifyHomerunTuner(int); // // Constructs a packet to use to respond to a discovery request. The caller is responsible for destroying the packet struct hdhomerun_pkt_t* getDiscoveryReplyPacket(); struct hdhomerun_discover_device_t getValidDevice(); #endif
Rename MBArtist to MbArtist to make it compile.
/* Get artist by id. * * Usage: * getartist 'artist id' * * $Id$ */ #include <stdio.h> #include <musicbrainz3/mb_c.h> int main(int argc, char **argv) { MBQuery query; MBArtist artist; char data[256]; if (argc < 2) { printf("Usage: getartist 'artist id'\n"); return 1; } mb_webservice_init(); query = mb_query_new(NULL, NULL); artist = mb_query_get_artist_by_id(query, argv[1], NULL); if (!artist) { printf("No artist returned.\n"); mb_query_free(query); return 1; } mb_artist_get_id(artist, data, 256); printf("Id : %s\n", data); mb_artist_get_type(artist, data, 256); printf("Type : %s\n", data); mb_artist_get_name(artist, data, 256); printf("Name : %s\n", data); mb_artist_get_sortname(artist, data, 256); printf("SortName: %s\n", data); mb_artist_free(artist); mb_query_free(query); return 0; }
/* Get artist by id. * * Usage: * getartist 'artist id' * * $Id$ */ #include <stdio.h> #include <musicbrainz3/mb_c.h> int main(int argc, char **argv) { MbQuery query; MbArtist artist; char data[256]; if (argc < 2) { printf("Usage: getartist 'artist id'\n"); return 1; } mb_webservice_init(); query = mb_query_new(NULL, NULL); artist = mb_query_get_artist_by_id(query, argv[1], NULL); if (!artist) { printf("No artist returned.\n"); mb_query_free(query); return 1; } mb_artist_get_id(artist, data, 256); printf("Id : %s\n", data); mb_artist_get_type(artist, data, 256); printf("Type : %s\n", data); mb_artist_get_name(artist, data, 256); printf("Name : %s\n", data); mb_artist_get_sortname(artist, data, 256); printf("SortName: %s\n", data); mb_artist_free(artist); mb_query_free(query); return 0; }
Use platform stdint.h and standard size_t printf format in newer versions of MSVC
/******************************************************************************* * Copyright 2014 Trevor Robinson * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ #include <stddef.h> // size_t #ifdef _MSC_VER typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; # define SIZE_T_FORMAT "%Iu" #else # include <stdint.h> # define SIZE_T_FORMAT "%zu" #endif
/******************************************************************************* * Copyright 2014 Trevor Robinson * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ #include <stddef.h> // size_t #if defined(_MSC_VER) && _MSC_VER < 1600 // stdint.h added in MSVC 2010 typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; #else # include <stdint.h> #endif #if defined(_MSC_VER) && _MSC_VER < 1900 // MSVC 2015 # define SIZE_T_FORMAT "%Iu" #else # define SIZE_T_FORMAT "%zu" #endif
Add flash writer code for STM32F3.
#include <libopencm3/stm32/flash.h> #include "flash_writer.h" #include <stdio.h> void flash_writer_unlock(void) { flash_unlock(); } void flash_writer_lock(void) { flash_lock(); } void flash_writer_page_erase(void *page) { flash_wait_for_last_operation(); FLASH_CR |= FLASH_CR_PER; FLASH_AR = (uint32_t) page; FLASH_CR |= FLASH_CR_STRT; flash_wait_for_last_operation(); FLASH_CR &= ~FLASH_CR_PER; } static void flash_write_half_word(uint16_t *flash, uint16_t half_word) { /* select flash programming */ FLASH_CR |= FLASH_CR_PG; /* perform half-word write */ *flash = half_word; flash_wait_for_last_operation(); } /* page address is assumed to be half-word aligned */ void flash_writer_page_write(void *page, void *data, size_t len) { uint8_t *bytes = (uint8_t *) data; uint16_t *flash = (uint16_t *) page; uint16_t half_word; flash_wait_for_last_operation(); size_t count; for (count = len; count > 1; count -= 2) { half_word = *bytes++; half_word |= (uint16_t)*bytes++ << 8; flash_write_half_word(flash++, half_word); } if (count == 1) { half_word = *bytes; /* preserve value of adjacent byte */ half_word |= (uint16_t)(*(uint8_t *)flash) << 8; flash_write_half_word(flash, half_word); } /* reset flags */ FLASH_CR &= ~FLASH_CR_PG; FLASH_SR |= FLASH_SR_EOP; }
Add setHeader to HTTPRequest API
#pragma once namespace Halley { class HTTPResponse { public: virtual ~HTTPResponse() {} virtual int getResponseCode() const = 0; virtual const Bytes& getBody() const = 0; }; class HTTPRequest { public: virtual ~HTTPRequest() {} virtual void setPostData(const String& contentType, const Bytes& data) = 0; virtual Future<std::unique_ptr<HTTPResponse>> send() = 0; }; class AuthorisationToken { public: virtual ~AuthorisationToken() {} virtual String getType() const = 0; virtual bool isSingleUse() const = 0; virtual bool isCancellable() const = 0; virtual void cancel() = 0; virtual const Bytes& getData() const = 0; }; class PlatformAPI { public: virtual ~PlatformAPI() {} virtual void update() = 0; virtual std::unique_ptr<HTTPRequest> makeHTTPRequest(const String& method, const String& url) = 0; virtual bool canProvideAuthToken() const = 0; virtual Future<std::unique_ptr<AuthorisationToken>> getAuthToken() = 0; }; }
#pragma once namespace Halley { class HTTPResponse { public: virtual ~HTTPResponse() {} virtual int getResponseCode() const = 0; virtual const Bytes& getBody() const = 0; }; class HTTPRequest { public: virtual ~HTTPRequest() {} virtual void setPostData(const String& contentType, const Bytes& data) = 0; virtual void setHeader(const String& headerName, const String& headerValue) = 0; virtual Future<std::unique_ptr<HTTPResponse>> send() = 0; }; class AuthorisationToken { public: virtual ~AuthorisationToken() {} virtual String getType() const = 0; virtual bool isSingleUse() const = 0; virtual bool isCancellable() const = 0; virtual void cancel() = 0; virtual const Bytes& getData() const = 0; }; class PlatformAPI { public: virtual ~PlatformAPI() {} virtual void update() = 0; virtual std::unique_ptr<HTTPRequest> makeHTTPRequest(const String& method, const String& url) = 0; virtual bool canProvideAuthToken() const = 0; virtual Future<std::unique_ptr<AuthorisationToken>> getAuthToken() = 0; }; }
Use periods, not semicolons between Copyright and All Rights Reserved.
/* Return the copyright string. This is updated manually. */ #include "Python.h" static char cprt[] = "Copyright (c) 2000 BeOpen.com; All Rights Reserved.\n\ Copyright (c) 1995-2000 Corporation for National Research Initiatives;\n\ All Rights Reserved.\n\ Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam;\n\ All Rights Reserved."; const char * Py_GetCopyright(void) { return cprt; }
/* Return the copyright string. This is updated manually. */ #include "Python.h" static char cprt[] = "Copyright (c) 2000 BeOpen.com. All Rights Reserved.\n\ Copyright (c) 1995-2000 Corporation for National Research Initiatives.\n\ All Rights Reserved.\n\ Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n\ All Rights Reserved."; const char * Py_GetCopyright(void) { return cprt; }
Add BSD 3-clause open source header
#ifndef _EVENT_H_ #define _EVENT_H_ #include "dataStackEntry.h" typedef struct event Event; Event *ev_create(char *name, char *eventData, unsigned long nAUs); Event *ev_reference(Event *event); void ev_release(Event *event); char *ev_data(Event *event); char *ev_topic(Event *event); int ev_theData(Event *event, DataStackEntry **dse); void ev_dump(Event *event); #endif /* _EVENT_H_ */
#ifndef _EVENT_H_ #define _EVENT_H_ /* * Copyright (c) 2013, Court of the University of Glasgow * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * - Neither the name of the University of Glasgow nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include "dataStackEntry.h" typedef struct event Event; Event *ev_create(char *name, char *eventData, unsigned long nAUs); Event *ev_reference(Event *event); void ev_release(Event *event); char *ev_data(Event *event); char *ev_topic(Event *event); int ev_theData(Event *event, DataStackEntry **dse); void ev_dump(Event *event); #endif /* _EVENT_H_ */
Remove macOS header from Win32 impl
// LAF OS Library // Copyright (C) 2018-2020 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. #ifndef OS_WIN_COLOR_SPACE_H_INCLUDED #define OS_WIN_COLOR_SPACE_H_INCLUDED #pragma once #include "os/color_space.h" #ifdef __OBJC__ #include <Cocoa/Cocoa.h> #endif #include <vector> namespace os { std::string get_hmonitor_icc_filename(HMONITOR monitor); os::ColorSpaceRef get_colorspace_from_icc_file(const std::string& iccFilename); os::ColorSpaceRef get_hmonitor_colorspace(HMONITOR monitor); void list_display_colorspaces(std::vector<os::ColorSpaceRef>& list); } // namespace os #endif
// LAF OS Library // Copyright (C) 2018-2021 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. #ifndef OS_WIN_COLOR_SPACE_H_INCLUDED #define OS_WIN_COLOR_SPACE_H_INCLUDED #pragma once #include "os/color_space.h" #include <vector> namespace os { std::string get_hmonitor_icc_filename(HMONITOR monitor); os::ColorSpaceRef get_colorspace_from_icc_file(const std::string& iccFilename); os::ColorSpaceRef get_hmonitor_colorspace(HMONITOR monitor); void list_display_colorspaces(std::vector<os::ColorSpaceRef>& list); } // namespace os #endif
Fix formatting to match libdispatch coding style.
/* * Copyright (c) 2013-2016 Apple Inc. All rights reserved. * * @APPLE_APACHE_LICENSE_HEADER_START@ * * 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. * * @APPLE_APACHE_LICENSE_HEADER_END@ */ #include "internal.h" #include "shims.h" #if !HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t size) { size_t res = strlen(dst) + strlen(src) + 1; if (size > 0) { size_t n = size - 1; strncpy(dst, src, n); dst[n] = 0; } return res; } #endif
/* * Copyright (c) 2013-2016 Apple Inc. All rights reserved. * * @APPLE_APACHE_LICENSE_HEADER_START@ * * 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. * * @APPLE_APACHE_LICENSE_HEADER_END@ */ #include "internal.h" #include "shims.h" #if !HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t size) { size_t res = strlen(dst) + strlen(src) + 1; if (size > 0) { size_t n = size - 1; strncpy(dst, src, n); dst[n] = 0; } return res; } #endif
Make the header more descriptive
#ifndef __RXE_H #define __RXE_H #define MAXBYTES 8 #define MAXBITS 64 void encrypt(char*, char *, char *); void decrypt(char*, char *, char *); #endif /* !__RXE_H */
#ifndef __RXE_H #define __RXE_H #define MAXBYTES 8 #define MAXBITS MAXBYTES*8 void encrypt(char* in, char *out, char *key); void decrypt(char* in, char *out, char *key); #endif /* !__RXE_H */
Revert "limozeen: Refine the BRD_ID check"
/* Copyright 2021 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "common.h" #include "sku.h" #include "system.h" #include "usbc_ppc.h" void board_hibernate(void) { int i; if (!board_is_clamshell()) { /* * Sensors are unpowered in hibernate. Apply PD to the * interrupt lines such that they don't float. */ gpio_set_flags(GPIO_ACCEL_GYRO_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); gpio_set_flags(GPIO_LID_ACCEL_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); } /* * Board rev 5+ has the hardware fix. Don't need the following * workaround. Limozeen's BRD_ID is not monotonically increasing. * 4 is the earliest revision. */ if ((system_get_board_version() >= 5) || (board_is_clamshell() && ((system_get_board_version() != 4)))) return; /* * Enable the PPC power sink path before EC enters hibernate; * otherwise, ACOK won't go High and can't wake EC up. Check the * bug b/170324206 for details. */ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) ppc_vbus_sink_enable(i, 1); }
/* Copyright 2021 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "common.h" #include "sku.h" #include "system.h" #include "usbc_ppc.h" void board_hibernate(void) { int i; if (!board_is_clamshell()) { /* * Sensors are unpowered in hibernate. Apply PD to the * interrupt lines such that they don't float. */ gpio_set_flags(GPIO_ACCEL_GYRO_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); gpio_set_flags(GPIO_LID_ACCEL_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); } /* * Board rev 5+ has the hardware fix. Don't need the following * workaround. */ if (system_get_board_version() >= 5) return; /* * Enable the PPC power sink path before EC enters hibernate; * otherwise, ACOK won't go High and can't wake EC up. Check the * bug b/170324206 for details. */ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) ppc_vbus_sink_enable(i, 1); }
Use jstreams namespace in macro definition (not everybody uses the "using" keyword.
#include "analyzerfactoryfactory.h" #ifdef STRIGI_IMPORT_API #ifdef WIN32 #define STRIGI_PLUGIN_API __declspec(dllexport) #else #define STRIGI_PLUGIN_API #endif #else #error "You should add STRIGI_IMPORT_API to the top of you plugin, you should not include this header if your code is not a plugin" #endif #define STRIGI_ANALYZER_FACTORY(CLASS) extern "C" { \ const AnalyzerFactoryFactory* getStrigiAnalyzerFactory() { \ return new CLASS(); \ } \ void deleteStrigiAnalyzerFactory(const AnalyzerFactoryFactory* f) { \ delete f; \ } \ }
#include "analyzerfactoryfactory.h" #ifdef STRIGI_IMPORT_API #ifdef WIN32 #define STRIGI_PLUGIN_API __declspec(dllexport) #else #define STRIGI_PLUGIN_API #endif #else #error "You should add STRIGI_IMPORT_API to the top of you plugin, you should not include this header if your code is not a plugin" #endif #define STRIGI_ANALYZER_FACTORY(CLASS) extern "C" { \ const jstreams::AnalyzerFactoryFactory* getStrigiAnalyzerFactory() { \ return new CLASS(); \ } \ void deleteStrigiAnalyzerFactory(const jstreams::AnalyzerFactoryFactory* f) { \ delete f; \ } \ }
Add primitive array to library header.
/* * BPFoundationExtensions.h * BPFoundation * * Created by Jon Olson on 7/9/09. * Copyright 2009 Ballistic Pigeon, LLC. All rights reserved. * */ #ifndef _BPFOUNDATION_EXTENSIONS_H_ #define _BPFOUNDATION_EXTENSIONS_H_ #import "NSArray+BPFoundationExtensions.h" #import "NSMutableArray+BPFoundationExtensions.h" #import "NSSet+BPFoundationExtensions.h" #import "NSDictionary+BPFoundationExtensions.h" #import "NSThread+BPFoundationExtensions.h" #endif
/* * BPFoundationExtensions.h * BPFoundation * * Created by Jon Olson on 7/9/09. * Copyright 2009 Ballistic Pigeon, LLC. All rights reserved. * */ #ifndef _BPFOUNDATION_EXTENSIONS_H_ #define _BPFOUNDATION_EXTENSIONS_H_ #import "NSArray+BPFoundationExtensions.h" #import "NSMutableArray+BPFoundationExtensions.h" #import "NSSet+BPFoundationExtensions.h" #import "NSDictionary+BPFoundationExtensions.h" #import "NSThread+BPFoundationExtensions.h" #import "BPPrimitiveArray.h" #endif
Add Duff's Device adaptation to test suite
int printf(const char *, ...); /* "Duff's Device", adapted from * https://groups.google.com/forum/#!msg/net.lang.c/3KFq-67DzdQ/TKl64DiBAGYJ */ void send(short *to, short *from, int count) { int n = (count + 7)/8; switch (count % 8) { case 0: do { *to += *from++; case 7: *to += *from++; case 6: *to += *from++; case 5: *to += *from++; case 4: *to += *from++; case 3: *to += *from++; case 2: *to += *from++; case 1: *to += *from++; } while (--n > 0); } } static int result(short *to, short *from, int count) { int i; for (i = 0; i < count; ++i) { printf("(%d, %d)", to[i], from[i]); if (i < count - 1) { printf(", "); } } printf("\n"); return 0; } static short p[16] = {1, 2, 3, 4, 5, 6, 7, 8, 3, 8, 5, 1, 0, 0, 9, 2}; static short q[16] = {4, 2, 7, 2, 1, 2, 5, 7, 2, 6, 8, 0, 4, 2, 6, 3}; int main(void) { send(p + 2, q, 16); send(p + 5, q, 13); send(p + 7, p, 5); return result(p, q, 16); }
Implement faster inverse square root function
#include <pal.h> /** * * Calculates the inverse square root of the input vector 'a'. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @param p Number of processor to use (task parallelism) * * @param team Team to work with ** * @return None * */ #include <math.h> void p_invsqrt_f32(const float *a, float *c, int n, int p, p_team_t team) { int i; for (i = 0; i < n; i++) { *(c + i) = 1.0f / sqrtf(*(a + i)); } }
#include <pal.h> /** * * Calculates the inverse square root of the input vector 'a'. * * This function uses a method of computing the inverse square root * made popular by the Quake 3 source code release. Chris Lomont has * provided an exhaustive analysis here: * http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @param p Number of processor to use (task parallelism) * * @param team Team to work with ** * @return None * */ #include <math.h> void p_invsqrt_f32(const float *a, float *c, int n, int p, p_team_t team) { // This union allows us to type-pun between integers and floats // with fewer strict aliasing concerns than the pointer casts // used in the original source. union { int32_t i; float f; } u; int i; for (i = 0; i < n; i++) { float x = *(a + i); float x2 = x * 0.5f; // Use some bit hacks to get a decent first approximation u.f = x; u.i = 0x5f375a86 - (u.i >> 1); x = u.f; // Perform a couple steps of Newton's method to refine our guess x = x * (1.5f - (x2 * x * x)); x = x * (1.5f - (x2 * x * x)); *(c + i) = x; } }
Reimplement InsertPointGuard to avoid LLVM ABI incompatibility.
#pragma once #include "preprocessor/llvm_includes_start.h" #include <llvm/IR/IRBuilder.h> #include "preprocessor/llvm_includes_end.h" namespace dev { namespace eth { namespace jit { class RuntimeManager; /// Base class for compiler helpers like Memory, GasMeter, etc. class CompilerHelper { protected: CompilerHelper(llvm::IRBuilder<>& _builder); CompilerHelper(const CompilerHelper&) = delete; CompilerHelper& operator=(CompilerHelper) = delete; /// Reference to the IR module being compiled llvm::Module* getModule(); /// Reference to the main module function llvm::Function* getMainFunction(); /// Reference to parent compiler IR builder llvm::IRBuilder<>& m_builder; llvm::IRBuilder<>& getBuilder() { return m_builder; } llvm::CallInst* createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args); friend class RuntimeHelper; }; /// Compiler helper that depends on runtime data class RuntimeHelper : public CompilerHelper { protected: RuntimeHelper(RuntimeManager& _runtimeManager); RuntimeManager& getRuntimeManager() { return m_runtimeManager; } private: RuntimeManager& m_runtimeManager; }; using InsertPointGuard = llvm::IRBuilderBase::InsertPointGuard; } } }
#pragma once #include "preprocessor/llvm_includes_start.h" #include <llvm/IR/IRBuilder.h> #include "preprocessor/llvm_includes_end.h" namespace dev { namespace eth { namespace jit { class RuntimeManager; /// Base class for compiler helpers like Memory, GasMeter, etc. class CompilerHelper { protected: CompilerHelper(llvm::IRBuilder<>& _builder); CompilerHelper(const CompilerHelper&) = delete; CompilerHelper& operator=(CompilerHelper) = delete; /// Reference to the IR module being compiled llvm::Module* getModule(); /// Reference to the main module function llvm::Function* getMainFunction(); /// Reference to parent compiler IR builder llvm::IRBuilder<>& m_builder; llvm::IRBuilder<>& getBuilder() { return m_builder; } llvm::CallInst* createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args); friend class RuntimeHelper; }; /// Compiler helper that depends on runtime data class RuntimeHelper : public CompilerHelper { protected: RuntimeHelper(RuntimeManager& _runtimeManager); RuntimeManager& getRuntimeManager() { return m_runtimeManager; } private: RuntimeManager& m_runtimeManager; }; struct InsertPointGuard { explicit InsertPointGuard(llvm::IRBuilderBase& _builder): m_builder(_builder), m_insertPoint(_builder.saveIP()) {} ~InsertPointGuard() { m_builder.restoreIP(m_insertPoint); } private: llvm::IRBuilderBase& m_builder; decltype(m_builder.saveIP()) m_insertPoint; }; } } }
Rename the implementation pointer to respect naming convention
#ifndef ENTRY_H #define ENTRY_H #include <string> #include <memory> namespace diaryengine { class Entry { public: Entry(); ~Entry(); void setTitle(std::string title); std::string title(); private: struct Implementation; std::unique_ptr<Implementation> inside_; }; } #endif // ENTRY_H
#ifndef ENTRY_H #define ENTRY_H #include <string> #include <memory> namespace diaryengine { class Entry { public: Entry(); ~Entry(); void setTitle(std::string title); std::string title(); private: struct Implementation; std::unique_ptr<Implementation> _inside; }; } #endif // ENTRY_H
Fix incorrect reporting of successful parsing. On branch master Your branch is ahead of 'github/master' by 3 commits. (use "git push" to publish your local commits)
/*! @file main.c @brief A simple test program for the C library code. */ #include "stdio.h" #include "verilog_parser.h" int main(int argc, char ** argv) { if(argc < 2) { printf("ERROR. Please supply at least one file path argument.\n"); return 1; } else { int F = 0; for(F = 1; F < argc; F++) { printf("%s", argv[F]);fflush(stdout); // Load the file. FILE * fh = fopen(argv[F], "r"); // Instance the parser. verilog_parser parser = verilog_file_parse(fh); printf(" parser built ");fflush(stdout); // Parse the file and store the result. int result = verilog_parse_buffer(parser); printf(" parser finished");fflush(stdout); verilog_free_parser(parser); printf(" parser freed");fflush(stdout); fclose(fh); if(result == 0) { printf(" - Parse successful\n"); } else { printf(" - Parse failed for\n"); } } } return 0; }
/*! @file main.c @brief A simple test program for the C library code. */ #include "stdio.h" #include "verilog_parser.h" int main(int argc, char ** argv) { if(argc < 2) { printf("ERROR. Please supply at least one file path argument.\n"); return 1; } else { int F = 0; for(F = 1; F < argc; F++) { printf("%s", argv[F]);fflush(stdout); // Load the file. FILE * fh = fopen(argv[F], "r"); // Instance the parser. verilog_parser parser = verilog_file_parse(fh); printf(" parser built ");fflush(stdout); // Parse the file and store the result. int result = verilog_parse_buffer(parser); printf(" parser finished");fflush(stdout); verilog_free_parser(parser); printf(" parser freed");fflush(stdout); fclose(fh); if(result == 0) { printf(" - Parse successful\n"); } else { printf(" - Parse failed for\n"); if(argc<=2) return 1; } } } return 0; }
Make sure stdout is flushed before trapping in panic
#include <stdarg.h> #include <stdio.h> #include <whitgl/logging.h> #define LOG_BUFFER_MAX (256) char _buffer[LOG_BUFFER_MAX]; void whitgl_logit(const char *file, const int line, const char *str, ...) { va_list args; va_start(args, str); vsnprintf(_buffer, LOG_BUFFER_MAX, str, args); printf("%24s:%03d %s\n", file, line, _buffer); } void whitgl_panic(const char *file, const int line, const char *str, ...) { va_list args; va_start(args, str); vsnprintf(_buffer, LOG_BUFFER_MAX, str, args); printf("PANIC %24s:%03d %s\n", file, line, _buffer); __builtin_trap(); }
#include <stdarg.h> #include <stdio.h> #include <whitgl/logging.h> #define LOG_BUFFER_MAX (256) char _buffer[LOG_BUFFER_MAX]; void whitgl_logit(const char *file, const int line, const char *str, ...) { va_list args; va_start(args, str); vsnprintf(_buffer, LOG_BUFFER_MAX, str, args); printf("%24s:%03d %s\n", file, line, _buffer); } void whitgl_panic(const char *file, const int line, const char *str, ...) { va_list args; va_start(args, str); vsnprintf(_buffer, LOG_BUFFER_MAX, str, args); printf("PANIC %24s:%03d %s\n", file, line, _buffer); fflush(stdout); __builtin_trap(); }
Remove unnecessarily public method from interface
// // NSManagedObject+JSONHelpers.h // // Created by Saul Mora on 6/28/11. // Copyright 2011 Magical Panda Software LLC. All rights reserved. // #import <CoreData/CoreData.h> extern NSString * const kMagicalRecordImportCustomDateFormatKey; extern NSString * const kMagicalRecordImportDefaultDateFormatString; extern NSString * const kMagicalRecordImportUnixTimeString; extern NSString * const kMagicalRecordImportAttributeKeyMapKey; extern NSString * const kMagicalRecordImportAttributeValueClassNameKey; extern NSString * const kMagicalRecordImportRelationshipMapKey; extern NSString * const kMagicalRecordImportRelationshipLinkedByKey; extern NSString * const kMagicalRecordImportRelationshipTypeKey; @interface NSManagedObject (MagicalRecord_DataImport) - (BOOL) MR_importValuesForKeysWithObject:(id)objectData; + (instancetype) MR_importFromObject:(id)data; + (instancetype) MR_importFromObject:(id)data inContext:(NSManagedObjectContext *)context; + (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData; + (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData inContext:(NSManagedObjectContext *)context; @end @interface NSManagedObject (MagicalRecord_DataImportControls) - (BOOL) shouldImport:(id)data; - (void) willImport:(id)data; - (void) didImport:(id)data; @end
// // NSManagedObject+JSONHelpers.h // // Created by Saul Mora on 6/28/11. // Copyright 2011 Magical Panda Software LLC. All rights reserved. // #import <CoreData/CoreData.h> extern NSString * const kMagicalRecordImportCustomDateFormatKey; extern NSString * const kMagicalRecordImportDefaultDateFormatString; extern NSString * const kMagicalRecordImportUnixTimeString; extern NSString * const kMagicalRecordImportAttributeKeyMapKey; extern NSString * const kMagicalRecordImportAttributeValueClassNameKey; extern NSString * const kMagicalRecordImportRelationshipMapKey; extern NSString * const kMagicalRecordImportRelationshipLinkedByKey; extern NSString * const kMagicalRecordImportRelationshipTypeKey; @interface NSManagedObject (MagicalRecord_DataImport) + (instancetype) MR_importFromObject:(id)data; + (instancetype) MR_importFromObject:(id)data inContext:(NSManagedObjectContext *)context; + (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData; + (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData inContext:(NSManagedObjectContext *)context; @end @interface NSManagedObject (MagicalRecord_DataImportControls) - (BOOL) shouldImport:(id)data; - (void) willImport:(id)data; - (void) didImport:(id)data; @end
Fix typo in umbrella header
// // TLLayoutTransitioning.h // TLLayoutTransitioning // // Created by Tim Moose on 6/29/15. // Copyright (c) 2015 Tractable Labs. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for TLLayoutTransitioning. FOUNDATION_EXPORT double TLLayoutTransitioningVersionNumber; //! Project version string for TLLayoutTransitioning. FOUNDATION_EXPORT const unsigned char TLLayoutTransitioningVersionString[]; <TLLayoutTransitioning/TLTransitionLayout.h> <TLLayoutTransitioning/UICollectionView+TLTransitioning.h>
// // TLLayoutTransitioning.h // TLLayoutTransitioning // // Created by Tim Moose on 6/29/15. // Copyright (c) 2015 Tractable Labs. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for TLLayoutTransitioning. FOUNDATION_EXPORT double TLLayoutTransitioningVersionNumber; //! Project version string for TLLayoutTransitioning. FOUNDATION_EXPORT const unsigned char TLLayoutTransitioningVersionString[]; #import <TLLayoutTransitioning/TLTransitionLayout.h> #import <TLLayoutTransitioning/UICollectionView+TLTransitioning.h>
Mend improper use of readlink(2)
#include <unistd.h> #include <limits.h> char *os_find_self(void) { // Using PATH_MAX is generally bad, but that's what readlink() says it uses. size_t size = PATH_MAX; char *path = malloc(size); if (readlink("/proc/self/exe", path, size) == 0) { return path; } else { free(path); return NULL; } }
#include <unistd.h> #include <stdlib.h> char *os_find_self(void) { // PATH_MAX (used by readlink(2)) is not necessarily available size_t size = 4096; char *path = malloc(size); size_t used = readlink("/proc/self/exe", path, size); // need strictly less than size, or else we probably truncated if (used < size) { return path; } else { free(path); return NULL; } }
Create an "include all" header for the project
// Copyright 2016 ELIFE. All rights reserved. // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. #pragma once #include <inform/dist.h> #include <inform/entropy.h> #include <inform/state_encoding.h> #include <inform/time_series.h>
Make Fragaria's text view delegate protocol compatible with NSTextViewDelegate.
// // MGSFragariaTextViewDelegate.h // Fragaria // // Created by Jim Derry on 2/22/15. // // /** * This protocol defines an interface for delegates that wish * to receive notifications from Fragaria's text view. **/ #pragma mark - MGSFragariaTextViewDelegate Protocol @protocol MGSFragariaTextViewDelegate <NSObject> @optional /** * This notification is send when the paste has been accepted. You can use * this delegate method to query the pasteboard for additional pasteboard content * that may be relevant to the application: eg: a plist that may contain custom data. * @param note is an NSNotification instance. **/ - (void)mgsTextDidPaste:(NSNotification *)note; @end
// // MGSFragariaTextViewDelegate.h // Fragaria // // Created by Jim Derry on 2/22/15. // // /** * This protocol defines an interface for delegates that wish * to receive notifications from Fragaria's text view. **/ #pragma mark - MGSFragariaTextViewDelegate Protocol @protocol MGSFragariaTextViewDelegate <NSTextViewDelegate> @optional /** * This notification is send when the paste has been accepted. You can use * this delegate method to query the pasteboard for additional pasteboard content * that may be relevant to the application: eg: a plist that may contain custom data. * @param note is an NSNotification instance. **/ - (void)mgsTextDidPaste:(NSNotification *)note; @end
Print N before computing F(N)
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "weecrypt.h" void print_factorial(unsigned n); int main(void) { char buf[512]; mpi_t fib; mpi_init(fib); while (printf("Enter N: ") && fgets(buf, sizeof(buf), stdin)) { unsigned n = (unsigned)strtoul(buf, NULL, 10); if (!n) break; print_factorial(n); } return 0; } void print_factorial(unsigned n) { mpi_t f; mpi_init_u32(f, n); for (unsigned m = 2; m < n; ++m) { mpi_mul_u32(f, m, f); } printf("%u! = ", n), mpi_print_dec(f), printf("\n"); printf("As double: %g\n", mpi_get_d(f)); mpi_free(f); }
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "weecrypt.h" void print_factorial(unsigned n); int main(void) { char buf[512]; mpi_t fib; mpi_init(fib); while (printf("Enter N: ") && fgets(buf, sizeof(buf), stdin)) { unsigned n = (unsigned)strtoul(buf, NULL, 10); if (!n) break; print_factorial(n); } return 0; } void print_factorial(unsigned n) { mpi_t f; mpi_init_u32(f, n); printf("%u! = ", n); fflush(stdout); for (unsigned m = 2; m < n; ++m) { mpi_mul_u32(f, m, f); } mpi_print_dec(f), printf("\n"); printf("As double: %g\n", mpi_get_d(f)); mpi_free(f); }
Include windows.h (indirectly) in all files
// Copyright 2012-2014 UX Productivity Pty Ltd // // 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 DocFormats_DFTypes_h #define DocFormats_DFTypes_h #ifdef _MSC_VER #define ATTRIBUTE_ALIGNED(n) #define ATTRIBUTE_FORMAT(archetype,index,first) #else #define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n))) #define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first))) #endif #ifdef WIN32 #define _CRT_SECURE_NO_WARNINGS #endif #include <sys/types.h> #include <stdint.h> #include <stdarg.h> #endif
// Copyright 2012-2014 UX Productivity Pty Ltd // // 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 DocFormats_DFTypes_h #define DocFormats_DFTypes_h #ifdef _MSC_VER #define ATTRIBUTE_ALIGNED(n) #define ATTRIBUTE_FORMAT(archetype,index,first) #else #define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n))) #define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first))) #endif #ifdef WIN32 #define _CRT_SECURE_NO_WARNINGS #include <windows.h> #endif #include <sys/types.h> #include <stdint.h> #include <stdarg.h> #endif
Remove use of compatibility macros in Cygwin-specific code.
/**************************************************************************/ /* */ /* OCaml */ /* */ /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ /* */ /* Copyright 1997 Institut National de Recherche en Informatique et */ /* en Automatique. */ /* */ /* All rights reserved. This file is distributed under the terms of */ /* the GNU Lesser General Public License version 2.1, with the */ /* special exception on linking described in the file LICENSE. */ /* */ /**************************************************************************/ #include <caml/fail.h> #include <caml/mlvalues.h> #include "unixsupport.h" #ifdef HAS_UNISTD #include <unistd.h> #endif CAMLprim value unix_setsid(value unit) { #ifdef HAS_SETSID return Val_int(setsid()); #else invalid_argument("setsid not implemented"); return Val_unit; #endif }
/**************************************************************************/ /* */ /* OCaml */ /* */ /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ /* */ /* Copyright 1997 Institut National de Recherche en Informatique et */ /* en Automatique. */ /* */ /* All rights reserved. This file is distributed under the terms of */ /* the GNU Lesser General Public License version 2.1, with the */ /* special exception on linking described in the file LICENSE. */ /* */ /**************************************************************************/ #include <caml/fail.h> #include <caml/mlvalues.h> #include "unixsupport.h" #ifdef HAS_UNISTD #include <unistd.h> #endif CAMLprim value unix_setsid(value unit) { #ifdef HAS_SETSID return Val_int(setsid()); #else caml_invalid_argument("setsid not implemented"); return Val_unit; #endif }
Simplify and fix test case
// SPDX-License-Identifier: Apache-2.0 // Copyright 2018 Eotvos Lorand University, Budapest, Hungary #include "test.h" fake_cmd_t t4p4s_testcase_test[][RTE_MAX_LCORE] = { { // table lookup hits {FAKE_PKT, 0, 1, FDATA("AA00"), 200, 123, FDATA("AA22")}, // table lookup misses {FAKE_PKT, 0, 1, FDATA("BB00"), 200, 123, FDATA("BB44")}, FEND, }, { FEND, }, }; testcase_t t4p4s_test_suite[MAX_TESTCASES] = { { "test", &t4p4s_testcase_test }, TEST_SUITE_END, };
// SPDX-License-Identifier: Apache-2.0 // Copyright 2018 Eotvos Lorand University, Budapest, Hungary #include "test.h" fake_cmd_t t4p4s_testcase_test[][RTE_MAX_LCORE] = SINGLE_LCORE( // table lookup hits FAST(1, 123, INOUT("AA00", "AA22")), WAIT_FOR_CTL, WAIT_FOR_CTL, WAIT_FOR_CTL, // table lookup misses FAST(1, 123, INOUT("BB00", "BB11")) ); testcase_t t4p4s_test_suite[MAX_TESTCASES] = { { "test", &t4p4s_testcase_test }, TEST_SUITE_END, };
Define a standard header for plug-ins
/* $Id$ */ /* Copyright (c) 2008-2014 Pierre Pronchery <khorben@defora.org> */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LIBSYSTEM_SYSTEM_PLUGIN_H # define LIBSYSTEM_SYSTEM_PLUGIN_H # include "string.h" /* Plugin */ typedef void Plugin; /* functions */ Plugin * plugin_new(String const * libdir, String const * package, String const * type, String const * name); Plugin * plugin_new_self(void); void plugin_delete(Plugin * plugin); /* useful */ void * plugin_lookup(Plugin * plugin, String const * symbol); #endif /* !LIBSYSTEM_SYSTEM_PLUGIN_H */
/* $Id$ */ /* Copyright (c) 2008-2014 Pierre Pronchery <khorben@defora.org> */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LIBSYSTEM_SYSTEM_PLUGIN_H # define LIBSYSTEM_SYSTEM_PLUGIN_H # include "license.h" # include "string.h" /* Plugin */ typedef void Plugin; typedef struct _PluginHeader { char const * name; char const * icon; char const * description; LicenseFlags license; } PluginHeader; /* functions */ Plugin * plugin_new(String const * libdir, String const * package, String const * type, String const * name); Plugin * plugin_new_self(void); void plugin_delete(Plugin * plugin); /* useful */ void * plugin_lookup(Plugin * plugin, String const * symbol); #endif /* !LIBSYSTEM_SYSTEM_PLUGIN_H */
Mark ContiguousMemoryRange::size as const. am: f2c28cd765 am: 1b5ab79b0b
/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #define INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #include <assert.h> #include <stddef.h> #include <stdint.h> namespace protozero { // Keep this struct trivially constructible (no ctors, no default initializers). struct ContiguousMemoryRange { uint8_t* begin; uint8_t* end; // STL style: one byte past the end of the buffer. inline bool is_valid() const { return begin != nullptr; } inline void reset() { begin = nullptr; } inline size_t size() { return static_cast<size_t>(end - begin); } }; } // namespace protozero #endif // INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_
/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #define INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_ #include <assert.h> #include <stddef.h> #include <stdint.h> namespace protozero { // Keep this struct trivially constructible (no ctors, no default initializers). struct ContiguousMemoryRange { uint8_t* begin; uint8_t* end; // STL style: one byte past the end of the buffer. inline bool is_valid() const { return begin != nullptr; } inline void reset() { begin = nullptr; } inline size_t size() const { return static_cast<size_t>(end - begin); } }; } // namespace protozero #endif // INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_
Fix calling conventions around CUDA.
#ifndef PRIMITIV_C_CUDA_DEVICE_H_ #define PRIMITIV_C_CUDA_DEVICE_H_ #include <primitiv/c/define.h> #include <primitiv/c/device.h> /** * Creates a new Device object. * @param device_id ID of the physical GPU. * @param device Pointer to receive a handler. * @return Status code. * @remarks The random number generator is initialized using * `std::random_device`. */ extern PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new( uint32_t device_id, primitiv_Device **device); /** * Creates a new Device object. * @param device_id ID of the physical GPU. * @param rng_seed The seed value of the random number generator. * @param device Pointer to receive a handler. * @return Status code. */ extern PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new_with_seed( uint32_t device_id, uint32_t rng_seed, primitiv_Device **device); /** * Retrieves the number of active hardwares. * @param num_devices Pointer to receive the number of active hardwares. * @return Status code. */ extern PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_num_devices( uint32_t *num_devices); #endif // PRIMITIV_C_CUDA_DEVICE_H_
#ifndef PRIMITIV_C_CUDA_DEVICE_H_ #define PRIMITIV_C_CUDA_DEVICE_H_ #include <primitiv/c/define.h> #include <primitiv/c/device.h> /** * Creates a new Device object. * @param device_id ID of the physical GPU. * @param device Pointer to receive a handler. * @return Status code. * @remarks The random number generator is initialized using * `std::random_device`. */ PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new( uint32_t device_id, primitiv_Device **device); /** * Creates a new Device object. * @param device_id ID of the physical GPU. * @param rng_seed The seed value of the random number generator. * @param device Pointer to receive a handler. * @return Status code. */ PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new_with_seed( uint32_t device_id, uint32_t rng_seed, primitiv_Device **device); /** * Retrieves the number of active hardwares. * @param num_devices Pointer to receive the number of active hardwares. * @return Status code. */ PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_num_devices( uint32_t *num_devices); #endif // PRIMITIV_C_CUDA_DEVICE_H_
Add MZBlurEffectAdapter.h to umbrella header
// // MZFormSheetPresentationControllerFramework.h // MZFormSheetPresentationControllerFramework // #import <UIKit/UIKit.h> //! Project version number for MZFormSheetPresentation. FOUNDATION_EXPORT double MZFormSheetPresentationControllerVersionNumber; //! Project version string for MZFormSheetPresentation. FOUNDATION_EXPORT const unsigned char MZFormSheetPresentationControllerVersionString[]; // In this header, you should import all the public headers of // your framework using statements like // #import <MZFormSheetPresentationController/PublicHeader.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationController.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewController.h> #import <MZFormSheetPresentationController/MZTransition.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerAnimator.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerAnimatedTransitioning.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerInteractiveAnimator.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerInteractiveTransitioning.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationContentSizing.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerSegue.h>
// // MZFormSheetPresentationControllerFramework.h // MZFormSheetPresentationControllerFramework // #import <UIKit/UIKit.h> //! Project version number for MZFormSheetPresentation. FOUNDATION_EXPORT double MZFormSheetPresentationControllerVersionNumber; //! Project version string for MZFormSheetPresentation. FOUNDATION_EXPORT const unsigned char MZFormSheetPresentationControllerVersionString[]; // In this header, you should import all the public headers of // your framework using statements like // #import <MZFormSheetPresentationController/PublicHeader.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationController.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewController.h> #import <MZFormSheetPresentationController/MZTransition.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerAnimator.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerAnimatedTransitioning.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerInteractiveAnimator.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerInteractiveTransitioning.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationContentSizing.h> #import <MZFormSheetPresentationController/MZFormSheetPresentationViewControllerSegue.h> #import <MZFormSheetPresentationController/MZBlurEffectAdapter.h>
Revert "Added moreItems boolean to data model for a group"
#import <Foundation/Foundation.h> @interface StatsGroup : NSObject @property (nonatomic, strong) NSArray *items; // StatsItem @property (nonatomic, assign) BOOL moreItemsExist; @property (nonatomic, copy) NSString *titlePrimary; @property (nonatomic, copy) NSString *titleSecondary; @property (nonatomic, strong) NSURL *iconUrl; @end
#import <Foundation/Foundation.h> @interface StatsGroup : NSObject @property (nonatomic, strong) NSArray *items; // StatsItem @property (nonatomic, copy) NSString *titlePrimary; @property (nonatomic, copy) NSString *titleSecondary; @property (nonatomic, strong) NSURL *iconUrl; @end
Remove unnecessary constructor from NotificationObserver.
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_OBSERVER_H_ #define CONTENT_PUBLIC_BROWSER_NOTIFICATION_OBSERVER_H_ #pragma once #include "content/common/content_export.h" namespace content { class NotificationDetails; class NotificationSource; // This is the base class for notification observers. When a matching // notification is posted to the notification service, Observe is called. class CONTENT_EXPORT NotificationObserver { public: virtual void Observe(int type, const NotificationSource& source, const NotificationDetails& details) = 0; protected: NotificationObserver() {} virtual ~NotificationObserver() {} }; } // namespace content #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_OBSERVER_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_OBSERVER_H_ #define CONTENT_PUBLIC_BROWSER_NOTIFICATION_OBSERVER_H_ #pragma once #include "content/common/content_export.h" namespace content { class NotificationDetails; class NotificationSource; // This is the base class for notification observers. When a matching // notification is posted to the notification service, Observe is called. class CONTENT_EXPORT NotificationObserver { public: virtual void Observe(int type, const NotificationSource& source, const NotificationDetails& details) = 0; protected: virtual ~NotificationObserver() {} }; } // namespace content #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_OBSERVER_H_
Replace direct video memory access with cputc() for character output.
/* * Challenger 1P Hello World Program for cc65. */ #include <conio.h> #define VIDEO_RAM_START ((char *) 0xd000) int main() { static const char hello_world[] = "Hello world!"; int scrpos; const char *cp; clrscr(); for (cp = hello_world, scrpos = 0x083; *cp; scrpos += 1, cp += 1) { *(VIDEO_RAM_START + scrpos) = *cp; } while (1) { char c = cgetc(); *(VIDEO_RAM_START + scrpos++) = c; } return 0; }
/* * Challenger 1P Hello World Program for cc65. */ #include <conio.h> #define VIDEO_RAM_START ((char *) 0xd000) int main() { static const char hello_world[] = "Hello world!\n"; const char *cp; unsigned int i; clrscr(); for (cp = hello_world; *cp; cp += 1) { cputc(*cp); } for (i = 0; i < 256; i += 1) { cputc((unsigned char ) i); } cputc(' '); cputc((char) wherex()); while (1) { char c = cgetc(); cputc(c); } return 0; }
Add 1160 solution, but it can be improved!
/** https://www.urionlinejudge.com.br/judge/en/problems/view/1160 TODO: Test this conjecture: Since f(x) is the number of inhabitants as a function of x years, such f is a function defined in natural numbers. Then f(x) = rx/100 + s, such that r and s are real (floating) constants, where r is the growing hate percentual (0<=r<=100) and s is the initial population in this experiment. TODO2 Test this conjecture: This loop can be turned into a recurrency relation (ie, a recursive function) TODO3 Test this conjecture: If TODO2 returns True, then this recurrency relation can be turned into a closed form (ie, a regular function). */ #include <stdio.h> int main(){ int testsQtt; int aPopulation, bPopulation; double aPercentualGrowing, bPercentualGrowing; scanf("%d", &testsQtt); char results[testsQtt]; int i, years; for (i = 0; i < testsQtt; i++){ scanf("%d %d %lf %lf", &aPopulation, &bPopulation, &aPercentualGrowing, &bPercentualGrowing); years = 0; while(aPopulation <= bPopulation){ years++; if (years > 100){ break; } aPopulation += (int) (aPopulation*aPercentualGrowing/100); bPopulation += (int) (bPopulation*bPercentualGrowing/100); } results[i] = years; } for (i = 0; i < testsQtt; i++){ if (results[i] > 100){ printf("Mais de 1 seculo.\n"); } else{ printf("%d anos.\n", results[i]); } } return 0; }
Add parentheses to make example clearer.
#include <stdio.h> typedef struct { int *x; int **y; } inner ; typedef struct { int *g; inner in[3]; } outer; int *ep; int main(int argc, char *argv[]) { outer o; int z = 5; int zzz; printf("%d\n" , z); ep = &z; o.in[2].x = ep; *o.in[2].x = 3; printf("%d\n" , z); inner i; i.x = &zzz; o.in[1] = i; int **ptr = &o.in[0].x; int *p = *ptr; /* outer oo[4]; */ /* oo[2].in[2].y = &ep; */ return 0; }
#include <stdio.h> typedef struct { int *x; int **y; } inner ; typedef struct { int *g; inner in[3]; } outer; int *ep; int main(int argc, char *argv[]) { outer o; int z = 5; int zzz; printf("%d\n" , z); ep = &z; o.in[2].x = ep; *(o.in[2].x) = 3; printf("%d\n" , z); inner i; i.x = &zzz; o.in[1] = i; int **ptr = &(o.in[0].x); int *p = *ptr; /* outer oo[4]; */ /* oo[2].in[2].y = &ep; */ return 0; }
Remove duplicate members so this compiles again
// // GrowlBezelWindowView.h // Display Plugins // // Created by Jorge Salvador Caffarena on 09/09/04. // Copyright 2004 Jorge Salvador Caffarena. All rights reserved. // #import <Cocoa/Cocoa.h> #import "GrowlNotificationView.h" @interface GrowlBezelWindowView : GrowlNotificationView { NSImage *icon; NSString *title; NSString *text; SEL action; id target; NSColor *textColor; NSColor *backgroundColor; NSLayoutManager *layoutManager; } - (void) setIcon:(NSImage *)icon; - (void) setTitle:(NSString *)title; - (void) setText:(NSString *)text; - (void) setPriority:(int)priority; - (float) descriptionHeight:(NSString *)text attributes:(NSDictionary *)attributes width:(float)width; - (id) target; - (void) setTarget:(id)object; - (SEL) action; - (void) setAction:(SEL)selector; @end
// // GrowlBezelWindowView.h // Display Plugins // // Created by Jorge Salvador Caffarena on 09/09/04. // Copyright 2004 Jorge Salvador Caffarena. All rights reserved. // #import <Cocoa/Cocoa.h> #import "GrowlNotificationView.h" @interface GrowlBezelWindowView : GrowlNotificationView { NSImage *icon; NSString *title; NSString *text; NSColor *textColor; NSColor *backgroundColor; NSLayoutManager *layoutManager; } - (void) setIcon:(NSImage *)icon; - (void) setTitle:(NSString *)title; - (void) setText:(NSString *)text; - (void) setPriority:(int)priority; - (float) descriptionHeight:(NSString *)text attributes:(NSDictionary *)attributes width:(float)width; - (id) target; - (void) setTarget:(id)object; - (SEL) action; - (void) setAction:(SEL)selector; @end
Add last file of main filter framework
/* * filter registration * copyright (c) 2008 Vitor Sessak * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avfilter.h" #define REGISTER_VF(X,x) { \ extern AVFilter avfilter_vf_##x ; \ if(ENABLE_VF_##X ) avfilter_register(&avfilter_vf_##x ); } #define REGISTER_VSRC(X,x) { \ extern AVFilter avfilter_vsrc_##x ; \ if(ENABLE_VSRC_##X ) avfilter_register(&avfilter_vsrc_##x ); } void avfilter_register_all(void) { static int initialized; if (initialized) return; initialized = 1; // REGISTER_VF(CROP,crop); }
Add missing newlines to DSFYDEBUG() calls
#include <spotify/api.h> #include "debug.h" #include "sp_opaque.h" SP_LIBEXPORT(const char *) sp_user_canonical_name(sp_user *user) { DSFYDEBUG("FIXME: Not yet implemented"); return "not-yet-implemented"; } SP_LIBEXPORT(const char *) sp_user_display_name(sp_user *user) { DSFYDEBUG("FIXME: Not yet implemented"); return "not-yet-implemented"; } SP_LIBEXPORT(bool) sp_user_is_loaded(sp_user *user) { DSFYDEBUG("FIXME: Not yet implemented"); return 0; }
#include <spotify/api.h> #include "debug.h" #include "sp_opaque.h" SP_LIBEXPORT(const char *) sp_user_canonical_name(sp_user *user) { DSFYDEBUG("FIXME: Not yet implemented\n"); return "not-yet-implemented"; } SP_LIBEXPORT(const char *) sp_user_display_name(sp_user *user) { DSFYDEBUG("FIXME: Not yet implemented\n"); return "not-yet-implemented"; } SP_LIBEXPORT(bool) sp_user_is_loaded(sp_user *user) { DSFYDEBUG("FIXME: Not yet implemented\n"); return 0; }
Make |ZoneVector| constructor to take const reference.
// Copyright 2014 Project Vogue. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ELANG_BASE_ZONE_VECTOR_H_ #define ELANG_BASE_ZONE_VECTOR_H_ #include <vector> #include "elang/base/zone.h" #include "elang/base/zone_allocator.h" namespace elang { ////////////////////////////////////////////////////////////////////// // // ZoneVector // A wrapper subclass for |std::vector|. // template <typename T> class ZoneVector : public std::vector<T, ZoneAllocator<T>> { public: explicit ZoneVector(Zone* zone) : std::vector<T, ZoneAllocator<T>>(ZoneAllocator<T>(zone)) {} ZoneVector(Zone* zone, size_t size, value_type& val = value_type()) : std::vector<T, ZoneAllocator<T>>(size, val, ZoneAllocator<T>(zone)) {} ZoneVector(Zone* zone, const std::vector<T>& other) : std::vector<T, ZoneAllocator<T>>(other.begin(), other.end(), ZoneAllocator<T>(zone)) {} }; } // namespace elang #endif // ELANG_BASE_ZONE_VECTOR_H_
// Copyright 2014 Project Vogue. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ELANG_BASE_ZONE_VECTOR_H_ #define ELANG_BASE_ZONE_VECTOR_H_ #include <vector> #include "elang/base/zone.h" #include "elang/base/zone_allocator.h" namespace elang { ////////////////////////////////////////////////////////////////////// // // ZoneVector // A wrapper subclass for |std::vector|. // template <typename T> class ZoneVector : public std::vector<T, ZoneAllocator<T>> { public: explicit ZoneVector(Zone* zone) : std::vector<T, ZoneAllocator<T>>(ZoneAllocator<T>(zone)) {} ZoneVector(Zone* zone, size_t size, const value_type& val = value_type()) : std::vector<T, ZoneAllocator<T>>(size, val, ZoneAllocator<T>(zone)) {} ZoneVector(Zone* zone, const std::vector<T>& other) : std::vector<T, ZoneAllocator<T>>(other.begin(), other.end(), ZoneAllocator<T>(zone)) {} }; } // namespace elang #endif // ELANG_BASE_ZONE_VECTOR_H_
Fix compilation on posix platforms
#include <time.h> #include "clock.h" #include "clock_type.h" extern int clock_init(struct Clock **clockp, struct Allocator *allocator) { struct timespec res; if (clock_getres(CLOCK_MONOTONIC, &res) != 0 || res.tv_nsec > 1000) { /* unknown clock or insufficient resolution */ return -1; } return clock_init_base(clockp, allocator, 1, 1000); } extern uint64_t clock_ticks(struct Clock const *const clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); (void)clock; return ts.tv_sec * 1000000000LL + ts.tv_nsec; }
#include <time.h> #include "clock.h" #include "clock_type.h" extern int clock_init(struct SPDR_Clock **clockp, struct SPDR_Allocator *allocator) { struct timespec res; if (clock_getres(CLOCK_MONOTONIC, &res) != 0 || res.tv_nsec > 1000) { /* unknown clock or insufficient resolution */ return -1; } return clock_init_base(clockp, allocator, 1, 1000); } extern uint64_t clock_ticks(struct SPDR_Clock const *const clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); (void)clock; return ts.tv_sec * 1000000000LL + ts.tv_nsec; }
Work around incompatibility of warn_unused_result on one machine.
#include <format.h> #include <string.h> /* strlen */ #include <output.h> #include <unistd.h> /* write */ /* Initially we put data to stdout. */ int cur_out = 1; /* Put data to current output. */ void putd(const char *data, unsigned long len) { (void)write(cur_out,data,len); } void put(const char *data) { putd(data, strlen(data)); } void put_ch(char ch) { char buf[1]; buf[0] = ch; putd(buf,1); } void put_long(long x) { put(format_long(x)); } void put_ulong(unsigned long x) { put(format_ulong(x)); } void put_double(double x) { put(format_double(x)); } void nl(void) { putd("\n",1); } void set_output(int fd) { fsync(cur_out); cur_out = fd; } void put_to_error(void) { set_output(2); }
#include <format.h> #include <string.h> /* strlen */ #include <output.h> #include <unistd.h> /* write */ /* Initially we put data to stdout. */ int cur_out = 1; /* Put data to current output. */ void putd(const char *data, unsigned long len) { ssize_t n = write(cur_out,data,len); (void)n; } void put(const char *data) { putd(data, strlen(data)); } void put_ch(char ch) { char buf[1]; buf[0] = ch; putd(buf,1); } void put_long(long x) { put(format_long(x)); } void put_ulong(unsigned long x) { put(format_ulong(x)); } void put_double(double x) { put(format_double(x)); } void nl(void) { putd("\n",1); } void set_output(int fd) { fsync(cur_out); cur_out = fd; } void put_to_error(void) { set_output(2); }
Convert from double to signed data type for reference hamming distance.
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once namespace vespalib::eval { inline double hamming_distance(double a, double b) { uint8_t x = (uint8_t) a; uint8_t y = (uint8_t) b; return __builtin_popcount(x ^ y); } }
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once namespace vespalib::eval { inline double hamming_distance(double a, double b) { uint8_t x = (uint8_t) (int8_t) a; uint8_t y = (uint8_t) (int8_t) b; return __builtin_popcount(x ^ y); } }
Fix comment at top of file to match file name.
/* File: connection.h * * Description: See "md.h" * * Comments: See "notice.txt" for copyright and license information. * */ #ifndef __MD5_H__ #define __MD5_H__ #include "psqlodbc.h" #include <stdlib.h> #include <string.h> #ifdef WIN32 #define MD5_ODBC #define FRONTEND #endif #define MD5_PASSWD_LEN 35 /* From c.h */ #ifndef __BEOS__ #ifndef __cplusplus #ifndef bool typedef char bool; #endif #ifndef true #define true ((bool) 1) #endif #ifndef false #define false ((bool) 0) #endif #endif /* not C++ */ #endif /* __BEOS__ */ /* Also defined in include/c.h */ #if SIZEOF_UINT8 == 0 typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ #endif /* SIZEOF_UINT8 == 0 */ extern bool md5_hash(const void *buff, size_t len, char *hexsum); extern bool EncryptMD5(const char *passwd, const char *salt, size_t salt_len, char *buf); #endif
/* File: md5.h * * Description: See "md5.c" * * Comments: See "notice.txt" for copyright and license information. * */ #ifndef __MD5_H__ #define __MD5_H__ #include "psqlodbc.h" #include <stdlib.h> #include <string.h> #ifdef WIN32 #define MD5_ODBC #define FRONTEND #endif #define MD5_PASSWD_LEN 35 /* From c.h */ #ifndef __BEOS__ #ifndef __cplusplus #ifndef bool typedef char bool; #endif #ifndef true #define true ((bool) 1) #endif #ifndef false #define false ((bool) 0) #endif #endif /* not C++ */ #endif /* __BEOS__ */ /* Also defined in include/c.h */ #if SIZEOF_UINT8 == 0 typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ #endif /* SIZEOF_UINT8 == 0 */ extern bool md5_hash(const void *buff, size_t len, char *hexsum); extern bool EncryptMD5(const char *passwd, const char *salt, size_t salt_len, char *buf); #endif
Move file closer out from public.
#pragma once #include <memory> #include <cstdio> // fopen, fclose #include <openssl/evp.h> #include <openssl/ec.h> namespace JWTXX { namespace Utils { struct FileCloser { void operator()(FILE* fp) { fclose(fp); } }; typedef std::unique_ptr<FILE, FileCloser> FilePtr; struct EVPKeyDeleter { void operator()(EVP_PKEY* key) { EVP_PKEY_free(key); } }; typedef std::unique_ptr<EVP_PKEY, EVPKeyDeleter> EVPKeyPtr; struct EVPMDCTXDeleter { void operator()(EVP_MD_CTX* ctx) { EVP_MD_CTX_destroy(ctx); } }; typedef std::unique_ptr<EVP_MD_CTX, EVPMDCTXDeleter> EVPMDCTXPtr; EVPKeyPtr readPEMPrivateKey(const std::string& fileName); EVPKeyPtr readPEMPublicKey(const std::string& fileName); std::string OPENSSLError(); } }
#pragma once #include <memory> #include <cstdio> // fopen, fclose #include <openssl/evp.h> #include <openssl/ec.h> namespace JWTXX { namespace Utils { struct EVPKeyDeleter { void operator()(EVP_PKEY* key) { EVP_PKEY_free(key); } }; typedef std::unique_ptr<EVP_PKEY, EVPKeyDeleter> EVPKeyPtr; struct EVPMDCTXDeleter { void operator()(EVP_MD_CTX* ctx) { EVP_MD_CTX_destroy(ctx); } }; typedef std::unique_ptr<EVP_MD_CTX, EVPMDCTXDeleter> EVPMDCTXPtr; EVPKeyPtr readPEMPrivateKey(const std::string& fileName); EVPKeyPtr readPEMPublicKey(const std::string& fileName); std::string OPENSSLError(); } }