text
stringlengths
4
6.14k
/* variance_AD.c -- Adjoint of the lateral variance of outgoing photons Copyright (C) 2011 Robin Hogan <r.j.hogan@reading.ac.uk> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <math.h> #include "ms.h" /* Adjoint of the calculation of the lateral variance of the outgoing unscattered and forward-scattered photon distribution */ int ms_variance_AD(int n, ms_real wavelength, ms_real rho_laser, ms_real inst_altitude, const ms_real *range, const ms_real *radius, const ms_real *ext, ms_real *variance_out, ms_real *variance_AD, ms_real *radius_AD, ms_real *ext_AD) { ms_real angle_var = rho_laser*rho_laser; ms_real covar = fabs(range[0]-inst_altitude)*angle_var; variance_out[0] = (range[0]-inst_altitude)*(range[0]-inst_altitude)*angle_var; int i; for (i = 0; i < n-1; i++) { ms_real drange = ms_get_drange(i, n, range); ms_real theta = wavelength/(MS_PI*radius[i]); variance_out[i+1] = variance_out[i] + angle_var*drange*drange + covar*drange; covar += angle_var*drange; angle_var += 0.5*ext[i]*theta*theta*drange; } /* ADJOINT CALCULATION */ ms_real angle_var_AD = 0.0; ms_real covar_AD = 0.0; for (i = n-2; i >= 0; i--) { ms_real drange = ms_get_drange(i, n, range); ms_real theta = wavelength/(MS_PI*radius[i]); ms_real theta_AD = 0.0; /* Need to be careful with the order here so that the *_AD variables can be reused */ ext_AD[i] += angle_var_AD*0.5*theta*theta*drange; theta_AD += theta*drange*ext[i]*angle_var_AD; radius_AD[i] -= theta_AD*theta/radius[i]; angle_var_AD += covar_AD*drange + variance_AD[i+1]*drange*drange; covar_AD += variance_AD[i+1]*drange; variance_AD[i] += variance_AD[i+1]; variance_AD[i+1] = 0.0; } return MS_SUCCESS; }
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_SHADER_PROGRAMS_MAC_H_ #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_SHADER_PROGRAMS_MAC_H_ #include <OpenGL/gl.h> #include "base/basictypes.h" namespace content { // Provides caching of the compile-and-link step for shader programs at runtime // since, once compiled and linked, the programs can be shared. Callers invoke // one of the UseXXX() methods within a GL context to glUseProgram() the program // and have its uniform variables bound with the given parameters. class CompositingIOSurfaceShaderPrograms { public: CompositingIOSurfaceShaderPrograms(); ~CompositingIOSurfaceShaderPrograms(); // Reset the cache, deleting any references to currently-cached shader // programs. This must be called within an active OpenGL context just before // destruction. void Reset(); // Begin using the "blit" program, which is set up to sample the texture at // GL_TEXTURE_0. Returns false on error. bool UseBlitProgram(); // Begin using the program that just draws solid white very efficiently. // Returns false on error. bool UseSolidWhiteProgram(); // Begin using one of the two RGB-to-YV12 color conversion programs, as // specified by |pass_number| 1 or 2. The programs will sample the texture at // GL_TEXTURE0, and account for scaling in the X direction by |texel_scale_x|. // Returns false on error. bool UseRGBToYV12Program(int pass_number, float texel_scale_x); private: enum { kNumShaderPrograms = 4 }; // Helper methods to cache uniform variable locations. GLuint GetShaderProgram(int which); void BindUniformTextureVariable(int which, int texture_unit_offset); void BindUniformTexelScaleXVariable(int which, float texel_scale_x); // Cached values for previously-compiled/linked shader programs, and the // locations of their uniform variables. GLuint shader_programs_[kNumShaderPrograms]; GLint texture_var_locations_[kNumShaderPrograms]; GLint texel_scale_x_var_locations_[kNumShaderPrograms]; DISALLOW_COPY_AND_ASSIGN(CompositingIOSurfaceShaderPrograms); }; } // namespace content #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_SHADER_PROGRAMS_MAC_H_
// Copyright 2020 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 THIRD_PARTY_BLINK_PUBLIC_COMMON_PRIVACY_BUDGET_IDENTIFIABILITY_STUDY_SETTINGS_H_ #define THIRD_PARTY_BLINK_PUBLIC_COMMON_PRIVACY_BUDGET_IDENTIFIABILITY_STUDY_SETTINGS_H_ #include <memory> #include "third_party/blink/public/common/common_export.h" #include "third_party/blink/public/common/privacy_budget/identifiability_study_settings_provider.h" #include "third_party/blink/public/common/privacy_budget/identifiable_surface.h" #include "third_party/blink/public/mojom/web_feature/web_feature.mojom-forward.h" namespace blink { // Determines whether the identifiability study is active and if so whether a // given surface or surface type should be sampled. // // This class can used from multiple threads and does not require // synchronization. // // See documentation on individual methods for notes on thread safety. // // Guidelines for when and how to use it can be found in: // // //docs/privacy_budget/privacy_budget_instrumentation.md#gating // class BLINK_COMMON_EXPORT IdentifiabilityStudySettings { public: // Constructs a default IdentifiabilityStudySettings instance. By default the // settings instance acts as if the study is disabled, and implicitly as if // all surfaces and types are blocked. IdentifiabilityStudySettings(); // Constructs a IdentifiabilityStudySettings instance which reflects the state // specified by |provider|. explicit IdentifiabilityStudySettings( std::unique_ptr<IdentifiabilityStudySettingsProvider> provider); ~IdentifiabilityStudySettings(); // Get a pointer to an instance of IdentifiabilityStudySettings for the // process. // // This method and the returned object is safe to use from any thread and is // never destroyed. // // On the browser process, the returned instance is authoritative. On all // other processes the returned instance should be considered advisory. It's // only meant as an optimization to avoid calculating things unnecessarily. static const IdentifiabilityStudySettings* Get(); // Initialize the process-wide settings instance with the specified settings // provider. Should only be called once per process and only from the main // thread. // // For testing, you can use ResetStateForTesting(). static void SetGlobalProvider( std::unique_ptr<IdentifiabilityStudySettingsProvider> provider); // Returns true if the study is active for this client. Once if it returns // true, it doesn't return false at any point after. The converse is not true. bool IsActive() const; // Returns true if |surface| is allowed. // // Will always return false if IsActive() is false. I.e. If the study is // inactive, all surfaces are considered to be blocked. Hence it is sufficient // to call this function directly instead of calling IsActive() before it. bool IsSurfaceAllowed(IdentifiableSurface surface) const; // Returns true if |type| is allowed. // // Will always return false if IsActive() is false. I.e. If the study is // inactive, all surface types are considered to be blocked. Hence it is // sufficient to call this function directly instead of calling IsActive() // before it. bool IsTypeAllowed(IdentifiableSurface::Type type) const; // Returns true if |surface| should be sampled. // // Will always return false if IsActive() is false or if IsSurfaceAllowed() is // false. I.e. If the study is inactive, all surfaces are considered to be // blocked. Hence it is sufficient to call this function directly instead of // calling IsActive() before it. bool ShouldSample(IdentifiableSurface surface) const; // Returns true if |type| should be sampled. // // Will always return false if IsActive() is false or if IsTypeAllowed() is // false. I.e. If the study is inactive, all surface types are considered to // be blocked. Hence it is sufficient to call this function directly instead // of calling IsActive() before it. bool ShouldSample(IdentifiableSurface::Type type) const; // Convenience method for determining whether the surface constructable from // the type (|kWebFeature|) and the |feature| is allowed. See IsSurfaceAllowed // for more detail. bool IsWebFeatureAllowed(mojom::WebFeature feature) const; // Only used for testing. Resets internal state and violates API contracts // made above about the lifetime of IdentifiabilityStudySettings*. static void ResetStateForTesting(); IdentifiabilityStudySettings(IdentifiabilityStudySettings&&) = delete; IdentifiabilityStudySettings(const IdentifiabilityStudySettings&) = delete; IdentifiabilityStudySettings& operator=(const IdentifiabilityStudySettings&) = delete; private: const std::unique_ptr<IdentifiabilityStudySettingsProvider> provider_; const bool is_enabled_ = false; const bool is_any_surface_or_type_blocked_ = false; }; } // namespace blink #endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_PRIVACY_BUDGET_IDENTIFIABILITY_STUDY_SETTINGS_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 MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ #define MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ #include "base/memory/scoped_ptr.h" #include "base/process/launch.h" #include "build/build_config.h" #include "mojo/edk/embedder/scoped_platform_handle.h" #include "mojo/edk/system/system_impl_export.h" #include "mojo/public/cpp/system/macros.h" namespace base { class CommandLine; } namespace mojo { namespace edk { // It would be nice to refactor base/process/launch.h to have a more platform- // independent way of representing handles that are passed to child processes. #if defined(OS_WIN) using HandlePassingInformation = base::HandlesToInheritVector; #elif defined(OS_POSIX) using HandlePassingInformation = base::FileHandleMappingVector; #else #error "Unsupported." #endif // This is used to create a pair of |PlatformHandle|s that are connected by a // suitable (platform-specific) bidirectional "pipe" (e.g., socket on POSIX, // named pipe on Windows). The resulting handles can then be used in the same // process (e.g., in tests) or between processes. (The "server" handle is the // one that will be used in the process that created the pair, whereas the // "client" handle is the one that will be used in a different process.) // // This class provides facilities for passing the client handle to a child // process. The parent should call |PrepareToPassClientHandlelToChildProcess()| // to get the data needed to do this, spawn the child using that data, and then // call |ChildProcessLaunched()|. Note that on Windows this facility (will) only // work on Vista and later (TODO(vtl)). // // Note: |PlatformChannelPair()|, |PassClientHandleFromParentProcess()| and // |PrepareToPassClientHandleToChildProcess()| have platform-specific // implementations. // // Note: On POSIX platforms, to write to the "pipe", use // |PlatformChannel{Write,Writev}()| (from platform_channel_utils_posix.h) // instead of |write()|, |writev()|, etc. Otherwise, you have to worry about // platform differences in suppressing |SIGPIPE|. class MOJO_SYSTEM_IMPL_EXPORT PlatformChannelPair { public: // If |client_is_blocking| is true, then the client handle only supports // blocking reads and writes. The default is nonblocking. PlatformChannelPair(bool client_is_blocking = false); ~PlatformChannelPair(); ScopedPlatformHandle PassServerHandle(); // For in-process use (e.g., in tests or to pass over another channel). ScopedPlatformHandle PassClientHandle(); // To be called in the child process, after the parent process called // |PrepareToPassClientHandleToChildProcess()| and launched the child (using // the provided data), to create a client handle connected to the server // handle (in the parent process). static ScopedPlatformHandle PassClientHandleFromParentProcess( const base::CommandLine& command_line); // Like above, but gets the handle from the passed in string. static ScopedPlatformHandle PassClientHandleFromParentProcessFromString( const std::string& value); // Prepares to pass the client channel to a new child process, to be launched // using |LaunchProcess()| (from base/launch.h). Modifies |*command_line| and // |*handle_passing_info| as needed. // Note: For Windows, this method only works on Vista and later. void PrepareToPassClientHandleToChildProcess( base::CommandLine* command_line, HandlePassingInformation* handle_passing_info) const; // Like above, but returns a string instead of changing the command line. std::string PrepareToPassClientHandleToChildProcessAsString( HandlePassingInformation* handle_passing_info) const; // To be called once the child process has been successfully launched, to do // any cleanup necessary. void ChildProcessLaunched(); private: static const char kMojoPlatformChannelHandleSwitch[]; ScopedPlatformHandle server_handle_; ScopedPlatformHandle client_handle_; MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformChannelPair); }; } // namespace edk } // namespace mojo #endif // MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_
/* * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef SQUID_CACHEMANAGER_H #define SQUID_CACHEMANAGER_H #include "comm/forward.h" #include "mgr/Action.h" #include "mgr/ActionProfile.h" #include "mgr/Command.h" #include "mgr/forward.h" #include "typedefs.h" #include <vector> /** \defgroup CacheManagerAPI Cache Manager API \ingroup Components * \defgroup CacheManagerInternal Cache Manager intenal API (not for public use) \ingroup CacheManagerAPI */ class HttpRequest; namespace Mgr { class ActionPasswordList; } //namespace Mgr /** \ingroup CacheManagerAPI * a CacheManager - the menu system for interacting with squid. * This is currently just an adapter to the global cachemgr* routines to * provide looser coupling between modules, but once fully transitioned, * an instance of this class will represent a single independent manager. * TODO: update documentation to reflect the new singleton model. */ class CacheManager { public: typedef std::vector<Mgr::ActionProfilePointer> Menu; void registerProfile(char const * action, char const * desc, OBJH * handler, int pw_req_flag, int atomic); void registerProfile(char const * action, char const * desc, Mgr::ClassActionCreationHandler *handler, int pw_req_flag, int atomic); Mgr::ActionProfilePointer findAction(char const * action) const; Mgr::Action::Pointer createNamedAction(const char *actionName); Mgr::Action::Pointer createRequestedAction(const Mgr::ActionParams &); const Menu& menu() const { return menu_; } void Start(const Comm::ConnectionPointer &client, HttpRequest * request, StoreEntry * entry); static CacheManager* GetInstance(); const char *ActionProtection(const Mgr::ActionProfilePointer &profile); protected: CacheManager() {} ///< use Instance() instead Mgr::CommandPointer ParseUrl(const char *url); void ParseHeaders(const HttpRequest * request, Mgr::ActionParams &params); int CheckPassword(const Mgr::Command &cmd); char *PasswdGet(Mgr::ActionPasswordList *, const char *); void registerProfile(const Mgr::ActionProfilePointer &profile); Menu menu_; private: static CacheManager* instance; }; #endif /* SQUID_CACHEMANAGER_H */
#ifndef THEANO_MOD_HELPER #define THEANO_MOD_HELPER #include <Python.h> #ifndef _WIN32 #define MOD_PUBLIC __attribute__((visibility ("default"))) #else /* MOD_PUBLIC is only used in PyMODINIT_FUNC, which is declared * and implemented in mod.cu/cpp, not in headers, so dllexport * is always correct. */ #define MOD_PUBLIC __declspec( dllexport ) #endif #ifdef __cplusplus #define THEANO_EXTERN extern "C" #else #define THEANO_EXTERN #endif #if PY_MAJOR_VERSION < 3 #define THEANO_RTYPE void #else #define THEANO_RTYPE PyObject * #endif /* We need to redefine PyMODINIT_FUNC to add MOD_PUBLIC in the middle */ #undef PyMODINIT_FUNC #define PyMODINIT_FUNC THEANO_EXTERN MOD_PUBLIC THEANO_RTYPE #endif
/* * This file is part of the coreboot project. * * Copyright 2013 Google Inc. * Copyright (C) 2012 Samsung Electronics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 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 General Public License for more details. */ #include <arch/io.h> #include <soc/trustzone.h> /* Setting TZPC[TrustZone Protection Controller] * We pretty much disable it all, as the kernel * expects it that way -- and that's not the default. */ void trustzone_init(void) { struct exynos_tzpc *tzpc; unsigned int addr; for (addr = TZPC10_BASE; addr <= TZPC9_BASE; addr += TZPC_BASE_OFFSET) { tzpc = (struct exynos_tzpc *)addr; if (addr == TZPC0_BASE) write32(&tzpc->r0size, R0SIZE); write32(&tzpc->decprot0set, DECPROTXSET); write32(&tzpc->decprot1set, DECPROTXSET); write32(&tzpc->decprot2set, DECPROTXSET); write32(&tzpc->decprot3set, DECPROTXSET); } }
/* * RAZE-x86 Z80 emulator. * * Copyright (c) 1999 Richard Mitton * * This may only be distributed as part of the complete RAZE package. * See RAZE.TXT for license information. */ #ifndef __RAZE_H_INCLUDED__ #define __RAZE_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif /* Fix this as you need it */ #ifndef UBYTE #define UBYTE unsigned char #endif #ifndef UWORD #define UWORD unsigned short #endif /* Memory map constants */ #define Z80_MAP_DIRECT 0 /* Reads/writes are done directly */ #define Z80_MAP_HANDLED 1 /* Reads/writes use a function handler */ /* Z80 registers */ typedef enum { Z80_REG_AF=0, Z80_REG_BC, Z80_REG_DE, Z80_REG_HL, Z80_REG_IX, Z80_REG_IY, Z80_REG_PC, Z80_REG_SP, Z80_REG_AF2, Z80_REG_BC2, Z80_REG_DE2, Z80_REG_HL2, Z80_REG_IFF1, /* boolean - 1 or 0 */ Z80_REG_IFF2, /* boolean - 1 or 0 */ Z80_REG_IR, Z80_REG_IM, /* 0, 1, or 2 */ Z80_REG_IRQVector, /* 0x00 to 0xff */ Z80_REG_IRQLine /* boolean - 1 or 0 */ } z80_register; /* Z80 main functions */ void z80_reset(void); int z80_emulate(int cycles); void z80_raise_IRQ(UBYTE vector); void z80_lower_IRQ(void); void z80_cause_NMI(void); /* Z80 context functions */ int z80_get_context_size(void); void z80_set_context(void *context); void z80_get_context(void *context); UWORD z80_get_reg(z80_register reg); void z80_set_reg(z80_register reg, UWORD value); /* Z80 cycle functions */ int z80_get_cycles_elapsed(void); void z80_stop_emulating(void); void z80_skip_idle(void); void z80_do_wait_states(int n); /* Z80 I/O functions */ void z80_init_memmap(void); void z80_map_fetch(UWORD start, UWORD end, UBYTE *memory); void z80_map_read(UWORD start, UWORD end, UBYTE *memory); void z80_map_write(UWORD start, UWORD end, UBYTE *memory); void z80_add_read(UWORD start, UWORD end, int method, void *data); void z80_add_write(UWORD start, UWORD end, int method, void *data); void z80_set_in(UBYTE (*handler)(UWORD port)); void z80_set_out(void (*handler)(UWORD port, UBYTE value)); void z80_set_reti(void (*handler)(void)); void z80_set_fetch_callback(void (*handler)(UWORD pc)); void z80_end_memmap(void); #ifdef __cplusplus }; #endif #endif /* __RAZE_H_INCLUDED__ */
/* * Backlight driver for OMAP based boards. * * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org> * * This package is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This package is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this package; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/fb.h> #include <linux/backlight.h> #include <asm/arch/hardware.h> #include <asm/arch/board.h> #include <asm/arch/mux.h> #define OMAPBL_MAX_INTENSITY 0xff struct omap_backlight { int powermode; int current_intensity; struct device *dev; struct omap_backlight_config *pdata; }; static void inline omapbl_send_intensity(int intensity) { omap_writeb(intensity, OMAP_PWL_ENABLE); } static void inline omapbl_send_enable(int enable) { omap_writeb(enable, OMAP_PWL_CLK_ENABLE); } static void omapbl_blank(struct omap_backlight *bl, int mode) { if (bl->pdata->set_power) bl->pdata->set_power(bl->dev, mode); switch (mode) { case FB_BLANK_NORMAL: case FB_BLANK_VSYNC_SUSPEND: case FB_BLANK_HSYNC_SUSPEND: case FB_BLANK_POWERDOWN: omapbl_send_intensity(0); omapbl_send_enable(0); break; case FB_BLANK_UNBLANK: omapbl_send_intensity(bl->current_intensity); omapbl_send_enable(1); break; } } #ifdef CONFIG_PM static int omapbl_suspend(struct platform_device *pdev, pm_message_t state) { struct backlight_device *dev = platform_get_drvdata(pdev); struct omap_backlight *bl = dev_get_drvdata(&dev->dev); omapbl_blank(bl, FB_BLANK_POWERDOWN); return 0; } static int omapbl_resume(struct platform_device *pdev) { struct backlight_device *dev = platform_get_drvdata(pdev); struct omap_backlight *bl = dev_get_drvdata(&dev->dev); omapbl_blank(bl, bl->powermode); return 0; } #else #define omapbl_suspend NULL #define omapbl_resume NULL #endif static int omapbl_set_power(struct backlight_device *dev, int state) { struct omap_backlight *bl = dev_get_drvdata(&dev->dev); omapbl_blank(bl, state); bl->powermode = state; return 0; } static int omapbl_update_status(struct backlight_device *dev) { struct omap_backlight *bl = dev_get_drvdata(&dev->dev); if (bl->current_intensity != dev->props.brightness) { if (bl->powermode == FB_BLANK_UNBLANK) omapbl_send_intensity(dev->props.brightness); bl->current_intensity = dev->props.brightness; } if (dev->props.fb_blank != bl->powermode) omapbl_set_power(dev, dev->props.fb_blank); return 0; } static int omapbl_get_intensity(struct backlight_device *dev) { struct omap_backlight *bl = dev_get_drvdata(&dev->dev); return bl->current_intensity; } static struct backlight_ops omapbl_ops = { .get_brightness = omapbl_get_intensity, .update_status = omapbl_update_status, }; static int omapbl_probe(struct platform_device *pdev) { struct backlight_device *dev; struct omap_backlight *bl; struct omap_backlight_config *pdata = pdev->dev.platform_data; if (!pdata) return -ENXIO; omapbl_ops.check_fb = pdata->check_fb; bl = kzalloc(sizeof(struct omap_backlight), GFP_KERNEL); if (unlikely(!bl)) return -ENOMEM; dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops); if (IS_ERR(dev)) { kfree(bl); return PTR_ERR(dev); } bl->powermode = FB_BLANK_POWERDOWN; bl->current_intensity = 0; bl->pdata = pdata; bl->dev = &pdev->dev; platform_set_drvdata(pdev, dev); omap_cfg_reg(PWL); /* Conflicts with UART3 */ dev->props.fb_blank = FB_BLANK_UNBLANK; dev->props.max_brightness = OMAPBL_MAX_INTENSITY; dev->props.brightness = pdata->default_intensity; omapbl_update_status(dev); printk(KERN_INFO "OMAP LCD backlight initialised\n"); return 0; } static int omapbl_remove(struct platform_device *pdev) { struct backlight_device *dev = platform_get_drvdata(pdev); struct omap_backlight *bl = dev_get_drvdata(&dev->dev); backlight_device_unregister(dev); kfree(bl); return 0; } static struct platform_driver omapbl_driver = { .probe = omapbl_probe, .remove = omapbl_remove, .suspend = omapbl_suspend, .resume = omapbl_resume, .driver = { .name = "omap-bl", }, }; static int __init omapbl_init(void) { return platform_driver_register(&omapbl_driver); } static void __exit omapbl_exit(void) { platform_driver_unregister(&omapbl_driver); } module_init(omapbl_init); module_exit(omapbl_exit); MODULE_AUTHOR("Andrzej Zaborowski <balrog@zabor.org>"); MODULE_DESCRIPTION("OMAP LCD Backlight driver"); MODULE_LICENSE("GPL");
/* * * Copyright 2003 Blur Studio Inc. * * This file is part of Arsenal. * * Arsenal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Arsenal is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Arsenal; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * $Id$ */ #ifdef COMPILE_AUTODESK_BURNER #ifndef AUTODESKBURN_BURNER_H #define AUTODESKBURN_BURNER_H #include "jobburner.h" /* * This class is used to Burn Autodesk Burn (Inferno, Flame) jobs * */ class QTimer; /// \ingroup ABurner /// @{ class AutodeskBurnBurner : public JobBurner { Q_OBJECT public: AutodeskBurnBurner( const Job & job, Slave * slave ); ~AutodeskBurnBurner(); virtual QStringList processNames() const; virtual QString executable(); virtual QStringList buildCmdArgs(); void slotProcessOutputLine( const QString &, QProcess::ProcessChannel ); void startProcess(); void cleanup(); public slots: void slotReadLog(); protected: QProcess * mLogCmd; bool mTaskRunning; QRegExp mCompleteRE; }; /// @} #endif // SYNC_BURNER_H #endif
#ifndef __EXTDISP_DRV_PLATFORM_H__ #define __EXTDISP_DRV_PLATFORM_H__ #include <linux/dma-mapping.h> #include <mach/mt_typedefs.h> #include <mach/mt_gpio.h> #include <mach/m4u.h> //#include <mach/mt6585_pwm.h> #include <mach/mt_reg_base.h> #include <mach/mt_clkmgr.h> #include <mach/mt_irq.h> //#include <mach/boot.h> #include <board-custom.h> #include <linux/disp_assert_layer.h> #include "ddp_hal.h" #if 0 #include "ddp_drv.h" #include "ddp_path.h" #include "ddp_rdma.h" #include <mach/sync_write.h> #ifdef OUTREG32 #undef OUTREG32 #define OUTREG32(x, y) mt65xx_reg_sync_writel(y, x) #endif #ifndef OUTREGBIT #define OUTREGBIT(TYPE,REG,bit,value) \ do { \ TYPE r = *((TYPE*)&INREG32(&REG)); \ r.bit = value; \ OUTREG32(&REG, AS_UINT32(&r)); \ } while (0) #endif #endif #define MAX_SESSION_COUNT 5 //#define MTK_LCD_HW_3D_SUPPORT #define ALIGN_TO(x, n) \ (((x) + ((n) - 1)) & ~((n) - 1)) #define MTK_EXT_DISP_ALIGNMENT 32 #define MTK_EXT_DISP_START_DSI_ISR #define MTK_EXT_DISP_OVERLAY_SUPPORT #define MTK_EXT_DISP_SYNC_SUPPORT #define MTK_EXT_DISP_ION_SUPPORT #define MTK_AUDIO_MULTI_CHANNEL_SUPPORT ///#define EXTD_DBG_USE_INNER_BUF #define HW_OVERLAY_COUNT (4) #endif //__DISP_DRV_PLATFORM_H__
/* Shared general utility routines for GDB, the GNU debugger. Copyright (C) 1986-2015 Free Software Foundation, Inc. This file is part of GDB. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef COMMON_UTILS_H #define COMMON_UTILS_H /* If possible, define FUNCTION_NAME, a macro containing the name of the function being defined. Since this macro may not always be defined, all uses must be protected by appropriate macro definition checks (Eg: "#ifdef FUNCTION_NAME"). Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' which contains the name of the function currently being defined. This is broken in G++ before version 2.6. C9x has a similar variable called __func__, but prefer the GCC one since it demangles C++ function names. */ #if (GCC_VERSION >= 2004) #define FUNCTION_NAME __PRETTY_FUNCTION__ #else #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L #define FUNCTION_NAME __func__ /* ARI: func */ #endif #endif /* xmalloc(), xrealloc() and xcalloc() have already been declared in "libiberty.h". */ /* Like xmalloc, but zero the memory. */ void *xzalloc (size_t); void xfree (void *); /* Like asprintf and vasprintf, but return the string, throw an error if no memory. */ char *xstrprintf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2); char *xstrvprintf (const char *format, va_list ap) ATTRIBUTE_PRINTF (1, 0); /* Like snprintf, but throw an error if the output buffer is too small. */ int xsnprintf (char *str, size_t size, const char *format, ...) ATTRIBUTE_PRINTF (3, 4); /* Make a copy of the string at PTR with LEN characters (and add a null character at the end in the copy). Uses malloc to get the space. Returns the address of the copy. */ char *savestring (const char *ptr, size_t len); /* The strerror() function can return NULL for errno values that are out of range. Provide a "safe" version that always returns a printable string. */ extern char *safe_strerror (int); /* Return non-zero if the start of STRING matches PATTERN, zero otherwise. */ static inline int startswith (const char *string, const char *pattern) { return strncmp (string, pattern, strlen (pattern)) == 0; } #endif
/* * This file is part of the coreboot project. * * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc. */ #include <arch/io.h> #include <arch/acpi.h> #include <console/console.h> #include <device/device.h> #include <device/pci.h> #include <device/pci_ops.h> #include <stdint.h> #include <string.h> #include <elog.h> #include "pch.h" static void pch_log_standard_gpe(u32 gpe0_sts_reg, u32 gpe0_en_reg) { u32 gpe0_en = inl(get_pmbase() + gpe0_en_reg); u32 gpe0_sts = inl(get_pmbase() + gpe0_sts_reg) & gpe0_en; /* PME (TODO: determine wake device) */ if (gpe0_sts & (1 << 11)) elog_add_event_wake(ELOG_WAKE_SOURCE_PME, 0); /* Internal PME (TODO: determine wake device) */ if (gpe0_sts & (1 << 13)) elog_add_event_wake(ELOG_WAKE_SOURCE_PME_INTERNAL, 0); /* SMBUS Wake */ if (gpe0_sts & (1 << 7)) elog_add_event_wake(ELOG_WAKE_SOURCE_SMBUS, 0); } static void pch_log_gpio_gpe(u32 gpe0_sts_reg, u32 gpe0_en_reg, int start) { /* GPE Bank 1 is GPIO 0-31 */ u32 gpe0_en = inl(get_pmbase() + gpe0_en_reg); u32 gpe0_sts = inl(get_pmbase() + gpe0_sts_reg) & gpe0_en; int i; for (i = 0; i <= 31; i++) { if (gpe0_sts & (1 << i)) elog_add_event_wake(ELOG_WAKE_SOURCE_GPIO, i + start); } } static void pch_log_gpe(void) { int i; u16 pmbase = get_pmbase(); u32 gpe0_sts, gpe0_en; int gpe0_high_gpios[] = { [0] = 27, [24] = 17, [25] = 19, [26] = 21, [27] = 22, [28] = 43, [29] = 56, [30] = 57, [31] = 60 }; pch_log_standard_gpe(GPE0_EN, GPE0_STS); /* GPIO 0-15 */ gpe0_en = inw(pmbase + GPE0_EN + 2); gpe0_sts = inw(pmbase + GPE0_STS + 2) & gpe0_en; for (i = 0; i <= 15; i++) { if (gpe0_sts & (1 << i)) elog_add_event_wake(ELOG_WAKE_SOURCE_GPIO, i); } /* * Now check and log upper status bits */ gpe0_en = inl(pmbase + GPE0_EN_2); gpe0_sts = inl(pmbase + GPE0_STS_2) & gpe0_en; for (i = 0; i <= 31; i++) { if (!gpe0_high_gpios[i]) continue; if (gpe0_sts & (1 << i)) elog_add_event_wake(ELOG_WAKE_SOURCE_GPIO, gpe0_high_gpios[i]); } } static void pch_lp_log_gpe(void) { /* Standard GPE are in GPE set 4 */ pch_log_standard_gpe(LP_GPE0_STS_4, LP_GPE0_EN_4); /* Log GPIO events in set 1-3 */ pch_log_gpio_gpe(LP_GPE0_STS_1, LP_GPE0_EN_1, 0); pch_log_gpio_gpe(LP_GPE0_STS_2, LP_GPE0_EN_2, 32); pch_log_gpio_gpe(LP_GPE0_STS_3, LP_GPE0_EN_3, 64); } void pch_log_state(void) { u16 pm1_sts, gen_pmcon_3, tco2_sts; u8 gen_pmcon_2; struct device *lpc = dev_find_slot(0, PCI_DEVFN(0x1f, 0)); if (!lpc) return; pm1_sts = inw(get_pmbase() + PM1_STS); tco2_sts = inw(get_pmbase() + TCO2_STS); gen_pmcon_2 = pci_read_config8(lpc, GEN_PMCON_2); gen_pmcon_3 = pci_read_config16(lpc, GEN_PMCON_3); /* PWR_FLR Power Failure */ if (gen_pmcon_2 & (1 << 0)) elog_add_event(ELOG_TYPE_POWER_FAIL); /* SUS Well Power Failure */ if (gen_pmcon_3 & (1 << 14)) elog_add_event(ELOG_TYPE_SUS_POWER_FAIL); /* SYS_PWROK Failure */ if (gen_pmcon_2 & (1 << 1)) elog_add_event(ELOG_TYPE_SYS_PWROK_FAIL); /* PWROK Failure */ if (gen_pmcon_2 & (1 << 0)) elog_add_event(ELOG_TYPE_PWROK_FAIL); /* Second TCO Timeout */ if (tco2_sts & (1 << 1)) elog_add_event(ELOG_TYPE_TCO_RESET); /* Power Button Override */ if (pm1_sts & (1 << 11)) elog_add_event(ELOG_TYPE_POWER_BUTTON_OVERRIDE); /* System Reset Status (reset button pushed) */ if (gen_pmcon_2 & (1 << 4)) elog_add_event(ELOG_TYPE_RESET_BUTTON); /* General Reset Status */ if (gen_pmcon_3 & (1 << 9)) elog_add_event(ELOG_TYPE_SYSTEM_RESET); /* ACPI Wake */ if (pm1_sts & (1 << 15)) elog_add_event_byte(ELOG_TYPE_ACPI_WAKE, acpi_is_wakeup_s3() ? 3 : 5); /* * Wake sources */ /* Power Button */ if (pm1_sts & (1 << 8)) elog_add_event_wake(ELOG_WAKE_SOURCE_PWRBTN, 0); /* RTC */ if (pm1_sts & (1 << 10)) elog_add_event_wake(ELOG_WAKE_SOURCE_RTC, 0); /* PCI Express (TODO: determine wake device) */ if (pm1_sts & (1 << 14)) elog_add_event_wake(ELOG_WAKE_SOURCE_PCIE, 0); /* GPE */ if (pch_is_lp()) pch_lp_log_gpe(); else pch_log_gpe(); }
/** src/audio_reader/audio_reader_test.h This simple test application uses an audio_reader and content_pipe to read audio data from a file URI Copyright (C) 2007-2009 STMicroelectronics Copyright (C) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __AUDIO_READER_TEST_H__ #define __AUDIO_READER_TEST_H__ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> #include <pthread.h> #include <unistd.h> #include <sys/stat.h> #include <OMX_Types.h> #include <OMX_Core.h> #include <OMX_Component.h> #include <OMX_ContentPipe.h> #include <OMX_Audio.h> #include <bellagio/omx_comp_debug_levels.h> #include <bellagio/tsemaphore.h> #include "audio_reader.h" /** Specification version*/ #define VERSIONMAJOR 1 #define VERSIONMINOR 1 #define VERSIONREVISION 0 #define VERSIONSTEP 0 /* Number of buffers used on each component port */ #define BUFFER_COUNT_ACTUAL 2 /* Application's private data */ typedef struct appPrivateType{ /* cmdline options */ int opd; OMX_S8* szURI; /* private data */ OMX_HANDLETYPE handle; /* handle for audio_reader */ OMX_HANDLETYPE pipe; /* handle for content_pipe */ tsem_t* eventSem; tsem_t* eofSem; } appPrivateType; #endif
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once // multi producer-multi consumer blocking queue. // enqueue(..) - will block until room found to put the new message. // enqueue_nowait(..) - will return immediately with false if no room left in // the queue. // dequeue_for(..) - will block until the queue is not empty or timeout have // passed. #include <spdlog/details/circular_q.h> #include <condition_variable> #include <mutex> namespace spdlog { namespace details { template<typename T> class mpmc_blocking_queue { public: using item_type = T; explicit mpmc_blocking_queue(size_t max_items) : q_(max_items) {} #ifndef __MINGW32__ // try to enqueue and block if no room left void enqueue(T &&item) { { std::unique_lock<std::mutex> lock(queue_mutex_); pop_cv_.wait(lock, [this] { return !this->q_.full(); }); q_.push_back(std::move(item)); } push_cv_.notify_one(); } // enqueue immediately. overrun oldest message in the queue if no room left. void enqueue_nowait(T &&item) { { std::unique_lock<std::mutex> lock(queue_mutex_); q_.push_back(std::move(item)); } push_cv_.notify_one(); } // try to dequeue item. if no item found. wait upto timeout and try again // Return true, if succeeded dequeue item, false otherwise bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) { { std::unique_lock<std::mutex> lock(queue_mutex_); if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) { return false; } popped_item = std::move(q_.front()); q_.pop_front(); } pop_cv_.notify_one(); return true; } #else // apparently mingw deadlocks if the mutex is released before cv.notify_one(), // so release the mutex at the very end each function. // try to enqueue and block if no room left void enqueue(T &&item) { std::unique_lock<std::mutex> lock(queue_mutex_); pop_cv_.wait(lock, [this] { return !this->q_.full(); }); q_.push_back(std::move(item)); push_cv_.notify_one(); } // enqueue immediately. overrun oldest message in the queue if no room left. void enqueue_nowait(T &&item) { std::unique_lock<std::mutex> lock(queue_mutex_); q_.push_back(std::move(item)); push_cv_.notify_one(); } // try to dequeue item. if no item found. wait upto timeout and try again // Return true, if succeeded dequeue item, false otherwise bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) { std::unique_lock<std::mutex> lock(queue_mutex_); if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) { return false; } popped_item = std::move(q_.front()); q_.pop_front(); pop_cv_.notify_one(); return true; } #endif size_t overrun_counter() { std::unique_lock<std::mutex> lock(queue_mutex_); return q_.overrun_counter(); } private: std::mutex queue_mutex_; std::condition_variable push_cv_; std::condition_variable pop_cv_; spdlog::details::circular_q<T> q_; }; } // namespace details } // namespace spdlog
//===----------------------------------------------------------------------===// // // Peloton // // skiplist.h // // Identification: src/include/index/skiplist.h // // Copyright (c) 2015-17, Carnegie Mellon University Database Group // //===----------------------------------------------------------------------===// #pragma once namespace peloton { namespace index { /* * SKIPLIST_TEMPLATE_ARGUMENTS - Save some key strokes */ #define SKIPLIST_TEMPLATE_ARGUMENTS \ template <typename KeyType, typename ValueType, typename KeyComparator, \ typename KeyEqualityChecker, typename ValueEqualityChecker> template <typename KeyType, typename ValueType, typename KeyComparator, typename KeyEqualityChecker, typename ValueEqualityChecker> class SkipList { // TODO: Add your declarations here }; } // namespace index } // namespace peloton
// Backward-compat support -*- C++ -*- // Copyright (C) 2001 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /* * Copyright (c) 1996-1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ #ifndef _CPP_BACKWARD_ALLOC_H #define _CPP_BACKWARD_ALLOC_H 1 #include "backward_warning.h" #include <bits/c++config.h> #include <bits/stl_alloc.h> using std::__malloc_alloc_template; using std::__simple_alloc; using std::__debug_alloc; using std::__alloc; using std::__single_client_alloc; using std::allocator; using std::__default_alloc_template; #endif
/* * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) * * click.c: Button press (mouse click) events. * */ #ifndef I3_CLICK_H #define I3_CLICK_H /** * The button press X callback. This function determines whether the floating * modifier is pressed and where the user clicked (decoration, border, inside * the window). * * Then, route_click is called on the appropriate con. * */ int handle_button_press(xcb_button_press_event_t *event); #endif
/* * This file is part of the Soletta Project * * Copyright (C) 2015 Intel Corporation. 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 Intel Corporation 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 * OWNER 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 <errno.h> #include <stdlib.h> #include <stdio.h> #include "sol-mainloop.h" #include "sol-platform.h" #include "sol-util.h" #define CMD_TICK 2000 static char **cmds; static int n_cmds; static int cur_cmd; static struct sol_timeout *timeout_handle; static void on_state_change(void *data, enum sol_platform_state state) { printf("Platform state changed. New state: %d\n", state); } static void on_service_changed(void *data, const char *service, enum sol_platform_service_state state) { printf("Service state changed: '%s'. New state: %d\n", service, state); } static bool on_timeout_cmd(void *data) { const char *cmd; const char *param; cmd = cmds[cur_cmd++]; param = cmds[cur_cmd++]; printf("Firing new command: %s %s\n", cmd, param); if (streq(cmd, "monitor")) sol_platform_add_service_monitor(on_service_changed, param, NULL); else if (streq(cmd, "stop-monitor")) sol_platform_del_service_monitor(on_service_changed, param, NULL); else if (streq(cmd, "start")) sol_platform_start_service(param); else if (streq(cmd, "stop")) sol_platform_stop_service(param); else if (streq(cmd, "restart")) sol_platform_restart_service(param); else if (streq(cmd, "target")) sol_platform_set_target(param); if (n_cmds - cur_cmd >= 2) return true; timeout_handle = NULL; return false; } int main(int argc, char *argv[]) { int r = 0; if (sol_init() < 0) return EXIT_FAILURE; printf("Initial platform state: %d\n", sol_platform_get_state()); sol_platform_add_state_monitor(on_state_change, NULL); if (argc > 2) { cmds = argv + 1; n_cmds = argc - 1; timeout_handle = sol_timeout_add(CMD_TICK, on_timeout_cmd, NULL); } sol_run(); if (timeout_handle) sol_timeout_del(timeout_handle); sol_platform_del_state_monitor(on_state_change, NULL); sol_shutdown(); return r; }
// 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 CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_ITERATOR_H_ #define CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_ITERATOR_H_ #include <iterator> #include "chrome/browser/ui/browser_list.h" namespace content { class WebContents; } // Iterates through all tab contents in all browser windows. Because the // renderers act asynchronously, getting a tab contents through this interface // does not guarantee that the renderer is ready to go. Doing anything to affect // browser windows or tabs while iterating may cause incorrect behavior. // // Examples: // // for (auto* web_contents : AllTabContentses()) { // SomeFunctionTakingWebContents(web_contents); // -or- // web_contents->OperationOnWebContents(); // ... // } // // auto& all_tabs = AllTabContentses(); // auto it = some_std_algorithm(all_tabs.begin(), all_tabs.end(), ...); class AllTabContentsesList { public: class Iterator { public: using iterator_category = std::forward_iterator_tag; using value_type = content::WebContents*; using difference_type = ptrdiff_t; using pointer = value_type*; using reference = const value_type&; Iterator(); Iterator(const Iterator& iterator); ~Iterator(); value_type operator->() { return cur_; } reference operator*() { return cur_; } Iterator& operator++() { Next(); return *this; } Iterator operator++(int) { Iterator it(*this); Next(); return it; } bool operator==(const Iterator& other) const { return cur_ == other.cur_; } bool operator!=(const Iterator& other) const { return !(*this == other); } // Returns the Browser instance associated with the current tab contents. // Valid as long as this iterator != the AllTabContentses().end() iterator. Browser* browser() const { return browser_iterator_ == BrowserList::GetInstance()->end() ? nullptr : *browser_iterator_; } private: friend class AllTabContentsesList; explicit Iterator(bool is_end_iter); // Loads the next tab contents into |cur_|. This is designed so that for the // initial call from the constructor, when |browser_iterator_| points to the // first Browser and |tab_index_| is -1, it will fill the first tab // contents. void Next(); // Tab index into the current Browser of the current tab contents. int tab_index_; // Current WebContents, or null if we're at the end of the list. This can be // extracted given the browser iterator and index, but it's nice to cache // this since the caller may access the current tab contents many times. content::WebContents* cur_; // An iterator over all the browsers. BrowserList::const_iterator browser_iterator_; }; using iterator = Iterator; using const_iterator = Iterator; const_iterator begin() const { return Iterator(false); } const_iterator end() const { return Iterator(true); } AllTabContentsesList() = default; ~AllTabContentsesList() = default; }; const AllTabContentsesList& AllTabContentses(); #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_ITERATOR_H_
/* * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/> * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __TRINITY_VEHICLE_H #define __TRINITY_VEHICLE_H #include "ObjectDefines.h" #include "Object.h" #include "VehicleDefines.h" #include "Unit.h" #include <list> struct VehicleEntry; class Unit; class VehicleJoinEvent; class TC_GAME_API Vehicle : public TransportBase { protected: friend bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry); Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry); friend void Unit::RemoveVehicleKit(); ~Vehicle(); public: void Install(); void Uninstall(); void Reset(bool evading = false); void InstallAllAccessories(bool evading); void ApplyAllImmunities(); void InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime); //! May be called from scripts Unit* GetBase() const { return _me; } VehicleEntry const* GetVehicleInfo() const { return _vehicleInfo; } uint32 GetCreatureEntry() const { return _creatureEntry; } bool HasEmptySeat(int8 seatId) const; Unit* GetPassenger(int8 seatId) const; SeatMap::const_iterator GetNextEmptySeat(int8 seatId, bool next) const; uint8 GetAvailableSeatCount() const; bool AddPassenger(Unit* passenger, int8 seatId = -1); void EjectPassenger(Unit* passenger, Unit* controller); Vehicle* RemovePassenger(Unit* passenger); void RelocatePassengers(); void RemoveAllPassengers(); bool IsVehicleInUse() const; void SetLastShootPos(Position const& pos) { _lastShootPos.Relocate(pos); } Position const& GetLastShootPos() const { return _lastShootPos; } SeatMap Seats; ///< The collection of all seats on the vehicle. Including vacant ones. VehicleSeatEntry const* GetSeatForPassenger(Unit const* passenger) const; void RemovePendingEventsForPassenger(Unit* passenger); protected: friend class VehicleJoinEvent; uint32 UsableSeatNum; ///< Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags private: enum Status { STATUS_NONE, STATUS_INSTALLED, STATUS_UNINSTALLING, }; SeatMap::iterator GetSeatIteratorForPassenger(Unit* passenger); void InitMovementInfoForBase(); /// This method transforms supplied transport offsets into global coordinates void CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= NULL*/) const override { TransportBase::CalculatePassengerPosition(x, y, z, o, GetBase()->GetPositionX(), GetBase()->GetPositionY(), GetBase()->GetPositionZ(), GetBase()->GetOrientation()); } /// This method transforms supplied global coordinates into local offsets void CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= NULL*/) const override { TransportBase::CalculatePassengerOffset(x, y, z, o, GetBase()->GetPositionX(), GetBase()->GetPositionY(), GetBase()->GetPositionZ(), GetBase()->GetOrientation()); } void RemovePendingEvent(VehicleJoinEvent* e); void RemovePendingEventsForSeat(int8 seatId); private: Unit* _me; ///< The underlying unit with the vehicle kit. Can be player or creature. VehicleEntry const* _vehicleInfo; ///< DBC data for vehicle GuidSet vehiclePlayers; uint32 _creatureEntry; ///< Can be different than the entry of _me in case of players Status _status; ///< Internal variable for sanity checks Position _lastShootPos; typedef std::list<VehicleJoinEvent*> PendingJoinEventContainer; PendingJoinEventContainer _pendingJoinEvents; ///< Collection of delayed join events for prospective passengers }; class TC_GAME_API VehicleJoinEvent : public BasicEvent { friend class Vehicle; protected: VehicleJoinEvent(Vehicle* v, Unit* u) : Target(v), Passenger(u), Seat(Target->Seats.end()) { } ~VehicleJoinEvent(); bool Execute(uint64, uint32) override; void Abort(uint64) override; Vehicle* Target; Unit* Passenger; SeatMap::iterator Seat; }; #endif
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <errno.h> #include <sys/types.h> #include <sys/ptrace.h> #include <stdarg.h> #include <sysdep.h> #include <sys/syscall.h> extern long int __syscall_ptrace (int, pid_t, void *, void *); long int ptrace (enum __ptrace_request request, ...) { long int res, ret; va_list ap; pid_t pid; void *addr, *data; va_start (ap, request); pid = va_arg (ap, pid_t); addr = va_arg (ap, void *); data = va_arg (ap, void *); va_end (ap); if (request > 0 && request < 4) data = &ret; res = INLINE_SYSCALL (ptrace, 4, request, pid, addr, data); if (res >= 0 && request > 0 && request < 4) { __set_errno (0); return ret; } return res; }
/* -*- c++ -*- */ /* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_KEEP_ONE_IN_N_IMPL_H #define INCLUDED_KEEP_ONE_IN_N_IMPL_H #include <gnuradio/blocks/keep_one_in_n.h> namespace gr { namespace blocks { class BLOCKS_API keep_one_in_n_impl : public keep_one_in_n { int d_n; int d_count; float d_decim_rate; public: keep_one_in_n_impl(size_t itemsize,int n); int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); void set_n(int n); }; } /* namespace blocks */ } /* namespace gr */ #endif /* INCLUDED_KEEP_ONE_IN_N_IMPL_H */
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ // Simple hash functions used for internal data structures #ifndef TENSORFLOW_LIB_HASH_HASH_H_ #define TENSORFLOW_LIB_HASH_HASH_H_ #include <stddef.h> #include <stdint.h> #include <string> #include "tensorflow/core/platform/types.h" namespace tensorflow { extern uint32 Hash32(const char* data, size_t n, uint32 seed); extern uint64 Hash64(const char* data, size_t n, uint64 seed); inline uint64 Hash64(const char* data, size_t n) { return Hash64(data, n, 0xDECAFCAFFE); } inline uint64 Hash64(const string& str) { return Hash64(str.data(), str.size()); } inline uint64 Hash64Combine(uint64 a, uint64 b) { return a ^ (b + 0x9e3779b97f4a7800ULL + (a << 10) + (a >> 4)); } } // namespace tensorflow #endif // TENSORFLOW_LIB_HASH_HASH_H_
/* * Copyright (C) 2015 Google Inc. 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 Google Inc. 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 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef WebRTCKeyParams_h #define WebRTCKeyParams_h #include "WebCommon.h" namespace blink { // Corresponds to rtc::KeyType in WebRTC. enum WebRTCKeyType { WebRTCKeyTypeRSA, WebRTCKeyTypeECDSA, WebRTCKeyTypeNull }; // Corresponds to rtc::RSAParams in WebRTC. struct WebRTCRSAParams { unsigned modLength; unsigned pubExp; }; // Corresponds to rtc::ECCurve in WebRTC. enum WebRTCECCurve { WebRTCECCurveNistP256 }; // Corresponds to rtc::KeyParams in WebRTC. class WebRTCKeyParams { public: static WebRTCKeyParams createRSA(unsigned modLength, unsigned pubExp) { WebRTCKeyParams keyParams(WebRTCKeyTypeRSA); keyParams.m_params.rsa.modLength = modLength; keyParams.m_params.rsa.pubExp = pubExp; return keyParams; } static WebRTCKeyParams createECDSA(WebRTCECCurve curve) { WebRTCKeyParams keyParams(WebRTCKeyTypeECDSA); keyParams.m_params.ecCurve = curve; return keyParams; } WebRTCKeyParams() : WebRTCKeyParams(WebRTCKeyTypeNull) {} WebRTCKeyType keyType() const { return m_keyType; } WebRTCRSAParams rsaParams() const { BLINK_ASSERT(m_keyType == WebRTCKeyTypeRSA); return m_params.rsa; } WebRTCECCurve ecCurve() const { BLINK_ASSERT(m_keyType == WebRTCKeyTypeECDSA); return m_params.ecCurve; } private: WebRTCKeyParams(WebRTCKeyType keyType) : m_keyType(keyType) {} WebRTCKeyType m_keyType; union { WebRTCRSAParams rsa; WebRTCECCurve ecCurve; } m_params; }; } // namespace blink #endif // WebRTCKeyParams_h
/*******************************************************/ /* "C" Language Integrated Production System */ /* */ /* CLIPS Version 6.20 01/31/02 */ /* */ /* DEFMODULE CONSTRUCT COMPILER HEADER FILE */ /*******************************************************/ /*************************************************************/ /* Purpose: Implements the constructs-to-c feature for the */ /* defmodule construct. */ /* */ /* Principal Programmer(s): */ /* Gary D. Riley */ /* */ /* Contributing Programmer(s): */ /* */ /* Revision History: */ /* */ /*************************************************************/ #ifndef _H_modulcmp #define _H_modulcmp #ifndef _STDIO_INCLUDED_ #define _STDIO_INCLUDED_ #include <stdio.h> #endif #ifndef _H_moduldef #include "moduldef.h" #endif #ifdef LOCALE #undef LOCALE #endif #ifdef _MODULCMP_SOURCE_ #define LOCALE #else #define LOCALE extern #endif LOCALE void DefmoduleCompilerSetup(void *); LOCALE void PrintDefmoduleReference(void *,FILE *,struct defmodule *); #endif
// Default ECO Layout // KLE here : http://www.keyboard-layout-editor.com/#/gists/0733eca6b4cb88ff9d7de746803f4039 #include QMK_KEYBOARD_H extern keymap_config_t keymap_config; // Each layer gets a name for readability, which is then used in the keymap matrix below. // The underscores don't mean anything - you can have a layer called STUFF or any other name. // Layer names don't all need to be of the same length, obviously, and you can also skip them // entirely and just use numbers. #define _QWERTY 0 #define _FN1 2 #define _FN2 3 enum eco_keycodes { QWERTY = SAFE_RANGE }; // Defines for task manager and such #define CALTDEL LCTL(LALT(KC_DEL)) #define TSKMGR LCTL(LSFT(KC_ESC)) const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty * ,-------------------------------------------------------------------------------------------------. * | Esc | Q | W | E | R | T | Y | U | I | O | P | [ | ] | Bksp | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | Tab | A | S | D | F | G | H | J | K | L | ; | ' | Enter| \ | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | Shift| Z | X | C | V | B | N | M | , | . | / | Shift| Up | Del | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | Ctrl | GUI | Alt | Del | FN1 | FN1 | Space| Space| FN2 | FN2 | Ctrl | Left | Down | Right| * `-------------------------------------------------------------------------------------------------' */ [_QWERTY] = LAYOUT( KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_BSLS, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_DEL, KC_LCTL, KC_LGUI,KC_LALT, KC_DEL, MO(_FN1), MO(_FN1), KC_SPC, KC_SPC, MO(_FN2), MO(_FN2), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT ), /* FN1 * ,-------------------------------------------------------------------------------------------------. * | | ! | @ | # | $ | % | ^ | & | * | ( | ) | _ | + | | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * |caltde| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | | | | | | | | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | | | | | | | RESET| * `-------------------------------------------------------------------------------------------------' */ [_FN1] = LAYOUT( _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_UNDS, KC_PLUS, _______, CALTDEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET ), /* Raise * ,-------------------------------------------------------------------------------------------------. * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * |Taskmg| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | | | | | | | | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | | | | | | | | * `-------------------------------------------------------------------------------------------------' */ [_FN2] = LAYOUT( _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, _______, TSKMGR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ) }; void persistant_default_layer_set(uint16_t default_layer) { eeconfig_update_default_layer(default_layer); default_layer_set(default_layer); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { persistant_default_layer_set(1UL<<_QWERTY); } return false; break; } return true; }
/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _SCSI_SCSI_EH_H #define _SCSI_SCSI_EH_H #include <linux/scatterlist.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_common.h> struct scsi_device; struct Scsi_Host; extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q); extern void scsi_eh_flush_done_q(struct list_head *done_q); extern void scsi_report_bus_reset(struct Scsi_Host *, int); extern void scsi_report_device_reset(struct Scsi_Host *, int, int); extern int scsi_block_when_processing_errors(struct scsi_device *); extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd, struct scsi_sense_hdr *sshdr); extern int scsi_check_sense(struct scsi_cmnd *); static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr) { return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); } extern bool scsi_get_sense_info_fld(const u8 *sense_buffer, int sb_len, u64 *info_out); extern int scsi_ioctl_reset(struct scsi_device *, int __user *); struct scsi_eh_save { /* saved state */ int result; unsigned int resid_len; int eh_eflags; enum dma_data_direction data_direction; unsigned underflow; unsigned char cmd_len; unsigned char prot_op; unsigned char *cmnd; struct scsi_data_buffer sdb; struct request *next_rq; /* new command support */ unsigned char eh_cmnd[BLK_MAX_CDB]; struct scatterlist sense_sgl; }; extern void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, unsigned char *cmnd, int cmnd_size, unsigned sense_bytes); extern void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses); #endif /* _SCSI_SCSI_EH_H */
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Per-thread (in Go, per-M) malloc cache for small objects. // // See malloc.h for an overview. #include "runtime.h" #include "arch.h" #include "malloc.h" void* runtime_MCache_Alloc(MCache *c, int32 sizeclass, uintptr size, int32 zeroed) { MCacheList *l; MLink *first, *v; int32 n; // Allocate from list. l = &c->list[sizeclass]; if(l->list == nil) { // Replenish using central lists. n = runtime_MCentral_AllocList(&runtime_mheap.central[sizeclass], runtime_class_to_transfercount[sizeclass], &first); if(n == 0) runtime_throw("out of memory"); l->list = first; l->nlist = n; c->size += n*size; } v = l->list; l->list = v->next; l->nlist--; if(l->nlist < l->nlistmin) l->nlistmin = l->nlist; c->size -= size; // v is zeroed except for the link pointer // that we used above; zero that. v->next = nil; if(zeroed) { // block is zeroed iff second word is zero ... if(size > sizeof(uintptr) && ((uintptr*)v)[1] != 0) runtime_memclr((byte*)v, size); else { // ... except for the link pointer // that we used above; zero that. v->next = nil; } } c->local_cachealloc += size; c->local_objects++; return v; } // Take n elements off l and return them to the central free list. static void ReleaseN(MCache *c, MCacheList *l, int32 n, int32 sizeclass) { MLink *first, **lp; int32 i; // Cut off first n elements. first = l->list; lp = &l->list; for(i=0; i<n; i++) lp = &(*lp)->next; l->list = *lp; *lp = nil; l->nlist -= n; if(l->nlist < l->nlistmin) l->nlistmin = l->nlist; c->size -= n*runtime_class_to_size[sizeclass]; // Return them to central free list. runtime_MCentral_FreeList(&runtime_mheap.central[sizeclass], n, first); } void runtime_MCache_Free(MCache *c, void *v, int32 sizeclass, uintptr size) { int32 i, n; MCacheList *l; MLink *p; // Put back on list. l = &c->list[sizeclass]; p = v; p->next = l->list; l->list = p; l->nlist++; c->size += size; c->local_cachealloc -= size; c->local_objects--; if(l->nlist >= MaxMCacheListLen) { // Release a chunk back. ReleaseN(c, l, runtime_class_to_transfercount[sizeclass], sizeclass); } if(c->size >= MaxMCacheSize) { // Scavenge. for(i=0; i<NumSizeClasses; i++) { l = &c->list[i]; n = l->nlistmin; // n is the minimum number of elements we've seen on // the list since the last scavenge. If n > 0, it means that // we could have gotten by with n fewer elements // without needing to consult the central free list. // Move toward that situation by releasing n/2 of them. if(n > 0) { if(n > 1) n /= 2; ReleaseN(c, l, n, i); } l->nlistmin = l->nlist; } } } void runtime_MCache_ReleaseAll(MCache *c) { int32 i; MCacheList *l; for(i=0; i<NumSizeClasses; i++) { l = &c->list[i]; ReleaseN(c, l, l->nlist, i); l->nlistmin = 0; } }
/* test mpz_divisible_2exp_p */ /* Copyright 2001 Free Software Foundation, Inc. This file is part of the GNU MP Library test suite. The GNU MP Library test suite is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The GNU MP Library test suite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU MP Library test suite. If not, see http://www.gnu.org/licenses/. */ #include <stdio.h> #include <stdlib.h> #include "gmp.h" #include "gmp-impl.h" #include "tests.h" void check_one (mpz_srcptr a, unsigned long d, int want) { int got; got = (mpz_divisible_2exp_p (a, d) != 0); if (want != got) { printf ("mpz_divisible_2exp_p wrong\n"); printf (" expected %d got %d\n", want, got); mpz_trace (" a", a); printf (" d=%lu\n", d); mp_trace_base = -16; mpz_trace (" a", a); printf (" d=0x%lX\n", d); abort (); } } void check_data (void) { static const struct { const char *a; unsigned long d; int want; } data[] = { { "0", 0, 1 }, { "0", 1, 1 }, { "0", 2, 1 }, { "0", 3, 1 }, { "1", 0, 1 }, { "1", 1, 0 }, { "1", 2, 0 }, { "1", 3, 0 }, { "1", 10000, 0 }, { "4", 0, 1 }, { "4", 1, 1 }, { "4", 2, 1 }, { "4", 3, 0 }, { "4", 4, 0 }, { "4", 10000, 0 }, { "0x80000000", 31, 1 }, { "0x80000000", 32, 0 }, { "0x80000000", 64, 0 }, { "0x100000000", 32, 1 }, { "0x100000000", 33, 0 }, { "0x100000000", 64, 0 }, { "0x8000000000000000", 63, 1 }, { "0x8000000000000000", 64, 0 }, { "0x8000000000000000", 128, 0 }, { "0x10000000000000000", 64, 1 }, { "0x10000000000000000", 65, 0 }, { "0x10000000000000000", 128, 0 }, { "0x10000000000000000", 256, 0 }, { "0x10000000000000000100000000", 32, 1 }, { "0x10000000000000000100000000", 33, 0 }, { "0x10000000000000000100000000", 64, 0 }, { "0x1000000000000000010000000000000000", 64, 1 }, { "0x1000000000000000010000000000000000", 65, 0 }, { "0x1000000000000000010000000000000000", 128, 0 }, { "0x1000000000000000010000000000000000", 256, 0 }, { "0x1000000000000000010000000000000000", 1024, 0 }, }; mpz_t a, d; int i; mpz_init (a); mpz_init (d); for (i = 0; i < numberof (data); i++) { mpz_set_str_or_abort (a, data[i].a, 0); check_one (a, data[i].d, data[i].want); mpz_neg (a, a); check_one (a, data[i].d, data[i].want); } mpz_clear (a); mpz_clear (d); } int main (int argc, char *argv[]) { tests_start (); check_data (); tests_end (); exit (0); }
/** * * @defgroup app_pwm_config PWM functionality configuration * @{ * @ingroup app_pwm */ /** @brief Enabling PWM module * * Set to 1 to activate. * * @note This is an NRF_CONFIG macro. */ #define APP_PWM_ENABLED /** @} */
/*************************************************************************** Copyright (c) 2014, The OpenBLAS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the OpenBLAS project 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 OPENBLAS PROJECT 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. *****************************************************************************/ #define HAVE_KERNEL_4x4 1 static void dsymv_kernel_4x4(BLASLONG n, FLOAT *a0, FLOAT *a1, FLOAT *a2, FLOAT *a3, FLOAT *x, FLOAT *y, FLOAT *temp1, FLOAT *temp2) __attribute__ ((noinline)); static void dsymv_kernel_4x4(BLASLONG n, FLOAT *a0, FLOAT *a1, FLOAT *a2, FLOAT *a3, FLOAT *x, FLOAT *y, FLOAT *temp1, FLOAT *temp2) { BLASLONG register i = 0; __asm__ __volatile__ ( "vzeroupper \n\t" "vxorpd %%ymm0 , %%ymm0 , %%ymm0 \n\t" // temp2[0] "vxorpd %%ymm1 , %%ymm1 , %%ymm1 \n\t" // temp2[1] "vxorpd %%ymm2 , %%ymm2 , %%ymm2 \n\t" // temp2[2] "vxorpd %%ymm3 , %%ymm3 , %%ymm3 \n\t" // temp2[3] "vbroadcastsd (%8), %%ymm4 \n\t" // temp1[0] "vbroadcastsd 8(%8), %%ymm5 \n\t" // temp1[1] "vbroadcastsd 16(%8), %%ymm6 \n\t" // temp1[1] "vbroadcastsd 24(%8), %%ymm7 \n\t" // temp1[1] "xorq %0,%0 \n\t" ".align 16 \n\t" "1: \n\t" "vmovups (%3,%0,8), %%ymm9 \n\t" // 2 * y "vmovups (%2,%0,8), %%ymm8 \n\t" // 2 * x "vmovups (%4,%0,8), %%ymm12 \n\t" // 2 * a "vmovups (%5,%0,8), %%ymm13 \n\t" // 2 * a "vmovups (%6,%0,8), %%ymm14 \n\t" // 2 * a "vmovups (%7,%0,8), %%ymm15 \n\t" // 2 * a "vmulpd %%ymm4, %%ymm12, %%ymm10 \n\t" "vaddpd %%ymm9, %%ymm10, %%ymm9 \n\t" "vmulpd %%ymm8, %%ymm12, %%ymm11 \n\t" "vaddpd %%ymm0, %%ymm11, %%ymm0 \n\t" "vmulpd %%ymm5, %%ymm13, %%ymm10 \n\t" "vaddpd %%ymm9, %%ymm10, %%ymm9 \n\t" "vmulpd %%ymm8, %%ymm13, %%ymm11 \n\t" "vaddpd %%ymm1, %%ymm11, %%ymm1 \n\t" "vmulpd %%ymm6, %%ymm14, %%ymm10 \n\t" "vaddpd %%ymm9, %%ymm10, %%ymm9 \n\t" "vmulpd %%ymm8, %%ymm14, %%ymm11 \n\t" "vaddpd %%ymm2, %%ymm11, %%ymm2 \n\t" "vmulpd %%ymm7, %%ymm15, %%ymm10 \n\t" "vaddpd %%ymm9, %%ymm10, %%ymm9 \n\t" "vmulpd %%ymm8, %%ymm15, %%ymm11 \n\t" "vaddpd %%ymm3, %%ymm11, %%ymm3 \n\t" "addq $4 , %0 \n\t" "subq $4 , %1 \n\t" "vmovups %%ymm9 , -32(%3,%0,8) \n\t" "jnz 1b \n\t" "vmovsd (%9), %%xmm4 \n\t" "vmovsd 8(%9), %%xmm5 \n\t" "vmovsd 16(%9), %%xmm6 \n\t" "vmovsd 24(%9), %%xmm7 \n\t" "vextractf128 $0x01, %%ymm0 , %%xmm12 \n\t" "vextractf128 $0x01, %%ymm1 , %%xmm13 \n\t" "vextractf128 $0x01, %%ymm2 , %%xmm14 \n\t" "vextractf128 $0x01, %%ymm3 , %%xmm15 \n\t" "vaddpd %%xmm0, %%xmm12, %%xmm0 \n\t" "vaddpd %%xmm1, %%xmm13, %%xmm1 \n\t" "vaddpd %%xmm2, %%xmm14, %%xmm2 \n\t" "vaddpd %%xmm3, %%xmm15, %%xmm3 \n\t" "vhaddpd %%xmm0, %%xmm0, %%xmm0 \n\t" "vhaddpd %%xmm1, %%xmm1, %%xmm1 \n\t" "vhaddpd %%xmm2, %%xmm2, %%xmm2 \n\t" "vhaddpd %%xmm3, %%xmm3, %%xmm3 \n\t" "vaddsd %%xmm4, %%xmm0, %%xmm0 \n\t" "vaddsd %%xmm5, %%xmm1, %%xmm1 \n\t" "vaddsd %%xmm6, %%xmm2, %%xmm2 \n\t" "vaddsd %%xmm7, %%xmm3, %%xmm3 \n\t" "vmovsd %%xmm0 , (%9) \n\t" // save temp2 "vmovsd %%xmm1 , 8(%9) \n\t" // save temp2 "vmovsd %%xmm2 ,16(%9) \n\t" // save temp2 "vmovsd %%xmm3 ,24(%9) \n\t" // save temp2 "vzeroupper \n\t" : : "r" (i), // 0 "r" (n), // 1 "r" (x), // 2 "r" (y), // 3 "r" (a0), // 4 "r" (a1), // 5 "r" (a2), // 6 "r" (a3), // 8 "r" (temp1), // 8 "r" (temp2) // 9 : "cc", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12", "%xmm13", "%xmm14", "%xmm15", "memory" ); }
// Filename: bioStream.h // Created by: drose (25Sep02) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) Carnegie Mellon University. All rights reserved. // // All use of this software is subject to the terms of the revised BSD // license. You should have received a copy of this license along // with this source code in a file named "LICENSE." // //////////////////////////////////////////////////////////////////// #ifndef BIOSTREAM_H #define BIOSTREAM_H #include "pandabase.h" // This module is not compiled if OpenSSL is not available. #ifdef HAVE_OPENSSL #include "socketStream.h" #include "bioStreamBuf.h" //////////////////////////////////////////////////////////////////// // Class : IBioStream // Description : An input stream object that reads data from an // OpenSSL BIO object. This is used by the HTTPClient // and HTTPChannel classes to provide a C++ interface // to OpenSSL. // // Seeking is not supported. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEXPRESS IBioStream : public ISocketStream { public: INLINE IBioStream(); INLINE IBioStream(BioPtr *source); INLINE IBioStream &open(BioPtr *source); virtual bool is_closed(); virtual void close(); virtual ReadState get_read_state(); private: BioStreamBuf _buf; }; //////////////////////////////////////////////////////////////////// // Class : OBioStream // Description : An output stream object that writes data to an // OpenSSL BIO object. This is used by the HTTPClient // and HTTPChannel classes to provide a C++ interface // to OpenSSL. // // Seeking is not supported. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEXPRESS OBioStream : public OSocketStream { public: INLINE OBioStream(); INLINE OBioStream(BioPtr *source); INLINE OBioStream &open(BioPtr *source); virtual bool is_closed(); virtual void close(); private: BioStreamBuf _buf; }; //////////////////////////////////////////////////////////////////// // Class : BioStream // Description : A bi-directional stream object that reads and writes // data to an OpenSSL BIO object. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEXPRESS BioStream : public SocketStream { public: INLINE BioStream(); INLINE BioStream(BioPtr *source); INLINE BioStream &open(BioPtr *source); virtual bool is_closed(); virtual void close(); private: BioStreamBuf _buf; }; #include "bioStream.I" #endif // HAVE_OPENSSL #endif
/** src/utils.c Set of utility functions for debugging purposes Copyright (C) 2007-2009 STMicroelectronics Copyright (C) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utils.h" char *stateName(OMX_STATETYPE state) { char *nameString; switch(state) { case 0: nameString = "OMX_StateInvalid"; break; case 1: nameString = "OMX_StateLoaded"; break; case 2: nameString = "OMX_StateIdle"; break; case 3: nameString = "OMX_StateExecuting"; break; case 4: nameString = "OMX_StatePause"; break; case 5: nameString = "OMX_StateWaitForResources"; break; default: nameString = '\0'; } return nameString; } char *transientStateName(int state) { char *nameString; switch(state) { case 0: nameString = "OMX_StateInvalid"; break; case 1: nameString = "OMX_TransStateLoadedToIdle"; break; case 2: nameString = "OMX_TransStateIdleToPause"; break; case 3: nameString = "OMX_TransStatePauseToExecuting"; break; case 4: nameString = "OMX_TransStateIdleToExecuting"; break; case 5: nameString = "OMX_TransStateExecutingToIdle"; break; case 6: nameString = "OMX_TransStateExecutingToPause"; break; case 7: nameString = "OMX_TransStatePauseToIdle"; break; case 8: nameString = "OMX_TransStateIdleToLoaded"; break; default: nameString = '\0'; } return nameString; } char *errorName(OMX_ERRORTYPE error) { char *nameString; switch(error) { case 0: nameString = "OMX_ErrorNone"; break; case 0x80001000: nameString = "OMX_ErrorInsufficientResources"; break; case 0x80001001: nameString = "OMX_ErrorUndefined"; break; case 0x80001002: nameString = "OMX_ErrorInvalidComponentName"; break; case 0x80001003: nameString = "OMX_ErrorComponentNotFound"; break; case 0x80001004: nameString = "OMX_ErrorInvalidComponent"; break; case 0x80001005: nameString = "OMX_ErrorBadParameter"; break; case 0x80001006: nameString = "OMX_ErrorNotImplemented"; break; case 0x80001007: nameString = "OMX_ErrorUnderflow"; break; case 0x80001008: nameString = "OMX_ErrorOverflow"; break; case 0x80001009: nameString = "OMX_ErrorHardware"; break; case 0x8000100A: nameString = "OMX_ErrorInvalidState"; break; case 0x8000100B: nameString = "OMX_ErrorStreamCorrupt"; break; case 0x8000100C: nameString = "OMX_ErrorPortsNotCompatible"; break; case 0x8000100D: nameString = "OMX_ErrorResourcesLost"; break; case 0x8000100E: nameString = "OMX_ErrorNoMore"; break; case 0x8000100F: nameString = "OMX_ErrorVersionMismatch"; break; case 0x80001010: nameString = "OMX_ErrorNotReady"; break; case 0x80001011: nameString = "OMX_ErrorTimeout"; break; case 0x80001012: nameString = "OMX_ErrorSameState"; break; case 0x80001013: nameString = "OMX_ErrorResourcesPreempted"; break; case 0x80001014: nameString = "OMX_ErrorPortUnresponsiveDuringAllocation"; break; case 0x80001015: nameString = "OMX_ErrorPortUnresponsiveDuringDeallocation"; break; case 0x80001016: nameString = "OMX_ErrorPortUnresponsiveDuringStop"; break; case 0x80001017: nameString = "OMX_ErrorIncorrectStateTransition"; break; case 0x80001018: nameString = "OMX_ErrorIncorrectStateOperation"; break; case 0x80001019: nameString = "OMX_ErrorUnsupportedSetting"; break; case 0x8000101A: nameString = "OMX_ErrorUnsupportedIndex"; break; case 0x8000101B: nameString = "OMX_ErrorBadPortIndex"; break; case 0x8000101C: nameString = "OMX_ErrorPortUnpopulated"; break; case 0x8000101D: nameString = "OMX_ErrorComponentSuspended"; break; case 0x8000101E: nameString = "OMX_ErrorDynamicResourcesUnavailable"; break; case 0x8000101F: nameString = "OMX_ErrorMbErrorsInFrame"; break; case 0x80001020: nameString = "OMX_ErrorFormatNotDetected"; break; case 0x80001021: nameString = "OMX_ErrorContentPipeOpenFailed"; break; case 0x80001022: nameString = "OMX_ErrorContentPipeCreationFailed"; break; case 0x80001023: nameString = "OMX_ErrorSeperateTablesUsed"; break; case 0x80001024: nameString = "OMX_ErrorTunnelingUnsupported"; break; default: nameString = '\0'; } return nameString; }
/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <pthread.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/mman.h> #include <sys/wait.h> static int do_test (void) { size_t ps = sysconf (_SC_PAGESIZE); char tmpfname[] = "/tmp/tst-mutex4.XXXXXX"; char data[ps]; void *mem; int fd; pthread_mutex_t *m; pthread_mutexattr_t a; pid_t pid; char *p; int err; int s; fd = mkstemp (tmpfname); if (fd == -1) { printf ("cannot open temporary file: %m\n"); return 1; } /* Make sure it is always removed. */ unlink (tmpfname); /* Create one page of data. */ memset (data, '\0', ps); /* Write the data to the file. */ if (write (fd, data, ps) != (ssize_t) ps) { puts ("short write"); return 1; } mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (mem == MAP_FAILED) { printf ("mmap failed: %m\n"); return 1; } m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t)) & ~(__alignof (pthread_mutex_t) - 1)); p = (char *) (m + 1); if (pthread_mutexattr_init (&a) != 0) { puts ("mutexattr_init failed"); return 1; } if (pthread_mutexattr_getpshared (&a, &s) != 0) { puts ("1st mutexattr_getpshared failed"); return 1; } if (s != PTHREAD_PROCESS_PRIVATE) { puts ("default pshared value wrong"); return 1; } if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0) { puts ("mutexattr_setpshared failed"); return 1; } if (pthread_mutexattr_getpshared (&a, &s) != 0) { puts ("2nd mutexattr_getpshared failed"); return 1; } if (s != PTHREAD_PROCESS_SHARED) { puts ("pshared value after setpshared call wrong"); return 1; } if (pthread_mutex_init (m, &a) != 0) { puts ("mutex_init failed"); return 1; } if (pthread_mutex_lock (m) != 0) { puts ("mutex_lock failed"); return 1; } if (pthread_mutexattr_destroy (&a) != 0) { puts ("mutexattr_destroy failed"); return 1; } err = pthread_mutex_trylock (m); if (err == 0) { puts ("mutex_trylock succeeded"); return 1; } else if (err != EBUSY) { puts ("mutex_trylock didn't return EBUSY"); return 1; } *p = 0; puts ("going to fork now"); pid = fork (); if (pid == -1) { puts ("fork failed"); return 1; } else if (pid == 0) { /* Play some lock ping-pong. It's our turn to unlock first. */ if ((*p)++ != 0) { puts ("child: *p != 0"); return 1; } if (pthread_mutex_unlock (m) != 0) { puts ("child: 1st mutex_unlock failed"); return 1; } puts ("child done"); } else { if (pthread_mutex_lock (m) != 0) { puts ("parent: 2nd mutex_lock failed"); return 1; } if (*p != 1) { puts ("*p != 1"); return 1; } puts ("parent done"); } return 0; } #define TIMEOUT 4 #define TEST_FUNCTION do_test () #include "../test-skeleton.c"
#include <winpr/crt.h> #include <winpr/error.h> #include <winpr/wtsapi.h> int TestWtsApiExtraDynamicVirtualChannel(int argc, char* argv[]) { BOOL bSuccess; ULONG length; ULONG bytesRead; ULONG bytesWritten; BYTE buffer[1024]; HANDLE hVirtualChannel; length = sizeof(buffer); hVirtualChannel = WTSVirtualChannelOpenEx( WTS_CURRENT_SESSION, "ECHO",WTS_CHANNEL_OPTION_DYNAMIC); if (hVirtualChannel == INVALID_HANDLE_VALUE) { printf("WTSVirtualChannelOpen failed: %"PRIu32"\n", GetLastError()); return -1; } printf("WTSVirtualChannelOpen opend"); bytesWritten = 0; bSuccess = WTSVirtualChannelWrite(hVirtualChannel, (PCHAR) buffer, length, &bytesWritten); if (!bSuccess) { printf("WTSVirtualChannelWrite failed: %"PRIu32"\n", GetLastError()); return -1; } printf("WTSVirtualChannelWrite written"); bytesRead = 0; bSuccess = WTSVirtualChannelRead(hVirtualChannel, 5000, (PCHAR) buffer, length, &bytesRead); if (!bSuccess) { printf("WTSVirtualChannelRead failed: %"PRIu32"\n", GetLastError()); return -1; } printf("WTSVirtualChannelRead read"); if (!WTSVirtualChannelClose(hVirtualChannel)) { printf("WTSVirtualChannelClose failed\n"); return -1; } return 0; }
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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 itkGaussianTransferFunction_h #define itkGaussianTransferFunction_h #include "itkTransferFunctionBase.h" namespace itk { namespace Statistics { /** \class GaussianTransferFunction * \brief This is the itkGaussianTransferFunction class. * * \ingroup ITKNeuralNetworks */ template<typename ScalarType> class GaussianTransferFunction : public TransferFunctionBase<ScalarType> { public: /** Standard class typedefs. */ typedef GaussianTransferFunction Self; typedef TransferFunctionBase<ScalarType> Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; /** Run-time type information (and related methods). */ itkTypeMacro(GaussianTransferFunction, TransferFunctionBase); /** Method for creation through the object factory. */ itkNewMacro(Self); /** Evaluate at the specified input position */ virtual ScalarType Evaluate(const ScalarType& input) const; /** Evaluate the derivative at the specified input position */ virtual ScalarType EvaluateDerivative(const ScalarType& input) const; protected: GaussianTransferFunction(); virtual ~GaussianTransferFunction(); /** Method to print the object. */ virtual void PrintSelf( std::ostream& os, Indent indent ) const; };//class } // end namespace Statistics } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkGaussianTransferFunction.hxx" #endif #endif
//===-- AMDGPUISelLowering.h - AMDGPU Lowering Interface --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file contains the interface defintiion of the TargetLowering class // that is common to all AMD GPUs. // //===----------------------------------------------------------------------===// #ifndef AMDGPUISELLOWERING_H #define AMDGPUISELLOWERING_H #include "llvm/Target/TargetLowering.h" namespace llvm { class MachineRegisterInfo; class AMDGPUTargetLowering : public TargetLowering { private: SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const; SDValue LowerUDIVREM(SDValue Op, SelectionDAG &DAG) const; protected: /// CreateLiveInRegister - Helper function that adds Reg to the LiveIn list /// of the DAG's MachineFunction. This returns a Register SDNode representing /// Reg. SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC, unsigned Reg, EVT VT) const; bool isHWTrueValue(SDValue Op) const; bool isHWFalseValue(SDValue Op) const; public: AMDGPUTargetLowering(TargetMachine &TM); virtual SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl<ISD::InputArg> &Ins, DebugLoc DL, SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const; virtual SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl<ISD::OutputArg> &Outs, const SmallVectorImpl<SDValue> &OutVals, DebugLoc DL, SelectionDAG &DAG) const; virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; SDValue LowerIntrinsicIABS(SDValue Op, SelectionDAG &DAG) const; SDValue LowerIntrinsicLRP(SDValue Op, SelectionDAG &DAG) const; virtual const char* getTargetNodeName(unsigned Opcode) const; // Functions defined in AMDILISelLowering.cpp public: /// computeMaskedBitsForTargetNode - Determine which of the bits specified /// in Mask are known to be either zero or one and return them in the /// KnownZero/KnownOne bitsets. virtual void computeMaskedBitsForTargetNode(const SDValue Op, APInt &KnownZero, APInt &KnownOne, const SelectionDAG &DAG, unsigned Depth = 0) const; virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, unsigned Intrinsic) const; /// isFPImmLegal - We want to mark f32/f64 floating point values as legal. bool isFPImmLegal(const APFloat &Imm, EVT VT) const; /// ShouldShrinkFPConstant - We don't want to shrink f64/f32 constants. bool ShouldShrinkFPConstant(EVT VT) const; private: void InitAMDILLowering(); SDValue LowerSREM(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSREM8(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSREM16(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSREM32(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSREM64(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSDIV(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSDIV24(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSDIV32(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSDIV64(SDValue Op, SelectionDAG &DAG) const; SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const; EVT genIntType(uint32_t size = 32, uint32_t numEle = 1) const; SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const; SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const; }; namespace AMDGPUISD { enum { // AMDIL ISD Opcodes FIRST_NUMBER = ISD::BUILTIN_OP_END, MAD, // 32bit Fused Multiply Add instruction VBUILD, // scalar to vector mov instruction CALL, // Function call based on a single integer UMUL, // 32bit unsigned multiplication DIV_INF, // Divide with infinity returned on zero divisor RET_FLAG, BRANCH_COND, // End AMDIL ISD Opcodes BITALIGN, FRACT, FMAX, SMAX, UMAX, FMIN, SMIN, UMIN, URECIP, LAST_AMDGPU_ISD_NUMBER }; } // End namespace AMDGPUISD namespace SIISD { enum { SI_FIRST = AMDGPUISD::LAST_AMDGPU_ISD_NUMBER, VCC_AND, VCC_BITCAST }; } // End namespace SIISD } // End namespace llvm #endif // AMDGPUISELLOWERING_H
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow | FileCheck %s --check-prefix=CATCH_UB // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER // Tests for signed integer overflow stuff. // rdar://7432000 rdar://7221421 void test1() { // DEFAULT-LABEL: define void @test1 // WRAPV-LABEL: define void @test1 // TRAPV-LABEL: define void @test1 extern volatile int f11G, a, b; // DEFAULT: add nsw i32 // WRAPV: add i32 // TRAPV: llvm.sadd.with.overflow.i32 // CATCH_UB: llvm.sadd.with.overflow.i32 // TRAPV_HANDLER: foo( f11G = a + b; // DEFAULT: sub nsw i32 // WRAPV: sub i32 // TRAPV: llvm.ssub.with.overflow.i32 // CATCH_UB: llvm.ssub.with.overflow.i32 // TRAPV_HANDLER: foo( f11G = a - b; // DEFAULT: mul nsw i32 // WRAPV: mul i32 // TRAPV: llvm.smul.with.overflow.i32 // CATCH_UB: llvm.smul.with.overflow.i32 // TRAPV_HANDLER: foo( f11G = a * b; // DEFAULT: sub nsw i32 0, // WRAPV: sub i32 0, // TRAPV: llvm.ssub.with.overflow.i32(i32 0 // CATCH_UB: llvm.ssub.with.overflow.i32(i32 0 // TRAPV_HANDLER: foo( f11G = -a; // PR7426 - Overflow checking for increments. // DEFAULT: add nsw i32 {{.*}}, 1 // WRAPV: add i32 {{.*}}, 1 // TRAPV: llvm.sadd.with.overflow.i32({{.*}}, i32 1) // CATCH_UB: llvm.sadd.with.overflow.i32({{.*}}, i32 1) // TRAPV_HANDLER: foo( ++a; // DEFAULT: add nsw i32 {{.*}}, -1 // WRAPV: add i32 {{.*}}, -1 // TRAPV: llvm.ssub.with.overflow.i32({{.*}}, i32 1) // CATCH_UB: llvm.ssub.with.overflow.i32({{.*}}, i32 1) // TRAPV_HANDLER: foo( --a; // -fwrapv should turn off inbounds for GEP's, PR9256 extern int* P; ++P; // DEFAULT: getelementptr inbounds i32, i32* // WRAPV: getelementptr i32, i32* // TRAPV: getelementptr inbounds i32, i32* // CATCH_UB: getelementptr inbounds i32, i32* // PR9350: char pre-increment never overflows. extern volatile signed char PR9350_char_inc; // DEFAULT: add i8 {{.*}}, 1 // WRAPV: add i8 {{.*}}, 1 // TRAPV: add i8 {{.*}}, 1 // CATCH_UB: add i8 {{.*}}, 1 ++PR9350_char_inc; // PR9350: char pre-decrement never overflows. extern volatile signed char PR9350_char_dec; // DEFAULT: add i8 {{.*}}, -1 // WRAPV: add i8 {{.*}}, -1 // TRAPV: add i8 {{.*}}, -1 // CATCH_UB: add i8 {{.*}}, -1 --PR9350_char_dec; // PR9350: short pre-increment never overflows. extern volatile signed short PR9350_short_inc; // DEFAULT: add i16 {{.*}}, 1 // WRAPV: add i16 {{.*}}, 1 // TRAPV: add i16 {{.*}}, 1 // CATCH_UB: add i16 {{.*}}, 1 ++PR9350_short_inc; // PR9350: short pre-decrement never overflows. extern volatile signed short PR9350_short_dec; // DEFAULT: add i16 {{.*}}, -1 // WRAPV: add i16 {{.*}}, -1 // TRAPV: add i16 {{.*}}, -1 // CATCH_UB: add i16 {{.*}}, -1 --PR9350_short_dec; // PR24256: don't instrument __builtin_frame_address. __builtin_frame_address(0 + 0); // DEFAULT: call i8* @llvm.frameaddress(i32 0) // WRAPV: call i8* @llvm.frameaddress(i32 0) // TRAPV: call i8* @llvm.frameaddress(i32 0) // CATCH_UB: call i8* @llvm.frameaddress(i32 0) }
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_LOG_SOURCES_CHROME_INTERNAL_LOG_SOURCE_H_ #define CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_LOG_SOURCES_CHROME_INTERNAL_LOG_SOURCE_H_ #include "base/macros.h" #include "build/build_config.h" #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h" namespace system_logs { // Fetches internal Chrome logs. class ChromeInternalLogSource : public SystemLogsSource { public: ChromeInternalLogSource(); ~ChromeInternalLogSource() override; // SystemLogsSource override. void Fetch(const SysLogsSourceCallback& request) override; private: void PopulateSyncLogs(SystemLogsResponse* response); void PopulateExtensionInfoLogs(SystemLogsResponse* response); void PopulateDataReductionProxyLogs(SystemLogsResponse* response); #if defined(OS_WIN) void PopulateUsbKeyboardDetected(SystemLogsResponse* response); #endif DISALLOW_COPY_AND_ASSIGN(ChromeInternalLogSource); }; } // namespace system_logs #endif // CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_LOG_SOURCES_CHROME_INTERNAL_LOG_SOURCE_H_
// Copyright (c) 2010 libmv authors. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. #ifndef LIBMV_MULTIVIEW_ROBUST_AFFINE_H_ #define LIBMV_MULTIVIEW_ROBUST_AFFINE_H_ #include "libmv/base/vector.h" #include "libmv/numeric/numeric.h" namespace libmv { /** Robust 2D affine transformation estimation * * This function estimates robustly the 2d affine matrix between two dataset * of 2D point (image coords space). The 2d affine solver relies on the 3 * points solution. * * \param[in] x1 The first 2xN matrix of euclidean points * \param[in] x2 The second 2xN matrix of euclidean points * \param[in] max_error maximum error (in pixels) * \param[out] H The 3x3 affine transformation matrix (6 dof) * with the following parametrization * |a b tx| * H = |c d ty| * |0 0 1 | * such that x2 = H * x1 * \param[out] inliers the indexes list of the detected inliers * \param[in] outliers_probability outliers probability (in ]0,1[). * The number of iterations is controlled using the following equation: * n_iter = log(outliers_prob) / log(1.0 - pow(inlier_ratio, min_samples))) * The more this value is high, the less the function selects ramdom samples. * * \return the best error found (in pixels), associated to the solution H * * \note The function needs at least 3 points * \note The overall iteration limit is 1000 */ double Affine2DFromCorrespondences3PointRobust( const Mat &x1, const Mat &x2, double max_error, Mat3 *H, vector<int> *inliers = NULL, double outliers_probability = 1e-2); } // namespace libmv #endif // LIBMV_MULTIVIEW_ROBUST_AFFINE_H_
/* * Common LSM logging functions * Heavily borrowed from selinux/avc.h * * Author : Etienne BASSET <etienne.basset@ensta.org> * * All credits to : Stephen Smalley, <sds@tycho.nsa.gov> * All BUGS to : Etienne BASSET <etienne.basset@ensta.org> */ #ifndef _LSM_COMMON_LOGGING_ #define _LSM_COMMON_LOGGING_ #include <linux/stddef.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/kdev_t.h> #include <linux/spinlock.h> #include <linux/init.h> #include <linux/audit.h> #include <linux/in6.h> #include <linux/path.h> #include <linux/key.h> #include <linux/skbuff.h> #include <rdma/ib_verbs.h> struct lsm_network_audit { int netif; struct sock *sk; u16 family; __be16 dport; __be16 sport; union { struct { __be32 daddr; __be32 saddr; } v4; struct { struct in6_addr daddr; struct in6_addr saddr; } v6; } fam; }; struct lsm_ioctlop_audit { struct path path; u16 cmd; }; struct lsm_ibpkey_audit { u64 subnet_prefix; u16 pkey; }; struct lsm_ibendport_audit { char dev_name[IB_DEVICE_NAME_MAX]; u8 port; }; /* Auxiliary data to use in generating the audit record. */ struct common_audit_data { char type; #define LSM_AUDIT_DATA_PATH 1 #define LSM_AUDIT_DATA_NET 2 #define LSM_AUDIT_DATA_CAP 3 #define LSM_AUDIT_DATA_IPC 4 #define LSM_AUDIT_DATA_TASK 5 #define LSM_AUDIT_DATA_KEY 6 #define LSM_AUDIT_DATA_NONE 7 #define LSM_AUDIT_DATA_KMOD 8 #define LSM_AUDIT_DATA_INODE 9 #define LSM_AUDIT_DATA_DENTRY 10 #define LSM_AUDIT_DATA_IOCTL_OP 11 #define LSM_AUDIT_DATA_FILE 12 #define LSM_AUDIT_DATA_IBPKEY 13 #define LSM_AUDIT_DATA_IBENDPORT 14 union { struct path path; struct dentry *dentry; struct inode *inode; struct lsm_network_audit *net; int cap; int ipc_id; struct task_struct *tsk; #ifdef CONFIG_KEYS struct { key_serial_t key; char *key_desc; } key_struct; #endif char *kmod_name; struct lsm_ioctlop_audit *op; struct file *file; struct lsm_ibpkey_audit *ibpkey; struct lsm_ibendport_audit *ibendport; } u; /* this union contains LSM specific data */ union { #ifdef CONFIG_SECURITY_SMACK struct smack_audit_data *smack_audit_data; #endif #ifdef CONFIG_SECURITY_SELINUX struct selinux_audit_data *selinux_audit_data; #endif #ifdef CONFIG_SECURITY_APPARMOR struct apparmor_audit_data *apparmor_audit_data; #endif }; /* per LSM data pointer union */ }; #define v4info fam.v4 #define v6info fam.v6 int ipv4_skb_to_auditdata(struct sk_buff *skb, struct common_audit_data *ad, u8 *proto); int ipv6_skb_to_auditdata(struct sk_buff *skb, struct common_audit_data *ad, u8 *proto); void common_lsm_audit(struct common_audit_data *a, void (*pre_audit)(struct audit_buffer *, void *), void (*post_audit)(struct audit_buffer *, void *)); #endif
/* * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #include <dirent.h> #include <errno.h> #define __need_NULL #include <stddef.h> #include "dirstream.h" #ifndef __READDIR # define __READDIR readdir # define __DIRENT_TYPE struct dirent # define __GETDENTS __getdents #endif __DIRENT_TYPE *__READDIR(DIR * dir) { ssize_t bytes; __DIRENT_TYPE *de; if (!dir) { __set_errno(EBADF); return NULL; } __UCLIBC_MUTEX_LOCK(dir->dd_lock); do { if (dir->dd_size <= dir->dd_nextloc) { /* read dir->dd_max bytes of directory entries. */ bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max); if (bytes <= 0) { de = NULL; goto all_done; } dir->dd_size = bytes; dir->dd_nextloc = 0; } de = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc); /* Am I right? H.J. */ dir->dd_nextloc += de->d_reclen; /* We have to save the next offset here. */ dir->dd_nextoff = de->d_off; /* Skip deleted files. */ } while (de->d_ino == 0); all_done: __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); return de; } libc_hidden_def(__READDIR) #if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 strong_alias_untyped(readdir,readdir64) libc_hidden_def(readdir64) #endif
//* This file is part of the MOOSE framework //* https://www.mooseframework.org //* //* All rights reserved, see COPYRIGHT for full restrictions //* https://github.com/idaholab/moose/blob/master/COPYRIGHT //* //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html #pragma once #include "RichardsSeff.h" #include "RichardsSeffVG.h" /** * van-Genuchten water effective saturation as a function of (Pwater, Pgas), * and its derivs wrt to those pressures. Note that the water pressure appears * first in the tuple (Pwater, Pgas) */ class RichardsSeff2waterVG : public RichardsSeff { public: static InputParameters validParams(); RichardsSeff2waterVG(const InputParameters & parameters); /** * water effective saturation * @param p porepressures. Here (*p[0])[qp] is the water pressure at quadpoint qp, and * (*p[1])[qp] is the gas porepressure * @param qp the quadpoint to evaluate effective saturation at */ Real seff(std::vector<const VariableValue *> p, unsigned int qp) const; /** * derivative of effective saturation as a function of porepressure * @param p porepressure in the element. Note that (*p[0])[qp] is the porepressure at quadpoint * qp * @param qp the quad point to evaluate effective saturation at * @param result the derivtives will be placed in this array */ void dseff(std::vector<const VariableValue *> p, unsigned int qp, std::vector<Real> & result) const; /** * second derivative of effective saturation as a function of porepressure * @param p porepressure in the element. Note that (*p[0])[qp] is the porepressure at quadpoint * qp * @param qp the quad point to evaluate effective saturation at * @param result the derivtives will be placed in this array */ void d2seff(std::vector<const VariableValue *> p, unsigned int qp, std::vector<std::vector<Real>> & result) const; protected: /// van Genuchten alpha parameter Real _al; /// van Genuchten m parameter Real _m; };
/* Recreated Espressif libpp lmac.o contents. Copyright (C) 2015 Espressif Systems. Derived from MIT Licensed SDK libraries. BSD Licensed as described in the file LICENSE */ #include "open_esplibs.h" #if OPEN_LIBPP_LMAC // The contents of this file are only built if OPEN_LIBPHY_PHY_CHIP_SLEEP is set to true #endif /* OPEN_LIBPP_LMAC */
// MiniPieFrame.h : interface of the CMiniPieFrame class // ///////////////////////////////////////////////////////////////////////////// #pragma once #define ID_TITLE 0 // Document title uses StatusBar pane 0 #define ID_BROWSER 1 // DispEvent ID class CMiniPieFrame : public CFrameWindowImpl<CMiniPieFrame>, public CUpdateUI<CMiniPieFrame>, public CAppWindow<CMiniPieFrame>, public CFullScreenFrame<CMiniPieFrame>, public CMessageFilter, public CIdleHandler, public IDispEventImpl<ID_BROWSER, CMiniPieFrame> { public: DECLARE_APP_FRAME_CLASS(NULL, IDR_MAINFRAME, L"Software\\WTL\\MiniPie") // Data members CAxWindow m_browser; CComPtr<IWebBrowser2> m_spIWebBrowser2; // Message filter virtual BOOL PreTranslateMessage(MSG* pMsg); // CAppWindow operations bool AppNewInstance( LPCTSTR lpstrCmdLine); void AppSave(); // Implementation void UpdateLayout(BOOL bResizeBars = TRUE); BOOL SetCommandButton(INT iID, bool bRight = false); void Navigate(LPCTSTR sUrl); // Idle handler and UI map virtual BOOL OnIdle(); BEGIN_UPDATE_UI_MAP(CMiniPieFrame) UPDATE_ELEMENT(ID_TITLE, UPDUI_STATUSBAR) UPDATE_ELEMENT(ID_VIEW_FULLSCREEN, UPDUI_MENUPOPUP) UPDATE_ELEMENT(ID_VIEW_STATUS_BAR, UPDUI_MENUPOPUP) UPDATE_ELEMENT(ID_VIEW_ADDRESSBAR, UPDUI_MENUPOPUP) UPDATE_ELEMENT(IDM_BACK, UPDUI_MENUPOPUP) UPDATE_ELEMENT(IDM_FORWARD, UPDUI_MENUPOPUP) UPDATE_ELEMENT(IDM_STOP, UPDUI_MENUPOPUP | UPDUI_TOOLBAR) UPDATE_ELEMENT(IDM_REFRESH, UPDUI_MENUPOPUP | UPDUI_TOOLBAR) END_UPDATE_UI_MAP() // Message map and handlers BEGIN_MSG_MAP(CMiniPieFrame) MESSAGE_HANDLER(WM_CREATE, OnCreate) COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit) COMMAND_ID_HANDLER(ID_VIEW_FULLSCREEN, OnFullScreen) COMMAND_ID_HANDLER(ID_VIEW_STATUS_BAR, OnViewStatusBar) #ifdef WIN32_PLATFORM_PSPC COMMAND_ID_HANDLER(ID_VIEW_ADDRESSBAR, OnViewAddressBar) #endif COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout) COMMAND_RANGE_HANDLER(IDM_FORWARD, IDM_STOP, OnBrowserCmd) COMMAND_ID_HANDLER(IDM_OPENURL, OnOpenURL) CHAIN_MSG_MAP(CAppWindow<CMiniPieFrame>) CHAIN_MSG_MAP(CFullScreenFrame<CMiniPieFrame>) CHAIN_MSG_MAP(CUpdateUI<CMiniPieFrame>) CHAIN_MSG_MAP(CFrameWindowImpl<CMiniPieFrame>) END_MSG_MAP() LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnFullScreen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnViewStatusBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); #ifdef WIN32_PLATFORM_PSPC LRESULT OnViewAddressBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); #endif LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnBrowserCmd(WORD /*wNotifyCode*/, WORD wID/**/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnOpenURL(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); // IWebBrowser2 event map and handlers BEGIN_SINK_MAP(CMiniPieFrame) SINK_ENTRY(ID_BROWSER, DISPID_BEFORENAVIGATE2, OnBeforeNavigate2) SINK_ENTRY(ID_BROWSER, DISPID_TITLECHANGE, OnBrowserTitleChange) SINK_ENTRY(ID_BROWSER, DISPID_NAVIGATECOMPLETE2, OnNavigateComplete2) SINK_ENTRY(ID_BROWSER, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete) SINK_ENTRY(ID_BROWSER, DISPID_COMMANDSTATECHANGE, OnCommandStateChange) END_SINK_MAP() private: void __stdcall OnBeforeNavigate2(IDispatch* pDisp, VARIANT * pvtURL, VARIANT * /*pvtFlags*/, VARIANT * pvtTargetFrameName, VARIANT * /*pvtPostData*/, VARIANT * /*pvtHeaders*/, VARIANT_BOOL * /*pvbCancel*/); void __stdcall OnBrowserTitleChange(BSTR bstrTitleText); void __stdcall OnNavigateComplete2(IDispatch* pDisp, VARIANT * pvtURL); void __stdcall OnDocumentComplete(IDispatch* pDisp, VARIANT * pvtURL); void __stdcall OnCommandStateChange(long lCommand, BOOL bEnable); };
/****************************************************************************** * * Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * Use of the Software is limited solely to applications: * (a) running on a Xilinx device, or * (b) that interact with a Xilinx device through a bus or interconnect. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of the Xilinx shall not be used * in advertising or otherwise to promote the sale, use or other dealings in * this Software without prior written authorization from Xilinx. * ******************************************************************************/ /***************************************************************************** * * @file sleep.c * * This function provides a second delay using the Global Timer register in * the ARM Cortex A9 MP core. * * <pre> * MODIFICATION HISTORY: * * Ver Who Date Changes * ----- -------- -------- ----------------------------------------------- * 1.00a ecm/sdm 11/11/09 First release * 3.07a sgd 07/05/12 Updated sleep function to make use Global Timer * </pre> * ******************************************************************************/ /***************************** Include Files *********************************/ #include "sleep.h" #include "xtime_l.h" #include "xparameters.h" /*****************************************************************************/ /* * * This API is used to provide delays in seconds * * @param seconds requested * * @return 0 always * * @note None. * ****************************************************************************/ int sleep(unsigned int seconds) { XTime tEnd, tCur; XTime_GetTime(&tCur); tEnd = tCur + ((XTime) seconds) * COUNTS_PER_SECOND; do { XTime_GetTime(&tCur); } while (tCur < tEnd); return 0; }
/*************************************************************************** * Copyright (c) 2013 Luke Parry <l.parry@warwick.ac.uk> * * Copyright (c) 2014 WandererFan <wandererfan@gmail.com> * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #ifndef DRAWINGGUI_QGRAPHICSITEMVIEWSYMBOL_H #define DRAWINGGUI_QGRAPHICSITEMVIEWSYMBOL_H #include <QObject> #include <QPainter> #include <QString> #include <QByteArray> #include <QSvgRenderer> #include <QGraphicsSvgItem> #include "QGIView.h" namespace TechDraw { class DrawViewSymbol; } namespace TechDrawGui { class QGCustomSvg; class QGDisplayArea; class TechDrawGuiExport QGIViewSymbol : public QGIView { public: QGIViewSymbol(); ~QGIViewSymbol(); enum {Type = QGraphicsItem::UserType + 121}; int type() const override { return Type;} virtual void updateView(bool update = false) override; void setViewSymbolFeature(TechDraw::DrawViewSymbol *obj); virtual void draw() override; virtual void rotateView(void) override; protected: virtual void drawSvg(); void symbolToSvg(QByteArray qba); QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; QGDisplayArea* m_displayArea; QGCustomSvg *m_svgItem; }; } // namespace #endif // DRAWINGGUI_QGRAPHICSITEMVIEWSYMBOL_H
/* Processed by ecpg (regression mode) */ /* These include files are added by the preprocessor */ #include <ecpglib.h> #include <ecpgerrno.h> #include <sqlca.h> /* End of automatic include section */ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) #line 1 "func.pgc" #include <stdio.h> #include <stdlib.h> #include <string.h> #line 1 "regression.h" #line 5 "func.pgc" int main() { #line 8 "func.pgc" char text [ 25 ] ; #line 8 "func.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } #line 11 "func.pgc" { ECPGsetcommit(__LINE__, "on", NULL);} #line 13 "func.pgc" /* exec sql whenever sql_warning sqlprint ; */ #line 14 "func.pgc" /* exec sql whenever sqlerror sqlprint ; */ #line 15 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table My_Table ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT); #line 17 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 17 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 17 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table Log ( name text , w text )", ECPGt_EOIT, ECPGt_EORT); #line 18 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 18 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 18 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create function My_Table_Check ( ) returns trigger as $test$\ BEGIN\ INSERT INTO Log VALUES(TG_NAME, TG_WHEN);\ RETURN NEW;\ END; $test$ language plpgsql", ECPGt_EOIT, ECPGt_EORT); #line 26 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 26 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create trigger My_Table_Check_Trigger before insert on My_Table for each row execute procedure My_Table_Check ( )", ECPGt_EOIT, ECPGt_EORT); #line 32 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 32 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 1234 , 'Some random text' )", ECPGt_EOIT, ECPGt_EORT); #line 34 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 34 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 34 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 5678 , 'The Quick Brown' )", ECPGt_EOIT, ECPGt_EORT); #line 35 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 35 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 35 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select name from Log limit 1", ECPGt_EOIT, ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 36 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 36 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 36 "func.pgc" printf("Trigger %s fired.\n", text); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop trigger My_Table_Check_Trigger on My_Table", ECPGt_EOIT, ECPGt_EORT); #line 39 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 39 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 39 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop function My_Table_Check ( )", ECPGt_EOIT, ECPGt_EORT); #line 40 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 40 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 40 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table Log", ECPGt_EOIT, ECPGt_EORT); #line 41 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 41 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 41 "func.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table", ECPGt_EOIT, ECPGt_EORT); #line 42 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 42 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 42 "func.pgc" { ECPGdisconnect(__LINE__, "ALL"); #line 44 "func.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 44 "func.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 44 "func.pgc" return 0; }
/* libs/graphics/animator/SkDisplayType.h ** ** Copyright 2006, 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 SkDisplayType_DEFINED #define SkDisplayType_DEFINED #include "SkMath.h" #include "SkScalar.h" #ifdef SK_DEBUG #ifdef SK_CAN_USE_FLOAT #define SK_DUMP_ENABLED #endif #ifdef SK_BUILD_FOR_MAC #define SK_FIND_LEAKS #endif #endif #define SK_LITERAL_STR_EQUAL(str, token, len) (sizeof(str) - 1 == len \ && strncmp(str, token, sizeof(str) - 1) == 0) class SkAnimateMaker; class SkDisplayable; struct SkMemberInfo; enum SkDisplayTypes { SkType_Unknown, SkType_Math, // for ecmascript compatible Math functions and constants SkType_Number, // for for ecmascript compatible Number functions and constants SkType_Add, SkType_AddCircle, SkType_AddGeom, SkType_AddMode, SkType_AddOval, SkType_AddPath, SkType_AddRect, // path part SkType_AddRoundRect, SkType_Align, SkType_Animate, SkType_AnimateBase, // base type for animate, set SkType_Apply, SkType_ApplyMode, SkType_ApplyTransition, SkType_Array, SkType_ARGB, SkType_Base64, SkType_BaseBitmap, SkType_BaseClassInfo, SkType_Bitmap, SkType_BitmapEncoding, SkType_BitmapFormat, SkType_BitmapShader, SkType_Blur, SkType_Boolean, // can have values -1 (uninitialized), 0, 1 SkType_Boundable, SkType_Bounds, SkType_Cap, SkType_Clear, SkType_Clip, SkType_Close, SkType_Color, SkType_CubicTo, SkType_Dash, SkType_DataInput, SkType_Discrete, SkType_Displayable, SkType_Drawable, SkType_DrawTo, SkType_Dump, SkType_DynamicString, // evaluate at draw time SkType_Emboss, SkType_Event, SkType_EventCode, SkType_EventKind, SkType_EventMode, SkType_FillType, SkType_FilterType, SkType_Float, SkType_FontStyle, SkType_FromPath, SkType_FromPathMode, SkType_Full, SkType_Gradient, SkType_Group, SkType_HitClear, SkType_HitTest, SkType_Image, SkType_Include, SkType_Input, SkType_Int, SkType_Join, SkType_Line, // simple line primitive SkType_LineTo, // used as part of path construction SkType_LinearGradient, SkType_MaskFilter, SkType_MaskFilterBlurStyle, SkType_MaskFilterLight, SkType_Matrix, SkType_MemberFunction, SkType_MemberProperty, SkType_Move, SkType_MoveTo, SkType_Movie, SkType_MSec, SkType_Oval, SkType_Paint, SkType_Path, SkType_PathDirection, SkType_PathEffect, SkType_Point, // used inside other structures, no vtable SkType_DrawPoint, // used to draw points, has a vtable SkType_PolyToPoly, SkType_Polygon, SkType_Polyline, SkType_Post, SkType_QuadTo, SkType_RCubicTo, SkType_RLineTo, SkType_RMoveTo, SkType_RQuadTo, SkType_RadialGradient, SkType_Random, SkType_Rect, SkType_RectToRect, SkType_Remove, SkType_Replace, SkType_Rotate, SkType_RoundRect, SkType_Save, SkType_SaveLayer, SkType_Scale, SkType_Screenplay, SkType_Set, SkType_Shader, SkType_Skew, SkType_3D_Camera, SkType_3D_Patch, SkType_3D_Point, SkType_Snapshot, SkType_String, // pointer to SkString SkType_Style, SkType_Text, SkType_TextBox, SkType_TextBoxAlign, SkType_TextBoxMode, SkType_TextOnPath, SkType_TextToPath, SkType_TileMode, SkType_Translate, SkType_TransparentShader, SkType_Typeface, SkType_Xfermode, kNumberOfTypes }; struct TypeNames { const char* fName; SkDisplayTypes fType; #if defined SK_DEBUG || defined SK_BUILD_CONDENSED bool fDrawPrefix; bool fDisplayPrefix; #endif }; #ifdef SK_DEBUG typedef SkDisplayTypes SkFunctionParamType; #else typedef unsigned char SkFunctionParamType; #endif extern const TypeNames gTypeNames[]; extern const int kTypeNamesSize; class SkDisplayType { public: static SkDisplayTypes Find(SkAnimateMaker* , const SkMemberInfo* ); static const SkMemberInfo* GetMember(SkAnimateMaker* , SkDisplayTypes , const char** ); static const SkMemberInfo* GetMembers(SkAnimateMaker* , SkDisplayTypes , int* infoCountPtr); static SkDisplayTypes GetParent(SkAnimateMaker* , SkDisplayTypes ); static bool IsDisplayable(SkAnimateMaker* , SkDisplayTypes ); static bool IsEnum(SkAnimateMaker* , SkDisplayTypes ); static bool IsStruct(SkAnimateMaker* , SkDisplayTypes ); static SkDisplayTypes RegisterNewType(); static SkDisplayTypes Resolve(const char[] , const SkMemberInfo** ); #ifdef SK_DEBUG static bool IsAnimate(SkDisplayTypes type ) { return type == SkType_Animate || type == SkType_Set; } static const char* GetName(SkAnimateMaker* , SkDisplayTypes ); #endif #ifdef SK_SUPPORT_UNITTEST static void UnitTest(); #endif #if defined SK_DEBUG || defined SK_BUILD_CONDENSED static void BuildCondensedInfo(SkAnimateMaker* ); #endif static SkDisplayTypes GetType(SkAnimateMaker* , const char[] , size_t len); static SkDisplayable* CreateInstance(SkAnimateMaker* , SkDisplayTypes ); private: static SkDisplayTypes gNewTypes; }; #endif // SkDisplayType_DEFINED
#ifndef _VKMS_DRV_H_ #define _VKMS_DRV_H_ #include <drm/drmP.h> #include <drm/drm.h> #include <drm/drm_gem.h> #include <drm/drm_encoder.h> #include <linux/hrtimer.h> #define XRES_MIN 20 #define YRES_MIN 20 #define XRES_DEF 1024 #define YRES_DEF 768 #define XRES_MAX 8192 #define YRES_MAX 8192 extern bool enable_cursor; static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; static const u32 vkms_cursor_formats[] = { DRM_FORMAT_ARGB8888, }; struct vkms_crc_data { struct drm_framebuffer fb; struct drm_rect src, dst; unsigned int offset; unsigned int pitch; unsigned int cpp; }; /** * vkms_plane_state - Driver specific plane state * @base: base plane state * @crc_data: data required for CRC computation */ struct vkms_plane_state { struct drm_plane_state base; struct vkms_crc_data *crc_data; }; /** * vkms_crtc_state - Driver specific CRTC state * @base: base CRTC state * @crc_work: work struct to compute and add CRC entries * @n_frame_start: start frame number for computed CRC * @n_frame_end: end frame number for computed CRC */ struct vkms_crtc_state { struct drm_crtc_state base; struct work_struct crc_work; u64 frame_start; u64 frame_end; }; struct vkms_output { struct drm_crtc crtc; struct drm_encoder encoder; struct drm_connector connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; struct drm_pending_vblank_event *event; bool crc_enabled; /* ordered wq for crc_work */ struct workqueue_struct *crc_workq; /* protects concurrent access to crc_data */ spinlock_t lock; /* protects concurrent access to crtc_state */ spinlock_t state_lock; }; struct vkms_device { struct drm_device drm; struct platform_device *platform; struct vkms_output output; }; struct vkms_gem_object { struct drm_gem_object gem; struct mutex pages_lock; /* Page lock used in page fault handler */ struct page **pages; unsigned int vmap_count; void *vaddr; }; #define drm_crtc_to_vkms_output(target) \ container_of(target, struct vkms_output, crtc) #define drm_device_to_vkms_device(target) \ container_of(target, struct vkms_device, drm) #define drm_gem_to_vkms_gem(target)\ container_of(target, struct vkms_gem_object, gem) #define to_vkms_crtc_state(target)\ container_of(target, struct vkms_crtc_state, base) #define to_vkms_plane_state(target)\ container_of(target, struct vkms_plane_state, base) /* CRTC */ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, struct drm_plane *primary, struct drm_plane *cursor); bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, int *max_error, ktime_t *vblank_time, bool in_vblank_irq); int vkms_output_init(struct vkms_device *vkmsdev); struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, enum drm_plane_type type); /* Gem stuff */ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, struct drm_file *file, u32 *handle, u64 size); vm_fault_t vkms_gem_fault(struct vm_fault *vmf); int vkms_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args); void vkms_gem_free_object(struct drm_gem_object *obj); int vkms_gem_vmap(struct drm_gem_object *obj); void vkms_gem_vunmap(struct drm_gem_object *obj); /* CRC Support */ int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name); int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, size_t *values_cnt); void vkms_crc_work_handle(struct work_struct *work); #endif /* _VKMS_DRV_H_ */
/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #ifndef GRAPHICS_PRIMITIVES_H #define GRAPHICS_PRIMITIVES_H namespace Graphics { void drawLine(int x0, int y0, int x1, int y1, int color, void (*plotProc)(int, int, int, void *), void *data); void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, int color, void (*plotProc)(int, int, int, void *), void *data); } // End of namespace Graphics #endif
/* PR middle-end/47893 */ /* { dg-do run } */ /* { dg-options "-O2" } */ /* { dg-options "-O2 -mtune=atom -fno-omit-frame-pointer -fno-strict-aliasing" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ extern void abort (void); struct S { unsigned s1:4, s2:2, s3:2, s4:2, s5:2, s6:1, s7:1, s8:1, s9:1, s10:1; int s11:16; unsigned s12:4; int s13:16; unsigned s14:2; int s15:16; unsigned s16:4; int s17:16; unsigned s18:2; }; struct T { unsigned t[3]; }; struct U { unsigned u1, u2; }; struct V; struct W { char w1[24]; struct V *w2; unsigned w3; char w4[28912]; unsigned int w5; char w6[60]; }; struct X { unsigned int x[2]; }; struct V { int v1; struct X v2[3]; char v3[28]; }; struct Y { void *y1; char y2[3076]; struct T y3[32]; char y4[1052]; }; volatile struct S v1 = { .s15 = -1, .s16 = 15, .s17 = -1, .s18 = 3 }; __attribute__ ((noinline, noclone)) int fn1 (int x) { int r; __asm__ volatile ("" : "=r" (r) : "0" (1), "r" (x) : "memory"); return r; } volatile int cnt; __attribute__ ((noinline, noclone)) #ifdef __i386__ __attribute__ ((regparm (2))) #endif struct S fn2 (struct Y *x, const struct X *y) { if (++cnt > 1) abort (); __asm__ volatile ("" : : "r" (x), "r" (y) : "memory"); return v1; } __attribute__ ((noinline, noclone)) void fn3 (void *x, unsigned y, const struct S *z, unsigned w) { __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z), "r" (w) : "memory"); } volatile struct U v2; __attribute__ ((noinline, noclone)) struct U fn4 (void *x, unsigned y) { __asm__ volatile ("" : : "r" (x), "r" (y) : "memory"); return v2; } __attribute__ ((noinline, noclone)) struct S fn5 (void *x) { __asm__ volatile ("" : : "r" (x) : "memory"); return v1; } volatile struct T v3; __attribute__ ((noinline, noclone)) struct T fn6 (void *x) { __asm__ volatile ("" : : "r" (x) : "memory"); return v3; } __attribute__ ((noinline, noclone)) struct T fn7 (void *x, unsigned y, unsigned z) { __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z) : "memory"); return v3; } static void fn8 (struct Y *x, const struct V *y) { void *a = x->y1; struct S b[4]; unsigned i, c; c = fn1 (y->v1); for (i = 0; i < c; i++) b[i] = fn2 (x, &y->v2[i]); fn3 (a, y->v1, b, c); } static inline void fn9 (void *x, struct S y __attribute__((unused))) { fn4 (x, 8); } static void fn10 (struct Y *x) { void *a = x->y1; struct T b __attribute__((unused)) = fn6 (a); fn9 (a, fn5 (a)); } __attribute__((noinline, noclone)) int fn11 (unsigned int x, void *y, const struct W *z, unsigned int w, const char *v, const char *u) { struct Y a, *t; unsigned i; t = &a; __builtin_memset (t, 0, sizeof *t); t->y1 = y; if (x == 0) { if (z->w3 & 1) fn10 (t); for (i = 0; i < w; i++) { if (v[i] == 0) t->y3[i] = fn7 (y, 0, u[i]); else return 0; } } else for (i = 0; i < w; i++) t->y3[i] = fn7 (y, v[i], u[i]); for (i = 0; i < z->w5; i++) fn8 (t, &z->w2[i]); return 0; } volatile int i; const char *volatile p = ""; int main () { struct V v = { .v1 = 0 }; struct W w = { .w5 = 1, .w2 = &v }; fn11 (i + 1, (void *) p, &w, i, (const char *) p, (const char *) p); if (cnt != 1) abort (); return 0; }
/** * Marlin 3D Printer Firmware * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ #pragma once #if HAS_SPI_TFT || HAS_FSMC_TFT #error "Sorry! TFT displays are not available for HAL/TEENSY35_36." #endif
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 University of California, Los Angeles * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> */ #ifndef LFU_POLICY_H_ #define LFU_POLICY_H_ #include <boost/intrusive/options.hpp> #include <boost/intrusive/set.hpp> namespace ns3 { namespace ndn { namespace ndnSIM { /** * @brief Traits for LFU replacement policy */ struct lfu_policy_traits { /// @brief Name that can be used to identify the policy (for NS-3 object model and logging) static std::string GetName () { return "Lfu"; } struct policy_hook_type : public boost::intrusive::set_member_hook<> { double frequency; }; template<class Container> struct container_hook { typedef boost::intrusive::member_hook< Container, policy_hook_type, &Container::policy_hook_ > type; }; template<class Base, class Container, class Hook> struct policy { static double& get_order (typename Container::iterator item) { return static_cast<policy_hook_type*> (policy_container::value_traits::to_node_ptr(*item))->frequency; } static const double& get_order (typename Container::const_iterator item) { return static_cast<const policy_hook_type*> (policy_container::value_traits::to_node_ptr(*item))->frequency; } template<class Key> struct MemberHookLess { bool operator () (const Key &a, const Key &b) const { return get_order (&a) < get_order (&b); } }; typedef boost::intrusive::multiset< Container, boost::intrusive::compare< MemberHookLess< Container > >, Hook > policy_container; // could be just typedef class type : public policy_container { public: typedef policy policy_base; // to get access to get_order methods from outside typedef Container parent_trie; type (Base &base) : base_ (base) , max_size_ (100) { } inline void update (typename parent_trie::iterator item) { policy_container::erase (policy_container::s_iterator_to (*item)); get_order (item) += 1; policy_container::insert (*item); } inline bool insert (typename parent_trie::iterator item) { get_order (item) = 0; if (max_size_ != 0 && policy_container::size () >= max_size_) { // this erases the "least frequently used item" from cache base_.erase (&(*policy_container::begin ())); } policy_container::insert (*item); return true; } inline void lookup (typename parent_trie::iterator item) { policy_container::erase (policy_container::s_iterator_to (*item)); get_order (item) += 1; policy_container::insert (*item); } inline void erase (typename parent_trie::iterator item) { policy_container::erase (policy_container::s_iterator_to (*item)); } inline void clear () { policy_container::clear (); } inline void set_max_size (size_t max_size) { max_size_ = max_size; } inline size_t get_max_size () const { return max_size_; } private: type () : base_(*((Base*)0)) { }; private: Base &base_; size_t max_size_; }; }; }; } // ndnSIM } // ndn } // ns3 #endif // LFU_POLICY_H
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Written (W) 2013 Kevin Hughes */ #ifndef FFSEP_H_ #define FFSEP_H_ #include <shogun/lib/config.h> #ifdef HAVE_EIGEN3 #include <shogun/lib/SGNDArray.h> #include <shogun/features/Features.h> #include <shogun/converter/ica/ICAConverter.h> namespace shogun { class CFeatures; /** @brief class FFSep * * Implements the FFSep algorithm for Independent * Component Analysis (ICA) and Blind Source * Separation (BSS). * * Ziehe, A., Laskov, P., Nolte, G., & Müller, K. R. (2004). * A fast algorithm for joint diagonalization with non-orthogonal transformations * and its application to blind source separation. * The Journal of Machine Learning Research, 5, 777-800. * */ class CFFSep: public CICAConverter { public: /** constructor */ CFFSep(); /** destructor */ virtual ~CFFSep(); /** apply to features * @param features features to embed */ virtual CFeatures* apply(CFeatures* features); /** getter for tau parameter * @return tau vector */ SGVector<float64_t> get_tau() const; /** setter for tau parameter * @param tau vector */ void set_tau(SGVector<float64_t> tau); /** getter for time sep cov matrices * @return cov matrices */ SGNDArray<float64_t> get_covs() const; /** @return object name */ virtual const char* get_name() const { return "FFSep"; }; protected: /** init */ void init(); private: /** tau vector */ SGVector<float64_t> m_tau; /** cov matrices */ SGNDArray<float64_t> m_covs; }; } #endif // HAVE_EIGEN3 #endif // FFSEP
/* Copyright (C) 2005-2016 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. This file is part of the GNU Offloading and Multi Processing Library (libgomp). Libgomp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ /* This is the default PTHREADS implementation of the public OpenMP locking primitives. Because OpenMP uses different entry points for normal and recursive locks, and pthreads uses only one entry point, a system may be able to do better and streamline the locking as well as reduce the size of the types exported. */ /* We need UNIX98/XPG5 extensions to get recursive locks. Request XPG6 since Solaris requires this for C99 and later. */ #define _XOPEN_SOURCE 600 #include "libgomp.h" #ifdef HAVE_BROKEN_POSIX_SEMAPHORES void gomp_init_lock_30 (omp_lock_t *lock) { pthread_mutex_init (lock, NULL); } void gomp_destroy_lock_30 (omp_lock_t *lock) { pthread_mutex_destroy (lock); } void gomp_set_lock_30 (omp_lock_t *lock) { pthread_mutex_lock (lock); } void gomp_unset_lock_30 (omp_lock_t *lock) { pthread_mutex_unlock (lock); } int gomp_test_lock_30 (omp_lock_t *lock) { return pthread_mutex_trylock (lock) == 0; } void gomp_init_nest_lock_30 (omp_nest_lock_t *lock) { pthread_mutex_init (&lock->lock, NULL); lock->count = 0; lock->owner = NULL; } void gomp_destroy_nest_lock_30 (omp_nest_lock_t *lock) { pthread_mutex_destroy (&lock->lock); } void gomp_set_nest_lock_30 (omp_nest_lock_t *lock) { void *me = gomp_icv (true); if (lock->owner != me) { pthread_mutex_lock (&lock->lock); lock->owner = me; } lock->count++; } void gomp_unset_nest_lock_30 (omp_nest_lock_t *lock) { if (--lock->count == 0) { lock->owner = NULL; pthread_mutex_unlock (&lock->lock); } } int gomp_test_nest_lock_30 (omp_nest_lock_t *lock) { void *me = gomp_icv (true); if (lock->owner != me) { if (pthread_mutex_trylock (&lock->lock) != 0) return 0; lock->owner = me; } return ++lock->count; } #else void gomp_init_lock_30 (omp_lock_t *lock) { sem_init (lock, 0, 1); } void gomp_destroy_lock_30 (omp_lock_t *lock) { sem_destroy (lock); } void gomp_set_lock_30 (omp_lock_t *lock) { while (sem_wait (lock) != 0) ; } void gomp_unset_lock_30 (omp_lock_t *lock) { sem_post (lock); } int gomp_test_lock_30 (omp_lock_t *lock) { return sem_trywait (lock) == 0; } void gomp_init_nest_lock_30 (omp_nest_lock_t *lock) { sem_init (&lock->lock, 0, 1); lock->count = 0; lock->owner = NULL; } void gomp_destroy_nest_lock_30 (omp_nest_lock_t *lock) { sem_destroy (&lock->lock); } void gomp_set_nest_lock_30 (omp_nest_lock_t *lock) { void *me = gomp_icv (true); if (lock->owner != me) { while (sem_wait (&lock->lock) != 0) ; lock->owner = me; } lock->count++; } void gomp_unset_nest_lock_30 (omp_nest_lock_t *lock) { if (--lock->count == 0) { lock->owner = NULL; sem_post (&lock->lock); } } int gomp_test_nest_lock_30 (omp_nest_lock_t *lock) { void *me = gomp_icv (true); if (lock->owner != me) { if (sem_trywait (&lock->lock) != 0) return 0; lock->owner = me; } return ++lock->count; } #endif #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING void gomp_init_lock_25 (omp_lock_25_t *lock) { pthread_mutex_init (lock, NULL); } void gomp_destroy_lock_25 (omp_lock_25_t *lock) { pthread_mutex_destroy (lock); } void gomp_set_lock_25 (omp_lock_25_t *lock) { pthread_mutex_lock (lock); } void gomp_unset_lock_25 (omp_lock_25_t *lock) { pthread_mutex_unlock (lock); } int gomp_test_lock_25 (omp_lock_25_t *lock) { return pthread_mutex_trylock (lock) == 0; } void gomp_init_nest_lock_25 (omp_nest_lock_25_t *lock) { pthread_mutexattr_t attr; pthread_mutexattr_init (&attr); pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init (&lock->lock, &attr); lock->count = 0; pthread_mutexattr_destroy (&attr); } void gomp_destroy_nest_lock_25 (omp_nest_lock_25_t *lock) { pthread_mutex_destroy (&lock->lock); } void gomp_set_nest_lock_25 (omp_nest_lock_25_t *lock) { pthread_mutex_lock (&lock->lock); lock->count++; } void gomp_unset_nest_lock_25 (omp_nest_lock_25_t *lock) { lock->count--; pthread_mutex_unlock (&lock->lock); } int gomp_test_nest_lock_25 (omp_nest_lock_25_t *lock) { if (pthread_mutex_trylock (&lock->lock) == 0) return ++lock->count; return 0; } omp_lock_symver (omp_init_lock) omp_lock_symver (omp_destroy_lock) omp_lock_symver (omp_set_lock) omp_lock_symver (omp_unset_lock) omp_lock_symver (omp_test_lock) omp_lock_symver (omp_init_nest_lock) omp_lock_symver (omp_destroy_nest_lock) omp_lock_symver (omp_set_nest_lock) omp_lock_symver (omp_unset_nest_lock) omp_lock_symver (omp_test_nest_lock) #else ialias (omp_init_lock) ialias (omp_init_nest_lock) ialias (omp_destroy_lock) ialias (omp_destroy_nest_lock) ialias (omp_set_lock) ialias (omp_set_nest_lock) ialias (omp_unset_lock) ialias (omp_unset_nest_lock) ialias (omp_test_lock) ialias (omp_test_nest_lock) #endif
// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s // CHECK-LABEL: define { float, float } @p({ float, float }* byval align 4 %a, { float, float }* byval align 4 %b) #0 { float __complex__ p (float __complex__ a, float __complex__ b) { } // CHECK-LABEL: define { double, double } @q({ double, double }* byval align 8 %a, { double, double }* byval align 8 %b) #0 { double __complex__ q (double __complex__ a, double __complex__ b) { } // CHECK-LABEL: define { i64, i64 } @r({ i64, i64 }* byval align 8 %a, { i64, i64 }* byval align 8 %b) #0 { long long __complex__ r (long long __complex__ a, long long __complex__ b) { }
#ifndef TESTS_ARC4_H #define TESTS_ARC4_H #include <stddef.h> #include <stdint.h> /* Alleged RC4 algorithm encryption state. */ struct arc4 { uint8_t s[256]; uint8_t i, j; }; void arc4_init (struct arc4 *, const void *, size_t); void arc4_crypt (struct arc4 *, void *, size_t); #endif /* tests/arc4.h */
//****************************************************************************** // // Copyright (c) 2016 Microsoft Corporation. All rights reserved. // // This code is licensed under the MIT License (MIT). // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // //****************************************************************************** #pragma once #import <StoreKit/StoreKitExport.h> #import <Foundation/NSObject.h> @class NSError; @class SKPayment; @class NSString; @class NSData; @class NSDate; @class NSArray; typedef NSInteger SKPaymentTransactionState; enum { SKPaymentTransactionStatePurchasing, SKPaymentTransactionStatePurchased, SKPaymentTransactionStateFailed, SKPaymentTransactionStateRestored, SKPaymentTransactionStateDeferred, }; STOREKIT_EXPORT_CLASS @interface SKPaymentTransaction : NSObject <NSObject> @property (readonly, nonatomic) NSError* error STUB_PROPERTY; @property (readonly, nonatomic) SKPayment* payment STUB_PROPERTY; @property (readonly, nonatomic) SKPaymentTransactionState transactionState STUB_PROPERTY; @property (readonly, nonatomic) NSString* transactionIdentifier STUB_PROPERTY; @property (readonly, nonatomic) NSData* transactionReceipt STUB_PROPERTY; @property (readonly, nonatomic) NSDate* transactionDate STUB_PROPERTY; @property (readonly, nonatomic) NSArray* downloads STUB_PROPERTY; @property (readonly, nonatomic) SKPaymentTransaction* originalTransaction STUB_PROPERTY; @end
/* * $Id$ * * Various URI related functions * * Copyright (C) 2001-2003 FhG Fokus * * This file is part of ser, a free SIP server. * * ser is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * * For a license to use the ser software under conditions * other than those described here, or to purchase support for this * software, please contact iptel.org by e-mail at the following addresses: * info@iptel.org * * ser is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * History: * -------- * 2003-02-26: created by janakj */ #ifndef URI_MOD_H #define URI_MOD_H #include "../../lib/srdb2/db.h" #include "../../str.h" #endif /* URI_MOD_H */
/******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * * Copyright (C) 2004-2008 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * * www.emulex.com * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of version 2 of the GNU General * * Public License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful. * * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * * TO BE LEGALLY INVALID. See the GNU General Public License for * * more details, a copy of which can be found in the file COPYING * * included with this package. * *******************************************************************/ #define LPFC_DRIVER_VERSION "8.2.7" #define LPFC_DRIVER_NAME "lpfc" #define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \ LPFC_DRIVER_VERSION #define LPFC_COPYRIGHT "Copyright(c) 2004-2008 Emulex. All rights reserved."
#pragma once namespace vm { using namespace ps3; } enum CELL_MOUSE_ERROR_CODE { CELL_MOUSE_ERROR_FATAL = 0x80121201, CELL_MOUSE_ERROR_INVALID_PARAMETER = 0x80121202, CELL_MOUSE_ERROR_ALREADY_INITIALIZED = 0x80121203, CELL_MOUSE_ERROR_UNINITIALIZED = 0x80121204, CELL_MOUSE_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121205, CELL_MOUSE_ERROR_DATA_READ_FAILED = 0x80121206, CELL_MOUSE_ERROR_NO_DEVICE = 0x80121207, CELL_MOUSE_ERROR_SYS_SETTING_FAILED = 0x80121208, }; static const u32 CELL_MAX_MICE = 127; struct CellMouseInfo { be_t<u32> max_connect; be_t<u32> now_connect; be_t<u32> info; be_t<u16> vendor_id[CELL_MAX_MICE]; be_t<u16> product_id[CELL_MAX_MICE]; u8 status[CELL_MAX_MICE]; }; struct CellMouseInfoTablet { be_t<u32> is_supported; be_t<u32> mode; }; struct CellMouseData { u8 update; u8 buttons; s8 x_axis; s8 y_axis; s8 wheel; s8 tilt; }; static const u32 CELL_MOUSE_MAX_DATA_LIST_NUM = 8; struct CellMouseDataList { be_t<u32> list_num; CellMouseData list[CELL_MOUSE_MAX_DATA_LIST_NUM]; }; static const u32 CELL_MOUSE_MAX_CODES = 64;
// Copyright 2004-present Facebook. All Rights Reserved. #pragma once #include <atomic> #include <functional> #include <map> #include <vector> #include <folly/dynamic.h> #include "Executor.h" #include "ExecutorToken.h" #include "JSModulesUnbundle.h" #include "MessageQueueThread.h" #include "MethodCall.h" #include "NativeModule.h" #include "Value.h" namespace folly { struct dynamic; } namespace facebook { namespace react { struct InstanceCallback; class ModuleRegistry; class ExecutorRegistration { public: ExecutorRegistration( std::unique_ptr<JSExecutor> executor, std::shared_ptr<MessageQueueThread> executorMessageQueueThread) : executor_(std::move(executor)), messageQueueThread_(executorMessageQueueThread) {} std::unique_ptr<JSExecutor> executor_; std::shared_ptr<MessageQueueThread> messageQueueThread_; }; class JsToNativeBridge; // This class manages calls from native code to JS. It also manages // executors and their threads. This part is used by both bridges for // now, but further refactorings should separate the bridges more // fully #11247981. class NativeToJsBridge { public: friend class JsToNativeBridge; /** * This must be called on the main JS thread. */ NativeToJsBridge( JSExecutorFactory* jsExecutorFactory, std::shared_ptr<ModuleRegistry> registry, std::shared_ptr<MessageQueueThread> jsQueue, std::unique_ptr<MessageQueueThread> nativeQueue, std::shared_ptr<InstanceCallback> callback); virtual ~NativeToJsBridge(); /** * Executes a function with the module ID and method ID and any additional * arguments in JS. */ void callFunction( ExecutorToken executorToken, std::string&& module, std::string&& method, folly::dynamic&& args); /** * Invokes a callback with the cbID, and optional additional arguments in JS. */ void invokeCallback(ExecutorToken executorToken, double callbackId, folly::dynamic&& args); /** * Starts the JS application from an "bundle", i.e. a JavaScript file that * contains code for all modules and a runtime that resolves and * executes modules. */ void loadApplicationScript(std::unique_ptr<const JSBigString> script, std::string sourceURL); /** * Similar to loading a "bundle", but instead of passing js source this method accepts * path to a directory containing files prepared for particular JSExecutor. */ void loadOptimizedApplicationScript(std::string bundlePath, std::string sourceURL, int flags); /** * An "unbundle" is a backend that stores and injects JavaScript modules as * individual scripts, rather than bundling all of them into a single scrupt. * * Loading an unbundle means setting the storage backend and executing the * startup script. */ void loadApplicationUnbundle( std::unique_ptr<JSModulesUnbundle> unbundle, std::unique_ptr<const JSBigString> startupCode, std::string sourceURL); void setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue); void* getJavaScriptContext(); bool supportsProfiling(); void startProfiler(const std::string& title); void stopProfiler(const std::string& title, const std::string& filename); void handleMemoryPressureUiHidden(); void handleMemoryPressureModerate(); void handleMemoryPressureCritical(); /** * Returns the ExecutorToken corresponding to the main JSExecutor. */ ExecutorToken getMainExecutorToken() const; /** * Synchronously tears down the bridge and the main executor. */ void destroy(); private: /** * Registers the given JSExecutor which runs on the given MessageQueueThread * with the NativeToJsBridge. Part of this registration is transfering * ownership of this JSExecutor to the NativeToJsBridge for the duration of * the registration. * * Returns a ExecutorToken which can be used to refer to this JSExecutor * in the NativeToJsBridge. */ ExecutorToken registerExecutor( ExecutorToken token, std::unique_ptr<JSExecutor> executor, std::shared_ptr<MessageQueueThread> executorMessageQueueThread); /** * Unregisters a JSExecutor that was previously registered with this NativeToJsBridge * using registerExecutor. */ std::unique_ptr<JSExecutor> unregisterExecutor(JSExecutor& executorToken); void runOnExecutorQueue(ExecutorToken token, std::function<void(JSExecutor*)> task); // This is used to avoid a race condition where a proxyCallback gets queued // after ~NativeToJsBridge(), on the same thread. In that case, the callback // will try to run the task on m_callback which will have been destroyed // within ~NativeToJsBridge(), thus causing a SIGSEGV. std::shared_ptr<bool> m_destroyed; JSExecutor* m_mainExecutor; ExecutorToken m_mainExecutorToken; std::shared_ptr<JsToNativeBridge> m_delegate; std::unordered_map<JSExecutor*, ExecutorToken> m_executorTokenMap; std::unordered_map<ExecutorToken, ExecutorRegistration> m_executorMap; std::mutex m_registrationMutex; #ifdef WITH_FBSYSTRACE std::atomic_uint_least32_t m_systraceCookie = ATOMIC_VAR_INIT(); #endif MessageQueueThread* getMessageQueueThread(const ExecutorToken& executorToken); JSExecutor* getExecutor(const ExecutorToken& executorToken); ExecutorToken getTokenForExecutor(JSExecutor& executor); }; } }
// 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 CHROME_BROWSER_UI_WEBUI_PROFILER_UI_H_ #define CHROME_BROWSER_UI_WEBUI_PROFILER_UI_H_ #include "base/memory/weak_ptr.h" #include "components/metrics/profiler/tracking_synchronizer_observer.h" #include "content/public/browser/web_ui_controller.h" // The C++ back-end for the chrome://profiler webui page. class ProfilerUI : public content::WebUIController, public metrics::TrackingSynchronizerObserver { public: explicit ProfilerUI(content::WebUI* web_ui); ~ProfilerUI() override; // Get the tracking data from TrackingSynchronizer. void GetData(); private: // TrackingSynchronizerObserver: void ReceivedProfilerData( const metrics::ProfilerDataAttributes& attributes, const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase, const metrics::ProfilerEvents& past_events) override; // Used to get |weak_ptr_| to self on the UI thread. base::WeakPtrFactory<ProfilerUI> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(ProfilerUI); }; #endif // CHROME_BROWSER_UI_WEBUI_PROFILER_UI_H_
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007-2009 Strasbourg University * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr> */ #ifndef IPV6_END_POINT_H #define IPV6_END_POINT_H #include <stdint.h> #include "ns3/ipv6-address.h" #include "ns3/callback.h" namespace ns3 { class Header; class Packet; /** * \class Ipv6EndPoint * \brief An IPv6 end point, four tuples identification. */ class Ipv6EndPoint { public: /** * \brief Constructor. * \param addr the IPv6 address * \param port the port */ Ipv6EndPoint (Ipv6Address addr, uint16_t port); /** * \brief Destructor. */ ~Ipv6EndPoint (); /** * \brief Get the local address. * \return the local address */ Ipv6Address GetLocalAddress (); /** * \brief Set the local address. * \param addr the address to set */ void SetLocalAddress (Ipv6Address addr); /** * \brief Get the local port. * \return the local port */ uint16_t GetLocalPort (); /** * \brief Set the local port. * \param port the port to set */ void SetLocalPort (uint16_t port); /** * \brief Get the peer address. * \return the peer address */ Ipv6Address GetPeerAddress (); /** * \brief Get the peer port. * \return the peer port */ uint16_t GetPeerPort (); /** * \brief Set the peer informations (address and port). * \param addr peer address * \param port peer port */ void SetPeer (Ipv6Address addr, uint16_t port); /** * \brief Set the reception callback. * \param callback callback function */ void SetRxCallback (Callback<void, Ptr<Packet>, Ipv6Address, uint16_t> callback); /** * \brief Set the ICMP callback. * \param callback callback function */ void SetIcmpCallback (Callback<void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t> callback); /** * \brief Set the default destroy callback. * \param callback callback function */ void SetDestroyCallback (Callback<void> callback); /** * \brief Forward the packet to the upper level. * \param p the packet * \param addr source address * \param port source port */ void ForwardUp (Ptr<Packet> p, Ipv6Address addr, uint16_t port); /** * \brief Function called from an L4Protocol implementation * to notify an endpoint of an icmp message reception. * \param src source IPv6 address * \param ttl time-to-live * \param type ICMPv6 type * \param code ICMPv6 code * \param info ICMPv6 info */ void ForwardIcmp (Ipv6Address src, uint8_t ttl, uint8_t type, uint8_t code, uint32_t info); private: /** * \brief ForwardUp wrapper. * \param p packet * \param saddr source IPv6 address * \param sport source port */ void DoForwardUp (Ptr<Packet> p, Ipv6Address saddr, uint16_t sport); /** * \brief ForwardIcmp wrapper. * \param src source IPv6 address * \param ttl time-to-live * \param type ICMPv6 type * \param code ICMPv6 code * \param info ICMPv6 info */ void DoForwardIcmp (Ipv6Address src, uint8_t ttl, uint8_t type, uint8_t code, uint32_t info); /** * \brief The local address. */ Ipv6Address m_localAddr; /** * \brief The local port. */ uint16_t m_localPort; /** * \brief The peer address. */ Ipv6Address m_peerAddr; /** * \brief The peer port. */ uint16_t m_peerPort; /** * \brief The RX callback. */ Callback<void, Ptr<Packet>, Ipv6Address, uint16_t> m_rxCallback; /** * \brief The ICMPv6 callback. */ Callback<void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t> m_icmpCallback; /** * \brief The destroy callback. */ Callback<void> m_destroyCallback; }; } /* namespace ns3 */ #endif /* IPV6_END_POINT_H */
/* * Copyright (C) 2002-2015 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Write the data from the opcode */ switch (inst.code.save) { /* Byte */ case S_C_Eb: inst_op1_b=inst.cond ? 1 : 0; case S_Eb: if (inst.rm<0xc0) SaveMb(inst.rm_eaa,inst_op1_b); else reg_8(inst.rm_eai)=inst_op1_b; break; case S_Gb: reg_8(inst.rm_index)=inst_op1_b; break; case S_EbGb: if (inst.rm<0xc0) SaveMb(inst.rm_eaa,inst_op1_b); else reg_8(inst.rm_eai)=inst_op1_b; reg_8(inst.rm_index)=inst_op2_b; break; /* Word */ case S_Ew: if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w); else reg_16(inst.rm_eai)=inst_op1_w; break; case S_Gw: reg_16(inst.rm_index)=inst_op1_w; break; case S_EwGw: if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w); else reg_16(inst.rm_eai)=inst_op1_w; reg_16(inst.rm_index)=inst_op2_w; break; /* Dword */ case S_Ed: if (inst.rm<0xc0) SaveMd(inst.rm_eaa,inst_op1_d); else reg_32(inst.rm_eai)=inst_op1_d; break; case S_EdMw: /* Special one 16 to memory, 32 zero extend to reg */ if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w); else reg_32(inst.rm_eai)=inst_op1_d; break; case S_Gd: reg_32(inst.rm_index)=inst_op1_d; break; case S_EdGd: if (inst.rm<0xc0) SaveMd(inst.rm_eaa,inst_op1_d); else reg_32(inst.rm_eai)=inst_op1_d; reg_32(inst.rm_index)=inst_op2_d; break; case S_REGb: reg_8(inst.code.extra)=inst_op1_b; break; case S_REGw: reg_16(inst.code.extra)=inst_op1_w; break; case S_REGd: reg_32(inst.code.extra)=inst_op1_d; break; case S_SEGm: if (CPU_SetSegGeneral((SegNames)inst.rm_index,inst_op1_w)) RunException(); break; case S_SEGGw: if (CPU_SetSegGeneral((SegNames)inst.code.extra,inst_op2_w)) RunException(); reg_16(inst.rm_index)=inst_op1_w; break; case S_SEGGd: if (CPU_SetSegGeneral((SegNames)inst.code.extra,inst_op2_w)) RunException(); reg_32(inst.rm_index)=inst_op1_d; break; case S_PUSHw: Push_16(inst_op1_w); break; case S_PUSHd: Push_32(inst_op1_d); break; case S_C_AIPw: if (!inst.cond) goto nextopcode; case S_AIPw: SaveIP(); reg_eip+=inst_op1_d; reg_eip&=0xffff; continue; case S_C_AIPd: if (!inst.cond) goto nextopcode; case S_AIPd: SaveIP(); reg_eip+=inst_op1_d; continue; case S_IPIw: reg_esp+=Fetchw(); case S_IP: SaveIP(); reg_eip=inst_op1_d; continue; case 0: break; default: LOG(LOG_CPU,LOG_ERROR)("SAVE:Unhandled code %d entry %X",inst.code.save,inst.entry); }
/* Copyright 2016 Fred Sundvik <fsundvik@gmail.com> Jun Wako <wakojun@gmail.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdint.h> #include <stdbool.h> #include <string.h> #include "hal.h" #include "timer.h" #include "wait.h" #include "print.h" #include "debug.h" #include "matrix.h" #include "serial_link/system/serial_link.h" /* * Infinity ErgoDox Pinusage: * Column pins are input with internal pull-down. Row pins are output and strobe with high. * Key is high or 1 when it turns on. * * col: { PTD1, PTD4, PTD5, PTD6, PTD7 } * row: { PTB2, PTB3, PTB18, PTB19, PTC0, PTC9, PTC10, PTC11, PTD0 } */ /* matrix state(1:on, 0:off) */ static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix_debouncing[LOCAL_MATRIX_ROWS]; static bool debouncing = false; static uint16_t debouncing_time = 0; void matrix_init(void) { /* Column(sense) */ palSetPadMode(GPIOD, 1, PAL_MODE_INPUT_PULLDOWN); palSetPadMode(GPIOD, 4, PAL_MODE_INPUT_PULLDOWN); palSetPadMode(GPIOD, 5, PAL_MODE_INPUT_PULLDOWN); palSetPadMode(GPIOD, 6, PAL_MODE_INPUT_PULLDOWN); palSetPadMode(GPIOD, 7, PAL_MODE_INPUT_PULLDOWN); /* Row(strobe) */ palSetPadMode(GPIOB, 2, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 3, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 18, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 19, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOC, 0, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOC, 9, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOC, 10, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOC, 11, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOD, 0, PAL_MODE_OUTPUT_PUSHPULL); memset(matrix, 0, MATRIX_ROWS); memset(matrix_debouncing, 0, LOCAL_MATRIX_ROWS); matrix_init_quantum(); } uint8_t matrix_scan(void) { for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) { matrix_row_t data = 0; // strobe row switch (row) { case 0: palSetPad(GPIOB, 2); break; case 1: palSetPad(GPIOB, 3); break; case 2: palSetPad(GPIOB, 18); break; case 3: palSetPad(GPIOB, 19); break; case 4: palSetPad(GPIOC, 0); break; case 5: palSetPad(GPIOC, 9); break; case 6: palSetPad(GPIOC, 10); break; case 7: palSetPad(GPIOC, 11); break; case 8: palSetPad(GPIOD, 0); break; } // need wait to settle pin state // if you wait too short, or have a too high update rate // the keyboard might freeze, or there might not be enough // processing power to update the LCD screen properly. // 20us, or two ticks at 100000Hz seems to be OK wait_us(20); // read col data: { PTD1, PTD4, PTD5, PTD6, PTD7 } data = ((palReadPort(GPIOD) & 0xF0) >> 3) | ((palReadPort(GPIOD) & 0x02) >> 1); // un-strobe row switch (row) { case 0: palClearPad(GPIOB, 2); break; case 1: palClearPad(GPIOB, 3); break; case 2: palClearPad(GPIOB, 18); break; case 3: palClearPad(GPIOB, 19); break; case 4: palClearPad(GPIOC, 0); break; case 5: palClearPad(GPIOC, 9); break; case 6: palClearPad(GPIOC, 10); break; case 7: palClearPad(GPIOC, 11); break; case 8: palClearPad(GPIOD, 0); break; } if (matrix_debouncing[row] != data) { matrix_debouncing[row] = data; debouncing = true; debouncing_time = timer_read(); } } uint8_t offset = 0; #ifdef MASTER_IS_ON_RIGHT if (is_serial_link_master()) { offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS; } #endif if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) { for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) { matrix[offset + row] = matrix_debouncing[row]; } debouncing = false; } matrix_scan_quantum(); return 1; } bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & (1<<col)); } matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } void matrix_print(void) { xprintf("\nr/c 01234567\n"); for (uint8_t row = 0; row < MATRIX_ROWS; row++) { xprintf("%X0: ", row); matrix_row_t data = matrix_get_row(row); for (int col = 0; col < MATRIX_COLS; col++) { if (data & (1<<col)) xprintf("1"); else xprintf("0"); } xprintf("\n"); } } void matrix_set_remote(matrix_row_t* rows, uint8_t index) { uint8_t offset = 0; #ifdef MASTER_IS_ON_RIGHT offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2); #else offset = LOCAL_MATRIX_ROWS * (index + 1); #endif for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) { matrix[offset + row] = rows[row]; } }
/* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client * Copyright (C) 2002-2012 Match Grun and the Claws Mail team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /* * General functions for saving properties to an XML file. */ #ifndef __XMLSAVER_H__ #define __XMLSAVER_H__ #include <stdio.h> #include <glib.h> /* XML property data */ typedef struct _XmlProperty XmlProperty; struct _XmlProperty { gchar *path; gchar *encoding; GHashTable *propertyTable; gint retVal; }; /* Function prototypes */ XmlProperty *xmlprops_create ( void ); void xmlprops_free ( XmlProperty *props ); void xmlprops_set_path ( XmlProperty *props, const gchar *value ); gint xmlprops_load_file ( XmlProperty *props ); gint xmlprops_save_file ( XmlProperty *props ); void xmlprops_set_property ( XmlProperty *props, const gchar *name, const gchar *value ); void xmlprops_set_property_i ( XmlProperty *props, const gchar *name, const gint value ); void xmlprops_set_property_b ( XmlProperty *props, const gchar *name, const gboolean value ); void xmlprops_get_property_s ( XmlProperty *props, const gchar *name, gchar *buffer ); gint xmlprops_get_property_i ( XmlProperty *props, const gchar *name ); gboolean xmlprops_get_property_b( XmlProperty *props, const gchar *name ); #endif /* __XMLSAVER_H__ */
// // GoogleMobileAds.h // Google Mobile Ads SDK // // Copyright 2014 Google Inc. All rights reserved. #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0 #error The Google Mobile Ads SDK requires a deployment target of iOS 6.0 or later. #endif //! Project version string for GoogleMobileAds. FOUNDATION_EXPORT const unsigned char GoogleMobileAdsVersionString[]; #import <GoogleMobileAds/GADAdNetworkExtras.h> #import <GoogleMobileAds/GADAdSize.h> #import <GoogleMobileAds/GADBannerView.h> #import <GoogleMobileAds/GADBannerViewDelegate.h> #import <GoogleMobileAds/GADExtras.h> #import <GoogleMobileAds/GADInAppPurchase.h> #import <GoogleMobileAds/GADInAppPurchaseDelegate.h> #import <GoogleMobileAds/GADInterstitial.h> #import <GoogleMobileAds/GADInterstitialDelegate.h> #import <GoogleMobileAds/GADRequest.h> #import <GoogleMobileAds/GADRequestError.h> #import <GoogleMobileAds/DFPBannerView.h> #import <GoogleMobileAds/DFPCustomRenderedAd.h> #import <GoogleMobileAds/DFPCustomRenderedBannerViewDelegate.h> #import <GoogleMobileAds/DFPCustomRenderedInterstitialDelegate.h> #import <GoogleMobileAds/DFPInterstitial.h> #import <GoogleMobileAds/DFPRequest.h> #import <GoogleMobileAds/GADAdSizeDelegate.h> #import <GoogleMobileAds/GADAppEventDelegate.h> #import <GoogleMobileAds/Loading/GADAdLoader.h> #import <GoogleMobileAds/Loading/GADAdLoaderAdTypes.h> #import <GoogleMobileAds/Loading/GADAdLoaderDelegate.h> #import <GoogleMobileAds/Loading/Formats/GADNativeAd.h> #import <GoogleMobileAds/Loading/Formats/GADNativeAdDelegate.h> #import <GoogleMobileAds/Loading/Formats/GADNativeAdImage.h> #import <GoogleMobileAds/Loading/Formats/GADNativeAppInstallAd.h> #import <GoogleMobileAds/Loading/Formats/GADNativeContentAd.h> #import <GoogleMobileAds/Loading/Formats/GADNativeCustomTemplateAd.h> #import <GoogleMobileAds/Loading/Options/GADNativeAdImageAdLoaderOptions.h> #import <GoogleMobileAds/Mediation/GADCustomEventBanner.h> #import <GoogleMobileAds/Mediation/GADCustomEventBannerDelegate.h> #import <GoogleMobileAds/Mediation/GADCustomEventExtras.h> #import <GoogleMobileAds/Mediation/GADCustomEventInterstitial.h> #import <GoogleMobileAds/Mediation/GADCustomEventInterstitialDelegate.h> #import <GoogleMobileAds/Mediation/GADCustomEventRequest.h> #import <GoogleMobileAds/Search/GADSearchBannerView.h> #import <GoogleMobileAds/Search/GADSearchRequest.h>
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_COMPILER_MLIR_TENSORFLOW_UTILS_CONVERT_TYPE_H_ #define TENSORFLOW_COMPILER_MLIR_TENSORFLOW_UTILS_CONVERT_TYPE_H_ #include "mlir/IR/Builders.h" // from @llvm-project #include "mlir/IR/Types.h" // from @llvm-project #include "tensorflow/core/framework/tensor_shape.h" #include "tensorflow/core/framework/tensor_shape.pb.h" #include "tensorflow/core/framework/types.pb.h" #include "tensorflow/stream_executor/lib/statusor.h" namespace tensorflow { using stream_executor::port::StatusOr; // Converts the TensorFlow DataType 'dtype' into an MLIR (scalar) type. Status ConvertDataType(DataType dtype, mlir::Builder builder, mlir::Type* type); // Converts a scalar MLIR type to a TensorFlow Datatype. Status ConvertScalarTypeToDataType(mlir::Type type, DataType* dtype); // Converts an MLIR type to TensorFlow DataType. If 'type' is a scalar type, it // is converted directly. If it is a shaped type, the element type is converted. Status ConvertToDataType(mlir::Type type, DataType* dtype); // Converts an TensorFlow shape to the one used in MLIR. void ConvertToMlirShape(const TensorShape& input_shape, llvm::SmallVectorImpl<int64_t>* shape); // Converts an TensorFlow shape proto to the one used in MLIR. Status ConvertToMlirShape(const TensorShapeProto& input_shape, llvm::SmallVectorImpl<int64_t>* shape); // Given a tensor shape and dtype, get the corresponding MLIR tensor type. StatusOr<mlir::Type> ConvertToMlirTensorType(const TensorShapeProto& shape, DataType dtype, mlir::Builder* builder); } // namespace tensorflow #endif // TENSORFLOW_COMPILER_MLIR_TENSORFLOW_UTILS_CONVERT_TYPE_H_
#include "ruby.h" #include "rubyspec.h" #ifdef RUBY_VERSION_IS_1_8 #include "rubyio.h" #else #include "ruby/io.h" #endif #include <fcntl.h> #ifdef __cplusplus extern "C" { #endif #ifdef RUBY_VERSION_IS_LT_1_8_7 #define rb_io_t OpenFile #endif static int set_non_blocking(int fd) { int flags; #if defined(O_NONBLOCK) if (-1 == (flags = fcntl(fd, F_GETFL, 0))) flags = 0; return fcntl(fd, F_SETFL, flags | O_NONBLOCK); #else flags = 1; return ioctl(fd, FIOBIO, &flags); #endif } #ifdef HAVE_GET_OPEN_FILE static int io_spec_get_fd(VALUE io) { rb_io_t* fp; GetOpenFile(io, fp); #ifdef RUBY_VERSION_IS_1_9 return fp->fd; #else return fileno(fp->f); #endif } VALUE io_spec_GetOpenFile_fd(VALUE self, VALUE io) { return INT2NUM(io_spec_get_fd(io)); } #endif #ifdef HAVE_RB_IO_WRITE VALUE io_spec_rb_io_write(VALUE self, VALUE io, VALUE str) { return rb_io_write(io, str); } #endif #ifdef HAVE_RB_IO_CHECK_READABLE VALUE io_spec_rb_io_check_readable(VALUE self, VALUE io) { rb_io_t* fp; GetOpenFile(io, fp); rb_io_check_readable(fp); return Qnil; } #endif #ifdef HAVE_RB_IO_CHECK_WRITABLE VALUE io_spec_rb_io_check_writable(VALUE self, VALUE io) { rb_io_t* fp; GetOpenFile(io, fp); rb_io_check_writable(fp); return Qnil; } #endif #ifdef HAVE_RB_IO_CHECK_CLOSED VALUE io_spec_rb_io_check_closed(VALUE self, VALUE io) { rb_io_t* fp; GetOpenFile(io, fp); rb_io_check_closed(fp); return Qnil; } #endif #ifdef RUBY_VERSION_IS_1_9 typedef int wait_bool; #define wait_bool_to_ruby_bool(x) (x ? Qtrue : Qfalse) #else typedef VALUE wait_bool; #define wait_bool_to_ruby_bool(x) (x) #endif #ifdef HAVE_RB_IO_WAIT_READABLE #define RB_IO_WAIT_READABLE_BUF 13 VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) { int fd = io_spec_get_fd(io); set_non_blocking(fd); char buf[RB_IO_WAIT_READABLE_BUF]; wait_bool ret; if(RTEST(read_p)) { rb_ivar_set(self, rb_intern("@write_data"), Qtrue); if(read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) { return Qnil; } } ret = rb_io_wait_readable(fd); if(RTEST(read_p)) { if(read(fd, buf, RB_IO_WAIT_READABLE_BUF) != 13) { return Qnil; } rb_ivar_set(self, rb_intern("@read_data"), rb_str_new(buf, RB_IO_WAIT_READABLE_BUF)); } return wait_bool_to_ruby_bool(ret); } #endif #ifdef HAVE_RB_IO_WAIT_WRITABLE VALUE io_spec_rb_io_wait_writable(VALUE self, VALUE io) { wait_bool ret; ret = rb_io_wait_writable(io_spec_get_fd(io)); return wait_bool_to_ruby_bool(ret); } #endif #ifdef HAVE_RB_IO_CLOSE VALUE io_spec_rb_io_close(VALUE self, VALUE io) { return rb_io_close(io); } #endif void Init_io_spec() { VALUE cls = rb_define_class("CApiIOSpecs", rb_cObject); #ifdef HAVE_GET_OPEN_FILE rb_define_method(cls, "GetOpenFile_fd", io_spec_GetOpenFile_fd, 1); #endif #ifdef HAVE_RB_IO_WRITE rb_define_method(cls, "rb_io_write", io_spec_rb_io_write, 2); #endif #ifdef HAVE_RB_IO_CLOSE rb_define_method(cls, "rb_io_close", io_spec_rb_io_close, 1); #endif #ifdef HAVE_RB_IO_CHECK_READABLE rb_define_method(cls, "rb_io_check_readable", io_spec_rb_io_check_readable, 1); #endif #ifdef HAVE_RB_IO_CHECK_WRITABLE rb_define_method(cls, "rb_io_check_writable", io_spec_rb_io_check_writable, 1); #endif #ifdef HAVE_RB_IO_CHECK_CLOSED rb_define_method(cls, "rb_io_check_closed", io_spec_rb_io_check_closed, 1); #endif #ifdef HAVE_RB_IO_WAIT_READABLE rb_define_method(cls, "rb_io_wait_readable", io_spec_rb_io_wait_readable, 2); #endif #ifdef HAVE_RB_IO_WAIT_WRITABLE rb_define_method(cls, "rb_io_wait_writable", io_spec_rb_io_wait_writable, 1); #endif } #ifdef __cplusplus } #endif
/* (C) 1999-2001 Paul `Rusty' Russell * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/types.h> #include <linux/ipv6.h> #include <linux/in6.h> #include <linux/netfilter.h> #include <linux/module.h> #include <linux/skbuff.h> #include <linux/icmp.h> #include <linux/sysctl.h> #include <net/ipv6.h> #include <net/inet_frag.h> #include <linux/netfilter_ipv6.h> #include <linux/netfilter_bridge.h> #if IS_ENABLED(CONFIG_NF_CONNTRACK) #include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack_helper.h> #include <net/netfilter/nf_conntrack_l4proto.h> #include <net/netfilter/nf_conntrack_l3proto.h> #include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/ipv6/nf_conntrack_ipv6.h> #endif #include <net/netfilter/nf_conntrack_zones.h> #include <net/netfilter/ipv6/nf_defrag_ipv6.h> static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum, struct sk_buff *skb) { u16 zone = NF_CT_DEFAULT_ZONE; #if IS_ENABLED(CONFIG_NF_CONNTRACK) if (skb->nfct) zone = nf_ct_zone((struct nf_conn *)skb->nfct); #endif #ifdef CONFIG_BRIDGE_NETFILTER if (skb->nf_bridge && skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING) return IP6_DEFRAG_CONNTRACK_BRIDGE_IN + zone; #endif if (hooknum == NF_INET_PRE_ROUTING) return IP6_DEFRAG_CONNTRACK_IN + zone; else return IP6_DEFRAG_CONNTRACK_OUT + zone; } static unsigned int ipv6_defrag(unsigned int hooknum, struct sk_buff *skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { struct sk_buff *reasm; #if IS_ENABLED(CONFIG_NF_CONNTRACK) /* Previously seen (loopback)? */ if (skb->nfct && !nf_ct_is_template((struct nf_conn *)skb->nfct)) return NF_ACCEPT; #endif reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(hooknum, skb)); /* queued */ if (reasm == NULL) return NF_STOLEN; /* error occurred or not fragmented */ if (reasm == skb) return NF_ACCEPT; nf_ct_frag6_consume_orig(reasm); NF_HOOK_THRESH(NFPROTO_IPV6, hooknum, reasm, (struct net_device *) in, (struct net_device *) out, okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1); return NF_STOLEN; } static struct nf_hook_ops ipv6_defrag_ops[] = { { .hook = ipv6_defrag, .owner = THIS_MODULE, .pf = NFPROTO_IPV6, .hooknum = NF_INET_PRE_ROUTING, .priority = NF_IP6_PRI_CONNTRACK_DEFRAG, }, { .hook = ipv6_defrag, .owner = THIS_MODULE, .pf = NFPROTO_IPV6, .hooknum = NF_INET_LOCAL_OUT, .priority = NF_IP6_PRI_CONNTRACK_DEFRAG, }, }; static int __init nf_defrag_init(void) { int ret = 0; ret = nf_ct_frag6_init(); if (ret < 0) { pr_err("nf_defrag_ipv6: can't initialize frag6.\n"); return ret; } ret = nf_register_hooks(ipv6_defrag_ops, ARRAY_SIZE(ipv6_defrag_ops)); if (ret < 0) { pr_err("nf_defrag_ipv6: can't register hooks\n"); goto cleanup_frag6; } return ret; cleanup_frag6: nf_ct_frag6_cleanup(); return ret; } static void __exit nf_defrag_fini(void) { nf_unregister_hooks(ipv6_defrag_ops, ARRAY_SIZE(ipv6_defrag_ops)); nf_ct_frag6_cleanup(); } void nf_defrag_ipv6_enable(void) { } EXPORT_SYMBOL_GPL(nf_defrag_ipv6_enable); module_init(nf_defrag_init); module_exit(nf_defrag_fini); MODULE_LICENSE("GPL");
#include <sys/stat.h> #include <stdlib.h> #include <stdio.h> #include <time.h> #include "expat.h" static void usage(const char *prog, int rc) { fprintf(stderr, "usage: %s [-n] filename bufferSize nr_of_loops\n", prog); exit(rc); } int main (int argc, char *argv[]) { XML_Parser parser; char *XMLBuf, *XMLBufEnd, *XMLBufPtr; FILE *fd; struct stat fileAttr; int nrOfLoops, bufferSize, fileSize, i, isFinal; int j = 0, ns = 0; clock_t tstart, tend; double cpuTime = 0.0; if (argc > 1) { if (argv[1][0] == '-') { if (argv[1][1] == 'n' && argv[1][2] == '\0') { ns = 1; j = 1; } else usage(argv[0], 1); } } if (argc != j + 4) usage(argv[0], 1); if (stat (argv[j + 1], &fileAttr) != 0) { fprintf (stderr, "could not access file '%s'\n", argv[j + 1]); return 2; } fd = fopen (argv[j + 1], "r"); if (!fd) { fprintf (stderr, "could not open file '%s'\n", argv[j + 1]); exit(2); } bufferSize = atoi (argv[j + 2]); nrOfLoops = atoi (argv[j + 3]); if (bufferSize <= 0 || nrOfLoops <= 0) { fprintf (stderr, "buffer size and nr of loops must be greater than zero.\n"); exit(3); } XMLBuf = malloc (fileAttr.st_size); fileSize = fread (XMLBuf, sizeof (char), fileAttr.st_size, fd); fclose (fd); i = 0; XMLBufEnd = XMLBuf + fileSize; while (i < nrOfLoops) { XMLBufPtr = XMLBuf; isFinal = 0; if (ns) parser = XML_ParserCreateNS(NULL, '!'); else parser = XML_ParserCreate(NULL); tstart = clock(); do { int parseBufferSize = XMLBufEnd - XMLBufPtr; if (parseBufferSize <= bufferSize) isFinal = 1; else parseBufferSize = bufferSize; if (!XML_Parse (parser, XMLBufPtr, parseBufferSize, isFinal)) { fprintf (stderr, "error '%s' at line %d character %d\n", XML_ErrorString (XML_GetErrorCode (parser)), XML_GetCurrentLineNumber (parser), XML_GetCurrentColumnNumber (parser)); free (XMLBuf); XML_ParserFree (parser); exit (4); } XMLBufPtr += bufferSize; } while (!isFinal); tend = clock(); cpuTime += ((double) (tend - tstart)) / CLOCKS_PER_SEC; XML_ParserFree (parser); i++; } free (XMLBuf); printf ("%d loops, with buffer size %d. Average time per loop: %f\n", nrOfLoops, bufferSize, cpuTime / (double) nrOfLoops); return 0; }
/* * Copyright (c) 1993 Martin Birgmeier * All rights reserved. * * You may redistribute unmodified or modified versions of this source * code provided that the above copyright notice and this and the * following conditions are retained. * * This software is provided ``as is'', and comes with no warranties * of any kind. I shall in no event be liable for anything that happens * to anyone/anything when using this software. */ #include "rand48.h" double _drand48_r (struct _reent *r) { _REENT_CHECK_RAND48(r); return _erand48_r(r, __rand48_seed); } #ifndef _REENT_ONLY double drand48 (void) { return _drand48_r (_REENT); } #endif /* !_REENT_ONLY */
/* * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> * Copyright (c) 2013 Pablo Neira Ayuso <pablo@netfilter.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Development of this code funded by Astaro AG (http://www.astaro.com/) */ #include <linux/init.h> #include <linux/module.h> #include <linux/netfilter_bridge.h> #include <net/netfilter/nf_tables.h> #include <linux/ip.h> #include <linux/ipv6.h> #include <net/netfilter/nf_tables_ipv4.h> #include <net/netfilter/nf_tables_ipv6.h> static unsigned int nft_do_chain_bridge(void *priv, struct sk_buff *skb, const struct nf_hook_state *state) { struct nft_pktinfo pkt; nft_set_pktinfo(&pkt, skb, state); switch (eth_hdr(skb)->h_proto) { case htons(ETH_P_IP): nft_set_pktinfo_ipv4_validate(&pkt, skb); break; case htons(ETH_P_IPV6): nft_set_pktinfo_ipv6_validate(&pkt, skb); break; default: nft_set_pktinfo_unspec(&pkt, skb); break; } return nft_do_chain(&pkt, priv); } static const struct nf_chain_type filter_bridge = { .name = "filter", .type = NFT_CHAIN_T_DEFAULT, .family = NFPROTO_BRIDGE, .owner = THIS_MODULE, .hook_mask = (1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_IN) | (1 << NF_BR_FORWARD) | (1 << NF_BR_LOCAL_OUT) | (1 << NF_BR_POST_ROUTING), .hooks = { [NF_BR_PRE_ROUTING] = nft_do_chain_bridge, [NF_BR_LOCAL_IN] = nft_do_chain_bridge, [NF_BR_FORWARD] = nft_do_chain_bridge, [NF_BR_LOCAL_OUT] = nft_do_chain_bridge, [NF_BR_POST_ROUTING] = nft_do_chain_bridge, }, }; static int __init nf_tables_bridge_init(void) { return nft_register_chain_type(&filter_bridge); } static void __exit nf_tables_bridge_exit(void) { nft_unregister_chain_type(&filter_bridge); } module_init(nf_tables_bridge_init); module_exit(nf_tables_bridge_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); MODULE_ALIAS_NFT_CHAIN(AF_BRIDGE, "filter");
/* This testcase is part of GDB, the GNU debugger. Copyright 2004, 2007-2012 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Useful abreviations. */ typedef void t; typedef char tc; typedef short ts; typedef int ti; typedef long tl; typedef long long tll; typedef float tf; typedef double td; typedef long double tld; typedef enum { e = '1' } te; /* Force the type of each field. */ #ifndef T typedef t T; #endif T foo = '1', L; T fun() { return foo; } #ifdef PROTOTYPES void Fun(T foo) #else void Fun(foo) T foo; #endif { L = foo; } zed () { L = 'Z'; } int main() { int i; Fun(foo); /* An infinite loop that first clears all the variables and then calls the function. This "hack" is to make re-testing easier - "advance fun" is guaranteed to have always been preceded by a global variable clearing zed call. */ zed (); while (1) { L = fun (); zed (); } return 0; }
/* SPDX-License-Identifier: LGPL-2.1+ */ #include <getopt.h> #include "macro.h" #include "strv.h" #include "verbs.h" static int noop_dispatcher(int argc, char *argv[], void *userdata) { return 0; } #define test_dispatch_one(argv, verbs, expected) \ optind = 0; \ assert_se(dispatch_verb(strv_length(argv), argv, verbs, NULL) == expected); static void test_verbs(void) { static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, noop_dispatcher }, { "list-images", VERB_ANY, 1, 0, noop_dispatcher }, { "list", VERB_ANY, 2, VERB_DEFAULT, noop_dispatcher }, { "status", 2, VERB_ANY, 0, noop_dispatcher }, { "show", VERB_ANY, VERB_ANY, 0, noop_dispatcher }, { "terminate", 2, VERB_ANY, 0, noop_dispatcher }, { "login", 2, 2, 0, noop_dispatcher }, { "copy-to", 3, 4, 0, noop_dispatcher }, {} }; /* not found */ test_dispatch_one(STRV_MAKE("command-not-found"), verbs, -EINVAL); /* found */ test_dispatch_one(STRV_MAKE("show"), verbs, 0); /* found, too few args */ test_dispatch_one(STRV_MAKE("copy-to", "foo"), verbs, -EINVAL); /* found, meets min args */ test_dispatch_one(STRV_MAKE("status", "foo", "bar"), verbs, 0); /* found, too many args */ test_dispatch_one(STRV_MAKE("copy-to", "foo", "bar", "baz", "quux", "qaax"), verbs, -EINVAL); /* no verb, but a default is set */ test_dispatch_one(STRV_MAKE_EMPTY, verbs, 0); } static void test_verbs_no_default(void) { static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, noop_dispatcher }, {}, }; test_dispatch_one(STRV_MAKE(NULL), verbs, -EINVAL); } int main(int argc, char *argv[]) { test_verbs(); test_verbs_no_default(); return 0; }
/* Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization dedicated to making software imaging solutions freely available. You may not use this file except in compliance with the License. obtain a copy of the License at http://www.imagemagick.org/script/license.php 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. MagickCore image segment methods. */ #ifndef _MAGICKCORE_SEGMENT_H #define _MAGICKCORE_SEGMENT_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif extern MagickExport MagickBooleanType GetImageDynamicThreshold(const Image *,const double,const double, MagickPixelPacket *,ExceptionInfo *), SegmentImage(Image *,const ColorspaceType,const MagickBooleanType, const double,const double); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif
// // AccessExpireLRUCache.h // // $Id: //poco/1.3/Foundation/include/Poco/AccessExpireLRUCache.h#1 $ // // Library: Foundation // Package: Cache // Module: AccessExpireLRUCache // // Definition of the AccessExpireLRUCache class. // // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // and Contributors. // // Permission is hereby granted, free of charge, to any person or organization // obtaining a copy of the software and accompanying documentation covered by // this license (the "Software") to use, reproduce, display, distribute, // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // // The copyright notices in the Software and this entire statement, including // the above license grant, this restriction and the following disclaimer, // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // #ifndef Foundation_AccessExpireLRUCache_INCLUDED #define Foundation_AccessExpireLRUCache_INCLUDED #include "Poco/AbstractCache.h" #include "Poco/StrategyCollection.h" #include "Poco/AccessExpireStrategy.h" #include "Poco/LRUStrategy.h" namespace Poco { template < class TKey, class TValue > class AccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> > /// An AccessExpireLRUCache combines LRU caching and time based expire caching. /// It cache entries for a fixed time period (per default 10 minutes) /// but also limits the size of the cache (per default: 1024). { public: AccessExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000): AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >(StrategyCollection<TKey, TValue>()) { this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); this->_strategy.pushBack(new AccessExpireStrategy<TKey, TValue>(expire)); } ~AccessExpireLRUCache() { } private: AccessExpireLRUCache(const AccessExpireLRUCache& aCache); AccessExpireLRUCache& operator = (const AccessExpireLRUCache& aCache); }; } // namespace Poco #endif // Foundation_AccessExpireLRUCache_INCLUDED
/* * Copyright 2008-2013 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <thrust/detail/config.h> #include <thrust/iterator/iterator_traits.h> namespace thrust { namespace system { namespace detail { namespace generic { template<typename InputIterator> inline __host__ __device__ typename thrust::iterator_traits<InputIterator>::difference_type distance(InputIterator first, InputIterator last); } // end namespace generic } // end namespace detail } // end namespace system } // end namespace thrust #include <thrust/system/detail/generic/distance.inl>
/* Bluetooth Low Energy Protocol for QMK. * Author: Wez Furlong, 2016 * Supports the Adafruit BLE board built around the nRF51822 chip. */ #pragma once #ifdef MODULE_ADAFRUIT_BLE # include <stdbool.h> # include <stdint.h> # include <string.h> # include "config_common.h" # include "progmem.h" # ifdef __cplusplus extern "C" { # endif /* Instruct the module to enable HID keyboard support and reset */ extern bool adafruit_ble_enable_keyboard(void); /* Query to see if the BLE module is connected */ extern bool adafruit_ble_query_is_connected(void); /* Returns true if we believe that the BLE module is connected. * This uses our cached understanding that is maintained by * calling ble_task() periodically. */ extern bool adafruit_ble_is_connected(void); /* Call this periodically to process BLE-originated things */ extern void adafruit_ble_task(void); /* Generates keypress events for a set of keys. * The hid modifier mask specifies the state of the modifier keys for * this set of keys. * Also sends a key release indicator, so that the keys do not remain * held down. */ extern bool adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys); /* Send a consumer keycode, holding it down for the specified duration * (milliseconds) */ extern bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration); # ifdef MOUSE_ENABLE /* Send a mouse/wheel movement report. * The parameters are signed and indicate positive of negative direction * change. */ extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons); # endif /* Compute battery voltage by reading an analog pin. * Returns the integer number of millivolts */ extern uint32_t adafruit_ble_read_battery_voltage(void); extern bool adafruit_ble_set_mode_leds(bool on); extern bool adafruit_ble_set_power_level(int8_t level); # ifdef __cplusplus } # endif #endif // MODULE_ADAFRUIT_BLE
#pragma once /* * Copyright (C) 2005-2013 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XBMC; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * */ #include "BackgroundInfoLoader.h" #include "MusicDatabase.h" class CFileItemList; class CMusicThumbLoader; namespace MUSIC_INFO { class CMusicInfoLoader : public CBackgroundInfoLoader { public: CMusicInfoLoader(); virtual ~CMusicInfoLoader(); void UseCacheOnHD(const CStdString& strFileName); virtual bool LoadItem(CFileItem* pItem); virtual bool LoadItemCached(CFileItem* pItem); virtual bool LoadItemLookup(CFileItem* pItem); static bool LoadAdditionalTagInfo(CFileItem* pItem); protected: virtual void OnLoaderStart(); virtual void OnLoaderFinish(); void LoadCache(const CStdString& strFileName, CFileItemList& items); void SaveCache(const CStdString& strFileName, CFileItemList& items); protected: CStdString m_strCacheFileName; CFileItemList* m_mapFileItems; MAPSONGS m_songsMap; CStdString m_strPrevPath; CMusicDatabase m_musicDatabase; unsigned int m_databaseHits; unsigned int m_tagReads; CMusicThumbLoader *m_thumbLoader; }; }
/* Copyright 2013 Google Inc. All Rights Reserved. Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Data model for a font file in sfnt format, reading and writing functions and accessors for the glyph data. */ #ifndef WOFF2_FONT_H_ #define WOFF2_FONT_H_ #include <stddef.h> #include <inttypes.h> #include <map> #include <vector> namespace woff2 { // Represents an sfnt font file. Only the table directory is parsed, for the // table data we only store a raw pointer, therefore a font object is valid only // as long the data from which it was parsed is around. struct Font { uint32_t flavor; uint16_t num_tables; struct Table { uint32_t tag; uint32_t checksum; uint32_t offset; uint32_t length; const uint8_t* data; // Buffer used to mutate the data before writing out. std::vector<uint8_t> buffer; // If we've seen this tag/offset before, pointer to the first time we saw it // If this is the first time we've seen this table, NULL // Intended use is to bypass re-processing tables Font::Table* reuse_of; uint8_t flag_byte; // Is this table reused by a TTC bool IsReused() const; }; std::map<uint32_t, Table> tables; std::vector<uint32_t> OutputOrderedTags() const; Table* FindTable(uint32_t tag); const Table* FindTable(uint32_t tag) const; }; // Accomodates both singular (OTF, TTF) and collection (TTC) fonts struct FontCollection { uint32_t flavor; uint32_t header_version; // (offset, first use of table*) pairs std::map<uint32_t, Font::Table*> tables; std::vector<Font> fonts; }; // Parses the font from the given data. Returns false on parsing failure or // buffer overflow. The font is valid only so long the input data pointer is // valid. Does NOT support collections. bool ReadFont(const uint8_t* data, size_t len, Font* font); // Parses the font from the given data. Returns false on parsing failure or // buffer overflow. The font is valid only so long the input data pointer is // valid. Supports collections. bool ReadFontCollection(const uint8_t* data, size_t len, FontCollection* fonts); // Returns the file size of the font. size_t FontFileSize(const Font& font); size_t FontCollectionFileSize(const FontCollection& font); // Writes the font into the specified dst buffer. The dst_size should be the // same as returned by FontFileSize(). Returns false upon buffer overflow (which // should not happen if dst_size was computed by FontFileSize()). bool WriteFont(const Font& font, uint8_t* dst, size_t dst_size); // Write the font at a specific offset bool WriteFont(const Font& font, size_t* offset, uint8_t* dst, size_t dst_size); bool WriteFontCollection(const FontCollection& font_collection, uint8_t* dst, size_t dst_size); // Returns the number of glyphs in the font. // NOTE: Currently this works only for TrueType-flavored fonts, will return // zero for CFF-flavored fonts. int NumGlyphs(const Font& font); // Returns the index format of the font int IndexFormat(const Font& font); // Sets *glyph_data and *glyph_size to point to the location of the glyph data // with the given index. Returns false if the glyph is not found. bool GetGlyphData(const Font& font, int glyph_index, const uint8_t** glyph_data, size_t* glyph_size); // Removes the digital signature (DSIG) table bool RemoveDigitalSignature(Font* font); } // namespace woff2 #endif // WOFF2_FONT_H_
/* packet-dpvreq.c * Routines for DOCSIS 3.0 DOCSIS Path Verify Response Message dissection. * Copyright 2010, Guido Reismueller <g.reismueller[AT]avm.de> * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" #include <epan/packet.h> void proto_register_docsis_dpvreq(void); void proto_reg_handoff_docsis_dpvreq(void); /* Initialize the protocol and registered fields */ static int proto_docsis_dpvreq = -1; static int hf_docsis_dpvreq_tranid = -1; static int hf_docsis_dpvreq_dschan = -1; static int hf_docsis_dpvreq_flags = -1; static int hf_docsis_dpvreq_us_sf = -1; static int hf_docsis_dpvreq_n = -1; static int hf_docsis_dpvreq_start = -1; static int hf_docsis_dpvreq_end = -1; static int hf_docsis_dpvreq_ts_start = -1; static int hf_docsis_dpvreq_ts_end = -1; /* Initialize the subtree pointers */ static gint ett_docsis_dpvreq = -1; /* Dissection */ static void dissect_dpvreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) { proto_item *it; proto_tree *dpvreq_tree = NULL; guint16 transid; guint8 dschan; transid = tvb_get_ntohs (tvb, 0); dschan = tvb_get_guint8 (tvb, 2); col_add_fstr (pinfo->cinfo, COL_INFO, "DOCSIS Path Verify Request: Transaction-Id = %u DS-Ch %d", transid, dschan); if (tree) { it = proto_tree_add_protocol_format (tree, proto_docsis_dpvreq, tvb, 0, -1, "DPV Request"); dpvreq_tree = proto_item_add_subtree (it, ett_docsis_dpvreq); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_tranid, tvb, 0, 2, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_dschan, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_flags, tvb, 3, 1, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_us_sf, tvb, 4, 4, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_n, tvb, 8, 2, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_start, tvb, 10, 1, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_end, tvb, 11, 1, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_start, tvb, 12, 4, ENC_BIG_ENDIAN); proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_end, tvb, 16, 4, ENC_BIG_ENDIAN); } } /* Register the protocol with Wireshark */ void proto_register_docsis_dpvreq (void) { static hf_register_info hf[] = { {&hf_docsis_dpvreq_tranid, {"Transaction Id", "docsis_dpvreq.tranid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_dschan, {"Downstream Channel ID", "docsis_dpvreq.dschan", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_flags, {"Flags", "docsis_dpvreq.flags", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_us_sf, {"Upstream Service Flow ID", "docsis_dpvreq.us_sf", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_n, {"N (Measurement avaraging factor)", "docsis_dpvreq.n", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_start, {"Start Reference Point", "docsis_dpvreq.start", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_end, {"End Reference Point", "docsis_dpvreq.end", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_ts_start, {"Timestamp Start", "docsis_dpvreq.ts_start", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_dpvreq_ts_end, {"Timestamp End", "docsis_dpvreq.ts_end", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL} }, }; static gint *ett[] = { &ett_docsis_dpvreq, }; proto_docsis_dpvreq = proto_register_protocol ("DOCSIS Path Verify Request", "DOCSIS DPV-REQ", "docsis_dpvreq"); proto_register_field_array (proto_docsis_dpvreq, hf, array_length (hf)); proto_register_subtree_array (ett, array_length (ett)); register_dissector ("docsis_dpvreq", dissect_dpvreq, proto_docsis_dpvreq); } void proto_reg_handoff_docsis_dpvreq (void) { dissector_handle_t docsis_dpvreq_handle; docsis_dpvreq_handle = find_dissector ("docsis_dpvreq"); dissector_add_uint ("docsis_mgmt", 0x27, docsis_dpvreq_handle); } /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * * Local Variables: * c-basic-offset: 2 * tab-width: 8 * indent-tabs-mode: nil * End: * * ex: set shiftwidth=2 tabstop=8 expandtab: * :indentSize=2:tabSize=8:noTabs=true: */
/* esp.c */ #define ESP_MAX_DEVS 7 typedef void (*espdma_memory_read_write)(void *opaque, uint8_t *buf, int len); void esp_init(target_phys_addr_t espaddr, int it_shift, espdma_memory_read_write dma_memory_read, espdma_memory_read_write dma_memory_write, void *dma_opaque, qemu_irq irq, qemu_irq *reset);
/* PR optimization/13985 */ /* Copied from gcc.c-torture/compile/930621-1.c */ /* { dg-do compile } */ /* { dg-options "-O3" } */ /* { dg-options "-O3 -mtune=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ /* { dg-add-options stack_size } */ #if defined(STACK_SIZE) && (STACK_SIZE < 65536) # define BYTEMEM_SIZE 10000L #endif #ifndef BYTEMEM_SIZE # define BYTEMEM_SIZE 45000L #endif int bytestart[5000 + 1]; unsigned char modtext[400 + 1]; unsigned char bytemem[2][BYTEMEM_SIZE + 1]; long modlookup (int l) { signed char c; long j; long k; signed char w; long p; while (p != 0) { while ((k < bytestart[p + 2]) && (j <= l) && (modtext[j] == bytemem[w][k])) { k = k + 1; j = j + 1; } if (k == bytestart[p + 2]) if (j > l) c = 1; else c = 4; else if (j > l) c = 3; else if (modtext[j] < bytemem[w][k]) c = 0; else c = 2; } }
/* Define a default password for telnetd here. * NOTES: * - this can be overridden at run-time by setting * the "TELNETD_PASSWD" environment variable. * As soon as that variable is set, the new password * is effective - no need to restart telnetd. * - this must be set to an _encrypted_ password, NOT * the cleartext. Use the 'genpw' utility to generate * a password string: * * 1) Compile 'genpw.c' for the HOST, i.e. * cc -o genpw genpw.c -lcrypt * 1) delete an old password definition from this file. * 2) run './genpw >> passwd.h'. This will append * a new definition to this file. * * - if no password is defined here, no authentication * is needed, i.e. telnet is open to the world. * * T. Straumann <strauman@slac.stanford.edu> */ /* #undef TELNETD_DEFAULT_PASSWD */ /* Default password: 'rtems' */ #define TELNETD_DEFAULT_PASSWD "tduDcyLX12owo"
// license:BSD-3-Clause // copyright-holders: F. Ulivi /********************************************************************* 82900.h 82900 module (CP/M auxiliary processor) *********************************************************************/ #ifndef MAME_BUS_HP80_IO_82900_H #define MAME_BUS_HP80_IO_82900_H #pragma once #include "hp80_io.h" #include "cpu/z80/z80.h" #include "machine/1mb5.h" class hp82900_io_card_device : public device_t, public device_hp80_io_interface { public: // construction/destruction hp82900_io_card_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); virtual ~hp82900_io_card_device(); protected: virtual void device_start() override; virtual void device_reset() override; // device-level overrides virtual ioport_constructor device_input_ports() const override; virtual const tiny_rom_entry *device_rom_region() const override; virtual void device_add_mconfig(machine_config &config) override; virtual void install_read_write_handlers(address_space& space , uint16_t base_addr) override; virtual void inten() override; virtual void clear_service() override; private: required_device<z80_device> m_cpu; required_device<hp_1mb5_device> m_translator; // Boot ROM required_region_ptr<uint8_t> m_rom; // RAM std::unique_ptr<uint8_t []> m_ram; bool m_rom_enabled; uint8_t m_addr_latch; DECLARE_WRITE_LINE_MEMBER(reset_w); uint8_t cpu_mem_r(offs_t offset); void cpu_mem_w(offs_t offset, uint8_t data); uint8_t cpu_io_r(offs_t offset); void cpu_io_w(offs_t offset, uint8_t data); void cpu_mem_map(address_map &map); void cpu_io_map(address_map &map); void z80_m1_w(uint8_t data); }; // device type definition DECLARE_DEVICE_TYPE(HP82900_IO_CARD, hp82900_io_card_device) #endif // MAME_BUS_HP80_IO_82900_H
// license:BSD-3-Clause // copyright-holders:Phil Stroffolino /************************************************************************* Munch Mobile *************************************************************************/ #ifndef MAME_INCLUDES_MUNCHMO_H #define MAME_INCLUDES_MUNCHMO_H #pragma once #include "machine/gen_latch.h" #include "machine/74259.h" #include "sound/ay8910.h" #include "emupal.h" class munchmo_state : public driver_device { public: munchmo_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_sprite_xpos(*this, "sprite_xpos") , m_sprite_tile(*this, "sprite_tile") , m_sprite_attr(*this, "sprite_attr") , m_videoram(*this, "videoram") , m_status_vram(*this, "status_vram") , m_vreg(*this, "vreg") , m_maincpu(*this, "maincpu") , m_audiocpu(*this, "audiocpu") , m_mainlatch(*this, "mainlatch") , m_gfxdecode(*this, "gfxdecode") , m_palette(*this, "palette") , m_soundlatch(*this, "soundlatch") , m_ay8910(*this, "ay%u", 1U) { } void mnchmobl(machine_config &config); protected: virtual void machine_start() override; virtual void video_start() override; private: DECLARE_WRITE_LINE_MEMBER(nmi_enable_w); void nmi_ack_w(uint8_t data); void sound_nmi_ack_w(uint8_t data); uint8_t ay1reset_r(); uint8_t ay2reset_r(); DECLARE_WRITE_LINE_MEMBER(palette_bank_0_w); DECLARE_WRITE_LINE_MEMBER(palette_bank_1_w); DECLARE_WRITE_LINE_MEMBER(flipscreen_w); void munchmo_palette(palette_device &palette) const; DECLARE_WRITE_LINE_MEMBER(vblank_irq); IRQ_CALLBACK_MEMBER(generic_irq_ack); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void draw_status( bitmap_ind16 &bitmap, const rectangle &cliprect ); void draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect ); void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); void mnchmobl_map(address_map &map); void sound_map(address_map &map); /* memory pointers */ required_shared_ptr<uint8_t> m_sprite_xpos; required_shared_ptr<uint8_t> m_sprite_tile; required_shared_ptr<uint8_t> m_sprite_attr; required_shared_ptr<uint8_t> m_videoram; required_shared_ptr<uint8_t> m_status_vram; required_shared_ptr<uint8_t> m_vreg; /* video-related */ std::unique_ptr<bitmap_ind16> m_tmpbitmap; int m_palette_bank; int m_flipscreen; /* misc */ int m_nmi_enable; /* devices */ required_device<cpu_device> m_maincpu; required_device<cpu_device> m_audiocpu; required_device<ls259_device> m_mainlatch; required_device<gfxdecode_device> m_gfxdecode; required_device<palette_device> m_palette; required_device<generic_latch_8_device> m_soundlatch; required_device_array<ay8910_device, 2> m_ay8910; }; #endif // MAME_INCLUDES_MUNCHMO_H
// license:BSD-3-Clause // copyright-holders:Nicola Salmoria #ifndef MAME_INCLUDES_FLSTORY_H #define MAME_INCLUDES_FLSTORY_H #pragma once #include "machine/gen_latch.h" #include "machine/input_merger.h" #include "sound/msm5232.h" #include "machine/taito68705interface.h" #include "sound/ta7630.h" #include "sound/ay8910.h" #include "emupal.h" #include "tilemap.h" class flstory_state : public driver_device { public: flstory_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_videoram(*this, "videoram"), m_spriteram(*this, "spriteram"), m_scrlram(*this, "scrlram"), m_workram(*this, "workram"), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_bmcu(*this, "bmcu"), m_msm(*this, "msm"), m_ay(*this, "aysnd"), m_ta7630(*this, "ta7630"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), m_soundlatch(*this, "soundlatch"), m_soundlatch2(*this, "soundlatch2"), m_soundnmi(*this, "soundnmi"), m_extraio1(*this, "EXTRA_P1") { } void common(machine_config &config); void flstory(machine_config &config); void rumba(machine_config &config); void onna34ro(machine_config &config); void victnine(machine_config &config); void onna34ro_mcu(machine_config &config); protected: virtual void machine_start() override; private: /* memory pointers */ required_shared_ptr<uint8_t> m_videoram; required_shared_ptr<uint8_t> m_spriteram; required_shared_ptr<uint8_t> m_scrlram; optional_shared_ptr<uint8_t> m_workram; /* video-related */ tilemap_t *m_bg_tilemap; std::vector<uint8_t> m_paletteram; std::vector<uint8_t> m_paletteram_ext; uint8_t m_gfxctrl; uint8_t m_char_bank; uint8_t m_palette_bank; /* sound-related */ uint8_t m_snd_ctrl0; uint8_t m_snd_ctrl1; uint8_t m_snd_ctrl2; uint8_t m_snd_ctrl3; /* protection sims */ uint8_t m_from_mcu; int m_mcu_select; /* devices */ required_device<cpu_device> m_maincpu; required_device<cpu_device> m_audiocpu; optional_device<taito68705_mcu_device> m_bmcu; required_device<msm5232_device> m_msm; required_device<ay8910_device> m_ay; required_device<ta7630_device> m_ta7630; required_device<gfxdecode_device> m_gfxdecode; required_device<palette_device> m_palette; required_device<generic_latch_8_device> m_soundlatch; required_device<generic_latch_8_device> m_soundlatch2; required_device<input_merger_device> m_soundnmi; optional_ioport m_extraio1; uint8_t snd_flag_r(); void snd_reset_w(uint8_t data); uint8_t flstory_mcu_status_r(); uint8_t victnine_mcu_status_r(); void flstory_videoram_w(offs_t offset, uint8_t data); void flstory_palette_w(offs_t offset, uint8_t data); uint8_t flstory_palette_r(offs_t offset); void flstory_gfxctrl_w(uint8_t data); uint8_t victnine_gfxctrl_r(); void victnine_gfxctrl_w(uint8_t data); void flstory_scrlram_w(offs_t offset, uint8_t data); void sound_control_0_w(uint8_t data); void sound_control_1_w(uint8_t data); void sound_control_2_w(uint8_t data); void sound_control_3_w(uint8_t data); TILE_GET_INFO_MEMBER(get_tile_info); TILE_GET_INFO_MEMBER(victnine_get_tile_info); TILE_GET_INFO_MEMBER(get_rumba_tile_info); DECLARE_MACHINE_RESET(flstory); DECLARE_VIDEO_START(flstory); DECLARE_VIDEO_START(victnine); DECLARE_MACHINE_RESET(rumba); DECLARE_VIDEO_START(rumba); DECLARE_MACHINE_RESET(ta7630); uint32_t screen_update_flstory(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); uint32_t screen_update_victnine(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); uint32_t screen_update_rumba(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void flstory_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri ); void victnine_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); void base_map(address_map &map); void flstory_map(address_map &map); void onna34ro_map(address_map &map); void onna34ro_mcu_map(address_map &map); void rumba_map(address_map &map); void sound_map(address_map &map); void victnine_map(address_map &map); }; #endif // MAME_INCLUDES_FLSTORY_H
/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com> * Copyright (C) 2012 Regents of the University of California * Copyright (C) 2017 SiFive * Copyright (C) 2017 XiaojingZhu <zhuxiaoj@ict.ac.cn> */ #ifndef _ASM_RISCV_PAGE_H #define _ASM_RISCV_PAGE_H #include <linux/pfn.h> #include <linux/const.h> #define PAGE_SHIFT (12) #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) #define PAGE_MASK (~(PAGE_SIZE - 1)) #ifdef CONFIG_64BIT #define HUGE_MAX_HSTATE 2 #else #define HUGE_MAX_HSTATE 1 #endif #define HPAGE_SHIFT PMD_SHIFT #define HPAGE_SIZE (_AC(1, UL) << HPAGE_SHIFT) #define HPAGE_MASK (~(HPAGE_SIZE - 1)) #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) /* * PAGE_OFFSET -- the first address of the first page of memory. * When not using MMU this corresponds to the first free page in * physical memory (aligned on a page boundary). */ #define PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL) #define KERN_VIRT_SIZE (-PAGE_OFFSET) #ifndef __ASSEMBLY__ #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1))) #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1))) /* align addr on a size boundary - adjust address up/down if needed */ #define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1))) #define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1))) /* align addr on a size boundary - adjust address up if needed */ #define _ALIGN(addr, size) _ALIGN_UP(addr, size) #define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE) #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE) #define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE) #define copy_user_page(vto, vfrom, vaddr, topg) \ memcpy((vto), (vfrom), PAGE_SIZE) /* * Use struct definitions to apply C type checking */ /* Page Global Directory entry */ typedef struct { unsigned long pgd; } pgd_t; /* Page Table entry */ typedef struct { unsigned long pte; } pte_t; typedef struct { unsigned long pgprot; } pgprot_t; typedef struct page *pgtable_t; #define pte_val(x) ((x).pte) #define pgd_val(x) ((x).pgd) #define pgprot_val(x) ((x).pgprot) #define __pte(x) ((pte_t) { (x) }) #define __pgd(x) ((pgd_t) { (x) }) #define __pgprot(x) ((pgprot_t) { (x) }) #ifdef CONFIG_64BIT #define PTE_FMT "%016lx" #else #define PTE_FMT "%08lx" #endif #ifdef CONFIG_MMU extern unsigned long va_pa_offset; extern unsigned long pfn_base; #define ARCH_PFN_OFFSET (pfn_base) #else #define va_pa_offset 0 #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) #endif /* CONFIG_MMU */ #define __pa_to_va_nodebug(x) ((void *)((unsigned long) (x) + va_pa_offset)) #define __va_to_pa_nodebug(x) ((unsigned long)(x) - va_pa_offset) #ifdef CONFIG_DEBUG_VIRTUAL extern phys_addr_t __virt_to_phys(unsigned long x); extern phys_addr_t __phys_addr_symbol(unsigned long x); #else #define __virt_to_phys(x) __va_to_pa_nodebug(x) #define __phys_addr_symbol(x) __va_to_pa_nodebug(x) #endif /* CONFIG_DEBUG_VIRTUAL */ #define __pa_symbol(x) __phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0)) #define __pa(x) __virt_to_phys((unsigned long)(x)) #define __va(x) ((void *)__pa_to_va_nodebug((phys_addr_t)(x))) #define phys_to_pfn(phys) (PFN_DOWN(phys)) #define pfn_to_phys(pfn) (PFN_PHYS(pfn)) #define virt_to_pfn(vaddr) (phys_to_pfn(__pa(vaddr))) #define pfn_to_virt(pfn) (__va(pfn_to_phys(pfn))) #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr))) #define page_to_virt(page) (pfn_to_virt(page_to_pfn(page))) #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page))) #define page_to_bus(page) (page_to_phys(page)) #define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr))) #ifdef CONFIG_FLATMEM #define pfn_valid(pfn) \ (((pfn) >= ARCH_PFN_OFFSET) && (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)) #endif #endif /* __ASSEMBLY__ */ #define virt_addr_valid(vaddr) ({ \ unsigned long _addr = (unsigned long)vaddr; \ (unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \ }) #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC #include <asm-generic/memory_model.h> #include <asm-generic/getorder.h> #endif /* _ASM_RISCV_PAGE_H */
/* $NoKeywords:$ */ /** * @file * * Four node Square Topology. * * @xrefitem bom "File Content Label" "Release Content" * @e project: AGESA * @e sub-project: HyperTransport * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 17:16:51 +0800 (Wed, 22 Dec 2010) $ * */ /* ***************************************************************************** * * Copyright (c) 2011, Advanced Micro Devices, Inc. * 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 Advanced Micro Devices, Inc. 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 ADVANCED MICRO DEVICES, INC. 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 "Porting.h" #include "htTopologies.h" CODE_GROUP (G1_PEICC) RDATA_GROUP (G1_PEICC) /* * 2---3 * | | * | | * 0---1 */ /** * Four Node square */ /** * @dot strict graph square4 { node [shape="plaintext"]; {rank=same; 0; 1} {rank=same; 2; 3} 0 -- 1 ; 0 -- 2 ; 1 -- 3 ; 2 -- 3 ; } @enddot * */ CONST UINT8 ROMDATA amdHtTopologyFourSquare[] = { 0x04, 0x06, 0xFF, 0x00, 0x11, 0x02, 0x22, 0x00, 0x22, // Node 0 0x00, 0x00, 0x09, 0xFF, 0x00, 0x33, 0x01, 0x33, // Node 1 0x08, 0x00, 0x00, 0x00, 0x09, 0xFF, 0x00, 0x33, // Node 2 0x00, 0x11, 0x04, 0x11, 0x00, 0x22, 0x06, 0xFF // Node 3 };
/* * * Copyright 2015-2016, Google Inc. * 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 Google Inc. 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 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef GRPC_SUPPORT_LOG_WIN32_H #define GRPC_SUPPORT_LOG_WIN32_H #ifdef __cplusplus extern "C" { #endif /* Returns a string allocated with gpr_malloc that contains a UTF-8 * formatted error message, corresponding to the error messageid. * Use in conjunction with GetLastError() et al. */ GPR_API char *gpr_format_message(int messageid); #ifdef __cplusplus } #endif #endif /* GRPC_SUPPORT_LOG_WIN32_H */
// Copyright 2015 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #ifndef BAZEL_SRC_MAIN_CPP_UTIL_ERRORS_H_ #define BAZEL_SRC_MAIN_CPP_UTIL_ERRORS_H_ #include "src/main/cpp/util/port.h" namespace blaze_util { // Prints the specified error message and exits nonzero. void die(const int exit_status, const char *format, ...) ATTRIBUTE_NORETURN PRINTF_ATTRIBUTE(2, 3); // Prints "Error: <formatted-message>: <strerror(errno)>\n", and exits nonzero. void pdie(const int exit_status, const char *format, ...) ATTRIBUTE_NORETURN PRINTF_ATTRIBUTE(2, 3); } // namespace blaze_util #endif // BAZEL_SRC_MAIN_CPP_UTIL_ERRORS_H_
// license:BSD-3-Clause // copyright-holders:Tyler J. Stachecki,Ryan Holtz // LBV, LDV, LLV, LSV, SBV, SDV, SLV, SSV inline void vec_lbdlsv_sbdlsv(uint32_t iw, uint32_t rs) { const uint32_t shift_and_idx = (iw >> 11) & 0x3; rsp_vec_t dqm = _mm_loadl_epi64((rsp_vec_t *) (m_vec_helpers.bdls_lut[shift_and_idx])); const uint32_t addr = (rs + (sign_extend_6(iw) << shift_and_idx)) & 0xfff; const uint32_t element = (iw >> 7) & 0xf; uint16_t* regp = m_v[(iw >> 16) & 0x1f].s; if (iw >> 29 & 0x1) { vec_store_group1(addr, element, regp, vec_load_unshuffled_operand(regp), dqm); } else { vec_load_group1(addr, element, regp, vec_load_unshuffled_operand(regp), dqm); } } // LPV, LUV, SPV, SUV inline void vec_lfhpuv_sfhpuv(uint32_t iw, uint32_t rs) { static const enum rsp_mem_request_type fhpu_type_lut[4] = { RSP_MEM_REQUEST_PACK, RSP_MEM_REQUEST_UPACK, RSP_MEM_REQUEST_HALF, RSP_MEM_REQUEST_FOURTH }; const uint32_t addr = (rs + (sign_extend_6(iw) << 3)) & 0xfff; const uint32_t element = (iw >> 7) & 0xf; uint16_t* regp = m_v[(iw >> 16) & 0x1f].s; rsp_mem_request_type request_type = fhpu_type_lut[((iw >> 11) & 0x1f) - 6]; if ((iw >> 29) & 0x1) { vec_store_group2(addr, element, regp, vec_load_unshuffled_operand(regp), _mm_setzero_si128(), request_type); } else { vec_load_group2(addr, element, regp, vec_load_unshuffled_operand(regp), _mm_setzero_si128(), request_type); } } // LQV, LRV, SQV, SRV inline void vec_lqrv_sqrv(uint32_t iw, uint32_t rs) { rs &= 0xfff; const uint32_t addr = rs + (sign_extend_6(iw) << 4); const uint32_t element = (iw >> 7) & 0xf; uint16_t* regp = m_v[(iw >> 16) & 0x1f].s; memcpy(m_vdqm.s, m_vec_helpers.qr_lut[addr & 0xf], sizeof(m_vdqm.s)); rsp_mem_request_type request_type = (iw >> 11 & 0x1) ? RSP_MEM_REQUEST_REST : RSP_MEM_REQUEST_QUAD; if ((iw >> 29) & 0x1) { vec_store_group4(addr, element, regp, vec_load_unshuffled_operand(regp), vec_load_unshuffled_operand(m_vdqm.s), request_type); } else { vec_load_group4(addr, element, regp, vec_load_unshuffled_operand(regp), vec_load_unshuffled_operand(m_vdqm.s), request_type); } }
/** @file * IPRT - Power management. */ /* * Copyright (C) 2008-2010 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * The contents of this file may alternatively be used under the terms * of the Common Development and Distribution License Version 1.0 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the * VirtualBox OSE distribution, in which case the provisions of the * CDDL are applicable instead of those of the GPL. * * You may elect to license modified versions of this file under the * terms and conditions of either the GPL or the CDDL or both. */ #ifndef ___iprt_power_h #define ___iprt_power_h #include <iprt/cdefs.h> #include <iprt/types.h> RT_C_DECLS_BEGIN /** @defgroup grp_rt_power RTPower - Power management * @ingroup grp_rt * @{ */ #ifdef IN_RING0 /** * MP event, see FNRTPOWERNOTIFICATION. */ typedef enum RTPOWEREVENT { /** The system will go into suspend mode. */ RTPOWEREVENT_SUSPEND = 1, /** The system has resumed. */ RTPOWEREVENT_RESUME } RTPOWEREVENT; /** * Notification callback. * * The context this is called in differs a bit from platform to * platform, so be careful while in here. * * @param enmEvent The event. * @param pvUser The user argument. */ typedef DECLCALLBACK(void) FNRTPOWERNOTIFICATION(RTPOWEREVENT enmEvent, void *pvUser); /** Pointer to a FNRTPOWERNOTIFICATION(). */ typedef FNRTPOWERNOTIFICATION *PFNRTPOWERNOTIFICATION; /** * Registers a notification callback for power events. * * @returns IPRT status code. * @retval VINF_SUCCESS on success. * @retval VERR_NO_MEMORY if a registration record cannot be allocated. * @retval VERR_ALREADY_EXISTS if the pfnCallback and pvUser already exist * in the callback list. * * @param pfnCallback The callback. * @param pvUser The user argument to the callback function. */ RTDECL(int) RTPowerNotificationRegister(PFNRTPOWERNOTIFICATION pfnCallback, void *pvUser); /** * This deregisters a notification callback registered via RTPowerNotificationRegister(). * * The pfnCallback and pvUser arguments must be identical to the registration call * of we won't find the right entry. * * @returns IPRT status code. * @retval VINF_SUCCESS on success. * @retval VERR_NOT_FOUND if no matching entry was found. * * @param pfnCallback The callback. * @param pvUser The user argument to the callback function. */ RTDECL(int) RTPowerNotificationDeregister(PFNRTPOWERNOTIFICATION pfnCallback, void *pvUser); /** * This calls all registered power management callback handlers registered via RTPowerNotificationRegister(). * * @returns IPRT status code. * @retval VINF_SUCCESS on success. * * @param enmEvent Power Management event */ RTDECL(int) RTPowerSignalEvent(RTPOWEREVENT enmEvent); #endif /* IN_RING0 */ /** @} */ RT_C_DECLS_END #endif
/* This file contains an example program from The Little Book of Semaphores, available from Green Tea Press, greenteapress.com Copyright 2014 Allen B. Downey License: Creative Commons Attribution-ShareAlike 3.0 */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #define NUM_CHILDREN 2 void perror_exit (char *s) { perror (s); exit (-1); } void *check_malloc(int size) { void *p = malloc (size); if (p == NULL) perror_exit ("malloc failed"); return p; } typedef sem_t Semaphore; Semaphore *make_semaphore (int n) { Semaphore *sem = check_malloc (sizeof(Semaphore)); int ret = sem_init(sem, 0, n); if (ret == -1) perror_exit ("sem_init failed"); return sem; } int sem_signal(Semaphore *sem) { return sem_post(sem); } typedef struct { int counter; int end; int *array; Semaphore *mutex; } Shared; Shared *make_shared (int end) { int i; Shared *shared = check_malloc (sizeof (Shared)); shared->counter = 0; shared->end = end; shared->array = check_malloc (shared->end * sizeof(int)); for (i=0; i<shared->end; i++) { shared->array[i] = 0; } shared->mutex = make_semaphore(1); return shared; } pthread_t make_thread(void *(*entry)(void *), Shared *shared) { int ret; pthread_t thread; ret = pthread_create (&thread, NULL, entry, (void *) shared); if (ret != 0) perror_exit ("pthread_create failed"); return thread; } void join_thread (pthread_t thread) { int ret = pthread_join (thread, NULL); if (ret == -1) perror_exit ("pthread_join failed"); } void child_code (Shared *shared) { printf ("Starting child at counter %d\n", shared->counter); while (1) { sem_wait(shared->mutex); if (shared->counter >= shared->end) { sem_signal(shared->mutex); return; } shared->array[shared->counter]++; shared->counter++; if (shared->counter % 10000 == 0) { printf ("%d\n", shared->counter); } sem_signal(shared->mutex); } } void *entry (void *arg) { Shared *shared = (Shared *) arg; child_code (shared); printf ("Child done.\n"); pthread_exit (NULL); } void check_array (Shared *shared) { int i, errors=0; printf ("Checking...\n"); for (i=0; i<shared->end; i++) { if (shared->array[i] != 1) errors++; } printf ("%d errors.\n", errors); } int main () { int i; pthread_t child[NUM_CHILDREN]; Shared *shared = make_shared (100000000); for (i=0; i<NUM_CHILDREN; i++) { child[i] = make_thread (entry, shared); } for (i=0; i<NUM_CHILDREN; i++) { join_thread (child[i]); } check_array (shared); return 0; }
// array allocator -*- C++ -*- // Copyright (C) 2004-2015 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file ext/array_allocator.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _ARRAY_ALLOCATOR_H #define _ARRAY_ALLOCATOR_H 1 #include <bits/c++config.h> #include <new> #include <bits/functexcept.h> #include <tr1/array> #include <bits/move.h> #if __cplusplus >= 201103L #include <type_traits> #endif // Suppress deprecated warning for this file. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION using std::size_t; using std::ptrdiff_t; /// Base class. template<typename _Tp> class array_allocator_base { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; pointer address(reference __x) const _GLIBCXX_NOEXCEPT { return std::__addressof(__x); } const_pointer address(const_reference __x) const _GLIBCXX_NOEXCEPT { return std::__addressof(__x); } void deallocate(pointer, size_type) { // Does nothing. } size_type max_size() const _GLIBCXX_USE_NOEXCEPT { return size_t(-1) / sizeof(_Tp); } #if __cplusplus >= 201103L template<typename _Up, typename... _Args> void construct(_Up* __p, _Args&&... __args) { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } template<typename _Up> void destroy(_Up* __p) { __p->~_Up(); } #else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 402. wrong new expression in [some_] allocator::construct void construct(pointer __p, const _Tp& __val) { ::new((void *)__p) value_type(__val); } void destroy(pointer __p) { __p->~_Tp(); } #endif } _GLIBCXX_DEPRECATED; /** * @brief An allocator that uses previously allocated memory. * This memory can be externally, globally, or otherwise allocated. * @ingroup allocators */ template<typename _Tp, typename _Array = std::tr1::array<_Tp, 1> > class array_allocator : public array_allocator_base<_Tp> { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; typedef _Array array_type; #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2103. std::allocator propagate_on_container_move_assignment typedef std::true_type propagate_on_container_move_assignment; typedef std::true_type is_always_equal; #endif private: array_type* _M_array; size_type _M_used; public: template<typename _Tp1, typename _Array1 = _Array> struct rebind { typedef array_allocator<_Tp1, _Array1> other _GLIBCXX_DEPRECATED; } _GLIBCXX_DEPRECATED; array_allocator(array_type* __array = 0) _GLIBCXX_USE_NOEXCEPT : _M_array(__array), _M_used(size_type()) { } array_allocator(const array_allocator& __o) _GLIBCXX_USE_NOEXCEPT : _M_array(__o._M_array), _M_used(__o._M_used) { } template<typename _Tp1, typename _Array1> array_allocator(const array_allocator<_Tp1, _Array1>&) _GLIBCXX_USE_NOEXCEPT : _M_array(0), _M_used(size_type()) { } ~array_allocator() _GLIBCXX_USE_NOEXCEPT { } pointer allocate(size_type __n, const void* = 0) { if (_M_array == 0 || _M_used + __n > _M_array->size()) std::__throw_bad_alloc(); pointer __ret = _M_array->begin() + _M_used; _M_used += __n; return __ret; } } _GLIBCXX_DEPRECATED; template<typename _Tp, typename _Array> inline bool operator==(const array_allocator<_Tp, _Array>&, const array_allocator<_Tp, _Array>&) { return true; } template<typename _Tp, typename _Array> inline bool operator!=(const array_allocator<_Tp, _Array>&, const array_allocator<_Tp, _Array>&) { return false; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #pragma GCC diagnostic pop #endif
/* Copyright (C) 1991, 1995, 1996, 1997, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU 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. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <errno.h> #include <sys/socket.h> /* Put the local address of FD into *ADDR and its length in *LEN. */ int __getsockname (fd, addr, len) int fd; __SOCKADDR_ARG addr; socklen_t *len; { __set_errno (ENOSYS); return -1; } weak_alias (__getsockname, getsockname) stub_warning (getsockname) #include <stub-tag.h>