text
stringlengths
4
6.14k
/* ** $Id: lobject.c,v 1.97 2003/04/03 13:35:34 roberto Exp $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ #include <ctype.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #define lobject_c #include "lua.h" #include "ldo.h" #include "lmem.h" #include "lobject.h" #include "lstate.h" #include "lstring.h" #include "lvm.h" /* function to convert a string to a lua_Number */ #ifndef lua_str2number #define lua_str2number(s,p) strtod((s), (p)) #endif const TObject luaO_nilobject = {LUA_TNIL, {NULL}}; /* ** converts an integer to a "floating point byte", represented as ** (mmmmmxxx), where the real value is (xxx) * 2^(mmmmm) */ int luaO_int2fb (unsigned int x) { int m = 0; /* mantissa */ while (x >= (1<<3)) { x = (x+1) >> 1; m++; } return (m << 3) | cast(int, x); } int luaO_log2 (unsigned int x) { static const lu_byte log_8[255] = { 0, 1,1, 2,2,2,2, 3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 }; if (x >= 0x00010000) { if (x >= 0x01000000) return log_8[((x>>24) & 0xff) - 1]+24; else return log_8[((x>>16) & 0xff) - 1]+16; } else { if (x >= 0x00000100) return log_8[((x>>8) & 0xff) - 1]+8; else if (x) return log_8[(x & 0xff) - 1]; return -1; /* special `log' for 0 */ } } int luaO_rawequalObj (const TObject *t1, const TObject *t2) { if (ttype(t1) != ttype(t2)) return 0; else switch (ttype(t1)) { case LUA_TNIL: return 1; case LUA_TNUMBER: return nvalue(t1) == nvalue(t2); case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); default: lua_assert(iscollectable(t1)); return gcvalue(t1) == gcvalue(t2); } } int luaO_str2d (const char *s, lua_Number *result) { char *endptr; lua_Number res = lua_str2number(s, &endptr); if (endptr == s) return 0; /* no conversion */ while (isspace((unsigned char)(*endptr))) endptr++; if (*endptr != '\0') return 0; /* invalid trailing characters? */ *result = res; return 1; } static void pushstr (lua_State *L, const char *str) { setsvalue2s(L->top, luaS_new(L, str)); incr_top(L); } /* this function handles only `%d', `%c', %f, and `%s' formats */ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { int n = 1; pushstr(L, ""); for (;;) { const char *e = strchr(fmt, '%'); if (e == NULL) break; setsvalue2s(L->top, luaS_newlstr(L, fmt, e-fmt)); incr_top(L); switch (*(e+1)) { case 's': pushstr(L, va_arg(argp, char *)); break; case 'c': { char buff[2]; buff[0] = cast(char, va_arg(argp, int)); buff[1] = '\0'; pushstr(L, buff); break; } case 'd': setnvalue(L->top, cast(lua_Number, va_arg(argp, int))); incr_top(L); break; case 'f': setnvalue(L->top, cast(lua_Number, va_arg(argp, l_uacNumber))); incr_top(L); break; case '%': pushstr(L, "%"); break; default: lua_assert(0); } n += 2; fmt = e+2; } pushstr(L, fmt); luaV_concat(L, n+1, L->top - L->base - 1); L->top -= n; return svalue(L->top - 1); } const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { const char *msg; va_list argp; va_start(argp, fmt); msg = luaO_pushvfstring(L, fmt, argp); va_end(argp); return msg; } void luaO_chunkid (char *out, const char *source, int bufflen) { if (*source == '=') { strncpy(out, source+1, bufflen); /* remove first char */ out[bufflen-1] = '\0'; /* ensures null termination */ } else { /* out = "source", or "...source" */ if (*source == '@') { int l; source++; /* skip the `@' */ bufflen -= sizeof(" `...' "); l = strlen(source); strcpy(out, ""); if (l>bufflen) { source += (l-bufflen); /* get last part of file name */ strcat(out, "..."); } strcat(out, source); } else { /* out = [string "string"] */ int len = strcspn(source, "\n"); /* stop at first newline */ bufflen -= sizeof(" [string \"...\"] "); if (len > bufflen) len = bufflen; strcpy(out, "[string \""); if (source[len] != '\0') { /* must truncate? */ strncat(out, source, len); strcat(out, "..."); } else strcat(out, source); strcat(out, "\"]"); } } }
/*********************************************************************** filename: CEGUIForwardRefs.h created: 21/2/2004 author: Paul D Turner purpose: Forward declares all core system classes *************************************************************************/ /*************************************************************************** * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team * * 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 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 _CEGUIForwardRefs_h_ #define _CEGUIForwardRefs_h_ // Start of CEGUI namespace section namespace CEGUI { /************************************************************************* Forward declare majority of core classes *************************************************************************/ class Affector; class Animation; class AnimationInstance; class AnimationManager; class BasicRenderedStringParser; class BiDiVisualMapping; class CentredRenderedString; class colour; class ColourRect; class CoordConverter; class DefaultLogger; class DefaultRenderedStringParser; class DefaultResourceProvider; class DynamicModule; class Event; class EventArgs; class EventSet; class Exception; class FactoryModule; class Font; class FontGlyph; class FontManager; class FormattedRenderedString; class GeometryBuffer; class GlobalEventSet; class Image; class ImageCodec; class ImagerySection; class Imageset; class ImagesetManager; class Interpolator; class JustifiedRenderedString; class KeyFrame; class LeftAlignedRenderedString; class Logger; class MouseCursor; class Property; class PropertyHelper; class PropertyReceiver; class PropertySet; class RawDataContainer; class Rect; class RegexMatcher; class RenderedString; class RenderedStringComponent; class RenderedStringImageComponent; class RenderedStringParser; class RenderedStringTextComponent; class RenderedStringWidgetComponent; class Renderer; class RenderEffect; class RenderEffectManager; struct RenderingContext; class RenderingRoot; class RenderingSurface; class RenderingWindow; class RenderQueue; class RenderSystem; class RenderTarget; class ResourceEventSet; class ResourceProvider; class RightAlignedRenderedString; class Scheme; class SchemeManager; class ScriptFunctor; class ScriptModule; class Size; class String; class System; class Texture; class TextureTarget; class TextUtils; class UBox; class UDim; class URect; class UVector2; class Vector2; class Vector3; struct Vertex; class WidgetLookFeel; class Window; class WindowFactory; class WindowFactoryManager; class WindowManager; class WindowRenderer; class WindowRendererModule; class WRFactoryRegisterer; class XMLAttributes; class XMLHandler; class XMLParser; /************************************************************************* Forward declare window / widget classes. *************************************************************************/ class ButtonBase; class Checkbox; class ClippedContainer; class Combobox; class ComboDropList; class DragContainer; class Editbox; class FrameWindow; class GridLayoutContainer; class GUISheet; class HorizontalLayoutContainer; class ItemEntry; class ItemListBase; class ItemListbox; class LayoutContainer; class Listbox; class ListboxItem; class ListboxTextItem; class ListHeader; class ListHeaderSegment; class Menubar; class MenuBase; class MenuItem; class MultiColumnList; class MultiLineEditbox; class PopupMenu; class ProgressBar; class PushButton; class RadioButton; class ScrollablePane; class Scrollbar; class ScrolledContainer; class ScrolledItemListBase; class SequentialLayoutContainer; class Slider; class Spinner; class TabButton; class TabControl; class Thumb; class Titlebar; class Tooltip; class Tree; class TreeItem; class VerticalLayoutContainer; /************************************************************************* Forward declare EventArg based classes. *************************************************************************/ class ActivationEventArgs; class DisplayEventArgs; class DragDropEventArgs; class HeaderSequenceEventArgs; class KeyEventArgs; class MouseCursorEventArgs; class MouseEventArgs; class RenderQueueEventArgs; class ResourceEventArgs; class TreeEventArgs; class UpdateEventArgs; class WindowEventArgs; } // End of CEGUI namespace section #endif // end of guard _CEGUIForwardRefs_h_
#include <stdarg.h> #include <stddef.h> #include <setjmp.h> #include "cmockery.h" #include "../auth.c" #ifdef ENABLE_GSS /* Unit tests for check_valid_until_for_gssapi() function */ void test_checkValidUntilForGssapi1(void **state) { int result = -1; Port *port = (Port *) malloc(sizeof(Port)); port->user_name = "foo"; expect_any(get_role_line, role); will_return(get_role_line, NULL); result = check_valid_until_for_gssapi(port); assert_true(result == STATUS_ERROR); } void test_checkValidUntilForGssapi2(void **state) { int result = -1; List *list = list_make1("foo"); List **line = &list; Port *port = (Port *) malloc(sizeof(Port)); port->user_name = "foo"; expect_any(get_role_line, role); will_return(get_role_line, line); result = check_valid_until_for_gssapi(port); assert_true(result == STATUS_OK); } void test_checkValidUntilForGssapi3(void **state) { int result = -1; ListCell *cell; List *list = list_make1(cell); List **line = &list; Port *port = (Port *) malloc(sizeof(Port)); port->user_name = "foo"; expect_any(get_role_line, role); will_return(get_role_line, line); result = check_valid_until_for_gssapi(port); assert_true(result == STATUS_OK); } void test_checkValidUntilForGssapi4(void **state) { int result = -1; ListCell *cell; ListCell *cell1; List *list = list_make2(cell, cell1); List **line = &list; Port *port = (Port *) malloc(sizeof(Port)); port->user_name = "foo"; expect_any(get_role_line, role); will_return(get_role_line, line); result = check_valid_until_for_gssapi(port); assert_true(result == STATUS_OK); } void test_checkValidUntilForGssapi5(void **state) { int result = -1; ListCell *cell; ListCell *cell1; ListCell *cell2; List *list = list_make3(cell, "foo", "bar"); List **line = &list; Port *port = (Port *) malloc(sizeof(Port)); port->user_name = "foo"; expect_any(get_role_line, role); will_return(get_role_line, line); expect_any(DirectFunctionCall3, func); expect_any(DirectFunctionCall3, arg1); expect_any(DirectFunctionCall3, arg2); expect_any(DirectFunctionCall3, arg3); will_return(DirectFunctionCall3, 10293842); will_return(GetCurrentTimestamp, 10293843); result = check_valid_until_for_gssapi(port); assert_true(result == STATUS_ERROR); } void test_checkValidUntilForGssapi6(void **state) { int result = -1; ListCell *cell; ListCell *cell1; ListCell *cell2; List *list = list_make3(cell, "foo", "bar"); List **line = &list; Port *port = (Port *) malloc(sizeof(Port)); port->user_name = "foo"; expect_any(get_role_line, role); will_return(get_role_line, line); expect_any(DirectFunctionCall3, func); expect_any(DirectFunctionCall3, arg1); expect_any(DirectFunctionCall3, arg2); expect_any(DirectFunctionCall3, arg3); will_return(DirectFunctionCall3, 10293844); will_return(GetCurrentTimestamp, 10293843); result = check_valid_until_for_gssapi(port); assert_true(result == STATUS_OK); } #endif int main(int argc, char* argv[]) { cmockery_parse_arguments(argc, argv); const UnitTest tests[] = { #ifdef ENABLE_GSS unit_test(test_checkValidUntilForGssapi1), unit_test(test_checkValidUntilForGssapi2), unit_test(test_checkValidUntilForGssapi3), unit_test(test_checkValidUntilForGssapi4), unit_test(test_checkValidUntilForGssapi5), unit_test(test_checkValidUntilForGssapi6) #endif }; MemoryContextInit(); return run_tests(tests); }
// ======================================================================== // // Copyright 2009-2019 Intel Corporation // // // // Licensed under the Apache License, Version 2.0 (the "License"); // // you may not use this file except in compliance with the License. // // You may obtain a copy of the License at // // // // http://www.apache.org/licenses/LICENSE-2.0 // // // // Unless required by applicable law or agreed to in writing, software // // distributed under the License is distributed on an "AS IS" BASIS, // // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // // limitations under the License. // // ======================================================================== // #pragma once #include "platform.h" #include <vector> #include <map> namespace oidn { template<typename T> using shared_vector = std::shared_ptr<std::vector<T>>; // Generic tensor struct Tensor { float* data; std::vector<int64_t> dims; std::string format; shared_vector<char> buffer; // optional, only for reference counting __forceinline Tensor() : data(nullptr) {} __forceinline Tensor(const std::vector<int64_t>& dims, const std::string& format) : dims(dims), format(format) { buffer = std::make_shared<std::vector<char>>(size() * sizeof(float)); data = (float*)buffer->data(); } __forceinline operator bool() const { return data != nullptr; } __forceinline int ndims() const { return (int)dims.size(); } // Returns the number of values __forceinline size_t size() const { size_t size = 1; for (int i = 0; i < ndims(); ++i) size *= dims[i]; return size; } __forceinline float& operator [](size_t i) { return data[i]; } __forceinline const float& operator [](size_t i) const { return data[i]; } }; // Parses tensors from a buffer std::map<std::string, Tensor> parseTensors(void* buffer); } // namespace oidn
/* Convert wide character to multibyte character. Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2008. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> /* Specification. */ #include <wchar.h> #include <errno.h> #include <stdlib.h> size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps) { /* This implementation of wcrtomb on top of wctomb() supports only stateless encodings. ps must be in the initial state. */ if (ps != NULL && !mbsinit (ps)) { errno = EINVAL; return (size_t)(-1); } if (s == NULL) /* We know the NUL wide character corresponds to the NUL character. */ return 1; else { int ret = wctomb (s, wc); if (ret >= 0) return ret; else { errno = EILSEQ; return (size_t)(-1); } } }
#include "capabilities.h" virCapsPtr testQemuCapsInit(void);
/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- Copyright (c) 2006-2012, assimp team All rights reserved. Redistribution and use of this software 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 assimp team, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of the assimp team. 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. ---------------------------------------------------------------------- */ /** @file MaterialSystem.h * Now that #MaterialHelper is gone, this file only contains some * internal material utility functions. */ #ifndef AI_MATERIALSYSTEM_H_INC #define AI_MATERIALSYSTEM_H_INC namespace Assimp { // ------------------------------------------------------------------------------ /** Computes a hash (hopefully unique) from all material properties * The hash value reflects the current property state, so if you add any * property and call this method again, the resulting hash value will be * different. The hash is not persistent across different builds and platforms. * * @param includeMatName Set to 'true' to take all properties with * '?' as initial character in their name into account. * Currently #AI_MATKEY_NAME is the only example. * @return 32 Bit jash value for the material */ uint32_t ComputeMaterialHash(const aiMaterial* mat, bool includeMatName = false); } // ! namespace Assimp #endif //!! AI_MATERIALSYSTEM_H_INC
/* x509v3.h for libcurl */
/*---------------------------------------------------------------------------- * * File: * eas_reverbdata.c * * Contents and purpose: * Contains the static data allocation for the Reverb effect * * * Copyright Sonic Network Inc. 2006 * 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. * *---------------------------------------------------------------------------- * Revision Control: * $Revision: 550 $ * $Date: 2007-02-02 09:37:03 -0800 (Fri, 02 Feb 2007) $ *---------------------------------------------------------------------------- */ #include "eas_reverbdata.h" S_REVERB_OBJECT eas_ReverbData;
#include <pthread.h> #include <stdio.h> void *threadfunc(void *parm) { printf("Entered secondary thread\n"); while (1) { printf("Secondary thread is looping\n"); pthread_testcancel(); sleep(1); } return NULL; } int main(int argc, char **argv) { pthread_t thread; int rc=0; printf("Entering testcase\n"); /* Create a thread using default attributes */ printf("Create thread using the NULL attributes\n"); rc = pthread_create(&thread, NULL, threadfunc, NULL); /* sleep() is not a very robust way to wait for the thread */ sleep(2); printf("Cancel the thread\n"); rc = pthread_cancel(thread); /* sleep() is not a very robust way to wait for the thread */ sleep(3); printf("Main completed\n"); return 0; }
/***************************************************************************** Copyright (c) 2010, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************** * Contents: Native C interface to LAPACK utility function * Author: Intel Corporation * Created in February, 2010 *****************************************************************************/ #include "lapacke_utils.h" /* Check a matrix for NaN entries. */ lapack_logical LAPACKE_cge_nancheck( int matrix_order, lapack_int m, lapack_int n, const lapack_complex_float *a, lapack_int lda ) { lapack_int i, j; if( a == NULL ) return (lapack_logical) 0; if( matrix_order == LAPACK_COL_MAJOR ) { for( j = 0; j < n; j++ ) { for( i = 0; i < MIN( m, lda ); i++ ) { if( LAPACK_CISNAN( a[i+(size_t)j*lda] ) ) return (lapack_logical) 1; } } } else if ( matrix_order == LAPACK_ROW_MAJOR ) { for( i = 0; i < m; i++ ) { for( j = 0; j < MIN( n, lda ); j++ ) { if( LAPACK_CISNAN( a[(size_t)i*lda+j] ) ) return (lapack_logical) 1; } } } return (lapack_logical) 0; }
// Copyright 2010 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef DOUBLE_CONVERSION_BIGNUM_H_ #define DOUBLE_CONVERSION_BIGNUM_H_ #include "utils.h" namespace double_conversion { class Bignum { public: // 3584 = 128 * 28. We can represent 2^3584 > 10^1000 accurately. // This bignum can encode much bigger numbers, since it contains an // exponent. static const int kMaxSignificantBits = 3584; Bignum() : used_bigits_(0), exponent_(0) {} void AssignUInt16(const uint16_t value); void AssignUInt64(uint64_t value); void AssignBignum(const Bignum& other); void AssignDecimalString(const Vector<const char> value); void AssignHexString(const Vector<const char> value); void AssignPowerUInt16(uint16_t base, const int exponent); void AddUInt64(const uint64_t operand); void AddBignum(const Bignum& other); // Precondition: this >= other. void SubtractBignum(const Bignum& other); void Square(); void ShiftLeft(const int shift_amount); void MultiplyByUInt32(const uint32_t factor); void MultiplyByUInt64(const uint64_t factor); void MultiplyByPowerOfTen(const int exponent); void Times10() { return MultiplyByUInt32(10); } // Pseudocode: // int result = this / other; // this = this % other; // In the worst case this function is in O(this/other). uint16_t DivideModuloIntBignum(const Bignum& other); bool ToHexString(char* buffer, const int buffer_size) const; // Returns // -1 if a < b, // 0 if a == b, and // +1 if a > b. static int Compare(const Bignum& a, const Bignum& b); static bool Equal(const Bignum& a, const Bignum& b) { return Compare(a, b) == 0; } static bool LessEqual(const Bignum& a, const Bignum& b) { return Compare(a, b) <= 0; } static bool Less(const Bignum& a, const Bignum& b) { return Compare(a, b) < 0; } // Returns Compare(a + b, c); static int PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c); // Returns a + b == c static bool PlusEqual(const Bignum& a, const Bignum& b, const Bignum& c) { return PlusCompare(a, b, c) == 0; } // Returns a + b <= c static bool PlusLessEqual(const Bignum& a, const Bignum& b, const Bignum& c) { return PlusCompare(a, b, c) <= 0; } // Returns a + b < c static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) { return PlusCompare(a, b, c) < 0; } private: typedef uint32_t Chunk; typedef uint64_t DoubleChunk; static const int kChunkSize = sizeof(Chunk) * 8; static const int kDoubleChunkSize = sizeof(DoubleChunk) * 8; // With bigit size of 28 we loose some bits, but a double still fits easily // into two chunks, and more importantly we can use the Comba multiplication. static const int kBigitSize = 28; static const Chunk kBigitMask = (1 << kBigitSize) - 1; // Every instance allocates kBigitLength chunks on the stack. Bignums cannot // grow. There are no checks if the stack-allocated space is sufficient. static const int kBigitCapacity = kMaxSignificantBits / kBigitSize; static void EnsureCapacity(const int size) { if (size > kBigitCapacity) { DOUBLE_CONVERSION_UNREACHABLE(); } } void Align(const Bignum& other); void Clamp(); bool IsClamped() const { return used_bigits_ == 0 || RawBigit(used_bigits_ - 1) != 0; } void Zero() { used_bigits_ = 0; exponent_ = 0; } // Requires this to have enough capacity (no tests done). // Updates used_bigits_ if necessary. // shift_amount must be < kBigitSize. void BigitsShiftLeft(const int shift_amount); // BigitLength includes the "hidden" bigits encoded in the exponent. int BigitLength() const { return used_bigits_ + exponent_; } Chunk& RawBigit(const int index); const Chunk& RawBigit(const int index) const; Chunk BigitOrZero(const int index) const; void SubtractTimes(const Bignum& other, const int factor); // The Bignum's value is value(bigits_buffer_) * 2^(exponent_ * kBigitSize), // where the value of the buffer consists of the lower kBigitSize bits of // the first used_bigits_ Chunks in bigits_buffer_, first chunk has lowest // significant bits. int16_t used_bigits_; int16_t exponent_; Chunk bigits_buffer_[kBigitCapacity]; DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Bignum); }; } // namespace double_conversion #endif // DOUBLE_CONVERSION_BIGNUM_H_
/* * linux/arch/unicore32/kernel/ptrace.c * * Code specific to PKUnity SoC and UniCore ISA * * Copyright (C) 2001-2010 GUAN Xue-tao * * By Ross Biro 1/23/92 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/kernel.h> #include <linux/ptrace.h> #include <linux/signal.h> #include <linux/uaccess.h> #include <linux/sched/task_stack.h> /* * this routine will get a word off of the processes privileged stack. * the offset is how far from the base addr as stored in the THREAD. * this routine assumes that all the privileged stacks are in our * data space. */ static inline long get_user_reg(struct task_struct *task, int offset) { return task_pt_regs(task)->uregs[offset]; } /* * this routine will put a word on the processes privileged stack. * the offset is how far from the base addr as stored in the THREAD. * this routine assumes that all the privileged stacks are in our * data space. */ static inline int put_user_reg(struct task_struct *task, int offset, long data) { struct pt_regs newregs, *regs = task_pt_regs(task); int ret = -EINVAL; newregs = *regs; newregs.uregs[offset] = data; if (valid_user_regs(&newregs)) { regs->uregs[offset] = data; ret = 0; } return ret; } /* * Called by kernel/ptrace.c when detaching.. */ void ptrace_disable(struct task_struct *child) { } /* * We actually access the pt_regs stored on the kernel stack. */ static int ptrace_read_user(struct task_struct *tsk, unsigned long off, unsigned long __user *ret) { unsigned long tmp; tmp = 0; if (off < sizeof(struct pt_regs)) tmp = get_user_reg(tsk, off >> 2); return put_user(tmp, ret); } /* * We actually access the pt_regs stored on the kernel stack. */ static int ptrace_write_user(struct task_struct *tsk, unsigned long off, unsigned long val) { if (off >= sizeof(struct pt_regs)) return 0; return put_user_reg(tsk, off >> 2, val); } long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; unsigned long __user *datap = (unsigned long __user *) data; switch (request) { case PTRACE_PEEKUSR: ret = ptrace_read_user(child, addr, datap); break; case PTRACE_POKEUSR: ret = ptrace_write_user(child, addr, data); break; case PTRACE_GET_THREAD_AREA: ret = put_user(task_pt_regs(child)->UCreg_16, datap); break; default: ret = ptrace_request(child, request, addr, data); break; } return ret; } asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno) { unsigned long ip; if (!test_thread_flag(TIF_SYSCALL_TRACE)) return scno; if (!(current->ptrace & PT_PTRACED)) return scno; /* * Save IP. IP is used to denote syscall entry/exit: * IP = 0 -> entry, = 1 -> exit */ ip = regs->UCreg_ip; regs->UCreg_ip = why; current_thread_info()->syscall = scno; /* the 0x80 provides a way for the tracing parent to distinguish between a syscall stop and SIGTRAP delivery */ ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); /* * this isn't the same as continuing with a signal, but it will do * for normal use. strace only continues with a signal if the * stopping signal is not SIGTRAP. -brl */ if (current->exit_code) { send_sig(current->exit_code, current, 1); current->exit_code = 0; } regs->UCreg_ip = ip; return current_thread_info()->syscall; }
// Copyright (c) 2013 GitHub, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #ifndef ATOM_BROWSER_API_ATOM_API_WINDOW_H_ #define ATOM_BROWSER_API_ATOM_API_WINDOW_H_ #include <string> #include <vector> #include "base/memory/scoped_ptr.h" #include "ui/gfx/image/image.h" #include "atom/browser/api/trackable_object.h" #include "atom/browser/native_window.h" #include "atom/browser/native_window_observer.h" #include "native_mate/handle.h" class GURL; namespace gfx { class Rect; } namespace mate { class Arguments; class Dictionary; } namespace atom { class NativeWindow; namespace api { class WebContents; class Window : public mate::TrackableObject<Window>, public NativeWindowObserver { public: static mate::Wrappable* New(v8::Isolate* isolate, const mate::Dictionary& options); static void BuildPrototype(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype); NativeWindow* window() const { return window_.get(); } protected: Window(v8::Isolate* isolate, const mate::Dictionary& options); virtual ~Window(); // NativeWindowObserver: void OnPageTitleUpdated(bool* prevent_default, const std::string& title) override; void WillCloseWindow(bool* prevent_default) override; void OnWindowClosed() override; void OnWindowBlur() override; void OnWindowFocus() override; void OnWindowMaximize() override; void OnWindowUnmaximize() override; void OnWindowMinimize() override; void OnWindowRestore() override; void OnWindowResize() override; void OnWindowMove() override; void OnWindowMoved() override; void OnWindowEnterFullScreen() override; void OnWindowLeaveFullScreen() override; void OnWindowEnterHtmlFullScreen() override; void OnWindowLeaveHtmlFullScreen() override; void OnRendererUnresponsive() override; void OnRendererResponsive() override; void OnDevToolsFocus() override; void OnDevToolsOpened() override; void OnDevToolsClosed() override; void OnExecuteWindowsCommand(const std::string& command_name) override; // mate::Wrappable: bool IsDestroyed() const override; private: // mate::TrackableObject: void Destroy() override; // APIs for NativeWindow. void Close(); bool IsClosed(); void Focus(); bool IsFocused(); void Show(); void ShowInactive(); void Hide(); bool IsVisible(); void Maximize(); void Unmaximize(); bool IsMaximized(); void Minimize(); void Restore(); bool IsMinimized(); void SetFullScreen(bool fullscreen); bool IsFullscreen(); void SetBounds(const gfx::Rect& bounds); gfx::Rect GetBounds(); void SetSize(int width, int height); std::vector<int> GetSize(); void SetContentSize(int width, int height); std::vector<int> GetContentSize(); void SetMinimumSize(int width, int height); std::vector<int> GetMinimumSize(); void SetMaximumSize(int width, int height); std::vector<int> GetMaximumSize(); void SetResizable(bool resizable); bool IsResizable(); void SetAlwaysOnTop(bool top); bool IsAlwaysOnTop(); void Center(); void SetPosition(int x, int y); std::vector<int> GetPosition(); void SetTitle(const std::string& title); std::string GetTitle(); void FlashFrame(bool flash); void SetSkipTaskbar(bool skip); void SetKiosk(bool kiosk); bool IsKiosk(); void FocusOnWebView(); void BlurWebView(); bool IsWebViewFocused(); bool IsDevToolsFocused(); void SetRepresentedFilename(const std::string& filename); std::string GetRepresentedFilename(); void SetDocumentEdited(bool edited); bool IsDocumentEdited(); void CapturePage(mate::Arguments* args); void SetProgressBar(double progress); void SetOverlayIcon(const gfx::Image& overlay, const std::string& description); bool SetThumbarButtons(mate::Arguments* args); void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu); void SetAutoHideMenuBar(bool auto_hide); bool IsMenuBarAutoHide(); void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); void SetAspectRatio(double aspect_ratio, mate::Arguments* args); #if defined(OS_MACOSX) void ShowDefinitionForSelection(); #endif void SetVisibleOnAllWorkspaces(bool visible); bool IsVisibleOnAllWorkspaces(); int32_t ID() const; v8::Local<v8::Value> WebContents(v8::Isolate* isolate); v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate); v8::Global<v8::Value> web_contents_; v8::Global<v8::Value> devtools_web_contents_; v8::Global<v8::Value> menu_; api::WebContents* api_web_contents_; scoped_ptr<NativeWindow> window_; DISALLOW_COPY_AND_ASSIGN(Window); }; } // namespace api } // namespace atom namespace mate { template<> struct Converter<atom::NativeWindow*> { static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, atom::NativeWindow** out) { // null would be tranfered to NULL. if (val->IsNull()) { *out = NULL; return true; } atom::api::Window* window; if (!Converter<atom::api::Window*>::FromV8(isolate, val, &window)) return false; *out = window->window(); return true; } }; } // namespace mate #endif // ATOM_BROWSER_API_ATOM_API_WINDOW_H_
/* ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "ch.h" #include "hal.h" static void pwmpcb(PWMDriver *pwmp) { (void)pwmp; palClearPad(GPIOD, GPIOD_LED5); } static void pwmc1cb(PWMDriver *pwmp) { (void)pwmp; palSetPad(GPIOD, GPIOD_LED5); } static PWMConfig pwmcfg = { 10000, /* 10kHz PWM clock frequency. */ 10000, /* Initial PWM period 1S. */ pwmpcb, { {PWM_OUTPUT_ACTIVE_HIGH, pwmc1cb}, {PWM_OUTPUT_DISABLED, NULL}, {PWM_OUTPUT_DISABLED, NULL}, {PWM_OUTPUT_DISABLED, NULL} }, 0, 0 }; icucnt_t last_width, last_period; static void icuwidthcb(ICUDriver *icup) { palSetPad(GPIOD, GPIOD_LED4); last_width = icuGetWidthX(icup); } static void icuperiodcb(ICUDriver *icup) { palClearPad(GPIOD, GPIOD_LED4); last_period = icuGetPeriodX(icup); } static ICUConfig icucfg = { ICU_INPUT_ACTIVE_HIGH, 10000, /* 10kHz ICU clock frequency. */ icuwidthcb, icuperiodcb, NULL, ICU_CHANNEL_1, 0 }; /* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Initializes the PWM driver 2 and ICU driver 3. * GPIOA8 is the PWM output. * GPIOC6 is the ICU input. * The two pins have to be externally connected together. */ pwmStart(&PWMD1, &pwmcfg); pwmEnablePeriodicNotification(&PWMD1); palSetPadMode(GPIOA, 8, PAL_MODE_ALTERNATE(1)); icuStart(&ICUD3, &icucfg); palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2)); icuStartCapture(&ICUD3); icuEnableNotifications(&ICUD3); chThdSleepMilliseconds(2000); /* * Starts the PWM channel 0 using 75% duty cycle. */ pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 7500)); pwmEnableChannelNotification(&PWMD1, 0); chThdSleepMilliseconds(5000); /* * Changes the PWM channel 0 to 50% duty cycle. */ pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000)); chThdSleepMilliseconds(5000); /* * Changes the PWM channel 0 to 25% duty cycle. */ pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 2500)); chThdSleepMilliseconds(5000); /* * Changes PWM period to half second the duty cycle becomes 50% * implicitly. */ pwmChangePeriod(&PWMD1, 5000); chThdSleepMilliseconds(5000); /* * Disables channel 0 and stops the drivers. */ pwmDisableChannel(&PWMD1, 0); pwmStop(&PWMD1); icuStopCapture(&ICUD3); icuStop(&ICUD3); palClearPad(GPIOD, GPIOD_LED4); palClearPad(GPIOD, GPIOD_LED5); /* * Normal main() thread activity, in this demo it does nothing. */ while (true) { chThdSleepMilliseconds(500); } return 0; }
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org> */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/cpu.h> #include <asm/cpu.h> #include <asm/cpu-info.h> #include <asm/mipsregs.h> #include <bcm63xx_cpu.h> #include <bcm63xx_regs.h> #include <bcm63xx_io.h> #include <bcm63xx_irq.h> const unsigned long *bcm63xx_regs_base; EXPORT_SYMBOL(bcm63xx_regs_base); const int *bcm63xx_irqs; EXPORT_SYMBOL(bcm63xx_irqs); static u16 bcm63xx_cpu_id; static u16 bcm63xx_cpu_rev; static unsigned int bcm63xx_cpu_freq; static unsigned int bcm63xx_memory_size; static const unsigned long bcm6338_regs_base[] = { __GEN_CPU_REGS_TABLE(6338) }; static const int bcm6338_irqs[] = { __GEN_CPU_IRQ_TABLE(6338) }; static const unsigned long bcm6345_regs_base[] = { __GEN_CPU_REGS_TABLE(6345) }; static const int bcm6345_irqs[] = { __GEN_CPU_IRQ_TABLE(6345) }; static const unsigned long bcm6348_regs_base[] = { __GEN_CPU_REGS_TABLE(6348) }; static const int bcm6348_irqs[] = { __GEN_CPU_IRQ_TABLE(6348) }; static const unsigned long bcm6358_regs_base[] = { __GEN_CPU_REGS_TABLE(6358) }; static const int bcm6358_irqs[] = { __GEN_CPU_IRQ_TABLE(6358) }; static const unsigned long bcm6368_regs_base[] = { __GEN_CPU_REGS_TABLE(6368) }; static const int bcm6368_irqs[] = { __GEN_CPU_IRQ_TABLE(6368) }; u16 __bcm63xx_get_cpu_id(void) { return bcm63xx_cpu_id; } EXPORT_SYMBOL(__bcm63xx_get_cpu_id); u16 bcm63xx_get_cpu_rev(void) { return bcm63xx_cpu_rev; } EXPORT_SYMBOL(bcm63xx_get_cpu_rev); unsigned int bcm63xx_get_cpu_freq(void) { return bcm63xx_cpu_freq; } unsigned int bcm63xx_get_memory_size(void) { return bcm63xx_memory_size; } static unsigned int detect_cpu_clock(void) { switch (bcm63xx_get_cpu_id()) { case BCM6338_CPU_ID: return 240000000; case BCM6345_CPU_ID: return 140000000; case BCM6348_CPU_ID: { unsigned int tmp, n1, n2, m1; tmp = bcm_perf_readl(PERF_MIPSPLLCTL_REG); n1 = (tmp & MIPSPLLCTL_N1_MASK) >> MIPSPLLCTL_N1_SHIFT; n2 = (tmp & MIPSPLLCTL_N2_MASK) >> MIPSPLLCTL_N2_SHIFT; m1 = (tmp & MIPSPLLCTL_M1CPU_MASK) >> MIPSPLLCTL_M1CPU_SHIFT; n1 += 1; n2 += 2; m1 += 1; return (16 * 1000000 * n1 * n2) / m1; } case BCM6358_CPU_ID: { unsigned int tmp, n1, n2, m1; tmp = bcm_ddr_readl(DDR_DMIPSPLLCFG_REG); n1 = (tmp & DMIPSPLLCFG_N1_MASK) >> DMIPSPLLCFG_N1_SHIFT; n2 = (tmp & DMIPSPLLCFG_N2_MASK) >> DMIPSPLLCFG_N2_SHIFT; m1 = (tmp & DMIPSPLLCFG_M1_MASK) >> DMIPSPLLCFG_M1_SHIFT; return (16 * 1000000 * n1 * n2) / m1; } case BCM6368_CPU_ID: { unsigned int tmp, p1, p2, ndiv, m1; tmp = bcm_ddr_readl(DDR_DMIPSPLLCFG_6368_REG); p1 = (tmp & DMIPSPLLCFG_6368_P1_MASK) >> DMIPSPLLCFG_6368_P1_SHIFT; p2 = (tmp & DMIPSPLLCFG_6368_P2_MASK) >> DMIPSPLLCFG_6368_P2_SHIFT; ndiv = (tmp & DMIPSPLLCFG_6368_NDIV_MASK) >> DMIPSPLLCFG_6368_NDIV_SHIFT; tmp = bcm_ddr_readl(DDR_DMIPSPLLDIV_6368_REG); m1 = (tmp & DMIPSPLLDIV_6368_MDIV_MASK) >> DMIPSPLLDIV_6368_MDIV_SHIFT; return (((64 * 1000000) / p1) * p2 * ndiv) / m1; } default: BUG(); } } static unsigned int detect_memory_size(void) { unsigned int cols = 0, rows = 0, is_32bits = 0, banks = 0; u32 val; if (BCMCPU_IS_6345()) { val = bcm_sdram_readl(SDRAM_MBASE_REG); return (val * 8 * 1024 * 1024); } if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) { val = bcm_sdram_readl(SDRAM_CFG_REG); rows = (val & SDRAM_CFG_ROW_MASK) >> SDRAM_CFG_ROW_SHIFT; cols = (val & SDRAM_CFG_COL_MASK) >> SDRAM_CFG_COL_SHIFT; is_32bits = (val & SDRAM_CFG_32B_MASK) ? 1 : 0; banks = (val & SDRAM_CFG_BANK_MASK) ? 2 : 1; } if (BCMCPU_IS_6358() || BCMCPU_IS_6368()) { val = bcm_memc_readl(MEMC_CFG_REG); rows = (val & MEMC_CFG_ROW_MASK) >> MEMC_CFG_ROW_SHIFT; cols = (val & MEMC_CFG_COL_MASK) >> MEMC_CFG_COL_SHIFT; is_32bits = (val & MEMC_CFG_32B_MASK) ? 0 : 1; banks = 2; } rows += 11; cols += 8; return 1 << (cols + rows + (is_32bits + 1) + banks); } void __init bcm63xx_cpu_init(void) { unsigned int tmp, expected_cpu_id; struct cpuinfo_mips *c = &current_cpu_data; unsigned int cpu = smp_processor_id(); expected_cpu_id = 0; switch (c->cputype) { case CPU_BMIPS3300: if ((read_c0_prid() & 0xff00) == PRID_IMP_BMIPS3300_ALT) { expected_cpu_id = BCM6348_CPU_ID; bcm63xx_regs_base = bcm6348_regs_base; bcm63xx_irqs = bcm6348_irqs; } else { __cpu_name[cpu] = "Broadcom BCM6338"; expected_cpu_id = BCM6338_CPU_ID; bcm63xx_regs_base = bcm6338_regs_base; bcm63xx_irqs = bcm6338_irqs; } break; case CPU_BMIPS32: expected_cpu_id = BCM6345_CPU_ID; bcm63xx_regs_base = bcm6345_regs_base; bcm63xx_irqs = bcm6345_irqs; break; case CPU_BMIPS4350: switch (read_c0_prid() & 0xf0) { case 0x10: expected_cpu_id = BCM6358_CPU_ID; bcm63xx_regs_base = bcm6358_regs_base; bcm63xx_irqs = bcm6358_irqs; break; case 0x30: expected_cpu_id = BCM6368_CPU_ID; bcm63xx_regs_base = bcm6368_regs_base; bcm63xx_irqs = bcm6368_irqs; break; } break; } if (!expected_cpu_id) panic("unsupported Broadcom CPU"); tmp = bcm_perf_readl(PERF_REV_REG); bcm63xx_cpu_id = (tmp & REV_CHIPID_MASK) >> REV_CHIPID_SHIFT; bcm63xx_cpu_rev = (tmp & REV_REVID_MASK) >> REV_REVID_SHIFT; if (bcm63xx_cpu_id != expected_cpu_id) panic("bcm63xx CPU id mismatch"); bcm63xx_cpu_freq = detect_cpu_clock(); bcm63xx_memory_size = detect_memory_size(); printk(KERN_INFO "Detected Broadcom 0x%04x CPU revision %02x\n", bcm63xx_cpu_id, bcm63xx_cpu_rev); printk(KERN_INFO "CPU frequency is %u MHz\n", bcm63xx_cpu_freq / 1000000); printk(KERN_INFO "%uMB of RAM installed\n", bcm63xx_memory_size >> 20); }
/* * Freescale PWM Register Definitions * * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. * Copyright 2008-2010 Freescale Semiconductor, 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 * * This file is created by xml file. Don't Edit it. * * Xml Revision: 1.23 * Template revision: 26195 */ #ifndef __ARCH_ARM___PWM_H #define __ARCH_ARM___PWM_H #define HW_PWM_CTRL (0x00000000) #define HW_PWM_CTRL_SET (0x00000004) #define HW_PWM_CTRL_CLR (0x00000008) #define HW_PWM_CTRL_TOG (0x0000000c) #define BM_PWM_CTRL_SFTRST 0x80000000 #define BM_PWM_CTRL_CLKGATE 0x40000000 #define BM_PWM_CTRL_PWM4_PRESENT 0x20000000 #define BM_PWM_CTRL_PWM3_PRESENT 0x10000000 #define BM_PWM_CTRL_PWM2_PRESENT 0x08000000 #define BM_PWM_CTRL_PWM1_PRESENT 0x04000000 #define BM_PWM_CTRL_PWM0_PRESENT 0x02000000 #define BP_PWM_CTRL_RSRVD1 7 #define BM_PWM_CTRL_RSRVD1 0x01FFFF80 #define BF_PWM_CTRL_RSRVD1(v) \ (((v) << 7) & BM_PWM_CTRL_RSRVD1) #define BM_PWM_CTRL_OUTPUT_CUTOFF_EN 0x00000040 #define BM_PWM_CTRL_PWM2_ANA_CTRL_ENABLE 0x00000020 #define BM_PWM_CTRL_PWM4_ENABLE 0x00000010 #define BM_PWM_CTRL_PWM3_ENABLE 0x00000008 #define BM_PWM_CTRL_PWM2_ENABLE 0x00000004 #define BM_PWM_CTRL_PWM1_ENABLE 0x00000002 #define BM_PWM_CTRL_PWM0_ENABLE 0x00000001 /* * multi-register-define name HW_PWM_ACTIVEn * base 0x00000010 * count 5 * offset 0x20 */ #define HW_PWM_ACTIVEn(n) (0x00000010 + (n) * 0x20) #define HW_PWM_ACTIVEn_SET(n) (0x00000014 + (n) * 0x20) #define HW_PWM_ACTIVEn_CLR(n) (0x00000018 + (n) * 0x20) #define HW_PWM_ACTIVEn_TOG(n) (0x0000001c + (n) * 0x20) #define BP_PWM_ACTIVEn_INACTIVE 16 #define BM_PWM_ACTIVEn_INACTIVE 0xFFFF0000 #define BF_PWM_ACTIVEn_INACTIVE(v) \ (((v) << 16) & BM_PWM_ACTIVEn_INACTIVE) #define BP_PWM_ACTIVEn_ACTIVE 0 #define BM_PWM_ACTIVEn_ACTIVE 0x0000FFFF #define BF_PWM_ACTIVEn_ACTIVE(v) \ (((v) << 0) & BM_PWM_ACTIVEn_ACTIVE) /* * multi-register-define name HW_PWM_PERIODn * base 0x00000020 * count 5 * offset 0x20 */ #define HW_PWM_PERIODn(n) (0x00000020 + (n) * 0x20) #define HW_PWM_PERIODn_SET(n) (0x00000024 + (n) * 0x20) #define HW_PWM_PERIODn_CLR(n) (0x00000028 + (n) * 0x20) #define HW_PWM_PERIODn_TOG(n) (0x0000002c + (n) * 0x20) #define BP_PWM_PERIODn_RSRVD2 25 #define BM_PWM_PERIODn_RSRVD2 0xFE000000 #define BF_PWM_PERIODn_RSRVD2(v) \ (((v) << 25) & BM_PWM_PERIODn_RSRVD2) #define BM_PWM_PERIODn_MATT_SEL 0x01000000 #define BM_PWM_PERIODn_MATT 0x00800000 #define BP_PWM_PERIODn_CDIV 20 #define BM_PWM_PERIODn_CDIV 0x00700000 #define BF_PWM_PERIODn_CDIV(v) \ (((v) << 20) & BM_PWM_PERIODn_CDIV) #define BV_PWM_PERIODn_CDIV__DIV_1 0x0 #define BV_PWM_PERIODn_CDIV__DIV_2 0x1 #define BV_PWM_PERIODn_CDIV__DIV_4 0x2 #define BV_PWM_PERIODn_CDIV__DIV_8 0x3 #define BV_PWM_PERIODn_CDIV__DIV_16 0x4 #define BV_PWM_PERIODn_CDIV__DIV_64 0x5 #define BV_PWM_PERIODn_CDIV__DIV_256 0x6 #define BV_PWM_PERIODn_CDIV__DIV_1024 0x7 #define BP_PWM_PERIODn_INACTIVE_STATE 18 #define BM_PWM_PERIODn_INACTIVE_STATE 0x000C0000 #define BF_PWM_PERIODn_INACTIVE_STATE(v) \ (((v) << 18) & BM_PWM_PERIODn_INACTIVE_STATE) #define BV_PWM_PERIODn_INACTIVE_STATE__HI_Z 0x0 #define BV_PWM_PERIODn_INACTIVE_STATE__0 0x2 #define BV_PWM_PERIODn_INACTIVE_STATE__1 0x3 #define BP_PWM_PERIODn_ACTIVE_STATE 16 #define BM_PWM_PERIODn_ACTIVE_STATE 0x00030000 #define BF_PWM_PERIODn_ACTIVE_STATE(v) \ (((v) << 16) & BM_PWM_PERIODn_ACTIVE_STATE) #define BV_PWM_PERIODn_ACTIVE_STATE__HI_Z 0x0 #define BV_PWM_PERIODn_ACTIVE_STATE__0 0x2 #define BV_PWM_PERIODn_ACTIVE_STATE__1 0x3 #define BP_PWM_PERIODn_PERIOD 0 #define BM_PWM_PERIODn_PERIOD 0x0000FFFF #define BF_PWM_PERIODn_PERIOD(v) \ (((v) << 0) & BM_PWM_PERIODn_PERIOD) #define HW_PWM_VERSION (0x000000b0) #define BP_PWM_VERSION_MAJOR 24 #define BM_PWM_VERSION_MAJOR 0xFF000000 #define BF_PWM_VERSION_MAJOR(v) \ (((v) << 24) & BM_PWM_VERSION_MAJOR) #define BP_PWM_VERSION_MINOR 16 #define BM_PWM_VERSION_MINOR 0x00FF0000 #define BF_PWM_VERSION_MINOR(v) \ (((v) << 16) & BM_PWM_VERSION_MINOR) #define BP_PWM_VERSION_STEP 0 #define BM_PWM_VERSION_STEP 0x0000FFFF #define BF_PWM_VERSION_STEP(v) \ (((v) << 0) & BM_PWM_VERSION_STEP) #endif /* __ARCH_ARM___PWM_H */
#include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/device.h> #include <linux/slab.h> #include <linux/fs.h> #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/vmalloc.h> #include <linux/platform_device.h> #include <linux/miscdevice.h> #include <linux/wait.h> #include <linux/spinlock.h> #include <linux/ctype.h> #include <linux/semaphore.h> #include <asm/uaccess.h> #include <asm/io.h> #include <linux/workqueue.h> #include <linux/switch.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/kdev_t.h> #include <linux/fs.h> #include <linux/cdev.h> #include <asm/uaccess.h> #include <linux/kthread.h> #include <linux/input.h> #include <linux/wakelock.h> #include <linux/time.h> #include <linux/string.h> #include <mach/mt_typedefs.h> #include <mach/mt_reg_base.h> #include <mach/irqs.h> #include <mach/reg_accdet.h> #include <accdet_custom.h> #include <accdet_custom_def.h> /*---------------------------------------------------------------------- IOCTL ----------------------------------------------------------------------*/ #define ACCDET_DEVNAME "accdet" #define ACCDET_IOC_MAGIC 'A' #define ACCDET_INIT _IO(ACCDET_IOC_MAGIC,0) #define SET_CALL_STATE _IO(ACCDET_IOC_MAGIC,1) #define GET_BUTTON_STATUS _IO(ACCDET_IOC_MAGIC,2) /*define for phone call state*/ #define CALL_IDLE 0 #define CALL_RINGING 1 #define CALL_ACTIVE 2 #define KEY_CALL KEY_SEND #define KEY_ENDCALL KEY_HANGEUL /**************************************************** globle ACCDET variables ****************************************************/ enum accdet_report_state { NO_DEVICE =0, HEADSET_MIC = 1, HEADSET_NO_MIC = 2, //HEADSET_ILEGAL = 3, //DOUBLE_CHECK_TV = 4 }; enum accdet_status { PLUG_OUT = 0, MIC_BIAS = 1, //DOUBLE_CHECK = 2, HOOK_SWITCH = 2, //MIC_BIAS_ILLEGAL =3, //TV_OUT = 5, STAND_BY =4 }; char *accdet_status_string[5]= { "Plug_out", "Headset_plug_in", //"Double_check", "Hook_switch", //"Tvout_plug_in", "Stand_by" }; char *accdet_report_string[4]= { "No_device", "Headset_mic", "Headset_no_mic", //"HEADSET_illegal", // "Double_check" }; enum hook_switch_result { DO_NOTHING =0, ANSWER_CALL = 1, REJECT_CALL = 2 }; /* typedef enum { TVOUT_STATUS_OK = 0, TVOUT_STATUS_ALREADY_SET, TVOUT_STATUS_ERROR, } TVOUT_STATUS; */
/* * SoftDog: A Software Watchdog Device * * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide * warranty for any of this software. This material is provided * "AS-IS" and at no charge. * * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> * * Software only watchdog driver. Unlike its big brother the WDT501P * driver this won't always recover a failed machine. * * 03/96: Angelo Haritsis <ah@doc.ic.ac.uk> : * Modularised. * Added soft_margin; use upon insmod to change the timer delay. * NB: uses same minor as wdt (WATCHDOG_MINOR); we could use separate * minors. * * 19980911 Alan Cox * Made SMP safe for 2.3.x * * 20011127 Joel Becker (jlbec@evilplan.org> * Added soft_noboot; Allows testing the softdog trigger without * requiring a recompile. * Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT. * * 20020530 Joel Becker <joel.becker@oracle.com> * Added Matt Domsch's nowayout module option. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/types.h> #include <linux/timer.h> #include <linux/miscdevice.h> #include <linux/watchdog.h> #include <linux/notifier.h> #include <linux/reboot.h> #include <linux/init.h> #include <linux/jiffies.h> #include <linux/kernel.h> #define TIMER_MARGIN 60 static unsigned int soft_margin = TIMER_MARGIN; module_param(soft_margin, uint, 0); MODULE_PARM_DESC(soft_margin, "Watchdog soft_margin in seconds. (0 < soft_margin < 65536, default=" __MODULE_STRING(TIMER_MARGIN) ")"); static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static int soft_noboot = 0; module_param(soft_noboot, int, 0); MODULE_PARM_DESC(soft_noboot, "Softdog action, set to 1 to ignore reboots, 0 to reboot (default=0)"); static int soft_panic; module_param(soft_panic, int, 0); MODULE_PARM_DESC(soft_panic, "Softdog action, set to 1 to panic, 0 to reboot (default=0)"); static void watchdog_fire(unsigned long); static struct timer_list watchdog_ticktock = TIMER_INITIALIZER(watchdog_fire, 0, 0); static void watchdog_fire(unsigned long data) { if (soft_noboot) pr_crit("Triggered - Reboot ignored\n"); else if (soft_panic) { pr_crit("Initiating panic\n"); panic("Software Watchdog Timer expired"); } else { pr_crit("Initiating system reboot\n"); emergency_restart(); pr_crit("Reboot didn't ?????\n"); } } static int softdog_ping(struct watchdog_device *w) { mod_timer(&watchdog_ticktock, jiffies+(w->timeout*HZ)); return 0; } static int softdog_stop(struct watchdog_device *w) { del_timer(&watchdog_ticktock); return 0; } static int softdog_set_timeout(struct watchdog_device *w, unsigned int t) { w->timeout = t; return 0; } static int softdog_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { if (code == SYS_DOWN || code == SYS_HALT) softdog_stop(NULL); return NOTIFY_DONE; } static struct notifier_block softdog_notifier = { .notifier_call = softdog_notify_sys, }; static struct watchdog_info softdog_info = { .identity = "Software Watchdog", .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, }; static struct watchdog_ops softdog_ops = { .owner = THIS_MODULE, .start = softdog_ping, .stop = softdog_stop, .ping = softdog_ping, .set_timeout = softdog_set_timeout, }; static struct watchdog_device softdog_dev = { .info = &softdog_info, .ops = &softdog_ops, .min_timeout = 1, .max_timeout = 0xFFFF }; static int __init watchdog_init(void) { int ret; if (soft_margin < 1 || soft_margin > 65535) { pr_info("soft_margin must be 0 < soft_margin < 65536, using %d\n", TIMER_MARGIN); return -EINVAL; } softdog_dev.timeout = soft_margin; watchdog_set_nowayout(&softdog_dev, nowayout); ret = register_reboot_notifier(&softdog_notifier); if (ret) { pr_err("cannot register reboot notifier (err=%d)\n", ret); return ret; } ret = watchdog_register_device(&softdog_dev); if (ret) { unregister_reboot_notifier(&softdog_notifier); return ret; } pr_info("Software Watchdog Timer: 0.08 initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d (nowayout=%d)\n", soft_noboot, soft_margin, soft_panic, nowayout); return 0; } static void __exit watchdog_exit(void) { watchdog_unregister_device(&softdog_dev); unregister_reboot_notifier(&softdog_notifier); } module_init(watchdog_init); module_exit(watchdog_exit); MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("Software Watchdog Device Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
/* * OMAP2+ MPU WD_TIMER-specific code * * 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. */ #include <linux/kernel.h> #include <linux/io.h> #include <linux/err.h> #include <plat/omap_hwmod.h> #include "wd_timer.h" #define OMAP_WDT_WPS 0x34 #define OMAP_WDT_SPR 0x48 int omap2_wd_timer_disable(struct omap_hwmod *oh) { void __iomem *base; if (!oh) { pr_err("%s: Could not look up wdtimer_hwmod\n", __func__); return -EINVAL; } base = omap_hwmod_get_mpu_rt_va(oh); if (!base) { pr_err("%s: Could not get the base address for %s\n", oh->name, __func__); return -EINVAL; } __raw_writel(0xAAAA, base + OMAP_WDT_SPR); while (__raw_readl(base + OMAP_WDT_WPS) & 0x10) cpu_relax(); __raw_writel(0x5555, base + OMAP_WDT_SPR); while (__raw_readl(base + OMAP_WDT_WPS) & 0x10) cpu_relax(); return 0; }
/* * MobiCore client library device management. * * Device and Trustlet Session management Functions. * * <-- Copyright Giesecke & Devrient GmbH 2009 - 2012 --> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/list.h> #include <linux/slab.h> #include <linux/device.h> #include "mc_kernel_api.h" #include "public/mobicore_driver_api.h" #include "device.h" #include "common.h" struct wsm *wsm_create(void *virt_addr, uint32_t len, uint32_t handle, void *phys_addr) { struct wsm *wsm; wsm = kzalloc(sizeof(*wsm), GFP_KERNEL); wsm->virt_addr = virt_addr; wsm->len = len; wsm->handle = handle; wsm->phys_addr = phys_addr; return wsm; } struct mcore_device_t *mcore_device_create(uint32_t device_id, struct connection *connection) { struct mcore_device_t *dev; dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev->device_id = device_id; dev->connection = connection; INIT_LIST_HEAD(&dev->session_vector); INIT_LIST_HEAD(&dev->wsm_l2_vector); return dev; } void mcore_device_cleanup(struct mcore_device_t *dev) { struct session *tmp; struct wsm *wsm; struct list_head *pos, *q; list_for_each_safe(pos, q, &dev->session_vector) { tmp = list_entry(pos, struct session, list); list_del(pos); session_cleanup(tmp); } list_for_each_safe(pos, q, &dev->wsm_l2_vector) { wsm = list_entry(pos, struct wsm, list); list_del(pos); kfree(wsm); } connection_cleanup(dev->connection); mcore_device_close(dev); kfree(dev); } bool mcore_device_open(struct mcore_device_t *dev, const char *deviceName) { dev->instance = mobicore_open(); return (dev->instance != NULL); } void mcore_device_close(struct mcore_device_t *dev) { mobicore_release(dev->instance); } bool mcore_device_has_sessions(struct mcore_device_t *dev) { return !list_empty(&dev->session_vector); } bool mcore_device_create_new_session(struct mcore_device_t *dev, uint32_t session_id, struct connection *connection) { if (mcore_device_resolve_session_id(dev, session_id)) { MCDRV_DBG_ERROR(mc_kapi, " session %u already exists", session_id); return false; } struct session *session = session_create(session_id, dev->instance, connection); list_add_tail(&(session->list), &(dev->session_vector)); return true; } bool mcore_device_remove_session(struct mcore_device_t *dev, uint32_t session_id) { bool ret = false; struct session *tmp; struct list_head *pos, *q; list_for_each_safe(pos, q, &dev->session_vector) { tmp = list_entry(pos, struct session, list); if (tmp->session_id == session_id) { list_del(pos); session_cleanup(tmp); ret = true; break; } } return ret; } struct session *mcore_device_resolve_session_id(struct mcore_device_t *dev, uint32_t session_id) { struct session *ret = NULL; struct session *tmp; struct list_head *pos; list_for_each(pos, &dev->session_vector) { tmp = list_entry(pos, struct session, list); if (tmp->session_id == session_id) { ret = tmp; break; } } return ret; } struct wsm *mcore_device_allocate_contiguous_wsm(struct mcore_device_t *dev, uint32_t len) { struct wsm *wsm = NULL; do { if (len == 0) break; void *virt_addr; uint32_t handle; void *phys_addr; int ret = mobicore_allocate_wsm(dev->instance, len, &handle, &virt_addr, &phys_addr); if (ret != 0) break; wsm = wsm_create(virt_addr, len, handle, phys_addr); list_add_tail(&(wsm->list), &(dev->wsm_l2_vector)); } while (0); return wsm; } bool mcore_device_free_contiguous_wsm(struct mcore_device_t *dev, struct wsm *wsm) { bool ret = false; struct wsm *tmp; struct list_head *pos; list_for_each(pos, &dev->wsm_l2_vector) { tmp = list_entry(pos, struct wsm, list); if (tmp == wsm) { ret = true; break; } } if (ret) { MCDRV_DBG_VERBOSE(mc_kapi, "freeWsm virt_addr=0x%p, handle=%d", wsm->virt_addr, wsm->handle); mobicore_free_wsm(dev->instance, wsm->handle); list_del(pos); kfree(wsm); } return ret; } struct wsm *mcore_device_find_contiguous_wsm(struct mcore_device_t *dev, void *virt_addr) { struct wsm *wsm; struct list_head *pos; list_for_each(pos, &dev->wsm_l2_vector) { wsm = list_entry(pos, struct wsm, list); if (virt_addr == wsm->virt_addr) return wsm; } return NULL; }
#ifndef _OZURBPARANOIA_H #define _OZURBPARANOIA_H /* ----------------------------------------------------------------------------- * Released under the GNU General Public License Version 2 (GPLv2). * Copyright (c) 2011 Ozmo Inc * ----------------------------------------------------------------------------- */ #ifdef WANT_URB_PARANOIA void oz_remember_urb(struct urb *urb); int oz_forget_urb(struct urb *urb); #else #define oz_remember_urb(__x) #define oz_forget_urb(__x) 0 #endif #endif
// // InviteViewController.h // Funner // // Created by highjump on 14-11-9. // // #import <UIKit/UIKit.h> @interface InviteViewController : UIViewController @end
/* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com */ #include "tomcrypt.h" /** @file der_length_bit_string.c ASN.1 DER, get length of BIT STRING, Tom St Denis */ #ifdef LTC_DER /** Gets length of DER encoding of BIT STRING @param nbits The number of bits in the string to encode @param outlen [out] The length of the DER encoding for the given string @return CRYPT_OK if successful */ int der_length_bit_string(unsigned long nbits, unsigned long *outlen) { unsigned long nbytes; LTC_ARGCHK(outlen != NULL); /* get the number of the bytes */ nbytes = (nbits >> 3) + ((nbits & 7) ? 1 : 0) + 1; if (nbytes < 128) { /* 03 LL PP DD DD DD ... */ *outlen = 2 + nbytes; } else if (nbytes < 256) { /* 03 81 LL PP DD DD DD ... */ *outlen = 3 + nbytes; } else if (nbytes < 65536) { /* 03 82 LL LL PP DD DD DD ... */ *outlen = 4 + nbytes; } else { return CRYPT_INVALID_ARG; } return CRYPT_OK; } #endif /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_length_bit_string.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2006/03/31 14:15:35 $ */
/* SPDX-License-Identifier: MIT */ /* * Copyright © 2019 Intel Corporation */ #ifndef __I915_GEM_REGION_H__ #define __I915_GEM_REGION_H__ #include <linux/types.h> struct intel_memory_region; struct drm_i915_gem_object; struct sg_table; void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj, struct intel_memory_region *mem); void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj); struct drm_i915_gem_object * i915_gem_object_create_region(struct intel_memory_region *mem, resource_size_t size, resource_size_t page_size, unsigned int flags); #endif
/* Copyright (c) 2008-2010, Code Aurora Forum. 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 Code Aurora Forum, 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 "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * 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 MSM_FB_PANEL_H #define MSM_FB_PANEL_H #include "msm_fb_def.h" struct msm_fb_data_type; typedef void (*msm_fb_vsync_handler_type) (void *arg); /* panel id type */ typedef struct panel_id_s { uint16 id; uint16 type; } panel_id_type; /* panel type list */ #define NO_PANEL 0xffff /* No Panel */ #define MDDI_PANEL 1 /* MDDI */ #define EBI2_PANEL 2 /* EBI2 */ #define LCDC_PANEL 3 /* internal LCDC type */ #define EXT_MDDI_PANEL 4 /* Ext.MDDI */ #define TV_PANEL 5 /* TV */ #define HDMI_PANEL 6 /* HDMI TV */ #define DTV_PANEL 7 /* DTV */ #define MIPI_VIDEO_PANEL 8 /* MIPI */ #define MIPI_CMD_PANEL 9 /* MIPI */ /* panel class */ typedef enum { DISPLAY_LCD = 0, /* lcd = ebi2/mddi */ DISPLAY_LCDC, /* lcdc */ DISPLAY_TV, /* TV Out */ DISPLAY_EXT_MDDI, /* External MDDI */ } DISP_TARGET; /* panel device locaiton */ typedef enum { DISPLAY_1 = 0, /* attached as first device */ DISPLAY_2, /* attached on second device */ MAX_PHYS_TARGET_NUM, } DISP_TARGET_PHYS; /* panel info type */ struct lcd_panel_info { __u32 vsync_enable; __u32 refx100; __u32 v_back_porch; __u32 v_front_porch; __u32 v_pulse_width; __u32 hw_vsync_mode; __u32 vsync_notifier_period; __u32 rev; }; struct lcdc_panel_info { __u32 h_back_porch; __u32 h_front_porch; __u32 h_pulse_width; __u32 v_back_porch; __u32 v_front_porch; __u32 v_pulse_width; __u32 border_clr; __u32 underflow_clr; __u32 hsync_skew; }; struct mddi_panel_info { __u32 vdopkt; }; /* DSI PHY configuration */ struct mipi_dsi_phy_ctrl { uint32 regulator[4]; uint32 timing[12]; uint32 ctrl[4]; uint32 strength[4]; uint32 pll[21]; }; struct mipi_panel_info { char mode; /* video/cmd */ char interleave_mode; char crc_check; char ecc_check; char dst_format; /* shared by video and command */ char data_lane0; char data_lane1; char data_lane2; char data_lane3; char dlane_swap; /* data lane swap */ char rgb_swap; char b_sel; char g_sel; char r_sel; char rx_eot_ignore; char tx_eot_append; char t_clk_post; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */ char t_clk_pre; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */ char vc; /* virtual channel */ struct mipi_dsi_phy_ctrl *dsi_phy_db; /* video mode */ char pulse_mode_hsa_he; char hfp_power_stop; char hbp_power_stop; char hsa_power_stop; char eof_bllp_power_stop; char bllp_power_stop; char traffic_mode; /* command mode */ char interleave_max; char insert_dcs_cmd; char wr_mem_continue; char wr_mem_start; char te_sel; char stream; /* 0 or 1 */ char mdp_trigger; char dma_trigger; }; struct msm_panel_info { __u32 xres; __u32 yres; __u32 bpp; __u32 mode2_xres; __u32 mode2_yres; __u32 mode2_bpp; __u32 type; __u32 wait_cycle; DISP_TARGET_PHYS pdest; __u32 bl_max; __u32 bl_min; __u32 fb_num; __u32 clk_rate; __u32 clk_min; __u32 clk_max; __u32 frame_count; union { struct mddi_panel_info mddi; }; union { struct lcd_panel_info lcd; struct lcdc_panel_info lcdc; }; struct mipi_panel_info mipi; }; #define MSM_FB_SINGLE_MODE_PANEL(pinfo) \ do { \ (pinfo)->mode2_xres = 0; \ (pinfo)->mode2_yres = 0; \ (pinfo)->mode2_bpp = 0; \ } while (0) struct msm_fb_panel_data { struct msm_panel_info panel_info; void (*set_rect) (int x, int y, int xres, int yres); void (*set_vsync_notifier) (msm_fb_vsync_handler_type, void *arg); void (*set_backlight) (struct msm_fb_data_type *); void (*display_on) (struct msm_fb_data_type *); /* function entry chain */ int (*on) (struct platform_device *pdev); int (*off) (struct platform_device *pdev); void (*bklswitch) (struct msm_fb_data_type *, bool on); void (*bklctrl) (bool on); void (*panel_type_detect) (void); struct platform_device *next; int (*clk_func) (int enable); }; /*=========================================================================== FUNCTIONS PROTOTYPES ============================================================================*/ struct platform_device *msm_fb_device_alloc(struct msm_fb_panel_data *pdata, u32 type, u32 id); int panel_next_on(struct platform_device *pdev); int panel_next_off(struct platform_device *pdev); int lcdc_device_register(struct msm_panel_info *pinfo); int mddi_toshiba_device_register(struct msm_panel_info *pinfo, u32 channel, u32 panel); #endif /* MSM_FB_PANEL_H */
// SPDX-License-Identifier: GPL-2.0-only /* * kretprobe_example.c * * Here's a sample kernel module showing the use of return probes to * report the return value and total time taken for probed function * to run. * * usage: insmod kretprobe_example.ko func=<func_name> * * If no func_name is specified, _do_fork is instrumented * * For more information on theory of operation of kretprobes, see * Documentation/kprobes.txt * * Build and insert the kernel module as done in the kprobe example. * You will see the trace data in /var/log/messages and on the console * whenever the probed function returns. (Some messages may be suppressed * if syslogd is configured to eliminate duplicate messages.) */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/kprobes.h> #include <linux/ktime.h> #include <linux/limits.h> #include <linux/sched.h> static char func_name[NAME_MAX] = "_do_fork"; module_param_string(func, func_name, NAME_MAX, S_IRUGO); MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the" " function's execution time"); /* per-instance private data */ struct my_data { ktime_t entry_stamp; }; /* Here we use the entry_hanlder to timestamp function entry */ static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs) { struct my_data *data; if (!current->mm) return 1; /* Skip kernel threads */ data = (struct my_data *)ri->data; data->entry_stamp = ktime_get(); return 0; } NOKPROBE_SYMBOL(entry_handler); /* * Return-probe handler: Log the return value and duration. Duration may turn * out to be zero consistently, depending upon the granularity of time * accounting on the platform. */ static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs) { unsigned long retval = regs_return_value(regs); struct my_data *data = (struct my_data *)ri->data; s64 delta; ktime_t now; now = ktime_get(); delta = ktime_to_ns(ktime_sub(now, data->entry_stamp)); pr_info("%s returned %lu and took %lld ns to execute\n", func_name, retval, (long long)delta); return 0; } NOKPROBE_SYMBOL(ret_handler); static struct kretprobe my_kretprobe = { .handler = ret_handler, .entry_handler = entry_handler, .data_size = sizeof(struct my_data), /* Probe up to 20 instances concurrently. */ .maxactive = 20, }; static int __init kretprobe_init(void) { int ret; my_kretprobe.kp.symbol_name = func_name; ret = register_kretprobe(&my_kretprobe); if (ret < 0) { pr_err("register_kretprobe failed, returned %d\n", ret); return -1; } pr_info("Planted return probe at %s: %p\n", my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr); return 0; } static void __exit kretprobe_exit(void) { unregister_kretprobe(&my_kretprobe); pr_info("kretprobe at %p unregistered\n", my_kretprobe.kp.addr); /* nmissed > 0 suggests that maxactive was set too low. */ pr_info("Missed probing %d instances of %s\n", my_kretprobe.nmissed, my_kretprobe.kp.symbol_name); } module_init(kretprobe_init) module_exit(kretprobe_exit) MODULE_LICENSE("GPL");
/*************************************************************************/ /* position_3d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* 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 POSITION_3D_H #define POSITION_3D_H #include "scene/3d/spatial.h" class Position3D : public Spatial { OBJ_TYPE(Position3D,Spatial); virtual RES _get_gizmo_geometry() const; public: Position3D(); }; #endif // POSITION_3D_H
// Copyright 2012 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef V8_PLATFORM_POSIX_H_ #define V8_PLATFORM_POSIX_H_ namespace v8 { namespace internal { // Used by platform implementation files during OS::PostSetUp(). void POSIXPostSetUp(); } } // namespace v8::internal #endif // V8_PLATFORM_POSIX_H_
#ifndef SEC_MTD_H #define SEC_MTD_H #include <mach/sec_osal.h> /************************************************************************** * MTD INTERNAL DEFINITION **************************************************************************/ typedef struct _MtdRCtx { char *buf; ASF_FILE fd; } MtdRCtx; /************************************************************************** * MTD CONFIGURATION **************************************************************************/ #define ROM_INFO_SEARCH_LEN (0x100000) #define SECRO_SEARCH_START (0x0) #define SECRO_SEARCH_LEN (0x100000) /* mtd number */ #define MTD_PL_NUM (0x0) #define MTD_SECCFG_NUM (0x3) /* indicate the search region each time */ #define ROM_INFO_SEARCH_REGION (0x2000) #define SECRO_SEARCH_REGION (0x4000) /****************************************************************************** * EXPORT FUNCTION ******************************************************************************/ extern void sec_mtd_find_partitions(void); extern unsigned int sec_mtd_read_image(char *part_name, char *buf, unsigned int off, unsigned int sz); extern unsigned int sec_mtd_get_off(char *part_name); #endif /* SEC_MTD_H */
/* Unix SMB/CIFS implementation. SMB parameters and setup, plus a whole lot more. Copyright (C) Jeremy Allison 2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _LOCKING_H #define _LOCKING_H /* passed to br lock code - the UNLOCK_LOCK should never be stored into the tdb and is used in calculating POSIX unlock ranges only. We differentiate between PENDING read and write locks to allow posix lock downgrades to trigger a lock re-evaluation. */ enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_READ_LOCK, PENDING_WRITE_LOCK, UNLOCK_LOCK}; enum brl_flavour {WINDOWS_LOCK = 0, POSIX_LOCK = 1}; #define IS_PENDING_LOCK(type) ((type) == PENDING_READ_LOCK || (type) == PENDING_WRITE_LOCK) #include "librpc/gen_ndr/server_id.h" /* This contains elements that differentiate locks. The smbpid is a client supplied pid, and is essentially the locking context for this client */ struct lock_context { uint64_t smblctx; uint32_t tid; struct server_id pid; }; struct files_struct; #include "lib/file_id.h" struct byte_range_lock; /* Internal structure in brlock.tdb. The data in brlock records is an unsorted linear array of these records. It is unnecessary to store the count as tdb provides the size of the record */ struct lock_struct { struct lock_context context; br_off start; br_off size; uint64_t fnum; enum brl_type lock_type; enum brl_flavour lock_flav; }; /**************************************************************************** This is the structure to queue to implement blocking locks. *****************************************************************************/ struct blocking_lock_record { struct blocking_lock_record *next; struct blocking_lock_record *prev; struct files_struct *fsp; struct timeval expire_time; int lock_num; uint64_t offset; uint64_t count; uint64_t smblctx; uint64_t blocking_smblctx; /* Context that blocks us. */ enum brl_flavour lock_flav; enum brl_type lock_type; struct smb_request *req; void *blr_private; /* Implementation specific. */ }; struct smbd_lock_element { uint64_t smblctx; enum brl_type brltype; uint64_t offset; uint64_t count; }; struct share_mode_lock { struct share_mode_data *data; }; #endif /* _LOCKING_H_ */
#include "../../src/gui/kernel/qplatformglcontext_qpa.h"
#ifndef __GLX_glxint_h__ #define __GLX_glxint_h__ /* * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice including the dates of first publication and * either this permission notice or a reference to * http://oss.sgi.com/projects/FreeB/ * 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 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Silicon Graphics, Inc. * shall not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization from * Silicon Graphics, Inc. */ #include <X11/X.h> #include <X11/Xdefs.h> #include "GL/gl.h" typedef struct __GLXvisualConfigRec __GLXvisualConfig; typedef struct __GLXFBConfigRec __GLXFBConfig; struct __GLXvisualConfigRec { VisualID vid; int class; Bool rgba; int redSize, greenSize, blueSize, alphaSize; unsigned long redMask, greenMask, blueMask, alphaMask; int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize; Bool doubleBuffer; Bool stereo; int bufferSize; int depthSize; int stencilSize; int auxBuffers; int level; /* Start of Extended Visual Properties */ int visualRating; /* visual_rating extension */ int transparentPixel; /* visual_info extension */ /* colors are floats scaled to ints */ int transparentRed, transparentGreen, transparentBlue, transparentAlpha; int transparentIndex; int multiSampleSize; int nMultiSampleBuffers; int visualSelectGroup; }; #define __GLX_MIN_CONFIG_PROPS 18 #define __GLX_MAX_CONFIG_PROPS 500 #define __GLX_EXT_CONFIG_PROPS 10 /* ** Since we send all non-core visual properties as token, value pairs, ** we require 2 words across the wire. In order to maintain backwards ** compatibility, we need to send the total number of words that the ** VisualConfigs are sent back in so old libraries can simply "ignore" ** the new properties. */ #define __GLX_TOTAL_CONFIG (__GLX_MIN_CONFIG_PROPS + \ 2 * __GLX_EXT_CONFIG_PROPS) struct __GLXFBConfigRec { int visualType; int transparentType; /* colors are floats scaled to ints */ int transparentRed, transparentGreen, transparentBlue, transparentAlpha; int transparentIndex; int visualCaveat; int associatedVisualId; int screen; int drawableType; int renderType; int maxPbufferWidth, maxPbufferHeight, maxPbufferPixels; int optimalPbufferWidth, optimalPbufferHeight; /* for SGIX_pbuffer */ int visualSelectGroup; /* visuals grouped by select priority */ unsigned int id; GLboolean rgbMode; GLboolean colorIndexMode; GLboolean doubleBufferMode; GLboolean stereoMode; GLboolean haveAccumBuffer; GLboolean haveDepthBuffer; GLboolean haveStencilBuffer; /* The number of bits present in various buffers */ GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; GLint depthBits; GLint stencilBits; GLint indexBits; GLint redBits, greenBits, blueBits, alphaBits; GLuint redMask, greenMask, blueMask, alphaMask; GLuint multiSampleSize; /* Number of samples per pixel (0 if no ms) */ GLuint nMultiSampleBuffers; /* Number of availble ms buffers */ GLint maxAuxBuffers; /* frame buffer level */ GLint level; /* color ranges (for SGI_color_range) */ GLboolean extendedRange; GLdouble minRed, maxRed; GLdouble minGreen, maxGreen; GLdouble minBlue, maxBlue; GLdouble minAlpha, maxAlpha; }; #define __GLX_TOTAL_FBCONFIG_PROPS 35 #endif /* !__GLX_glxint_h__ */
#define _tmain main #define _TCHAR char
// 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 UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ #define UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_ #include <string> #include "base/compiler_specific.h" #include "base/strings/string16.h" #include "ui/views/controls/button/label_button.h" namespace views { // A native themed class representing a checkbox. This class does not use // platform specific objects to replicate the native platforms looks and feel. class VIEWS_EXPORT Checkbox : public LabelButton { public: static const char kViewClassName[]; explicit Checkbox(const base::string16& label); virtual ~Checkbox(); // Sets a listener for this checkbox. Checkboxes aren't required to have them // since their state can be read independently of them being toggled. void set_listener(ButtonListener* listener) { listener_ = listener; } // Sets/Gets whether or not the checkbox is checked. virtual void SetChecked(bool checked); bool checked() const { return checked_; } protected: // Overridden from LabelButton: virtual void Layout() OVERRIDE; virtual const char* GetClassName() const OVERRIDE; virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; virtual const gfx::ImageSkia& GetImage(ButtonState for_state) OVERRIDE; // Set the image shown for each button state depending on whether it is // [checked] or [focused]. void SetCustomImage(bool checked, bool focused, ButtonState for_state, const gfx::ImageSkia& image); private: // Overridden from Button: virtual void NotifyClick(const ui::Event& event) OVERRIDE; virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; virtual void GetExtraParams( ui::NativeTheme::ExtraParams* params) const OVERRIDE; // True if the checkbox is checked. bool checked_; // The images for each button state. gfx::ImageSkia images_[2][2][STATE_COUNT]; DISALLOW_COPY_AND_ASSIGN(Checkbox); }; } // namespace views #endif // UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2013 Davidlohr Bueso <davidlohr@hp.com> * * futex-requeue: Block a bunch of threads on futex1 and requeue them * on futex2, N at a time. * * This program is particularly useful to measure the latency of nthread * requeues without waking up any tasks -- thus mimicking a regular futex_wait. */ /* For the CLR_() macros */ #include <string.h> #include <pthread.h> #include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> #include <linux/compiler.h> #include <linux/kernel.h> #include <linux/time64.h> #include <errno.h> #include "bench.h" #include "futex.h" #include <err.h> #include <stdlib.h> #include <sys/time.h> static u_int32_t futex1 = 0, futex2 = 0; /* * How many tasks to requeue at a time. * Default to 1 in order to make the kernel work more. */ static unsigned int nrequeue = 1; static pthread_t *worker; static bool done = false, silent = false, fshared = false; static pthread_mutex_t thread_lock; static pthread_cond_t thread_parent, thread_worker; static struct stats requeuetime_stats, requeued_stats; static unsigned int ncpus, threads_starting, nthreads = 0; static int futex_flag = 0; static const struct option options[] = { OPT_UINTEGER('t', "threads", &nthreads, "Specify amount of threads"), OPT_UINTEGER('q', "nrequeue", &nrequeue, "Specify amount of threads to requeue at once"), OPT_BOOLEAN( 's', "silent", &silent, "Silent mode: do not display data/details"), OPT_BOOLEAN( 'S', "shared", &fshared, "Use shared futexes instead of private ones"), OPT_END() }; static const char * const bench_futex_requeue_usage[] = { "perf bench futex requeue <options>", NULL }; static void print_summary(void) { double requeuetime_avg = avg_stats(&requeuetime_stats); double requeuetime_stddev = stddev_stats(&requeuetime_stats); unsigned int requeued_avg = avg_stats(&requeued_stats); printf("Requeued %d of %d threads in %.4f ms (+-%.2f%%)\n", requeued_avg, nthreads, requeuetime_avg / USEC_PER_MSEC, rel_stddev_stats(requeuetime_stddev, requeuetime_avg)); } static void *workerfn(void *arg __maybe_unused) { pthread_mutex_lock(&thread_lock); threads_starting--; if (!threads_starting) pthread_cond_signal(&thread_parent); pthread_cond_wait(&thread_worker, &thread_lock); pthread_mutex_unlock(&thread_lock); futex_wait(&futex1, 0, NULL, futex_flag); return NULL; } static void block_threads(pthread_t *w, pthread_attr_t thread_attr) { cpu_set_t cpu; unsigned int i; threads_starting = nthreads; /* create and block all threads */ for (i = 0; i < nthreads; i++) { CPU_ZERO(&cpu); CPU_SET(i % ncpus, &cpu); if (pthread_attr_setaffinity_np(&thread_attr, sizeof(cpu_set_t), &cpu)) err(EXIT_FAILURE, "pthread_attr_setaffinity_np"); if (pthread_create(&w[i], &thread_attr, workerfn, NULL)) err(EXIT_FAILURE, "pthread_create"); } } static void toggle_done(int sig __maybe_unused, siginfo_t *info __maybe_unused, void *uc __maybe_unused) { done = true; } int bench_futex_requeue(int argc, const char **argv) { int ret = 0; unsigned int i, j; struct sigaction act; pthread_attr_t thread_attr; argc = parse_options(argc, argv, options, bench_futex_requeue_usage, 0); if (argc) goto err; ncpus = sysconf(_SC_NPROCESSORS_ONLN); sigfillset(&act.sa_mask); act.sa_sigaction = toggle_done; sigaction(SIGINT, &act, NULL); if (!nthreads) nthreads = ncpus; worker = calloc(nthreads, sizeof(*worker)); if (!worker) err(EXIT_FAILURE, "calloc"); if (!fshared) futex_flag = FUTEX_PRIVATE_FLAG; if (nrequeue > nthreads) nrequeue = nthreads; printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), " "%d at a time.\n\n", getpid(), nthreads, fshared ? "shared":"private", &futex1, &futex2, nrequeue); init_stats(&requeued_stats); init_stats(&requeuetime_stats); pthread_attr_init(&thread_attr); pthread_mutex_init(&thread_lock, NULL); pthread_cond_init(&thread_parent, NULL); pthread_cond_init(&thread_worker, NULL); for (j = 0; j < bench_repeat && !done; j++) { unsigned int nrequeued = 0; struct timeval start, end, runtime; /* create, launch & block all threads */ block_threads(worker, thread_attr); /* make sure all threads are already blocked */ pthread_mutex_lock(&thread_lock); while (threads_starting) pthread_cond_wait(&thread_parent, &thread_lock); pthread_cond_broadcast(&thread_worker); pthread_mutex_unlock(&thread_lock); usleep(100000); /* Ok, all threads are patiently blocked, start requeueing */ gettimeofday(&start, NULL); while (nrequeued < nthreads) { /* * Do not wakeup any tasks blocked on futex1, allowing * us to really measure futex_wait functionality. */ nrequeued += futex_cmp_requeue(&futex1, 0, &futex2, 0, nrequeue, futex_flag); } gettimeofday(&end, NULL); timersub(&end, &start, &runtime); update_stats(&requeued_stats, nrequeued); update_stats(&requeuetime_stats, runtime.tv_usec); if (!silent) { printf("[Run %d]: Requeued %d of %d threads in %.4f ms\n", j + 1, nrequeued, nthreads, runtime.tv_usec / (double)USEC_PER_MSEC); } /* everybody should be blocked on futex2, wake'em up */ nrequeued = futex_wake(&futex2, nrequeued, futex_flag); if (nthreads != nrequeued) warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads); for (i = 0; i < nthreads; i++) { ret = pthread_join(worker[i], NULL); if (ret) err(EXIT_FAILURE, "pthread_join"); } } /* cleanup & report results */ pthread_cond_destroy(&thread_parent); pthread_cond_destroy(&thread_worker); pthread_mutex_destroy(&thread_lock); pthread_attr_destroy(&thread_attr); print_summary(); free(worker); return ret; err: usage_with_options(bench_futex_requeue_usage, options); exit(EXIT_FAILURE); }
/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _ASM_X86_AGP_H #define _ASM_X86_AGP_H #include <asm/pgtable.h> #include <asm/cacheflush.h> /* * Functions to keep the agpgart mappings coherent with the MMU. The * GART gives the CPU a physical alias of pages in memory. The alias * region is mapped uncacheable. Make sure there are no conflicting * mappings with different cachability attributes for the same * page. This avoids data corruption on some CPUs. */ #define map_page_into_agp(page) set_pages_uc(page, 1) #define unmap_page_from_agp(page) set_pages_wb(page, 1) /* * Could use CLFLUSH here if the cpu supports it. But then it would * need to be called for each cacheline of the whole page so it may * not be worth it. Would need a page for it. */ #define flush_agp_cache() wbinvd() /* GATT allocation. Returns/accepts GATT kernel virtual address. */ #define alloc_gatt_pages(order) \ ((char *)__get_free_pages(GFP_KERNEL, (order))) #define free_gatt_pages(table, order) \ free_pages((unsigned long)(table), (order)) #endif /* _ASM_X86_AGP_H */
/*version.h =========*/ #define MAJOR_VERSION "1" #define MINOR_VERSION "7"
/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #ifndef GOB_SOUND_INFOGRAMES_H #define GOB_SOUND_INFOGRAMES_H #include "audio/mixer.h" #include "audio/mods/infogrames.h" namespace Gob { class Infogrames { public: Infogrames(Audio::Mixer &mixer); ~Infogrames(); bool loadInstruments(const char *fileName); bool loadSong(const char *fileName); void play(); void stop(); private: Audio::Mixer *_mixer; Audio::Infogrames::Instruments *_instruments; Audio::Infogrames *_song; Audio::SoundHandle _handle; void clearInstruments(); void clearSong(); bool loadInst(const char *fileName); }; } // End of namespace Gob #endif // GOB_SOUND_INFOGRAMES_H
/* Common hooks for Motorola MCore. Copyright (C) 1993-2015 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC 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 GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ #include "config.h" #include "system.h" #include "coretypes.h" #include "tm.h" #include "common/common-target.h" #include "common/common-target-def.h" /* What options are we going to default to specific settings when -O* happens; the user can subsequently override these settings. Omitting the frame pointer is a very good idea on the MCore. Scheduling isn't worth anything on the current MCore implementation. */ static const struct default_options mcore_option_optimization_table[] = { { OPT_LEVELS_1_PLUS, OPT_ffunction_cse, NULL, 0 }, { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, { OPT_LEVELS_ALL, OPT_fcaller_saves, NULL, 0 }, { OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 }, { OPT_LEVELS_ALL, OPT_fschedule_insns2, NULL, 0 }, { OPT_LEVELS_SIZE, OPT_mhardlit, NULL, 0 }, { OPT_LEVELS_NONE, 0, NULL, 0 } }; #undef TARGET_DEFAULT_TARGET_FLAGS #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT #undef TARGET_OPTION_OPTIMIZATION_TABLE #define TARGET_OPTION_OPTIMIZATION_TABLE mcore_option_optimization_table #undef TARGET_EXCEPT_UNWIND_INFO #define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
#ifndef __SUN3_HEAD_H #define __SUN3_HEAD_H #define KERNBASE 0xE000000 /* First address the kernel will eventually be */ #define LOAD_ADDR 0x4000 /* prom jumps to us here unless this is elf /boot */ #define FC_CONTROL 3 #define FC_SUPERD 5 #define FC_CPU 7 #endif /* __SUN3_HEAD_H */
/* * trace_export.c - export basic ftrace utilities to user space * * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com> */ #include <linux/stringify.h> #include <linux/kallsyms.h> #include <linux/seq_file.h> #include <linux/debugfs.h> #include <linux/uaccess.h> #include <linux/ftrace.h> #include <linux/module.h> #include <linux/init.h> #include <linux/fs.h> #include "trace_output.h" #undef TRACE_SYSTEM #define TRACE_SYSTEM ftrace /* not needed for this file */ #undef __field_struct #define __field_struct(type, item) #undef __field #define __field(type, item) type item; #undef __field_desc #define __field_desc(type, container, item) type item; #undef __array #define __array(type, item, size) type item[size]; #undef __array_desc #define __array_desc(type, container, item, size) type item[size]; #undef __dynamic_array #define __dynamic_array(type, item) type item[]; #undef F_STRUCT #define F_STRUCT(args...) args #undef F_printk #define F_printk(fmt, args...) fmt, args #undef FTRACE_ENTRY #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ struct ____ftrace_##name { \ tstruct \ }; \ static void __always_unused ____ftrace_check_##name(void) \ { \ struct ____ftrace_##name *__entry = NULL; \ \ /* force compile-time check on F_printk() */ \ printk(print); \ } #undef FTRACE_ENTRY_DUP #define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \ FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) #include "trace_entries.h" #undef __field #define __field(type, item) \ ret = trace_define_field(event_call, #type, #item, \ offsetof(typeof(field), item), \ sizeof(field.item), \ is_signed_type(type), FILTER_OTHER); \ if (ret) \ return ret; #undef __field_desc #define __field_desc(type, container, item) \ ret = trace_define_field(event_call, #type, #item, \ offsetof(typeof(field), \ container.item), \ sizeof(field.container.item), \ is_signed_type(type), FILTER_OTHER); \ if (ret) \ return ret; #undef __array #define __array(type, item, len) \ BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ ret = trace_define_field(event_call, #type "[" #len "]", #item, \ offsetof(typeof(field), item), \ sizeof(field.item), \ is_signed_type(type), FILTER_OTHER); \ if (ret) \ return ret; #undef __array_desc #define __array_desc(type, container, item, len) \ BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ ret = trace_define_field(event_call, #type "[" #len "]", #item, \ offsetof(typeof(field), \ container.item), \ sizeof(field.container.item), \ is_signed_type(type), FILTER_OTHER); \ if (ret) \ return ret; #undef __dynamic_array #define __dynamic_array(type, item) \ ret = trace_define_field(event_call, #type, #item, \ offsetof(typeof(field), item), \ 0, is_signed_type(type), FILTER_OTHER);\ if (ret) \ return ret; #undef FTRACE_ENTRY #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ int \ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ { \ struct struct_name field; \ int ret; \ \ tstruct; \ \ return ret; \ } #include "trace_entries.h" static int ftrace_raw_init_event(struct ftrace_event_call *call) { INIT_LIST_HEAD(&call->fields); return 0; } #undef __entry #define __entry REC #undef __field #define __field(type, item) #undef __field_desc #define __field_desc(type, container, item) #undef __array #define __array(type, item, len) #undef __array_desc #define __array_desc(type, container, item, len) #undef __dynamic_array #define __dynamic_array(type, item) #undef F_printk #define F_printk(fmt, args...) #fmt ", " __stringify(args) #undef FTRACE_ENTRY #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \ \ struct ftrace_event_call __used \ __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) event_##call = { \ .name = #call, \ .id = type, \ .system = __stringify(TRACE_SYSTEM), \ .raw_init = ftrace_raw_init_event, \ .print_fmt = print, \ .define_fields = ftrace_define_fields_##call, \ }; \ #include "trace_entries.h"
/* visorchipset_umode.h * * Copyright © 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; 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, GOOD TITLE or * NON INFRINGEMENT. See the GNU General Public License for more * details. */ /** @file ********************************************************************* * * This describes structures needed for the interface between the * visorchipset driver and a user-mode component that opens the device. * ****************************************************************************** */ #ifndef __VISORCHIPSET_UMODE_H #define __VISORCHIPSET_UMODE_H /** The user-mode program can access the control channel buffer directly * via this memory map. */ #define VISORCHIPSET_MMAP_CONTROLCHANOFFSET (0x00000000) #define VISORCHIPSET_MMAP_CONTROLCHANSIZE (0x00400000) /* 4MB */ #endif /* __VISORCHIPSET_UMODE_H */
/* SPDX-License-Identifier: GPL-2.0-only */ #ifndef RTL8180_SA2400_H #define RTL8180_SA2400_H /* * Radio tuning for Philips SA2400 on RTL8180 * * Copyright 2007 Andrea Merello <andrea.merello@gmail.com> * * Code from the BSD driver and the rtl8181 project have been * very useful to understand certain things * * I want to thanks the Authors of such projects and the Ndiswrapper * project Authors. * * A special Big Thanks also is for all people who donated me cards, * making possible the creation of the original rtl8180 driver * from which this code is derived! */ #define SA2400_ANTENNA 0x91 #define SA2400_DIG_ANAPARAM_PWR1_ON 0x8 #define SA2400_ANA_ANAPARAM_PWR1_ON 0x28 #define SA2400_ANAPARAM_PWR0_ON 0x3 /* RX sensitivity in dbm */ #define SA2400_MAX_SENS 85 #define SA2400_REG4_FIRDAC_SHIFT 7 extern const struct rtl818x_rf_ops sa2400_rf_ops; #endif /* RTL8180_SA2400_H */
// SPDX-License-Identifier: GPL-2.0 /* * Check for extended topology enumeration cpuid leaf 0xb and if it * exists, use it for populating initial_apicid and cpu topology * detection. */ #include <linux/cpu.h> #include <asm/apic.h> #include <asm/pat.h> #include <asm/processor.h> #include "cpu.h" /* leaf 0xb SMT level */ #define SMT_LEVEL 0 /* extended topology sub-leaf types */ #define INVALID_TYPE 0 #define SMT_TYPE 1 #define CORE_TYPE 2 #define DIE_TYPE 5 #define LEAFB_SUBTYPE(ecx) (((ecx) >> 8) & 0xff) #define BITS_SHIFT_NEXT_LEVEL(eax) ((eax) & 0x1f) #define LEVEL_MAX_SIBLINGS(ebx) ((ebx) & 0xffff) #ifdef CONFIG_SMP unsigned int __max_die_per_package __read_mostly = 1; EXPORT_SYMBOL(__max_die_per_package); /* * Check if given CPUID extended toplogy "leaf" is implemented */ static int check_extended_topology_leaf(int leaf) { unsigned int eax, ebx, ecx, edx; cpuid_count(leaf, SMT_LEVEL, &eax, &ebx, &ecx, &edx); if (ebx == 0 || (LEAFB_SUBTYPE(ecx) != SMT_TYPE)) return -1; return 0; } /* * Return best CPUID Extended Toplogy Leaf supported */ static int detect_extended_topology_leaf(struct cpuinfo_x86 *c) { if (c->cpuid_level >= 0x1f) { if (check_extended_topology_leaf(0x1f) == 0) return 0x1f; } if (c->cpuid_level >= 0xb) { if (check_extended_topology_leaf(0xb) == 0) return 0xb; } return -1; } #endif int detect_extended_topology_early(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP unsigned int eax, ebx, ecx, edx; int leaf; leaf = detect_extended_topology_leaf(c); if (leaf < 0) return -1; set_cpu_cap(c, X86_FEATURE_XTOPOLOGY); cpuid_count(leaf, SMT_LEVEL, &eax, &ebx, &ecx, &edx); /* * initial apic id, which also represents 32-bit extended x2apic id. */ c->initial_apicid = edx; smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx); #endif return 0; } /* * Check for extended topology enumeration cpuid leaf, and if it * exists, use it for populating initial_apicid and cpu topology * detection. */ int detect_extended_topology(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP unsigned int eax, ebx, ecx, edx, sub_index; unsigned int ht_mask_width, core_plus_mask_width, die_plus_mask_width; unsigned int core_select_mask, core_level_siblings; unsigned int die_select_mask, die_level_siblings; int leaf; leaf = detect_extended_topology_leaf(c); if (leaf < 0) return -1; /* * Populate HT related information from sub-leaf level 0. */ cpuid_count(leaf, SMT_LEVEL, &eax, &ebx, &ecx, &edx); c->initial_apicid = edx; core_level_siblings = smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx); core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); die_level_siblings = LEVEL_MAX_SIBLINGS(ebx); die_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); sub_index = 1; do { cpuid_count(leaf, sub_index, &eax, &ebx, &ecx, &edx); /* * Check for the Core type in the implemented sub leaves. */ if (LEAFB_SUBTYPE(ecx) == CORE_TYPE) { core_level_siblings = LEVEL_MAX_SIBLINGS(ebx); core_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); die_level_siblings = core_level_siblings; die_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); } if (LEAFB_SUBTYPE(ecx) == DIE_TYPE) { die_level_siblings = LEVEL_MAX_SIBLINGS(ebx); die_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax); } sub_index++; } while (LEAFB_SUBTYPE(ecx) != INVALID_TYPE); core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width; die_select_mask = (~(-1 << die_plus_mask_width)) >> core_plus_mask_width; c->cpu_core_id = apic->phys_pkg_id(c->initial_apicid, ht_mask_width) & core_select_mask; c->cpu_die_id = apic->phys_pkg_id(c->initial_apicid, core_plus_mask_width) & die_select_mask; c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, die_plus_mask_width); /* * Reinit the apicid, now that we have extended initial_apicid. */ c->apicid = apic->phys_pkg_id(c->initial_apicid, 0); c->x86_max_cores = (core_level_siblings / smp_num_siblings); __max_die_per_package = (die_level_siblings / core_level_siblings); #endif return 0; }
/* MiniDLNA media server * Copyright (C) 2013 NETGEAR * * This file is part of MiniDLNA. * * MiniDLNA 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. * * MiniDLNA 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 MiniDLNA. If not, see <http://www.gnu.org/licenses/>. */ #if defined(HAVE_LINUX_SENDFILE_API) #include <sys/sendfile.h> int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len) { return sendfile(sock, sendfd, offset, len); } #elif defined(HAVE_DARWIN_SENDFILE_API) #include <sys/types.h> #include <sys/socket.h> #include <sys/uio.h> int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len) { int ret; ret = sendfile(sendfd, sock, *offset, &len, NULL, 0); *offset += len; return ret; } #elif defined(HAVE_FREEBSD_SENDFILE_API) #include <sys/types.h> #include <sys/socket.h> #include <sys/uio.h> int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len) { int ret; size_t nbytes = len; ret = sendfile(sendfd, sock, *offset, nbytes, NULL, &len, SF_MNOWAIT); *offset += len; return ret; } #else #include <errno.h> int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len) { errno = EINVAL; return -1; } #endif
/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __PERF_TOOL_H #define __PERF_TOOL_H #include <stdbool.h> #include <linux/types.h> struct perf_session; union perf_event; struct evlist; struct evsel; struct perf_sample; struct perf_tool; struct machine; struct ordered_events; typedef int (*event_sample)(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); typedef int (*event_op)(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); typedef int (*event_attr_op)(struct perf_tool *tool, union perf_event *event, struct evlist **pevlist); typedef int (*event_op2)(struct perf_session *session, union perf_event *event); typedef s64 (*event_op3)(struct perf_session *session, union perf_event *event); typedef int (*event_op4)(struct perf_session *session, union perf_event *event, u64 data); typedef int (*event_oe)(struct perf_tool *tool, union perf_event *event, struct ordered_events *oe); enum show_feature_header { SHOW_FEAT_NO_HEADER = 0, SHOW_FEAT_HEADER, SHOW_FEAT_HEADER_FULL_INFO, }; struct perf_tool { event_sample sample, read; event_op mmap, mmap2, comm, namespaces, cgroup, fork, exit, lost, lost_samples, aux, itrace_start, context_switch, throttle, unthrottle, ksymbol, bpf; event_attr_op attr; event_attr_op event_update; event_op2 tracing_data; event_oe finished_round; event_op2 build_id, id_index, auxtrace_info, auxtrace_error, time_conv, thread_map, cpu_map, stat_config, stat, stat_round, feature; event_op4 compressed; event_op3 auxtrace; bool ordered_events; bool ordering_requires_timestamps; bool namespace_events; bool cgroup_events; bool no_warn; enum show_feature_header show_feat_hdr; }; #endif /* __PERF_TOOL_H */
/* * STB810 specific prom routines * * Author: MontaVista Software, Inc. * source@mvista.com * * Copyright 2005 MontaVista Software 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. */ #include <linux/init.h> #include <linux/mm.h> #include <linux/sched.h> #include <linux/bootmem.h> #include <asm/addrspace.h> #include <asm/bootinfo.h> #include <linux/string.h> #include <linux/kernel.h> int prom_argc; char **prom_argv, **prom_envp; extern void __init prom_init_cmdline(void); extern char *prom_getenv(char *envname); const char *get_system_type(void) { return "Philips PNX8550/STB810"; } void __init prom_init(void) { unsigned long memsize; prom_argc = (int) fw_arg0; prom_argv = (char **) fw_arg1; prom_envp = (char **) fw_arg2; prom_init_cmdline(); mips_machgroup = MACH_GROUP_PHILIPS; mips_machtype = MACH_PHILIPS_STB810; memsize = 0x08000000; /* Trimedia uses memory above */ add_memory_region(0, memsize, BOOT_MEM_RAM); }
//======================================================================== // Context sharing test program // Copyright (c) Camilla Berglund <elmindreda@glfw.org> // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would // be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, and must not // be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source // distribution. // //======================================================================== // // This program is used to test sharing of objects between contexts // //======================================================================== #include <glad/glad.h> #include <GLFW/glfw3.h> #include <stdio.h> #include <stdlib.h> #define WIDTH 400 #define HEIGHT 400 #define OFFSET 50 static GLFWwindow* windows[2]; static void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) glfwSetWindowShouldClose(window, GLFW_TRUE); } static GLFWwindow* open_window(const char* title, GLFWwindow* share, int posX, int posY) { GLFWwindow* window; glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share); if (!window) return NULL; glfwMakeContextCurrent(window); gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); glfwSwapInterval(1); glfwSetWindowPos(window, posX, posY); glfwShowWindow(window); glfwSetKeyCallback(window, key_callback); return window; } static GLuint create_texture(void) { int x, y; char pixels[256 * 256]; GLuint texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); for (y = 0; y < 256; y++) { for (x = 0; x < 256; x++) pixels[y * 256 + x] = rand() % 256; } glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); return texture; } static void draw_quad(GLuint texture) { int width, height; glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.f, 1.f, 0.f, 1.f, 0.f, 1.f); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBegin(GL_QUADS); glTexCoord2f(0.f, 0.f); glVertex2f(0.f, 0.f); glTexCoord2f(1.f, 0.f); glVertex2f(1.f, 0.f); glTexCoord2f(1.f, 1.f); glVertex2f(1.f, 1.f); glTexCoord2f(0.f, 1.f); glVertex2f(0.f, 1.f); glEnd(); } int main(int argc, char** argv) { int x, y, width; GLuint texture; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); windows[0] = open_window("First", NULL, OFFSET, OFFSET); if (!windows[0]) { glfwTerminate(); exit(EXIT_FAILURE); } // This is the one and only time we create a texture // It is created inside the first context, created above // It will then be shared with the second context, created below texture = create_texture(); glfwGetWindowPos(windows[0], &x, &y); glfwGetWindowSize(windows[0], &width, NULL); // Put the second window to the right of the first one windows[1] = open_window("Second", windows[0], x + width + OFFSET, y); if (!windows[1]) { glfwTerminate(); exit(EXIT_FAILURE); } // Set drawing color for both contexts glfwMakeContextCurrent(windows[0]); glColor3f(0.6f, 0.f, 0.6f); glfwMakeContextCurrent(windows[1]); glColor3f(0.6f, 0.6f, 0.f); glfwMakeContextCurrent(windows[0]); while (!glfwWindowShouldClose(windows[0]) && !glfwWindowShouldClose(windows[1])) { glfwMakeContextCurrent(windows[0]); draw_quad(texture); glfwMakeContextCurrent(windows[1]); draw_quad(texture); glfwSwapBuffers(windows[0]); glfwSwapBuffers(windows[1]); glfwWaitEvents(); } glfwTerminate(); exit(EXIT_SUCCESS); }
/*============================================================================ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic Package, Release 3e, by John R. Hauser. Copyright 2011, 2012, 2013, 2014 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 <stdint.h> #include "platform.h" #include "specialize.h" #include "softfloat.h" /*---------------------------------------------------------------------------- | Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts | this NaN to the common NaN form, and stores the resulting common NaN at the | location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid | exception is raised. *----------------------------------------------------------------------------*/ void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr ) { if ( softfloat_isSigNaNF64UI( uiA ) ) { softfloat_raiseFlags( softfloat_flag_invalid ); } zPtr->sign = uiA>>63; zPtr->v64 = uiA<<12; zPtr->v0 = 0; }
#include <linux/kernel.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv6.h> #include <net/netfilter/nf_queue.h> __sum16 nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, u_int8_t protocol, unsigned short family) { const struct nf_ipv6_ops *v6ops; __sum16 csum = 0; switch (family) { case AF_INET: csum = nf_ip_checksum(skb, hook, dataoff, protocol); break; case AF_INET6: v6ops = rcu_dereference(nf_ipv6_ops); if (v6ops) csum = v6ops->checksum(skb, hook, dataoff, protocol); break; } return csum; } EXPORT_SYMBOL_GPL(nf_checksum); __sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, unsigned int len, u_int8_t protocol, unsigned short family) { const struct nf_ipv6_ops *v6ops; __sum16 csum = 0; switch (family) { case AF_INET: csum = nf_ip_checksum_partial(skb, hook, dataoff, len, protocol); break; case AF_INET6: v6ops = rcu_dereference(nf_ipv6_ops); if (v6ops) csum = v6ops->checksum_partial(skb, hook, dataoff, len, protocol); break; } return csum; } EXPORT_SYMBOL_GPL(nf_checksum_partial); int nf_route(struct net *net, struct dst_entry **dst, struct flowi *fl, bool strict, unsigned short family) { const struct nf_ipv6_ops *v6ops; int ret = 0; switch (family) { case AF_INET: ret = nf_ip_route(net, dst, fl, strict); break; case AF_INET6: v6ops = rcu_dereference(nf_ipv6_ops); if (v6ops) ret = v6ops->route(net, dst, fl, strict); break; } return ret; } EXPORT_SYMBOL_GPL(nf_route); int nf_reroute(struct sk_buff *skb, struct nf_queue_entry *entry) { const struct nf_ipv6_ops *v6ops; int ret = 0; switch (entry->state.pf) { case AF_INET: ret = nf_ip_reroute(skb, entry); break; case AF_INET6: v6ops = rcu_dereference(nf_ipv6_ops); if (v6ops) ret = v6ops->reroute(skb, entry); break; } return ret; }
// SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2014, Michael Ellerman, IBM Corp. */ #define _GNU_SOURCE #include <stdio.h> #include <stdbool.h> #include <string.h> #include <sys/prctl.h> #include "ebb.h" /* * Run a calibrated instruction loop and count instructions executed using * EBBs. Make sure the counts look right. */ extern void thirty_two_instruction_loop(uint64_t loops); static bool counters_frozen = true; static int do_count_loop(struct event *event, uint64_t instructions, uint64_t overhead, bool report) { int64_t difference, expected; double percentage; clear_ebb_stats(); counters_frozen = false; mb(); mtspr(SPRN_MMCR0, mfspr(SPRN_MMCR0) & ~MMCR0_FC); thirty_two_instruction_loop(instructions >> 5); counters_frozen = true; mb(); mtspr(SPRN_MMCR0, mfspr(SPRN_MMCR0) | MMCR0_FC); count_pmc(4, sample_period); event->result.value = ebb_state.stats.pmc_count[4-1]; expected = instructions + overhead; difference = event->result.value - expected; percentage = (double)difference / event->result.value * 100; if (report) { printf("Looped for %lu instructions, overhead %lu\n", instructions, overhead); printf("Expected %lu\n", expected); printf("Actual %llu\n", event->result.value); printf("Delta %ld, %f%%\n", difference, percentage); printf("Took %d EBBs\n", ebb_state.stats.ebb_count); } if (difference < 0) difference = -difference; /* Tolerate a difference of up to 0.0001 % */ difference *= 10000 * 100; if (difference / event->result.value) return -1; return 0; } /* Count how many instructions it takes to do a null loop */ static uint64_t determine_overhead(struct event *event) { uint64_t current, overhead; int i; do_count_loop(event, 0, 0, false); overhead = event->result.value; for (i = 0; i < 100; i++) { do_count_loop(event, 0, 0, false); current = event->result.value; if (current < overhead) { printf("Replacing overhead %lu with %lu\n", overhead, current); overhead = current; } } return overhead; } static void pmc4_ebb_callee(void) { uint64_t val; val = mfspr(SPRN_BESCR); if (!(val & BESCR_PMEO)) { ebb_state.stats.spurious++; goto out; } ebb_state.stats.ebb_count++; count_pmc(4, sample_period); out: if (counters_frozen) reset_ebb_with_clear_mask(MMCR0_PMAO); else reset_ebb(); } int instruction_count(void) { struct event event; uint64_t overhead; SKIP_IF(!ebb_is_supported()); event_init_named(&event, 0x400FA, "PM_RUN_INST_CMPL"); event_leader_ebb_init(&event); event.attr.exclude_kernel = 1; event.attr.exclude_hv = 1; event.attr.exclude_idle = 1; FAIL_IF(event_open(&event)); FAIL_IF(ebb_event_enable(&event)); sample_period = COUNTER_OVERFLOW; setup_ebb_handler(pmc4_ebb_callee); mtspr(SPRN_MMCR0, mfspr(SPRN_MMCR0) & ~MMCR0_FC); ebb_global_enable(); overhead = determine_overhead(&event); printf("Overhead of null loop: %lu instructions\n", overhead); /* Run for 1M instructions */ FAIL_IF(do_count_loop(&event, 0x100000, overhead, true)); /* Run for 10M instructions */ FAIL_IF(do_count_loop(&event, 0xa00000, overhead, true)); /* Run for 100M instructions */ FAIL_IF(do_count_loop(&event, 0x6400000, overhead, true)); /* Run for 1G instructions */ FAIL_IF(do_count_loop(&event, 0x40000000, overhead, true)); /* Run for 16G instructions */ FAIL_IF(do_count_loop(&event, 0x400000000, overhead, true)); /* Run for 64G instructions */ FAIL_IF(do_count_loop(&event, 0x1000000000, overhead, true)); /* Run for 128G instructions */ FAIL_IF(do_count_loop(&event, 0x2000000000, overhead, true)); ebb_global_disable(); event_close(&event); printf("Finished OK\n"); return 0; } int main(void) { test_harness_set_timeout(300); return test_harness(instruction_count, "instruction_count"); }
/* crypto/ripemd/rmd_one.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * 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 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include <stdio.h> #include <string.h> #include <openssl/ripemd.h> #include <openssl/crypto.h> unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md) { RIPEMD160_CTX c; static unsigned char m[RIPEMD160_DIGEST_LENGTH]; if (md == NULL) md=m; if (!RIPEMD160_Init(&c)) return NULL; RIPEMD160_Update(&c,d,n); RIPEMD160_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ return(md); }
/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2008 Simtec Electronics * http://armlinux.simtec.co.uk/ * Ben Dooks <ben@simtec.co.uk> * * S3C ADC driver information */ #ifndef __ASM_PLAT_ADC_H #define __ASM_PLAT_ADC_H __FILE__ struct s3c_adc_client; struct platform_device; extern int s3c_adc_start(struct s3c_adc_client *client, unsigned int channel, unsigned int nr_samples); extern int s3c_adc_read(struct s3c_adc_client *client, unsigned int ch); extern struct s3c_adc_client * s3c_adc_register(struct platform_device *pdev, void (*select)(struct s3c_adc_client *client, unsigned selected), void (*conv)(struct s3c_adc_client *client, unsigned d0, unsigned d1, unsigned *samples_left), unsigned int is_ts); extern void s3c_adc_release(struct s3c_adc_client *client); #endif /* __ASM_PLAT_ADC_H */
/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _ASM_S390_PCI_CLP_H #define _ASM_S390_PCI_CLP_H #include <asm/clp.h> /* * Call Logical Processor - Command Codes */ #define CLP_LIST_PCI 0x0002 #define CLP_QUERY_PCI_FN 0x0003 #define CLP_QUERY_PCI_FNGRP 0x0004 #define CLP_SET_PCI_FN 0x0005 /* PCI function handle list entry */ struct clp_fh_list_entry { u16 device_id; u16 vendor_id; u32 config_state : 1; u32 : 31; u32 fid; /* PCI function id */ u32 fh; /* PCI function handle */ } __packed; #define CLP_RC_SETPCIFN_FH 0x0101 /* Invalid PCI fn handle */ #define CLP_RC_SETPCIFN_FHOP 0x0102 /* Fn handle not valid for op */ #define CLP_RC_SETPCIFN_DMAAS 0x0103 /* Invalid DMA addr space */ #define CLP_RC_SETPCIFN_RES 0x0104 /* Insufficient resources */ #define CLP_RC_SETPCIFN_ALRDY 0x0105 /* Fn already in requested state */ #define CLP_RC_SETPCIFN_ERR 0x0106 /* Fn in permanent error state */ #define CLP_RC_SETPCIFN_RECPND 0x0107 /* Error recovery pending */ #define CLP_RC_SETPCIFN_BUSY 0x0108 /* Fn busy */ #define CLP_RC_LISTPCI_BADRT 0x010a /* Resume token not recognized */ #define CLP_RC_QUERYPCIFG_PFGID 0x010b /* Unrecognized PFGID */ /* request or response block header length */ #define LIST_PCI_HDR_LEN 32 /* Number of function handles fitting in response block */ #define CLP_FH_LIST_NR_ENTRIES \ ((CLP_BLK_SIZE - 2 * LIST_PCI_HDR_LEN) \ / sizeof(struct clp_fh_list_entry)) #define CLP_SET_ENABLE_PCI_FN 0 /* Yes, 0 enables it */ #define CLP_SET_DISABLE_PCI_FN 1 /* Yes, 1 disables it */ #define CLP_SET_ENABLE_MIO 2 #define CLP_SET_DISABLE_MIO 3 #define CLP_UTIL_STR_LEN 64 #define CLP_PFIP_NR_SEGMENTS 4 extern bool zpci_unique_uid; /* List PCI functions request */ struct clp_req_list_pci { struct clp_req_hdr hdr; u64 resume_token; u64 reserved2; } __packed; /* List PCI functions response */ struct clp_rsp_list_pci { struct clp_rsp_hdr hdr; u64 resume_token; u32 reserved2; u16 max_fn; u8 : 7; u8 uid_checking : 1; u8 entry_size; struct clp_fh_list_entry fh_list[CLP_FH_LIST_NR_ENTRIES]; } __packed; struct mio_info { u32 valid : 6; u32 : 26; u32 : 32; struct { u64 wb; u64 wt; } addr[PCI_BAR_COUNT]; u32 reserved[6]; } __packed; /* Query PCI function request */ struct clp_req_query_pci { struct clp_req_hdr hdr; u32 fh; /* function handle */ u32 reserved2; u64 reserved3; } __packed; /* Query PCI function response */ struct clp_rsp_query_pci { struct clp_rsp_hdr hdr; u16 vfn; /* virtual fn number */ u16 : 6; u16 mio_addr_avail : 1; u16 util_str_avail : 1; /* utility string available? */ u16 pfgid : 8; /* pci function group id */ u32 fid; /* pci function id */ u8 bar_size[PCI_BAR_COUNT]; u16 pchid; __le32 bar[PCI_BAR_COUNT]; u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */ u32 : 16; u8 fmb_len; u8 pft; /* pci function type */ u64 sdma; /* start dma as */ u64 edma; /* end dma as */ u32 reserved[11]; u32 uid; /* user defined id */ u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */ u32 reserved2[16]; struct mio_info mio; } __packed; /* Query PCI function group request */ struct clp_req_query_pci_grp { struct clp_req_hdr hdr; u32 reserved2 : 24; u32 pfgid : 8; /* function group id */ u32 reserved3; u64 reserved4; } __packed; /* Query PCI function group response */ struct clp_rsp_query_pci_grp { struct clp_rsp_hdr hdr; u16 : 4; u16 noi : 12; /* number of interrupts */ u8 version; u8 : 6; u8 frame : 1; u8 refresh : 1; /* TLB refresh mode */ u16 reserved2; u16 mui; u16 : 16; u16 maxfaal; u16 : 4; u16 dnoi : 12; u16 maxcpu; u64 dasm; /* dma address space mask */ u64 msia; /* MSI address */ u64 reserved4; u64 reserved5; } __packed; /* Set PCI function request */ struct clp_req_set_pci { struct clp_req_hdr hdr; u32 fh; /* function handle */ u16 reserved2; u8 oc; /* operation controls */ u8 ndas; /* number of dma spaces */ u64 reserved3; } __packed; /* Set PCI function response */ struct clp_rsp_set_pci { struct clp_rsp_hdr hdr; u32 fh; /* function handle */ u32 reserved1; u64 reserved2; struct mio_info mio; } __packed; /* Combined request/response block structures used by clp insn */ struct clp_req_rsp_list_pci { struct clp_req_list_pci request; struct clp_rsp_list_pci response; } __packed; struct clp_req_rsp_set_pci { struct clp_req_set_pci request; struct clp_rsp_set_pci response; } __packed; struct clp_req_rsp_query_pci { struct clp_req_query_pci request; struct clp_rsp_query_pci response; } __packed; struct clp_req_rsp_query_pci_grp { struct clp_req_query_pci_grp request; struct clp_rsp_query_pci_grp response; } __packed; #endif
/* { dg-do run } */ /* { dg-options "-O2 -fdump-tree-strlen" } */ #include "strlenopt.h" __attribute__((noinline, noclone)) size_t fn1 (char *p) { char *q; /* This can be optimized into memcpy and the size can be decreased to one, as it is immediately overwritten. */ strcpy (p, "z"); q = strchr (p, '\0'); *q = 32; /* This strlen can't be optimized away, string length is unknown here. */ return strlen (p); } __attribute__((noinline, noclone)) void fn2 (char *p, const char *z, size_t *lp) { char *q, *r; char buf[64]; size_t l[10]; /* The first strlen stays, all the strcpy calls can be optimized into memcpy and all other strlen calls and all strchr calls optimized away. */ l[0] = strlen (z); strcpy (buf, z); strcpy (p, "abcde"); q = strchr (p, '\0'); strcpy (q, "efghi"); r = strchr (q, '\0'); strcpy (r, "jkl"); l[1] = strlen (p); l[2] = strlen (q); l[3] = strlen (r); strcpy (r, buf); l[4] = strlen (p); l[5] = strlen (q); l[6] = strlen (r); strcpy (r, "mnopqr"); l[7] = strlen (p); l[8] = strlen (q); l[9] = strlen (r); memcpy (lp, l, sizeof l); } int main () { char buf[64]; size_t l[10]; const char *volatile z = "ABCDEFG"; memset (buf, '\0', sizeof buf); if (fn1 (buf) != 2 || buf[0] != 'z' || buf[1] != 32 || buf[2] != '\0') abort (); fn2 (buf, z, l); if (memcmp (buf, "abcdeefghimnopqr", 17) != 0) abort (); if (l[0] != 7) abort (); if (l[1] != 13 || l[2] != 8 || l[3] != 3) abort (); if (l[4] != 17 || l[5] != 12 || l[6] != 7) abort (); if (l[7] != 16 || l[8] != 11 || l[9] != 6) abort (); return 0; } /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */ /* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op to expand the memcpy call at the end of fn2. */ /* { dg-final { scan-tree-dump-times "memcpy \\(" 8 "strlen" { target { ! avr-*-* } } } } */ /* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen" { target { avr-*-* } } } } */ /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */ /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */ /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */ /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */ /* { dg-final { scan-tree-dump-times "\\*q_\[0-9\]* = 32;" 1 "strlen" } } */ /* { dg-final { scan-tree-dump-times "memcpy \\(\[^\n\r\]*, 1\\)" 1 "strlen" } } */ /* { dg-final { cleanup-tree-dump "strlen" } } */
/* SPDX-License-Identifier: GPL-2.0 */ /* written by Philipp Rumpf, Copyright (C) 1999 SuSE GmbH Nuernberg ** Copyright (C) 2000 Grant Grundler, Hewlett-Packard */ #ifndef _PARISC_PTRACE_H #define _PARISC_PTRACE_H #include <uapi/asm/ptrace.h> #define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS)) #define arch_has_single_step() 1 #define arch_has_block_step() 1 /* XXX should we use iaoq[1] or iaoq[0] ? */ #define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0) #define user_space(regs) (((regs)->iasq[1] != 0) ? 1 : 0) #define instruction_pointer(regs) ((regs)->iaoq[0] & ~3) #define user_stack_pointer(regs) ((regs)->gr[30]) unsigned long profile_pc(struct pt_regs *); static inline unsigned long regs_return_value(struct pt_regs *regs) { return regs->gr[28]; } static inline void instruction_pointer_set(struct pt_regs *regs, unsigned long val) { regs->iaoq[0] = val; regs->iaoq[1] = val + 4; } /* Query offset/name of register from its name/offset */ extern int regs_query_register_offset(const char *name); extern const char *regs_query_register_name(unsigned int offset); #define MAX_REG_OFFSET (offsetof(struct pt_regs, ipsw)) #define kernel_stack_pointer(regs) ((regs)->gr[30]) static inline unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset) { if (unlikely(offset > MAX_REG_OFFSET)) return 0; return *(unsigned long *)((unsigned long)regs + offset); } unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n); int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr); #endif
/** * @file op_rtc.c * Setup and handling of RTC interrupts * * @remark Copyright 2002 OProfile authors * @remark Read the file COPYING * * @author Bob Montgomery * @author Philippe Elie * @author John Levon */ #include <linux/ioport.h> #include <linux/mc146818rtc.h> #include <asm/ptrace.h> #include "oprofile.h" #include "op_arch.h" #include "op_util.h" #define RTC_IO_PORTS 2 /* not in 2.2 */ #ifndef RTC_IRQ #define RTC_IRQ 8 #endif /* ---------------- RTC handler ------------------ */ static void do_rtc_interrupt(int irq, void * dev_id, struct pt_regs * regs) { uint cpu = op_cpu_id(); unsigned char intr_flags; unsigned long flags; int usermode = user_mode(regs); if ((sysctl.ctr[0].kernel && usermode) || (sysctl.ctr[0].user && !usermode)) return; lock_rtc(flags); /* read and ack the interrupt */ intr_flags = CMOS_READ(RTC_INTR_FLAGS); /* Is this my type of interrupt? */ if (intr_flags & RTC_PF) { op_do_profile(cpu, instruction_pointer(regs), IRQ_ENABLED(regs), 0); } unlock_rtc(flags); return; } static int rtc_setup(void) { unsigned char tmp_control; unsigned long flags; unsigned char tmp_freq_select; unsigned long target; unsigned int exp, freq; lock_rtc(flags); /* disable periodic interrupts */ tmp_control = CMOS_READ(RTC_CONTROL); tmp_control &= ~RTC_PIE; CMOS_WRITE(tmp_control, RTC_CONTROL); CMOS_READ(RTC_INTR_FLAGS); /* Set the frequency for periodic interrupts by finding the * closest power of two within the allowed range. */ target = sysctl.ctr[0].count; exp = 0; while (target > (1 << exp) + ((1 << exp) >> 1)) exp++; freq = 16 - exp; tmp_freq_select = CMOS_READ(RTC_FREQ_SELECT); tmp_freq_select = (tmp_freq_select & 0xf0) | freq; CMOS_WRITE(tmp_freq_select, RTC_FREQ_SELECT); /* Update /proc with the actual frequency. */ sysctl_parms.ctr[0].count = sysctl.ctr[0].count = 1 << exp; unlock_rtc(flags); return 0; } static void rtc_start(void) { unsigned char tmp_control; unsigned long flags; lock_rtc(flags); /* Enable periodic interrupts */ tmp_control = CMOS_READ(RTC_CONTROL); tmp_control |= RTC_PIE; CMOS_WRITE(tmp_control, RTC_CONTROL); /* read the flags register to start interrupts */ CMOS_READ(RTC_INTR_FLAGS); unlock_rtc(flags); } static void rtc_stop(void) { unsigned char tmp_control; unsigned long flags; lock_rtc(flags); /* disable periodic interrupts */ tmp_control = CMOS_READ(RTC_CONTROL); tmp_control &= ~RTC_PIE; CMOS_WRITE(tmp_control, RTC_CONTROL); CMOS_READ(RTC_INTR_FLAGS); unlock_rtc(flags); } static void rtc_start_cpu(uint cpu) { rtc_start(); } static void rtc_stop_cpu(uint cpu) { rtc_stop(); } static int rtc_check_params(void) { int target = sysctl.ctr[0].count; if (check_range(target, OP_MIN_RTC_COUNT, OP_MAX_RTC_COUNT, "RTC value %d is out of range (%d-%d)\n")) return -EINVAL; return 0; } static int rtc_init(void) { /* request_region returns 0 on **failure** */ if (!request_region_check(RTC_PORT(0), RTC_IO_PORTS, "oprofile")) { printk(KERN_ERR "oprofile: can't get RTC I/O Ports\n"); return -EBUSY; } /* request_irq returns 0 on **success** */ if (request_irq(RTC_IRQ, do_rtc_interrupt, SA_INTERRUPT, "oprofile", NULL)) { printk(KERN_ERR "oprofile: IRQ%d busy \n", RTC_IRQ); release_region(RTC_PORT(0), RTC_IO_PORTS); return -EBUSY; } return 0; } static void rtc_deinit(void) { free_irq(RTC_IRQ, NULL); release_region(RTC_PORT(0), RTC_IO_PORTS); } static int rtc_add_sysctls(ctl_table * next) { *next = ((ctl_table) { 1, "rtc_value", &sysctl_parms.ctr[0].count, sizeof(int), 0600, NULL, lproc_dointvec, NULL, }); return 0; } static void rtc_remove_sysctls(ctl_table * next) { /* nothing to do */ } struct op_int_operations op_rtc_ops = { init: rtc_init, deinit: rtc_deinit, add_sysctls: rtc_add_sysctls, remove_sysctls: rtc_remove_sysctls, check_params: rtc_check_params, setup: rtc_setup, start: rtc_start, stop: rtc_stop, start_cpu: rtc_start_cpu, stop_cpu: rtc_stop_cpu, };
//////////////////////////////////////////////////////////////////////////////// /// /// Sample interpolation routine using 8-tap band-limited Shannon interpolation /// with kaiser window. /// /// Notice. This algorithm is remarkably much heavier than linear or cubic /// interpolation, and not remarkably better than cubic algorithm. Thus mostly /// for experimental purposes /// /// Author : Copyright (c) Olli Parviainen /// Author e-mail : oparviai 'at' iki.fi /// SoundTouch WWW: http://www.surina.net/soundtouch /// //////////////////////////////////////////////////////////////////////////////// // // $Id: InterpolateShannon.h 179 2014-01-06 18:41:42Z oparviai $ // //////////////////////////////////////////////////////////////////////////////// // // License : // // SoundTouch audio processing library // Copyright (c) Olli Parviainen // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //////////////////////////////////////////////////////////////////////////////// #ifndef _InterpolateShannon_H_ #define _InterpolateShannon_H_ #include "RateTransposer.h" #include "STTypes.h" namespace soundtouch { class InterpolateShannon : public TransposerBase { protected: void resetRegisters(); int transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples); int transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples); int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples); float fract; public: InterpolateShannon(); }; } #endif
/* Test vbslq_u64 can be folded. */ /* { dg-do assemble } */ /* { dg-options "--save-temps -O3" } */ #include <arm_neon.h> /* Folds to BIC. */ int32x4_t half_fold_int (uint32x4_t mask) { int32x4_t a = {0, 0, 0, 0}; int32x4_t b = {2, 4, 8, 16}; return vbslq_s32 (mask, a, b); } /* { dg-final { scan-assembler-not "bsl\\tv" } } */ /* { dg-final { scan-assembler-not "bit\\tv" } } */ /* { dg-final { scan-assembler-not "bif\\tv" } } */ /* { dg-final { scan-assembler "bic\\tv" } } */
/* itbl-lex.h Copyright 2005, 2007 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. GAS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GAS 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 GAS; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ extern int insntbl_line; extern int yyparse (void); extern int yylex (void);
#ifndef __ASM_MACH_IP32_KMALLOC_H #define __ASM_MACH_IP32_KMALLOC_H #if defined(CONFIG_CPU_R5000) || defined(CONFIG_CPU_RM7000) #define ARCH_DMA_MINALIGN 32 #else #define ARCH_DMA_MINALIGN 128 #endif #endif /* __ASM_MACH_IP32_KMALLOC_H */
/** * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #import <Foundation/Foundation.h> @interface User : NSObject @property (strong, nonatomic) NSString *email; @property (strong, nonatomic) NSString *name; @property (strong, nonatomic) NSString *family_name; @property (strong, nonatomic) NSString *username; @property (strong, nonatomic) NSString *given_name; @end
// Copyright 2004-present Facebook. All Rights Reserved. #pragma once #include <jschelpers/JavaScriptCore.h> namespace facebook { namespace react { void initSamplingProfilerOnMainJSCThread(JSGlobalContextRef ctx); } }
#include "layout.h" #include "../vgmstream.h" /* set up for the block at the given offset */ void filp_block_update(off_t block_offset, VGMSTREAM * vgmstream) { int i; vgmstream->current_block_offset = block_offset; vgmstream->current_block_size = read_32bitLE( vgmstream->current_block_offset+0x18, vgmstream->ch[0].streamfile)-0x800; vgmstream->next_block_offset = vgmstream->current_block_offset+vgmstream->current_block_size+0x800; vgmstream->current_block_size/=vgmstream->channels; for (i=0;i<vgmstream->channels;i++) { vgmstream->ch[i].offset = vgmstream->current_block_offset+0x800+(vgmstream->current_block_size*i); } }
/* * * Includes for cdc-acm.c * * Mainly take from usbnet's cdc-ether part * */ /* * CMSPAR, some architectures can't have space and mark parity. */ #ifndef CMSPAR #define CMSPAR 0 #endif /* * Major and minor numbers. */ #define ACM_TTY_MAJOR 166 #define ACM_TTY_MINORS 256 /* * Requests. */ #define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE) /* * Output control lines. */ #define ACM_CTRL_DTR 0x01 #define ACM_CTRL_RTS 0x02 /* * Input control lines and line errors. */ #define ACM_CTRL_DCD 0x01 #define ACM_CTRL_DSR 0x02 #define ACM_CTRL_BRK 0x04 #define ACM_CTRL_RI 0x08 #define ACM_CTRL_FRAMING 0x10 #define ACM_CTRL_PARITY 0x20 #define ACM_CTRL_OVERRUN 0x40 /* * Internal driver structures. */ /* * The only reason to have several buffers is to accommodate assumptions * in line disciplines. They ask for empty space amount, receive our URB size, * and proceed to issue several 1-character writes, assuming they will fit. * The very first write takes a complete URB. Fortunately, this only happens * when processing onlcr, so we only need 2 buffers. These values must be * powers of 2. */ #define ACM_NW 16 #define ACM_NR 16 struct acm_wb { unsigned char *buf; dma_addr_t dmah; int len; int use; struct urb *urb; struct acm *instance; }; struct acm_rb { int size; unsigned char *base; dma_addr_t dma; int index; struct acm *instance; }; struct acm { struct usb_device *dev; /* the corresponding usb device */ struct usb_interface *control; /* control interface */ struct usb_interface *data; /* data interface */ unsigned in, out; /* i/o pipes */ struct tty_port port; /* our tty port data */ struct urb *ctrlurb; /* urbs */ u8 *ctrl_buffer; /* buffers of urbs */ dma_addr_t ctrl_dma; /* dma handles of buffers */ u8 *country_codes; /* country codes from device */ unsigned int country_code_size; /* size of this buffer */ unsigned int country_rel_date; /* release date of version */ struct acm_wb wb[ACM_NW]; unsigned long read_urbs_free; struct urb *read_urbs[ACM_NR]; struct acm_rb read_buffers[ACM_NR]; struct acm_wb *putbuffer; /* for acm_tty_put_char() */ int rx_buflimit; spinlock_t read_lock; u8 *notification_buffer; /* to reassemble fragmented notifications */ unsigned int nb_index; unsigned int nb_size; int transmitting; spinlock_t write_lock; struct mutex mutex; bool disconnected; unsigned long flags; # define EVENT_TTY_WAKEUP 0 # define EVENT_RX_STALL 1 struct usb_cdc_line_coding line; /* bits, stop, parity */ struct work_struct work; /* work queue entry for line discipline waking up */ unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ unsigned int ctrlout; /* output control lines (DTR, RTS) */ struct async_icount iocount; /* counters for control line changes */ struct async_icount oldcount; /* for comparison of counter */ wait_queue_head_t wioctl; /* for ioctl */ unsigned int writesize; /* max packet size for the output bulk endpoint */ unsigned int readsize,ctrlsize; /* buffer sizes for freeing */ unsigned int minor; /* acm minor number */ unsigned char clocal; /* termios CLOCAL */ unsigned int ctrl_caps; /* control capabilities from the class specific header */ unsigned int susp_count; /* number of suspended interfaces */ unsigned int combined_interfaces:1; /* control and data collapsed */ unsigned int throttled:1; /* actually throttled */ unsigned int throttle_req:1; /* throttle requested */ u8 bInterval; struct usb_anchor delayed; /* writes queued for a device about to be woken */ unsigned long quirks; }; #define CDC_DATA_INTERFACE_TYPE 0x0a /* constants describing various quirks and errors */ #define NO_UNION_NORMAL BIT(0) #define SINGLE_RX_URB BIT(1) #define NO_CAP_LINE BIT(2) #define NO_DATA_INTERFACE BIT(4) #define IGNORE_DEVICE BIT(5) #define QUIRK_CONTROL_LINE_STATE BIT(6) #define CLEAR_HALT_CONDITIONS BIT(7) #define SEND_ZERO_PACKET BIT(8)
/* GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 only, * 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 version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see http://www.gnu.org/licenses * * Please visit http://www.xyratex.com/contact if you need additional * information or have any questions. * * GPL HEADER END */ /* * Copyright 2012 Xyratex Technology Limited */ /* * This is crypto api shash wrappers to zlib_adler32. */ #include <linux/module.h> #include <linux/zutil.h> #include <crypto/internal/hash.h> #define CHKSUM_BLOCK_SIZE 1 #define CHKSUM_DIGEST_SIZE 4 static u32 __adler32(u32 cksum, unsigned char const *p, size_t len) { return zlib_adler32(cksum, p, len); } static int adler32_cra_init(struct crypto_tfm *tfm) { u32 *key = crypto_tfm_ctx(tfm); *key = 1; return 0; } static int adler32_setkey(struct crypto_shash *hash, const u8 *key, unsigned int keylen) { u32 *mctx = crypto_shash_ctx(hash); if (keylen != sizeof(u32)) { crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } *mctx = *(u32 *)key; return 0; } static int adler32_init(struct shash_desc *desc) { u32 *mctx = crypto_shash_ctx(desc->tfm); u32 *cksump = shash_desc_ctx(desc); *cksump = *mctx; return 0; } static int adler32_update(struct shash_desc *desc, const u8 *data, unsigned int len) { u32 *cksump = shash_desc_ctx(desc); *cksump = __adler32(*cksump, data, len); return 0; } static int __adler32_finup(u32 *cksump, const u8 *data, unsigned int len, u8 *out) { *(u32 *)out = __adler32(*cksump, data, len); return 0; } static int adler32_finup(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out) { return __adler32_finup(shash_desc_ctx(desc), data, len, out); } static int adler32_final(struct shash_desc *desc, u8 *out) { u32 *cksump = shash_desc_ctx(desc); *(u32 *)out = *cksump; return 0; } static int adler32_digest(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out) { return __adler32_finup(crypto_shash_ctx(desc->tfm), data, len, out); } static struct shash_alg alg = { .setkey = adler32_setkey, .init = adler32_init, .update = adler32_update, .final = adler32_final, .finup = adler32_finup, .digest = adler32_digest, .descsize = sizeof(u32), .digestsize = CHKSUM_DIGEST_SIZE, .base = { .cra_name = "adler32", .cra_driver_name = "adler32-zlib", .cra_priority = 100, .cra_blocksize = CHKSUM_BLOCK_SIZE, .cra_ctxsize = sizeof(u32), .cra_module = THIS_MODULE, .cra_init = adler32_cra_init, } }; int cfs_crypto_adler32_register(void) { return crypto_register_shash(&alg); } EXPORT_SYMBOL(cfs_crypto_adler32_register); void cfs_crypto_adler32_unregister(void) { crypto_unregister_shash(&alg); } EXPORT_SYMBOL(cfs_crypto_adler32_unregister);
/** @file mlan_join.h * * @brief This file defines the interface for the WLAN infrastructure * and adhoc join routines. * * Driver interface functions and type declarations for the join module * implemented in mlan_join.c. Process all start/join requests for * both adhoc and infrastructure networks * * Copyright (C) 2008-2011, Marvell International Ltd. * * This software file (the "File") is distributed by Marvell International * Ltd. under the terms of the GNU General Public License Version 2, June 1991 * (the "License"). You may use, redistribute and/or modify this File in * accordance with the terms and conditions of the License, a copy of which * is available by writing to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE * ARE EXPRESSLY DISCLAIMED. The License provides additional details about * this warranty disclaimer. */ /****************************************************** Change log: 10/13/2008: initial version ******************************************************/ #ifndef _MLAN_JOIN_H_ #define _MLAN_JOIN_H_ /** Size of buffer allocated to store the association response from firmware */ #define MRVDRV_ASSOC_RSP_BUF_SIZE 500 /** Size of buffer allocated to store IEs passed to firmware in the assoc req */ #define MRVDRV_GENIE_BUF_SIZE 256 #endif /* _MLAN_JOIN_H_ */
/* * Copyright 2015 Simon Arlott * * 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. * * Derived from bcm63138_nand.c: * Copyright © 2015 Broadcom Corporation * * Derived from bcm963xx_4.12L.06B_consumer/shared/opensource/include/bcm963xx/63268_map_part.h: * Copyright 2000-2010 Broadcom Corporation * * Derived from bcm963xx_4.12L.06B_consumer/shared/opensource/flash/nandflash.c: * Copyright 2000-2010 Broadcom Corporation */ #include <linux/device.h> #include <linux/io.h> #include <linux/ioport.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/slab.h> #include "brcmnand.h" struct bcm6368_nand_soc { struct brcmnand_soc soc; void __iomem *base; }; #define BCM6368_NAND_INT 0x00 #define BCM6368_NAND_STATUS_SHIFT 0 #define BCM6368_NAND_STATUS_MASK (0xfff << BCM6368_NAND_STATUS_SHIFT) #define BCM6368_NAND_ENABLE_SHIFT 16 #define BCM6368_NAND_ENABLE_MASK (0xffff << BCM6368_NAND_ENABLE_SHIFT) #define BCM6368_NAND_BASE_ADDR0 0x04 #define BCM6368_NAND_BASE_ADDR1 0x0c enum { BCM6368_NP_READ = BIT(0), BCM6368_BLOCK_ERASE = BIT(1), BCM6368_COPY_BACK = BIT(2), BCM6368_PAGE_PGM = BIT(3), BCM6368_CTRL_READY = BIT(4), BCM6368_DEV_RBPIN = BIT(5), BCM6368_ECC_ERR_UNC = BIT(6), BCM6368_ECC_ERR_CORR = BIT(7), }; static bool bcm6368_nand_intc_ack(struct brcmnand_soc *soc) { struct bcm6368_nand_soc *priv = container_of(soc, struct bcm6368_nand_soc, soc); void __iomem *mmio = priv->base + BCM6368_NAND_INT; u32 val = brcmnand_readl(mmio); if (val & (BCM6368_CTRL_READY << BCM6368_NAND_STATUS_SHIFT)) { /* Ack interrupt */ val &= ~BCM6368_NAND_STATUS_MASK; val |= BCM6368_CTRL_READY << BCM6368_NAND_STATUS_SHIFT; brcmnand_writel(val, mmio); return true; } return false; } static void bcm6368_nand_intc_set(struct brcmnand_soc *soc, bool en) { struct bcm6368_nand_soc *priv = container_of(soc, struct bcm6368_nand_soc, soc); void __iomem *mmio = priv->base + BCM6368_NAND_INT; u32 val = brcmnand_readl(mmio); /* Don't ack any interrupts */ val &= ~BCM6368_NAND_STATUS_MASK; if (en) val |= BCM6368_CTRL_READY << BCM6368_NAND_ENABLE_SHIFT; else val &= ~(BCM6368_CTRL_READY << BCM6368_NAND_ENABLE_SHIFT); brcmnand_writel(val, mmio); } static int bcm6368_nand_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct bcm6368_nand_soc *priv; struct brcmnand_soc *soc; struct resource *res; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; soc = &priv->soc; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand-int-base"); priv->base = devm_ioremap_resource(dev, res); if (IS_ERR(priv->base)) return PTR_ERR(priv->base); soc->ctlrdy_ack = bcm6368_nand_intc_ack; soc->ctlrdy_set_enabled = bcm6368_nand_intc_set; /* Disable and ack all interrupts */ brcmnand_writel(0, priv->base + BCM6368_NAND_INT); brcmnand_writel(BCM6368_NAND_STATUS_MASK, priv->base + BCM6368_NAND_INT); return brcmnand_probe(pdev, soc); } static const struct of_device_id bcm6368_nand_of_match[] = { { .compatible = "brcm,nand-bcm6368" }, {}, }; MODULE_DEVICE_TABLE(of, bcm6368_nand_of_match); static struct platform_driver bcm6368_nand_driver = { .probe = bcm6368_nand_probe, .remove = brcmnand_remove, .driver = { .name = "bcm6368_nand", .pm = &brcmnand_pm_ops, .of_match_table = bcm6368_nand_of_match, } }; module_platform_driver(bcm6368_nand_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Simon Arlott"); MODULE_DESCRIPTION("NAND driver for BCM6368");
// functional_hash.h header -*- C++ -*- // Copyright (C) 2007, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/functional_hash.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ #ifndef _FUNCTIONAL_HASH_H #define _FUNCTIONAL_HASH_H 1 #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ # include <c++0x_warning.h> #endif #if defined(_GLIBCXX_INCLUDE_AS_TR1) # error C++0x header cannot be included from TR1 header #endif #if defined(_GLIBCXX_INCLUDE_AS_CXX0X) # include <tr1_impl/functional_hash.h> #else # define _GLIBCXX_INCLUDE_AS_CXX0X # define _GLIBCXX_BEGIN_NAMESPACE_TR1 # define _GLIBCXX_END_NAMESPACE_TR1 # define _GLIBCXX_TR1 # include <tr1_impl/functional_hash.h> # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_CXX0X #endif namespace std { struct error_code; template<> size_t hash<error_code>::operator()(error_code) const; } #endif // _FUNCTIONAL_HASH_H
// Copyright (c) 2013 Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // exploitability_linux.h: Linux specific exploitability engine. // // Provides a guess at the exploitability of the crash for the Linux // platform given a minidump and process_state. // // Author: Matthew Riley #ifndef GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_LINUX_H_ #define GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_LINUX_H_ #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/processor/exploitability.h" namespace google_breakpad { class ExploitabilityLinux : public Exploitability { public: ExploitabilityLinux(Minidump *dump, ProcessState *process_state); virtual ExploitabilityRating CheckPlatformExploitability(); }; } // namespace google_breakpad #endif // GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_LINUX_H_
/* * Copyright (c) 2005-2006 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * 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 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 RDMA_USER_CM_H #define RDMA_USER_CM_H #include <linux/types.h> #include <linux/in6.h> #include <rdma/ib_user_verbs.h> #include <rdma/ib_user_sa.h> #define RDMA_USER_CM_ABI_VERSION 4 #define RDMA_MAX_PRIVATE_DATA 256 enum { RDMA_USER_CM_CMD_CREATE_ID, RDMA_USER_CM_CMD_DESTROY_ID, RDMA_USER_CM_CMD_BIND_ADDR, RDMA_USER_CM_CMD_RESOLVE_ADDR, RDMA_USER_CM_CMD_RESOLVE_ROUTE, RDMA_USER_CM_CMD_QUERY_ROUTE, RDMA_USER_CM_CMD_CONNECT, RDMA_USER_CM_CMD_LISTEN, RDMA_USER_CM_CMD_ACCEPT, RDMA_USER_CM_CMD_REJECT, RDMA_USER_CM_CMD_DISCONNECT, RDMA_USER_CM_CMD_INIT_QP_ATTR, RDMA_USER_CM_CMD_GET_EVENT, RDMA_USER_CM_CMD_GET_OPTION, RDMA_USER_CM_CMD_SET_OPTION, RDMA_USER_CM_CMD_NOTIFY, RDMA_USER_CM_CMD_JOIN_MCAST, RDMA_USER_CM_CMD_LEAVE_MCAST, RDMA_USER_CM_CMD_MIGRATE_ID }; /* * command ABI structures. */ struct rdma_ucm_cmd_hdr { __u32 cmd; __u16 in; __u16 out; }; struct rdma_ucm_create_id { __u64 uid; __u64 response; __u16 ps; __u8 qp_type; __u8 reserved[5]; }; struct rdma_ucm_create_id_resp { __u32 id; }; struct rdma_ucm_destroy_id { __u64 response; __u32 id; __u32 reserved; }; struct rdma_ucm_destroy_id_resp { __u32 events_reported; }; struct rdma_ucm_bind_addr { __u64 response; struct sockaddr_in6 addr; __u32 id; }; struct rdma_ucm_resolve_addr { struct sockaddr_in6 src_addr; struct sockaddr_in6 dst_addr; __u32 id; __u32 timeout_ms; }; struct rdma_ucm_resolve_route { __u32 id; __u32 timeout_ms; }; struct rdma_ucm_query_route { __u64 response; __u32 id; __u32 reserved; }; struct rdma_ucm_query_route_resp { __u64 node_guid; struct ib_user_path_rec ib_route[2]; struct sockaddr_in6 src_addr; struct sockaddr_in6 dst_addr; __u32 num_paths; __u8 port_num; __u8 reserved[3]; }; struct rdma_ucm_conn_param { __u32 qp_num; __u32 reserved; __u8 private_data[RDMA_MAX_PRIVATE_DATA]; __u8 private_data_len; __u8 srq; __u8 responder_resources; __u8 initiator_depth; __u8 flow_control; __u8 retry_count; __u8 rnr_retry_count; __u8 valid; }; struct rdma_ucm_ud_param { __u32 qp_num; __u32 qkey; struct ib_uverbs_ah_attr ah_attr; __u8 private_data[RDMA_MAX_PRIVATE_DATA]; __u8 private_data_len; __u8 reserved[7]; }; struct rdma_ucm_connect { struct rdma_ucm_conn_param conn_param; __u32 id; __u32 reserved; }; struct rdma_ucm_listen { __u32 id; __u32 backlog; }; struct rdma_ucm_accept { __u64 uid; struct rdma_ucm_conn_param conn_param; __u32 id; __u32 reserved; }; struct rdma_ucm_reject { __u32 id; __u8 private_data_len; __u8 reserved[3]; __u8 private_data[RDMA_MAX_PRIVATE_DATA]; }; struct rdma_ucm_disconnect { __u32 id; }; struct rdma_ucm_init_qp_attr { __u64 response; __u32 id; __u32 qp_state; }; struct rdma_ucm_notify { __u32 id; __u32 event; }; struct rdma_ucm_join_mcast { __u64 response; /* rdma_ucm_create_id_resp */ __u64 uid; struct sockaddr_in6 addr; __u32 id; }; struct rdma_ucm_get_event { __u64 response; }; struct rdma_ucm_event_resp { __u64 uid; __u32 id; __u32 event; __u32 status; union { struct rdma_ucm_conn_param conn; struct rdma_ucm_ud_param ud; } param; }; /* Option levels */ enum { RDMA_OPTION_ID = 0, RDMA_OPTION_IB = 1 }; /* Option details */ enum { RDMA_OPTION_ID_TOS = 0, RDMA_OPTION_ID_REUSEADDR = 1, RDMA_OPTION_IB_PATH = 1 }; struct rdma_ucm_set_option { __u64 optval; __u32 id; __u32 level; __u32 optname; __u32 optlen; }; struct rdma_ucm_migrate_id { __u64 response; __u32 id; __u32 fd; }; struct rdma_ucm_migrate_resp { __u32 events_reported; }; #endif /* RDMA_USER_CM_H */
#include <linux/kernel.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/leds.h> #include <linux/err.h> #include <linux/clk.h> /* only needed for hacked clk rate change */ #include <asm/hardware/scoop.h> #include <asm/mach-types.h> static void hacked_arm_clk_rate_change(enum led_brightness value) { #define LED_OFF_ARM_CLK_RATE 100000000 static unsigned long max_arm_clk_rate = LED_OFF_ARM_CLK_RATE; static unsigned long min_arm_clk_rate = LED_OFF_ARM_CLK_RATE; struct clk * arm_clk; unsigned long old_arm_clk_rate; unsigned long new_arm_clk_rate; int rc; arm_clk = clk_get(NULL, "arm_clk"); BUG_ON(IS_ERR(arm_clk)); old_arm_clk_rate = clk_get_rate(arm_clk); // remember the current "maximum" so we can restore it when backlight is // back on max_arm_clk_rate = max(old_arm_clk_rate, max_arm_clk_rate); if( value == LED_OFF ) { new_arm_clk_rate = min_arm_clk_rate; } else { new_arm_clk_rate = max_arm_clk_rate; } if (new_arm_clk_rate != old_arm_clk_rate) { rc = clk_set_rate(arm_clk, new_arm_clk_rate); if (rc < 0 ) { printk(KERN_WARNING \ "Warning: %s(): HACK: setting arm clock rate to %ld Hz failed, rc=%d\n", __FUNCTION__, new_arm_clk_rate, rc); } else { printk(KERN_INFO \ "Info: %s(): HACK: set arm clock rate to %ld Hz, got %ld Hz\n", __FUNCTION__, new_arm_clk_rate, clk_get_rate(arm_clk)); } } clk_put(arm_clk); } extern int vc_gencmd(char *response, int maxlen, const char *format, ...); static void islands_ff_led_lcdbacklight_set(struct led_classdev *led_cdev, enum led_brightness value) { char response_buffer[32]; unsigned int brightness = (unsigned int)value; /* Restrict brighness level as 0 = 0, 1 - 90 = 90, 91-255 = 91-255 * We did this because, with brightness below 90 the display is barely * visible. * ssp */ if (brightness && brightness < 90) brightness = 90; vc_gencmd(response_buffer, 32, "set_backlight %i", brightness); hacked_arm_clk_rate_change(value); } static void islands_ff_led_buttonbacklight_set(struct led_classdev *led_cdev, enum led_brightness value) { } static void islands_ff_led_keyboardbacklight_set(struct led_classdev *led_cdev, enum led_brightness value) { } static struct led_classdev islands_ff_lcdbacklight_led = { .name = "lcd-backlight", .default_trigger = "lcd-backlight", .brightness_set = islands_ff_led_lcdbacklight_set, }; static struct led_classdev islands_ff_buttonbacklight_led = { .name = "button-backlight", .default_trigger = "button-backlight", .brightness_set = islands_ff_led_buttonbacklight_set, }; static struct led_classdev islands_ff_keyboardbacklight_led = { .name = "keyboard-backlight", .default_trigger = "keyboard-backlight", .brightness_set = islands_ff_led_keyboardbacklight_set, }; #ifdef CONFIG_PM static int islands_ff_led_suspend(struct platform_device *dev, pm_message_t state) { #ifdef CONFIG_LEDS_TRIGGERS if (islands_ff_lcdbacklight_led.trigger && strcmp(islands_ff_lcdbacklight_led.trigger->name, "sharpsl-charge")) #endif led_classdev_suspend(&islands_ff_lcdbacklight_led); led_classdev_suspend(&islands_ff_buttonbacklight_led); led_classdev_suspend(&islands_ff_keyboardbacklight_led); return 0; } static int islands_ff_led_resume(struct platform_device *dev) { led_classdev_resume(&islands_ff_lcdbacklight_led); led_classdev_resume(&islands_ff_buttonbacklight_led); led_classdev_resume(&islands_ff_keyboardbacklight_led); return 0; } #else #define islands_ff_led_suspend NULL #define islands_ff_led_resume NULL #endif static int islands_ff_led_probe(struct platform_device *pdev) { int ret; ret = led_classdev_register(&pdev->dev, &islands_ff_lcdbacklight_led); if (ret < 0) return ret; ret = led_classdev_register(&pdev->dev, &islands_ff_buttonbacklight_led); if (ret < 0) return ret; led_classdev_register(&pdev->dev, &islands_ff_keyboardbacklight_led); return ret; } static int islands_ff_led_remove(struct platform_device *pdev) { led_classdev_unregister(&islands_ff_lcdbacklight_led); led_classdev_unregister(&islands_ff_buttonbacklight_led); led_classdev_unregister(&islands_ff_keyboardbacklight_led); return 0; } static struct platform_driver islands_ff_led_driver = { .probe = islands_ff_led_probe, .remove = islands_ff_led_remove, .suspend = islands_ff_led_suspend, .resume = islands_ff_led_resume, .driver = { .name = "islands_ff-led", .owner = THIS_MODULE, }, }; static int __init islands_ff_led_init(void) { return platform_driver_register(&islands_ff_led_driver); } static void __exit islands_ff_led_exit(void) { platform_driver_unregister(&islands_ff_led_driver); } module_init(islands_ff_led_init); module_exit(islands_ff_led_exit);
/* * This file is part of Cleanflight. * * Cleanflight is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>. */ /* * telemetry_MSP.h * * Created on: 22 Apr 2014 * Author: trey marc */ #ifndef TELEMETRY_MSP_H_ #define TELEMETRY_MSP_H_ void initMSPTelemetry(telemetryConfig_t *initialTelemetryConfig); void handleMSPTelemetry(void); void checkMSPTelemetryState(void); void freeMSPTelemetryPort(void); void configureMSPTelemetryPort(void); #endif /* TELEMETRY_MSP_H_ */
/* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_SHARED_BUFFER_H #define ANDROID_SHARED_BUFFER_H #include <stdint.h> #include <sys/types.h> // --------------------------------------------------------------------------- namespace android { class SharedBuffer { public: /* flags to use with release() */ enum { eKeepStorage = 0x00000001 }; /*! allocate a buffer of size 'size' and acquire() it. * call release() to free it. */ static SharedBuffer* alloc(size_t size); /*! free the memory associated with the SharedBuffer. * Fails if there are any users associated with this SharedBuffer. * In other words, the buffer must have been release by all its * users. */ static ssize_t dealloc(const SharedBuffer* released); //! access the data for read inline const void* data() const; //! access the data for read/write inline void* data(); //! get size of the buffer inline size_t size() const; //! get back a SharedBuffer object from its data static inline SharedBuffer* bufferFromData(void* data); //! get back a SharedBuffer object from its data static inline const SharedBuffer* bufferFromData(const void* data); //! get the size of a SharedBuffer object from its data static inline size_t sizeFromData(const void* data); //! edit the buffer (get a writtable, or non-const, version of it) SharedBuffer* edit() const; //! edit the buffer, resizing if needed SharedBuffer* editResize(size_t size) const; //! like edit() but fails if a copy is required SharedBuffer* attemptEdit() const; //! resize and edit the buffer, loose it's content. SharedBuffer* reset(size_t size) const; //! acquire/release a reference on this buffer void acquire() const; /*! release a reference on this buffer, with the option of not * freeing the memory associated with it if it was the last reference * returns the previous reference count */ int32_t release(uint32_t flags = 0) const; //! returns wether or not we're the only owner inline bool onlyOwner() const; private: inline SharedBuffer() { } inline ~SharedBuffer() { } SharedBuffer(const SharedBuffer&); SharedBuffer& operator = (const SharedBuffer&); // 16 bytes. must be sized to preserve correct alignment. mutable int32_t mRefs; size_t mSize; uint32_t mReserved[2]; }; // --------------------------------------------------------------------------- const void* SharedBuffer::data() const { return this + 1; } void* SharedBuffer::data() { return this + 1; } size_t SharedBuffer::size() const { return mSize; } SharedBuffer* SharedBuffer::bufferFromData(void* data) { return data ? static_cast<SharedBuffer *>(data)-1 : 0; } const SharedBuffer* SharedBuffer::bufferFromData(const void* data) { return data ? static_cast<const SharedBuffer *>(data)-1 : 0; } size_t SharedBuffer::sizeFromData(const void* data) { return data ? bufferFromData(data)->mSize : 0; } bool SharedBuffer::onlyOwner() const { return (mRefs == 1); } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_VECTOR_H
/* * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ #ifndef JAVA_MAIN_MD_H #define JAVA_MAIN_MD_H #define PATH_SEPARATOR ";" #define LOCAL_DIR_SEPARATOR '\\' #define DIR_SEPARATOR '/' #endif
/* * LuCI Template - Utility header * * Copyright (C) 2010-2012 Jo-Philipp Wich <jow@openwrt.org> * * 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 _TEMPLATE_UTILS_H_ #define _TEMPLATE_UTILS_H_ #include <stdlib.h> #include <stdio.h> #include <string.h> /* buffer object */ struct template_buffer { char *data; char *dptr; unsigned int size; unsigned int fill; }; struct template_buffer * buf_init(int size); int buf_grow(struct template_buffer *buf, int size); int buf_putchar(struct template_buffer *buf, char c); int buf_append(struct template_buffer *buf, const char *s, int len); int buf_length(struct template_buffer *buf); char * buf_destroy(struct template_buffer *buf); char * utf8(const char *s, unsigned int l); char * pcdata(const char *s, unsigned int l); char * striptags(const char *s, unsigned int l); void luastr_escape(struct template_buffer *out, const char *s, unsigned int l, int escape_xml); void luastr_translate(struct template_buffer *out, const char *s, unsigned int l, int escape_xml); #endif
/* * linux/mm/page_io.c * * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds * * Swap reorganised 29.12.95, * Asynchronous swapping added 30.12.95. Stephen Tweedie * Removed race in async swapping. 14.4.1996. Bruno Haible * Add swap of shared pages through the page cache. 20.2.1998. Stephen Tweedie * Always use brw_page, life becomes simpler. 12 May 1998 Eric Biederman */ #include <linux/mm.h> #include <linux/kernel_stat.h> #include <linux/gfp.h> #include <linux/pagemap.h> #include <linux/swap.h> #include <linux/bio.h> #include <linux/swapops.h> #include <linux/writeback.h> #include <linux/ratelimit.h> #include <asm/pgtable.h> /* * We don't need to see swap errors more than once every 1 second to know * that a problem is occurring. */ #define SWAP_ERROR_LOG_RATE_MS 1000 static struct bio *get_swap_bio(gfp_t gfp_flags, struct page *page, bio_end_io_t end_io) { struct bio *bio; bio = bio_alloc(gfp_flags, 1); if (bio) { bio->bi_sector = map_swap_page(page, &bio->bi_bdev); bio->bi_sector <<= PAGE_SHIFT - 9; bio->bi_io_vec[0].bv_page = page; bio->bi_io_vec[0].bv_len = PAGE_SIZE; bio->bi_io_vec[0].bv_offset = 0; bio->bi_vcnt = 1; bio->bi_idx = 0; bio->bi_size = PAGE_SIZE; bio->bi_end_io = end_io; } return bio; } static void end_swap_bio_write(struct bio *bio, int err) { const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); struct page *page = bio->bi_io_vec[0].bv_page; static unsigned long swap_error_rs_time; if (!uptodate) { SetPageError(page); /* * We failed to write the page out to swap-space. * Re-dirty the page in order to avoid it being reclaimed. * Also print a dire warning that things will go BAD (tm) * very quickly. * * Also clear PG_reclaim to avoid rotate_reclaimable_page() */ set_page_dirty(page); if (printk_timed_ratelimit(&swap_error_rs_time, SWAP_ERROR_LOG_RATE_MS)) printk(KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n", imajor(bio->bi_bdev->bd_inode), iminor(bio->bi_bdev->bd_inode), (unsigned long long)bio->bi_sector); ClearPageReclaim(page); } end_page_writeback(page); bio_put(bio); } void end_swap_bio_read(struct bio *bio, int err) { const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); struct page *page = bio->bi_io_vec[0].bv_page; if (!uptodate) { SetPageError(page); ClearPageUptodate(page); printk(KERN_ALERT "Read-error on swap-device (%u:%u:%Lu)\n", imajor(bio->bi_bdev->bd_inode), iminor(bio->bi_bdev->bd_inode), (unsigned long long)bio->bi_sector); } else { SetPageUptodate(page); } unlock_page(page); bio_put(bio); } /* * We may have stale swap cache pages in memory: notice * them here and get rid of the unnecessary final write. */ int swap_writepage(struct page *page, struct writeback_control *wbc) { struct bio *bio; int ret = 0, rw = WRITE; if (try_to_free_swap(page)) { unlock_page(page); goto out; } bio = get_swap_bio(GFP_NOIO, page, end_swap_bio_write); if (bio == NULL) { set_page_dirty(page); unlock_page(page); ret = -ENOMEM; goto out; } if (wbc->sync_mode == WB_SYNC_ALL) rw |= REQ_SYNC; count_vm_event(PSWPOUT); set_page_writeback(page); unlock_page(page); submit_bio(rw, bio); out: return ret; } int swap_readpage(struct page *page) { struct bio *bio; int ret = 0; VM_BUG_ON(!PageLocked(page)); VM_BUG_ON(PageUptodate(page)); bio = get_swap_bio(GFP_KERNEL, page, end_swap_bio_read); if (bio == NULL) { unlock_page(page); ret = -ENOMEM; goto out; } count_vm_event(PSWPIN); submit_bio(READ, bio); out: return ret; }
#ifndef SPI_ADIS16240_H_ #define SPI_ADIS16240_H_ #define ADIS16240_STARTUP_DELAY 220 /* ms */ /* Flash memory write count */ #define ADIS16240_FLASH_CNT 0x00 /* Output, power supply */ #define ADIS16240_SUPPLY_OUT 0x02 /* Output, x-axis accelerometer */ #define ADIS16240_XACCL_OUT 0x04 /* Output, y-axis accelerometer */ #define ADIS16240_YACCL_OUT 0x06 /* Output, z-axis accelerometer */ #define ADIS16240_ZACCL_OUT 0x08 /* Output, auxiliary ADC input */ #define ADIS16240_AUX_ADC 0x0A /* Output, temperature */ #define ADIS16240_TEMP_OUT 0x0C /* Output, x-axis acceleration peak */ #define ADIS16240_XPEAK_OUT 0x0E /* Output, y-axis acceleration peak */ #define ADIS16240_YPEAK_OUT 0x10 /* Output, z-axis acceleration peak */ #define ADIS16240_ZPEAK_OUT 0x12 /* Output, sum-of-squares acceleration peak */ #define ADIS16240_XYZPEAK_OUT 0x14 /* Output, Capture Buffer 1, X and Y acceleration */ #define ADIS16240_CAPT_BUF1 0x16 /* Output, Capture Buffer 2, Z acceleration */ #define ADIS16240_CAPT_BUF2 0x18 /* Diagnostic, error flags */ #define ADIS16240_DIAG_STAT 0x1A /* Diagnostic, event counter */ #define ADIS16240_EVNT_CNTR 0x1C /* Diagnostic, check sum value from firmware test */ #define ADIS16240_CHK_SUM 0x1E /* Calibration, x-axis acceleration offset adjustment */ #define ADIS16240_XACCL_OFF 0x20 /* Calibration, y-axis acceleration offset adjustment */ #define ADIS16240_YACCL_OFF 0x22 /* Calibration, z-axis acceleration offset adjustment */ #define ADIS16240_ZACCL_OFF 0x24 /* Clock, hour and minute */ #define ADIS16240_CLK_TIME 0x2E /* Clock, month and day */ #define ADIS16240_CLK_DATE 0x30 /* Clock, year */ #define ADIS16240_CLK_YEAR 0x32 /* Wake-up setting, hour and minute */ #define ADIS16240_WAKE_TIME 0x34 /* Wake-up setting, month and day */ #define ADIS16240_WAKE_DATE 0x36 /* Alarm 1 amplitude threshold */ #define ADIS16240_ALM_MAG1 0x38 /* Alarm 2 amplitude threshold */ #define ADIS16240_ALM_MAG2 0x3A /* Alarm control */ #define ADIS16240_ALM_CTRL 0x3C /* Capture, external trigger control */ #define ADIS16240_XTRIG_CTRL 0x3E /* Capture, address pointer */ #define ADIS16240_CAPT_PNTR 0x40 /* Capture, configuration and control */ #define ADIS16240_CAPT_CTRL 0x42 /* General-purpose digital input/output control */ #define ADIS16240_GPIO_CTRL 0x44 /* Miscellaneous control */ #define ADIS16240_MSC_CTRL 0x46 /* Internal sample period (rate) control */ #define ADIS16240_SMPL_PRD 0x48 /* System command */ #define ADIS16240_GLOB_CMD 0x4A /* MSC_CTRL */ /* Enables sum-of-squares output (XYZPEAK_OUT) */ #define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN BIT(15) /* Enables peak tracking output (XPEAK_OUT, YPEAK_OUT, and ZPEAK_OUT) */ #define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN BIT(14) /* Self-test enable: 1 = apply electrostatic force, 0 = disabled */ #define ADIS16240_MSC_CTRL_SELF_TEST_EN BIT(8) /* Data-ready enable: 1 = enabled, 0 = disabled */ #define ADIS16240_MSC_CTRL_DATA_RDY_EN BIT(2) /* Data-ready polarity: 1 = active high, 0 = active low */ #define ADIS16240_MSC_CTRL_ACTIVE_HIGH BIT(1) /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ #define ADIS16240_MSC_CTRL_DATA_RDY_DIO2 BIT(0) /* DIAG_STAT */ /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ #define ADIS16240_DIAG_STAT_ALARM2 BIT(9) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ #define ADIS16240_DIAG_STAT_ALARM1 BIT(8) /* Capture buffer full: 1 = capture buffer is full */ #define ADIS16240_DIAG_STAT_CPT_BUF_FUL BIT(7) /* Flash test, checksum flag: 1 = mismatch, 0 = match */ #define ADIS16240_DIAG_STAT_CHKSUM BIT(6) /* Power-on, self-test flag: 1 = failure, 0 = pass */ #define ADIS16240_DIAG_STAT_PWRON_FAIL_BIT 5 /* Power-on self-test: 1 = in-progress, 0 = complete */ #define ADIS16240_DIAG_STAT_PWRON_BUSY BIT(4) /* SPI communications failure */ #define ADIS16240_DIAG_STAT_SPI_FAIL_BIT 3 /* Flash update failure */ #define ADIS16240_DIAG_STAT_FLASH_UPT_BIT 2 /* Power supply above 3.625 V */ #define ADIS16240_DIAG_STAT_POWER_HIGH_BIT 1 /* Power supply below 3.15 V */ #define ADIS16240_DIAG_STAT_POWER_LOW_BIT 0 /* GLOB_CMD */ #define ADIS16240_GLOB_CMD_RESUME BIT(8) #define ADIS16240_GLOB_CMD_SW_RESET BIT(7) #define ADIS16240_GLOB_CMD_STANDBY BIT(2) #define ADIS16240_ERROR_ACTIVE BIT(14) /* At the moment triggers are only used for ring buffer * filling. This may change! */ #define ADIS16240_SCAN_ACC_X 0 #define ADIS16240_SCAN_ACC_Y 1 #define ADIS16240_SCAN_ACC_Z 2 #define ADIS16240_SCAN_SUPPLY 3 #define ADIS16240_SCAN_AUX_ADC 4 #define ADIS16240_SCAN_TEMP 5 #endif /* SPI_ADIS16240_H_ */
/* * Count register synchronisation. * * All CPUs will have their count registers synchronised to the CPU0 next time * value. This can cause a small timewarp for CPU0. All other CPU's should * not have done anything significant (but they may have had interrupts * enabled briefly - prom_smp_finish() should not be responsible for enabling * interrupts...) */ #include <linux/kernel.h> #include <linux/irqflags.h> #include <linux/cpumask.h> #include <asm/r4k-timer.h> #include <linux/atomic.h> #include <asm/barrier.h> #include <asm/mipsregs.h> static unsigned int initcount = 0; static atomic_t count_count_start = ATOMIC_INIT(0); static atomic_t count_count_stop = ATOMIC_INIT(0); #define COUNTON 100 #define NR_LOOPS 3 void synchronise_count_master(int cpu) { int i; unsigned long flags; pr_info("Synchronize counters for CPU %u: ", cpu); local_irq_save(flags); /* * We loop a few times to get a primed instruction cache, * then the last pass is more or less synchronised and * the master and slaves each set their cycle counters to a known * value all at once. This reduces the chance of having random offsets * between the processors, and guarantees that the maximum * delay between the cycle counters is never bigger than * the latency of information-passing (cachelines) between * two CPUs. */ for (i = 0; i < NR_LOOPS; i++) { /* slaves loop on '!= 2' */ while (atomic_read(&count_count_start) != 1) mb(); atomic_set(&count_count_stop, 0); smp_wmb(); /* Let the slave writes its count register */ atomic_inc(&count_count_start); /* Count will be initialised to current timer */ if (i == 1) initcount = read_c0_count(); /* * Everyone initialises count in the last loop: */ if (i == NR_LOOPS-1) write_c0_count(initcount); /* * Wait for slave to leave the synchronization point: */ while (atomic_read(&count_count_stop) != 1) mb(); atomic_set(&count_count_start, 0); smp_wmb(); atomic_inc(&count_count_stop); } /* Arrange for an interrupt in a short while */ write_c0_compare(read_c0_count() + COUNTON); local_irq_restore(flags); /* * i386 code reported the skew here, but the * count registers were almost certainly out of sync * so no point in alarming people */ pr_cont("done.\n"); } void synchronise_count_slave(int cpu) { int i; /* * Not every cpu is online at the time this gets called, * so we first wait for the master to say everyone is ready */ for (i = 0; i < NR_LOOPS; i++) { atomic_inc(&count_count_start); while (atomic_read(&count_count_start) != 2) mb(); /* * Everyone initialises count in the last loop: */ if (i == NR_LOOPS-1) write_c0_count(initcount); atomic_inc(&count_count_stop); while (atomic_read(&count_count_stop) != 2) mb(); } /* Arrange for an interrupt in a short while */ write_c0_compare(read_c0_count() + COUNTON); } #undef NR_LOOPS
#include "clar_libgit2.h" static git_repository *_repo; static git_commit *commit; void test_graph_descendant_of__initialize(void) { git_oid oid; cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git"))); git_oid_fromstr(&oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); cl_git_pass(git_commit_lookup(&commit, _repo, &oid)); } void test_graph_descendant_of__cleanup(void) { git_commit_free(commit); commit = NULL; git_repository_free(_repo); _repo = NULL; } void test_graph_descendant_of__returns_correct_result(void) { git_commit *other; cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(commit))); cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 1)); cl_assert_equal_i(1, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(other))); cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(other), git_commit_id(commit))); git_commit_free(other); cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 3)); cl_assert_equal_i(1, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(other))); cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(other), git_commit_id(commit))); git_commit_free(other); } void test_graph_descendant_of__nopath(void) { git_oid oid; git_oid_fromstr(&oid, "e90810b8df3e80c413d903f631643c716887138d"); cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(commit), &oid)); }
/* IP tables module for matching the value of the IPv4 and TCP ECN bits * * (C) 2002 by Harald Welte <laforge@gnumonks.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/in.h> #include <linux/ip.h> #include <net/ip.h> #include <linux/module.h> #include <linux/skbuff.h> #include <linux/tcp.h> #include <linux/netfilter/x_tables.h> #include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netfilter_ipv4/ipt_ecn.h> MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); MODULE_DESCRIPTION("Xtables: Explicit Congestion Notification (ECN) flag match for IPv4"); MODULE_LICENSE("GPL"); static inline bool match_ip(const struct sk_buff *skb, const struct ipt_ecn_info *einfo) { return (ip_hdr(skb)->tos & IPT_ECN_IP_MASK) == einfo->ip_ect; } static inline bool match_tcp(const struct sk_buff *skb, const struct ipt_ecn_info *einfo, bool *hotdrop) { struct tcphdr _tcph; const struct tcphdr *th; /* In practice, TCP match does this, so can't fail. But let's * be good citizens. */ th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph); if (th == NULL) { *hotdrop = false; return false; } if (einfo->operation & IPT_ECN_OP_MATCH_ECE) { if (einfo->invert & IPT_ECN_OP_MATCH_ECE) { if (th->ece == 1) return false; } else { if (th->ece == 0) return false; } } if (einfo->operation & IPT_ECN_OP_MATCH_CWR) { if (einfo->invert & IPT_ECN_OP_MATCH_CWR) { if (th->cwr == 1) return false; } else { if (th->cwr == 0) return false; } } return true; } static bool ecn_mt(const struct sk_buff *skb, const struct xt_match_param *par) { const struct ipt_ecn_info *info = par->matchinfo; if (info->operation & IPT_ECN_OP_MATCH_IP) if (!match_ip(skb, info)) return false; if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR)) { if (ip_hdr(skb)->protocol != IPPROTO_TCP) return false; if (!match_tcp(skb, info, par->hotdrop)) return false; } return true; } static bool ecn_mt_check(const struct xt_mtchk_param *par) { const struct ipt_ecn_info *info = par->matchinfo; const struct ipt_ip *ip = par->entryinfo; if (info->operation & IPT_ECN_OP_MATCH_MASK) return false; if (info->invert & IPT_ECN_OP_MATCH_MASK) return false; if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR) && ip->proto != IPPROTO_TCP) { printk(KERN_WARNING "ipt_ecn: can't match TCP bits in rule for" " non-tcp packets\n"); return false; } return true; } static struct xt_match ecn_mt_reg __read_mostly = { .name = "ecn", .family = NFPROTO_IPV4, .match = ecn_mt, .matchsize = sizeof(struct ipt_ecn_info), .checkentry = ecn_mt_check, .me = THIS_MODULE, }; static int __init ecn_mt_init(void) { return xt_register_match(&ecn_mt_reg); } static void __exit ecn_mt_exit(void) { xt_unregister_match(&ecn_mt_reg); } module_init(ecn_mt_init); module_exit(ecn_mt_exit);
/* mt6627_fm_config.c * * (C) Copyright 2011 * MediaTek <www.MediaTek.com> * hongcheng <hongcheng.xia@MediaTek.com> * * FM Radio Driver * * 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 */ #include <linux/string.h> #include <linux/slab.h> #include "fm_typedef.h" #include "fm_rds.h" #include "fm_dbg.h" #include "fm_err.h" #include "fm_stdlib.h" #include "fm_patch.h" #include "fm_config.h" /* #include "fm_cust_cfg.h" */ #include "mt6627_fm_cust_cfg.h" fm_cust_cfg mt6627_fm_config; /* static fm_s32 fm_index = 0; */ static fm_s32 MT6627fm_cust_config_print(fm_cust_cfg *cfg) { WCN_DBG(FM_NTC | MAIN, "MT6627 rssi_l:\t%d\n", cfg->rx_cfg.long_ana_rssi_th); WCN_DBG(FM_NTC | MAIN, "MT6627 rssi_s:\t%d\n", cfg->rx_cfg.short_ana_rssi_th); WCN_DBG(FM_NTC | MAIN, "MT6627 pamd_th:\t%d\n", cfg->rx_cfg.pamd_th); WCN_DBG(FM_NTC | MAIN, "MT6627 mr_th:\t%d\n", cfg->rx_cfg.mr_th); WCN_DBG(FM_NTC | MAIN, "MT6627 atdc_th:\t%d\n", cfg->rx_cfg.atdc_th); WCN_DBG(FM_NTC | MAIN, "MT6627 prx_th:\t%d\n", cfg->rx_cfg.prx_th); WCN_DBG(FM_NTC | MAIN, "MT6627 atdev_th:\t%d\n", cfg->rx_cfg.atdev_th); WCN_DBG(FM_NTC | MAIN, "MT6627 smg_th:\t%d\n", cfg->rx_cfg.smg_th); WCN_DBG(FM_NTC | MAIN, "de_emphasis:\t%d\n", cfg->rx_cfg.deemphasis); WCN_DBG(FM_NTC | MAIN, "osc_freq:\t%d\n", cfg->rx_cfg.osc_freq); WCN_DBG(FM_NTC | MAIN, "aud path[%d]I2S state[%d]mode[%d]rate[%d]\n", cfg->aud_cfg.aud_path, cfg->aud_cfg.i2s_info.status, cfg->aud_cfg.i2s_info.mode, cfg->aud_cfg.i2s_info.rate); return 0; } static fm_s32 MT6627cfg_item_handler(fm_s8 *grp, fm_s8 *key, fm_s8 *val, fm_cust_cfg *cfg) { fm_s32 ret = 0; struct fm_rx_cust_cfg *rx_cfg = &cfg->rx_cfg; if (0 <= (ret = cfg_item_match(key, val, "FM_RX_RSSI_TH_LONG_MT6627", &rx_cfg->long_ana_rssi_th))) { /* FMR_RSSI_TH_L = 0x0301 */ return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_RSSI_TH_SHORT_MT6627", &rx_cfg->short_ana_rssi_th))) { return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_DESENSE_RSSI_MT6627", &rx_cfg->desene_rssi_th))) { return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_PAMD_TH_MT6627", &rx_cfg->pamd_th))) { return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_MR_TH_MT6627", &rx_cfg->mr_th))) { return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_ATDC_TH_MT6627", &rx_cfg->atdc_th))) { return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_PRX_TH_MT6627", &rx_cfg->prx_th))) { return ret; } /*else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_ATDEV_TH_MT6627", &rx_cfg->atdev_th))) { return ret; } */ else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_SMG_TH_MT6627", &rx_cfg->smg_th))) { return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_DEEMPHASIS_MT6627", &rx_cfg->deemphasis))) { return ret; } else if (0 <= (ret = cfg_item_match(key, val, "FM_RX_OSC_FREQ_MT6627", &rx_cfg->osc_freq))) { return ret; } else { WCN_DBG(FM_WAR | MAIN, "MT6627 invalid key\n"); return -1; } } static fm_s32 MT6627fm_cust_config_default(fm_cust_cfg *cfg) { FMR_ASSERT(cfg); cfg->rx_cfg.long_ana_rssi_th = FM_RX_RSSI_TH_LONG_MT6627; cfg->rx_cfg.short_ana_rssi_th = FM_RX_RSSI_TH_SHORT_MT6627; cfg->rx_cfg.desene_rssi_th = FM_RX_DESENSE_RSSI_MT6627; cfg->rx_cfg.pamd_th = FM_RX_PAMD_TH_MT6627; cfg->rx_cfg.mr_th = FM_RX_MR_TH_MT6627; cfg->rx_cfg.atdc_th = FM_RX_ATDC_TH_MT6627; cfg->rx_cfg.prx_th = FM_RX_PRX_TH_MT6627; cfg->rx_cfg.smg_th = FM_RX_SMG_TH_MT6627; cfg->rx_cfg.deemphasis = FM_RX_DEEMPHASIS_MT6627; cfg->rx_cfg.osc_freq = FM_RX_OSC_FREQ_MT6627; cfg->aud_cfg.aud_path = FM_AUD_I2S; cfg->aud_cfg.i2s_info.status = FM_I2S_OFF; cfg->aud_cfg.i2s_info.mode = FM_I2S_MASTER; cfg->aud_cfg.i2s_info.rate = FM_I2S_32K; cfg->aud_cfg.i2s_pad = FM_I2S_PAD_CONN; return 0; } static fm_s32 MT6627fm_cust_config_file(const fm_s8 *filename, fm_cust_cfg *cfg) { fm_s32 ret = 0; fm_s8 *buf = NULL; fm_s32 file_len = 0; if (!(buf = fm_zalloc(4096))) { WCN_DBG(FM_ALT | MAIN, "-ENOMEM\n"); return -ENOMEM; } /* fm_index = 0; */ file_len = fm_file_read(filename, buf, 4096, 0); if (file_len <= 0) { ret = -1; goto out; } ret = cfg_parser(buf, MT6627cfg_item_handler, cfg); out: if (buf) { fm_free(buf); } return ret; } #define MT6627_FM_CUST_CFG_PATH "etc/fmr/mt6627_fm_cust.cfg" fm_s32 MT6627fm_cust_config_setup(const fm_s8 *filepath) { fm_s32 ret = 0; fm_s8 *filep = NULL; fm_s8 file_path[51] = { 0 }; MT6627fm_cust_config_default(&mt6627_fm_config); WCN_DBG(FM_NTC | MAIN, "MT6627 FM default config\n"); MT6627fm_cust_config_print(&mt6627_fm_config); if (!filepath) { filep = MT6627_FM_CUST_CFG_PATH; } else { memcpy(file_path, filepath, (strlen(filepath) > 50) ? 50 : strlen(filepath)); filep = file_path; trim_path(&filep); } ret = MT6627fm_cust_config_file(filep, &mt6627_fm_config); WCN_DBG(FM_NTC | MAIN, "MT6627 FM cust config\n"); MT6627fm_cust_config_print(&mt6627_fm_config); return ret; }
#include <linux/init.h> #include <linux/pci.h> /* PCI interrupt pins */ #define PCIA 1 #define PCIB 2 #define PCIC 3 #define PCID 4 /* This table is filled in by interrogating the PIIX4 chip */ static char pci_irq[5] = { }; static char irq_tab[][5] __initdata = { /* INTA INTB INTC INTD */ {0, 0, 0, 0, 0 }, /* 0: GT64120 PCI bridge */ {0, 0, 0, 0, 0 }, /* 1: Unused */ {0, 0, 0, 0, 0 }, /* 2: Unused */ {0, 0, 0, 0, 0 }, /* 3: Unused */ {0, 0, 0, 0, 0 }, /* 4: Unused */ {0, 0, 0, 0, 0 }, /* 5: Unused */ {0, 0, 0, 0, 0 }, /* 6: Unused */ {0, 0, 0, 0, 0 }, /* 7: Unused */ {0, 0, 0, 0, 0 }, /* 8: Unused */ {0, 0, 0, 0, 0 }, /* 9: Unused */ {0, 0, 0, 0, PCID }, /* 10: PIIX4 USB */ {0, PCIB, 0, 0, 0 }, /* 11: AMD 79C973 Ethernet */ {0, PCIC, 0, 0, 0 }, /* 12: Crystal 4281 Sound */ {0, 0, 0, 0, 0 }, /* 13: Unused */ {0, 0, 0, 0, 0 }, /* 14: Unused */ {0, 0, 0, 0, 0 }, /* 15: Unused */ {0, 0, 0, 0, 0 }, /* 16: Unused */ {0, 0, 0, 0, 0 }, /* 17: Bonito/SOC-it PCI Bridge*/ {0, PCIA, PCIB, PCIC, PCID }, /* 18: PCI Slot 1 */ {0, PCIB, PCIC, PCID, PCIA }, /* 19: PCI Slot 2 */ {0, PCIC, PCID, PCIA, PCIB }, /* 20: PCI Slot 3 */ {0, PCID, PCIA, PCIB, PCIC } /* 21: PCI Slot 4 */ }; int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { int virq; virq = irq_tab[slot][pin]; return pci_irq[virq]; } /* Do platform specific device initialization at pci_enable_device() time */ int pcibios_plat_dev_init(struct pci_dev *dev) { return 0; } static void malta_piix_func0_fixup(struct pci_dev *pdev) { unsigned char reg_val; static int piixirqmap[16] = { /* PIIX PIRQC[A:D] irq mappings */ 0, 0, 0, 3, 4, 5, 6, 7, 0, 9, 10, 11, 12, 0, 14, 15 }; int i; /* Interrogate PIIX4 to get PCI IRQ mapping */ for (i = 0; i <= 3; i++) { pci_read_config_byte(pdev, 0x60+i, &reg_val); if (reg_val & 0x80) pci_irq[PCIA+i] = 0; /* Disabled */ else pci_irq[PCIA+i] = piixirqmap[reg_val & 15]; } /* Done by YAMON 2.00 onwards */ if (PCI_SLOT(pdev->devfn) == 10) { /* * Set top of main memory accessible by ISA or DMA * devices to 16 Mb. */ pci_read_config_byte(pdev, 0x69, &reg_val); pci_write_config_byte(pdev, 0x69, reg_val | 0xf0); } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0, malta_piix_func0_fixup); static void malta_piix_func1_fixup(struct pci_dev *pdev) { unsigned char reg_val; /* Done by YAMON 2.02 onwards */ if (PCI_SLOT(pdev->devfn) == 10) { /* * IDE Decode enable. */ pci_read_config_byte(pdev, 0x41, &reg_val); pci_write_config_byte(pdev, 0x41, reg_val|0x80); pci_read_config_byte(pdev, 0x43, &reg_val); pci_write_config_byte(pdev, 0x43, reg_val|0x80); } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB, malta_piix_func1_fixup); /* Enable PCI 2.1 compatibility in PIIX4 */ static void quirk_dlcsetup(struct pci_dev *dev) { u8 odlc, ndlc; (void) pci_read_config_byte(dev, 0x82, &odlc); /* Enable passive releases and delayed transaction */ ndlc = odlc | 7; (void) pci_write_config_byte(dev, 0x82, ndlc); } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0, quirk_dlcsetup);
#undef MMC_STRPCL #undef MMC_STAT #undef MMC_CLKRT #undef MMC_SPI #undef MMC_CMDAT #undef MMC_RESTO #undef MMC_RDTO #undef MMC_BLKLEN #undef MMC_NOB #undef MMC_PRTBUF #undef MMC_I_MASK #undef END_CMD_RES #undef PRG_DONE #undef DATA_TRAN_DONE #undef MMC_I_REG #undef MMC_CMD #undef MMC_ARGH #undef MMC_ARGL #undef MMC_RES #undef MMC_RXFIFO #undef MMC_TXFIFO #define MMC_STRPCL 0x0000 #define STOP_CLOCK (1 << 0) #define START_CLOCK (2 << 0) #define MMC_STAT 0x0004 #define STAT_END_CMD_RES (1 << 13) #define STAT_PRG_DONE (1 << 12) #define STAT_DATA_TRAN_DONE (1 << 11) #define STAT_CLK_EN (1 << 8) #define STAT_RECV_FIFO_FULL (1 << 7) #define STAT_XMIT_FIFO_EMPTY (1 << 6) #define STAT_RES_CRC_ERR (1 << 5) #define STAT_SPI_READ_ERROR_TOKEN (1 << 4) #define STAT_CRC_READ_ERROR (1 << 3) #define STAT_CRC_WRITE_ERROR (1 << 2) #define STAT_TIME_OUT_RESPONSE (1 << 1) #define STAT_READ_TIME_OUT (1 << 0) #define MMC_CLKRT 0x0008 /* 3 bit */ #define MMC_SPI 0x000c #define SPI_CS_ADDRESS (1 << 3) #define SPI_CS_EN (1 << 2) #define CRC_ON (1 << 1) #define SPI_EN (1 << 0) #define MMC_CMDAT 0x0010 #define CMDAT_DMAEN (1 << 7) #define CMDAT_INIT (1 << 6) #define CMDAT_BUSY (1 << 5) #define CMDAT_STREAM (1 << 4) /* 1 = stream */ #define CMDAT_WRITE (1 << 3) /* 1 = write */ #define CMDAT_DATAEN (1 << 2) #define CMDAT_RESP_NONE (0 << 0) #define CMDAT_RESP_SHORT (1 << 0) #define CMDAT_RESP_R2 (2 << 0) #define CMDAT_RESP_R3 (3 << 0) #define MMC_RESTO 0x0014 /* 7 bit */ #define MMC_RDTO 0x0018 /* 16 bit */ #define MMC_BLKLEN 0x001c /* 10 bit */ #define MMC_NOB 0x0020 /* 16 bit */ #define MMC_PRTBUF 0x0024 #define BUF_PART_FULL (1 << 0) #define MMC_I_MASK 0x0028 /*PXA27x MMC interrupts*/ #define SDIO_SUSPEND_ACK (1 << 12) #define SDIO_INT (1 << 11) #define RD_STALLED (1 << 10) #define RES_ERR (1 << 9) #define DAT_ERR (1 << 8) #define TINT (1 << 7) /*PXA2xx MMC interrupts*/ #define TXFIFO_WR_REQ (1 << 6) #define RXFIFO_RD_REQ (1 << 5) #define CLK_IS_OFF (1 << 4) #define STOP_CMD (1 << 3) #define END_CMD_RES (1 << 2) #define PRG_DONE (1 << 1) #define DATA_TRAN_DONE (1 << 0) #ifdef CONFIG_PXA27x #define MMC_I_MASK_ALL 0x00001fff #else #define MMC_I_MASK_ALL 0x0000007f #endif #define MMC_I_REG 0x002c /* same as MMC_I_MASK */ #define MMC_CMD 0x0030 #define MMC_ARGH 0x0034 /* 16 bit */ #define MMC_ARGL 0x0038 /* 16 bit */ #define MMC_RES 0x003c /* 16 bit */ #define MMC_RXFIFO 0x0040 /* 8 bit */ #define MMC_TXFIFO 0x0044 /* 8 bit */ /* * The base MMC clock rate */ #ifdef CONFIG_PXA27x #define CLOCKRATE_MIN 304688 #define CLOCKRATE_MAX 19500000 #else #define CLOCKRATE_MIN 312500 #define CLOCKRATE_MAX 20000000 #endif #define CLOCKRATE CLOCKRATE_MAX
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_CLOUD_EXTERNAL_DATA_MANAGER_H_ #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_CLOUD_EXTERNAL_DATA_MANAGER_H_ #include <string> #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "components/policy/core/common/cloud/cloud_external_data_manager.h" #include "components/policy/core/common/external_data_fetcher.h" #include "testing/gmock/include/gmock/gmock.h" namespace net { class URLRequestContextGetter; } namespace policy { class ExternalDataFetcher; class MockCloudExternalDataManager : public CloudExternalDataManager { public: MockCloudExternalDataManager(); virtual ~MockCloudExternalDataManager(); MOCK_METHOD0(OnPolicyStoreLoaded, void(void)); MOCK_METHOD1(Connect, void(scoped_refptr<net::URLRequestContextGetter>)); MOCK_METHOD0(Disconnect, void(void)); MOCK_METHOD2(Fetch, void(const std::string&, const ExternalDataFetcher::FetchCallback&)); scoped_ptr<ExternalDataFetcher> CreateExternalDataFetcher( const std::string& policy); private: DISALLOW_COPY_AND_ASSIGN(MockCloudExternalDataManager); }; } // namespace policy #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_CLOUD_EXTERNAL_DATA_MANAGER_H_
/****************************************************************************** * * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, 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. * * The full GNU General Public License is included in this distribution in the * file called LICENSE. * * Contact Information: * wlanfae <wlanfae@realtek.com> * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, * Hsinchu 300, Taiwan. * * Created on 2010/ 5/18, 1:41 * * Larry Finger <Larry.Finger@lwfinger.net> * *****************************************************************************/ #ifndef __RTL8723E_TABLE__H_ #define __RTL8723E_TABLE__H_ #include <linux/types.h> #define RTL8723E_PHY_REG_1TARRAY_LENGTH 372 extern u32 RTL8723EPHY_REG_1TARRAY[RTL8723E_PHY_REG_1TARRAY_LENGTH]; #define RTL8723E_PHY_REG_ARRAY_PGLENGTH 336 extern u32 RTL8723EPHY_REG_ARRAY_PG[RTL8723E_PHY_REG_ARRAY_PGLENGTH]; #define RTL8723ERADIOA_1TARRAYLENGTH 282 extern u32 RTL8723E_RADIOA_1TARRAY[RTL8723ERADIOA_1TARRAYLENGTH]; #define RTL8723E_RADIOB_1TARRAYLENGTH 1 extern u32 RTL8723E_RADIOB_1TARRAY[RTL8723E_RADIOB_1TARRAYLENGTH]; #define RTL8723E_MACARRAYLENGTH 172 extern u32 RTL8723EMAC_ARRAY[RTL8723E_MACARRAYLENGTH]; #define RTL8723E_AGCTAB_1TARRAYLENGTH 320 extern u32 RTL8723EAGCTAB_1TARRAY[RTL8723E_AGCTAB_1TARRAYLENGTH]; #endif
/* MN10300 Watchdog timer * * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * - Derived from arch/i386/kernel/nmi.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public Licence * as published by the Free Software Foundation; either version * 2 of the Licence, or (at your option) any later version. */ #include <linux/module.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/kernel_stat.h> #include <linux/nmi.h> #include <asm/processor.h> #include <linux/atomic.h> #include <asm/intctl-regs.h> #include <asm/rtc-regs.h> #include <asm/div64.h> #include <asm/smp.h> #include <asm/gdb-stub.h> #include <proc/clock.h> static DEFINE_SPINLOCK(watchdog_print_lock); static unsigned int watchdog; static unsigned int watchdog_hz = 1; unsigned int watchdog_alert_counter[NR_CPUS]; EXPORT_SYMBOL(arch_touch_nmi_watchdog); /* * the best way to detect whether a CPU has a 'hard lockup' problem * is to check its timer makes IRQ counts. If they are not * changing then that CPU has some problem. * * since NMIs dont listen to _any_ locks, we have to be extremely * careful not to rely on unsafe variables. The printk might lock * up though, so we have to break up any console locks first ... * [when there will be more tty-related locks, break them up * here too!] */ static unsigned int last_irq_sums[NR_CPUS]; int __init check_watchdog(void) { irq_cpustat_t tmp[1]; printk(KERN_INFO "Testing Watchdog... "); memcpy(tmp, irq_stat, sizeof(tmp)); local_irq_enable(); mdelay((10 * 1000) / watchdog_hz); /* wait 10 ticks */ local_irq_disable(); if (nmi_count(0) - tmp[0].__nmi_count <= 5) { printk(KERN_WARNING "CPU#%d: Watchdog appears to be stuck!\n", 0); return -1; } printk(KERN_INFO "OK.\n"); /* now that we know it works we can reduce NMI frequency to something * more reasonable; makes a difference in some configs */ watchdog_hz = 1; return 0; } static int __init setup_watchdog(char *str) { unsigned tmp; int opt; u8 ctr; get_option(&str, &opt); if (opt != 1) return 0; watchdog = opt; if (watchdog) { set_intr_stub(EXCEP_WDT, watchdog_handler); ctr = WDCTR_WDCK_65536th; WDCTR = WDCTR_WDRST | ctr; WDCTR = ctr; tmp = WDCTR; tmp = __muldiv64u(1 << (16 + ctr * 2), 1000000, MN10300_WDCLK); tmp = 1000000000 / tmp; watchdog_hz = (tmp + 500) / 1000; } return 1; } __setup("watchdog=", setup_watchdog); void __init watchdog_go(void) { u8 wdt; if (watchdog) { printk(KERN_INFO "Watchdog: running at %uHz\n", watchdog_hz); wdt = WDCTR & ~WDCTR_WDCNE; WDCTR = wdt | WDCTR_WDRST; wdt = WDCTR; WDCTR = wdt | WDCTR_WDCNE; wdt = WDCTR; check_watchdog(); } } #ifdef CONFIG_SMP static void watchdog_dump_register(void *dummy) { printk(KERN_ERR "--- Register Dump (CPU%d) ---\n", CPUID); show_registers(current_frame()); } #endif asmlinkage void watchdog_interrupt(struct pt_regs *regs, enum exception_code excep) { /* * Since current-> is always on the stack, and we always switch * the stack NMI-atomically, it's safe to use smp_processor_id(). */ int sum, cpu; int irq = NMIIRQ; u8 wdt, tmp; wdt = WDCTR & ~WDCTR_WDCNE; WDCTR = wdt; tmp = WDCTR; NMICR = NMICR_WDIF; nmi_count(smp_processor_id())++; kstat_incr_irq_this_cpu(irq); for_each_online_cpu(cpu) { sum = irq_stat[cpu].__irq_count; if ((last_irq_sums[cpu] == sum) #if defined(CONFIG_GDBSTUB) && defined(CONFIG_SMP) && !(CHK_GDBSTUB_BUSY() || atomic_read(&cpu_doing_single_step)) #endif ) { /* * Ayiee, looks like this CPU is stuck ... * wait a few IRQs (5 seconds) before doing the oops ... */ watchdog_alert_counter[cpu]++; if (watchdog_alert_counter[cpu] == 5 * watchdog_hz) { spin_lock(&watchdog_print_lock); /* * We are in trouble anyway, lets at least try * to get a message out. */ bust_spinlocks(1); printk(KERN_ERR "NMI Watchdog detected LOCKUP on CPU%d," " pc %08lx, registers:\n", cpu, regs->pc); #ifdef CONFIG_SMP printk(KERN_ERR "--- Register Dump (CPU%d) ---\n", CPUID); #endif show_registers(regs); #ifdef CONFIG_SMP smp_nmi_call_function(watchdog_dump_register, NULL, 1); #endif printk(KERN_NOTICE "console shuts up ...\n"); console_silent(); spin_unlock(&watchdog_print_lock); bust_spinlocks(0); #ifdef CONFIG_GDBSTUB if (CHK_GDBSTUB_BUSY_AND_ACTIVE()) gdbstub_exception(regs, excep); else gdbstub_intercept(regs, excep); #endif do_exit(SIGSEGV); } } else { last_irq_sums[cpu] = sum; watchdog_alert_counter[cpu] = 0; } } WDCTR = wdt | WDCTR_WDRST; tmp = WDCTR; WDCTR = wdt | WDCTR_WDCNE; tmp = WDCTR; }
/* -*- linux-c -*- * sysctl_net_core.c: sysctl interface to net core subsystem. * * Begun April 1, 1996, Mike Shaver. * Added /proc/sys/net/core directory entry (empty =) ). [MS] */ #include <linux/mm.h> #include <linux/sysctl.h> #include <linux/module.h> #include <linux/socket.h> #include <linux/netdevice.h> #include <linux/ratelimit.h> #include <linux/vmalloc.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/kmemleak.h> #include <net/ip.h> #include <net/sock.h> #include <net/net_ratelimit.h> static int zero = 0; static int ushort_max = USHRT_MAX; static int one = 1; #ifdef CONFIG_RPS static int rps_sock_flow_sysctl(ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { unsigned int orig_size, size; int ret, i; ctl_table tmp = { .data = &size, .maxlen = sizeof(size), .mode = table->mode }; struct rps_sock_flow_table *orig_sock_table, *sock_table; static DEFINE_MUTEX(sock_flow_mutex); mutex_lock(&sock_flow_mutex); orig_sock_table = rcu_dereference_protected(rps_sock_flow_table, lockdep_is_held(&sock_flow_mutex)); size = orig_size = orig_sock_table ? orig_sock_table->mask + 1 : 0; ret = proc_dointvec(&tmp, write, buffer, lenp, ppos); if (write) { if (size) { if (size > 1<<30) { /* Enforce limit to prevent overflow */ mutex_unlock(&sock_flow_mutex); return -EINVAL; } size = roundup_pow_of_two(size); if (size != orig_size) { sock_table = vmalloc(RPS_SOCK_FLOW_TABLE_SIZE(size)); if (!sock_table) { mutex_unlock(&sock_flow_mutex); return -ENOMEM; } sock_table->mask = size - 1; } else sock_table = orig_sock_table; for (i = 0; i < size; i++) sock_table->ents[i] = RPS_NO_CPU; } else sock_table = NULL; if (sock_table != orig_sock_table) { rcu_assign_pointer(rps_sock_flow_table, sock_table); if (sock_table) static_key_slow_inc(&rps_needed); if (orig_sock_table) { static_key_slow_dec(&rps_needed); synchronize_rcu(); vfree(orig_sock_table); } } } mutex_unlock(&sock_flow_mutex); return ret; } #endif /* CONFIG_RPS */ static struct ctl_table net_core_table[] = { #ifdef CONFIG_NET { .procname = "wmem_max", .data = &sysctl_wmem_max, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &one, }, { .procname = "rmem_max", .data = &sysctl_rmem_max, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &one, }, { .procname = "wmem_default", .data = &sysctl_wmem_default, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &one, }, { .procname = "rmem_default", .data = &sysctl_rmem_default, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &one, }, { .procname = "dev_weight", .data = &weight_p, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, { .procname = "netdev_max_backlog", .data = &netdev_max_backlog, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, #ifdef CONFIG_BPF_JIT { .procname = "bpf_jit_enable", .data = &bpf_jit_enable, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, #endif { .procname = "netdev_tstamp_prequeue", .data = &netdev_tstamp_prequeue, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, { .procname = "message_cost", .data = &net_ratelimit_state.interval, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "message_burst", .data = &net_ratelimit_state.burst, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "optmem_max", .data = &sysctl_optmem_max, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, #ifdef CONFIG_RPS { .procname = "rps_sock_flow_entries", .maxlen = sizeof(int), .mode = 0644, .proc_handler = rps_sock_flow_sysctl }, #endif #endif /* CONFIG_NET */ { .procname = "netdev_budget", .data = &netdev_budget, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, { .procname = "warnings", .data = &net_msg_warn, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, { } }; static struct ctl_table netns_core_table[] = { { .procname = "somaxconn", .data = &init_net.core.sysctl_somaxconn, .maxlen = sizeof(int), .mode = 0644, .extra1 = &zero, .extra2 = &ushort_max, .proc_handler = proc_dointvec_minmax }, { } }; __net_initdata struct ctl_path net_core_path[] = { { .procname = "net", }, { .procname = "core", }, { }, }; static __net_init int sysctl_core_net_init(struct net *net) { struct ctl_table *tbl; net->core.sysctl_somaxconn = SOMAXCONN; tbl = netns_core_table; if (!net_eq(net, &init_net)) { tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL); if (tbl == NULL) goto err_dup; tbl[0].data = &net->core.sysctl_somaxconn; } net->core.sysctl_hdr = register_net_sysctl_table(net, net_core_path, tbl); if (net->core.sysctl_hdr == NULL) goto err_reg; return 0; err_reg: if (tbl != netns_core_table) kfree(tbl); err_dup: return -ENOMEM; } static __net_exit void sysctl_core_net_exit(struct net *net) { struct ctl_table *tbl; tbl = net->core.sysctl_hdr->ctl_table_arg; unregister_net_sysctl_table(net->core.sysctl_hdr); BUG_ON(tbl == netns_core_table); kfree(tbl); } static __net_initdata struct pernet_operations sysctl_core_ops = { .init = sysctl_core_net_init, .exit = sysctl_core_net_exit, }; static __init int sysctl_core_init(void) { static struct ctl_table empty[1]; kmemleak_not_leak(register_sysctl_paths(net_core_path, empty)); register_net_sysctl_rotable(net_core_path, net_core_table); return register_pernet_subsys(&sysctl_core_ops); } fs_initcall(sysctl_core_init);
/** * @file fairqueue_test.c * @author Ambroz Bizjak <ambrop7@gmail.com> * * @section LICENSE * * 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 author 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 AUTHOR 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 <stdio.h> #include <stddef.h> #include <misc/debug.h> #include <system/BReactor.h> #include <base/BLog.h> #include <system/BTime.h> #include <flow/PacketPassFairQueue.h> #include <examples/FastPacketSource.h> #include <examples/TimerPacketSink.h> #define OUTPUT_INTERVAL 0 #define REMOVE_INTERVAL 1 #define NUM_INPUTS 3 BReactor reactor; TimerPacketSink sink; PacketPassFairQueue fq; PacketPassFairQueueFlow flows[NUM_INPUTS]; FastPacketSource sources[NUM_INPUTS]; char *data[] = {"0 data", "1 datadatadata", "2 datadatadatadatadata"}; BTimer timer; int current_cancel; static void init_input (int i) { PacketPassFairQueueFlow_Init(&flows[i], &fq); FastPacketSource_Init(&sources[i], PacketPassFairQueueFlow_GetInput(&flows[i]), (uint8_t *)data[i], strlen(data[i]), BReactor_PendingGroup(&reactor)); } static void free_input (int i) { FastPacketSource_Free(&sources[i]); PacketPassFairQueueFlow_Free(&flows[i]); } static void reset_input (void) { PacketPassFairQueueFlow_AssertFree(&flows[current_cancel]); printf("removing %d\n", current_cancel); // remove flow free_input(current_cancel); // init flow init_input(current_cancel); // increment cancel current_cancel = (current_cancel + 1) % NUM_INPUTS; // reset timer BReactor_SetTimer(&reactor, &timer); } static void flow_handler_busy (void *user) { PacketPassFairQueueFlow_AssertFree(&flows[current_cancel]); reset_input(); } static void timer_handler (void *user) { // if flow is busy, request cancel and wait for it if (PacketPassFairQueueFlow_IsBusy(&flows[current_cancel])) { printf("cancelling %d\n", current_cancel); PacketPassFairQueueFlow_RequestCancel(&flows[current_cancel]); PacketPassFairQueueFlow_SetBusyHandler(&flows[current_cancel], flow_handler_busy, NULL); return; } reset_input(); } int main () { // initialize logging BLog_InitStdout(); // init time BTime_Init(); // initialize reactor if (!BReactor_Init(&reactor)) { DEBUG("BReactor_Init failed"); return 1; } // initialize sink TimerPacketSink_Init(&sink, &reactor, 500, OUTPUT_INTERVAL); // initialize queue if (!PacketPassFairQueue_Init(&fq, TimerPacketSink_GetInput(&sink), BReactor_PendingGroup(&reactor), 1, 1)) { DEBUG("PacketPassFairQueue_Init failed"); return 1; } // initialize inputs for (int i = 0; i < NUM_INPUTS; i++) { init_input(i); } // init cancel timer BTimer_Init(&timer, REMOVE_INTERVAL, timer_handler, NULL); BReactor_SetTimer(&reactor, &timer); // init cancel counter current_cancel = 0; // run reactor int ret = BReactor_Exec(&reactor); BReactor_Free(&reactor); return ret; }
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO //// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //// PARTICULAR PURPOSE. //// //// Copyright (c) Microsoft Corporation. All rights reserved #pragma once #include <CritSec.h> #include <linklist.h> #include <StspDefs.h> namespace Microsoft { namespace Samples { namespace SimpleCommunication { class CMediaSource; namespace Network { interface IBufferPacket; } class CMediaStream : public IMFMediaStream, public IMFQualityAdvise2, public IMFGetService { public: static HRESULT CreateInstance(StspStreamDescription *pStreamDescription, Network::IBufferPacket *pAttributesBuffer, CMediaSource *pSource, CMediaStream **ppStream); // IUnknown IFACEMETHOD (QueryInterface) (REFIID iid, void **ppv); IFACEMETHOD_ (ULONG, AddRef) (); IFACEMETHOD_ (ULONG, Release) (); // IMFMediaEventGenerator IFACEMETHOD (BeginGetEvent) (IMFAsyncCallback *pCallback,IUnknown *punkState); IFACEMETHOD (EndGetEvent) (IMFAsyncResult *pResult, IMFMediaEvent **ppEvent); IFACEMETHOD (GetEvent) (DWORD dwFlags, IMFMediaEvent **ppEvent); IFACEMETHOD (QueueEvent) (MediaEventType met, REFGUID guidExtendedType, HRESULT hrStatus, const PROPVARIANT *pvValue); // IMFMediaStream IFACEMETHOD (GetMediaSource) (IMFMediaSource **ppMediaSource); IFACEMETHOD (GetStreamDescriptor) (IMFStreamDescriptor **ppStreamDescriptor); IFACEMETHOD (RequestSample) (IUnknown *pToken); // IMFQualityAdvise IFACEMETHOD (SetDropMode ) (_In_ MF_QUALITY_DROP_MODE eDropMode); IFACEMETHOD (SetQualityLevel ) ( _In_ MF_QUALITY_LEVEL eQualityLevel); IFACEMETHOD (GetDropMode ) (_Out_ MF_QUALITY_DROP_MODE *peDropMode); IFACEMETHOD (GetQualityLevel )(_Out_ MF_QUALITY_LEVEL *peQualityLevel ); IFACEMETHOD (DropTime) (_In_ LONGLONG hnsAmountToDrop); // IMFQualityAdvise2 IFACEMETHOD (NotifyQualityEvent) (_In_opt_ IMFMediaEvent *pEvent, _Out_ DWORD *pdwFlags); // IMFGetService IFACEMETHOD (GetService) (_In_ REFGUID guidService, _In_ REFIID riid, _Out_ LPVOID *ppvObject); // Other public methods HRESULT Start(); HRESULT Stop(); HRESULT SetRate(float flRate); HRESULT Flush(); HRESULT Shutdown(); void ProcessSample(StspSampleHeader *pSampleHeader, IMFSample *pSample); void ProcessFormatChange(IMFMediaType *pMediaType); HRESULT SetActive(bool fActive); bool IsActive() const {return _fActive;} SourceState GetState() const {return _eSourceState;} DWORD GetId() const {return _dwId;} protected: CMediaStream(CMediaSource *pSource); ~CMediaStream(void); private: class CSourceLock; private: void Initialize(StspStreamDescription *pStreamDescription, Network::IBufferPacket *pAttributesBuffer); void DeliverSamples(); void SetSampleAttributes(StspSampleHeader *pSampleHeader, IMFSample *pSample); void HandleError(HRESULT hErrorCode); HRESULT CheckShutdown() const { if (_eSourceState == SourceState_Shutdown) { return MF_E_SHUTDOWN; } else { return S_OK; } } bool ShouldDropSample(IMFSample *pSample); void CleanSampleQueue(); void ResetDropTime(); private: long _cRef; // reference count SourceState _eSourceState; // Flag to indicate if Shutdown() method was called. ComPtr<CMediaSource> _spSource; // Media source ComPtr<IMFMediaEventQueue> _spEventQueue; // Event queue ComPtr<IMFStreamDescriptor> _spStreamDescriptor; // Stream descriptor ComPtrList<IUnknown> _samples; ComPtrList<IUnknown, true> _tokens; DWORD _dwId; bool _fActive; bool _fVideo; float _flRate; MF_QUALITY_DROP_MODE _eDropMode; bool _fDiscontinuity; bool _fDropTime; bool _fInitDropTime; bool _fWaitingForCleanPoint; LONGLONG _hnsStartDroppingAt; LONGLONG _hnsAmountToDrop; }; }}} // namespace Microsoft::Samples::SimpleCommunication
/* * Copyright (C) 2007, 2013 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: * * 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 Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 SQLTransaction_h #define SQLTransaction_h #if ENABLE(SQL_DATABASE) #include "AbstractSQLTransaction.h" #include "SQLCallbackWrapper.h" #include "SQLStatement.h" #include "SQLTransactionStateMachine.h" #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> namespace WebCore { class AbstractSQLTransactionBackend; class Database; class SQLError; class SQLStatementCallback; class SQLStatementErrorCallback; class SQLTransactionCallback; class SQLTransactionErrorCallback; class SQLValue; class VoidCallback; class SQLTransaction : public SQLTransactionStateMachine<SQLTransaction>, public AbstractSQLTransaction { public: static PassRefPtr<SQLTransaction> create(Database*, PassRefPtr<SQLTransactionCallback>, PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionErrorCallback>, bool readOnly); void performPendingCallback(); void executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments, PassRefPtr<SQLStatementCallback>, PassRefPtr<SQLStatementErrorCallback>, ExceptionCode&); Database* database() { return m_database.get(); } private: SQLTransaction(Database*, PassRefPtr<SQLTransactionCallback>, PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionErrorCallback>, bool readOnly); void clearCallbackWrappers(); // APIs called from the backend published via AbstractSQLTransaction: virtual void requestTransitToState(SQLTransactionState) OVERRIDE; virtual bool hasCallback() const OVERRIDE; virtual bool hasSuccessCallback() const OVERRIDE; virtual bool hasErrorCallback() const OVERRIDE; virtual void setBackend(AbstractSQLTransactionBackend*) OVERRIDE; // State Machine functions: virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE; bool computeNextStateAndCleanupIfNeeded(); // State functions: SQLTransactionState deliverTransactionCallback(); SQLTransactionState deliverTransactionErrorCallback(); SQLTransactionState deliverStatementCallback(); SQLTransactionState deliverQuotaIncreaseCallback(); SQLTransactionState deliverSuccessCallback(); SQLTransactionState unreachableState(); SQLTransactionState sendToBackendState(); SQLTransactionState nextStateForTransactionError(); RefPtr<Database> m_database; RefPtr<AbstractSQLTransactionBackend> m_backend; SQLCallbackWrapper<SQLTransactionCallback> m_callbackWrapper; SQLCallbackWrapper<VoidCallback> m_successCallbackWrapper; SQLCallbackWrapper<SQLTransactionErrorCallback> m_errorCallbackWrapper; bool m_executeSqlAllowed; RefPtr<SQLError> m_transactionError; bool m_readOnly; }; } // namespace WebCore #endif #endif // SQLTransaction_h
/* * rwlock3_t.c * * * -------------------------------------------------------------------------- * * Pthreads-win32 - POSIX Threads Library for Win32 * Copyright(C) 1998 John E. Bossom * Copyright(C) 1999,2005 Pthreads-win32 contributors * * Contact Email: rpj@callisto.canberra.edu.au * * The current list of contributors is contained * in the file CONTRIBUTORS included with the source * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * -------------------------------------------------------------------------- * * Declare a static rwlock object, timed-wrlock it, trywrlock it, * and then unlock it again. * * Depends on API functions: * pthread_rwlock_timedwrlock() * pthread_rwlock_trywrlock() * pthread_rwlock_unlock() */ #include "test.h" #include <sys/timeb.h> pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; static int washere = 0; void * func(void * arg) { assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY); washere = 1; return 0; } int main() { pthread_t t; struct timespec abstime = { 0, 0 }; PTW32_STRUCT_TIMEB currSysTime; const DWORD NANOSEC_PER_MILLISEC = 1000000; PTW32_FTIME(&currSysTime); abstime.tv_sec = (long)currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; abstime.tv_sec += 1; assert(pthread_rwlock_timedwrlock(&rwlock1, &abstime) == 0); assert(pthread_create(&t, NULL, func, NULL) == 0); Sleep(2000); assert(pthread_rwlock_unlock(&rwlock1) == 0); assert(washere == 1); return 0; }
/////////////////////////////////////////////////////////////////////////////// // Name: wx/choicebk.h // Purpose: wxChoicebook: wxChoice and wxNotebook combination // Author: Vadim Zeitlin // Modified by: Wlodzimierz ABX Skiba from wx/listbook.h // Created: 15.09.04 // Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_CHOICEBOOK_H_ #define _WX_CHOICEBOOK_H_ #include "wx/defs.h" #if wxUSE_CHOICEBOOK #include "wx/bookctrl.h" #include "wx/choice.h" #include "wx/containr.h" class WXDLLIMPEXP_FWD_CORE wxChoice; wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); // wxChoicebook flags #define wxCHB_DEFAULT wxBK_DEFAULT #define wxCHB_TOP wxBK_TOP #define wxCHB_BOTTOM wxBK_BOTTOM #define wxCHB_LEFT wxBK_LEFT #define wxCHB_RIGHT wxBK_RIGHT #define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK // ---------------------------------------------------------------------------- // wxChoicebook // ---------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxChoicebook : public wxNavigationEnabled<wxBookCtrlBase> { public: wxChoicebook() { } wxChoicebook(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxEmptyString) { (void)Create(parent, id, pos, size, style, name); } // quasi ctor bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxEmptyString); virtual bool SetPageText(size_t n, const wxString& strText); virtual wxString GetPageText(size_t n) const; virtual int GetPageImage(size_t n) const; virtual bool SetPageImage(size_t n, int imageId); virtual bool InsertPage(size_t n, wxWindow *page, const wxString& text, bool bSelect = false, int imageId = NO_IMAGE); virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); } virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } virtual void SetImageList(wxImageList *imageList); virtual bool DeleteAllPages(); // returns the choice control wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; } // Override this to return true because the part of parent window // background between our controlling wxChoice and the page area should // show through. virtual bool HasTransparentBackground() { return true; } protected: virtual void DoSetWindowVariant(wxWindowVariant variant); virtual wxWindow *DoRemovePage(size_t page); void UpdateSelectedPage(size_t newsel) { m_selection = static_cast<int>(newsel); GetChoiceCtrl()->Select(m_selection); } wxBookCtrlEvent* CreatePageChangingEvent() const; void MakeChangedEvent(wxBookCtrlEvent &event); // event handlers void OnChoiceSelected(wxCommandEvent& event); private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook) }; // ---------------------------------------------------------------------------- // choicebook event class and related stuff // ---------------------------------------------------------------------------- // wxChoicebookEvent is obsolete and defined for compatibility only #define wxChoicebookEvent wxBookCtrlEvent typedef wxBookCtrlEventFunction wxChoicebookEventFunction; #define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func) #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \ wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn)) #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \ wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) // old wxEVT_COMMAND_* constants #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING #endif // wxUSE_CHOICEBOOK #endif // _WX_CHOICEBOOK_H_
/* * datastream.h * */ struct buffer_head *befs_read_datastream(struct super_block *sb, const befs_data_stream *ds, befs_off_t pos, uint *off); int befs_fblock2brun(struct super_block *sb, const befs_data_stream *data, befs_blocknr_t fblock, befs_block_run *run); size_t befs_read_lsymlink(struct super_block *sb, const befs_data_stream *data, void *buff, befs_off_t len); befs_blocknr_t befs_count_blocks(struct super_block *sb, const befs_data_stream *ds); extern const befs_inode_addr BAD_IADDR;
#ifndef __LIS3LV02D_H_ #define __LIS3LV02D_H_ struct lis3lv02d_platform_data { /* please note: the 'click' feature is only supported for * LIS[32]02DL variants of the chip and will be ignored for * others */ #define LIS3_CLICK_SINGLE_X (1 << 0) #define LIS3_CLICK_DOUBLE_X (1 << 1) #define LIS3_CLICK_SINGLE_Y (1 << 2) #define LIS3_CLICK_DOUBLE_Y (1 << 3) #define LIS3_CLICK_SINGLE_Z (1 << 4) #define LIS3_CLICK_DOUBLE_Z (1 << 5) unsigned char click_flags; unsigned char click_thresh_x; unsigned char click_thresh_y; unsigned char click_thresh_z; unsigned char click_time_limit; unsigned char click_latency; unsigned char click_window; #define LIS3_IRQ1_DISABLE (0 << 0) #define LIS3_IRQ1_FF_WU_1 (1 << 0) #define LIS3_IRQ1_FF_WU_2 (2 << 0) #define LIS3_IRQ1_FF_WU_12 (3 << 0) #define LIS3_IRQ1_DATA_READY (4 << 0) #define LIS3_IRQ1_CLICK (7 << 0) #define LIS3_IRQ1_MASK (7 << 0) #define LIS3_IRQ2_DISABLE (0 << 3) #define LIS3_IRQ2_FF_WU_1 (1 << 3) #define LIS3_IRQ2_FF_WU_2 (2 << 3) #define LIS3_IRQ2_FF_WU_12 (3 << 3) #define LIS3_IRQ2_DATA_READY (4 << 3) #define LIS3_IRQ2_CLICK (7 << 3) #define LIS3_IRQ2_MASK (7 << 3) #define LIS3_IRQ_OPEN_DRAIN (1 << 6) #define LIS3_IRQ_ACTIVE_LOW (1 << 7) unsigned char irq_cfg; #define LIS3_WAKEUP_X_LO (1 << 0) #define LIS3_WAKEUP_X_HI (1 << 1) #define LIS3_WAKEUP_Y_LO (1 << 2) #define LIS3_WAKEUP_Y_HI (1 << 3) #define LIS3_WAKEUP_Z_LO (1 << 4) #define LIS3_WAKEUP_Z_HI (1 << 5) unsigned char wakeup_flags; unsigned char wakeup_thresh; unsigned char wakeup_flags2; unsigned char wakeup_thresh2; #define LIS3_HIPASS_CUTFF_8HZ 0 #define LIS3_HIPASS_CUTFF_4HZ 1 #define LIS3_HIPASS_CUTFF_2HZ 2 #define LIS3_HIPASS_CUTFF_1HZ 3 #define LIS3_HIPASS1_DISABLE (1 << 2) #define LIS3_HIPASS2_DISABLE (1 << 3) unsigned char hipass_ctrl; #define LIS3_NO_MAP 0 #define LIS3_DEV_X 1 #define LIS3_DEV_Y 2 #define LIS3_DEV_Z 3 #define LIS3_INV_DEV_X -1 #define LIS3_INV_DEV_Y -2 #define LIS3_INV_DEV_Z -3 s8 axis_x; s8 axis_y; s8 axis_z; int (*setup_resources)(void); int (*release_resources)(void); /* Limits for selftest are specified in chip data sheet */ s16 st_min_limits[3]; /* min pass limit x, y, z */ s16 st_max_limits[3]; /* max pass limit x, y, z */ int irq2; }; #endif /* __LIS3LV02D_H_ */
/* mbed Microcontroller Library * Copyright (c) 2006-2012 ARM Limited * * 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 FIR_F32_H #define FIR_F32_H #include <stdint.h> #include "arm_math.h" namespace dsp { template<uint16_t num_taps, uint32_t block_size=32> class FIR_f32 { public: FIR_f32(const float32_t *coeff) { arm_fir_init_f32(&fir, num_taps, (float32_t*)coeff, fir_state, block_size); } void process(float32_t *sgn_in, float32_t *sgn_out) { arm_fir_f32(&fir, sgn_in, sgn_out, block_size); } void reset(void) { memset(fir_state, 0, sizeof(fir_state)); } private: arm_fir_instance_f32 fir; float32_t fir_state[block_size + num_taps - 1]; }; } #endif
#ifndef __LINUX_RTNETLINK_H #define __LINUX_RTNETLINK_H #include <linux/mutex.h> #include <linux/netdevice.h> #include <linux/wait.h> #include <uapi/linux/rtnetlink.h> extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid); extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, struct nlmsghdr *nlh, gfp_t flags); extern void rtnl_set_sk_err(struct net *net, u32 group, int error); extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id, long expires, u32 error); void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change, gfp_t flags); struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev, unsigned change, gfp_t flags); void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev, gfp_t flags); /* RTNL is used as a global lock for all changes to network configuration */ extern void rtnl_lock(void); extern void rtnl_unlock(void); extern int rtnl_trylock(void); extern int rtnl_is_locked(void); extern wait_queue_head_t netdev_unregistering_wq; extern struct mutex net_mutex; #ifdef CONFIG_PROVE_LOCKING extern bool lockdep_rtnl_is_held(void); #else static inline bool lockdep_rtnl_is_held(void) { return true; } #endif /* #ifdef CONFIG_PROVE_LOCKING */ /** * rcu_dereference_rtnl - rcu_dereference with debug checking * @p: The pointer to read, prior to dereferencing * * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference() */ #define rcu_dereference_rtnl(p) \ rcu_dereference_check(p, lockdep_rtnl_is_held()) /** * rcu_dereference_bh_rtnl - rcu_dereference_bh with debug checking * @p: The pointer to read, prior to dereference * * Do an rcu_dereference_bh(p), but check caller either holds rcu_read_lock_bh() * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference_bh() */ #define rcu_dereference_bh_rtnl(p) \ rcu_dereference_bh_check(p, lockdep_rtnl_is_held()) /** * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL * @p: The pointer to read, prior to dereferencing * * Return the value of the specified RCU-protected pointer, but omit * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because * caller holds RTNL. */ #define rtnl_dereference(p) \ rcu_dereference_protected(p, lockdep_rtnl_is_held()) static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev) { return rtnl_dereference(dev->ingress_queue); } struct netdev_queue *dev_ingress_queue_create(struct net_device *dev); #ifdef CONFIG_NET_INGRESS void net_inc_ingress_queue(void); void net_dec_ingress_queue(void); #endif #ifdef CONFIG_NET_EGRESS void net_inc_egress_queue(void); void net_dec_egress_queue(void); #endif extern void rtnetlink_init(void); extern void __rtnl_unlock(void); #define ASSERT_RTNL() do { \ if (unlikely(!rtnl_is_locked())) { \ printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \ __FILE__, __LINE__); \ dump_stack(); \ } \ } while(0) extern int ndo_dflt_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, struct net_device *dev, struct net_device *filter_dev, int idx); extern int ndo_dflt_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 flags); extern int ndo_dflt_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid); extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, struct net_device *dev, u16 mode, u32 flags, u32 mask, int nlflags, u32 filter_mask, int (*vlan_fill)(struct sk_buff *skb, struct net_device *dev, u32 filter_mask)); #endif /* __LINUX_RTNETLINK_H */
/* * linux/arch/arm/mach-nspire/nspire.c * * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, as * published by the Free Software Foundation. * */ #include <linux/init.h> #include <linux/of_irq.h> #include <linux/of_address.h> #include <linux/of_platform.h> #include <linux/irqchip.h> #include <linux/irqchip/arm-vic.h> #include <linux/clkdev.h> #include <linux/amba/bus.h> #include <linux/amba/clcd.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> #include <asm/mach/map.h> #include "mmio.h" #include "clcd.h" static const char *const nspire_dt_match[] __initconst = { "ti,nspire", "ti,nspire-cx", "ti,nspire-tp", "ti,nspire-clp", NULL, }; static struct clcd_board nspire_clcd_data = { .name = "LCD", .caps = CLCD_CAP_5551 | CLCD_CAP_565, .check = clcdfb_check, .decode = clcdfb_decode, .setup = nspire_clcd_setup, .mmap = nspire_clcd_mmap, .remove = nspire_clcd_remove, }; static struct of_dev_auxdata nspire_auxdata[] __initdata = { OF_DEV_AUXDATA("arm,pl111", NSPIRE_LCD_PHYS_BASE, NULL, &nspire_clcd_data), { } }; static void __init nspire_init(void) { of_platform_default_populate(NULL, nspire_auxdata, NULL); } static void nspire_restart(enum reboot_mode mode, const char *cmd) { void __iomem *base = ioremap(NSPIRE_MISC_PHYS_BASE, SZ_4K); if (!base) return; writel(2, base + NSPIRE_MISC_HWRESET); } DT_MACHINE_START(NSPIRE, "TI-NSPIRE") .dt_compat = nspire_dt_match, .init_machine = nspire_init, .restart = nspire_restart, MACHINE_END
/* $Id: sph_jh.h 216 2010-06-08 09:46:57Z tp $ */ /** * JH interface. JH is a family of functions which differ by * their output size; this implementation defines JH for output * sizes 224, 256, 384 and 512 bits. * * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR * * 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. * * ===========================(LICENSE END)============================= * * @file sph_jh.h * @author Thomas Pornin <thomas.pornin@cryptolog.com> */ #ifndef SPH_JH_H__ #define SPH_JH_H__ #ifdef __cplusplus extern "C"{ #endif #include <stddef.h> #include "sph_types.h" #define QSTATIC static /** * Output size (in bits) for JH-512. */ #define SPH_SIZE_jh512 512 /** * This structure is a context for JH computations: it contains the * intermediate values and some data from the last entered block. Once * a JH computation has been performed, the context can be reused for * another computation. * * The contents of this structure are private. A running JH computation * can be cloned by copying the context (e.g. with a simple * <code>memcpy()</code>). */ typedef struct { #ifndef DOXYGEN_IGNORE size_t ptr; union { sph_u64 wide[16]; sph_u32 narrow[32]; } H; sph_u64 block_count; } sph_jh_context; /** * Type for a JH-512 context (identical to the common context). */ typedef sph_jh_context sph_jh512_context; /** * Initialize a JH-512 context. This process performs no memory allocation. * * @param cc the JH-512 context (pointer to a * <code>sph_jh512_context</code>) */ QSTATIC void sph_jh512_init(void *cc); /** * Process some data bytes. It is acceptable that <code>len</code> is zero * (in which case this function does nothing). * * @param cc the JH-512 context * @param data the input data * @param len the input data length (in bytes) */ QSTATIC void sph_jh512(void *cc, const void *data, size_t len); /** * Terminate the current JH-512 computation and output the result into * the provided buffer. The destination buffer must be wide enough to * accomodate the result (64 bytes). The context is automatically * reinitialized. * * @param cc the JH-512 context * @param dst the destination buffer */ QSTATIC void sph_jh512_close(void *cc, void *dst); /** * Add a few additional bits (0 to 7) to the current computation, then * terminate it and output the result in the provided buffer, which must * be wide enough to accomodate the result (64 bytes). If bit number i * in <code>ub</code> has value 2^i, then the extra bits are those * numbered 7 downto 8-n (this is the big-endian convention at the byte * level). The context is automatically reinitialized. * * @param cc the JH-512 context * @param ub the extra bits * @param n the number of extra bits (0 to 7) * @param dst the destination buffer */ QSTATIC void sph_jh512_addbits_and_close( void *cc, unsigned ub, unsigned n, void *dst); #ifdef __cplusplus } #endif #endif