text
stringlengths
4
6.14k
// // NSDictionary+Unicode.h // EMSocialApp // // Created by ryan on 29/11/2016. // Copyright © 2016 Ryan Wang. All rights reserved. // #import <Foundation/Foundation.h> @interface NSDictionary (Unicode) - (NSString*)my_description; @end
// Copyright 2011 The Avalon Project Authors. All rights reserved. // Use of this source code is governed by the Apache License 2.0 // that can be found in the LICENSE file. // // Pretend to be the rudderd: read ctl, send plausible sts #include <errno.h> #include <fcntl.h> #include <math.h> #include <signal.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/select.h> #include <sys/time.h> #include <sys/types.h> #include <syslog.h> #include <time.h> #include <unistd.h> #include "../proto/rudder.h" //static const char* version = "$Id: $"; static const char* argv0; static int verbose = 0; static int debug = 0; static void crash(const char* fmt, ...) { va_list ap; char buf[1000]; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); if (debug) fprintf(stderr, "%s:%s%s%s\n", argv0, buf, (errno) ? ": " : "", (errno) ? strerror(errno):"" ); else syslog(LOG_CRIT, "%s%s%s\n", buf, (errno) ? ": " : "", (errno) ? strerror(errno):"" ); exit(1); va_end(ap); return; } static void fault(int i) { crash("fault"); } static void usage(void) { fprintf(stderr, "usage: [plug /path/to/linebus] %s\n", argv0); exit(1); } static void set_fd(fd_set* s, int* maxfd, FILE* f) { int fd = fileno(f); FD_SET(fd, s); if (*maxfd < fd) *maxfd = fd; } static int64_t now_ms() { struct timeval tv; if (gettimeofday(&tv, NULL) < 0) crash("no working clock"); int64_t ms1 = tv.tv_sec; ms1 *= 1000; int64_t ms2 = tv.tv_usec; ms2 /= 1000; return ms1 + ms2; } static double limit(double v, double min, double max) { if (v < min) return min; if (v > max) return max; return v; } int main(int argc, char* argv[]) { int ch; argv0 = strrchr(argv[0], '/'); if (argv0) ++argv0; else argv0 = argv[0]; while ((ch = getopt(argc, argv, "dhv")) != -1){ switch (ch) { case 'd': ++debug; break; case 'v': ++verbose; break; case 'h': default: usage(); } } argv += optind; argc -= optind; if (argc != 0) usage(); setlinebuf(stdout); if (!debug) openlog(argv0, LOG_PERROR, LOG_DAEMON); if (signal(SIGBUS, fault) == SIG_ERR) crash("signal(SIGBUS)"); if (signal(SIGSEGV, fault) == SIG_ERR) crash("signal(SIGSEGV)"); if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) crash("signal(SIGPIPE)"); fprintf(stderr, "Started.\n"); int64_t last = now_ms(); struct RudderProto target = INIT_RUDDERPROTO; struct RudderProto actual = { last, 0, 0, 0 }; while (!feof(stdin)) { struct timespec timeout = { 1, 0 }; // wake up at least 1/second fd_set rfds; fd_set wfds; int max_fd = -1; FD_ZERO(&rfds); FD_ZERO(&wfds); set_fd(&rfds, &max_fd, stdin); sigset_t empty_mask; sigemptyset(&empty_mask); int r = pselect(max_fd + 1, &rfds, &wfds, NULL, &timeout, &empty_mask); if (r == -1 && errno != EINTR) crash("pselect"); if (debug>2) fprintf(stderr, "Woke up %d\n", r); if (FD_ISSET(fileno(stdin), &rfds)) { char line[1024]; if (fgets(line, sizeof line, stdin)) { int nn = 0; struct RudderProto newtarget = INIT_RUDDERPROTO; int n = sscanf(line, IFMT_RUDDERPROTO_CTL(&newtarget, &nn)); if (n == 4) memmove(&target, &newtarget, sizeof target); } // fprintf(stderr, "got:%s\n", line); if (ferror(stdin)) clearerr(stdin); } target.rudder_l_deg = limit(target.rudder_l_deg, -90.0, 90.0); target.rudder_r_deg = limit(target.rudder_r_deg, -90.0, 90.0); int changed = 0; int64_t now = now_ms(); // rudders move 10 degrees / 1000 milliseconds double delta_rudder_deg = (now - actual.timestamp_ms) * (10.0/1000.0); if (target.rudder_l_deg < actual.rudder_l_deg) { ++changed; actual.rudder_l_deg = limit(actual.rudder_l_deg - delta_rudder_deg, target.rudder_l_deg, actual.rudder_l_deg); } if (target.rudder_l_deg > actual.rudder_l_deg) { ++changed; actual.rudder_l_deg = limit(actual.rudder_l_deg + delta_rudder_deg, actual.rudder_l_deg, target.rudder_l_deg); } if (target.rudder_r_deg < actual.rudder_r_deg) { ++changed; actual.rudder_r_deg = limit(actual.rudder_r_deg - delta_rudder_deg, target.rudder_r_deg, actual.rudder_r_deg); } if (target.rudder_r_deg > actual.rudder_r_deg) { ++changed; actual.rudder_r_deg = limit(actual.rudder_r_deg + delta_rudder_deg, actual.rudder_r_deg, target.rudder_r_deg); } if (!isnan(target.sail_deg)) { double delta_sail_deg = (now - actual.timestamp_ms) * (18.0/1000.0); double sail_diff_deg = target.sail_deg - actual.sail_deg; while (sail_diff_deg < -180.0) sail_diff_deg += 360.0; while (sail_diff_deg > 180.0) sail_diff_deg -= 360.0; if (sail_diff_deg < 0) { ++changed; sail_diff_deg = limit(-delta_sail_deg, sail_diff_deg, 0); } if (sail_diff_deg > 0) { ++changed; sail_diff_deg = limit(delta_sail_deg, 0, sail_diff_deg); } actual.sail_deg += sail_diff_deg; } actual.timestamp_ms = now; if (now > last + 1000) ++changed; if (now < last + 100) changed = 0; if (changed) { last = now; printf(OFMT_RUDDERPROTO_STS(actual)); } } // main loop crash("exit loop"); return 0; }
/************************************************************************/ /* */ /* Centre for Speech Technology Research */ /* University of Edinburgh, UK */ /* Copyright (c) 1996,1997 */ /* All Rights Reserved. */ /* */ /* Permission is hereby granted, free of charge, to use and distribute */ /* this software and its documentation without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of this work, and to */ /* permit persons to whom this work is furnished to do so, subject to */ /* the following conditions: */ /* 1. The code must retain the above copyright notice, this list of */ /* conditions and the following disclaimer. */ /* 2. Any modifications must be clearly marked as such. */ /* 3. Original authors' names are not deleted. */ /* 4. The authors' names are not used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ /* THIS SOFTWARE. */ /* */ /*************************************************************************/ /* */ /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ /* Date: Tue Sep4th 1997 */ /* -------------------------------------------------------------------- */ /* Wrapper around iostream includes to avoid aome win32 nasties. */ /* */ /*************************************************************************/ #if !defined(__EST_IOSTREAM_WIN32_H__) # define __EST_IOSTREAM_WIN32_H__ 1 /* This gets incuded from C */ #ifdef __cplusplus #include <iostream> using namespace std; #undef read #undef write #define snprintf _snprintf #endif #endif
/* * %CopyrightBegin% * * Copyright Ericsson AB 1996-2016. 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. * * %CopyrightEnd% */ #ifndef __MODULE_H__ #define __MODULE_H__ #include "index.h" #ifdef HIPE #include "hipe_module.h" #endif struct erl_module_instance { BeamCodeHeader* code_hdr; int code_length; /* Length of loaded code in bytes. */ unsigned catches; struct erl_module_nif* nif; int num_breakpoints; int num_traced_exports; #ifdef HIPE HipeModule *hipe_code; #endif }; typedef struct erl_module { IndexSlot slot; /* Must be located at top of struct! */ int module; /* Atom index for module (not tagged). */ int seen; /* Used by finish_loading() */ struct erl_module_instance curr; struct erl_module_instance old; /* active protected by "old_code" rwlock */ struct erl_module_instance* on_load; } Module; void erts_module_instance_init(struct erl_module_instance* modi); Module* erts_get_module(Eterm mod, ErtsCodeIndex code_ix); Module* erts_put_module(Eterm mod); void init_module_table(void); void module_start_staging(void); void module_end_staging(int commit); void module_info(fmtfn_t, void *); Module *module_code(int, ErtsCodeIndex); int module_code_size(ErtsCodeIndex); int module_table_sz(void); ERTS_GLB_INLINE void erts_rwlock_old_code(ErtsCodeIndex); ERTS_GLB_INLINE void erts_rwunlock_old_code(ErtsCodeIndex); ERTS_GLB_INLINE void erts_rlock_old_code(ErtsCodeIndex); ERTS_GLB_INLINE void erts_runlock_old_code(ErtsCodeIndex); #ifdef ERTS_ENABLE_LOCK_CHECK int erts_is_old_code_rlocked(ErtsCodeIndex); #endif #if ERTS_GLB_INLINE_INCL_FUNC_DEF extern erts_rwmtx_t the_old_code_rwlocks[ERTS_NUM_CODE_IX]; ERTS_GLB_INLINE void erts_rwlock_old_code(ErtsCodeIndex code_ix) { erts_rwmtx_rwlock(&the_old_code_rwlocks[code_ix]); } ERTS_GLB_INLINE void erts_rwunlock_old_code(ErtsCodeIndex code_ix) { erts_rwmtx_rwunlock(&the_old_code_rwlocks[code_ix]); } ERTS_GLB_INLINE void erts_rlock_old_code(ErtsCodeIndex code_ix) { erts_rwmtx_rlock(&the_old_code_rwlocks[code_ix]); } ERTS_GLB_INLINE void erts_runlock_old_code(ErtsCodeIndex code_ix) { erts_rwmtx_runlock(&the_old_code_rwlocks[code_ix]); } #ifdef ERTS_ENABLE_LOCK_CHECK ERTS_GLB_INLINE int erts_is_old_code_rlocked(ErtsCodeIndex code_ix) { return erts_lc_rwmtx_is_rlocked(&the_old_code_rwlocks[code_ix]); } #endif #endif /* ERTS_GLB_INLINE_INCL_FUNC_DEF */ #endif /* !__MODULE_H__ */
/*! @file preemphasis.h * @brief Number of time domain zero crossings of the signal. * @author Markovtsev Vadim <v.markovtsev@samsung.com> * @version 1.0 * * @section Notes * This code partially conforms to <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml">Google C++ Style Guide</a>. * * @section Copyright * Copyright © 2013 Samsung R&D Institute Russia * * @section License * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #ifndef SRC_TRANSFORMS_PREEMPHASIS_H_ #define SRC_TRANSFORMS_PREEMPHASIS_H_ #include "src/transforms/common.h" namespace sound_feature_extraction { namespace transforms { class Preemphasis : public OmpUniformFormatTransform<formats::ArrayFormatF> { public: Preemphasis(); TRANSFORM_INTRO("Preemphasis", "Filter the signal with a first-order " "high-pass filter y[n] = 1 - k * x[n - 1].", Preemphasis) TP(value, float, kDefaultValue, "The filter coefficient from range (0..1]. " "The higher, the more emphasis occurs.") protected: static constexpr float kDefaultValue = 0.9f; virtual void Do(const float* in, float* out) const noexcept override; static void Do(bool simd, const float* input, size_t length, float k, float* output) noexcept; }; } // namespace transforms } // namespace sound_feature_extraction #endif // SRC_TRANSFORMS_PREEMPHASIS_H_
/* Copyright (C) 2012-2014 Soomla Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef __CCLevelUpBridgeBinderIos_H_ #define __CCLevelUpBridgeBinderIos_H_ namespace soomla { class CCLevelUpBridgeBinderIos { public: static void bind(); }; }; #endif // __CCLevelUpBridgeBinderIos_H_
/* * ModSecurity, http://www.modsecurity.org/ * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) * * 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 * * If any of the files related to licensing are missing or if you have any * other questions related to licensing please contact Trustwave Holdings, Inc. * directly using the email address security@modsecurity.org. * */ #include <iostream> #include <string> #include <vector> #include <list> #include <utility> #ifndef SRC_VARIABLES_REQBODY_PROCESSOR_H_ #define SRC_VARIABLES_REQBODY_PROCESSOR_H_ #include "src/variables/variable.h" namespace modsecurity { class Transaction; namespace variables { DEFINE_VARIABLE(ReqbodyProcessor, REQBODY_PROCESSOR, m_variableReqbodyProcessor) } // namespace variables } // namespace modsecurity #endif // SRC_VARIABLES_REQBODY_PROCESSOR_H_
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); vcyou 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 THIRD_PARTY_TENSORFLOW_CORE_KERNELS_HEXAGON_I_GRAPH_TRANSFER_OPS_DEFINITIONS_H_ #define THIRD_PARTY_TENSORFLOW_CORE_KERNELS_HEXAGON_I_GRAPH_TRANSFER_OPS_DEFINITIONS_H_ #include "tensorflow/core/framework/graph_transfer_info.pb.h" #include "tensorflow/core/framework/types.h" #include "tensorflow/core/platform/macros.h" namespace tensorflow { // IGraphTransferOpsDefinitions is an interface class which provides interfaces // about ops supported by SOC. // TODO(satok): Provide ways to transfer graph definitions into SOC class IGraphTransferOpsDefinitions { public: // op id which is not supported by SOC static constexpr int INVALID_OP_ID = -1; // Custom op name for input node static constexpr const char* const INPUT_OP_NAME = "INPUT"; // Custom op name for output node static constexpr const char* const OUTPUT_OP_NAME = "OUTPUT"; // Custom op name for flatten node static constexpr const char* const FLATTEN_OP_NAME = "FLATTEN"; IGraphTransferOpsDefinitions() = default; virtual ~IGraphTransferOpsDefinitions() = default; // Return total ops count supported by SOC virtual int GetTotalOpsCount() const = 0; // Return op id for input node // TODO(satok): Return vector isntead of integer virtual int GetInputNodeOpId() const = 0; // Return op id for output node // TODO(satok): Return vector isntead of integer virtual int GetOutputNodeOpId() const = 0; // Return op id for given string op name virtual int GetOpIdFor(const string& op_name) const = 0; // Return destination of transfer virtual GraphTransferInfo::Destination GetTransferDestination() const = 0; private: TF_DISALLOW_COPY_AND_ASSIGN(IGraphTransferOpsDefinitions); }; } // namespace tensorflow #endif // THIRD_PARTY_TENSORFLOW_CORE_KERNELS_HEXAGON_I_GRAPH_TRANSFER_OPS_DEFINITIONS_H
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=4 sw=4 et tw=99: * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef jsion_codegen_arm_h__ #define jsion_codegen_arm_h__ #include "Assembler-arm.h" #include "ion/shared/CodeGenerator-shared.h" namespace js { namespace ion { class OutOfLineBailout; class CodeGeneratorARM : public CodeGeneratorShared { friend class MoveResolverARM; CodeGeneratorARM *thisFromCtor() {return this;} protected: // Label for the common return path. HeapLabel *returnLabel_; HeapLabel *deoptLabel_; // ugh. this is not going to be pretty to move over. // stack slotted variables are not useful on arm. // it looks like this will need to return one of two types. inline Operand ToOperand(const LAllocation &a) { if (a.isGeneralReg()) return Operand(a.toGeneralReg()->reg()); if (a.isFloatReg()) return Operand(a.toFloatReg()->reg()); return Operand(StackPointer, ToStackOffset(&a)); } inline Operand ToOperand(const LAllocation *a) { return ToOperand(*a); } inline Operand ToOperand(const LDefinition *def) { return ToOperand(def->output()); } MoveResolver::MoveOperand toMoveOperand(const LAllocation *a) const; bool bailoutIf(Assembler::Condition condition, LSnapshot *snapshot); bool bailoutFrom(Label *label, LSnapshot *snapshot); bool bailout(LSnapshot *snapshot); protected: bool generatePrologue(); bool generateEpilogue(); bool generateOutOfLineCode(); void emitDoubleToInt32(const FloatRegister &src, const Register &dest, Label *fail, bool negativeZeroCheck = true); void emitRoundDouble(const FloatRegister &src, const Register &dest, Label *fail); // Emits a conditional set. void emitSet(Assembler::Condition cond, const Register &dest); // Emits a branch that directs control flow to the true block if |cond| is // true, and the false block if |cond| is false. void emitBranch(Assembler::Condition cond, MBasicBlock *ifTrue, MBasicBlock *ifFalse); public: // Instruction visitors. virtual bool visitMinMaxD(LMinMaxD *ins); virtual bool visitAbsD(LAbsD *ins); virtual bool visitSqrtD(LSqrtD *ins); virtual bool visitAddI(LAddI *ins); virtual bool visitSubI(LSubI *ins); virtual bool visitBitNotI(LBitNotI *ins); virtual bool visitBitOpI(LBitOpI *ins); virtual bool visitMulI(LMulI *ins); virtual bool visitDivI(LDivI *ins); virtual bool visitModI(LModI *ins); virtual bool visitModPowTwoI(LModPowTwoI *ins); virtual bool visitModMaskI(LModMaskI *ins); virtual bool visitPowHalfD(LPowHalfD *ins); virtual bool visitMoveGroup(LMoveGroup *group); virtual bool visitShiftI(LShiftI *ins); virtual bool visitUrshD(LUrshD *ins); virtual bool visitTestIAndBranch(LTestIAndBranch *test); virtual bool visitCompare(LCompare *comp); virtual bool visitCompareAndBranch(LCompareAndBranch *comp); virtual bool visitTestDAndBranch(LTestDAndBranch *test); virtual bool visitCompareD(LCompareD *comp); virtual bool visitCompareDAndBranch(LCompareDAndBranch *comp); virtual bool visitCompareB(LCompareB *lir); virtual bool visitCompareBAndBranch(LCompareBAndBranch *lir); virtual bool visitNotI(LNotI *ins); virtual bool visitNotD(LNotD *ins); virtual bool visitMathD(LMathD *math); virtual bool visitFloor(LFloor *lir); virtual bool visitRound(LRound *lir); virtual bool visitTableSwitch(LTableSwitch *ins); virtual bool visitTruncateDToInt32(LTruncateDToInt32 *ins); // Out of line visitors. bool visitOutOfLineBailout(OutOfLineBailout *ool); protected: ValueOperand ToValue(LInstruction *ins, size_t pos); ValueOperand ToOutValue(LInstruction *ins); ValueOperand ToTempValue(LInstruction *ins, size_t pos); // Functions for LTestVAndBranch. Register splitTagForTest(const ValueOperand &value); void storeElementTyped(const LAllocation *value, MIRType valueType, MIRType elementType, const Register &elements, const LAllocation *index); protected: void linkAbsoluteLabels(); public: CodeGeneratorARM(MIRGenerator *gen, LIRGraph &graph); public: bool visitBox(LBox *box); bool visitBoxDouble(LBoxDouble *box); bool visitUnbox(LUnbox *unbox); bool visitValue(LValue *value); bool visitOsrValue(LOsrValue *value); bool visitDouble(LDouble *ins); bool visitLoadSlotV(LLoadSlotV *load); bool visitLoadSlotT(LLoadSlotT *load); bool visitStoreSlotT(LStoreSlotT *load); bool visitLoadElementT(LLoadElementT *load); bool visitGuardShape(LGuardShape *guard); bool visitGuardClass(LGuardClass *guard); bool visitImplicitThis(LImplicitThis *lir); bool visitRecompileCheck(LRecompileCheck *lir); bool visitInterruptCheck(LInterruptCheck *lir); bool generateInvalidateEpilogue(); }; typedef CodeGeneratorARM CodeGeneratorSpecific; // An out-of-line bailout thunk. class OutOfLineBailout : public OutOfLineCodeBase<CodeGeneratorARM> { LSnapshot *snapshot_; uint32 frameSize_; public: OutOfLineBailout(LSnapshot *snapshot, uint32 frameSize) : snapshot_(snapshot), frameSize_(frameSize) { } bool accept(CodeGeneratorARM *codegen); LSnapshot *snapshot() const { return snapshot_; } }; } // ion } // js #endif // jsion_codegen_arm_h__
/* * Copyright 2019 Google * * 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 FIRESTORE_CORE_SRC_CORE_KEY_FIELD_FILTER_H_ #define FIRESTORE_CORE_SRC_CORE_KEY_FIELD_FILTER_H_ #include <string> #include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h" #include "Firestore/core/src/core/field_filter.h" #include "Firestore/core/src/nanopb/message.h" namespace firebase { namespace firestore { namespace core { /** * A Filter that matches on key fields (i.e. '__name__'). */ class KeyFieldFilter : public FieldFilter { public: /** Creates a new document key filter. Takes ownership of `value`. */ KeyFieldFilter(const model::FieldPath& field, core::Filter::Operator op, nanopb::SharedMessage<google_firestore_v1_Value> value); private: class Rep; }; } // namespace core } // namespace firestore } // namespace firebase #endif // FIRESTORE_CORE_SRC_CORE_KEY_FIELD_FILTER_H_
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/iotanalytics/IoTAnalytics_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace IoTAnalytics { namespace Model { class AWS_IOTANALYTICS_API StartPipelineReprocessingResult { public: StartPipelineReprocessingResult(); StartPipelineReprocessingResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); StartPipelineReprocessingResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>The ID of the pipeline reprocessing activity that was started.</p> */ inline const Aws::String& GetReprocessingId() const{ return m_reprocessingId; } /** * <p>The ID of the pipeline reprocessing activity that was started.</p> */ inline void SetReprocessingId(const Aws::String& value) { m_reprocessingId = value; } /** * <p>The ID of the pipeline reprocessing activity that was started.</p> */ inline void SetReprocessingId(Aws::String&& value) { m_reprocessingId = std::move(value); } /** * <p>The ID of the pipeline reprocessing activity that was started.</p> */ inline void SetReprocessingId(const char* value) { m_reprocessingId.assign(value); } /** * <p>The ID of the pipeline reprocessing activity that was started.</p> */ inline StartPipelineReprocessingResult& WithReprocessingId(const Aws::String& value) { SetReprocessingId(value); return *this;} /** * <p>The ID of the pipeline reprocessing activity that was started.</p> */ inline StartPipelineReprocessingResult& WithReprocessingId(Aws::String&& value) { SetReprocessingId(std::move(value)); return *this;} /** * <p>The ID of the pipeline reprocessing activity that was started.</p> */ inline StartPipelineReprocessingResult& WithReprocessingId(const char* value) { SetReprocessingId(value); return *this;} private: Aws::String m_reprocessingId; }; } // namespace Model } // namespace IoTAnalytics } // namespace Aws
/* This file is a part of libcds - Concurrent Data Structures library (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 Source code repo: http://github.com/khizmax/libcds/ Download: http://sourceforge.net/projects/libcds/files/ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CDSLIB_LOCK_SPINLOCK_H #define CDSLIB_LOCK_SPINLOCK_H #if CDS_COMPILER == CDS_COMPILER_MSVC # pragma message("cds/lock/spinlock.h is deprecated, use cds/sync/spinlock.h instead") #else # warning "cds/lock/spinlock.h is deprecated, use cds/sync/spinlock.h instead" #endif #include <cds/sync/spinlock.h> //@cond namespace cds { /// Synchronization primitives (deprecated namespace, use \p cds::sync namespace instead) namespace lock { /// Alias for \p cds::sync::spin_lock for backward compatibility template <typename Backoff> using Spinlock = cds::sync::spin_lock< Backoff >; /// Spin-lock implementation default for the current platform typedef cds::sync::spin_lock< backoff::LockDefault> Spin; /// Alias for \p cds::sync::reentrant_spin_lock for backward compatibility template <typename Integral, class Backoff> using ReentrantSpinT = cds::sync::reentrant_spin_lock< Integral, Backoff >; /// Recursive 32bit spin-lock typedef cds::sync::reentrant_spin32 ReentrantSpin32; /// Recursive 64bit spin-lock typedef cds::sync::reentrant_spin64 ReentrantSpin64; /// Default recursive spin-lock type typedef ReentrantSpin32 ReentrantSpin; } // namespace lock /// Standard (best for the current platform) spin-lock implementation typedef lock::Spin SpinLock; /// Standard (best for the current platform) recursive spin-lock implementation typedef lock::ReentrantSpin RecursiveSpinLock; /// 32bit recursive spin-lock shortcut typedef lock::ReentrantSpin32 RecursiveSpinLock32; /// 64bit recursive spin-lock shortcut typedef lock::ReentrantSpin64 RecursiveSpinLock64; } // namespace cds //@endcond #endif // #ifndef CDSLIB_LOCK_SPINLOCK_H
#pragma once #include <pcapplusplus/DpdkDevice.h> #include <pcapplusplus/DpdkDeviceList.h> class EchoThread : public pcpp::DpdkWorkerThread { private: pcpp::DpdkDevice* m_Device; bool m_Stop; uint32_t m_CoreId; uint32_t m_queue; public: // c'tor EchoThread(pcpp::DpdkDevice* device, uint32_t queue); // d'tor (does nothing) ~EchoThread() { } // implement abstract method // start running the worker thread bool run(uint32_t coreId); // ask the worker thread to stop void stop(); // get worker thread core ID uint32_t getCoreId(); };
/* Copyright 2018 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_TF2TENSORRT_UTILS_TRT_RESOURCES_H_ #define TENSORFLOW_COMPILER_TF2TENSORRT_UTILS_TRT_RESOURCES_H_ #include <list> #include <sstream> #include <string> #include <thread> #include <unordered_map> #include <vector> #include "tensorflow/compiler/tf2tensorrt/convert/utils.h" #include "tensorflow/compiler/tf2tensorrt/utils/trt_allocator.h" #include "tensorflow/compiler/tf2tensorrt/utils/trt_int8_calibrator.h" #include "tensorflow/compiler/tf2tensorrt/utils/trt_logger.h" #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/resource_mgr.h" #if GOOGLE_CUDA #if GOOGLE_TENSORRT #include "tensorrt/include/NvInfer.h" namespace tensorflow { namespace tensorrt { class SerializableResourceBase : public tensorflow::ResourceBase { public: virtual Status SerializeToString(string* serialized) = 0; }; class TRTCalibrationResource : public SerializableResourceBase { public: ~TRTCalibrationResource() override; string DebugString() const override; Status SerializeToString(string* serialized) override; // Lookup table for temporary staging areas of input tensors for calibration. std::unordered_map<string, std::pair<void*, size_t>> device_buffers_; // Temporary staging areas for calibration inputs. std::vector<PersistentTensor> device_tensors_; std::unique_ptr<TRTInt8Calibrator> calibrator_; TrtUniquePtrType<nvinfer1::IBuilder> builder_; TrtUniquePtrType<nvinfer1::ICudaEngine> engine_; std::unique_ptr<TRTBaseAllocator> allocator_; tensorflow::tensorrt::Logger logger_; // TODO(sami): Use threadpool threads! std::unique_ptr<std::thread> thr_; }; } // namespace tensorrt } // namespace tensorflow #endif // GOOGLE_TENSORRT #endif // GOOGLE_CUDA #endif // TENSORFLOW_COMPILER_TF2TENSORRT_UTILS_TRT_RESOURCES_H_
/****************************************************************************** * Copyright 2018 The Apollo 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. *****************************************************************************/ /** * @file **/ #pragma once #include <string> #include <unordered_map> #include <vector> #include "modules/planning/proto/planning_config.pb.h" #include "modules/planning/scenarios/stage.h" #include "modules/planning/scenarios/stop_sign/unprotected/stop_sign_unprotected_scenario.h" namespace apollo { namespace planning { namespace scenario { namespace stop_sign { struct StopSignUnprotectedContext; class StopSignUnprotectedStagePreStop : public Stage { public: explicit StopSignUnprotectedStagePreStop( const ScenarioConfig::StageConfig& config) : Stage(config) {} private: Stage::StageStatus Process(const common::TrajectoryPoint& planning_init_point, Frame* frame) override; StopSignUnprotectedContext* GetContext() { return GetContextAs<StopSignUnprotectedContext>(); } int AddWatchVehicle(const Obstacle& obstacle, std::unordered_map<std::string, std::vector<std::string>>* watch_vehicles); bool CheckADCStop(const double adc_front_edge_s, const double stop_line_s); private: Stage::StageStatus FinishStage(); private: ScenarioStopSignUnprotectedConfig scenario_config_; }; } // namespace stop_sign } // namespace scenario } // namespace planning } // namespace apollo
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include "nffs_test_utils.h" TEST_CASE_SELF(nffs_test_read) { struct fs_file *file; uint8_t buf[16]; uint32_t bytes_read; int rc; rc = nffs_format(nffs_current_area_descs); TEST_ASSERT(rc == 0); nffs_test_util_create_file("/myfile.txt", "1234567890", 10); rc = fs_open("/myfile.txt", FS_ACCESS_READ, &file); TEST_ASSERT(rc == 0); nffs_test_util_assert_file_len(file, 10); TEST_ASSERT(fs_getpos(file) == 0); rc = fs_read(file, 4, buf, &bytes_read); TEST_ASSERT(rc == 0); TEST_ASSERT(bytes_read == 4); TEST_ASSERT(memcmp(buf, "1234", 4) == 0); TEST_ASSERT(fs_getpos(file) == 4); rc = fs_read(file, sizeof buf - 4, buf + 4, &bytes_read); TEST_ASSERT(rc == 0); TEST_ASSERT(bytes_read == 6); TEST_ASSERT(memcmp(buf, "1234567890", 10) == 0); TEST_ASSERT(fs_getpos(file) == 10); rc = fs_close(file); TEST_ASSERT(rc == 0); }
#pragma once //¶¨ÒåÒ»×éSOUIÄÚ²¿Ê¹ÓõÄLOGÊä³öºê£¬"soui"¶¨ÒåLOG ID£¬"soui-lib"ÓÃÓÚ¶¨ÒålogµÄfilter. //Óû§ÐèҪʹÓÃLOG¿ÉÒÔ·ÂÕÕÏÂÃæµÄÐÎʽ¶¨Ò壬²»½¨ÒéÔÚAPPÖÐÖ±½ÓʹÓÃÏÂÃæµÄºê¡£ #define SLOG_TRACE( log) LOG_TRACE("soui", "soui-lib", log) #define SLOG_DEBUG( log) LOG_DEBUG("soui", "soui-lib", log) #define SLOG_INFO ( log) LOG_INFO ("soui", "soui-lib", log) #define SLOG_WARN ( log) LOG_WARN ("soui", "soui-lib", log) #define SLOG_ERROR( log) LOG_ERROR("soui", "soui-lib", log) #define SLOG_ALARM( log) LOG_ALARM("soui", "soui-lib", log) #define SLOG_FATAL( log) LOG_FATAL("soui", "soui-lib", log) #define SLOGFMTT( fmt, ...) LOGFMT_TRACE("soui", "soui-lib", fmt, ##__VA_ARGS__) #define SLOGFMTD( fmt, ...) LOGFMT_DEBUG("soui", "soui-lib", fmt, ##__VA_ARGS__) #define SLOGFMTI( fmt, ...) LOGFMT_INFO("soui", "soui-lib", fmt, ##__VA_ARGS__) #define SLOGFMTW( fmt, ...) LOGFMT_WARN("soui", "soui-lib", fmt, ##__VA_ARGS__) #define SLOGFMTE( fmt, ...) LOGFMT_ERROR("soui", "soui-lib", fmt, ##__VA_ARGS__) #define SLOGFMTA( fmt, ...) LOGFMT_ALARM("soui", "soui-lib", fmt, ##__VA_ARGS__) #define SLOGFMTF( fmt, ...) LOGFMT_FATAL("soui", "soui-lib", fmt, ##__VA_ARGS__)
// __BEGIN_LICENSE__ // Copyright (c) 2009-2013, United States Government as represented by the // Administrator of the National Aeronautics and Space Administration. All // rights reserved. // // The NGT platform is 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. // __END_LICENSE__ /// \file CsmModel.h /// /// Wrapper for Community Sensor Model implementations. /// /// #ifndef __STEREO_CAMERA_CSM_MODEL_H__ #define __STEREO_CAMERA_CSM_MODEL_H__ #include <vw/Camera/CameraModel.h> #include <asp/Core/StereoSettings.h> #include <vw/Cartography/Datum.h> #include <boost/shared_ptr.hpp> namespace csm { class RasterGM; // Forward declaration } namespace asp { /// Class to load any cameras described by the Community Sensor Model (CSM) class CsmModel : public vw::camera::CameraModel { public: //------------------------------------------------------------------ // Constructors / Destructors //------------------------------------------------------------------ CsmModel(); CsmModel(std::string const& isd_path); ///< Construct from ISD file virtual ~CsmModel(); virtual std::string type() const { return "CSM"; } /// Load the camera model from an ISD file or model state. void load_model(std::string const& isd_path); /// Return the size of the associated image. vw::Vector2 get_image_size() const; virtual vw::Vector2 point_to_pixel (vw::Vector3 const& point) const; virtual vw::Vector3 pixel_to_vector(vw::Vector2 const& pix) const; virtual vw::Vector3 camera_center(vw::Vector2 const& pix) const; virtual vw::Quaternion<double> camera_pose(vw::Vector2 const& pix) const { vw_throw( vw::NoImplErr() << "CsmModel: Cannot retrieve camera_pose!" ); return vw::Quaternion<double>(); } /// Return true if the path has an extension compatible with CsmModel. static bool file_has_isd_extension(std::string const& path); /// Return the path to the folder where we will look for CSM plugin DLLs. static std::string get_csm_plugin_folder(); /// Get a list of all of the CSM plugin DLLs in the CSM plugin folder. static size_t find_csm_plugins(std::vector<std::string> &plugins); /// Print the CSM models that have been loaded into the main CSM plugin. static void print_available_models(); /// Get the semi-axes of the datum. vw::Vector3 target_radii() const; // Apply a transform to the model and save the transformed state as a JSON file. void save_transformed_json_state(std::string const& json_state_file, vw::Matrix4x4 const& transform) const; vw::Vector3 sun_position() const { return m_sun_position; } // For bundle adjustment need a higher precision as CERES needs to do accurate // numerical differences. void setDesiredPrecision(double desired_precision) { m_desired_precision = desired_precision; } private: // Read the ellipsoid (datum) axes from the isd json file // (does not work for reading it from a json state file). void read_ellipsoid_from_isd(std::string const& isd_path); /// Load the camera model from an ISD file. void load_model_from_isd(std::string const& isd_path); /// Load the camera model from a model state written to disk. /// A model state is obtained from an ISD model by pre-processing /// and combining its data in a form ready to be used. void load_model_from_state(std::string const& state_path); // TODO: Is it always going to be this type (RasterGM)? boost::shared_ptr<csm::RasterGM> m_csm_model; /// Find and load any available CSM plugin libraries from disk. /// - This does nothing after the first time it finds any plugins. void initialize_plugins(); /// Throw an exception if we have not loaded the model yet. void throw_if_not_init() const; // These are read from the json camera file double m_semi_major_axis, m_semi_minor_axis; vw::Vector3 m_sun_position; double m_desired_precision; }; // End class CsmModel } // namespace asp #endif//__STEREO_CAMERA_CSM_MODEL_H__
#include "genlib.h" #include "genopt.h" #include "genobj.h" #include "genheader.h" #include "genprim.h" #include "../reach/paint.h" #include "../type/assemble.h" #include "../../libponyrt/mem/pool.h" #include <string.h> #ifdef PLATFORM_IS_POSIX_BASED # include <unistd.h> #endif static bool reachable_methods(compile_t* c, ast_t* ast) { ast_t* id = ast_child(ast); ast_t* type = type_builtin(c->opt, ast, ast_name(id)); ast_t* def = (ast_t*)ast_data(type); ast_t* members = ast_childidx(def, 4); ast_t* member = ast_child(members); while(member != NULL) { switch(ast_id(member)) { case TK_NEW: case TK_BE: case TK_FUN: { AST_GET_CHILDREN(member, cap, m_id, typeparams); // Mark all non-polymorphic methods as reachable. if(ast_id(typeparams) == TK_NONE) reach(c->reach, type, ast_name(m_id), NULL, c->opt); break; } default: {} } member = ast_sibling(member); } ast_free_unattached(type); return true; } static bool reachable_actors(compile_t* c, ast_t* program) { errors_t* errors = c->opt->check.errors; if(c->opt->verbosity >= VERBOSITY_INFO) fprintf(stderr, " Library reachability\n"); // Look for C-API actors in every package. bool found = false; ast_t* package = ast_child(program); while(package != NULL) { ast_t* module = ast_child(package); while(module != NULL) { ast_t* entity = ast_child(module); while(entity != NULL) { if(ast_id(entity) == TK_ACTOR) { ast_t* c_api = ast_childidx(entity, 5); if(ast_id(c_api) == TK_AT) { // We have an actor marked as C-API. if(!reachable_methods(c, entity)) return false; found = true; } } entity = ast_sibling(entity); } module = ast_sibling(module); } package = ast_sibling(package); } reach_done(c->reach, c->opt); if(!found) { errorf(errors, NULL, "no C-API actors found in package '%s'", c->filename); return false; } if(c->opt->verbosity >= VERBOSITY_INFO) fprintf(stderr, " Selector painting\n"); paint(&c->reach->types); return true; } static bool link_lib(compile_t* c, const char* file_o) { errors_t* errors = c->opt->check.errors; #if defined(PLATFORM_IS_POSIX_BASED) const char* file_lib = suffix_filename(c, c->opt->output, "lib", c->filename, ".a"); if(c->opt->verbosity >= VERBOSITY_MINIMAL) fprintf(stderr, "Archiving %s\n", file_lib); size_t len = 32 + strlen(file_lib) + strlen(file_o); char* cmd = (char*)ponyint_pool_alloc_size(len); #if defined(PLATFORM_IS_MACOSX) snprintf(cmd, len, "/usr/bin/ar -rcs %s %s", file_lib, file_o); #else snprintf(cmd, len, "ar -rcs %s %s", file_lib, file_o); #endif if(c->opt->verbosity >= VERBOSITY_TOOL_INFO) fprintf(stderr, "%s\n", cmd); if(system(cmd) != 0) { errorf(errors, NULL, "unable to link: %s", cmd); ponyint_pool_free_size(len, cmd); return false; } ponyint_pool_free_size(len, cmd); #elif defined(PLATFORM_IS_WINDOWS) const char* file_lib = suffix_filename(c, c->opt->output, "", c->filename, ".lib"); if(c->opt->verbosity >= VERBOSITY_MINIMAL) fprintf(stderr, "Archiving %s\n", file_lib); vcvars_t vcvars; if(!vcvars_get(c, &vcvars, errors)) { errorf(errors, NULL, "unable to link: no vcvars"); return false; } size_t len = strlen(vcvars.ar) + strlen(file_lib) + strlen(file_o) + 64; char* cmd = (char*)ponyint_pool_alloc_size(len); snprintf(cmd, len, "cmd /C \"\"%s\" /NOLOGO /OUT:%s %s\"", vcvars.ar, file_lib, file_o); if(c->opt->verbosity >= VERBOSITY_TOOL_INFO) fprintf(stderr, "%s\n", cmd); if(system(cmd) == -1) { errorf(errors, NULL, "unable to link: %s", cmd); ponyint_pool_free_size(len, cmd); return false; } ponyint_pool_free_size(len, cmd); #endif return true; } bool genlib(compile_t* c, ast_t* program) { if(!reachable_actors(c, program) || !gentypes(c) || !genheader(c) ) return false; if(!genopt(c, true)) return false; if(c->opt->runtimebc) { if(!codegen_merge_runtime_bitcode(c)) return false; // Rerun the optimiser without the Pony-specific optimisation passes. // Inlining runtime functions can screw up these passes so we can't // run the optimiser only once after merging. if(!genopt(c, false)) return false; } const char* file_o = genobj(c); if(file_o == NULL) return false; if(c->opt->limit < PASS_ALL) return true; if(!link_lib(c, file_o)) return false; #ifdef PLATFORM_IS_WINDOWS _unlink(file_o); #else unlink(file_o); #endif return true; }
/* $NetBSD: fpgetmask.c,v 1.2 2002/01/13 21:45:50 thorpej Exp $ */ /* * Written by J.T. Conklin, Apr 10, 1995 * Public domain. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD: soc2013/dpl/head/lib/libc/sparc64/gen/fpgetmask.c 103366 2002-09-14 18:06:21Z tmm $"); #include <machine/fsr.h> #include <ieeefp.h> fp_except_t fpgetmask() { unsigned int x; __asm__("st %%fsr,%0" : "=m" (x)); return (FSR_GET_TEM(x)); }
/*- * Copyright (c) 2006 Verdens Gang AS * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Martin Blix Grydeland <martin@varnish-software.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* VUT options */ #define VUT_OPT_d \ VOPT("d", "[-d]", "Process old log entries and exit", \ "Process log records at the head of the log and exit." \ ) #define VUT_OPT_D \ VOPT("D", "[-D]", "Daemonize", \ "Daemonize." \ ) #define VUT_OPT_g \ VOPT("g:", "[-g <session|request|vxid|raw>]", "Grouping mode (default: vxid)", \ "The grouping of the log records. The default is to group" \ " by vxid." \ ) #define VUT_OPT_h \ VOPT("h", "[-h]", "Usage help", \ "Print program usage and exit" \ ) #define VUT_OPT_k \ VOPT("k:", "[-k <num>]", "Limit transactions", \ "Process this number of matching log transactions before" \ " exiting." \ ) #define VUT_OPT_n \ VOPT("n:", "[-n <dir>]", "varnishd working directory", \ "Specify the varnishd working directory (also known as" \ " instance name) to get logs from. If -n is not specified," \ " the host name is used." \ ) #define VUT_OPT_P \ VOPT("P:", "[-P <file>]", "PID file", \ "Write the process' PID to the specified file." \ ) #define VUT_OPT_q \ VOPT("q:", "[-q <query>]", "VSL query", \ "Specifies the VSL query to use." \ ) #define VUT_OPT_r \ VOPT("r:", "[-r <filename>]", "Binary file input", \ "Read log in binary file format from this file. The file" \ " can be created with ``varnishlog -w filename``." \ ) #define VUT_OPT_t \ VOPT("t:", "[-t <seconds|off>]", "VSM connection timeout", \ "Timeout before returning error on initial VSM connection." \ " If set the VSM connection is retried every 0.5 seconds" \ " for this many seconds. If zero the connection is" \ " attempted only once and will fail immediately if" \ " unsuccessful. If set to \"off\", the connection will not" \ " fail, allowing the utility to start and wait" \ " indefinetely for the Varnish instance to appear. " \ " Defaults to 5 seconds." \ ) #define VUT_OPT_V \ VOPT("V", "[-V]", "Version", \ "Print version information and exit." \ )
#include <Ecore.h> #include <unistd.h> static void _job_print_cb(void *data) { char *str = data; printf("%s\n", str); } static void _job_quit_cb(void *data) { ecore_main_loop_quit(); } int main(int argc, char **argv) { Ecore_Job *job1, *job2, *job3, *job_quit; char *str1 = "Job 1 started."; char *str2 = "Job 2 started."; char *str3 = "Job 3 started."; if (!ecore_init()) { printf("ERROR: Cannot init Ecore!\n"); return -1; } job1 = ecore_job_add(_job_print_cb, str1); job2 = ecore_job_add(_job_print_cb, str2); job3 = ecore_job_add(_job_print_cb, str3); job_quit = ecore_job_add(_job_quit_cb, NULL); printf("Created jobs 1, 2, 3 and quit.\n"); if (job2) { char *str; str = ecore_job_del(job2); job2 = NULL; printf("Deleted job 2. Its data was: \"%s\"\n", str); } ecore_main_loop_begin(); ecore_shutdown(); }
/* * Copyright (C) 2010 Apple 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 DeviceOrientationClientIOS_h #define DeviceOrientationClientIOS_h #include "DeviceOrientationClient.h" #include "DeviceOrientationController.h" #include "DeviceOrientationData.h" #include <wtf/PassOwnPtr.h> #include <wtf/RefPtr.h> #ifdef __OBJC__ @class WebCoreMotionManager; #else class WebCoreMotionManager; #endif namespace WebCore { class DeviceOrientationClientIOS : public DeviceOrientationClient { public: DeviceOrientationClientIOS(); virtual ~DeviceOrientationClientIOS() override; virtual void setController(DeviceOrientationController*) override; virtual void startUpdating() override; virtual void stopUpdating() override; virtual DeviceOrientationData* lastOrientation() const override; virtual void deviceOrientationControllerDestroyed() override; void orientationChanged(double, double, double, double, double); private: WebCoreMotionManager* m_motionManager; DeviceOrientationController* m_controller; RefPtr<DeviceOrientationData> m_currentDeviceOrientation; bool m_updating; }; } // namespace WebCore #endif // DeviceOrientationClientIOS_h
// Copyright ©2005, 2006 Freescale Semiconductor, Inc. // Please see the License for the specific language governing rights and // limitations under the License. // =========================================================================== // VPLListBox.h © 1996-97 Metrowerks Inc. All rights reserved. // =========================================================================== // // Created: 12/08/96 // $Date: 2006/01/18 01:34:01 $ // $History: VPLListBox.h $ // // ***************** Version 3 ***************** // User: scouten QDate: 02/19/97 Time: 19:53 // Updated in $/Constructor/Source files/H1- MacOS/Editors/Views/Drawing agents // Improved commenting. // // ***************** Version 2 ***************** // User: scouten QDate: 01/24/97 Time: 17:48 // Updated in $/Constructor/Source files/H1- MacOS/Editors/Views/Drawing agents // Fixed CR/LF problem // // ***************** Version 1 ***************** // User: scouten QDate: 12/08/96 Time: 17:16 // Created in $/Constructor/Source files/Editors/Views/PowerPlant/Drawing agents // Added class. // // =========================================================================== #pragma once // MacOS : Editors : Views : Drawing agents #include "VPLPane.h" // =========================================================================== // * VPLListBox // =========================================================================== // Drawing agent for the PowerPlant class LListBox. class VPLListBox : public VPLPane { public: static VEDrawingAgent* CreateAgent() { return new VPLListBox; } VPLListBox() {} virtual ~VPLListBox() {} virtual LPane* CreateFromStream(LStream* inStream) { return new LListBox(inStream); } protected: virtual void ValueChangedSelf( FourCharCode inAttributeKey, DMAttribute* inAttribute); virtual void ContainerListChanged( DM_ListChange* inMessage); };
#ifndef __Sectioning__ #define __Sectioning__ /////////////////////////////////////////////////////////////////////////// #include "HDialogs.h" #include "NiceTextCtrl.h" /////////////////////////////////////////////////////////////////////////////// /// Class SectioningDlg /////////////////////////////////////////////////////////////////////////////// class SectioningData { public: double m_pos1[3]; double m_pos2[3]; double m_angle; void ReadFromConfig(); void WriteConfig(); int GetAxisType(); bool Validate(); void GetOrigin(gp_Trsf &trsf); }; class SectioningDlg : public HDialog { protected: wxStaticText* m_staticText1; wxRadioButton* m_radioBtn1; wxRadioButton* m_radioBtn2; wxRadioButton* m_radioBtn3; wxRadioButton* m_radioBtn4; wxStaticText* m_staticText3; wxButton* m_button1; wxButton* m_button_zero; wxStaticText* m_staticText2; wxStaticText* m_staticText4; wxStaticText* m_staticText5; CLengthCtrl* m_textCtrl1; CLengthCtrl* m_textCtrl2; CLengthCtrl* m_textCtrl3; wxStaticText* m_staticText12; wxButton* m_button2; wxStaticText* m_staticText9; wxStaticText* m_staticText10; wxStaticText* m_staticText11; CLengthCtrl* m_textCtrl4; CLengthCtrl* m_textCtrl5; CLengthCtrl* m_textCtrl6; wxStaticText* m_staticText13; CDoubleCtrl* m_textCtrl7; public: SectioningDlg( wxWindow* parent, SectioningData &data ); ~SectioningDlg(); void OnRadioButtonX(wxCommandEvent& event); void OnRadioButtonY(wxCommandEvent& event); void OnRadioButtonZ(wxCommandEvent& event); void OnRadioButtonSpecify(wxCommandEvent& event); void OnPickPos1(wxCommandEvent& event); void OnButtonZero(wxCommandEvent& event); void OnPickPos2(wxCommandEvent& event); void OnOK(wxCommandEvent& event); void EnableSecondaryPointControls(bool bEnable); void UpdateSecondaryPoint(); void SetFromData(SectioningData &data); void SetPos1(const double* pos); void GetData(SectioningData &data); DECLARE_EVENT_TABLE() }; #endif //__Sectioning__
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef REMOTING_HOST_DESKTOP_CAPTURER_PROXY_H_ #define REMOTING_HOST_DESKTOP_CAPTURER_PROXY_H_ #include <memory> #include "base/callback.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/threading/thread_checker.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" namespace base { class SingleThreadTaskRunner; } // namespace base namespace webrtc { class DesktopCaptureOptions; } // namespace webrtc namespace remoting { namespace protocol { class CursorShapeInfo; } // namespace protocol // DesktopCapturerProxy is responsible for calling webrtc::DesktopCapturer on // the capturer thread and then returning results to the caller's thread. class DesktopCapturerProxy : public webrtc::DesktopCapturer { public: explicit DesktopCapturerProxy( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner); ~DesktopCapturerProxy() override; // CreateCapturer() should be used if the capturer needs to be created on the // capturer thread. Alternatively the capturer can be passed to // set_capturer(). void CreateCapturer(const webrtc::DesktopCaptureOptions& options); void set_capturer(std::unique_ptr<webrtc::DesktopCapturer> capturer); // webrtc::DesktopCapturer interface. void Start(Callback* callback) override; void SetSharedMemoryFactory(std::unique_ptr<webrtc::SharedMemoryFactory> shared_memory_factory) override; void CaptureFrame() override; private: class Core; void OnFrameCaptured(webrtc::DesktopCapturer::Result result, std::unique_ptr<webrtc::DesktopFrame> frame); base::ThreadChecker thread_checker_; std::unique_ptr<Core> core_; scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; webrtc::DesktopCapturer::Callback* callback_; base::WeakPtrFactory<DesktopCapturerProxy> weak_factory_; DISALLOW_COPY_AND_ASSIGN(DesktopCapturerProxy); }; } // namespace remoting #endif // REMOTING_HOST_DESKTOP_CAPTURER_PROXY_H_
/* * Star.h * openFrameworks */ #include "ofMain.h" class Star { public: Star(); void setup(); void reset(); void update(); void draw(int red, int green, int blue, int alpha); void attract(int fx, int fy); // position in space float x; float y; // current velocity float dx; float dy; // how big it is int radius; // RGB colour value int red; int green; int blue; ofTrueTypeFont font; // this is shared amongst // all the Star objects (so // we don't have to load // the same image for each // star object) static ofImage image; };
/* * Copyright (c) Citrix Systems, 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: * * 1) Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2) Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <string.h> #include "xen_internal.h" #include <xen/api/xen_task_status_type.h> #include "xen_task_status_type_internal.h" /* * Maintain this in the same order as the enum declaration! */ static const char *lookup_table[] = { "pending", "success", "failure", "cancelling", "cancelled", "undefined" }; extern xen_task_status_type_set * xen_task_status_type_set_alloc(size_t size) { return calloc(1, sizeof(xen_task_status_type_set) + size * sizeof(enum xen_task_status_type)); } extern void xen_task_status_type_set_free(xen_task_status_type_set *set) { free(set); } const char * xen_task_status_type_to_string(enum xen_task_status_type val) { return lookup_table[val]; } extern enum xen_task_status_type xen_task_status_type_from_string(xen_session *session, const char *str) { (void)session; return ENUM_LOOKUP(str, lookup_table); } const abstract_type xen_task_status_type_abstract_type_ = { .typename = ENUM, .enum_marshaller = (const char *(*)(int))&xen_task_status_type_to_string, .enum_demarshaller = (int (*)(xen_session *, const char *))&xen_task_status_type_from_string }; const abstract_type xen_task_status_type_set_abstract_type_ = { .typename = SET, .child = &xen_task_status_type_abstract_type_ };
////////////////////////////////////////////////////////////////// // (c) Copyright 2010- by Ken Esler and Jeongnim Kim ////////////////////////////////////////////////////////////////// // National Center for Supercomputing Applications & // Materials Computation Center // University of Illinois, Urbana-Champaign // Urbana, IL 61801 // e-mail: esler@uiuc.edu // // Supported by // National Center for Supercomputing Applications, UIUC // Materials Computation Center, UIUC ////////////////////////////////////////////////////////////////// #ifndef AFM_SPO_BUILDER_H #define AFM_SPO_BUILDER_H #include "QMCWaveFunctions/BasisSetBase.h" #include "QMCWaveFunctions/AFMSPOSet.h" namespace qmcplusplus { class AFMSPOBuilder : public BasisSetBuilder { protected: typedef map<string,ParticleSet*> PtclPoolType; typedef map<string,SPOSetBase*> SPOPoolType; ParticleSet *targetPtcl; public: AFMSPOBuilder(ParticleSet& p, PtclPoolType& psets, xmlNodePtr cur); bool put (xmlNodePtr cur); /** initialize the Antisymmetric wave function for electrons *@param cur the current xml node */ SPOSetBase* createSPOSetFromXML(xmlNodePtr cur); // SPOSetBase* createSPOSetFromXML(xmlNodePtr cur, SPOPool_t& spo_pool); }; } #endif
/* Copyright 2020 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "cbi_fw_config.h" #include "common.h" #include "console.h" #include "cros_board_info.h" #include "hooks.h" /**************************************************************************** * Dedede CBI FW Configuration */ #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) /* Cache FW_CONFIG on init since we don't expect it to change in runtime */ static uint32_t cached_fw_config; static void cbi_fw_config_init(void) { if (cbi_get_fw_config(&cached_fw_config) != EC_SUCCESS) /* Default to 0 when CBI isn't populated */ cached_fw_config = 0; CPRINTS("FW_CONFIG: 0x%04X", cached_fw_config); } DECLARE_HOOK(HOOK_INIT, cbi_fw_config_init, HOOK_PRIO_FIRST); enum fw_config_db get_cbi_fw_config_db(void) { return ((cached_fw_config & FW_CONFIG_DB_MASK) >> FW_CONFIG_DB_OFFSET); } enum fw_config_stylus get_cbi_fw_config_stylus(void) { return ((cached_fw_config & FW_CONFIG_STYLUS_MASK) >> FW_CONFIG_STYLUS_OFFSET); } enum fw_config_kblight_type get_cbi_fw_config_kblight(void) { return ((cached_fw_config & FW_CONFIG_KB_BL_MASK) >> FW_CONFIG_KB_BL_OFFSET); } enum fw_config_tablet_mode_type get_cbi_fw_config_tablet_mode(void) { return ((cached_fw_config & FW_CONFIG_TABLET_MODE_MASK) >> FW_CONFIG_TABLET_MODE_OFFSET); } int get_cbi_fw_config_keyboard(void) { return ((cached_fw_config & FW_CONFIG_KB_LAYOUT_MASK) >> FW_CONFIG_KB_LAYOUT_OFFSET); } enum fw_config_numeric_pad_type get_cbi_fw_config_numeric_pad(void) { return ((cached_fw_config & FW_CONFIG_KB_NUMPAD_MASK) >> FW_CONFIG_KB_NUMPAD_OFFSET); } enum fw_config_hdmi_type get_cbi_fw_config_hdmi(void) { return ((cached_fw_config & FW_CONFIG_HDMI_MASK) >> FW_CONFIG_HDMI_OFFSET); }
/*** Copyright (c), The Regents of the University of California *** *** For more information please refer to files in the COPYRIGHT directory ***/ /* msoFileDriver.c - Driver to get/put objects using micro-service-based drivers */ #include "rsGlobalExtern.h" #include "reGlobalsExtern.h" #include "msoFileDriver.h" int msoFileUnlink (rsComm_t *rsComm, char *filename) { return(0); } int msoFileStat (rsComm_t *rsComm, char *filename, struct stat *statbuf) { statbuf->st_mode = S_IFREG; statbuf->st_nlink = 1; statbuf->st_uid = getuid (); statbuf->st_gid = getgid (); statbuf->st_atime = statbuf->st_mtime = statbuf->st_ctime = time(0); statbuf->st_size = UNKNOWN_FILE_SZ; return 0; } rodsLong_t msoFileGetFsFreeSpace (rsComm_t *rsComm, char *path, int flag) { return(LARGE_SPACE); } /* msoStageToCache - * Just copy the file from filename to cacheFilename. optionalInfo info * is not used. * */ int msoStageToCache (rsComm_t *rsComm, fileDriverType_t cacheFileType, int mode, int flags, char *msoObjName, char *cacheFilename, rodsLong_t dataSize, keyValPair_t *condInput) { char *myMSICall; char *t; int i; ruleExecInfo_t rei2; msParamArray_t msParamArray; char callCode[100]; if ((t = strstr(msoObjName, ":")) == NULL) { return(MICRO_SERVICE_OBJECT_TYPE_UNDEFINED); } *t = '\0'; sprintf(callCode, "%s", msoObjName+2); *t = ':'; myMSICall = (char *) malloc(strlen(msoObjName) + strlen(cacheFilename) + 200); sprintf(myMSICall, "msiobjget_%s(\"%s\",\"%i\",\"%i\",\"%s\")",callCode,msoObjName+2,mode,flags,cacheFilename); memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t)); memset ((char*)&msParamArray, 0, sizeof(msParamArray_t)); rei2.rsComm = rsComm; if (rsComm != NULL) { rei2.uoic = &rsComm->clientUser; rei2.uoip = &rsComm->proxyUser; } i = applyRule(myMSICall, &msParamArray, &rei2, NO_SAVE_REI); if (i < 0) { if (rei2.status < 0) { i = rei2.status; } rodsLog (LOG_ERROR, "msoStageToCache: Error in rule for %s error=%d",myMSICall,i); } free(myMSICall); clearMsParamArray(&msParamArray,0); return(i); } /* msoSyncToArch - * Just copy the file from cacheFilename to filename. optionalInfo info * is not used. * */ int msoSyncToArch (rsComm_t *rsComm, fileDriverType_t cacheFileType, int mode, int flags, char *msoObjName, char *cacheFilename, rodsLong_t dataSize, keyValPair_t *condInput) { int status; struct stat statbuf; char *myMSICall; char *t; int i; ruleExecInfo_t rei2; msParamArray_t msParamArray; char callCode[100]; status = stat (cacheFilename, &statbuf); if (status < 0) { status = UNIX_FILE_STAT_ERR - errno; printf ("msoSyncToArch: CacheFile stat of %s error, status = %d\n", cacheFilename, status); } if ((statbuf.st_mode & S_IFREG) == 0) { status = UNIX_FILE_STAT_ERR - errno; printf ( "msoSyncToArch: %s is not a file, status = %d\n", cacheFilename, status); return status; } if (dataSize > 0 && dataSize != statbuf.st_size) { printf ( "msoSyncToArch: %s inp size %lld does not match actual size %lld\n", cacheFilename, (long long int) dataSize, (long long int) statbuf.st_size); return SYS_COPY_LEN_ERR; } dataSize = statbuf.st_size; if ((t = strstr(msoObjName, ":")) == NULL) { return(MICRO_SERVICE_OBJECT_TYPE_UNDEFINED); } *t = '\0'; sprintf(callCode, "%s", msoObjName+2); *t = ':'; myMSICall = (char *) malloc(strlen(msoObjName) + strlen(cacheFilename) + 200); sprintf(myMSICall, "msiobjput_%s(\"%s\",\"%s\",\"%lld\")",callCode,msoObjName+2,cacheFilename,dataSize); memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t)); memset ((char*)&msParamArray, 0, sizeof(msParamArray_t)); rei2.rsComm = rsComm; if (rsComm != NULL) { rei2.uoic = &rsComm->clientUser; rei2.uoip = &rsComm->proxyUser; } i = applyRule(myMSICall, &msParamArray, &rei2, NO_SAVE_REI); if (i < 0) { if (rei2.status < 0) { i = rei2.status; } rodsLog (LOG_ERROR, "msoSyncToArch: Error in rule for %s error=%d",myMSICall,i); } free(myMSICall); clearMsParamArray(&msParamArray,0); return(i); }
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_VIDEO_CAPTURE_CAPTURABLE_FRAME_SINK_H_ #define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_VIDEO_CAPTURE_CAPTURABLE_FRAME_SINK_H_ #include "base/time/time.h" #include "components/viz/common/surfaces/region_capture_bounds.h" #include "components/viz/service/surfaces/pending_copy_output_request.h" #include "third_party/abseil-cpp/absl/types/variant.h" #include "ui/gfx/geometry/size.h" namespace gfx { class Rect; } // namespace gfx namespace viz { class CompositorFrameMetadata; class LocalSurfaceId; // Interface for CompositorFrameSink implementations that support frame sink // video capture. class CapturableFrameSink { public: // Interface for a client that observes certain frame events and calls // RequestCopyOfSurface() at the appropriate times. class Client { public: virtual ~Client() = default; // Called when a frame's content, or that of one or more of its child // frames, has changed. |frame_size| is the output size of the currently- // active compositor frame for the frame sink being monitored, with // |damage_rect| being the region within that has changed (never empty). // |expected_display_time| indicates when the content change was expected to // appear on the Display. virtual void OnFrameDamaged( const gfx::Size& frame_size, const gfx::Rect& damage_rect, base::TimeTicks expected_display_time, const CompositorFrameMetadata& frame_metadata) = 0; // Called from SurfaceAggregator to get the video capture status on the // surface which is going to be drawn to. virtual bool IsVideoCaptureStarted() = 0; }; virtual ~CapturableFrameSink() = default; virtual const FrameSinkId& GetFrameSinkId() const = 0; // Attach/Detach a video capture client to the frame sink. The client will // receive frame begin and draw events, and issue copy requests, when // appropriate. virtual void AttachCaptureClient(Client* client) = 0; virtual void DetachCaptureClient(Client* client) = 0; // Returns the capture region of a render pass, either matching the // |subtree_id| if set, or the root render pass if not set. Returns an empty // rect if (1) there is no active frame, (2) |subtree_id| is valid/set and // no matching render pass could be found, or (3) a valid crop ID is set and // its associated bounds are set to empty or could not be found. // NOTE: only one of |subtree_id| or |crop_id| should be set and valid, not // both. using RegionSpecifier = absl::variant<absl::monostate, SubtreeCaptureId, RegionCaptureCropId>; virtual gfx::Rect GetCopyOutputRequestRegion( const RegionSpecifier& specifier) const = 0; // Called when a video capture client starts or stops capturing. virtual void OnClientCaptureStarted() = 0; virtual void OnClientCaptureStopped() = 0; // Issues a request for a copy of the next composited frame whose // LocalSurfaceId is at least |local_surface_id|. Note that if this id is // default constructed, then the next surface will provide the copy output // regardless of its LocalSurfaceId. virtual void RequestCopyOfOutput( PendingCopyOutputRequest pending_copy_output_request) = 0; // Returns the CompositorFrameMetadata of the last activated CompositorFrame. // Return null if no CompositorFrame has activated yet. virtual const CompositorFrameMetadata* GetLastActivatedFrameMetadata() = 0; }; } // namespace viz #endif // COMPONENTS_VIZ_SERVICE_FRAME_SINKS_VIDEO_CAPTURE_CAPTURABLE_FRAME_SINK_H_
#ifndef MITK_MINMAXIMAGEFILTERWITHINDEX_H #define MITK_MINMAXIMAGEFILTERWITHINDEX_H #include <MitkImageStatisticsExports.h> #include <itkImage.h> #include <itkImageToImageFilter.h> #include <itkImageRegionConstIteratorWithIndex.h> namespace itk { template <typename TInputImage> class MinMaxImageFilterWithIndex: public itk::ImageToImageFilter<TInputImage, TInputImage> { public: /** Standard Self typedef */ typedef MinMaxImageFilterWithIndex Self; typedef ImageToImageFilter< TInputImage, TInputImage > Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Runtime information support. */ itkTypeMacro(MinMaxImageFilterWithIndex, ImageToImageFilter); typedef typename TInputImage::RegionType RegionType; typedef typename TInputImage::SizeType SizeType; typedef typename TInputImage::IndexType IndexType; typedef typename TInputImage::PixelType PixelType; typedef typename NumericTraits< PixelType >::RealType RealType; RealType GetMin() const { return m_Min; } RealType GetMax() const { return m_Max; } IndexType GetMinIndex() const { return m_MinIndex; } IndexType GetMaxIndex() const { return m_MaxIndex; } protected: void AllocateOutputs(); void ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType threadId); void BeforeThreadedGenerateData(); void AfterThreadedGenerateData(); private: std::vector<PixelType> m_ThreadMin; std::vector<PixelType> m_ThreadMax; std::vector<IndexType> m_ThreadMinIndex; std::vector<IndexType> m_ThreadMaxIndex; PixelType m_Min; PixelType m_Max; IndexType m_MinIndex; IndexType m_MaxIndex; }; } #include "mitkMinMaxImageFilterWithIndex.hxx" #endif
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_ #define CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_ #pragma once #include "base/basictypes.h" #include "base/compiler_specific.h" #include "build/build_config.h" #include "ui/base/accessibility/accessibility_types.h" #include "ui/views/views_delegate.h" class ChromeViewsDelegate : public views::ViewsDelegate { public: ChromeViewsDelegate() {} virtual ~ChromeViewsDelegate() {} // Overridden from views::ViewsDelegate: virtual ui::Clipboard* GetClipboard() const OVERRIDE; virtual void SaveWindowPlacement(const views::Widget* window, const std::string& window_name, const gfx::Rect& bounds, ui::WindowShowState show_state) OVERRIDE; virtual bool GetSavedWindowPlacement( const std::string& window_name, gfx::Rect* bounds, ui::WindowShowState* show_state) const OVERRIDE; virtual void NotifyAccessibilityEvent( views::View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE; virtual void NotifyMenuItemFocused(const string16& menu_name, const string16& menu_item_name, int item_index, int item_count, bool has_submenu) OVERRIDE; #if defined(OS_WIN) virtual HICON GetDefaultWindowIcon() const OVERRIDE; #endif virtual views::NonClientFrameView* CreateDefaultNonClientFrameView( views::Widget* widget) OVERRIDE; virtual void AddRef() OVERRIDE; virtual void ReleaseRef() OVERRIDE; virtual int GetDispositionForEvent(int event_flags) OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(ChromeViewsDelegate); }; #endif // CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53b.c Label Definition File: CWE789_Uncontrolled_Mem_Alloc__malloc.label.xml Template File: sources-sinks-53b.tmpl.c */ /* * @description * CWE: 789 Uncontrolled Memory Allocation * BadSource: listen_socket Read data using a listen socket (server side) * GoodSource: Small number greater than zero * Sinks: * GoodSink: Allocate memory with malloc() and check the size of the memory to be allocated * BadSink : Allocate memory with malloc(), but incorrectly check the size of the memory to be allocated * Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files * * */ #include "std_testcase.h" #ifndef _WIN32 #include <wchar.h> #endif #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define CLOSE_SOCKET close #define SOCKET int #endif #define TCP_PORT 27015 #define LISTEN_BACKLOG 5 #define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2) #define HELLO_STRING "hello" #ifndef OMITBAD /* bad function declaration */ void CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53c_badSink(size_t data); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53b_badSink(size_t data) { CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53c_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53c_goodG2BSink(size_t data); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53b_goodG2BSink(size_t data) { CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53c_goodG2BSink(data); } /* goodB2G uses the BadSource with the GoodSink */ void CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53c_goodB2GSink(size_t data); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53b_goodB2GSink(size_t data) { CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_53c_goodB2GSink(data); } #endif /* OMITGOOD */
/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) * (C) 2006 Alexey Proskuryakov (ap@webkit.org) * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2012 Intel Corporation. All rights reserved. * * 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., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef ViewportArguments_h #define ViewportArguments_h #include "core/page/PageScaleConstraints.h" #include "core/platform/graphics/FloatSize.h" #include <wtf/Forward.h> namespace WebCore { class Document; enum ViewportErrorCode { UnrecognizedViewportArgumentKeyError, UnrecognizedViewportArgumentValueError, TruncatedViewportArgumentValueError, MaximumScaleTooLargeError, TargetDensityDpiUnsupported }; struct ViewportArguments { enum Type { // These are ordered in increasing importance. Implicit, XHTMLMobileProfile, HandheldFriendlyMeta, MobileOptimizedMeta, ViewportMeta, CSSDeviceAdaptation } type; enum { ValueAuto = -1, ValueDeviceWidth = -2, ValueDeviceHeight = -3, ValuePortrait = -4, ValueLandscape = -5, ValueDeviceDPI = -6, ValueLowDPI = -7, ValueMediumDPI = -8, ValueHighDPI = -9 }; ViewportArguments(Type type = Implicit) : type(type) , width(ValueAuto) , minWidth(ValueAuto) , maxWidth(ValueAuto) , height(ValueAuto) , minHeight(ValueAuto) , maxHeight(ValueAuto) , zoom(ValueAuto) , minZoom(ValueAuto) , maxZoom(ValueAuto) , userZoom(ValueAuto) , orientation(ValueAuto) , deprecatedTargetDensityDPI(ValueAuto) { } // All arguments are in CSS units. PageScaleConstraints resolve(const FloatSize& initialViewportSize, const FloatSize& deviceSize, int defaultWidth) const; float width; float minWidth; float maxWidth; float height; float minHeight; float maxHeight; float zoom; float minZoom; float maxZoom; float userZoom; float orientation; float deprecatedTargetDensityDPI; // Only used for Android WebView bool operator==(const ViewportArguments& other) const { // Used for figuring out whether to reset the viewport or not, // thus we are not taking type into account. return width == other.width && minWidth == other.minWidth && maxWidth == other.maxWidth && height == other.height && minHeight == other.minHeight && maxHeight == other.maxHeight && zoom == other.zoom && minZoom == other.minZoom && maxZoom == other.maxZoom && userZoom == other.userZoom && orientation == other.orientation && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI; } bool operator!=(const ViewportArguments& other) const { return !(*this == other); } }; void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data); void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2); } // namespace WebCore #endif // ViewportArguments_h
#ifndef THEMIS_SINK_WRITER_H #define THEMIS_SINK_WRITER_H #include "core/SingleUnitRunnable.h" #include "common/WriteTokenPool.h" template <typename T> class SinkWriter : public SingleUnitRunnable<T> { WORKER_IMPL public: SinkWriter( uint64_t id, const std::string& stageName, WriteTokenPool& _writeTokenPool) : SingleUnitRunnable<T>(id, stageName), writeTokenPool(_writeTokenPool) { } void run(T* resource) { WriteToken* token = resource->getToken(); if (token != NULL) { writeTokenPool.putToken(token); } delete resource; } private: WriteTokenPool& writeTokenPool; }; template <typename T> BaseWorker* SinkWriter<T>::newInstance( const std::string& phaseName, const std::string& stageName, uint64_t id, Params& params, MemoryAllocatorInterface& memoryAllocator, NamedObjectCollection& dependencies) { WriteTokenPool* writeTokenPool = dependencies.get<WriteTokenPool>( "write_token_pool"); SinkWriter* sink = new SinkWriter(id, stageName, *writeTokenPool); return sink; } #endif // THEMIS_SINK_WRITER_H
/*------------------------------------------------------------------------------ * * Copyright (c) 2011, EURid. All rights reserved. * The YADIFA TM software product is provided under the BSD 3-clause license: * * 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 EURid nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * *------------------------------------------------------------------------------ * * DOCUMENTATION */ /** @defgroup dnsdbcollection Collections used by the database * @ingroup dnsdb * @brief Hash-based collection designed to change it's structure to improve speed. * * Hash-based collection designed to change it's structure to improve speed. * * @{ */ #include <stdio.h> #include <stdlib.h> #include "dnsdb/zdb_config.h" #include "dnsdb/dictionary.h" #define ZDB_HASHTABLE_THRESHOLD_DISABLE (~0) void dictionary_btree_init(dictionary* dico); void dictionary_htbt_init(dictionary* dico); struct dictionary_mutation_table_entry { u32 threshold; /* Up to that number of items in the collection */ dictionary_init_method* init; }; static struct dictionary_mutation_table_entry dictionary_mutation_table[2] = { { ZDB_HASHTABLE_THRESHOLD, dictionary_btree_init}, { MAX_U32, dictionary_htbt_init}, }; static struct dictionary_mutation_table_entry* dictionary_get_mutation_entry(dictionary* dico) { struct dictionary_mutation_table_entry* entry = dictionary_mutation_table; for(; dico->count > entry->threshold; entry++); return entry; } /* * I could avoid this hook, the signature is almost the same * */ static void dictionary_bucket_record_callback(void* bucket_data, hashcode key, dictionary_node* node) { dictionary_fills((dictionary*)bucket_data, key, node); } static void dictionary_destroy_record_callback(dictionary_node* node) { /* This should NEVER be called */ assert(FALSE); /* NOT zassert ! */ } void dictionary_init(dictionary* dico) { dictionary_mutation_table[0].init(dico); dico->threshold = dictionary_mutation_table[0].threshold; } void dictionary_mutate(dictionary* dico) { struct dictionary_mutation_table_entry* entry = dictionary_get_mutation_entry(dico); /* Check the mutation condition */ if(dico->threshold == entry->threshold) { return; } /* Mutate */ dictionary new_dico; entry->init(&new_dico); /* Update the default (MAX_UNSIGNED_INT) threshold */ new_dico.threshold = entry->threshold; dictionary_empties(dico, &new_dico, dictionary_bucket_record_callback); dictionary_destroy(dico, dictionary_destroy_record_callback); MEMCOPY(dico, &new_dico, sizeof (dictionary)); } /** @} */
/******************************************************************************* * >>>>>> "Development of a PAPI Backend for the Sun Niagara 2 Processor" <<<<<< * ----------------------------------------------------------------------------- * * Fabian Gorsler <fabian.gorsler@smail.inf.h-bonn-rhein-sieg.de> * * Hochschule Bonn-Rhein-Sieg, Sankt Augustin, Germany * University of Applied Sciences * * ----------------------------------------------------------------------------- * * File: solaris-niagara2-memory.c * Author: fg215045 * * Description: This file holds functions returning information about the memory * hiearchy and the memory available to this process. utils/papi_mem_info and * ctests/dmem_info are related to these functions. * * ***** Feel free to convert this header to the PAPI default ***** * * ----------------------------------------------------------------------------- * Created on April 23, 2009, 3:18 PM ******************************************************************************/ #include "papi.h" #include "papi_internal.h" int _niagara2_get_memory_info( PAPI_hw_info_t * hw, int id ) { PAPI_mh_level_t *mem = hw->mem_hierarchy.level; #ifdef DEBUG SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__, __LINE__ ); #endif /* I-Cache -> L1$ instruction */ /* FIXME: The policy used at this cache is unknown to PAPI. LSFR with random replacement. */ mem[0].cache[0].type = PAPI_MH_TYPE_INST; mem[0].cache[0].size = 16 * 1024; // 16 Kb mem[0].cache[0].line_size = 32; mem[0].cache[0].num_lines = mem[0].cache[0].size / mem[0].cache[0].line_size; mem[0].cache[0].associativity = 8; /* D-Cache -> L1$ data */ mem[0].cache[1].type = PAPI_MH_TYPE_DATA | PAPI_MH_TYPE_WT | PAPI_MH_TYPE_LRU; mem[0].cache[1].size = 8 * 1024; // 8 Kb mem[0].cache[1].line_size = 16; mem[0].cache[1].num_lines = mem[0].cache[1].size / mem[0].cache[1].line_size; mem[0].cache[1].associativity = 4; /* ITLB -> TLB instruction */ mem[0].tlb[0].type = PAPI_MH_TYPE_INST | PAPI_MH_TYPE_PSEUDO_LRU; mem[0].tlb[0].num_entries = 64; mem[0].tlb[0].associativity = 64; /* DTLB -> TLB data */ mem[0].tlb[1].type = PAPI_MH_TYPE_DATA | PAPI_MH_TYPE_PSEUDO_LRU; mem[0].tlb[1].num_entries = 128; mem[0].tlb[1].associativity = 128; /* L2$ unified */ mem[1].cache[0].type = PAPI_MH_TYPE_UNIFIED | PAPI_MH_TYPE_WB | PAPI_MH_TYPE_PSEUDO_LRU; mem[1].cache[0].size = 4 * 1024 * 1024; // 4 Mb mem[1].cache[0].line_size = 64; mem[1].cache[0].num_lines = mem[1].cache[0].size / mem[1].cache[0].line_size; mem[1].cache[0].associativity = 16; /* Indicate we have two levels filled in the hierarchy */ hw->mem_hierarchy.levels = 2; #ifdef DEBUG SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__, __LINE__ ); #endif return PAPI_OK; } int _niagara2_get_dmem_info( PAPI_dmem_info_t * d ) { #ifdef DEBUG SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__, __LINE__ ); #endif /* More information needed to fill all fields */ d->pagesize = sysconf( _SC_PAGESIZE ); d->size = d->pagesize * sysconf( _SC_PHYS_PAGES ); d->resident = PAPI_EINVAL; d->high_water_mark = PAPI_EINVAL; d->shared = PAPI_EINVAL; d->text = PAPI_EINVAL; d->library = PAPI_EINVAL; d->heap = PAPI_EINVAL; d->locked = PAPI_EINVAL; d->stack = PAPI_EINVAL; #ifdef DEBUG SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__, __LINE__ ); #endif return PAPI_OK; }
/* $NetBSD: memset.c,v 1.12 2019/03/30 10:18:03 jmcneill Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Mike Hibler and Chris Torek. * * 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 University 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 REGENTS 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 REGENTS 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. */ #ifdef _KERNEL #include <sys/libkern.h> #include <limits.h> #else #include <sys/cdefs.h> #include <sys/types.h> #include <assert.h> #include <limits.h> #include <string.h> #endif #define wsize sizeof(u_int) #define wmask (wsize - 1) #undef memset #ifdef BZERO #define RETURN return #define VAL 0 #define WIDEVAL 0 void bzero(void *dst0, size_t length) #else #define RETURN return (dst0) #define VAL c0 #define WIDEVAL c void *memset(void *dst0, int c0, size_t length) #endif { size_t t; #ifndef BZERO u_int c; #endif u_char *dst; dst = dst0; /* * If not enough words, just fill bytes. A length >= 2 words * guarantees that at least one of them is `complete' after * any necessary alignment. For instance: * * |-----------|-----------|-----------| * |00|01|02|03|04|05|06|07|08|09|0A|00| * ^---------------------^ * dst dst+length-1 * * but we use a minimum of 3 here since the overhead of the code * to do word writes is substantial. */ if (length < 3 * wsize) { while (length != 0) { *dst++ = VAL; --length; } RETURN; } #ifndef BZERO if ((c = (u_char)c0) != 0) { /* Fill the word. */ c = (c << 8) | c; /* u_int is 16 bits. */ #if UINT_MAX > 0xffff c = (c << 16) | c; /* u_int is 32 bits. */ #endif #if UINT_MAX > 0xffffffff c = (c << 32) | c; /* u_int is 64 bits. */ #endif } #endif /* Align destination by filling in bytes. */ if ((t = (size_t)((u_long)dst & wmask)) != 0) { t = wsize - t; length -= t; do { *dst++ = VAL; } while (--t != 0); } /* Fill words. Length was >= 2*words so we know t >= 1 here. */ t = length / wsize; do { *(u_int *)(void *)dst = WIDEVAL; dst += wsize; } while (--t != 0); /* Mop up trailing bytes, if any. */ t = length & wmask; if (t != 0) do { *dst++ = VAL; } while (--t != 0); RETURN; }
// // ISProperty.h // iRubyKaigi // // Created by Katsuyoshi Ito on 10/05/29. // Copyright 2010 ITO SOFT DESIGN Inc. All rights reserved. // /* Copyright 2010 ITO SOFT DESIGN 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 ITO SOFT DESIGN 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. */ #import <Foundation/Foundation.h> @interface ISProperty : NSObject { } @property (assign, readonly) NSUserDefaults *userDefaults; + (ISProperty *)sharedProperty; - (void)setBoolValue:(BOOL)value forKey:(NSString *)key; - (BOOL)boolValueForKey:(NSString *)key defaultValue:(BOOL)defaultValue; - (BOOL)boolValueForKey:(NSString *)key; - (void)setIntValue:(int)value forKey:(NSString *)key; - (int)intValueForKey:(NSString *)key defaultValue:(int)defaultValue; - (int)intValueForKey:(NSString *)key; - (void)setFloatValue:(float)value forKey:(NSString *)key; - (float)floatValueForKey:(NSString *)key defaultValue:(float)defaultValue; - (float)floatValueForKey:(NSString *)key; - (void)setDoubleValue:(double)value forKey:(NSString *)key; - (double)doubleValueForKey:(NSString *)key defaultValue:(double)defaultValue; - (double)doubleValueForKey:(NSString *)key; - (void)setStringValue:(NSString *)value forKey:(NSString *)key; - (NSString *)stringValueForKey:(NSString *)key defaultValue:(NSString *)defaultValue; - (NSString *)stringValueForKey:(NSString *)key; - (void)setArray:(NSArray *)array forKey:(NSString *)key; - (NSArray *)arrayForKey:(NSString *)key defaultValue:(NSArray *)defaultValue; - (NSArray *)arrayForKey:(NSString *)key; - (void)setDate:(NSDate *)date forKey:(NSString *)key; - (NSDate *)dateForKey:(NSString *)key defaultValue:(NSDate *)defaultValue; - (NSDate *)dateForKey:(NSString *)key; @end
/**************************************************************************** ** Copyright (c) 2006 - 2011, the LibQxt project. ** See the Qxt AUTHORS file for a list of authors and copyright holders. ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** * Neither the name of the LibQxt 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 <COPYRIGHT HOLDER> 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. ** ** <http://libqxt.org> <foundation@libqxt.org> *****************************************************************************/ /************************************************************************** This is private API. it might change at any time without warning. ****************************************************************************/ #ifndef QxtBdb_H_kpasd #define QxtBdb_H_kpasd #include <QFlags> #include <QBuffer> #include <QDataStream> #include <QMetaType> #include <QString> #include <qxtglobal.h> #include <cstdlib> #include <cstdio> ///its impossible to forward anyway, namespace BerkeleyDB { extern "C" { #include <db.h> } /// aparantly MSVC and GCC have different understanding of what goes into a namespace and what not. #ifndef Q_CC_MSVC typedef quint32 u_int32_t; #endif } class QXT_BERKELEY_EXPORT QxtBdb { public: enum OpenFlag { CreateDatabase = 0x1, ReadOnly = 0x2, LockFree = 0x4 }; Q_DECLARE_FLAGS(OpenFlags, OpenFlag); QxtBdb(); ~QxtBdb(); bool get(void* key, int keytype, void* value, int valuetype, BerkeleyDB::u_int32_t flags = NULL, BerkeleyDB::DBC * cursor = 0) const ; bool get(const void* key, int keytype, void* value, int valuetype, BerkeleyDB::u_int32_t flags = NULL, BerkeleyDB::DBC * cursor = 0) const ; bool open(QString path, OpenFlags f = 0); OpenFlags openFlags(); bool flush(); BerkeleyDB::DB * db; bool isOpen; static QString dbErrorCodeToString(int e); template<class T> static T qxtMetaLoad(const void * data, size_t size) { T t; QByteArray b = QByteArray::fromRawData((const char*)data, size); QBuffer buffer(&b); buffer.open(QIODevice::ReadOnly); QDataStream s(&buffer); if (!QMetaType::load(s, qMetaTypeId<T>(), &t)) qCritical("QMetaType::load failed. is your type registered with the QMetaType?"); buffer.close(); return t; } static void * qxtMetaLoad(const void * data, size_t size, int type) { void *p = QMetaType::construct(type); QByteArray b = QByteArray::fromRawData(static_cast<const char*>(data), size); QBuffer buffer(&b); buffer.open(QIODevice::ReadOnly); QDataStream s(&buffer); if (!QMetaType::load(s, type, p)) qCritical("QMetaType::load failed. is your type registered with the QMetaType?"); buffer.close(); return p; } template<class T> static QByteArray qxtMetaSave(const T & t) { QByteArray d; QBuffer buffer(&d); buffer.open(QIODevice::WriteOnly); QDataStream s(&buffer); if (!QMetaType::save(s, qMetaTypeId<T>(), &t)) qCritical("QMetaType::save failed. is your type registered with the QMetaType?"); buffer.close(); return d; } static void * qxtMetaSave(size_t * size, void * t, int type) { QByteArray d; QBuffer buffer(&d); buffer.open(QIODevice::WriteOnly); QDataStream s(&buffer); if (!QMetaType::save(s, type, t)) qCritical("QMetaType::save failed. is your type registered with the QMetaType?"); buffer.close(); *size = d.size(); void *p = ::malloc(d.size()); ::memcpy(p, d.data(), d.size()); return p; } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QxtBdb::OpenFlags); #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82.h Label Definition File: CWE256_Plaintext_Storage_of_Password__w32.label.xml Template File: sources-sinks-82.tmpl.h */ /* * @description * CWE: 256 Plaintext Storage of Password * BadSource: Read the password from a file * GoodSource: Read the password from a file and decrypt it * Sinks: * GoodSink: Decrypt the password then authenticate the user using LogonUserW() * BadSink : Authenticate the user using LogonUserW() * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer * * */ #include "std_testcase.h" #include <wchar.h> #include <windows.h> #include <wincrypt.h> #pragma comment(lib, "advapi32") #pragma comment(lib, "crypt32.lib") #define HASH_INPUT "ABCDEFG123456" /* INCIDENTAL: Hardcoded crypto */ namespace CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82 { class CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82_base { public: /* pure virtual function */ virtual void action(wchar_t * data) = 0; }; #ifndef OMITBAD class CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82_bad : public CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82_base { public: void action(wchar_t * data); }; #endif /* OMITBAD */ #ifndef OMITGOOD class CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82_goodG2B : public CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82_base { public: void action(wchar_t * data); }; class CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82_goodB2G : public CWE256_Plaintext_Storage_of_Password__w32_wchar_t_82_base { public: void action(wchar_t * data); }; #endif /* OMITGOOD */ }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE123_Write_What_Where_Condition__connect_socket_64b.c Label Definition File: CWE123_Write_What_Where_Condition.label.xml Template File: sources-sink-64b.tmpl.c */ /* * @description * CWE: 123 Write-What-Where Condition * BadSource: connect_socket Overwrite linked list pointers using a connect socket (client side) * GoodSource: Don't overwrite linked list pointers * Sinks: * BadSink : Remove element from list * Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files * * */ #include "std_testcase.h" typedef struct _linkedList { struct _linkedList *next; struct _linkedList *prev; } linkedList; typedef struct _badStruct { linkedList list; } badStruct; static linkedList *linkedListPrev, *linkedListNext; #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else /* NOT _WIN32 */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define CLOSE_SOCKET close #define SOCKET int #endif #define TCP_PORT 27015 #define IP_ADDRESS "127.0.0.1" #ifndef OMITBAD void CWE123_Write_What_Where_Condition__connect_socket_64b_badSink(void * dataVoidPtr) { /* cast void pointer to a pointer of the appropriate type */ badStruct * dataPtr = (badStruct *)dataVoidPtr; /* dereference dataPtr into data */ badStruct data = (*dataPtr); /* POTENTIAL FLAW: The following removes 'a' from the list. Because of the possible overflow this * causes a "write-what-where" aka "write4". It does another write as * well. But this is the prototypical "write-what-where" at least from * the Windows perspective. * * linkedListPrev = a->list->prev WHAT * linkedListNext = a->list->next WHERE * linkedListPrev->next = linkedListNext "at the address that prev/WHERE points, write * next/WHAT" * aka "write-what-where" * linkedListNext->prev = linkedListPrev "at the address that next/WHAT points plus 4 * (because prev is the second field in 'list' hence * 4 bytes away on 32b machines), write prev/WHERE" */ linkedListPrev = data.list.prev; linkedListNext = data.list.next; linkedListPrev->next = linkedListNext; linkedListNext->prev = linkedListPrev; } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE123_Write_What_Where_Condition__connect_socket_64b_goodG2BSink(void * dataVoidPtr) { /* cast void pointer to a pointer of the appropriate type */ badStruct * dataPtr = (badStruct *)dataVoidPtr; /* dereference dataPtr into data */ badStruct data = (*dataPtr); /* POTENTIAL FLAW: The following removes 'a' from the list. Because of the possible overflow this * causes a "write-what-where" aka "write4". It does another write as * well. But this is the prototypical "write-what-where" at least from * the Windows perspective. * * linkedListPrev = a->list->prev WHAT * linkedListNext = a->list->next WHERE * linkedListPrev->next = linkedListNext "at the address that prev/WHERE points, write * next/WHAT" * aka "write-what-where" * linkedListNext->prev = linkedListPrev "at the address that next/WHAT points plus 4 * (because prev is the second field in 'list' hence * 4 bytes away on 32b machines), write prev/WHERE" */ linkedListPrev = data.list.prev; linkedListNext = data.list.next; linkedListPrev->next = linkedListNext; linkedListNext->prev = linkedListPrev; } #endif /* OMITGOOD */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_82.h Label Definition File: CWE124_Buffer_Underwrite__malloc.label.xml Template File: sources-sink-82.tmpl.h */ /* * @description * CWE: 124 Buffer Underwrite * BadSource: Set data pointer to before the allocated memory buffer * GoodSource: Set data pointer to the allocated memory buffer * BadSink : Copy string to data using memmove * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer * * */ #include "std_testcase.h" #include <wchar.h> namespace CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_82 { class CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_82_base { public: /* pure virtual function */ virtual void action(wchar_t * data) = 0; }; #ifndef OMITBAD class CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_82_bad : public CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_82_base { public: void action(wchar_t * data); }; #endif /* OMITBAD */ #ifndef OMITGOOD class CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_82_goodG2B : public CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_82_base { public: void action(wchar_t * data); }; #endif /* OMITGOOD */ }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66a.c Label Definition File: CWE195_Signed_to_Unsigned_Conversion_Error.label.xml Template File: sources-sink-66a.tmpl.c */ /* * @description * CWE: 195 Signed to Unsigned Conversion Error * BadSource: fgets Read data from the console using fgets() * GoodSource: Positive integer * Sinks: memmove * BadSink : Copy strings using memmove() with the length of data * Flow Variant: 66 Data flow: data passed in an array from one function to another in different source files * * */ #include "std_testcase.h" #define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2) #ifndef OMITBAD /* bad function declaration */ void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66b_badSink(int dataArray[]); void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66_bad() { int data; int dataArray[5]; /* Initialize data */ data = -1; { char inputBuffer[CHAR_ARRAY_SIZE] = ""; /* POTENTIAL FLAW: Read data from the console using fgets() */ if (fgets(inputBuffer, CHAR_ARRAY_SIZE, stdin) != NULL) { /* Convert to int */ data = atoi(inputBuffer); } else { printLine("fgets() failed."); } } /* put data in array */ dataArray[2] = data; CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66b_badSink(dataArray); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66b_goodG2BSink(int dataArray[]); static void goodG2B() { int data; int dataArray[5]; /* Initialize data */ data = -1; /* FIX: Use a positive integer less than &InitialDataSize&*/ data = 100-1; dataArray[2] = data; CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66b_goodG2BSink(dataArray); } void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66_good() { goodG2B(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_66_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
// // UIApplication+KIF.h // MoPub // // Copyright (c) 2013 MoPub. All rights reserved. // #import <UIKit/UIKit.h> @interface UIApplication (KIF) - (NSURL *)lastOpenedURL; - (void)resetLastOpenedURL; @end
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_13.c Label Definition File: CWE195_Signed_to_Unsigned_Conversion_Error.label.xml Template File: sources-sink-13.tmpl.c */ /* * @description * CWE: 195 Signed to Unsigned Conversion Error * BadSource: fgets Read data from the console using fgets() * GoodSource: Positive integer * Sink: memcpy * BadSink : Copy strings using memcpy() with the length of data * Flow Variant: 13 Control flow: if(GLOBAL_CONST_FIVE==5) and if(GLOBAL_CONST_FIVE!=5) * * */ #include "std_testcase.h" #define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2) #ifndef OMITBAD void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_13_bad() { int data; /* Initialize data */ data = -1; if(GLOBAL_CONST_FIVE==5) { { char inputBuffer[CHAR_ARRAY_SIZE] = ""; /* POTENTIAL FLAW: Read data from the console using fgets() */ if (fgets(inputBuffer, CHAR_ARRAY_SIZE, stdin) != NULL) { /* Convert to int */ data = atoi(inputBuffer); } else { printLine("fgets() failed."); } } } { char source[100]; char dest[100] = ""; memset(source, 'A', 100-1); source[100-1] = '\0'; if (data < 100) { /* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative, * the sign conversion could result in a very large number */ memcpy(dest, source, data); dest[data] = '\0'; /* NULL terminate */ } printLine(dest); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B1() - use goodsource and badsink by changing the GLOBAL_CONST_FIVE==5 to GLOBAL_CONST_FIVE!=5 */ static void goodG2B1() { int data; /* Initialize data */ data = -1; if(GLOBAL_CONST_FIVE!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Use a positive integer less than &InitialDataSize&*/ data = 100-1; } { char source[100]; char dest[100] = ""; memset(source, 'A', 100-1); source[100-1] = '\0'; if (data < 100) { /* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative, * the sign conversion could result in a very large number */ memcpy(dest, source, data); dest[data] = '\0'; /* NULL terminate */ } printLine(dest); } } /* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */ static void goodG2B2() { int data; /* Initialize data */ data = -1; if(GLOBAL_CONST_FIVE==5) { /* FIX: Use a positive integer less than &InitialDataSize&*/ data = 100-1; } { char source[100]; char dest[100] = ""; memset(source, 'A', 100-1); source[100-1] = '\0'; if (data < 100) { /* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative, * the sign conversion could result in a very large number */ memcpy(dest, source, data); dest[data] = '\0'; /* NULL terminate */ } printLine(dest); } } void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_13_good() { goodG2B1(); goodG2B2(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_13_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_13_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_53b.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.label.xml Template File: sources-sink-53b.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Set data pointer to the bad buffer * GoodSource: Set data pointer to the good buffer * Sink: memcpy * BadSink : Copy int array to data using memcpy * Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files * * */ #include "std_testcase.h" /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */ #ifndef OMITBAD /* bad function declaration */ void CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_53c_badSink(int * data); void CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_53b_badSink(int * data) { CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_53c_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declaration */ void CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_53c_goodG2BSink(int * data); /* goodG2B uses the GoodSource with the BadSink */ void CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_53b_goodG2BSink(int * data) { CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_53c_goodG2BSink(data); } #endif /* OMITGOOD */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63a.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__src.label.xml Template File: sources-sink-63a.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Initialize data as a large string * GoodSource: Initialize data as a small string * Sinks: cat * BadSink : Copy data to string using wcscat * Flow Variant: 63 Data flow: pointer to data passed from one function to another in different source files * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD /* bad function declaration */ void CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63b_badSink(wchar_t * * dataPtr); void CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63_bad() { wchar_t * data; wchar_t dataBuffer[100]; data = dataBuffer; /* FLAW: Initialize data as a large buffer that is larger than the small buffer used in the sink */ wmemset(data, L'A', 100-1); /* fill with L'A's */ data[100-1] = L'\0'; /* null terminate */ CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63b_badSink(&data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63b_goodG2BSink(wchar_t * * data); static void goodG2B() { wchar_t * data; wchar_t dataBuffer[100]; data = dataBuffer; /* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */ wmemset(data, L'A', 50-1); /* fill with L'A's */ data[50-1] = L'\0'; /* null terminate */ CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63b_goodG2BSink(&data); } void CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63_good() { goodG2B(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_63_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE190_Integer_Overflow__int_fscanf_square_68a.c Label Definition File: CWE190_Integer_Overflow__int.label.xml Template File: sources-sinks-68a.tmpl.c */ /* * @description * CWE: 190 Integer Overflow * BadSource: fscanf Read data from the console using fscanf() * GoodSource: Set data to a small, non-zero number (two) * Sinks: square * GoodSink: Ensure there will not be an overflow before squaring data * BadSink : Square data, which can lead to overflow * Flow Variant: 68 Data flow: data passed as a global variable from one function to another in different source files * * */ #include "std_testcase.h" #include <math.h> int CWE190_Integer_Overflow__int_fscanf_square_68_badData; int CWE190_Integer_Overflow__int_fscanf_square_68_goodG2BData; int CWE190_Integer_Overflow__int_fscanf_square_68_goodB2GData; #ifndef OMITBAD /* bad function declaration */ void CWE190_Integer_Overflow__int_fscanf_square_68b_badSink(); void CWE190_Integer_Overflow__int_fscanf_square_68_bad() { int data; /* Initialize data */ data = 0; /* POTENTIAL FLAW: Read data from the console using fscanf() */ fscanf(stdin, "%d", &data); CWE190_Integer_Overflow__int_fscanf_square_68_badData = data; CWE190_Integer_Overflow__int_fscanf_square_68b_badSink(); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declarations */ void CWE190_Integer_Overflow__int_fscanf_square_68b_goodG2BSink(); void CWE190_Integer_Overflow__int_fscanf_square_68b_goodB2GSink(); /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { int data; /* Initialize data */ data = 0; /* FIX: Use a small, non-zero value that will not cause an integer overflow in the sinks */ data = 2; CWE190_Integer_Overflow__int_fscanf_square_68_goodG2BData = data; CWE190_Integer_Overflow__int_fscanf_square_68b_goodG2BSink(); } /* goodB2G uses the BadSource with the GoodSink */ static void goodB2G() { int data; /* Initialize data */ data = 0; /* POTENTIAL FLAW: Read data from the console using fscanf() */ fscanf(stdin, "%d", &data); CWE190_Integer_Overflow__int_fscanf_square_68_goodB2GData = data; CWE190_Integer_Overflow__int_fscanf_square_68b_goodB2GSink(); } void CWE190_Integer_Overflow__int_fscanf_square_68_good() { goodG2B(); goodB2G(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE190_Integer_Overflow__int_fscanf_square_68_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE190_Integer_Overflow__int_fscanf_square_68_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* * Copyright 2012 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef GrDebugGL_DEFINED #define GrDebugGL_DEFINED #include "SkTArray.h" #include "gl/GrGLInterface.h" class GrFakeRefObj; class GrTextureUnitObj; class GrBufferObj; class GrTextureObj; class GrFrameBufferObj; class GrRenderBufferObj; class GrProgramObj; //////////////////////////////////////////////////////////////////////////////// // This is the main debugging object. It is a singleton and keeps track of // all the other debug objects. class GrDebugGL { public: enum GrObjTypes { kTexture_ObjTypes = 0, kBuffer_ObjTypes, kRenderBuffer_ObjTypes, kFrameBuffer_ObjTypes, kShader_ObjTypes, kProgram_ObjTypes, kTextureUnit_ObjTypes, kObjTypeCount }; GrFakeRefObj *createObj(GrObjTypes type) { GrFakeRefObj *temp = (*gFactoryFunc[type])(); fObjects.push_back(temp); return temp; } GrFakeRefObj *findObject(GrGLuint ID, GrObjTypes type); GrGLuint getMaxTextureUnits() const { return kDefaultMaxTextureUnits; } void setCurTextureUnit(GrGLuint curTextureUnit) { fCurTextureUnit = curTextureUnit; } GrGLuint getCurTextureUnit() const { return fCurTextureUnit; } GrTextureUnitObj *getTextureUnit(int iUnit) { GrAlwaysAssert(0 <= iUnit && kDefaultMaxTextureUnits > iUnit); return fTextureUnits[iUnit]; } void setArrayBuffer(GrBufferObj *arrayBuffer); GrBufferObj *getArrayBuffer() { return fArrayBuffer; } void setElementArrayBuffer(GrBufferObj *elementArrayBuffer); GrBufferObj *getElementArrayBuffer() { return fElementArrayBuffer; } void setTexture(GrTextureObj *texture); void setFrameBuffer(GrFrameBufferObj *frameBuffer); GrFrameBufferObj *getFrameBuffer() { return fFrameBuffer; } void setRenderBuffer(GrRenderBufferObj *renderBuffer); GrRenderBufferObj *getRenderBuffer() { return fRenderBuffer; } void useProgram(GrProgramObj *program); void setPackRowLength(GrGLint packRowLength) { fPackRowLength = packRowLength; } GrGLint getPackRowLength() const { return fPackRowLength; } void setUnPackRowLength(GrGLint unPackRowLength) { fUnPackRowLength = unPackRowLength; } GrGLint getUnPackRowLength() const { return fUnPackRowLength; } static GrDebugGL *getInstance() { // static GrDebugGL Obj; return &Obj; } void report() const; protected: private: // the OpenGLES 2.0 spec says this must be >= 2 static const GrGLint kDefaultMaxTextureUnits = 8; GrGLint fPackRowLength; GrGLint fUnPackRowLength; GrGLuint fMaxTextureUnits; GrGLuint fCurTextureUnit; GrBufferObj * fArrayBuffer; GrBufferObj * fElementArrayBuffer; GrFrameBufferObj *fFrameBuffer; GrRenderBufferObj *fRenderBuffer; GrProgramObj * fProgram; GrTextureObj * fTexture; GrTextureUnitObj *fTextureUnits[kDefaultMaxTextureUnits]; typedef GrFakeRefObj *(*Create)(); static Create gFactoryFunc[kObjTypeCount]; static GrDebugGL Obj; // global store of all objects SkTArray<GrFakeRefObj *> fObjects; GrDebugGL(); ~GrDebugGL(); }; //////////////////////////////////////////////////////////////////////////////// // Helper macro to make creating an object (where you need to get back a derived // type) easier #define GR_CREATE(className, classEnum) \ reinterpret_cast<className *>(GrDebugGL::getInstance()->createObj(classEnum)) //////////////////////////////////////////////////////////////////////////////// // Helper macro to make finding objects less painful #define GR_FIND(id, className, classEnum) \ reinterpret_cast<className *>(GrDebugGL::getInstance()->findObject(id, classEnum)) #endif // GrDebugGL_DEFINED
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE253_Incorrect_Check_of_Function_Return_Value__char_fwrite_16.c Label Definition File: CWE253_Incorrect_Check_of_Function_Return_Value.label.xml Template File: point-flaw-16.tmpl.c */ /* * @description * CWE: 253 Incorrect Check of Return Value * Sinks: fwrite * GoodSink: Correctly check if fwrite() failed * BadSink : Incorrectly check if fwrite() failed * Flow Variant: 16 Control flow: while(1) * * */ #include "std_testcase.h" #ifndef _WIN32 #include <wchar.h> #endif #ifndef OMITBAD void CWE253_Incorrect_Check_of_Function_Return_Value__char_fwrite_16_bad() { while(1) { /* FLAW: fwrite() might fail, in which case the return value will not be equal to strlen(data), * but we are checking to see if the return value is less than 0 */ if (fwrite((char *)"string", sizeof(char), strlen("string"), stdout) < 0) { printLine("fwrite failed!"); } break; } } #endif /* OMITBAD */ #ifndef OMITGOOD /* good1() uses the GoodSinkBody in the while loop */ static void good1() { while(1) { /* FIX: check for the correct return value */ if (fwrite((char *)"string", sizeof(char), strlen("string"), stdout) != strlen("string")) { printLine("fwrite failed!"); } break; } } void CWE253_Incorrect_Check_of_Function_Return_Value__char_fwrite_16_good() { good1(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE253_Incorrect_Check_of_Function_Return_Value__char_fwrite_16_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE253_Incorrect_Check_of_Function_Return_Value__char_fwrite_16_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* * @HEADER * * *********************************************************************** * * Zoltan Toolkit for Load-balancing, Partitioning, Ordering and Coloring * Copyright 2012 Sandia Corporation * * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, * the U.S. Government retains certain rights in this software. * * 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 Corporation nor the names of the * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE * 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. * * Questions? Contact Karen Devine kddevin@sandia.gov * Erik Boman egboman@sandia.gov * * *********************************************************************** * * @HEADER */ #ifndef __RCB_H #define __RCB_H #include "shared.h" #include "rcb_const.h" #ifdef __cplusplus /* if C++, define the rest of this header file as extern C */ extern "C" { #endif /* Data structures for parallel RCB */ struct rcb_tree { /* tree of RCB cuts */ double cut; /* position of cut */ int dim; /* dimension (012) of cut */ int parent; /* parent of this node in cut tree */ int left_leaf; /* left child of this node in cut tree */ int right_leaf; /* right child of this node in cut tree */ }; struct rcb_median { /* RCB cut info */ double totallo, totalhi; /* weight in each half of active partition */ double valuelo, valuehi; /* position of dot(s) nearest to cut */ double wtlo, wthi; /* total weight of dot(s) at that position */ ZOLTAN_GNO_TYPE countlo, counthi; /* # of dots at that position */ int proclo, prochi; /* unique proc who owns a nearest dot */ }; struct rcb_box { /* bounding box */ double lo[3], hi[3]; /* xyz lo/hi bounds */ }; typedef struct RCB_Struct { ZOLTAN_ID_PTR Global_IDs; /* Pointer to array of global IDs; global ID of Dots[i] starts in Global_IDs[i*zz->Num_GID]. Because zz->Num_GID is determined at runtime, this info is most easily stored, allocated and reallocated separately from Dots. This array is NOT used if Zoltan_RB_Use_IDs returns FALSE. */ ZOLTAN_ID_PTR Local_IDs; /* Pointer to array of local IDs; local ID of Dots[i] starts in Local_IDs[i*zz->Num_LID]. Because zz->Num_LID is determined at runtime, this info is most easily stored, allocated and reallocated separately from Dots. This array is NOT used if Zoltan_RB_Use_IDs returns FALSE. */ struct Dot_Struct Dots; /* coordinates, weights, etc */ struct rcb_tree *Tree_Ptr; struct rcb_box *Box; int Num_Dim; /* Number of dimensions in the input geometry. */ ZZ_Transform Tran; /* transformation for degenerate geometry */ } RCB_STRUCT; extern int Zoltan_RCB_Build_Structure(ZZ *, int *, int *, int, double, int,int); #ifdef __cplusplus } /* closing bracket for extern "C" */ #endif #endif
// // Created by juanfra on 20/11/16. // #ifndef ARQUI2016_IPCSTRUCTS_H #define ARQUI2016_IPCSTRUCTS_H typedef struct { char** mutexNames; char** pipesNames; }ipcs; #endif //ARQUI2016_IPCSTRUCTS_H
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_MEDIA_ROUTER_BROWSER_PRESENTATION_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ #define COMPONENTS_MEDIA_ROUTER_BROWSER_PRESENTATION_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ #include <string> #include "components/media_router/browser/presentation/presentation_service_delegate_observers.h" #include "content/public/browser/presentation_service_delegate.h" #include "content/public/browser/web_contents_user_data.h" namespace content { class WebContents; } // namespace content namespace media_router { class LocalPresentationManager; // Implements the receiver side of Presentation API for local presentation // (an offscreen presentation that is mirrored to a wireless display, or a // presentation on a wired display). // Created with the WebContents for a local presentation. Each // instance is tied to a single local presentation whose ID is given during // construction. As such, the receiver APIs are contextual with the local // presentation. Only the main frame of the WebContents is allowed to // make receiver Presentation API requests; requests made from any other frame // will be rejected. class ReceiverPresentationServiceDelegateImpl : public content::WebContentsUserData< ReceiverPresentationServiceDelegateImpl>, public content::ReceiverPresentationServiceDelegate { public: // Creates an instance of ReceiverPresentationServiceDelegateImpl under // |web_contents| and registers it as the receiver of the local // presentation |presentation_id| with LocalPresentationManager. // No-op if a ReceiverPresentationServiceDelegateImpl instance already // exists under |web_contents|. This class does not take ownership of // |web_contents|. static void CreateForWebContents(content::WebContents* web_contents, const std::string& presentation_id); ReceiverPresentationServiceDelegateImpl( const ReceiverPresentationServiceDelegateImpl&) = delete; ReceiverPresentationServiceDelegateImpl& operator=( const ReceiverPresentationServiceDelegateImpl&) = delete; // content::ReceiverPresentationServiceDelegate implementation. void AddObserver( int render_process_id, int render_frame_id, content::PresentationServiceDelegate::Observer* observer) override; void RemoveObserver(int render_process_id, int render_frame_id) override; void Reset(int render_process_id, int render_frame_id) override; void RegisterReceiverConnectionAvailableCallback( const content::ReceiverConnectionAvailableCallback& receiver_available_callback) override; private: friend class content::WebContentsUserData< ReceiverPresentationServiceDelegateImpl>; ReceiverPresentationServiceDelegateImpl(content::WebContents* web_contents, const std::string& presentation_id); // Reference to the WebContents that owns this instance. content::WebContents* const web_contents_; const std::string presentation_id_; // This is an unowned pointer to the LocalPresentationManager. LocalPresentationManager* const local_presentation_manager_; PresentationServiceDelegateObservers observers_; WEB_CONTENTS_USER_DATA_KEY_DECL(); }; } // namespace media_router #endif // COMPONENTS_MEDIA_ROUTER_BROWSER_PRESENTATION_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_INSTANT_INSTANT_LOADER_DELEGATE_H_ #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_DELEGATE_H_ #pragma once #include "base/string16.h" #include "chrome/common/instant_types.h" class GURL; namespace gfx { class Rect; } class InstantLoader; // InstantLoader's delegate. This interface is implemented by InstantController. class InstantLoaderDelegate { public: // Invoked when the status (either http_status_ok or ready) has changed. virtual void InstantStatusChanged(InstantLoader* loader) = 0; // Invoked when the loader has suggested text. virtual void SetSuggestedTextFor( InstantLoader* loader, const string16& text, InstantCompleteBehavior behavior) = 0; // Returns the bounds of instant. virtual gfx::Rect GetInstantBounds() = 0; // Returns true if instant should be committed on mouse up. virtual bool ShouldCommitInstantOnMouseUp() = 0; // Invoked when the the loader should be committed. virtual void CommitInstantLoader(InstantLoader* loader) = 0; // Invoked if the loader was created with the intention that the site supports // instant, but it turned out the site doesn't support instant. virtual void InstantLoaderDoesntSupportInstant(InstantLoader* loader) = 0; // Adds the specified url to the set of urls instant won't prefetch for. virtual void AddToBlacklist(InstantLoader* loader, const GURL& url) = 0; // Invoked if the loader swaps to a different TabContents. virtual void SwappedTabContents(InstantLoader* loader) = 0; // Invoked when the webcontents created by the loader is focused. virtual void InstantLoaderContentsFocused() = 0; protected: virtual ~InstantLoaderDelegate() {} }; #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_DELEGATE_H_
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Gearmand client and server library. * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * 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. * * * The names of its contributors may not 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 <sys/types.h> #include <libgearman/gearman.h> #include <libtest/visibility.h> #include <boost/shared_ptr.hpp> #include "tests/workers/v2/called.h" struct worker_handle_st { public: worker_handle_st(); ~worker_handle_st(); void set_shutdown(); bool is_shutdown(); bool shutdown(); void kill(); void set_worker_id(gearman_worker_st*); libtest::thread::Barrier* sync_point(); void wait(); bool check(); volatile bool failed_startup; boost::shared_ptr<libtest::thread::Thread> _thread; private: bool _shutdown; libtest::thread::Mutex _shutdown_lock; gearman_id_t _worker_id; libtest::thread::Barrier _sync_point; }; struct worker_handles_st { worker_handles_st(); ~worker_handles_st(); // Warning, this will not clean up memory void kill_all(); void reset(); void push(worker_handle_st *arg); private: std::vector<worker_handle_st *> _workers; }; #pragma once LIBTEST_API struct worker_handle_st *test_worker_start(in_port_t port, const char *namespace_key, const char *function_name, const gearman_function_t &worker_fn, void *context, gearman_worker_options_t options, int timeout= 0); LIBTEST_API bool test_worker_stop(struct worker_handle_st *);
// 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 SKY_SHELL_UI_PLATFORM_IMPL_H_ #define SKY_SHELL_UI_PLATFORM_IMPL_H_ #include "lib/ftl/macros.h" #include "flutter/sky/engine/public/platform/Platform.h" namespace sky { namespace shell { class PlatformImpl : public blink::Platform { public: explicit PlatformImpl(); ~PlatformImpl() override; // blink::Platform methods: std::string defaultLocale() override; ftl::TaskRunner* GetUITaskRunner() override; ftl::TaskRunner* GetIOTaskRunner() override; private: FTL_DISALLOW_COPY_AND_ASSIGN(PlatformImpl); }; } // namespace shell } // namespace sky #endif // SKY_SHELL_UI_PLATFORM_IMPL_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 EXTENSIONS_BROWSER_EXTENSION_PREF_STORE_H_ #define EXTENSIONS_BROWSER_EXTENSION_PREF_STORE_H_ #include <string> #include "base/macros.h" #include "components/prefs/value_map_pref_store.h" #include "extensions/browser/extension_pref_value_map.h" // A (non-persistent) PrefStore implementation that holds effective preferences // set by extensions. These preferences are managed by and fetched from an // ExtensionPrefValueMap. class ExtensionPrefStore : public ValueMapPrefStore, public ExtensionPrefValueMap::Observer { public: // Constructs an ExtensionPrefStore for a regular or an incognito profile. ExtensionPrefStore(ExtensionPrefValueMap* extension_pref_value_map, bool incognito_pref_store); ExtensionPrefStore(const ExtensionPrefStore&) = delete; ExtensionPrefStore& operator=(const ExtensionPrefStore&) = delete; // Overrides for ExtensionPrefValueMap::Observer: void OnInitializationCompleted() override; void OnPrefValueChanged(const std::string& key) override; void OnExtensionPrefValueMapDestruction() override; protected: ~ExtensionPrefStore() override; private: ExtensionPrefValueMap* extension_pref_value_map_; // Weak pointer. bool incognito_pref_store_; }; #endif // EXTENSIONS_BROWSER_EXTENSION_PREF_STORE_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This is a glue file, which allows third party code to call into our profiler // without having to include most any functions from base. #ifndef BASE_PROFILER_ALTERNATE_TIMER_H_ #define BASE_PROFILER_ALTERNATE_TIMER_H_ #include "base/base_export.h" namespace tracked_objects { enum TimeSourceType { TIME_SOURCE_TYPE_WALL_TIME, TIME_SOURCE_TYPE_TCMALLOC }; // Provide type for an alternate timer function. typedef unsigned int NowFunction(); // Environment variable name that is used to activate alternate timer profiling // (such as using TCMalloc allocations to provide a pseudo-timer) for tasks // instead of wall clock profiling. extern const char kAlternateProfilerTime[]; // Set an alternate timer function to replace the OS time function when // profiling. Typically this is called by an allocator that is providing a // function that indicates how much memory has been allocated on any given // thread. void SetAlternateTimeSource(NowFunction* now_function, TimeSourceType type); // Gets the pointer to a function that was set via SetAlternateTimeSource(). // Returns NULL if no set was done prior to calling GetAlternateTimeSource. NowFunction* GetAlternateTimeSource(); // Returns the type of the currently set time source. BASE_EXPORT TimeSourceType GetTimeSourceType(); } // namespace tracked_objects #endif // BASE_PROFILER_ALTERNATE_TIMER_H_
/* * Copyright (c) 2009, Michael Lehn * * 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 FLENS development group 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 FLENS_BLAS_LEVEL1_DOT_H #define FLENS_BLAS_LEVEL1_DOT_H 1 #include <flens/vectortypes/vectortypes.h> namespace flens { namespace blas { template <typename X, typename Y, typename T> void dot(const DenseVector<X> &x, const DenseVector<Y> &y, T &result); template <typename X, typename Y, typename T> void dotc(const DenseVector<X> &x, const DenseVector<Y> &y, T &result); template <typename X, typename Y, typename T> void dotu(const DenseVector<X> &x, const DenseVector<Y> &y, T &result); template <typename X, typename Y> typename CompatibleType<typename X::ElementType, typename Y::ElementType>::Type dot(const DenseVector<X> &x, const DenseVector<Y> &y); template <typename X, typename Y> typename CompatibleType<typename X::ElementType, typename Y::ElementType>::Type dotc(const DenseVector<X> &x, const DenseVector<Y> &y); template <typename X, typename Y> typename CompatibleType<typename X::ElementType, typename Y::ElementType>::Type dotu(const DenseVector<X> &x, const DenseVector<Y> &y); } } // namespace blas, flens #endif // FLENS_BLAS_LEVEL1_DOT_H
/* * Copyright (c) 2014, CETIC. * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. */ /** * \file * Simple CoAP Library * \author * 6LBR Team <6lbr@cetic.be> */ #ifndef COAP_BINDING_H #define COAP_BINDING_H #include "contiki.h" #include "contiki-net.h" #include "rest-engine.h" #include "coap-binding-nvm.h" #ifdef COAP_BINDING_CONF_ENABLED #define COAP_BINDING_ENABLED COAP_BINDING_CONF_ENABLED #else #define COAP_BINDING_ENABLED 1 #endif #define COAP_BINDING_FLAGS_NVM_BINDING_VALID 0x8000 #define COAP_BINDING_FLAGS_PMIN_VALID 0x0001 #define COAP_BINDING_FLAGS_PMAX_VALID 0x0002 #define COAP_BINDING_FLAGS_ST_VALID 0x0004 #define COAP_BINDING_FLAGS_LT_VALID 0x0008 #define COAP_BINDING_FLAGS_GT_VALID 0x0010 struct coap_binding_cond_s { uint32_t flags; uint32_t pmin; uint32_t pmax; uint32_t step; int32_t less_than; int32_t greater_than; }; typedef struct coap_binding_cond_s coap_binding_cond_t; struct coap_resource_data_s { int32_t last_value; int32_t last_sent_value; uint32_t last_sent_time; }; typedef struct coap_resource_data_s coap_resource_data_t; struct coap_binding_s { struct coap_binding_s* next; resource_t * resource; uip_ip6addr_t dest_addr; uint16_t dest_port; char uri[COAP_BINDING_MAX_URI_SIZE]; coap_binding_cond_t cond; coap_resource_data_t data; }; typedef struct coap_binding_s coap_binding_t; struct coap_full_resource_s { struct coap_full_resource_s *next; resource_t *coap_resource; uint32_t flags; void (*update_value)(coap_resource_data_t *data); coap_binding_cond_t trigger; coap_resource_data_t data; char const * name; }; typedef struct coap_full_resource_s coap_full_resource_t; void coap_binding_serialize(coap_binding_t const *binding, nvm_binding_data_t *store); int coap_binding_deserialize(nvm_binding_data_t const *store, coap_binding_t *binding); int coap_binding_parse_filter_tag(char *p, coap_binding_cond_t *binding_cond, char *data, char *max, int resource_type); int coap_binding_parse_filters(char *buffer, size_t len, coap_binding_cond_t *binding_cond, int resource_type); int coap_binding_trigger_cond(coap_binding_cond_t * binding_cond, coap_resource_data_t *resource_data); void coap_binding_add_resource(coap_full_resource_t *resource); void coap_binding_init(void); #endif
#pragma once namespace common { struct Vector4; struct Matrix44; struct Vector3 { float x,y,z; Vector3() : x(0), y(0), z(0) {} Vector3(float x0, float y0, float z0) : x(x0), y(y0), z(z0) {} Vector3(const Vector4 &rhs); bool IsEmpty() const; float Length() const; float LengthRoughly(const Vector3 &rhs) const; Vector3 Normal() const; void Normalize(); float DotProduct( const Vector3& v ) const; Vector3 CrossProduct( const Vector3& v ) const; Vector3 MultiplyNormal( const Matrix44& rhs ) const; Vector3 Interpolate( const Vector3 &v, const float alpha) const; Vector3 operator + () const; Vector3 operator - () const; Vector3 operator + ( const Vector3& rhs ) const; Vector3 operator - ( const Vector3& rhs ) const; Vector3& operator += ( const Vector3& rhs ); Vector3& operator -= ( const Vector3& rhs ); Vector3& operator *= ( const Vector3& rhs ); Vector3& operator /= ( const Vector3& rhs ); Vector3 operator * ( const Matrix44& rhs ) const; Vector3& operator *= ( const Matrix44& rhs ); template <class T> Vector3 operator * ( T t ) const { return Vector3(x*t, y*t, z*t); } template <class T> Vector3 operator / ( T t ) const { return Vector3(x/t, y/t, z/t); } template <class T> Vector3& operator *= ( T t ) { *this = Vector3(x*t, y*t, z*t); return *this; } template <class T> Vector3& operator /= ( T t ) { *this = Vector3(x/t, y/t, z/t); return *this; } static Vector3 Min; static Vector3 Max; static Vector3 Up; static Vector3 Right; static Vector3 Forward; }; }
// // MVFrame.h // MVSDK // // Created by Jomy on 16/1/28. // #import <Foundation/Foundation.h> #import "MVCampaign.h" @interface MVFrame : NSObject /*! @property @abstract The dataTemplate of the frame */ @property (nonatomic, assign) MVAdTemplateType templateType; /*! @property @abstract The ad source of the frame */ @property (nonatomic, assign) MVAdSourceType sourceType; /*! @property @abstract The timestap of the frame */ @property (nonatomic, assign) double timestamp; /*! @property @abstract The id of the frame */ @property (nonatomic, strong) NSString *frameId; /*! @property @abstract The native ads contained in this frame. Array of MVCampaign objects. */ @property (nonatomic, strong) NSArray *nativeAds; @end
/**************************************************************************** Copyright (c) 2014 cocos2d-x.org Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. http://www.cocos2d-x.org 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 __cocos2d_libs__Sprite3DReader__ #define __cocos2d_libs__Sprite3DReader__ #include "math/Vec2.h" #include "editor-support/cocostudio/CocosStudioExport.h" #include "editor-support/cocostudio/WidgetReader/NodeReaderProtocol.h" #include "editor-support/cocostudio/WidgetReader/NodeReaderDefine.h" namespace tinyxml2 { class XMLAttribute; } namespace cocostudio { class CC_STUDIO_DLL Sprite3DReader : public cocos2d::Ref, public NodeReaderProtocol { DECLARE_CLASS_NODE_READER_INFO public: Sprite3DReader(); ~Sprite3DReader(); static Sprite3DReader* getInstance(); /** @deprecated Use method destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purge(); static void destroyInstance(); flatbuffers::Offset<flatbuffers::Table> createOptionsWithFlatBuffers(const tinyxml2::XMLElement* objectData, flatbuffers::FlatBufferBuilder* builder); void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* sprite3DOptions); cocos2d::Node* createNodeWithFlatBuffers(const flatbuffers::Table* sprite3DOptions); protected: cocos2d::Vec2 getVec2Attribute(const tinyxml2::XMLAttribute* attribute) const; }; } #endif /* defined(__cocos2d_libs__Sprite3DReader__) */
// // main.h // HelloFFmpeg // // Created by burt on 2014. 2. 13.. // Copyright (c) 2014년 burt. All rights reserved. // #ifndef __HelloFFmpeg__main__ #define __HelloFFmpeg__main__ #include <iostream> #endif /* defined(__HelloFFmpeg__main__) */
/*============================================================================ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic Package, Release 3c, by John R. Hauser. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of California. 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 University 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 REGENTS 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 REGENTS 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 <stdbool.h> #include <stdint.h> #include "platform.h" #include "internals.h" #include "specialize.h" #include "softfloat.h" float16_t f16_mul( float16_t a, float16_t b ) { union ui16_f16 uA; uint_fast16_t uiA; bool signA; int_fast8_t expA; uint_fast16_t sigA; union ui16_f16 uB; uint_fast16_t uiB; bool signB; int_fast8_t expB; uint_fast16_t sigB; bool signZ; uint_fast16_t magBits; struct exp8_sig16 normExpSig; int_fast8_t expZ; uint_fast32_t sig32Z; uint_fast16_t sigZ, uiZ; union ui16_f16 uZ; /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ uA.f = a; uiA = uA.ui; signA = signF16UI( uiA ); expA = expF16UI( uiA ); sigA = fracF16UI( uiA ); uB.f = b; uiB = uB.ui; signB = signF16UI( uiB ); expB = expF16UI( uiB ); sigB = fracF16UI( uiB ); signZ = signA ^ signB; /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ if ( expA == 0x1F ) { if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN; magBits = expB | sigB; goto infArg; } if ( expB == 0x1F ) { if ( sigB ) goto propagateNaN; magBits = expA | sigA; goto infArg; } /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ if ( ! expA ) { if ( ! sigA ) goto zero; normExpSig = softfloat_normSubnormalF16Sig( sigA ); expA = normExpSig.exp; sigA = normExpSig.sig; } if ( ! expB ) { if ( ! sigB ) goto zero; normExpSig = softfloat_normSubnormalF16Sig( sigB ); expB = normExpSig.exp; sigB = normExpSig.sig; } /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ expZ = expA + expB - 0xF; sigA = (sigA | 0x0400)<<4; sigB = (sigB | 0x0400)<<5; sig32Z = (uint_fast32_t) sigA * sigB; sigZ = sig32Z>>16; if ( sig32Z & 0xFFFF ) sigZ |= 1; if ( sigZ < 0x4000 ) { --expZ; sigZ <<= 1; } return softfloat_roundPackToF16( signZ, expZ, sigZ ); /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ propagateNaN: uiZ = softfloat_propagateNaNF16UI( uiA, uiB ); goto uiZ; /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ infArg: if ( ! magBits ) { softfloat_raiseFlags( softfloat_flag_invalid ); uiZ = defaultNaNF16UI; } else { uiZ = packToF16UI( signZ, 0x1F, 0 ); } goto uiZ; /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ zero: uiZ = packToF16UI( signZ, 0, 0 ); uiZ: uZ.ui = uiZ; return uZ.f; }
/** * @project: irCbot - An Internet Relay Chat bot written in C * @file: constants.h * @author: Djole, King_Hual <djolel@net.dut.edu.vn>, <king_hell@abv.bg> */ #include "constants.h"
// This code contains NVIDIA Confidential Information and is disclosed to you // under a form of NVIDIA software license agreement provided separately to you. // // Notice // NVIDIA Corporation and its licensors retain all intellectual property and // proprietary rights in and to this software and related documentation and // any modifications thereto. Any use, reproduction, disclosure, or // distribution of this software and related documentation without an express // license agreement from NVIDIA Corporation is strictly prohibited. // // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. // // Information and code furnished is believed to be accurate and reliable. // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such // information or for any infringement of patents or other rights of third parties that may // result from its use. No license is granted by implication or otherwise under any patent // or patent rights of NVIDIA Corporation. Details are subject to change without notice. // This code supersedes and replaces all information previously supplied. // NVIDIA Corporation products are not authorized for use as critical // components in life support devices or systems without express written approval of // NVIDIA Corporation. // // Copyright (c) 2008-2012 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_FOUNDATION_PX_STRING_H #define PX_FOUNDATION_PX_STRING_H #include "foundation/PxPreprocessor.h" #if defined PX_WINDOWS #include "foundation/windows/PxWindowsString.h" #elif defined PX_X360 #include "foundation/xbox360/PxXbox360String.h" #elif (defined PX_LINUX || defined PX_APPLE || defined PX_ANDROID) #include "foundation/linux/PxLinuxString.h" #elif defined PX_PS3 #include "foundation/ps3/PxPS3String.h" #elif defined PX_PSP2 #include "foundation/psp2/PxPSP2String.h" #else #error "Platform not supported!" #endif #endif
/****************************************************************************** * The MIT License (MIT) * * Copyright (c) 2016-2018 Baldur Karlsson * * 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. ******************************************************************************/ enum ShaderType { eShaderGLSL, eShaderGLSLES, eShaderVulkan }; #include <string> #include <vector> void GenerateGLSLShader(std::vector<std::string> &sources, ShaderType type, const std::string &defines, const std::string &shader, int version, bool uniforms = true);
/* * fastsid.h - MOS6581 (SID) emulation. * * Written by * Teemu Rantanen <tvr@cs.hut.fi> * * This file is part of VICE, the Versatile Commodore Emulator. * See README for copyright notice. * * 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. * */ #ifndef VICE_FASTSID_H #define VICE_FASTSID_H #include "types.h" #include "sid.h" extern sid_engine_t fastsid_hooks; int fastsid_calculate_samples_mix(sound_t *psid, SWORD *pbuf, int nr, int interleave, int *delta_t); #endif
/* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ #include "obj.h" extern long lseek(); /* * Parts of the output file. */ #undef PARTEMIT #undef PARTRELO #undef PARTNAME #undef PARTCHAR #undef PARTDBUG #undef NPARTS #define PARTEMIT 0 #define PARTRELO 1 #define PARTNAME 2 #define PARTCHAR 3 #ifdef SYMDBUG #define PARTDBUG 4 #else #define PARTDBUG 3 #endif #define NPARTS (PARTDBUG + 1) static long offset[MAXSECT]; static int outfile; static long outseek[NPARTS]; static long currpos; static long rd_base; #define OUTSECT(i) \ (outseek[PARTEMIT] = offset[i]) #define BEGINSEEK(p, o) \ (outseek[(p)] = (o)) static int sectionnr; static void OUTREAD(p, b, n) char *b; long n; { register long l = outseek[p]; if (currpos != l) { lseek(outfile, l, 0); } rd_bytes(outfile, b, n); l += n; currpos = l; outseek[p] = l; } /* * Open the output file according to the chosen strategy. */ int rd_open(f) char *f; { if ((outfile = open(f, 0)) < 0) return 0; return rd_fdopen(outfile); } static int offcnt; int rd_fdopen(fd) { register int i; for (i = 0; i < NPARTS; i++) outseek[i] = 0; offcnt = 0; rd_base = lseek(fd, 0L, 1); if (rd_base < 0) { return 0; } currpos = rd_base; outseek[PARTEMIT] = currpos; outfile = fd; sectionnr = 0; return 1; } void rd_close() { close(outfile); outfile = -1; } int rd_fd() { return outfile; } void rd_ohead(head) register struct outhead *head; { register long off; OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD); #if BYTE_ORDER == 0x0123 if (sizeof(struct outhead) != SZ_HEAD) #endif { register char *c = (char *) head + (SZ_HEAD-4); head->oh_nchar = get4(c); c -= 4; head->oh_nemit = get4(c); c -= 2; head->oh_nname = uget2(c); c -= 2; head->oh_nrelo = uget2(c); c -= 2; head->oh_nsect = uget2(c); c -= 2; head->oh_flags = uget2(c); c -= 2; head->oh_stamp = uget2(c); c -= 2; head->oh_magic = uget2(c); } off = OFF_RELO(*head) + rd_base; BEGINSEEK(PARTRELO, off); off += (long) head->oh_nrelo * SZ_RELO; BEGINSEEK(PARTNAME, off); off += (long) head->oh_nname * SZ_NAME; BEGINSEEK(PARTCHAR, off); #ifdef SYMDBUG off += head->oh_nchar; BEGINSEEK(PARTDBUG, off); #endif } void rd_rew_relos(head) register struct outhead *head; { register long off = OFF_RELO(*head) + rd_base; BEGINSEEK(PARTRELO, off); } void rd_sect(sect, cnt) register struct outsect *sect; register unsigned int cnt; { register char *c = (char *) sect + cnt * SZ_SECT; OUTREAD(PARTEMIT, (char *) sect, (long)cnt * SZ_SECT); sect += cnt; offcnt += cnt; while (cnt--) { sect--; #if BYTE_ORDER == 0x0123 if (sizeof(struct outsect) != SZ_SECT) #endif { c -= 4; sect->os_lign = get4(c); c -= 4; sect->os_flen = get4(c); c -= 4; sect->os_foff = get4(c); c -= 4; sect->os_size = get4(c); c -= 4; sect->os_base = get4(c); } offset[--offcnt] = sect->os_foff + rd_base; } } void rd_outsect(s) { OUTSECT(s); sectionnr = s; } /* * We don't have to worry about byte order here. */ void rd_emit(emit, cnt) char *emit; long cnt; { OUTREAD(PARTEMIT, emit, cnt); offset[sectionnr] += cnt; } void rd_relo(relo, cnt) register struct outrelo *relo; register unsigned int cnt; { OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); #if BYTE_ORDER == 0x0123 if (sizeof(struct outrelo) != SZ_RELO) #endif { register char *c = (char *) relo + (long) cnt * SZ_RELO; relo += cnt; while (cnt--) { relo--; c -= 4; relo->or_addr = get4(c); c -= 2; relo->or_nami = uget2(c); relo->or_sect = *--c; relo->or_type = *--c; } } } void rd_name(name, cnt) register struct outname *name; register unsigned int cnt; { OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME); #if BYTE_ORDER == 0x0123 if (sizeof(struct outname) != SZ_NAME) #endif { register char *c = (char *) name + (long) cnt * SZ_NAME; name += cnt; while (cnt--) { name--; c -= 4; name->on_valu = get4(c); c -= 2; name->on_desc = uget2(c); c -= 2; name->on_type = uget2(c); c -= 4; name->on_foff = get4(c); } } } void rd_string(addr, len) char *addr; long len; { OUTREAD(PARTCHAR, addr, len); } #ifdef SYMDBUG void rd_dbug(buf, size) char *buf; long size; { OUTREAD(PARTDBUG, buf, size); } #endif
#if defined(_MSC_VER) # include <openssl/opensslconf_vs.h> #elif defined( __WIN32__ ) || defined( _WIN32 ) # include <openssl/opensslconf_win32.h> #elif TARGET_OS_IPHONE_SIMULATOR || TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE || TARGET_IPHONE # include <openssl/opensslconf_ios.h> #elif defined(__APPLE_CC__) # include <openssl/opensslconf_osx.h> #elif defined (__ANDROID__) # include <openssl/opensslconf_android.h> #endif
/*****************************************************************************\ * $Id: filldentry.c 82 2006-02-15 10:20:25Z garlick $ ***************************************************************************** * Copyright (C) 2001-2008 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Jim Garlick <garlick@llnl.gov>. * UCRL-CODE-2003-006. * * This file is part of Scrub, a program for erasing disks. * For details, see <http://www.llnl.gov/linux/scrub/>. * * Scrub 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. * * Scrub 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 Scrub; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. \*****************************************************************************/ #if HAVE_CONFIG_H #include "config.h" #endif #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <libgen.h> #include <assert.h> #include "filldentry.h" #include "util.h" extern char *prog; /* fsync(2) directory. */ static void dirsync(char *dir) { #if defined(_AIX) /* FIXME: need HAVE_FSYNC_DIR macro */ sync(); #else int fd; fd = open(dir, O_RDONLY); if (fd < 0) { fprintf(stderr, "%s: open: %s\n", prog, strerror(errno)); exit(1); } if (fsync(fd) < 0) { fprintf(stderr, "%s: fsync: %s\n", prog, strerror(errno)); exit(1); } if (close(fd) < 0) { fprintf(stderr, "%s: close: %s\n", prog, strerror(errno)); exit(1); } #endif } /* Construct a new name for 'old' by replacing its file component with * a string of 'pat' characters. Caller must free result. */ static char * newname(char *old, int pat) { char *new; char *base; assert(old != NULL); assert(strlen(old) > 0); assert(pat != 0); assert(pat <= 0xff); new = strdup(old); if (new) { if ((base = strrchr(new, '/'))) base++; else base = new; memset(base, pat, strlen(base)); } return new; } /* Rename file to pattern and fsync the directory. * Modifies 'path' so it is valid on successive calls. */ void filldentry(char *path, int pat) { char *new = newname(path, pat); char *cpy = strdup(path); char *dir; assert(strlen(cpy) == strlen(new)); if (!cpy || !new) { fprintf(stderr, "%s: out of memory\n", prog); exit(1); } if (rename(path, new) == -1) { fprintf(stderr, "%s: rename %s to %s: %s\n", prog, path, new, strerror(errno)); exit(1); } dir = dirname(cpy); dirsync(dir); free(cpy); assert(strlen(path) == strlen(new)); strcpy(path, new); free(new); } /* * vi:tabstop=4 shiftwidth=4 expandtab */
/*************************************************************************/ /* video_stream.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* 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 VIDEO_STREAM_H #define VIDEO_STREAM_H #include "scene/resources/texture.h" class VideoStreamPlayback : public Resource { GDCLASS(VideoStreamPlayback, Resource); protected: static void _bind_methods(); public: typedef int (*AudioMixCallback)(void *p_udata, const int16_t *p_data, int p_frames); virtual void stop() = 0; virtual void play() = 0; virtual bool is_playing() const = 0; virtual void set_paused(bool p_paused) = 0; virtual bool is_paused(bool p_paused) const = 0; virtual void set_loop(bool p_enable) = 0; virtual bool has_loop() const = 0; virtual float get_length() const = 0; virtual float get_playback_position() const = 0; virtual void seek(float p_time) = 0; virtual void set_audio_track(int p_idx) = 0; //virtual int mix(int16_t* p_bufer,int p_frames)=0; virtual Ref<Texture> get_texture() = 0; virtual void update(float p_delta) = 0; virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0; virtual int get_channels() const = 0; virtual int get_mix_rate() const = 0; VideoStreamPlayback(); }; class VideoStream : public Resource { GDCLASS(VideoStream, Resource); OBJ_SAVE_TYPE(VideoStream); //children are all saved as AudioStream, so they can be exchanged public: virtual void set_audio_track(int p_track) = 0; virtual Ref<VideoStreamPlayback> instance_playback() = 0; VideoStream() {} }; #endif
/* This provides unification of code over STM32 subfamilies */ /* * This file is part of the libopencm3 project. * * 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 3 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see <http://www.gnu.org/licenses/>. */ #include <libopencm3/cm3/common.h> #include <libopencm3/stm32/memorymap.h> #if defined(STM32F0) # include <libopencm3/stm32/f0/dma.h> #elif defined(STM32F1) # include <libopencm3/stm32/f1/dma.h> #elif defined(STM32F2) # include <libopencm3/stm32/f2/dma.h> #elif defined(STM32F3) # include <libopencm3/stm32/f3/dma.h> #elif defined(STM32F4) # include <libopencm3/stm32/f4/dma.h> #elif defined(STM32L1) # include <libopencm3/stm32/l1/dma.h> #else # error "stm32 family not defined." #endif
// This file was generated based on 'C:\ProgramData\Uno\Packages\Android\0.19.1\Android\android\util\$.uno'. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Android.Base.Wrappers.IJWrapper.h> #include <Android.java.lang.Object.h> #include <jni.h> #include <Uno.IDisposable.h> namespace g{namespace Android{namespace android{namespace util{struct TypedValue;}}}} namespace g{namespace Android{namespace java{namespace lang{struct String;}}}} namespace g{ namespace Android{ namespace android{ namespace util{ // public sealed extern class TypedValue :5086 // { ::g::Android::java::lang::Object_type* TypedValue_typeof(); void TypedValue___Init2_fn(); void TypedValue__get_COMPLEX_UNIT_DIP_fn(int* __retval); void TypedValue__toString_fn(TypedValue* __this, ::g::Android::java::lang::String** __retval); void TypedValue__toString_IMPL_20716_fn(bool* arg0_, jobject* arg1_, uObject** __retval); struct TypedValue : ::g::Android::java::lang::Object { static jclass _javaClass2_; static jclass& _javaClass2() { return _javaClass2_; } static jfieldID COMPLEX_UNIT_DIP_20678_ID_; static jfieldID& COMPLEX_UNIT_DIP_20678_ID() { return COMPLEX_UNIT_DIP_20678_ID_; } static jmethodID toString_20716_ID_; static jmethodID& toString_20716_ID() { return toString_20716_ID_; } static void _Init2(); static uObject* toString_IMPL_20716(bool arg0_, jobject arg1_); static int COMPLEX_UNIT_DIP(); }; // } }}}} // ::g::Android::android::util
/* * Machine-dependent uOS declarations for MSP430. * * Copyright (C) 2009 Serge Vakulenko, <vak@cronyx.ru> * * This file 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. * * You can redistribute this file and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software Foundation; * either version 2 of the License, or (at your discretion) any later version. * See the accompanying file "COPYING.txt" for more details. * * As a special exception to the GPL, permission is granted for additional * uses of the text contained in this file. See the accompanying file * "COPY-UOS.txt" for details. */ #ifndef __KERNEL_INTERNAL_H_ # error "Don't include directly, use <kernel/internal.h> instead." #endif /* * The total number of different hardware interrupts. */ #if defined(__MSP430_5418__) || defined(__MSP430_5419__) || \ defined(__MSP430_5435__) || defined(__MSP430_5436__) || \ defined(__MSP430_5437__) || defined(__MSP430_5438__) # define ARCH_INTERRUPTS 63 #else # define ARCH_INTERRUPTS 15 #endif /* * Type for saving task stack context. */ typedef void *arch_stack_t; static inline arch_stack_t arch_get_stack_pointer () { return msp430_get_stack_pointer (); } static inline void arch_set_stack_pointer (arch_stack_t sp) { msp430_set_stack_pointer (sp); } /* * Type for saving task interrupt mask. */ typedef int arch_state_t; /* * Build the initial task's stack frame. * Arguments: * t - the task object, with the stack space appended * f - the task function to call * a - the function argument * sz - stack size in bytes */ void arch_build_stack_frame (task_t *t, void (*func) (void*), void *arg, unsigned stacksz); /* * Perform the task switch. */ void arch_task_switch (task_t *target); /* * The global interrupt control. * Disable and restore the hardware interrupts, * saving the interrupt enable flag into the supplied variable. */ static inline void arch_intr_disable (arch_state_t *x) { msp430_intr_disable (x); } static inline void arch_intr_restore (arch_state_t x) { msp430_intr_restore (x); } /* * Allow the given hardware interrupt, * unmasking it in the interrupt controller. * * WARNING! MACHDEP_INTR_ALLOW(n) MUST be called when interrupt disabled */ void arch_intr_allow (int irq); /* * Bind the handler to the given hardware interrupt. * (optional feature) */ static inline void arch_intr_bind (int irq) { } /* * Unbind the interrupt handler. * (optional feature) */ static inline void arch_intr_unbind (int irq) { } /* * Idle system activity. */ static inline void arch_idle () { msp430_intr_enable (); for (;;) { _BIS_SR (CPUOFF); } }
/* * @BEGIN LICENSE * * Psi4: an open-source quantum chemistry software package * * Copyright (c) 2007-2017 The Psi4 Developers. * * The copyrights for code used from other parties are included in * the corresponding files. * * 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. * * @END LICENSE */ #ifndef STABILITY_H #define STABILITY_H #endif // STABILITY_H #include "psi4/libmints/wavefunction.h" namespace psi { class BasisSet; class Matrix; class TwoBodyAOInt; class JK; class VBase; namespace scf { class UStab { protected: std::vector<std::pair<SharedMatrix,SharedMatrix> > vecs_; std::vector<double> vals_; bool unstable = false; double unstable_val = 0.0; std::pair<SharedMatrix,SharedMatrix> unstable_vec; int print_; int bench_; int debug_; long int memory_; //SharedMatrix C_; SharedMatrix Cocca_; SharedMatrix Coccb_; SharedMatrix Cvira_; SharedMatrix Cvirb_; SharedMatrix Ca_; SharedMatrix Cb_; std::shared_ptr<Vector> eps_occa_; std::shared_ptr<Vector> eps_vira_; std::shared_ptr<Vector> eps_occb_; std::shared_ptr<Vector> eps_virb_; std::shared_ptr<Wavefunction> reference_wavefunction_; std::shared_ptr<Molecule> molecule_; std::shared_ptr<BasisSet> basis_; SharedMatrix AO2USO_; Options& options_; /// How far to converge the two-norm of the residual double convergence_; /// Global JK object, built in preiterations, destroyed in postiterations std::shared_ptr<JK> jk_; std::shared_ptr<VBase> v_; double Eref_; void common_init(); void print_header(); void preiterations(); public: UStab(SharedWavefunction ref_wfn, Options& options); virtual ~UStab(); /// Gets a handle to the JK object, if built by preiterations std::shared_ptr<JK> jk() const { return jk_;} /// Set the JK object, say from SCF void set_jk(std::shared_ptr<JK> jk) { jk_ = jk; } /// Gets a handle to the VBase object, if built by preiterations std::shared_ptr<VBase> v() const { return v_;} /// Set the VBase object, say from SCF (except that wouldn't work, right?) void set_jk(std::shared_ptr<VBase> v) { v_ = v; } /// Is the wavefunction stable ? bool is_unstable() const { return unstable;} /// Get the eigenvalue for storage and comparison. double get_eigval() const {return unstable_val;} /// => Setters <= /// /// Set convergence behavior void set_convergence(double convergence) { convergence_ = convergence; } /// Update reference info void set_reference(std::shared_ptr<Wavefunction> reference); virtual double compute_energy(); SharedMatrix analyze(); void rotate_orbs(double scale); }; } // namespace scf } // namespace psi
/* ************************************************************************* * Ralink Tech Inc. * 5F., No.36, Taiyuan St., Jhubei City, * Hsinchu County 302, * Taiwan, R.O.C. * * (c) Copyright 2002-2010, Ralink Technology, 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 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. * * * *************************************************************************/ #ifndef __RT3370_H__ #define __RT3370_H__ #ifdef RT3370 #ifndef RTMP_USB_SUPPORT #error "For RT3070, you should define the compile flag -DRTMP_USB_SUPPORT" #endif #ifndef RTMP_MAC_USB #error "For RT3070, you should define the compile flag -DRTMP_MAC_USB" #endif #ifndef RTMP_RF_RW_SUPPORT #error "For RT3070, you should define the compile flag -DRTMP_RF_RW_SUPPORT" #endif #ifndef RT33xx #error "For RT3370, you should define the compile flag -DRT33xx" #endif #ifndef RT30xx #error "For RT3070, you should define the compile flag -DRT30xx" #endif #include "chip/rt30xx.h" #include "chip/rt33xx.h" extern REG_PAIR RT3370_BBPRegTable[]; extern UCHAR RT3370_NUM_BBP_REG_PARMS; /* */ /* Device ID & Vendor ID, these values should match EEPROM value */ /* */ #endif /* RT3370 */ #endif /*__RT3370_H__ */
/* * Ayttm * * Copyright (C) 2003, the Ayttm 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 * */ #ifndef __IMAGE_WINDOW_H__ #define __IMAGE_WINDOW_H__ typedef void (*ay_image_window_cancel_callback) (int tag, void *data); #ifdef __cplusplus extern "C" { #endif int ay_image_window_new(int width, int height, const char *title, ay_image_window_cancel_callback cancel_callback, void *callback_data); int ay_image_window_add_data(int tag, const unsigned char *buf, long count, int new_image); void ay_image_window_update_title(int tag, const char *title); void ay_image_window_close(int tag); extern unsigned char *(*image_2_jpg) (const unsigned char *, long *); extern unsigned char *(*image_2_jpc) (const unsigned char *, long *); #ifdef __cplusplus } #endif #endif
/* Copyright (C) 2006 yopyop Copyright (C) 2006-2012 DeSmuME team This file 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 file 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 this software. If not, see <http://www.gnu.org/licenses/>. */ #ifndef BIOS_H #define BIOS_H #include "armcpu.h" extern u32 (* ARM_swi_tab[2][32])();; #endif
/** -*- c++ -*- * Copyright (C) 2008 Luke Lu (Zvents, Inc.) * * This file is part of Hypertable. * * Hypertable 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, or any later version. * * Hypertable 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 HYPERTABLE_RANGE_SERVER_METALOG_VERSION_H #define HYPERTABLE_RANGE_SERVER_METALOG_VERSION_H #include <iostream> namespace Hypertable { // sizes enum { ML_ENTRY_HEADER_SIZE = /*checksum*/4 + /*ts*/ 8 + /*type*/1 + /*payload*/4, RSML_HEADER_SIZE = /*prefix*/5 + /*version*/2, MML_HEADER_SIZE = /*prefix*/4 + /*version*/2 }; // range server constants extern const uint16_t RSML_VERSION; extern const char *RSML_PREFIX; // master constants extern const uint16_t MML_VERSION; extern const char *MML_PREFIX; struct MetaLogHeader { MetaLogHeader(const char *prfx, uint16_t vernum) : prefix(prfx), version(vernum) {} MetaLogHeader(const uint8_t *buf, size_t len) { decode(buf, len); } void encode(uint8_t *buf, size_t len); void decode(const uint8_t *buf, size_t len); const char *prefix; uint16_t version; }; std::ostream &operator<<(std::ostream &, const MetaLogHeader &); } // namespace Hypertable #endif // HYPERTABLE_RANGE_SERVER_METALOG_VERSION_H
/**************************************************************************************** * Copyright (c) 2008 Shane King <kde@dontletsstart.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 AMAROK_MULTIPLAYABLECAPABILITYIMPL_P_H #define AMAROK_MULTIPLAYABLECAPABILITYIMPL_P_H #include "core/interfaces/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "MainWindow.h" #include "LastFmMeta.h" #include "core/meta/Meta.h" #include "core/capabilities/MultiPlayableCapability.h" #include <lastfm/Track> #include <lastfm/RadioTuner> #include <lastfm/ws.h> #include <KLocale> class MultiPlayableCapabilityImpl : public Capabilities::MultiPlayableCapability, public Meta::Observer { Q_OBJECT public: MultiPlayableCapabilityImpl( LastFm::Track *track ) : Capabilities::MultiPlayableCapability() , m_url( track->internalUrl() ) , m_track( track ) , m_currentTrack( lastfm::Track() ) { Meta::TrackPtr trackptr( track ); subscribeTo( trackptr ); connect( track, SIGNAL( skipTrack() ), this, SLOT( skip() ) ); connect( The::mainWindow(), SIGNAL( skipTrack() ), SLOT( skip() ) ); } virtual ~MultiPlayableCapabilityImpl() {} virtual void fetchFirst() { DEBUG_BLOCK m_tuner = new lastfm::RadioTuner( lastfm::RadioStation( m_track->uidUrl() ) ); connect( m_tuner, SIGNAL( trackAvailable() ), this, SLOT( slotNewTrackAvailable() ) ); connect( m_tuner, SIGNAL( error( lastfm::ws::Error ) ), this, SLOT( error( lastfm::ws::Error ) ) ); } virtual void fetchNext() { DEBUG_BLOCK m_currentTrack = m_tuner->takeNextTrack(); m_track->setTrackInfo( m_currentTrack ); } using Observer::metadataChanged; virtual void metadataChanged( Meta::TrackPtr track ) { const LastFm::TrackPtr ltrack = LastFm::TrackPtr::dynamicCast( track ); if( ltrack.isNull() ) return; KUrl url = ltrack->internalUrl(); if( url.isEmpty() || url != m_url ) // always should let empty url through, since otherwise we swallow an error getting first track { m_url = url; emit playableUrlFetched( url ); } } public slots: void slotNewTrackAvailable() { if( m_currentTrack.isNull() ) // we only force a track change at the beginning { m_currentTrack = m_tuner->takeNextTrack(); m_track->setTrackInfo( m_currentTrack ); } } virtual void skip() { fetchNext(); // now we force a new signal to be emitted to kick the enginecontroller to moving on //KUrl url = m_track->playableUrl(); //emit playableUrlFetched( url ); } void error( lastfm::ws::Error e ) { if( e == lastfm::ws::SubscribersOnly || e == lastfm::ws::AuthenticationFailed ) { // last.fm is returning an AuthenticationFailed message when the user is not a subscriber, even if the credentials are OK Amarok::Components::logger()->shortMessage( i18n( "To listen to this stream you need to be a paying Last.fm subscriber. " \ "All the other Last.fm features are unaffected." ) ); } else { Amarok::Components::logger()->shortMessage( i18n( "Error starting track from Last.fm radio" ) ); } } private: KUrl m_url; LastFm::TrackPtr m_track; lastfm::Track m_currentTrack; lastfm::RadioTuner* m_tuner; }; #endif
// // MonthName.c // 5.6.4_calendar // // Created by Cirno MainasuK on 2015-1-10. // Copyright (c) 2015年 Cirno MainasuK. All rights reserved. // #include <stdio.h> // MonthName converts a numeric month in the range 1-12 // into the strng name for that month. char *MonthName(int month) { switch (month) { case 1: return ("January"); case 2: return ("February"); case 3: return ("March"); case 4: return ("April"); case 5: return ("May"); case 6: return ("June"); case 7: return ("Junly"); case 8: return ("August"); case 9: return ("September"); case 10: return ("October"); case 11: return ("November"); case 12: return ("December"); default: return ("Illegal month"); } }
/* * QEMU CPU cluster * * Copyright (c) 2018 GreenSocs SAS * * 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/gpl-2.0.html> */ #ifndef HW_CPU_CLUSTER_H #define HW_CPU_CLUSTER_H #include "qemu/osdep.h" #include "hw/qdev.h" /* * CPU Cluster type * * A cluster is a group of CPUs which are all identical and have the same view * of the rest of the system. It is mainly an internal QEMU representation and * does not necessarily match with the notion of clusters on the real hardware. * * If CPUs are not identical (for example, Cortex-A53 and Cortex-A57 CPUs in an * Arm big.LITTLE system) they should be in different clusters. If the CPUs do * not have the same view of memory (for example the main CPU and a management * controller processor) they should be in different clusters. * * A cluster is created by creating an object of TYPE_CPU_CLUSTER, and then * adding the CPUs to it as QOM child objects (e.g. using the * object_initialize_child() or object_property_add_child() functions). * The CPUs may be either direct children of the cluster object, or indirect * children (e.g. children of children of the cluster object). * * All CPUs must be added as children before the cluster is realized. * (Regrettably QOM provides no way to prevent adding children to a realized * object and no way for the parent to be notified when a new child is added * to it, so this restriction is not checked for, but the system will not * behave correctly if it is not adhered to. The cluster will assert that * it contains at least one CPU, which should catch most inadvertent * violations of this constraint.) * * A CPU which is not put into any cluster will be considered implicitly * to be in a cluster with all the other "loose" CPUs, so all CPUs that are * not assigned to clusters must be identical. */ #define TYPE_CPU_CLUSTER "cpu-cluster" #define CPU_CLUSTER(obj) \ OBJECT_CHECK(CPUClusterState, (obj), TYPE_CPU_CLUSTER) /* * This limit is imposed by TCG, which puts the cluster ID into an * 8 bit field (and uses all-1s for the default "not in any cluster"). */ #define MAX_CLUSTERS 255 /** * CPUClusterState: * @cluster_id: The cluster ID. This value is for internal use only and should * not be exposed directly to the user or to the guest. * * State of a CPU cluster. */ typedef struct CPUClusterState { /*< private >*/ DeviceState parent_obj; /*< public >*/ uint32_t cluster_id; } CPUClusterState; #endif
typedef struct { unsigned char ch1; unsigned char ch2; short count; } dbl_char_stat_t; typedef struct { unsigned char ch1; unsigned char ch2; int count; } dbl_char_stat_long_t;
#include <gsl/gsl_test.h> #include <gsl/gsl_ieee_utils.h> #include <gsl/gsl_math.h> #include "gsl_cblas.h" #include "tests.h" void test_syr (void) { const double flteps = 1e-4, dbleps = 1e-6; { int order = 101; int uplo = 121; int N = 1; int lda = 1; float alpha = 0.1f; float A[] = { -0.291f }; float X[] = { 0.845f }; int incX = -1; float A_expected[] = { -0.219597f }; cblas_ssyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], flteps, "ssyr(case 1402)"); } }; }; { int order = 101; int uplo = 122; int N = 1; int lda = 1; float alpha = 0.1f; float A[] = { -0.291f }; float X[] = { 0.845f }; int incX = -1; float A_expected[] = { -0.219597f }; cblas_ssyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], flteps, "ssyr(case 1403)"); } }; }; { int order = 102; int uplo = 121; int N = 1; int lda = 1; float alpha = 0.1f; float A[] = { -0.291f }; float X[] = { 0.845f }; int incX = -1; float A_expected[] = { -0.219597f }; cblas_ssyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], flteps, "ssyr(case 1404)"); } }; }; { int order = 102; int uplo = 122; int N = 1; int lda = 1; float alpha = 0.1f; float A[] = { -0.291f }; float X[] = { 0.845f }; int incX = -1; float A_expected[] = { -0.219597f }; cblas_ssyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], flteps, "ssyr(case 1405)"); } }; }; { int order = 101; int uplo = 121; int N = 1; int lda = 1; double alpha = -0.3; double A[] = { -0.65 }; double X[] = { -0.891 }; int incX = -1; double A_expected[] = { -0.8881643 }; cblas_dsyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], dbleps, "dsyr(case 1406)"); } }; }; { int order = 101; int uplo = 122; int N = 1; int lda = 1; double alpha = -0.3; double A[] = { -0.65 }; double X[] = { -0.891 }; int incX = -1; double A_expected[] = { -0.8881643 }; cblas_dsyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], dbleps, "dsyr(case 1407)"); } }; }; { int order = 102; int uplo = 121; int N = 1; int lda = 1; double alpha = -0.3; double A[] = { -0.65 }; double X[] = { -0.891 }; int incX = -1; double A_expected[] = { -0.8881643 }; cblas_dsyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], dbleps, "dsyr(case 1408)"); } }; }; { int order = 102; int uplo = 122; int N = 1; int lda = 1; double alpha = -0.3; double A[] = { -0.65 }; double X[] = { -0.891 }; int incX = -1; double A_expected[] = { -0.8881643 }; cblas_dsyr(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[i], A_expected[i], dbleps, "dsyr(case 1409)"); } }; }; }
/** * * $Id: MrmPrivate.h,v 1.1 2004/08/28 19:23:24 dannybackx Exp $ * * Copyright (C) 1995 Free Software Foundation, Inc. * Copyright (C) 1995-2000 LessTif Development Team * * This file is part of the GNU LessTif Library. * * 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; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * **/ #ifndef _MRM_MRMPRIVATE_H #define _MRM_MRMPRIVATE_H #include <Mrm/MrmPublic.h> #ifdef __cplusplus extern "C" { #endif typedef struct { Display *display; MrmHierarchy hierarchy_for_display; } MrmPerDisplay, *MrmPerDisplayList; #ifdef __cplusplus }; #endif #endif /* _MRM_MRMPRIVATE_H */
/** * @file * @brief Board Initialization routines for OMAP3EVM. * * This board is based on OMAP3530. * More on OMAP3530 (including documentation can be found here): * http://focus.ti.com/docs/prod/folders/print/omap3530.html * * This file provides initialization in two stages: * @li Boot time initialization - just get SDRAM working. * This is run from SRAM - so no case constructs and global vars can be used. * @li Run time initialization - this is for the rest of the initializations * such as flash, uart etc. * * Boot time initialization includes: * @li SDRAM initialization. * @li Pin Muxing relevant for the EVM. * * Run time initialization includes * @li serial @ref serial_ns16550.c driver device definition * * Originally from arch/arm/boards/omap/board-beagle.c */ /* * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ * Sanjeev Premi <premi@ti.com> * * 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. * */ #include <common.h> #include <console.h> #include <init.h> #include <driver.h> #include <io.h> #include <linux/sizes.h> #include <asm/armlinux.h> #include <mach/omap3-silicon.h> #include <mach/omap3-mux.h> #include <mach/gpmc.h> #include <errno.h> #include <generated/mach-types.h> #include <mach/omap3-devices.h> /** * @brief Initialize the serial port to be used as console. * * @return result of device registration */ static int omap3evm_init_console(void) { barebox_set_model("Texas Instruments omap3evm"); barebox_set_hostname("omap3evm"); if (IS_ENABLED(CONFIG_OMAP_UART1)) omap3_add_uart1(); if (IS_ENABLED(CONFIG_OMAP_UART3)) omap3_add_uart3(); return 0; } console_initcall(omap3evm_init_console); static int omap3evm_mem_init(void) { omap_add_ram0(SZ_128M); return 0; } mem_initcall(omap3evm_mem_init); static int omap3evm_init_devices(void) { #ifdef CONFIG_OMAP_GPMC /* * WP is made high and WAIT1 active Low */ gpmc_generic_init(0x10); #endif omap3_add_mmc1(NULL); armlinux_set_architecture(MACH_TYPE_OMAP3EVM); return 0; } device_initcall(omap3evm_init_devices);
/* * Copyright (C) 1995 by Sam Rushing <rushing@nightmare.com> */ /* $Id: avl.h,v 1.7 2003/07/07 01:10:14 brendan Exp $ */ #ifndef __AVL_H #define __AVL_H #ifdef __cplusplus extern "C" { #endif #ifndef NO_THREAD #include "thread/thread.h" #else #define thread_rwlock_create(x) do{}while(0) #define thread_rwlock_destroy(x) do{}while(0) #define thread_rwlock_rlock(x) do{}while(0) #define thread_rwlock_wlock(x) do{}while(0) #define thread_rwlock_unlock(x) do{}while(0) #endif typedef struct avl_node_tag { void * key; struct avl_node_tag * left; struct avl_node_tag * right; struct avl_node_tag * parent; /* * The lower 2 bits of <rank_and_balance> specify the balance * factor: 00==-1, 01==0, 10==+1. * The rest of the bits are used for <rank> */ unsigned int rank_and_balance; #if !defined(NO_THREAD) && defined(HAVE_AVL_NODE_LOCK) rwlock_t rwlock; #endif } avl_node; #define AVL_GET_BALANCE(n) ((int)(((n)->rank_and_balance & 3) - 1)) #define AVL_GET_RANK(n) (((n)->rank_and_balance >> 2)) #define AVL_SET_BALANCE(n,b) \ ((n)->rank_and_balance) = \ (((n)->rank_and_balance & (~3)) | ((int)((b) + 1))) #define AVL_SET_RANK(n,r) \ ((n)->rank_and_balance) = \ (((n)->rank_and_balance & 3) | (r << 2)) struct _avl_tree; typedef int (*avl_key_compare_fun_type) (void * compare_arg, void * a, void * b); typedef int (*avl_iter_fun_type) (void * key, void * iter_arg); typedef int (*avl_iter_index_fun_type) (unsigned long index, void * key, void * iter_arg); typedef int (*avl_free_key_fun_type) (void * key); typedef int (*avl_key_printer_fun_type) (char *, void *); /* * <compare_fun> and <compare_arg> let us associate a particular compare * function with each tree, separately. */ #ifdef _mangle # define avl_tree_new _mangle(avl_tree_new) # define avl_node_new _mangle(avl_node_new) # define avl_tree_free _mangle(avl_tree_free) # define avl_insert _mangle(avl_insert) # define avl_delete _mangle(avl_delete) # define avl_get_by_index _mangle(avl_get_by_index) # define avl_get_by_key _mangle(avl_get_by_key) # define avl_iterate_inorder _mangle(avl_iterate_inorder) # define avl_iterate_index_range _mangle(avl_iterate_index_range) # define avl_tree_rlock _mangle(avl_tree_rlock) # define avl_tree_wlock _mangle(avl_tree_wlock) # define avl_tree_trywlock _mangle(avl_tree_trywlock) # define avl_tree_unlock _mangle(avl_tree_unlock) # define avl_node_rlock _mangle(avl_node_rlock) # define avl_node_wlock _mangle(avl_node_wlock) # define avl_node_unlock _mangle(avl_node_unlock) # define avl_get_span_by_key _mangle(avl_get_span_by_key) # define avl_get_span_by_two_keys _mangle(avl_get_span_by_two_keys) # define avl_verify _mangle(avl_verify) # define avl_print_tree _mangle(avl_print_tree) # define avl_get_first _mangle(avl_get_first) # define avl_get_prev _mangle(avl_get_prev) # define avl_get_next _mangle(avl_get_next) # define avl_get_item_by_key_most _mangle(avl_get_item_by_key_most) # define avl_get_item_by_key_least _mangle(avl_get_item_by_key_least) #endif typedef struct _avl_tree { avl_node * root; unsigned int height; unsigned int length; avl_key_compare_fun_type compare_fun; void * compare_arg; #ifndef NO_THREAD rwlock_t rwlock; #endif } avl_tree; #define avl_tree_new(x,y) avl_tree_new_c(x,y, __LINE__, __FILE__) #define avl_tree_rlock(x) avl_tree_rlock_c(x,__LINE__,__FILE__) #define avl_tree_wlock(x) avl_tree_wlock_c(x,__LINE__,__FILE__) #define avl_tree_unlock(x) avl_tree_unlock_c(x,__LINE__,__FILE__) avl_tree * avl_tree_new_c (avl_key_compare_fun_type compare_fun, void * compare_arg, int line, const char *file); avl_node * avl_node_new (void * key, avl_node * parent); void avl_tree_free ( avl_tree * tree, avl_free_key_fun_type free_key_fun ); int avl_insert ( avl_tree * ob, void * key ); int avl_delete ( avl_tree * tree, void * key, avl_free_key_fun_type free_key_fun ); int avl_get_by_index ( avl_tree * tree, unsigned long index, void ** value_address ); int avl_get_by_key ( avl_tree * tree, void * key, void ** value_address ); int avl_iterate_inorder ( avl_tree * tree, avl_iter_fun_type iter_fun, void * iter_arg ); int avl_iterate_index_range ( avl_tree * tree, avl_iter_index_fun_type iter_fun, unsigned long low, unsigned long high, void * iter_arg ); int avl_get_span_by_key ( avl_tree * tree, void * key, unsigned long * low, unsigned long * high ); int avl_get_span_by_two_keys ( avl_tree * tree, void * key_a, void * key_b, unsigned long * low, unsigned long * high ); int avl_verify (avl_tree * tree); void avl_print_tree ( avl_tree * tree, avl_key_printer_fun_type key_printer ); avl_node *avl_get_first(avl_tree *tree); avl_node *avl_get_prev(avl_node * node); avl_node *avl_get_next(avl_node * node); /* These two are from David Ascher <david_ascher@brown.edu> */ int avl_get_item_by_key_most ( avl_tree * tree, void * key, void ** value_address ); int avl_get_item_by_key_least ( avl_tree * tree, void * key, void ** value_address ); /* optional locking stuff */ void avl_tree_rlock_c(avl_tree *tree, int line, const char *file); void avl_tree_wlock_c(avl_tree *tree, int line, const char *file); int avl_tree_trywlock(avl_tree *tree); void avl_tree_unlock_c(avl_tree *tree, int line, const char *file); void avl_node_rlock(avl_node *node); void avl_node_wlock(avl_node *node); void avl_node_unlock(avl_node *node); #ifdef __cplusplus } #endif #endif /* __AVL_H */
// // GitTest_AppDelegate.h // GitTest // // Created by Pieter de Bie on 13-06-08. // Copyright __MyCompanyName__ 2008 . All rights reserved. // #import <Cocoa/Cocoa.h> #import "PBGitRepository.h" @class PBCloneRepositoryPanel; @interface ApplicationController : NSObject <NSApplicationDelegate> { IBOutlet NSWindow *window; IBOutlet id firstResponder; PBCloneRepositoryPanel *cloneRepositoryPanel; bool started; } - (IBAction)openPreferencesWindow:(id)sender; - (IBAction)showAboutPanel:(id)sender; - (IBAction)installCliTool:(id)sender; - (IBAction)showHelp:(id)sender; - (IBAction)showChangeLog:(id)sender; - (IBAction)reportAProblem:(id)sender; - (IBAction)showCloneRepository:(id)sender; @end
/* * Copyright (c) 2012 Qualcomm Atheros, Inc. * All rights reserved. * Qualcomm Atheros Confidential and Proprietary. * */ /** * @defgroup horus_qos HORUS_QOS * @{ */ #ifndef _HORUS_QOS_H_ #define _HORUS_QOS_H_ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "fal/fal_qos.h" sw_error_t horus_qos_init(a_uint32_t dev_id); #ifdef IN_QOS #define HORUS_QOS_INIT(rv, dev_id) \ { \ rv = horus_qos_init(dev_id); \ SW_RTN_ON_ERROR(rv); \ } #else #define HORUS_QOS_INIT(rv, dev_id) #endif #ifdef HSL_STANDALONG HSL_LOCAL sw_error_t horus_qos_queue_tx_buf_status_set(a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable); HSL_LOCAL sw_error_t horus_qos_queue_tx_buf_status_get(a_uint32_t dev_id, fal_port_t port_id, a_bool_t * enable); HSL_LOCAL sw_error_t horus_qos_port_tx_buf_status_set(a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable); HSL_LOCAL sw_error_t horus_qos_port_tx_buf_status_get(a_uint32_t dev_id, fal_port_t port_id, a_bool_t * enable); HSL_LOCAL sw_error_t horus_qos_queue_tx_buf_nr_set(a_uint32_t dev_id, fal_port_t port_id, fal_queue_t queue_id, a_uint32_t * number); HSL_LOCAL sw_error_t horus_qos_queue_tx_buf_nr_get(a_uint32_t dev_id, fal_port_t port_id, fal_queue_t queue_id, a_uint32_t * number); HSL_LOCAL sw_error_t horus_qos_port_tx_buf_nr_set(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t * number); HSL_LOCAL sw_error_t horus_qos_port_tx_buf_nr_get(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t * number); HSL_LOCAL sw_error_t horus_qos_port_rx_buf_nr_set(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t * number); HSL_LOCAL sw_error_t horus_qos_port_rx_buf_nr_get(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t * number); HSL_LOCAL sw_error_t horus_cosmap_up_queue_set(a_uint32_t dev_id, a_uint32_t up, fal_queue_t queue); HSL_LOCAL sw_error_t horus_cosmap_up_queue_get(a_uint32_t dev_id, a_uint32_t up, fal_queue_t * queue); HSL_LOCAL sw_error_t horus_cosmap_dscp_queue_set(a_uint32_t dev_id, a_uint32_t dscp, fal_queue_t queue); HSL_LOCAL sw_error_t horus_cosmap_dscp_queue_get(a_uint32_t dev_id, a_uint32_t dscp, fal_queue_t * queue); HSL_LOCAL sw_error_t horus_qos_port_mode_set(a_uint32_t dev_id, fal_port_t port_id, fal_qos_mode_t mode, a_bool_t enable); HSL_LOCAL sw_error_t horus_qos_port_mode_get(a_uint32_t dev_id, fal_port_t port_id, fal_qos_mode_t mode, a_bool_t * enable); HSL_LOCAL sw_error_t horus_qos_port_mode_pri_set(a_uint32_t dev_id, fal_port_t port_id, fal_qos_mode_t mode, a_uint32_t pri); HSL_LOCAL sw_error_t horus_qos_port_mode_pri_get(a_uint32_t dev_id, fal_port_t port_id, fal_qos_mode_t mode, a_uint32_t * pri); HSL_LOCAL sw_error_t horus_qos_port_default_up_set(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t up); HSL_LOCAL sw_error_t horus_qos_port_default_up_get(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t * up); HSL_LOCAL sw_error_t horus_qos_port_sch_mode_set(a_uint32_t dev_id, a_uint32_t port_id, fal_sch_mode_t mode, const a_uint32_t weight[]); HSL_LOCAL sw_error_t horus_qos_port_sch_mode_get(a_uint32_t dev_id, a_uint32_t port_id, fal_sch_mode_t * mode, a_uint32_t weight[]); #endif #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _HORUS_QOS_H_ */ /** * @} */
/* Copyright (C) 2010-2020 by The D Language Foundation, All Rights Reserved * http://www.digitalmars.com * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) * https://github.com/D-Programming-Language/dmd/blob/master/src/root/aav.h */ #pragma once #include "dsystem.h" typedef void* Value; typedef void* Key; struct AA; size_t dmd_aaLen(AA* aa); Value* dmd_aaGet(AA** aa, Key key); Value dmd_aaGetRvalue(AA* aa, Key key); void dmd_aaRehash(AA** paa);
/* SPDX-License-Identifier: GPL-2.0-only */ #include <console/console.h> #include <delay.h> #include <drivers/parade/ps8640/ps8640.h> #include <edid.h> #include <gpio.h> #include <soc/i2c.h> #include "panel.h" static void power_on_ps8640(void) { /* Disable backlight before turning on bridge */ gpio_output(GPIO(PERIPHERAL_EN13), 0); gpio_output(GPIO(DISP_PWM), 0); /* Turn on bridge */ gpio_output(GPIO_MIPIBRDG_RST_L_1V8, 0); gpio_output(GPIO_PP1200_MIPIBRDG_EN, 1); gpio_output(GPIO_VDDIO_MIPIBRDG_EN, 1); mdelay(2); gpio_output(GPIO_MIPIBRDG_PWRDN_L_1V8, 1); mdelay(2); gpio_output(GPIO_MIPIBRDG_RST_L_1V8, 1); gpio_output(GPIO_PP3300_LCM_EN, 1); } static void dummy_power_on(void) { /* The panel has been already powered on when getting panel information * so we should do nothing here. */ } static struct panel_serializable_data ps8640_data = { .init = { PANEL_END }, }; static struct panel_description ps8640_panel = { .s = &ps8640_data, .orientation = LB_FB_ORIENTATION_NORMAL, .power_on = dummy_power_on, }; struct panel_description *get_panel_description(int panel_id) { /* To read panel EDID, we have to first power on PS8640. */ power_on_ps8640(); u8 i2c_bus = 4, i2c_addr = 0x08; mtk_i2c_bus_init(i2c_bus); ps8640_init(i2c_bus, i2c_addr); struct edid *edid = &ps8640_data.edid; if (ps8640_get_edid(i2c_bus, i2c_addr, edid)) { printk(BIOS_ERR, "Can't get panel's edid\n"); return NULL; } return &ps8640_panel; }
/* * itkStubLib.c -- * * Stub object that will be statically linked into extensions that wish * to access Itk. * * Copyright (c) 1998-1999 by XXXX * Copyright (c) 1998 Paul Duffin. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: $Id: itkStubLib.c 144 2003-02-05 10:56:26Z mdejong $ */ /* * We need to ensure that we use the stub macros so that this file contains * no references to any of the stub functions. This will make it possible * to build an extension that references Tcl_InitStubs but doesn't end up * including the rest of the stub functions. */ #ifndef USE_TCL_STUBS #define USE_TCL_STUBS #endif #undef USE_TCL_STUB_PROCS #ifndef USE_ITK_STUBS #define USE_ITK_STUBS #endif #undef USE_ITK_STUB_PROCS #include "itk.h" ItkStubs *itkStubsPtr; /* *---------------------------------------------------------------------- * * Itk_InitStubs -- * * Tries to initialise the stub table pointers and ensures that * the correct version of Itk is loaded. * * Results: * The actual version of Itk that satisfies the request, or * NULL to indicate that an error occurred. * * Side effects: * Sets the stub table pointers. * *---------------------------------------------------------------------- */ char * Itk_InitStubs (interp, version, exact) Tcl_Interp *interp; char *version; int exact; { char *actualVersion; actualVersion = Tcl_PkgRequireEx(interp, "Itk", version, exact, (ClientData *) &itkStubsPtr); if (actualVersion == NULL) { itkStubsPtr = NULL; return NULL; } return actualVersion; }
#include "ythtlib.h" // from src/bcache.c:useridhash by ylsdd. perhaps it is no good enough. int strhash(char *id) { int n1 = 0; int n2 = 0; while (*id) { n1 += ((unsigned char) *id) % 26; id++; if (!*id) break; n2 += ((unsigned char) *id) % 26; id++; } n1 %= 26; n2 %= 26; return n1 * 26 + n2; } int getdic(diction dic, size_t size, void **mem) { struct hword *tmp; int i, count; void *m; count = 0; for (i = 0; i < 26 * 26; i++) { tmp = dic[i]; while (tmp != NULL) { count++; tmp = tmp->next; } } m = malloc(size * count); if (m == NULL) return -1; *mem = m; for (i = 0; i < 26 * 26; i++) { tmp = dic[i]; while (tmp != NULL) { memcpy(m, tmp->value, size); m += size; tmp = tmp->next; } } return count; } struct hword * finddic(diction dic, char *key) { int hashkey; struct hword *tmp; hashkey = strhash(key); tmp = dic[hashkey]; while (tmp != NULL) { if (strcmp(tmp->str, key)) { tmp = tmp->next; continue; } break; } return tmp; } struct hword * insertdic(diction dic, struct hword *w) { int hashkey; hashkey = strhash(w->str); w->next = dic[hashkey]; dic[hashkey] = w; return w; }
// license:BSD-3-Clause // copyright-holders:Ed Bernard, Jonathan Gevaryahu, hap // thanks-to:Kevin Horton /* SSi TSI S14001A speech IC emulator */ #ifndef __S14001A_H__ #define __S14001A_H__ #define MCFG_S14001A_BSY_HANDLER(_devcb) \ devcb = &s14001a_device::set_bsy_handler(*device, DEVCB_##_devcb); #define MCFG_S14001A_EXT_READ_HANDLER(_devcb) \ devcb = &s14001a_device::set_ext_read_handler(*device, DEVCB_##_devcb); class s14001a_device : public device_t, public device_sound_interface { public: s14001a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~s14001a_device() {} // static configuration helpers template<class _Object> static devcb_base &set_bsy_handler(device_t &device, _Object object) { return downcast<s14001a_device &>(device).m_bsy_handler.set_callback(object); } template<class _Object> static devcb_base &set_ext_read_handler(device_t &device, _Object object) { return downcast<s14001a_device &>(device).m_ext_read_handler.set_callback(object); } DECLARE_READ_LINE_MEMBER(busy_r); // /BUSY (pin 40) DECLARE_READ_LINE_MEMBER(romen_r); // ROM /EN (pin 9) DECLARE_WRITE_LINE_MEMBER(start_w); // START (pin 10) DECLARE_WRITE8_MEMBER(data_w); // 6-bit word void set_clock(UINT32 clock); // set new CLK frequency void force_update(); // update stream, eg. before external ROM bankswitch protected: // device-level overrides virtual void device_start() override; // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; private: required_region_ptr<UINT8> m_SpeechRom; sound_stream * m_stream; devcb_write_line m_bsy_handler; devcb_read8 m_ext_read_handler; UINT8 readmem(UINT16 offset, bool phase); bool Clock(); // called once to toggle external clock twice // emulator helper functions UINT8 Mux8To2(bool bVoicedP2, UINT8 uPPQtrP2, UINT8 uDeltaAdrP2, UINT8 uRomDataP2); void CalculateIncrement(bool bVoicedP2, UINT8 uPPQtrP2, bool bPPQStartP2, UINT8 uDeltaP2, UINT8 uDeltaOldP2, UINT8 &uDeltaOldP1, UINT8 &uIncrementP2, bool &bAddP2); UINT8 CalculateOutput(bool bVoicedP2, bool bXSilenceP2, UINT8 uPPQtrP2, bool bPPQStartP2, UINT8 uLOutputP2, UINT8 uIncrementP2, bool bAddP2); void ClearStatistics(); void GetStatistics(UINT32 &uNPitchPeriods, UINT32 &uNVoiced, UINT32 &uNControlWords); void SetPrintLevel(UINT32 uPrintLevel) { m_uPrintLevel = uPrintLevel; } // internal state bool m_bPhase1; // 1 bit internal clock enum states { IDLE = 0, WORDWAIT, CWARMSB, // read 8 CWAR MSBs CWARLSB, // read 4 CWAR LSBs from rom d7-d4 DARMSB, // read 8 DAR MSBs CTRLBITS, // read Stop, Voiced, Silence, Length, XRepeat PLAY, DELAY }; // registers states m_uStateP1; // 3 bits states m_uStateP2; UINT16 m_uDAR13To05P1; // 9 MSBs of delta address register UINT16 m_uDAR13To05P2; // incrementing uDAR05To13 advances ROM address by 8 bytes UINT16 m_uDAR04To00P1; // 5 LSBs of delta address register UINT16 m_uDAR04To00P2; // 3 address ROM, 2 mux 8 bits of data into 2 bit delta // carry indicates end of quarter pitch period (32 cycles) UINT16 m_uCWARP1; // 12 bits Control Word Address Register (syllable) UINT16 m_uCWARP2; bool m_bStopP1; bool m_bStopP2; bool m_bVoicedP1; bool m_bVoicedP2; bool m_bSilenceP1; bool m_bSilenceP2; UINT8 m_uLengthP1; // 7 bits, upper three loaded from ROM length UINT8 m_uLengthP2; // middle two loaded from ROM repeat and/or uXRepeat // bit 0 indicates mirror in voiced mode // bit 1 indicates internal silence in voiced mode // incremented each pitch period quarter UINT8 m_uXRepeatP1; // 2 bits, loaded from ROM repeat UINT8 m_uXRepeatP2; UINT8 m_uDeltaOldP1; // 2 bit old delta UINT8 m_uDeltaOldP2; UINT8 m_uOutputP1; // 4 bits audio output, calculated during phase 1 // derived signals bool m_bDAR04To00CarryP2; bool m_bPPQCarryP2; bool m_bRepeatCarryP2; bool m_bLengthCarryP2; UINT16 m_RomAddrP1; // rom address // output pins UINT8 m_uOutputP2; // output changes on phase2 UINT16 m_uRomAddrP2; // address pins change on phase 2 bool m_bBusyP1; // busy changes on phase 1 // input pins bool m_bStart; UINT8 m_uWord; // 6 bit word noumber to be spoken // emulator variables // statistics UINT32 m_uNPitchPeriods; UINT32 m_uNVoiced; UINT32 m_uNControlWords; // diagnostic output UINT32 m_uPrintLevel; }; extern const device_type S14001A; #endif /* __S14001A_H__ */
/********************************************************************** ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved. ** ** This file is part of Qt Designer. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition ** licenses may use this file in accordance with the Qt Commercial License ** Agreement provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for ** information about Qt Commercial License Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef WORKSPACE_H #define WORKSPACE_H #include <qlistview.h> class FormWindow; class QResizeEvent; class QCloseEvent; class QDropEvent; class QDragMoveEvent; class QDragEnterEvent; class MainWindow; class Project; class SourceFile; class FormFile; class QCompletionEdit; class SourceEditor; class WorkspaceItem : public QListViewItem { public: enum Type { ProjectType, FormFileType, FormSourceType, SourceFileType, ObjectType }; WorkspaceItem( QListView *parent, Project* p ); WorkspaceItem( QListViewItem *parent, SourceFile* sf ); WorkspaceItem( QListViewItem *parent, FormFile* ff, Type t = FormFileType ); WorkspaceItem( QListViewItem *parent, QObject *o, Project *p ); void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ); Type type() const { return t; } bool isModified() const; QString text( int ) const; void fillCompletionList( QStringList& completion ); bool checkCompletion( const QString& completion ); QString key( int, bool ) const; // column sorting key Project* project; SourceFile* sourceFile; FormFile* formFile; QObject *object; void setOpen( bool ); void setAutoOpen( bool ); bool isAutoOpen() const { return isOpen() && autoOpen; } bool useOddColor; private: void init(); bool autoOpen; QColor backgroundColor(); Type t; }; class Workspace : public QListView { Q_OBJECT public: Workspace( QWidget *parent , MainWindow *mw ); void setCurrentProject( Project *pro ); void contentsDropEvent( QDropEvent *e ); void contentsDragEnterEvent( QDragEnterEvent *e ); void contentsDragMoveEvent( QDragMoveEvent *e ); void setBufferEdit( QCompletionEdit *edit ); public slots: void update(); void update( FormFile* ); void activeFormChanged( FormWindow *fw ); void activeEditorChanged( SourceEditor *se ); protected: void closeEvent( QCloseEvent *e ); bool eventFilter( QObject *, QEvent * ); private slots: void itemClicked( int, QListViewItem *i, const QPoint& pos ); void itemDoubleClicked( QListViewItem *i ); void rmbClicked( QListViewItem *i, const QPoint& pos ); void bufferChosen( const QString &buffer ); void projectDestroyed( QObject* ); void sourceFileAdded( SourceFile* ); void sourceFileRemoved( SourceFile* ); void formFileAdded( FormFile* ); void formFileRemoved( FormFile* ); void objectAdded( QObject* ); void objectRemoved( QObject * ); private: WorkspaceItem *findItem( FormFile *ff ); WorkspaceItem *findItem( SourceFile *sf ); WorkspaceItem *findItem( QObject *o ); void closeAutoOpenItems(); private: MainWindow *mainWindow; Project *project; WorkspaceItem *projectItem; QCompletionEdit *bufferEdit; bool blockNewForms; void updateBufferEdit(); bool completionDirty; void updateColors(); }; #endif