text stringlengths 4 6.14k |
|---|
#pragma once
#include "display/graphic/Font.h"
namespace stm32plus { namespace display {
// helper so the user can just do 'new fontname' without having to know the parameters
extern const struct FontChar FDEF_ATARIST8X16SYSTEMFONT_CHAR[];
class Font_ATARIST8X16SYSTEMFONT16 : public Font {
public:
Font_ATARIST8X16SYSTEMFONT16()
: Font(32,96,16,0,FDEF_ATARIST8X16SYSTEMFONT_CHAR) {
}
};
} }
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_
#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_
#import <Cocoa/Cocoa.h>
#import "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/geometry/size.h"
class Browser;
@class BrowserActionButton;
@class BrowserActionsContainerView;
@class MenuButton;
class ToolbarActionsBar;
class ToolbarActionsBarDelegate;
namespace content {
class WebContents;
}
// Sent when the visibility of the Browser Actions changes.
extern NSString* const kBrowserActionVisibilityChangedNotification;
// Handles state and provides an interface for controlling the Browser Actions
// container within the Toolbar.
@interface BrowserActionsController : NSObject<NSMenuDelegate> {
@private
// Reference to the current browser. Weak.
Browser* browser_;
// The view from Toolbar.xib we'll be rendering our browser actions in. Weak.
BrowserActionsContainerView* containerView_;
// Array of toolbar action buttons in the correct order for them to be
// displayed (includes both hidden and visible buttons).
base::scoped_nsobject<NSMutableArray> buttons_;
// The delegate for the ToolbarActionsBar.
scoped_ptr<ToolbarActionsBarDelegate> toolbarActionsBarBridge_;
// The controlling ToolbarActionsBar.
scoped_ptr<ToolbarActionsBar> toolbarActionsBar_;
// True if we should supppress the chevron (we do this during drag
// animations).
BOOL suppressChevron_;
// True if this is the overflow container for toolbar actions.
BOOL isOverflow_;
// The currently running chevron animation (fade in/out).
base::scoped_nsobject<NSViewAnimation> chevronAnimation_;
// The chevron button used when Browser Actions are hidden.
base::scoped_nsobject<MenuButton> chevronMenuButton_;
// The Browser Actions overflow menu.
base::scoped_nsobject<NSMenu> overflowMenu_;
}
@property(readonly, nonatomic) BrowserActionsContainerView* containerView;
@property(readonly, nonatomic) Browser* browser;
@property(readonly, nonatomic) BOOL isOverflow;
// Initializes the controller given the current browser and container view that
// will hold the browser action buttons. If |mainController| is nil, the created
// BrowserActionsController will be the main controller; otherwise (if this is
// for the overflow menu), |mainController| should be controller of the main bar
// for the |browser|.
- (id)initWithBrowser:(Browser*)browser
containerView:(BrowserActionsContainerView*)container
mainController:(BrowserActionsController*)mainController;
// Update the display of all buttons.
- (void)update;
// Returns the current number of browser action buttons within the container,
// whether or not they are displayed.
- (NSUInteger)buttonCount;
// Returns the current number of browser action buttons displayed in the
// container.
- (NSUInteger)visibleButtonCount;
// Returns the preferred size for the container.
- (gfx::Size)preferredSize;
// Returns where the popup arrow should point to for the action with the given
// |id|. If passed an id with no corresponding button, returns NSZeroPoint.
- (NSPoint)popupPointForId:(const std::string&)id;
// Returns whether the chevron button is currently hidden or in the process of
// being hidden (fading out). Will return NO if it is not hidden or is in the
// process of fading in.
- (BOOL)chevronIsHidden;
// Returns the currently-active web contents.
- (content::WebContents*)currentWebContents;
@end // @interface BrowserActionsController
@interface BrowserActionsController(TestingAPI)
- (BrowserActionButton*)buttonWithIndex:(NSUInteger)index;
- (ToolbarActionsBar*)toolbarActionsBar;
+ (BrowserActionsController*)fromToolbarActionsBarDelegate:
(ToolbarActionsBarDelegate*)delegate;
@end
#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_
|
#include "blis.h"
#ifdef BLIS_ENABLE_CBLAS
/*
*
* cblas_ssyr.c
* This program is a C interface to ssyr.
* Written by Keita Teranishi
* 4/6/1998
*
*/
#include "cblas.h"
#include "cblas_f77.h"
void cblas_ssyr(enum CBLAS_ORDER order, enum CBLAS_UPLO Uplo,
f77_int N, const float alpha, const float *X,
f77_int incX, float *A, f77_int lda)
{
char UL;
#ifdef F77_CHAR
F77_CHAR F77_UL;
#else
#define F77_UL &UL
#endif
#ifdef F77_INT
F77_INT F77_N=N, F77_incX=incX, F77_lda=lda;
#else
#define F77_N N
#define F77_incX incX
#define F77_lda lda
#endif
extern int CBLAS_CallFromC;
extern int RowMajorStrg;
RowMajorStrg = 0;
CBLAS_CallFromC = 1;
if (order == CblasColMajor)
{
if (Uplo == CblasLower) UL = 'L';
else if (Uplo == CblasUpper) UL = 'U';
else
{
cblas_xerbla(2, "cblas_ssyr","Illegal Uplo setting, %d\n",Uplo );
CBLAS_CallFromC = 0;
RowMajorStrg = 0;
return;
}
#ifdef F77_CHAR
F77_UL = C2F_CHAR(&UL);
#endif
F77_ssyr(F77_UL, &F77_N, &alpha, X, &F77_incX, A, &F77_lda);
} else if (order == CblasRowMajor)
{
RowMajorStrg = 1;
if (Uplo == CblasLower) UL = 'U';
else if (Uplo == CblasUpper) UL = 'L';
else
{
cblas_xerbla(2, "cblas_ssyr","Illegal Uplo setting, %d\n",Uplo );
CBLAS_CallFromC = 0;
RowMajorStrg = 0;
return;
}
#ifdef F77_CHAR
F77_UL = C2F_CHAR(&UL);
#endif
F77_ssyr(F77_UL, &F77_N, &alpha, X, &F77_incX, A, &F77_lda);
} else cblas_xerbla(1, "cblas_ssyr", "Illegal Order setting, %d\n", order);
CBLAS_CallFromC = 0;
RowMajorStrg = 0;
return;
}
#endif
|
typedef struct {
str_t *str;
size_t len;
off_t pos;
} PEG;
char next(PEG *const state) {
if(++state->pos > state->len) {
}
return state->str[state->pos++];
}
char peek(PEG *const state) {
return state->str[state->pos];
}
size_t alpha(PEG *const state) {
if(!isalpha(peek(state))) return 0;
state->pos++;
return 1;
}
size_t alphas(PEG *const state) {
}
size_t scheme(PEG *const state, size_t *const len) {
bool_t matched = false;
while(schemechar(state, len)) matched = true;
return matched;
}
#define URI_MAX 1024
#define TITLE_MAX 1024
size_t uri(byte_t const *const buf, size_t const len) {
size_t r = 0;
while(scheme(src)) append(dst, pop(src));
if(':' != append(dst, pop(src))) { return 0; }
if('/' != append(dst, pop(src))) { return 0; }
if('/' != append(dst, pop(src))) { return 0; }
while(domain(src)) append(dst, pop(src));
while(path(src)) append(dst, pop(src));
return r;
}
void meta_parse(parser) {
off_t pos = 0;
size_t urilen = uri(thing, pos);
if(!urilen) return -1;
cbs.on_source_uri(context, thing->str + pos, urilen);
pos += urilen;
if('\n' != next(thing, pos)) return -1;
pos += 1;
size_t titlelen = title(thing, pos);
if(titlelen) {
cbs.on_title(context, thing->str + pos, titlelen);
pos += titlelen;
if('\n' != next(thing, pos)) return -1;
pos += 1;
}
if('\n' != next(thing, pos)) return -1;
pos += 1;
for(;;) {
pos += spaces(thing, pos);
consume(spaces());
urilen = uri(thing, pos);
if(urilen) {
cbs.on_target_uri(context, thing->str + pos, urilen);
pos += urilen;
}
}
}
typedef struct {
int (*on_source_uri)(void *, strarg_t, size_t);
int (*on_title)(void *, strarg_t, size_t);
int (*on_target_uri)(void *, strarg_t, size_t);
int (*on_body)(void *, strarg_t, size_t);
} parser_cbs;
|
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Domain
extern NSString *const kMSMCErrorDomain;
#pragma mark - Log
// Error codes
NS_ENUM(NSInteger){kMSMCLogInvalidContainerErrorCode = 1};
// Error descriptions
extern NSString const *kMSMCLogInvalidContainerErrorDesc;
#pragma mark - Connection
// Error codes
NS_ENUM(NSInteger){kMSMCConnectionSuspendedErrorCode = 100, kMSMCConnectionHttpErrorCode = 101};
// Error descriptions
extern NSString const *kMSMCConnectionHttpErrorDesc;
extern NSString const *kMSMCConnectionSuspendedErrorDesc;
// Error user info keys
extern NSString const *kMSMCConnectionHttpCodeErrorKey;
NS_ASSUME_NONNULL_END
|
//
// OSKActivitySheetDelegate.h
// Overshare
//
// Created by Jared Sinclair on 10/13/13.
// Copyright (c) 2013 Overshare Kit. All rights reserved.
//
@class OSKActivity;
@class OSKActivitySheetViewController;
@protocol OSKActivitySheetDelegate <NSObject>
- (void)activitySheet:(OSKActivitySheetViewController *)viewController didSelectActivity:(OSKActivity *)activity;
- (void)activitySheetDidCancel:(OSKActivitySheetViewController *)viewController;
@end
|
/*
* LibNoPoll: A websocket library
* Copyright (C) 2013 Advanced Software Production Line, S.L.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* You may find a copy of the license under this software is released
* at COPYING file. This is LGPL software: you are welcome to develop
* proprietary applications using this library without any royalty or
* fee but returning back any change, improvement or addition in the
* form of source code, project image, documentation patches, etc.
*
* For commercial support on build Websocket enabled solutions
* contact us:
*
* Postal address:
* Advanced Software Production Line, S.L.
* Edificio Alius A, Oficina 102,
* C/ Antonio Suarez Nº 10,
* Alcalá de Henares 28802 Madrid
* Spain
*
* Email address:
* info@aspl.es - http://www.aspl.es/nopoll
*/
#ifndef __NOPOLL_CONN_OPTS_H__
#define __NOPOLL_CONN_OPTS_H__
#include <nopoll.h>
BEGIN_C_DECLS
noPollConnOpts * nopoll_conn_opts_new (void);
void nopoll_conn_opts_set_ssl_protocol (noPollConnOpts * opts, noPollSslProtocol ssl_protocol);
nopoll_bool nopoll_conn_opts_set_ssl_certs (noPollConnOpts * opts,
const char * client_certificate,
const char * private_key,
const char * chain_certificate,
const char * ca_certificate);
void nopoll_conn_opts_ssl_peer_verify (noPollConnOpts * opts, nopoll_bool verify);
void nopoll_conn_opts_set_cookie (noPollConnOpts * opts, const char * cookie_content);
nopoll_bool nopoll_conn_opts_ref (noPollConnOpts * opts);
void nopoll_conn_opts_unref (noPollConnOpts * opts);
void nopoll_conn_opts_set_reuse (noPollConnOpts * opts, nopoll_bool reuse);
void nopoll_conn_opts_free (noPollConnOpts * opts);
/** internal API **/
void __nopoll_conn_opts_release_if_needed (noPollConnOpts * options);
END_C_DECLS
#endif
|
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EPS_1D /Tps_4_1 /Fhshaders\ps1D.h
//
//
// Buffer Definitions:
//
// cbuffer cbArrayControl
// {
//
// float Index; // Offset: 0 Size: 4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samLinear sampler NA NA 0 1
// tx1D texture float4 1d 0 1
// cbArrayControl cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture1d (float,float,float,float) t0
dcl_input_ps linear v1.x
dcl_output o0.xyzw
sample o0.xyzw, v1.xxxx, t0.xyzw, s0
ret
// Approximately 2 instruction slots used
#endif
const BYTE g_PS_1D[] =
{
68, 88, 66, 67, 71, 33,
105, 235, 206, 215, 61, 110,
190, 73, 39, 172, 36, 251,
31, 148, 1, 0, 0, 0,
220, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
84, 1, 0, 0, 172, 1,
0, 0, 224, 1, 0, 0,
96, 2, 0, 0, 82, 68,
69, 70, 24, 1, 0, 0,
1, 0, 0, 0, 156, 0,
0, 0, 3, 0, 0, 0,
28, 0, 0, 0, 1, 4,
255, 255, 0, 1, 0, 0,
228, 0, 0, 0, 124, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0,
134, 0, 0, 0, 2, 0,
0, 0, 5, 0, 0, 0,
2, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0,
1, 0, 0, 0, 13, 0,
0, 0, 139, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 115, 97,
109, 76, 105, 110, 101, 97,
114, 0, 116, 120, 49, 68,
0, 99, 98, 65, 114, 114,
97, 121, 67, 111, 110, 116,
114, 111, 108, 0, 171, 171,
139, 0, 0, 0, 1, 0,
0, 0, 180, 0, 0, 0,
16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
204, 0, 0, 0, 0, 0,
0, 0, 4, 0, 0, 0,
0, 0, 0, 0, 212, 0,
0, 0, 0, 0, 0, 0,
73, 110, 100, 101, 120, 0,
171, 171, 0, 0, 3, 0,
1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
77, 105, 99, 114, 111, 115,
111, 102, 116, 32, 40, 82,
41, 32, 72, 76, 83, 76,
32, 83, 104, 97, 100, 101,
114, 32, 67, 111, 109, 112,
105, 108, 101, 114, 32, 57,
46, 50, 57, 46, 57, 53,
50, 46, 51, 49, 49, 49,
0, 171, 171, 171, 73, 83,
71, 78, 80, 0, 0, 0,
2, 0, 0, 0, 8, 0,
0, 0, 56, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 15, 1,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
78, 0, 84, 69, 88, 67,
79, 79, 82, 68, 0, 171,
171, 171, 79, 83, 71, 78,
44, 0, 0, 0, 1, 0,
0, 0, 8, 0, 0, 0,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 84, 97, 114,
103, 101, 116, 0, 171, 171,
83, 72, 68, 82, 120, 0,
0, 0, 65, 0, 0, 0,
30, 0, 0, 0, 106, 8,
0, 1, 89, 0, 0, 4,
70, 142, 32, 0, 0, 0,
0, 0, 1, 0, 0, 0,
90, 0, 0, 3, 0, 96,
16, 0, 0, 0, 0, 0,
88, 16, 0, 4, 0, 112,
16, 0, 0, 0, 0, 0,
85, 85, 0, 0, 98, 16,
0, 3, 18, 16, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
0, 0, 0, 0, 69, 0,
0, 9, 242, 32, 16, 0,
0, 0, 0, 0, 6, 16,
16, 0, 1, 0, 0, 0,
70, 126, 16, 0, 0, 0,
0, 0, 0, 96, 16, 0,
0, 0, 0, 0, 62, 0,
0, 1, 83, 84, 65, 84,
116, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
|
/*
* wbuf.h
*
* Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
* 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 Texas Instruments 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.
*/
/***************************************************************************/
/* */
/* MODULE: wbuf.h */
/* PURPOSE: manages the allocation/free and field access of the WBUF */
/* */
/***************************************************************************/
#ifndef _WBUF_H_
#define _WBUF_H_
#include <linux/version.h>
#include <linux/skbuff.h>
#include "tidef.h"
#include "queue.h"
typedef void WBUF;
/* Packet types */
typedef enum {
TX_PKT_TYPE_MGMT = 0x01,
TX_PKT_TYPE_EAPOL = 0x02,
TX_PKT_TYPE_ETHER = 0x04, /* Data packets from the Network interface. */
TX_PKT_TYPE_WLAN_DATA = 0x08 /* Currently includes Null and IAPP packets. */
} TX_PKT_TYPE;
#define TX_PKT_FLAGS_LINK_TEST 0x1 /* Tx-Packet-Flag */
#define WSPI_PAD_BYTES 16 /* Add padding before data buffer for WSPI overhead */
/* user callback definition (in tx complete) */
typedef void *CB_ARG;
typedef void (*CB_FUNC)(CB_ARG cb_arg);
/*
* wbuf user fields:
*/
typedef struct {
TQueNodeHdr queNodeHdr; /* The header used for queueing the WBUF */
TX_PKT_TYPE pktType; /* wbuf packet type */
CB_FUNC cb_func; /* callback function to use in tx complete */
CB_ARG cb_arg; /* callback argument to use in tx complete */
TI_UINT8 Tid; /* WLAN TID (traffic identity) */
TI_UINT8 hdrLen; /* WLAN header length, not including alignment pad. */
TI_UINT8 flags; /* Some application flags, see Tx-Packet-Flags defs above. */
} WBUF_PARAMS;
#define WBUF_DATA(pWbuf) ( ((struct sk_buff *)(pWbuf))->data )
#define WBUF_LEN(pWbuf) ( ((struct sk_buff *)(pWbuf))->len )
#define WBUF_PRIORITY(pWbuf) ( ((struct sk_buff *)(pWbuf))->priority )
#define WBUF_DEV(pWbuf) ( ((struct sk_buff *)(pWbuf))->dev )
#define WBUF_DEV_SET(pWbuf,pDev) ( ((struct sk_buff *)(pWbuf))->dev) = ((struct net_device *)(pDev))
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
#define WBUF_STAMP(pWbuf) ( ((struct sk_buff *)(pWbuf))->tstamp.off_usec )
#else
#define WBUF_STAMP(pWbuf) ( ((struct sk_buff *)(pWbuf))->tstamp.tv.nsec )
#endif
#define WBUF_CB(pWbuf) ( ((struct sk_buff *)(pWbuf))->cb )
#define WBUF_PKT_TYPE(pWbuf) ( ((WBUF_PARAMS *)&(WBUF_CB(pWbuf)))->pktType )
#define WBUF_CB_FUNC(pWbuf) ( ((WBUF_PARAMS *)&(WBUF_CB(pWbuf)))->cb_func )
#define WBUF_CB_ARG(pWbuf) ( ((WBUF_PARAMS *)&(WBUF_CB(pWbuf)))->cb_arg )
#define WBUF_TID(pWbuf) ( ((WBUF_PARAMS *)&(WBUF_CB(pWbuf)))->Tid )
#define WBUF_HDR_LEN(pWbuf) ( ((WBUF_PARAMS *)&(WBUF_CB(pWbuf)))->hdrLen )
#define WBUF_FLAGS(pWbuf) ( ((WBUF_PARAMS *)&(WBUF_CB(pWbuf)))->flags )
/* The offset of the node-header field from the WBUF entry (for queueing) */
#define WBUF_NODE_HDR_OFFSET \
( (unsigned long) &( ( (WBUF_PARAMS *) &( ( (struct sk_buff *)0 )->cb ) )->queNodeHdr ) )
/*
* Allocate WBUF for Tx/Rx packets.
* Add 16 bytes before the data buffer for WSPI overhead!
*/
static inline WBUF *WbufAlloc (TI_HANDLE hOs, TI_UINT32 len)
{
WBUF *pWbuf = alloc_skb (len + WSPI_PAD_BYTES, GFP_ATOMIC);
WBUF_DATA (pWbuf) += WSPI_PAD_BYTES;
return pWbuf;
}
#define WbufFree(hOs, pWbuf) ( dev_kfree_skb((struct sk_buff *)pWbuf) )
#define WbufReserve(hOs, pWbuf,len) ( skb_reserve((struct sk_buff *)pWbuf,(int)len) )
#endif
|
/***************************************************************************
qgsoptionsdialogbase.h - base vertical tabs option dialog
---------------------
begin : March 24, 2013
copyright : (C) 2013 by Larry Shaffer
email : larrys at dakcarto dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSOPTIONSDIALOGBASE_H
#define QGSOPTIONSDIALOGBASE_H
#include "qgsguiutils.h"
#include "qgssettings.h"
#include "qgis_gui.h"
#include <functional>
#include <QDialog>
#include <QPointer>
#include <QStyledItemDelegate>
class QDialogButtonBox;
class QListWidget;
class QModelIndex;
class QPalette;
class QPainter;
class QStackedWidget;
class QStyleOptionViewItem;
class QSplitter;
class QgsFilterLineEdit;
class QgsOptionsDialogHighlightWidget;
/**
* \ingroup gui
* \class QgsOptionsDialogBase
* A base dialog for options and properties dialogs that offers vertical tabs.
* It handles saving/restoring of geometry, splitter and current tab states,
* switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left),
* and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
*
* To use:
* 1) Start with copy of qgsoptionsdialog_template.ui and build options/properties dialog.
* 2) In source file for dialog, inherit this class instead of QDialog, then in constructor:
* ...
* setupUi( this ); // set up .ui file objects
* initOptionsBase( FALSE ); // set up this class to use .ui objects, optionally restoring base ui
* ...
* restoreOptionsBaseUi(); // restore the base ui with initOptionsBase or use this later on
*/
class GUI_EXPORT QgsOptionsDialogBase : public QDialog
{
Q_OBJECT
public:
/**
* Constructor
* \param settingsKey QgsSettings subgroup key for saving/restore ui states, e.g. "ProjectProperties".
* \param parent parent object (owner)
* \param fl widget flags
* \param settings custom QgsSettings pointer
*/
QgsOptionsDialogBase( const QString &settingsKey, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = nullptr, QgsSettings *settings = nullptr );
~QgsOptionsDialogBase() override;
/**
* Set up the base ui connections for vertical tabs.
* \param restoreUi Whether to restore the base ui at this time.
* \param title the window title
*/
void initOptionsBase( bool restoreUi = true, const QString &title = QString() );
// set custom QgsSettings pointer if dialog used outside QGIS (in plugin)
void setSettings( QgsSettings *settings );
/**
* Restore the base ui.
* Sometimes useful to do at end of subclass's constructor.
* \param title the window title (it does not need to be defined if previously given to initOptionsBase();
*/
void restoreOptionsBaseUi( const QString &title = QString() );
/**
* Resizes all tabs when the dialog is resized
* \param index current tab index
* \since QGIS 3.10
*/
void resizeAlltabs( int index );
/**
* Determine if the options list is in icon only mode
*/
bool iconOnly() {return mIconOnly;}
public slots:
/**
* searchText searches for a text in all the pages of the stacked widget and highlight the results
* \param text the text to search
* \since QGIS 3.0
*/
void searchText( const QString &text );
protected slots:
//! Update tabs on the splitter move
virtual void updateOptionsListVerticalTabs();
//! Select relevant tab on current page change
virtual void optionsStackedWidget_CurrentChanged( int index );
//! Remove tab and unregister widgets on page remove
virtual void optionsStackedWidget_WidgetRemoved( int index );
void warnAboutMissingObjects();
protected:
void showEvent( QShowEvent *e ) override;
void paintEvent( QPaintEvent *e ) override;
virtual void updateWindowTitle();
/**
* register widgets in the dialog to search for text in it
* it is automatically called if a line edit has "mSearchLineEdit" as object name.
* \since QGIS 3.0
*/
void registerTextSearchWidgets();
QList< QPair< QgsOptionsDialogHighlightWidget *, int > > mRegisteredSearchWidgets;
QString mOptsKey;
bool mInit;
QListWidget *mOptListWidget = nullptr;
QStackedWidget *mOptStackedWidget = nullptr;
QSplitter *mOptSplitter = nullptr;
QDialogButtonBox *mOptButtonBox = nullptr;
QgsFilterLineEdit *mSearchLineEdit = nullptr;
QString mDialogTitle;
bool mIconOnly;
// pointer to app or custom, external QgsSettings
// QPointer in case custom settings obj gets deleted while dialog is open
QPointer<QgsSettings> mSettings;
bool mDelSettings;
};
#endif // QGSOPTIONSDIALOGBASE_H
|
/*
* LEDDriver.c
*
* Created on: Aug 26, 2013
* Author: Omri Iluz
*/
#include "ws2812.h"
#include <stdlib.h>
#define BYTES_FOR_LED_BYTE 4
#define NB_COLORS 3
#define BYTES_FOR_LED BYTES_FOR_LED_BYTE*NB_COLORS
#define DATA_SIZE BYTES_FOR_LED*NB_LEDS
#define RESET_SIZE 200
#define PREAMBLE_SIZE 4
// Define the spi your LEDs are plugged to here
#define WS2812_SPI SPID2
// Define the number of LEDs you wish to control in your LED strip
#define NB_LEDS RGBLED_NUM
#define LED_SPIRAL 1
static uint8_t txbuf[PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE];
static uint8_t get_protocol_eq(uint8_t data, int pos);
/*
* This lib is meant to be used asynchronously, thus the colors contained in
* the txbuf will be sent in loop, so that the colors are always the ones you
* put in the table (the user thus have less to worry about)
*
* Since the data are sent via DMA, and the call to spiSend is a blocking one,
* the processor ressources are not used to much, if you see your program being
* too slow, simply add a:
* chThdSleepMilliseconds(x);
* after the spiSend, where you increment x untill you are satisfied with your
* program speed, another trick may be to lower this thread priority : your call
*/
static THD_WORKING_AREA(LEDS_THREAD_WA, 128);
static THD_FUNCTION(ledsThread, arg) {
(void) arg;
while(1){
spiSend(&WS2812_SPI, PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE, txbuf);
}
}
static const SPIConfig spicfg = {
false,
NULL,
PORT_WS2812,
PIN_WS2812,
SPI_CR1_BR_1|SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us (2.25 MHz)
};
/*
* Function used to initialize the driver.
*
* Starts by shutting off all the LEDs.
* Then gets access on the LED_SPI driver.
* May eventually launch an animation on the LEDs (e.g. a thread setting the
* txbuff values)
*/
void leds_init(void){
/* MOSI pin*/
palSetPadMode(PORT_WS2812, PIN_WS2812, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
for(int i = 0; i < RESET_SIZE; i++)
txbuf[DATA_SIZE+i] = 0x00;
for (int i=0; i<PREAMBLE_SIZE; i++)
txbuf[i] = 0x00;
spiAcquireBus(&WS2812_SPI); /* Acquire ownership of the bus. */
spiStart(&WS2812_SPI, &spicfg); /* Setup transfer parameters. */
spiSelect(&WS2812_SPI); /* Slave Select assertion. */
chThdCreateStatic(LEDS_THREAD_WA, sizeof(LEDS_THREAD_WA),NORMALPRIO, ledsThread, NULL);
}
/*
* As the trick here is to use the SPI to send a huge pattern of 0 and 1 to
* the ws2812b protocol, we use this helper function to translate bytes into
* 0s and 1s for the LED (with the appropriate timing).
*/
static uint8_t get_protocol_eq(uint8_t data, int pos){
uint8_t eq = 0;
if (data & (1 << (2*(3-pos))))
eq = 0b1110;
else
eq = 0b1000;
if (data & (2 << (2*(3-pos))))
eq += 0b11100000;
else
eq += 0b10000000;
return eq;
}
void WS2812_init(void) {
leds_init();
}
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) {
uint8_t i = 0;
while (i < number_of_leds) {
set_led_color_rgb(ledarray[i], i);
i++;
}
}
/*
* If you want to set a LED's color in the RGB color space, simply call this
* function with a hsv_color containing the desired color and the index of the
* led on the LED strip (starting from 0, the first one being the closest the
* first plugged to the board)
*
* Only set the color of the LEDs through the functions given by this API
* (unless you really know what you are doing)
*/
void set_led_color_rgb(LED_TYPE color, int pos){
for(int j = 0; j < 4; j++)
txbuf[PREAMBLE_SIZE + BYTES_FOR_LED*pos + j] = get_protocol_eq(color.g, j);
for(int j = 0; j < 4; j++)
txbuf[PREAMBLE_SIZE + BYTES_FOR_LED*pos + BYTES_FOR_LED_BYTE+j] = get_protocol_eq(color.r, j);
for(int j = 0; j < 4; j++)
txbuf[PREAMBLE_SIZE + BYTES_FOR_LED*pos + BYTES_FOR_LED_BYTE*2+j] = get_protocol_eq(color.b, j);
}
void set_leds_color_rgb(LED_TYPE color){
for(int i = 0; i < NB_LEDS; i++)
set_led_color_rgb(color, i);
}
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds) {
}
|
/**
* @file georss.c GeoRSS namespace support
*
* Copyright (C) 2009 Mikel Olasagasti <mikel@olasagasti.info>
*
* 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 "common.h"
#include "metadata.h"
#include "ns_georss.h"
#define GEORSS_PREFIX "georss"
/* One can find the GeoRSS namespace spec at:
http://georss.org/model
Just georss:point at the moment
*/
static void
ns_georss_parse_item_tag (feedParserCtxtPtr ctxt, xmlNodePtr cur)
{
gchar *point = NULL;
if (!xmlStrcmp (BAD_CAST"point", cur->name))
point = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1);
if (point) {
metadata_list_set (&(ctxt->item->metadata), "point", point);
g_free (point);
}
}
static void
ns_georss_register_ns (NsHandler *nsh, GHashTable *prefixhash, GHashTable *urihash)
{
g_hash_table_insert (prefixhash, GEORSS_PREFIX, nsh);
g_hash_table_insert (urihash, "http://www.georss.org/georss", nsh);
}
NsHandler *
ns_georss_get_handler (void)
{
NsHandler *nsh;
nsh = g_new0 (NsHandler, 1);
nsh->prefix = GEORSS_PREFIX;
nsh->registerNs = ns_georss_register_ns;
nsh->parseChannelTag = NULL;
nsh->parseItemTag = ns_georss_parse_item_tag;
return nsh;
}
|
#import <Cocoa/Cocoa.h>
@protocol CDEEntitiesViewControllerDelegate;
@interface CDEEntitiesViewController : NSViewController
#pragma mark - Properties
@property (nonatomic, weak) id<CDEEntitiesViewControllerDelegate> delegate;
@property (nonatomic, readonly) NSEntityDescription *selectedEntityDescription;
#pragma mark - Displaying Data
@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;
#pragma mark - UI
- (void)updateUIOfVisibleEntities;
@end
|
/*****************************************************************************
*
* Copyright (C) 2011 Atmel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the copyright holders nor the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
****************************************************************************/
#include "iom48.h"
|
/*
* Copyright (C) 2010 Martin Willi
* Copyright (C) 2010 revosec AG
*
* 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. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "hook.h"
#include <encoding/payloads/unknown_payload.h>
typedef struct private_set_ike_initiator_t private_set_ike_initiator_t;
/**
* Private data of an set_ike_initiator_t object.
*/
struct private_set_ike_initiator_t {
/**
* Implements the hook_t interface.
*/
hook_t hook;
/**
* Alter requests or responses?
*/
bool req;
/**
* ID of message to alter.
*/
int id;
};
METHOD(listener_t, message, bool,
private_set_ike_initiator_t *this, ike_sa_t *ike_sa, message_t *message,
bool incoming, bool plain)
{
if (!incoming && plain &&
message->get_request(message) == this->req &&
message->get_message_id(message) == this->id)
{
ike_sa_id_t *id;
DBG1(DBG_CFG, "toggling IKE message initiator flag");
id = message->get_ike_sa_id(message);
id->switch_initiator(id);
}
return TRUE;
}
METHOD(hook_t, destroy, void,
private_set_ike_initiator_t *this)
{
free(this);
}
/**
* Create the IKE_AUTH fill hook
*/
hook_t *set_ike_initiator_hook_create(char *name)
{
private_set_ike_initiator_t *this;
INIT(this,
.hook = {
.listener = {
.message = _message,
},
.destroy = _destroy,
},
.req = conftest->test->get_bool(conftest->test,
"hooks.%s.request", TRUE, name),
.id = conftest->test->get_int(conftest->test,
"hooks.%s.id", 0, name),
);
return &this->hook;
}
|
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_PLOT_INTERVAL_CURVE_H
#define QWT_PLOT_INTERVAL_CURVE_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
#include "qwt_series_data.h"
class QwtIntervalSymbol;
/*!
\brief QwtPlotIntervalCurve represents a series of samples, where each value
is associated with an interval ( \f$[y1,y2] = f(x)\f$ ).
The representation depends on the style() and an optional symbol()
that is displayed for each interval. QwtPlotIntervalCurve might be used
to display error bars or the area between 2 curves.
*/
class QWT_EXPORT QwtPlotIntervalCurve:
public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
{
public:
/*!
\brief Curve styles.
The default setting is QwtPlotIntervalCurve::Tube.
\sa setStyle(), style()
*/
enum CurveStyle
{
/*!
Don't draw a curve. Note: This doesn't affect the symbols.
*/
NoCurve,
/*!
Build 2 curves from the upper and lower limits of the intervals
and draw them with the pen(). The area between the curves is
filled with the brush().
*/
Tube,
/*!
Styles >= QwtPlotIntervalCurve::UserCurve are reserved for derived
classes that overload drawSeries() with
additional application specific curve types.
*/
UserCurve = 100
};
/*!
Attributes to modify the drawing algorithm.
\sa setPaintAttribute(), testPaintAttribute()
*/
enum PaintAttribute
{
/*!
Clip polygons before painting them. In situations, where points
are far outside the visible area (f.e when zooming deep) this
might be a substantial improvement for the painting performance.
*/
ClipPolygons = 0x01,
//! Check if a symbol is on the plot canvas before painting it.
ClipSymbol = 0x02
};
//! Paint attributes
typedef QFlags<PaintAttribute> PaintAttributes;
explicit QwtPlotIntervalCurve( const QString &title = QString() );
explicit QwtPlotIntervalCurve( const QwtText &title );
virtual ~QwtPlotIntervalCurve();
virtual int rtti() const;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setSamples( const QVector<QwtIntervalSample> & );
void setSamples( QwtSeriesData<QwtIntervalSample> * );
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen & );
const QPen &pen() const;
void setBrush( const QBrush & );
const QBrush &brush() const;
void setStyle( CurveStyle style );
CurveStyle style() const;
void setSymbol( const QwtIntervalSymbol * );
const QwtIntervalSymbol *symbol() const;
virtual void drawSeries( QPainter *p,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual QRectF boundingRect() const;
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
protected:
void init();
virtual void drawTube( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSymbols( QPainter *, const QwtIntervalSymbol &,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
private:
class PrivateData;
PrivateData *d_data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotIntervalCurve::PaintAttributes )
#endif
|
/***************************************************************
*
* Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
* University of Wisconsin-Madison, WI.
*
* 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.
*
***************************************************************/
#if !defined(_CONDOR_DAEMON_PROC_H)
#define _CONDOR_DAEMON_PROC_H
#include "user_proc.h"
/** This is a "Tool" process in the TDP or "Tool Daemon Protocol"
world. This implements the Condor side of the TDP for spawning a
tool that runs next to an application that might want to do
profiling, debugging, etc. It is derived directly from UserProc,
since we don't want most of the functionality in OsProc and its
children.
*/
class ToolDaemonProc : public UserProc
{
public:
/// Constructor
ToolDaemonProc( ClassAd *jobAd, int application_pid );
/** Here we do things like set_user_ids(), get the executable,
get the args, env, cwd from the classad, open the input,
output, error files for re-direction, and (finally) call
daemonCore->Create_Process().
*/
virtual int StartJob();
/** In this function, we determine if pid == our pid, and if so
do whatever cleanup we need to now that the tool
has exited. Also, this function will get called
whenever the application exits, so if the
ToolDaemon wants to do anything special when the
application is gone, we can go that here, too.
@param pid The pid that exited.
@param status Its status
@return True if our ToolDaemonProc is no longer active, else false.
*/
virtual bool JobReaper(int pid, int status);
/** ToolDaemonProcs don't need to send a remote system call to
the shadow to tell it we've exited. So, we want our own
version of this function that just returns without doing
anything.
*/
virtual bool JobExit( void );
/** Publish all attributes we care about for updating the
shadow into the given ClassAd. This function is just
virtual, not pure virtual, since ToolDaemonProc and any derived
classes should implement a version of this that publishes
any info contained in each class, and each derived version
should also call it's parent's version, too.
@param ad pointer to the classad to publish into
@return true if success, false if failure
*/
virtual bool PublishUpdateAd( ClassAd* ad );
/// Send a DC_SIGSTOP
virtual void Suspend();
/// Send a DC_SIGCONT
virtual void Continue();
/// Send a DC_SIGTERM
virtual bool ShutdownGraceful();
/// Send a DC_SIGKILL
virtual bool ShutdownFast();
/// Evict for condor_rm (ATTR_REMOVE_KILL_SIG)
virtual bool Remove();
/// Evict for condor_hold (ATTR_HOLD_KILL_SIG)
virtual bool Hold();
protected:
bool job_suspended;
private:
int ApplicationPid;
};
#endif /* _CONDOR_DAEMON_PROC_H */
|
#include <tommath.h>
#ifdef BN_MP_PRIME_MILLER_RABIN_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
* LibTomMath is a library that provides multiple-precision
* integer arithmetic as well as number theoretic functionality.
*
* The library was designed directly after the MPI library by
* Michael Fromberger but has been written from scratch with
* additional optimizations in place.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/* Miller-Rabin test of "a" to the base of "b" as described in
* HAC pp. 139 Algorithm 4.24
*
* Sets result to 0 if definitely composite or 1 if probably prime.
* Randomly the chance of error is no more than 1/4 and often
* very much lower.
*/
int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
{
mp_int n1, y, r;
int s, j, err;
/* default */
*result = MP_NO;
/* ensure b > 1 */
if (mp_cmp_d(b, 1) != MP_GT) {
return MP_VAL;
}
/* get n1 = a - 1 */
if ((err = mp_init_copy (&n1, a)) != MP_OKAY) {
return err;
}
if ((err = mp_sub_d (&n1, 1, &n1)) != MP_OKAY) {
goto LBL_N1;
}
/* set 2**s * r = n1 */
if ((err = mp_init_copy (&r, &n1)) != MP_OKAY) {
goto LBL_N1;
}
/* count the number of least significant bits
* which are zero
*/
s = mp_cnt_lsb(&r);
/* now divide n - 1 by 2**s */
if ((err = mp_div_2d (&r, s, &r, NULL)) != MP_OKAY) {
goto LBL_R;
}
/* compute y = b**r mod a */
if ((err = mp_init (&y)) != MP_OKAY) {
goto LBL_R;
}
if ((err = mp_exptmod (b, &r, a, &y)) != MP_OKAY) {
goto LBL_Y;
}
/* if y != 1 and y != n1 do */
if (mp_cmp_d (&y, 1) != MP_EQ && mp_cmp (&y, &n1) != MP_EQ) {
j = 1;
/* while j <= s-1 and y != n1 */
while ((j <= (s - 1)) && mp_cmp (&y, &n1) != MP_EQ) {
if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) {
goto LBL_Y;
}
/* if y == 1 then composite */
if (mp_cmp_d (&y, 1) == MP_EQ) {
goto LBL_Y;
}
++j;
}
/* if y != n1 then composite */
if (mp_cmp (&y, &n1) != MP_EQ) {
goto LBL_Y;
}
}
/* probably prime now */
*result = MP_YES;
LBL_Y:mp_clear (&y);
LBL_R:mp_clear (&r);
LBL_N1:mp_clear (&n1);
return err;
}
#endif
/* $Source$ */
/* $Revision: 0.41 $ */
/* $Date: 2007-04-18 09:58:18 +0000 $ */
|
/*
* Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-12-10 Zohar_Lee first version
* 2020-07-10 lik rewrite
*/
#ifndef __DRV_HWTIMER_H__
#define __DRV_HWTIMER_H__
#include "board.h"
struct swm_hwtimer_cfg
{
char *name;
TIMR_TypeDef *TIMRx;
};
struct swm_hwtimer
{
struct swm_hwtimer_cfg *cfg;
rt_hwtimer_t time_device;
};
#ifndef TIM_DEV_INFO_CONFIG
#define TIM_DEV_INFO_CONFIG \
{ \
.maxfreq = 120000000, \
.minfreq = 120000000, \
.maxcnt = 0xFFFFFFFF, \
.cntmode = HWTIMER_CNTMODE_DW, \
}
#endif /* TIM_DEV_INFO_CONFIG */
#ifdef BSP_USING_TIM0
#ifndef TIM0_CFG
#define TIM0_CFG \
{ \
.name = "timer0", \
.TIMRx = TIMR0, \
}
#endif /* TIM0_CFG */
#endif /* BSP_USING_TIM0 */
#ifdef BSP_USING_TIM1
#ifndef TIM1_CFG
#define TIM1_CFG \
{ \
.name = "timer1", \
.TIMRx = TIMR1, \
}
#endif /* TIM1_CFG */
#endif /* BSP_USING_TIM1 */
#ifdef BSP_USING_TIM2
#ifndef TIM2_CFG
#define TIM2_CFG \
{ \
.name = "timer2", \
.TIMRx = TIMR2, \
}
#endif /* TIM2_CFG */
#endif /* BSP_USING_TIM2 */
#ifdef BSP_USING_TIM3
#ifndef TIM3_CFG
#define TIM3_CFG \
{ \
.name = "timer3", \
.TIMRx = TIMR3, \
}
#endif /* TIM3_CFG */
#endif /* BSP_USING_TIM3 */
#ifdef BSP_USING_TIM4
#ifndef TIM4_CFG
#define TIM4_CFG \
{ \
.name = "timer4", \
.TIMRx = TIMR4, \
}
#endif /* TIM4_CFG */
#endif /* BSP_USING_TIM4 */
#ifdef BSP_USING_TIM5
#ifndef TIM5_CFG
#define TIM5_CFG \
{ \
.name = "timer5", \
.TIMRx = TIMR5, \
}
#endif /* TIM5_CFG */
#endif /* BSP_USING_TIM5 */
int rt_hw_hwtimer_init(void);
#endif /* __DRV_HWTIMER_H__ */
|
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Multiparty Virtual Channel
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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 FREERDP_CHANNEL_ENCOMSP_H
#define FREERDP_CHANNEL_ENCOMSP_H
#include <freerdp/api.h>
#include <freerdp/types.h>
#define ENCOMSP_SVC_CHANNEL_NAME "encomsp"
struct _ENCOMSP_UNICODE_STRING
{
UINT16 cchString;
WCHAR wString[1024];
};
typedef struct _ENCOMSP_UNICODE_STRING ENCOMSP_UNICODE_STRING;
/* Filter Updated PDU Flags */
#define ENCOMSP_FILTER_ENABLED 0x0001
/* Application Created PDU Flags */
#define ENCOMSP_APPLICATION_SHARED 0x0001
/* Window Created PDU Flags */
#define ENCOMSP_WINDOW_SHARED 0x0001
/* Participant Created PDU Flags */
#define ENCOMSP_MAY_VIEW 0x0001
#define ENCOMSP_MAY_INTERACT 0x0002
#define ENCOMSP_IS_PARTICIPANT 0x0004
/* Participant Removed PDU Disconnection Types */
#define ENCOMSP_PARTICIPANT_DISCONNECTION_REASON_APP 0x00000000
#define ENCOMSP_PARTICIPANT_DISCONNECTION_REASON_CLI 0x00000002
/* Change Participant Control Level PDU Flags */
#define ENCOMSP_REQUEST_VIEW 0x0001
#define ENCOMSP_REQUEST_INTERACT 0x0002
#define ENCOMSP_ALLOW_CONTROL_REQUESTS 0x0008
/* PDU Order Types */
#define ODTYPE_FILTER_STATE_UPDATED 0x0001
#define ODTYPE_APP_REMOVED 0x0002
#define ODTYPE_APP_CREATED 0x0003
#define ODTYPE_WND_REMOVED 0x0004
#define ODTYPE_WND_CREATED 0x0005
#define ODTYPE_WND_SHOW 0x0006
#define ODTYPE_PARTICIPANT_REMOVED 0x0007
#define ODTYPE_PARTICIPANT_CREATED 0x0008
#define ODTYPE_PARTICIPANT_CTRL_CHANGED 0x0009
#define ODTYPE_GRAPHICS_STREAM_PAUSED 0x000A
#define ODTYPE_GRAPHICS_STREAM_RESUMED 0x000B
#define DEFINE_ENCOMSP_HEADER_COMMON() \
UINT16 Type; \
UINT16 Length
#define ENCOMSP_ORDER_HEADER_SIZE 4
struct _ENCOMSP_ORDER_HEADER
{
DEFINE_ENCOMSP_HEADER_COMMON();
};
typedef struct _ENCOMSP_ORDER_HEADER ENCOMSP_ORDER_HEADER;
struct _ENCOMSP_FILTER_UPDATED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
BYTE Flags;
};
typedef struct _ENCOMSP_FILTER_UPDATED_PDU ENCOMSP_FILTER_UPDATED_PDU;
struct _ENCOMSP_APPLICATION_CREATED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT16 Flags;
UINT32 AppId;
ENCOMSP_UNICODE_STRING Name;
};
typedef struct _ENCOMSP_APPLICATION_CREATED_PDU ENCOMSP_APPLICATION_CREATED_PDU;
struct _ENCOMSP_APPLICATION_REMOVED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT32 AppId;
};
typedef struct _ENCOMSP_APPLICATION_REMOVED_PDU ENCOMSP_APPLICATION_REMOVED_PDU;
struct _ENCOMSP_WINDOW_CREATED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT16 Flags;
UINT32 AppId;
UINT32 WndId;
ENCOMSP_UNICODE_STRING Name;
};
typedef struct _ENCOMSP_WINDOW_CREATED_PDU ENCOMSP_WINDOW_CREATED_PDU;
struct _ENCOMSP_WINDOW_REMOVED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT32 WndId;
};
typedef struct _ENCOMSP_WINDOW_REMOVED_PDU ENCOMSP_WINDOW_REMOVED_PDU;
struct _ENCOMSP_SHOW_WINDOW_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT32 WndId;
};
typedef struct _ENCOMSP_SHOW_WINDOW_PDU ENCOMSP_SHOW_WINDOW_PDU;
struct _ENCOMSP_PARTICIPANT_CREATED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT32 ParticipantId;
UINT32 GroupId;
UINT16 Flags;
ENCOMSP_UNICODE_STRING FriendlyName;
};
typedef struct _ENCOMSP_PARTICIPANT_CREATED_PDU ENCOMSP_PARTICIPANT_CREATED_PDU;
struct _ENCOMSP_PARTICIPANT_REMOVED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT32 ParticipantId;
UINT32 DiscType;
UINT32 DiscCode;
};
typedef struct _ENCOMSP_PARTICIPANT_REMOVED_PDU ENCOMSP_PARTICIPANT_REMOVED_PDU;
struct _ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
UINT16 Flags;
UINT32 ParticipantId;
};
typedef struct _ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU
ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU;
struct _ENCOMSP_GRAPHICS_STREAM_PAUSED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
};
typedef struct _ENCOMSP_GRAPHICS_STREAM_PAUSED_PDU ENCOMSP_GRAPHICS_STREAM_PAUSED_PDU;
struct _ENCOMSP_GRAPHICS_STREAM_RESUMED_PDU
{
DEFINE_ENCOMSP_HEADER_COMMON();
};
typedef struct _ENCOMSP_GRAPHICS_STREAM_RESUMED_PDU ENCOMSP_GRAPHICS_STREAM_RESUMED_PDU;
#endif /* FREERDP_CHANNEL_ENCOMSP_H */
|
/* Copyright (c) 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// GTLAnalyticsWebPropertySummary.h
//
// ----------------------------------------------------------------------------
// NOTE: This file is generated from Google APIs Discovery Service.
// Service:
// Google Analytics API (analytics/v3)
// Description:
// View and manage your Google Analytics data
// Documentation:
// https://developers.google.com/analytics/
// Classes:
// GTLAnalyticsWebPropertySummary (0 custom class methods, 7 custom properties)
#if GTL_BUILT_AS_FRAMEWORK
#import "GTL/GTLObject.h"
#else
#import "GTLObject.h"
#endif
@class GTLAnalyticsProfileSummary;
// ----------------------------------------------------------------------------
//
// GTLAnalyticsWebPropertySummary
//
// JSON template for an Analytics WebPropertySummary. WebPropertySummary returns
// basic information (i.e., summary) for a web property.
@interface GTLAnalyticsWebPropertySummary : GTLObject
// Web property ID of the form UA-XXXXX-YY.
// identifier property maps to 'id' in JSON (to avoid Objective C's 'id').
@property (copy) NSString *identifier;
// Internal ID for this web property.
@property (copy) NSString *internalWebPropertyId;
// Resource type for Analytics WebPropertySummary.
@property (copy) NSString *kind;
// Level for this web property. Possible values are STANDARD or PREMIUM.
@property (copy) NSString *level;
// Web property name.
@property (copy) NSString *name;
// List of profiles under this web property.
@property (retain) NSArray *profiles; // of GTLAnalyticsProfileSummary
// Website url for this web property.
@property (copy) NSString *websiteUrl;
@end
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_ABOUT_CHROME_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_ABOUT_CHROME_VIEW_H_
#pragma once
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link_listener.h"
#include "ui/views/view.h"
#include "ui/views/window/dialog_delegate.h"
#if defined(OS_WIN) && !defined(USE_AURA)
#include "chrome/browser/google/google_update.h"
#endif
namespace views {
class Textfield;
class Throbber;
}
class Profile;
////////////////////////////////////////////////////////////////////////////////
//
// The AboutChromeView class is responsible for drawing the UI controls of the
// About Chrome dialog that allows the user to see what version is installed
// and check for updates.
//
////////////////////////////////////////////////////////////////////////////////
class AboutChromeView : public views::DialogDelegateView,
public views::LinkListener
#if defined(OS_WIN) && !defined(USE_AURA)
, public GoogleUpdateStatusListener
#endif
{
public:
explicit AboutChromeView(Profile* profile);
virtual ~AboutChromeView();
// Initialize the controls on the dialog.
void Init();
// Overridden from views::View:
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void Layout() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) OVERRIDE;
// Overridden from views::DialogDelegate:
virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
virtual bool IsDialogButtonVisible(ui::DialogButton button) const OVERRIDE;
virtual int GetDefaultDialogButton() const OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual ui::ModalType GetModalType() const OVERRIDE;
virtual string16 GetWindowTitle() const OVERRIDE;
virtual bool Accept() OVERRIDE;
virtual views::View* GetContentsView() OVERRIDE;
// Overridden from views::LinkListener:
virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
#if defined(OS_WIN) && !defined(USE_AURA)
// Overridden from GoogleUpdateStatusListener:
virtual void OnReportResults(GoogleUpdateUpgradeResult result,
GoogleUpdateErrorCode error_code,
const string16& error_message,
const string16& version) OVERRIDE;
#endif
private:
#if defined(OS_WIN) && !defined(USE_AURA)
// Update the UI to show the status of the upgrade.
void UpdateStatus(GoogleUpdateUpgradeResult result,
GoogleUpdateErrorCode error_code,
const string16& error_message);
// Update the size of the window containing this view to account for more
// text being displayed (error messages, etc). Returns how many pixels the
// window was increased by (if any).
int EnlargeWindowSizeIfNeeded();
#endif
Profile* profile_;
// UI elements on the dialog.
views::ImageView* about_dlg_background_logo_;
views::Label* about_title_label_;
views::Textfield* version_label_;
views::Label* copyright_label_;
views::Label* main_text_label_;
int main_text_label_height_;
views::Link* chromium_url_;
gfx::Rect chromium_url_rect_;
views::Link* open_source_url_;
gfx::Rect open_source_url_rect_;
views::Link* terms_of_service_url_;
gfx::Rect terms_of_service_url_rect_;
// NULL in non-official builds.
views::Label* error_label_;
// UI elements we add to the parent view.
scoped_ptr<views::Throbber> throbber_;
views::ImageView success_indicator_;
views::ImageView update_available_indicator_;
views::ImageView timeout_indicator_;
views::Label update_label_;
// The dialog dimensions.
gfx::Size dialog_dimensions_;
// Keeps track of the visible state of the Restart Now button.
bool restart_button_visible_;
// The text to display as the main label of the About box. We draw this text
// word for word with the help of the WordIterator, and make room for URLs
// which are drawn using views::Link. See also |url_offsets_|.
string16 main_label_chunk1_;
string16 main_label_chunk2_;
string16 main_label_chunk3_;
string16 main_label_chunk4_;
string16 main_label_chunk5_;
// Determines the order of the two links we draw in the main label.
bool chromium_url_appears_first_;
#if defined(OS_WIN) && !defined(USE_AURA)
// The class that communicates with Google Update to find out if an update is
// available and asks it to start an upgrade.
scoped_refptr<GoogleUpdate> google_updater_;
#endif
// The version Google Update reports is available to us.
string16 new_version_available_;
// Whether text direction is left-to-right or right-to-left.
bool text_direction_is_rtl_;
DISALLOW_COPY_AND_ASSIGN(AboutChromeView);
};
#endif // CHROME_BROWSER_UI_VIEWS_ABOUT_CHROME_VIEW_H_
|
// Copyright 2019 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 IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_MANAGE_SYNC_SETTINGS_VIEW_CONTROLLER_MODEL_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_MANAGE_SYNC_SETTINGS_VIEW_CONTROLLER_MODEL_DELEGATE_H_
@protocol ManageSyncSettingsConsumer;
// Delegate for ManageSyncSettingsTableViewController instance, to manage the
// model.
@protocol ManageSyncSettingsTableViewControllerModelDelegate <NSObject>
// Called when the model should be loaded.
- (void)manageSyncSettingsTableViewControllerLoadModel:
(id<ManageSyncSettingsConsumer>)controller;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_MANAGE_SYNC_SETTINGS_VIEW_CONTROLLER_MODEL_DELEGATE_H_
|
/****************************************************************************
* libc/unistd/lib_chdir.c
*
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "lib_internal.h"
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON)
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: _trimdir
****************************************************************************/
#if 0
static inline void _trimdir(char *path)
{
/* Skip any trailing '/' characters (unless it is also the leading '/') */
int len = strlen(path) - 1;
while (len > 0 && path[len] == '/')
{
path[len] = '\0';
len--;
}
}
#else
# define _trimdir(p)
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: chdir
*
* Description:
* The chdir() function causes the directory named by the pathname pointed
* to by the 'path' argument to become the current working directory; that
* is, the starting point for path searches for pathnames not beginning
* with '/'.
*
* Input Parmeters:
* path - A pointer to a directory to use as the new current working
* directory
*
* Returned Value:
* 0(OK) on success; -1(ERROR) on failure with errno set appropriately:
*
* EACCES
* Search permission is denied for any component of the pathname.
* ELOOP
* A loop exists in symbolic links encountered during resolution of the
* 'path' argument OR more that SYMLOOP_MAX symbolic links in the
* resolution of the 'path' argument.
* ENAMETOOLONG
* The length of the path argument exceeds PATH_MAX or a pathname component
* is longer than NAME_MAX.
* ENOENT
* A component of 'path' does not name an existing directory or path is
* an empty string.
* ENOTDIR
* A component of the pathname is not a directory.
*
****************************************************************************/
int chdir(FAR const char *path)
{
struct stat buf;
char *oldpwd;
char *alloc;
int err;
int ret;
/* Verify the input parameters */
if (!path)
{
err = ENOENT;
goto errout;
}
/* Verify that 'path' refers to a directory */
ret = stat(path, &buf);
if (ret != 0)
{
err = ENOENT;
goto errout;
}
/* Something exists here... is it a directory? */
if (!S_ISDIR(buf.st_mode))
{
err = ENOTDIR;
goto errout;
}
/* Yes, it is a directory. Remove any trailing '/' characters from the path */
_trimdir(path);
/* Replace any preceding OLDPWD with the current PWD (this is to
* support 'cd -' in NSH)
*/
sched_lock();
oldpwd = getenv("PWD");
if (!oldpwd)
{
oldpwd = CONFIG_LIB_HOMEDIR;
}
alloc = strdup(oldpwd); /* kludge needed because environment is realloc'ed */
setenv("OLDPWD", alloc, TRUE);
lib_free(alloc);
/* Set the cwd to the input 'path' */
setenv("PWD", path, TRUE);
sched_unlock();
return OK;
errout:
set_errno(err);
return ERROR;
}
#endif /* CONFIG_NFILE_DESCRIPTORS && !CONFIG_DISABLE_ENVIRON */
|
#ifndef MARISA_ALPHA_PROGRESS_H_
#define MARISA_ALPHA_PROGRESS_H_
#include "base.h"
namespace marisa_alpha {
class Progress {
public:
explicit Progress(int flags);
bool is_valid() const;
bool is_last() const {
return (trie_id_ + 1) >= num_tries();
}
Progress &operator++() {
++trie_id_;
return *this;
}
void test_total_size(std::size_t total_size) {
MARISA_ALPHA_THROW_IF(total_size_ > (MARISA_ALPHA_UINT32_MAX - total_size),
MARISA_ALPHA_SIZE_ERROR);
total_size_ += total_size;
}
int flags() const {
return flags_;
}
int trie_id() const {
return trie_id_;
}
std::size_t total_size() const {
return total_size_;
}
int num_tries() const {
return flags_ & MARISA_ALPHA_NUM_TRIES_MASK;
}
int trie() const {
return flags_ & MARISA_ALPHA_TRIE_MASK;
}
int tail() const {
return flags_ & MARISA_ALPHA_TAIL_MASK;
}
int order() const {
return flags_ & MARISA_ALPHA_ORDER_MASK;
}
private:
int flags_;
int trie_id_;
std::size_t total_size_;
// Disallows copy and assignment.
Progress(const Progress &);
Progress &operator=(const Progress &);
};
} // namespace marisa_alpha
#endif // MARISA_ALPHA_PROGRESS_H_
|
/*************************************************************************/
/* platform_config.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 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. */
/*************************************************************************/
#include <malloc.h>
//#else
//#include <alloca.h>
//#endif
#define GLES2_INCLUDE_H "gl_context/glew.h"
|
/*
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2013 Tatsuhiro Tsujikawa
*
* 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 NGHTTP2_HD_HUFFMAN_H
#define NGHTTP2_HD_HUFFMAN_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <nghttp2/nghttp2.h>
typedef enum {
/* FSA accepts this state as the end of huffman encoding
sequence. */
NGHTTP2_HUFF_ACCEPTED = 1,
/* This state emits symbol */
NGHTTP2_HUFF_SYM = (1 << 1),
/* If state machine reaches this state, decoding fails. */
NGHTTP2_HUFF_FAIL = (1 << 2)
} nghttp2_huff_decode_flag;
typedef struct {
/* huffman decoding state, which is actually the node ID of internal
huffman tree. We have 257 leaf nodes, but they are identical to
root node other than emitting a symbol, so we have 256 internal
nodes [1..255], inclusive. */
uint8_t state;
/* bitwise OR of zero or more of the nghttp2_huff_decode_flag */
uint8_t flags;
/* symbol if NGHTTP2_HUFF_SYM flag set */
uint8_t sym;
} nghttp2_huff_decode;
typedef nghttp2_huff_decode huff_decode_table_type[16];
typedef struct {
/* Current huffman decoding state. We stripped leaf nodes, so the
value range is [0..255], inclusive. */
uint8_t state;
/* nonzero if we can say that the decoding process succeeds at this
state */
uint8_t accept;
} nghttp2_hd_huff_decode_context;
typedef struct {
/* The number of bits in this code */
uint32_t nbits;
/* Huffman code aligned to LSB */
uint32_t code;
} nghttp2_huff_sym;
#endif /* NGHTTP2_HD_HUFFMAN_H */
|
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Abhishek Malik <abhishek.malik@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Thanks to Adafruit for supplying a google translated version of the
* Chinese datasheet and some clues in their code.
*
* 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.
*/
#include "urm37.h"
#include "upm_fti.h"
/**
* This file implements the Function Table Interface (FTI) for this sensor
*/
const char upm_light_name[] = "URM37";
const char upm_light_description[] = "Ultrasonic Ranger";
// problem here is it's an either/or analog vs. uart. So we will just
// only support analog for now
// 1st gpio is reset, 2nd is trigger
const upm_protocol_t upm_light_protocol[] = {UPM_ANALOG, UPM_GPIO, UPM_GPIO};
const upm_sensor_t upm_light_category[] = {UPM_DISTANCE};
// forward declarations
const void* upm_urm37_get_ft(upm_sensor_t sensor_type);
void* upm_urm37_init_name();
void upm_urm37_close(void* dev);
upm_result_t upm_urm37_get_distance(void* dev, float* distance,
upm_distance_u unit);
static const upm_sensor_ft ft =
{
.upm_sensor_init_name = &upm_urm37_init_name,
.upm_sensor_close = &upm_urm37_close,
};
static const upm_distance_ft dft =
{
.upm_distance_get_value = &upm_urm37_get_distance
};
const void* upm_urm37_get_ft(upm_sensor_t sensor_type)
{
switch(sensor_type)
{
case UPM_SENSOR:
return &ft;
case UPM_DISTANCE:
return &dft;
default:
return NULL;
}
}
void* upm_urm37_init_name()
{
return NULL;
}
void upm_urm37_close(void* dev)
{
urm37_close((urm37_context)dev);
}
upm_result_t upm_urm37_get_distance(void* dev, float* distance,
upm_distance_u unit)
{
// only cm returned by sensor
float dist;
urm37_get_distance((urm37_context)dev, &dist, 0);
switch(unit)
{
case CENTIMETER:
*distance = dist;
return UPM_SUCCESS;
case INCH:
*distance = dist / 2.54;
return UPM_SUCCESS;
default:
return UPM_ERROR_INVALID_PARAMETER;
}
}
|
#pragma once
#define SOC_ALIGN 0x1000
#define SOC_BUFFERSIZE 0x100000
u32 soc_init (void);
u32 soc_exit (void);
static u32 *SOC_buffer = 0;
|
// Utility code for loading GLSL shaders.
// Has support for auto-reload, see glsl_refresh
#pragma once
#include <map>
#include <string>
#include <time.h>
#include "gfx/gl_lost_manager.h"
#include "gfx/gl_common.h"
// Represent a compiled and linked vshader/fshader pair.
// A just-constructed object is valid but cannot be used as a shader program, meaning that
// yes, you can declare these as globals if you like.
struct GLSLProgram : public GfxResourceHolder {
char name[16];
char vshader_filename[256];
char fshader_filename[256];
const char *vshader_source;
const char *fshader_source;
time_t vshader_mtime;
time_t fshader_mtime;
// Locations to some common uniforms. Hardcoded for speed.
GLint sampler0;
GLint sampler1;
GLint u_worldviewproj;
GLint u_world;
GLint u_viewproj;
GLint u_fog; // rgb = color, a = density
GLint u_sundir;
GLint u_camerapos;
GLint a_position;
GLint a_color;
GLint a_normal;
GLint a_texcoord0;
GLint a_texcoord1;
// Private to the implementation, do not touch
GLuint vsh_;
GLuint fsh_;
GLuint program_;
void GLLost();
};
// C API, old skool. Not much point either...
// From files (VFS)
GLSLProgram *glsl_create(const char *vshader_file, const char *fshader_file, std::string *error_message = 0);
// Directly from source code
GLSLProgram *glsl_create_source(const char *vshader_src, const char *fshader_src, std::string *error_message = 0);
void glsl_destroy(GLSLProgram *program);
// If recompilation of the program fails, the program is untouched and error messages
// are logged and the function returns false.
bool glsl_recompile(GLSLProgram *program, std::string *error_message = 0);
void glsl_bind(const GLSLProgram *program);
void glsl_unbind();
int glsl_attrib_loc(const GLSLProgram *program, const char *name);
int glsl_uniform_loc(const GLSLProgram *program, const char *name);
|
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
#define _SYS_IO_H 1
#include <features.h>
__BEGIN_DECLS
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges.
Portability note: not all Linux platforms support this call. Most
platforms based on the PC I/O architecture probably will, however.
E.g., Linux/Alpha for Alpha PCs supports this. */
extern int ioperm (unsigned long int __from, unsigned long int __num,
int __turn_on) __THROW;
/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
access any I/O port is granted. This call requires root
privileges. */
extern int iopl (int __level) __THROW;
#if defined __GNUC__ && __GNUC__ >= 2
static __inline unsigned char
inb (unsigned short int __port)
{
unsigned char _v;
__asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
return _v;
}
static __inline unsigned char
inb_p (unsigned short int __port)
{
unsigned char _v;
__asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
return _v;
}
static __inline unsigned short int
inw (unsigned short int __port)
{
unsigned short _v;
__asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
return _v;
}
static __inline unsigned short int
inw_p (unsigned short int __port)
{
unsigned short int _v;
__asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
return _v;
}
static __inline unsigned int
inl (unsigned short int __port)
{
unsigned int _v;
__asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
return _v;
}
static __inline unsigned int
inl_p (unsigned short int __port)
{
unsigned int _v;
__asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
return _v;
}
static __inline void
outb (unsigned char __value, unsigned short int __port)
{
__asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
}
static __inline void
outb_p (unsigned char __value, unsigned short int __port)
{
__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
"Nd" (__port));
}
static __inline void
outw (unsigned short int __value, unsigned short int __port)
{
__asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
}
static __inline void
outw_p (unsigned short int __value, unsigned short int __port)
{
__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
"Nd" (__port));
}
static __inline void
outl (unsigned int __value, unsigned short int __port)
{
__asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
}
static __inline void
outl_p (unsigned int __value, unsigned short int __port)
{
__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
"Nd" (__port));
}
static __inline void
insb (unsigned short int __port, void *__addr, unsigned long int __count)
{
__asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
:"d" (__port), "0" (__addr), "1" (__count));
}
static __inline void
insw (unsigned short int __port, void *__addr, unsigned long int __count)
{
__asm__ __volatile__ ("cld ; rep ; insw":"=D" (__addr), "=c" (__count)
:"d" (__port), "0" (__addr), "1" (__count));
}
static __inline void
insl (unsigned short int __port, void *__addr, unsigned long int __count)
{
__asm__ __volatile__ ("cld ; rep ; insl":"=D" (__addr), "=c" (__count)
:"d" (__port), "0" (__addr), "1" (__count));
}
static __inline void
outsb (unsigned short int __port, const void *__addr,
unsigned long int __count)
{
__asm__ __volatile__ ("cld ; rep ; outsb":"=S" (__addr), "=c" (__count)
:"d" (__port), "0" (__addr), "1" (__count));
}
static __inline void
outsw (unsigned short int __port, const void *__addr,
unsigned long int __count)
{
__asm__ __volatile__ ("cld ; rep ; outsw":"=S" (__addr), "=c" (__count)
:"d" (__port), "0" (__addr), "1" (__count));
}
static __inline void
outsl (unsigned short int __port, const void *__addr,
unsigned long int __count)
{
__asm__ __volatile__ ("cld ; rep ; outsl":"=S" (__addr), "=c" (__count)
:"d" (__port), "0" (__addr), "1" (__count));
}
#endif /* GNU C */
__END_DECLS
#endif /* _SYS_IO_H */
|
/* @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
*
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
*
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
*
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
*
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
* clnt_raw.c
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*
* Memory based rpc for simple testing and timing.
* Interface to create an rpc client and server in the same process.
* This lets us similate rpc and get round trip overhead, without
* any interference from the kernal.
*/
#include <rpc/rpc.h>
#define MCALL_MSG_SIZE 24
/*
* This is the "network" we will be moving stuff over.
*/
static struct clntraw_private {
CLIENT client_object;
XDR xdr_stream;
char _raw_buf[UDPMSGSIZE];
char mashl_callmsg[MCALL_MSG_SIZE];
u_int mcnt;
} *clntraw_private;
static enum clnt_stat clntraw_call();
static void clntraw_abort();
static void clntraw_geterr();
static bool_t clntraw_freeres();
static bool_t clntraw_control();
static void clntraw_destroy();
static struct clnt_ops client_ops = {
clntraw_call,
clntraw_abort,
clntraw_geterr,
clntraw_freeres,
clntraw_destroy,
clntraw_control
};
void svc_getreq();
/*
* Create a client handle for memory based rpc.
*/
CLIENT *
clntraw_create(prog, vers)
u_long prog;
u_long vers;
{
register struct clntraw_private *clp = clntraw_private;
struct rpc_msg call_msg;
XDR *xdrs = &clp->xdr_stream;
CLIENT *client = &clp->client_object;
if (clp == 0) {
clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
if (clp == 0)
return (0);
clntraw_private = clp;
}
/*
* pre-serialize the staic part of the call msg and stash it away
*/
call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = prog;
call_msg.rm_call.cb_vers = vers;
xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
if (! xdr_callhdr(xdrs, &call_msg)) {
perror("clnt_raw.c - Fatal header serialization error.");
}
clp->mcnt = XDR_GETPOS(xdrs);
XDR_DESTROY(xdrs);
/*
* Set xdrmem for client/server shared buffer
*/
xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE);
/*
* create client handle
*/
client->cl_ops = &client_ops;
client->cl_auth = authnone_create();
return (client);
}
static enum clnt_stat
clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout)
CLIENT *h;
u_long proc;
xdrproc_t xargs;
caddr_t argsp;
xdrproc_t xresults;
caddr_t resultsp;
struct timeval timeout;
{
register struct clntraw_private *clp = clntraw_private;
register XDR *xdrs = &clp->xdr_stream;
struct rpc_msg msg;
enum clnt_stat status;
struct rpc_err error;
if (clp == 0)
return (RPC_FAILED);
call_again:
/*
* send request
*/
xdrs->x_op = XDR_ENCODE;
XDR_SETPOS(xdrs, 0);
((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ;
if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
(! XDR_PUTLONG(xdrs, (long *)&proc)) ||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
(! (*xargs)(xdrs, argsp))) {
return (RPC_CANTENCODEARGS);
}
(void)XDR_GETPOS(xdrs); /* called just to cause overhead */
/*
* We have to call server input routine here because this is
* all going on in one process. Yuk.
*/
svc_getreq(1);
/*
* get results
*/
xdrs->x_op = XDR_DECODE;
XDR_SETPOS(xdrs, 0);
msg.acpted_rply.ar_verf = _null_auth;
msg.acpted_rply.ar_results.where = resultsp;
msg.acpted_rply.ar_results.proc = xresults;
if (! xdr_replymsg(xdrs, &msg))
return (RPC_CANTDECODERES);
_seterr_reply(&msg, &error);
status = error.re_status;
if (status == RPC_SUCCESS) {
if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
status = RPC_AUTHERROR;
}
} /* end successful completion */
else {
if (AUTH_REFRESH(h->cl_auth))
goto call_again;
} /* end of unsuccessful completion */
if (status == RPC_SUCCESS) {
if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
status = RPC_AUTHERROR;
}
if (msg.acpted_rply.ar_verf.oa_base != NULL) {
xdrs->x_op = XDR_FREE;
(void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf));
}
}
return (status);
}
static void
clntraw_geterr()
{
}
static bool_t
clntraw_freeres(cl, xdr_res, res_ptr)
CLIENT *cl;
xdrproc_t xdr_res;
caddr_t res_ptr;
{
register struct clntraw_private *clp = clntraw_private;
register XDR *xdrs = &clp->xdr_stream;
bool_t rval;
if (clp == 0)
{
rval = (bool_t) RPC_FAILED;
return (rval);
}
xdrs->x_op = XDR_FREE;
return ((*xdr_res)(xdrs, res_ptr));
}
static void
clntraw_abort()
{
}
static bool_t
clntraw_control()
{
return (FALSE);
}
static void
clntraw_destroy()
{
}
|
/* Copyright (C) 2015-2019 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* \file
*
* \author Pierre Chifflier <chifflier@wzdftpd.net>
*/
#ifndef __DETECT_SNMP_PDU_TYPE_H__
#define __DETECT_SNMP_PDU_TYPE_H__
#include "app-layer-snmp.h"
void DetectSNMPPduTypeRegister(void);
#endif /* __DETECT_SNMP_PDU_TYPE_H__ */
|
/***************************************************************
* Name: ShapeDockpoint.h
* Purpose: Defines shape dockpoint class
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
* Created: 2010-12-14
* Copyright: Michal Bližňák
* License: wxWidgets license (www.wxwidgets.org)
* Notes:
**************************************************************/
#ifndef _WXSFSHAPEDOCKPOINT_H_
#define _WXSFSHAPEDOCKPOINT_H_
#include <wx/wxsf/ScaledDC.h>
#include <wx/wxxmlserializer/XmlSerializer.h>
class WXDLLIMPEXP_SF wxSFShapeBase;
// default values
/*! \brief Default value of wxSFConnectionPoint::m_nRelPosition data member */
#define sfdvCONNPOINT_RELPOS wxRealPoint(0, 0)
/*! \brief Default value of wxSFConnectionPoint::m_nOrthoDir data member */
#define sfdvCONNPOINT_ORTHODIR cpdUNDEF
/*!
* \brief Class encapsulating fixed connection point assignable to shapes. The assigned fixed connection
* points are the only places where connected lines can start/end.
* \sa wxSFShapeBase::AddConnectionPoint()
*/
class WXDLLIMPEXP_SF wxSFConnectionPoint : public xsSerializable
{
public:
friend class wxSFShapeBase;
XS_DECLARE_CLONABLE_CLASS(wxSFConnectionPoint);
/*! \brief Connection point type */
enum CPTYPE
{
cpUNDEF,
cpTOPLEFT,
cpTOPMIDDLE,
cpTOPRIGHT,
cpCENTERLEFT,
cpCENTERMIDDLE,
cpCENTERRIGHT,
cpBOTTOMLEFT,
cpBOTTOMMIDDLE,
cpBOTTOMRIGHT,
cpCUSTOM
};
/*! \brief Direction of orthogonal connection */
enum CPORTHODIR
{
cpdUNDEF,
cpdHORIZONTAL,
cpdVERTICAL
};
/*!
* \brief Basic constructor.
*/
wxSFConnectionPoint();
/*!
* \brief Enhanced constructor.
* \param parent Pointer to parent shape
* \param type Connection point type
*/
wxSFConnectionPoint(wxSFShapeBase *parent, CPTYPE type);
/*!
* \brief Enhanced constructor.
* \param parent Pointer to parent shape
* \param relpos Relative position in percentages
* \param id Connection point ID
*/
wxSFConnectionPoint(wxSFShapeBase *parent, const wxRealPoint& relpos, long id = -1);
/*!
* \brief Copy constructor.
* \param obj Reference to source object
*/
wxSFConnectionPoint(const wxSFConnectionPoint &obj);
/*!
* \brief Destructor.
*/
virtual ~wxSFConnectionPoint() {;}
/*!
* \brief Get connection point type.
* \return Connection point type
*/
inline CPTYPE GetType() const { return m_nType; }
/*!
* \brief Set direction of orthogonal line's connection.
* \param dir Required direction
* \sa CPORTHODIR
*/
inline void SetOrthoDirection(const CPORTHODIR& dir) { this->m_nOrthoDir = dir; }
/*!
* \brief Get direction of orthogonal line's connection.
* \return Current direction
* \sa CPORTHODIR
*/
inline const CPORTHODIR& GetOrthoDirection() const { return m_nOrthoDir; }
/*!
* \brief Set parent shape.
* \param parent Pointer to parent shape
*/
inline void SetParentShape(wxSFShapeBase *parent) { wxASSERT(parent); m_pParentShape = parent; }
/*!
* \brief Get parent shape.
* \return Pointer to parent shape
*/
inline wxSFShapeBase* GetParentShape() const {return m_pParentShape; }
/*!
* \brief Set relative position of custom connection point.
* \param relpos Relative position in percetnages
*/
inline void SetRelativePosition(const wxRealPoint& relpos) { m_nRelPosition = relpos; }
/*!
* \brief Get relative position of custom connection point.
* \return Relative position in percentages
*/
inline const wxRealPoint& GetRelativePosition() const { return m_nRelPosition; }
/*!
* \brief Get absolute position of the connection point.
* \return Absolute position of the connection point
*/
wxRealPoint GetConnectionPoint() const;
/*!
* \brief Find out whether given point is inside the connection point.
* \param pos Examined point
* \return TRUE if the point is inside the handle, otherwise FALSE
*/
virtual bool Contains(const wxPoint& pos) const;
/*!
* \brief Draw connection point.
* \param dc Device context where the handle will be drawn
*/
void Draw(wxDC& dc);
/*! \brief Refresh (repaint) the dock point */
void Refresh();
protected:
/*!
* \brief Draw the connection point in the normal way. The function can be overrided if neccessary.
* \param dc Reference to device context where the shape will be drawn to
*/
virtual void DrawNormal(wxDC& dc);
/*!
* \brief Draw the connection point in the hower mode (the mouse cursor is above the shape).
* The function can be overrided if neccessary.
* \param dc Reference to device context where the shape will be drawn to
*/
virtual void DrawHover(wxDC& dc);
private:
/*!
* \brief Event handler called when the mouse pointer is moving above shape canvas.
* \param pos Current mouse position
*/
void _OnMouseMove(const wxPoint& pos);
void MarkSerializableDataMembers();
CPTYPE m_nType;
CPORTHODIR m_nOrthoDir;
wxSFShapeBase *m_pParentShape;
bool m_fMouseOver;
wxRealPoint m_nRelPosition;
};
#endif //_WXSFSHAPEDOCKPOINT_H_
|
/* arch/arm/plat-samsung/include/plat/pm.h
*
* Copyright (c) 2004 Simtec Electronics
* http://armlinux.simtec.co.uk/
* Written by Ben Dooks, <ben@simtec.co.uk>
*
* 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.
*/
/* s3c_pm_init
*
* called from board at initialisation time to setup the power
* management
*/
#include <linux/irq.h>
struct device;
#ifdef CONFIG_PM
extern __init int s3c_pm_init(void);
extern __init int s3c64xx_pm_init(void);
#else
static inline int s3c_pm_init(void)
{
return 0;
}
static inline int s3c64xx_pm_init(void)
{
return 0;
}
#endif
/* configuration for the IRQ mask over sleep */
extern unsigned long s3c_irqwake_intmask;
extern unsigned long s3c_irqwake_eintmask;
/* IRQ masks for IRQs allowed to go to sleep (see irq.c) */
extern unsigned long s3c_irqwake_intallow;
extern unsigned long s3c_irqwake_eintallow;
/* per-cpu sleep functions */
extern void (*pm_cpu_prep)(void);
extern int (*pm_cpu_sleep)(unsigned long);
/* Flags for PM Control */
extern unsigned long s3c_pm_flags;
extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT */
/* from sleep.S */
extern void s3c_cpu_resume(void);
extern int s3c2410_cpu_suspend(unsigned long);
/* sleep save info */
/**
* struct sleep_save - save information for shared peripherals.
* @reg: Pointer to the register to save.
* @val: Holder for the value saved from reg.
*
* This describes a list of registers which is used by the pm core and
* other subsystem to save and restore register values over suspend.
*/
struct sleep_save {
void __iomem *reg;
unsigned long val;
};
#define SAVE_ITEM(x) \
{ .reg = (x) }
/**
* struct pm_uart_save - save block for core UART
* @ulcon: Save value for S3C2410_ULCON
* @ucon: Save value for S3C2410_UCON
* @ufcon: Save value for S3C2410_UFCON
* @umcon: Save value for S3C2410_UMCON
* @ubrdiv: Save value for S3C2410_UBRDIV
*
* Save block for UART registers to be held over sleep and restored if they
* are needed (say by debug).
*/
struct pm_uart_save {
u32 ulcon;
u32 ucon;
u32 ufcon;
u32 umcon;
u32 ubrdiv;
u32 udivslot;
};
/* helper functions to save/restore lists of registers. */
extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
extern void s3c_pm_do_restore(struct sleep_save *ptr, int count);
extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count);
#ifdef CONFIG_PM
extern int s3c_irq_wake(struct irq_data *data, unsigned int state);
extern int s3c_irqext_wake(struct irq_data *data, unsigned int state);
#else
#define s3c_irq_wake NULL
#define s3c_irqext_wake NULL
#endif
/* PM debug functions */
#ifdef CONFIG_SAMSUNG_PM_DEBUG
/**
* s3c_pm_dbg() - low level debug function for use in suspend/resume.
* @msg: The message to print.
*
* This function is used mainly to debug the resume process before the system
* can rely on printk/console output. It uses the low-level debugging output
* routine printascii() to do its work.
*/
extern void s3c_pm_dbg(const char *msg, ...);
#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
#else
#define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt)
#endif
#ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
/**
* s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs
* @set: set bits for the state of the LEDs
* @clear: clear bits for the state of the LEDs.
*/
extern void s3c_pm_debug_smdkled(u32 set, u32 clear);
#else
static inline void s3c_pm_debug_smdkled(u32 set, u32 clear) { }
#endif /* CONFIG_S3C_PM_DEBUG_LED_SMDK */
/* suspend memory checking */
#ifdef CONFIG_SAMSUNG_PM_CHECK
extern void s3c_pm_check_prepare(void);
extern void s3c_pm_check_restore(void);
extern void s3c_pm_check_cleanup(void);
extern void s3c_pm_check_store(void);
#else
#define s3c_pm_check_prepare() do { } while(0)
#define s3c_pm_check_restore() do { } while(0)
#define s3c_pm_check_cleanup() do { } while(0)
#define s3c_pm_check_store() do { } while(0)
#endif
/**
* s3c_pm_configure_extint() - ensure pins are correctly set for IRQ
*
* Setup all the necessary GPIO pins for waking the system on external
* interrupt.
*/
extern void s3c_pm_configure_extint(void);
#ifdef CONFIG_GPIO_SAMSUNG
/**
* samsung_pm_restore_gpios() - restore the state of the gpios after sleep.
*
* Restore the state of the GPIO pins after sleep, which may involve ensuring
* that we do not glitch the state of the pins from that the bootloader's
* resume code has done.
*/
extern void samsung_pm_restore_gpios(void);
/**
* samsung_pm_save_gpios() - save the state of the GPIOs for restoring after sleep.
*
* Save the GPIO states for resotration on resume. See samsung_pm_restore_gpios().
*/
extern void samsung_pm_save_gpios(void);
#else
static inline void samsung_pm_restore_gpios(void) {}
static inline void samsung_pm_save_gpios(void) {}
#endif
extern void s3c_pm_save_core(void);
extern void s3c_pm_restore_core(void);
|
/* pin MUX configuration data */
static unsigned long sys_mgr_init_table[] = {
0, /* EMACIO0 */
2, /* EMACIO1 */
2, /* EMACIO2 */
2, /* EMACIO3 */
2, /* EMACIO4 */
2, /* EMACIO5 */
2, /* EMACIO6 */
2, /* EMACIO7 */
2, /* EMACIO8 */
0, /* EMACIO9 */
2, /* EMACIO10 */
2, /* EMACIO11 */
2, /* EMACIO12 */
2, /* EMACIO13 */
0, /* EMACIO14 */
0, /* EMACIO15 */
0, /* EMACIO16 */
0, /* EMACIO17 */
0, /* EMACIO18 */
0, /* EMACIO19 */
3, /* FLASHIO0 */
0, /* FLASHIO1 */
3, /* FLASHIO2 */
3, /* FLASHIO3 */
0, /* FLASHIO4 */
0, /* FLASHIO5 */
0, /* FLASHIO6 */
0, /* FLASHIO7 */
0, /* FLASHIO8 */
3, /* FLASHIO9 */
3, /* FLASHIO10 */
3, /* FLASHIO11 */
0, /* GENERALIO0 */
1, /* GENERALIO1 */
1, /* GENERALIO2 */
1, /* GENERALIO3 */
1, /* GENERALIO4 */
0, /* GENERALIO5 */
0, /* GENERALIO6 */
1, /* GENERALIO7 */
1, /* GENERALIO8 */
3, /* GENERALIO9 */
3, /* GENERALIO10 */
3, /* GENERALIO11 */
3, /* GENERALIO12 */
2, /* GENERALIO13 */
2, /* GENERALIO14 */
1, /* GENERALIO15 */
1, /* GENERALIO16 */
1, /* GENERALIO17 */
1, /* GENERALIO18 */
0, /* GENERALIO19 */
0, /* GENERALIO20 */
0, /* GENERALIO21 */
0, /* GENERALIO22 */
0, /* GENERALIO23 */
0, /* GENERALIO24 */
0, /* GENERALIO25 */
0, /* GENERALIO26 */
0, /* GENERALIO27 */
0, /* GENERALIO28 */
0, /* GENERALIO29 */
0, /* GENERALIO30 */
0, /* GENERALIO31 */
2, /* MIXED1IO0 */
2, /* MIXED1IO1 */
2, /* MIXED1IO2 */
2, /* MIXED1IO3 */
2, /* MIXED1IO4 */
2, /* MIXED1IO5 */
2, /* MIXED1IO6 */
2, /* MIXED1IO7 */
2, /* MIXED1IO8 */
2, /* MIXED1IO9 */
2, /* MIXED1IO10 */
2, /* MIXED1IO11 */
2, /* MIXED1IO12 */
2, /* MIXED1IO13 */
0, /* MIXED1IO14 */
3, /* MIXED1IO15 */
3, /* MIXED1IO16 */
3, /* MIXED1IO17 */
3, /* MIXED1IO18 */
3, /* MIXED1IO19 */
3, /* MIXED1IO20 */
0, /* MIXED1IO21 */
0, /* MIXED2IO0 */
0, /* MIXED2IO1 */
0, /* MIXED2IO2 */
0, /* MIXED2IO3 */
0, /* MIXED2IO4 */
0, /* MIXED2IO5 */
0, /* MIXED2IO6 */
0, /* MIXED2IO7 */
0, /* GPLINMUX48 */
0, /* GPLINMUX49 */
0, /* GPLINMUX50 */
0, /* GPLINMUX51 */
0, /* GPLINMUX52 */
0, /* GPLINMUX53 */
0, /* GPLINMUX54 */
0, /* GPLINMUX55 */
0, /* GPLINMUX56 */
0, /* GPLINMUX57 */
0, /* GPLINMUX58 */
0, /* GPLINMUX59 */
0, /* GPLINMUX60 */
0, /* GPLINMUX61 */
0, /* GPLINMUX62 */
0, /* GPLINMUX63 */
0, /* GPLINMUX64 */
0, /* GPLINMUX65 */
0, /* GPLINMUX66 */
0, /* GPLINMUX67 */
0, /* GPLINMUX68 */
0, /* GPLINMUX69 */
0, /* GPLINMUX70 */
1, /* GPLMUX0 */
1, /* GPLMUX1 */
1, /* GPLMUX2 */
1, /* GPLMUX3 */
1, /* GPLMUX4 */
1, /* GPLMUX5 */
1, /* GPLMUX6 */
1, /* GPLMUX7 */
1, /* GPLMUX8 */
1, /* GPLMUX9 */
1, /* GPLMUX10 */
1, /* GPLMUX11 */
1, /* GPLMUX12 */
1, /* GPLMUX13 */
1, /* GPLMUX14 */
1, /* GPLMUX15 */
1, /* GPLMUX16 */
1, /* GPLMUX17 */
1, /* GPLMUX18 */
1, /* GPLMUX19 */
1, /* GPLMUX20 */
1, /* GPLMUX21 */
1, /* GPLMUX22 */
1, /* GPLMUX23 */
1, /* GPLMUX24 */
1, /* GPLMUX25 */
1, /* GPLMUX26 */
1, /* GPLMUX27 */
1, /* GPLMUX28 */
1, /* GPLMUX29 */
1, /* GPLMUX30 */
1, /* GPLMUX31 */
1, /* GPLMUX32 */
1, /* GPLMUX33 */
1, /* GPLMUX34 */
1, /* GPLMUX35 */
1, /* GPLMUX36 */
1, /* GPLMUX37 */
1, /* GPLMUX38 */
1, /* GPLMUX39 */
1, /* GPLMUX40 */
1, /* GPLMUX41 */
1, /* GPLMUX42 */
1, /* GPLMUX43 */
1, /* GPLMUX44 */
1, /* GPLMUX45 */
1, /* GPLMUX46 */
1, /* GPLMUX47 */
1, /* GPLMUX48 */
1, /* GPLMUX49 */
1, /* GPLMUX50 */
1, /* GPLMUX51 */
1, /* GPLMUX52 */
1, /* GPLMUX53 */
1, /* GPLMUX54 */
1, /* GPLMUX55 */
1, /* GPLMUX56 */
1, /* GPLMUX57 */
1, /* GPLMUX58 */
1, /* GPLMUX59 */
1, /* GPLMUX60 */
1, /* GPLMUX61 */
1, /* GPLMUX62 */
1, /* GPLMUX63 */
1, /* GPLMUX64 */
1, /* GPLMUX65 */
1, /* GPLMUX66 */
1, /* GPLMUX67 */
1, /* GPLMUX68 */
1, /* GPLMUX69 */
1, /* GPLMUX70 */
0, /* NANDUSEFPGA */
0, /* UART0USEFPGA */
0, /* RGMII1USEFPGA */
0, /* SPIS0USEFPGA */
0, /* CAN0USEFPGA */
0, /* I2C0USEFPGA */
0, /* SDMMCUSEFPGA */
0, /* QSPIUSEFPGA */
0, /* SPIS1USEFPGA */
0, /* RGMII0USEFPGA */
0, /* UART1USEFPGA */
0, /* CAN1USEFPGA */
0, /* USB1USEFPGA */
0, /* I2C3USEFPGA */
0, /* I2C2USEFPGA */
0, /* I2C1USEFPGA */
0, /* SPIM1USEFPGA */
0, /* USB0USEFPGA */
0 /* SPIM0USEFPGA */
};
|
/*
NetWinder Floating Point Emulator
(c) Rebel.com, 1998-1999
(c) Philip Blundell, 1998-1999
Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "fpa11.h"
#include <linux/module.h>
#include <linux/config.h>
/* XXX */
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/init.h>
/* XXX */
#include "softfloat.h"
#include "fpopcode.h"
#include "fpmodule.h"
#include "fpa11.inl"
/* kernel symbols required for signal handling */
#ifdef CONFIG_FPE_NWFPE_XP
#define NWFPE_BITS "extended"
#else
#define NWFPE_BITS "double"
#endif
#ifdef MODULE
void fp_send_sig(unsigned long sig, struct task_struct *p, int priv);
#else
#define fp_send_sig send_sig
#define kern_fp_enter fp_enter
extern char fpe_type[];
#endif
/* kernel function prototypes required */
void fp_setup(void);
/* external declarations for saved kernel symbols */
extern void (*kern_fp_enter)(void);
extern void (*fp_init)(union fp_state *);
/* Original value of fp_enter from kernel before patched by fpe_init. */
static void (*orig_fp_enter)(void);
static void (*orig_fp_init)(union fp_state *);
/* forward declarations */
extern void nwfpe_enter(void);
static int __init fpe_init(void)
{
if (sizeof(FPA11) > sizeof(union fp_state)) {
printk(KERN_ERR "nwfpe: bad structure size\n");
return -EINVAL;
}
if (sizeof(FPREG) != 12) {
printk(KERN_ERR "nwfpe: bad register size\n");
return -EINVAL;
}
if (fpe_type[0] && strcmp(fpe_type, "nwfpe"))
return 0;
/* Display title, version and copyright information. */
printk(KERN_WARNING "NetWinder Floating Point Emulator V0.97 ("
NWFPE_BITS " precision)\n");
/* Save pointer to the old FP handler and then patch ourselves in */
orig_fp_enter = kern_fp_enter;
orig_fp_init = fp_init;
kern_fp_enter = nwfpe_enter;
fp_init = nwfpe_init_fpa;
return 0;
}
static void __exit fpe_exit(void)
{
/* Restore the values we saved earlier. */
kern_fp_enter = orig_fp_enter;
fp_init = orig_fp_init;
}
/*
ScottB: November 4, 1998
Moved this function out of softfloat-specialize into fpmodule.c.
This effectively isolates all the changes required for integrating with the
Linux kernel into fpmodule.c. Porting to NetBSD should only require modifying
fpmodule.c to integrate with the NetBSD kernel (I hope!).
[1/1/99: Not quite true any more unfortunately. There is Linux-specific
code to access data in user space in some other source files at the
moment (grep for get_user / put_user calls). --philb]
This function is called by the SoftFloat routines to raise a floating
point exception. We check the trap enable byte in the FPSR, and raise
a SIGFPE exception if necessary. If not the relevant bits in the
cumulative exceptions flag byte are set and we return.
*/
void float_raise(signed char flags)
{
register unsigned int fpsr, cumulativeTraps;
#ifdef CONFIG_DEBUG_USER
/* Ignore inexact errors as there are far too many of them to log */
if (flags & ~BIT_IXC)
printk(KERN_DEBUG
"NWFPE: %s[%d] takes exception %08x at %p from %08lx\n",
current->comm, current->pid, flags,
__builtin_return_address(0), GET_USERREG()->ARM_pc);
#endif
/* Read fpsr and initialize the cumulativeTraps. */
fpsr = readFPSR();
cumulativeTraps = 0;
/* For each type of exception, the cumulative trap exception bit is only
set if the corresponding trap enable bit is not set. */
if ((!(fpsr & BIT_IXE)) && (flags & BIT_IXC))
cumulativeTraps |= BIT_IXC;
if ((!(fpsr & BIT_UFE)) && (flags & BIT_UFC))
cumulativeTraps |= BIT_UFC;
if ((!(fpsr & BIT_OFE)) && (flags & BIT_OFC))
cumulativeTraps |= BIT_OFC;
if ((!(fpsr & BIT_DZE)) && (flags & BIT_DZC))
cumulativeTraps |= BIT_DZC;
if ((!(fpsr & BIT_IOE)) && (flags & BIT_IOC))
cumulativeTraps |= BIT_IOC;
/* Set the cumulative exceptions flags. */
if (cumulativeTraps)
writeFPSR(fpsr | cumulativeTraps);
/* Raise an exception if necessary. */
if (fpsr & (flags << 16))
fp_send_sig(SIGFPE, current, 1);
}
module_init(fpe_init);
module_exit(fpe_exit);
MODULE_AUTHOR("Scott Bambrough <scottb@rebel.com>");
MODULE_DESCRIPTION("NWFPE floating point emulator (" NWFPE_BITS " precision)");
MODULE_LICENSE("GPL");
|
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#ifndef __FS_H__
#define __FS_H__
#include "lwip/opt.h"
#include "lwip/err.h"
/** Set this to 1 and provide the functions:
* - "int fs_open_custom(struct fs_file *file, const char *name)"
* Called first for every opened file to allow opening files
* that are not included in fsdata(_custom).c
* - "void fs_close_custom(struct fs_file *file)"
* Called to free resources allocated by fs_open_custom().
*/
#ifndef LWIP_HTTPD_CUSTOM_FILES
#define LWIP_HTTPD_CUSTOM_FILES 0
#endif
/** Set this to 1 to support fs_read() to dynamically read file data.
* Without this (default=off), only one-block files are supported,
* and the contents must be ready after fs_open().
*/
#ifndef LWIP_HTTPD_DYNAMIC_FILE_READ
#define LWIP_HTTPD_DYNAMIC_FILE_READ 0
#endif
/** Set this to 1 to include an application state argument per file
* that is opened. This allows to keep a state per connection/file.
*/
#ifndef LWIP_HTTPD_FILE_STATE
#define LWIP_HTTPD_FILE_STATE 0
#endif
/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for
* predefined (MSS-sized) chunks of the files to prevent having to calculate
* the checksums at runtime. */
#ifndef HTTPD_PRECALCULATED_CHECKSUM
#define HTTPD_PRECALCULATED_CHECKSUM 0
#endif
/** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations
* (fs_read_async returns FS_READ_DELAYED and calls a callback when finished).
*/
#ifndef LWIP_HTTPD_FS_ASYNC_READ
#define LWIP_HTTPD_FS_ASYNC_READ 0
#endif
#define FS_READ_EOF -1
#define FS_READ_DELAYED -2
#if HTTPD_PRECALCULATED_CHECKSUM
struct fsdata_chksum {
u32_t offset;
u16_t chksum;
u16_t len;
};
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
struct fs_file {
const char *data;
int len;
int index;
void *pextension;
#if HTTPD_PRECALCULATED_CHECKSUM
const struct fsdata_chksum *chksum;
u16_t chksum_count;
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
u8_t http_header_included;
#if LWIP_HTTPD_CUSTOM_FILES
u8_t is_custom_file;
#endif /* LWIP_HTTPD_CUSTOM_FILES */
#if LWIP_HTTPD_FILE_STATE
void *state;
#endif /* LWIP_HTTPD_FILE_STATE */
};
#if LWIP_HTTPD_FS_ASYNC_READ
typedef void (*fs_wait_cb)(void *arg);
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
err_t fs_open(struct fs_file *file, const char *name);
void fs_close(struct fs_file *file);
#if LWIP_HTTPD_DYNAMIC_FILE_READ
#if LWIP_HTTPD_FS_ASYNC_READ
int fs_read_async(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg);
#else /* LWIP_HTTPD_FS_ASYNC_READ */
int fs_read(struct fs_file *file, char *buffer, int count);
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
#endif /* LWIP_HTTPD_DYNAMIC_FILE_READ */
#if LWIP_HTTPD_FS_ASYNC_READ
int fs_is_file_ready(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg);
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
int fs_bytes_left(struct fs_file *file);
#if LWIP_HTTPD_FILE_STATE
/** This user-defined function is called when a file is opened. */
void *fs_state_init(struct fs_file *file, const char *name);
/** This user-defined function is called when a file is closed. */
void fs_state_free(struct fs_file *file, void *state);
#endif /* #if LWIP_HTTPD_FILE_STATE */
#endif /* __FS_H__ */
|
/**
* @file BlynkWildFire.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Mar 2015
* @brief
*
*/
#ifndef BlynkWildFire_h
#define BlynkWildFire_h
#ifndef BLYNK_INFO_DEVICE
#define BLYNK_INFO_DEVICE "WildFire"
#endif
#ifndef BLYNK_INFO_CONNECTION
#define BLYNK_INFO_CONNECTION "CC3000"
#endif
#define BLYNK_SEND_ATOMIC
#include <BlynkApiArduino.h>
#include <Blynk/BlynkProtocol.h>
#include <IPAddress.h>
#include <WildFire_CC3000.h>
class BlynkTransportWildFire
{
public:
BlynkTransportWildFire(WildFire_CC3000& cc3000)
: cc3000(cc3000), port(0)
{}
void begin(uint32_t a, uint16_t p) {
port = p;
addr = a;
}
bool connect() {
uint8_t* a = (uint8_t*)&addr;
BLYNK_LOG("Connecting to %d.%d.%d.%d:%d", a[3], a[2], a[1], a[0], port);
client = cc3000.connectTCP(addr, port);
return client.connected();
}
void disconnect() { client.close(); }
size_t read(void* buf, size_t len) {
char* beg = (char*)buf;
char* end = beg + len;
while (beg < end) {
int c = client.read();
if (c < 0)
break;
*beg++ = (char)c;
}
return len;
}
size_t write(const void* buf, size_t len) {
return client.write((const uint8_t*)buf, len);
}
bool connected() { return client.connected(); }
int available() { return client.available(); }
private:
WildFire_CC3000& cc3000;
WildFire_CC3000_Client client;
uint32_t addr;
uint16_t port;
};
class BlynkWildFire
: public BlynkProtocol<BlynkTransportWildFire>
{
typedef BlynkProtocol<BlynkTransportWildFire> Base;
public:
BlynkWildFire(WildFire_CC3000& cc3000, BlynkTransportWildFire& transp)
: Base(transp), cc3000(cc3000)
{}
void connectWiFi(const char* ssid,
const char* pass,
uint8_t secmode)
{
if (!cc3000.begin())
{
BLYNK_FATAL("Couldn't begin()! Check your wiring?");
}
#if !defined(CC3000_TINY_DRIVER) && defined(BLYNK_DEBUG)
uint8_t major, minor;
if(!cc3000.getFirmwareVersion(&major, &minor))
{
if(major != 0x1 || minor < 0x13) {
BLYNK_LOG("CC3000 upgrade needed?");
}
}
#endif
/*if (!cc3000.deleteProfiles())
{
BLYNK_FATAL("Fail deleting old profiles");
}*/
BLYNK_LOG("Connecting to %s...", ssid);
if (!cc3000.connectToAP(ssid, pass, secmode))
{
BLYNK_FATAL("Failed to connect to AP");
}
BLYNK_LOG("Getting IP address...");
while (!cc3000.checkDHCP())
{
::delay(100);
}
#ifdef BLYNK_PRINT
uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
{
BLYNK_FATAL("Unable to get the IP Address");
}
uint8_t* addr = (uint8_t*)&ipAddress;
BLYNK_LOG("IP: %d.%d.%d.%d", addr[3], addr[2], addr[1], addr[0]);
addr = (uint8_t*)&gateway;
BLYNK_LOG("GW: %d.%d.%d.%d", addr[3], addr[2], addr[1], addr[0]);
addr = (uint8_t*)&dnsserv;
BLYNK_LOG("DNS: %d.%d.%d.%d", addr[3], addr[2], addr[1], addr[0]);
#endif
}
void config(const char* auth,
const char* domain = BLYNK_DEFAULT_DOMAIN,
uint16_t port = BLYNK_DEFAULT_PORT)
{
Base::begin(auth);
uint32_t ip = 0;
BLYNK_LOG("Looking for %s", domain);
while (ip == 0) {
if (!cc3000.getHostByName((char*)domain, &ip)) {
BLYNK_LOG("Couldn't locate server");
::delay(500);
}
}
this->conn.begin(ip, port);
}
void config(const char* auth,
IPAddress ip,
uint16_t port = BLYNK_DEFAULT_PORT)
{
Base::begin(auth);
this->conn.begin(cc3000.IP2U32(ip[0],ip[1],ip[2],ip[3]), port);
}
void begin( const char* auth,
const char* ssid,
const char* pass,
uint8_t secmode,
const char* domain = BLYNK_DEFAULT_DOMAIN,
uint16_t port = BLYNK_DEFAULT_PORT)
{
connectWiFi(ssid, pass, secmode);
config(auth, domain, port);
}
void begin( const char* auth,
const char* ssid,
const char* pass,
uint8_t secmode,
IPAddress ip,
uint16_t port = BLYNK_DEFAULT_PORT)
{
connectWiFi(ssid, pass, secmode);
config(auth, ip, port);
}
private:
WildFire_CC3000& cc3000;
};
#endif
|
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QVFBHDR_H
#define QVFBHDR_H
#include <QtGui/qcolor.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qrect.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_QWS_TEMP_DIR
# define QT_QWS_TEMP_DIR QLatin1String("/tmp")
#endif
#ifdef QT_PRIVATE_QWS
#define QT_VFB_DATADIR(DISPLAY) QString::fromLatin1("%1/qtembedded-%2-%3") \
.arg(QT_QWS_TEMP_DIR).arg(getuid()).arg(DISPLAY)
#define QT_VFB_MOUSE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
.append(QLatin1String("/qtvfb_mouse"))
#define QT_VFB_KEYBOARD_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
.append(QLatin1String("/qtvfb_keyboard"))
#define QT_VFB_MAP(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
.append(QLatin1String("/qtvfb_map"))
#define QT_VFB_SOUND_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
.append(QLatin1String("/qt_soundserver"))
#define QTE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
.append(QLatin1String("/QtEmbedded"))
#define QTE_PIPE_QVFB(DISPLAY) QTE_PIPE(DISPLAY)
#else
#define QT_VFB_DATADIR(DISPLAY) QString::fromLatin1("%1/qtembedded-%2") \
.arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
#define QT_VFB_MOUSE_PIPE(DISPLAY) QString::fromLatin1("%1/.qtvfb_mouse-%2") \
.arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
#define QT_VFB_KEYBOARD_PIPE(DISPLAY) QString::fromLatin1("%1/.qtvfb_keyboard-%2") \
.arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
#define QT_VFB_MAP(DISPLAY) QString::fromLatin1("%1/.qtvfb_map-%2") \
.arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
#define QT_VFB_SOUND_PIPE(DISPLAY) QString::fromLatin1("%1/.qt_soundserver-%2") \
.arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
#define QTE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
.append(QLatin1String("/QtEmbedded-%1")).arg(DISPLAY)
#define QTE_PIPE_QVFB(DISPLAY) QTE_PIPE(DISPLAY)
#endif
struct QVFbHeader
{
int width;
int height;
int depth;
int linestep;
int dataoffset;
QRect update;
bool dirty;
int numcols;
QRgb clut[256];
int viewerVersion;
int serverVersion;
int brightness; // since 4.4.0
WId windowId; // since 4.5.0
};
struct QVFbKeyData
{
unsigned int keycode;
Qt::KeyboardModifiers modifiers;
unsigned short int unicode;
bool press;
bool repeat;
};
QT_END_NAMESPACE
QT_END_HEADER
#endif // QVFBHDR_H
|
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#ifndef XDA_H
#define XDA_H
// MOOSE includes
#include "BasicOutput.h"
#include "OversampleOutput.h"
// Forward declearations
class XDA;
template<>
InputParameters validParams<XDA>();
/**
* Class for output data to the XDAII format
*/
class XDA : public BasicOutput<OversampleOutput>
{
public:
/**
* Class consturctor
*/
XDA(const InputParameters & parameters);
protected:
/**
* Overload the Output::output method, this is required for XDA
* output due to the method utlized for outputing single/global parameters
*/
virtual void output(const ExecFlagType & type);
/**
* Returns the current filename, this method handles adding the timestep suffix
* @return A string containg the current filename to be written
*/
std::string filename();
private:
/// Flag for binary output
bool _binary;
};
#endif /* XDA_H */
|
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <i2c.h>
#include <init.h>
#include <misc/byteorder.h>
#include <sensor.h>
#include "mpu6050.h"
/* see "Accelerometer Measurements" section from register map description */
static void mpu6050_convert_accel(struct sensor_value *val, s16_t raw_val,
u16_t sensitivity_shift)
{
s64_t conv_val;
conv_val = ((s64_t)raw_val * SENSOR_G) >> sensitivity_shift;
val->val1 = conv_val / 1000000;
val->val2 = conv_val % 1000000;
}
/* see "Gyroscope Measurements" section from register map description */
static void mpu6050_convert_gyro(struct sensor_value *val, s16_t raw_val,
u16_t sensitivity_x10)
{
s64_t conv_val;
conv_val = ((s64_t)raw_val * SENSOR_PI * 10) /
(180 * sensitivity_x10);
val->val1 = conv_val / 1000000;
val->val2 = conv_val % 1000000;
}
/* see "Temperature Measurement" section from register map description */
static inline void mpu6050_convert_temp(struct sensor_value *val,
s16_t raw_val)
{
val->val1 = raw_val / 340 + 36;
val->val2 = ((s64_t)(raw_val % 340) * 1000000) / 340 + 530000;
if (val->val2 < 0) {
val->val1--;
val->val2 += 1000000;
} else if (val->val2 >= 1000000) {
val->val1++;
val->val2 -= 1000000;
}
}
static int mpu6050_channel_get(struct device *dev,
enum sensor_channel chan,
struct sensor_value *val)
{
struct mpu6050_data *drv_data = dev->driver_data;
switch (chan) {
case SENSOR_CHAN_ACCEL_XYZ:
mpu6050_convert_accel(val, drv_data->accel_x,
drv_data->accel_sensitivity_shift);
mpu6050_convert_accel(val + 1, drv_data->accel_y,
drv_data->accel_sensitivity_shift);
mpu6050_convert_accel(val + 2, drv_data->accel_z,
drv_data->accel_sensitivity_shift);
break;
case SENSOR_CHAN_ACCEL_X:
mpu6050_convert_accel(val, drv_data->accel_x,
drv_data->accel_sensitivity_shift);
break;
case SENSOR_CHAN_ACCEL_Y:
mpu6050_convert_accel(val, drv_data->accel_y,
drv_data->accel_sensitivity_shift);
break;
case SENSOR_CHAN_ACCEL_Z:
mpu6050_convert_accel(val, drv_data->accel_z,
drv_data->accel_sensitivity_shift);
break;
case SENSOR_CHAN_GYRO_XYZ:
mpu6050_convert_gyro(val, drv_data->gyro_x,
drv_data->gyro_sensitivity_x10);
mpu6050_convert_gyro(val + 1, drv_data->gyro_y,
drv_data->gyro_sensitivity_x10);
mpu6050_convert_gyro(val + 2, drv_data->gyro_z,
drv_data->gyro_sensitivity_x10);
break;
case SENSOR_CHAN_GYRO_X:
mpu6050_convert_gyro(val, drv_data->gyro_x,
drv_data->gyro_sensitivity_x10);
break;
case SENSOR_CHAN_GYRO_Y:
mpu6050_convert_gyro(val, drv_data->gyro_y,
drv_data->gyro_sensitivity_x10);
break;
case SENSOR_CHAN_GYRO_Z:
mpu6050_convert_gyro(val, drv_data->gyro_z,
drv_data->gyro_sensitivity_x10);
break;
default: /* chan == SENSOR_CHAN_TEMP */
mpu6050_convert_temp(val, drv_data->temp);
}
return 0;
}
static int mpu6050_sample_fetch(struct device *dev, enum sensor_channel chan)
{
struct mpu6050_data *drv_data = dev->driver_data;
s16_t buf[7];
if (i2c_burst_read(drv_data->i2c, CONFIG_MPU6050_I2C_ADDR,
MPU6050_REG_DATA_START, (u8_t *)buf, 14) < 0) {
SYS_LOG_ERR("Failed to read data sample.");
return -EIO;
}
drv_data->accel_x = sys_be16_to_cpu(buf[0]);
drv_data->accel_y = sys_be16_to_cpu(buf[1]);
drv_data->accel_z = sys_be16_to_cpu(buf[2]);
drv_data->temp = sys_be16_to_cpu(buf[3]);
drv_data->gyro_x = sys_be16_to_cpu(buf[4]);
drv_data->gyro_y = sys_be16_to_cpu(buf[5]);
drv_data->gyro_z = sys_be16_to_cpu(buf[6]);
return 0;
}
static const struct sensor_driver_api mpu6050_driver_api = {
#if CONFIG_MPU6050_TRIGGER
.trigger_set = mpu6050_trigger_set,
#endif
.sample_fetch = mpu6050_sample_fetch,
.channel_get = mpu6050_channel_get,
};
int mpu6050_init(struct device *dev)
{
struct mpu6050_data *drv_data = dev->driver_data;
u8_t id, i;
drv_data->i2c = device_get_binding(CONFIG_MPU6050_I2C_MASTER_DEV_NAME);
if (drv_data->i2c == NULL) {
SYS_LOG_ERR("Failed to get pointer to %s device",
CONFIG_MPU6050_I2C_MASTER_DEV_NAME);
return -EINVAL;
}
/* check chip ID */
if (i2c_reg_read_byte(drv_data->i2c, CONFIG_MPU6050_I2C_ADDR,
MPU6050_REG_CHIP_ID, &id) < 0) {
SYS_LOG_ERR("Failed to read chip ID.");
return -EIO;
}
if (id != MPU6050_CHIP_ID) {
SYS_LOG_ERR("Invalid chip ID.");
return -EINVAL;
}
/* wake up chip */
if (i2c_reg_update_byte(drv_data->i2c, CONFIG_MPU6050_I2C_ADDR,
MPU6050_REG_PWR_MGMT1, MPU6050_SLEEP_EN,
0) < 0) {
SYS_LOG_ERR("Failed to wake up chip.");
return -EIO;
}
/* set accelerometer full-scale range */
for (i = 0; i < 4; i++) {
if (BIT(i+1) == CONFIG_MPU6050_ACCEL_FS) {
break;
}
}
if (i == 4) {
SYS_LOG_ERR("Invalid value for accel full-scale range.");
return -EINVAL;
}
if (i2c_reg_write_byte(drv_data->i2c, CONFIG_MPU6050_I2C_ADDR,
MPU6050_REG_ACCEL_CFG,
i << MPU6050_ACCEL_FS_SHIFT) < 0) {
SYS_LOG_ERR("Failed to write accel full-scale range.");
return -EIO;
}
drv_data->accel_sensitivity_shift = 14 - i;
/* set gyroscope full-scale range */
for (i = 0; i < 4; i++) {
if (BIT(i) * 250 == CONFIG_MPU6050_GYRO_FS) {
break;
}
}
if (i == 4) {
SYS_LOG_ERR("Invalid value for gyro full-scale range.");
return -EINVAL;
}
if (i2c_reg_write_byte(drv_data->i2c, CONFIG_MPU6050_I2C_ADDR,
MPU6050_REG_GYRO_CFG,
i << MPU6050_GYRO_FS_SHIFT) < 0) {
SYS_LOG_ERR("Failed to write gyro full-scale range.");
return -EIO;
}
drv_data->gyro_sensitivity_x10 = mpu6050_gyro_sensitivity_x10[i];
#ifdef CONFIG_MPU6050_TRIGGER
if (mpu6050_init_interrupt(dev) < 0) {
SYS_LOG_DBG("Failed to initialize interrupts.");
return -EIO;
}
#endif
dev->driver_api = &mpu6050_driver_api;
return 0;
}
struct mpu6050_data mpu6050_driver;
DEVICE_INIT(mpu6050, CONFIG_MPU6050_NAME, mpu6050_init, &mpu6050_driver,
NULL, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY);
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prbit_h___
#define prbit_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic
** functions.
*/
#if defined(_WIN32) && (_MSC_VER >= 1300) && \
(defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM))
# include <intrin.h>
# pragma intrinsic(_BitScanForward,_BitScanReverse)
__forceinline static int __prBitScanForward32(unsigned int val)
{
unsigned long idx;
_BitScanForward(&idx, (unsigned long)val);
return( (int)idx );
}
__forceinline static int __prBitScanReverse32(unsigned int val)
{
unsigned long idx;
_BitScanReverse(&idx, (unsigned long)val);
return( (int)(31-idx) );
}
# define pr_bitscan_ctz32(val) __prBitScanForward32(val)
# define pr_bitscan_clz32(val) __prBitScanReverse32(val)
# define PR_HAVE_BUILTIN_BITSCAN32
#elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
(defined(__i386__) || defined(__x86_64__) || defined(__arm__))
# define pr_bitscan_ctz32(val) __builtin_ctz(val)
# define pr_bitscan_clz32(val) __builtin_clz(val)
# define PR_HAVE_BUILTIN_BITSCAN32
#endif /* MSVC || GCC */
/*
** A prbitmap_t is a long integer that can be used for bitmaps
*/
typedef unsigned long prbitmap_t;
#define PR_TEST_BIT(_map,_bit) \
((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] & (1L << ((_bit) & (PR_BITS_PER_LONG-1))))
#define PR_SET_BIT(_map,_bit) \
((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] |= (1L << ((_bit) & (PR_BITS_PER_LONG-1))))
#define PR_CLEAR_BIT(_map,_bit) \
((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] &= ~(1L << ((_bit) & (PR_BITS_PER_LONG-1))))
/*
** Compute the log of the least power of 2 greater than or equal to n
*/
NSPR_API(PRIntn) PR_CeilingLog2(PRUint32 i);
/*
** Compute the log of the greatest power of 2 less than or equal to n
*/
NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i);
/*
** Macro version of PR_CeilingLog2: Compute the log of the least power of
** 2 greater than or equal to _n. The result is returned in _log2.
*/
#ifdef PR_HAVE_BUILTIN_BITSCAN32
#define PR_CEILING_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = (j_ <= 1 ? 0 : 32 - pr_bitscan_clz32(j_ - 1)); \
PR_END_MACRO
#else
#define PR_CEILING_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = 0; \
if ((j_) & ((j_)-1)) \
(_log2) += 1; \
if ((j_) >> 16) \
(_log2) += 16, (j_) >>= 16; \
if ((j_) >> 8) \
(_log2) += 8, (j_) >>= 8; \
if ((j_) >> 4) \
(_log2) += 4, (j_) >>= 4; \
if ((j_) >> 2) \
(_log2) += 2, (j_) >>= 2; \
if ((j_) >> 1) \
(_log2) += 1; \
PR_END_MACRO
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
/*
** Macro version of PR_FloorLog2: Compute the log of the greatest power of
** 2 less than or equal to _n. The result is returned in _log2.
**
** This is equivalent to finding the highest set bit in the word.
*/
#ifdef PR_HAVE_BUILTIN_BITSCAN32
#define PR_FLOOR_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = 31 - pr_bitscan_clz32((j_) | 1); \
PR_END_MACRO
#else
#define PR_FLOOR_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = 0; \
if ((j_) >> 16) \
(_log2) += 16, (j_) >>= 16; \
if ((j_) >> 8) \
(_log2) += 8, (j_) >>= 8; \
if ((j_) >> 4) \
(_log2) += 4, (j_) >>= 4; \
if ((j_) >> 2) \
(_log2) += 2, (j_) >>= 2; \
if ((j_) >> 1) \
(_log2) += 1; \
PR_END_MACRO
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
/*
** Macros for rotate left and right. The argument 'a' must be an unsigned
** 32-bit integer type such as PRUint32.
**
** There is no rotate operation in the C Language, so the construct
** (a << 4) | (a >> 28) is frequently used instead. Most compilers convert
** this to a rotate instruction, but MSVC doesn't without a little help.
** To get MSVC to generate a rotate instruction, we have to use the _rotl
** or _rotr intrinsic and use a pragma to make it inline.
**
** Note: MSVC in VS2005 will do an inline rotate instruction on the above
** construct.
*/
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \
defined(_M_X64) || defined(_M_ARM))
#include <stdlib.h>
#pragma intrinsic(_rotl, _rotr)
#define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)
#define PR_ROTATE_RIGHT32(a, bits) _rotr(a, bits)
#else
#define PR_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits))))
#define PR_ROTATE_RIGHT32(a, bits) (((a) >> (bits)) | ((a) << (32 - (bits))))
#endif
PR_END_EXTERN_C
#endif /* prbit_h___ */
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTIMERINFO_UNIX_P_H
#define QTIMERINFO_UNIX_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/private/qglobal_p.h>
// #define QTIMERINFO_DEBUG
#include "qabstracteventdispatcher.h"
#include <sys/time.h> // struct timeval
QT_BEGIN_NAMESPACE
// internal timer info
struct QTimerInfo {
int id; // - timer identifier
int interval; // - timer interval in milliseconds
Qt::TimerType timerType; // - timer type
timespec timeout; // - when to actually fire
QObject *obj; // - object to receive event
QTimerInfo **activateRef; // - ref from activateTimers
#ifdef QTIMERINFO_DEBUG
timeval expected; // when timer is expected to fire
float cumulativeError;
uint count;
#endif
};
class Q_CORE_EXPORT QTimerInfoList : public QList<QTimerInfo*>
{
#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED)
timespec previousTime;
clock_t previousTicks;
int ticksPerSecond;
int msPerTick;
bool timeChanged(timespec *delta);
void timerRepair(const timespec &);
#endif
// state variables used by activateTimers()
QTimerInfo *firstTimerInfo;
public:
QTimerInfoList();
timespec currentTime;
timespec updateCurrentTime();
// must call updateCurrentTime() first!
void repairTimersIfNeeded();
bool timerWait(timespec &);
void timerInsert(QTimerInfo *);
int timerRemainingTime(int timerId);
void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object);
bool unregisterTimer(int timerId);
bool unregisterTimers(QObject *object);
QList<QAbstractEventDispatcher::TimerInfo> registeredTimers(QObject *object) const;
int activateTimers();
};
QT_END_NAMESPACE
#endif // QTIMERINFO_UNIX_P_H
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
start.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Forrest Yu, 2005
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include "type.h"
#include "const.h"
#include "protect.h"
#include "string.h"
#include "fs.h"
#include "proc.h"
#include "tty.h"
#include "console.h"
#include "global.h"
#include "proto.h"
/*======================================================================*
cstart
*======================================================================*/
PUBLIC void cstart()
{
disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n");
/* 将 LOADER 中的 GDT 复制到新的 GDT 中 */
memcpy( &gdt, /* New GDT */
(void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */
*((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */
);
/* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */
u16* p_gdt_limit = (u16*)(&gdt_ptr[0]);
u32* p_gdt_base = (u32*)(&gdt_ptr[2]);
*p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1;
*p_gdt_base = (u32)&gdt;
/* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */
u16* p_idt_limit = (u16*)(&idt_ptr[0]);
u32* p_idt_base = (u32*)(&idt_ptr[2]);
*p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1;
*p_idt_base = (u32)&idt;
init_prot();
disp_str("-----\"cstart\" finished-----\n");
}
|
/*
* Copyright (C) 2007 Atmel Corporation
*
* See file CREDITS for list of people who contributed to this
* project.
*
* 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 <common.h>
#include <spi.h>
#include <malloc.h>
#include <asm/io.h>
#include <asm/arch/clk.h>
#include <asm/arch/hardware.h>
#include "atmel_spi.h"
void spi_init()
{
}
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
unsigned int max_hz, unsigned int mode)
{
struct atmel_spi_slave *as;
unsigned int scbr;
u32 csrx;
void *regs;
if (!spi_cs_is_valid(bus, cs))
return NULL;
switch (bus) {
case 0:
regs = (void *)ATMEL_BASE_SPI0;
break;
#ifdef ATMEL_BASE_SPI1
case 1:
regs = (void *)ATMEL_BASE_SPI1;
break;
#endif
#ifdef ATMEL_BASE_SPI2
case 2:
regs = (void *)ATMEL_BASE_SPI2;
break;
#endif
#ifdef ATMEL_BASE_SPI3
case 3:
regs = (void *)ATMEL_BASE_SPI3;
break;
#endif
default:
return NULL;
}
scbr = (get_spi_clk_rate(bus) + max_hz - 1) / max_hz;
if (scbr > ATMEL_SPI_CSRx_SCBR_MAX)
/* Too low max SCK rate */
return NULL;
if (scbr < 1)
scbr = 1;
csrx = ATMEL_SPI_CSRx_SCBR(scbr);
csrx |= ATMEL_SPI_CSRx_BITS(ATMEL_SPI_BITS_8);
if (!(mode & SPI_CPHA))
csrx |= ATMEL_SPI_CSRx_NCPHA;
if (mode & SPI_CPOL)
csrx |= ATMEL_SPI_CSRx_CPOL;
as = spi_alloc_slave(struct atmel_spi_slave, bus, cs);
if (!as)
return NULL;
as->regs = regs;
as->mr = ATMEL_SPI_MR_MSTR | ATMEL_SPI_MR_MODFDIS
#if defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9M10G45)
| ATMEL_SPI_MR_WDRBT
#endif
| ATMEL_SPI_MR_PCS(~(1 << cs) & 0xf);
spi_writel(as, CSR(cs), csrx);
return &as->slave;
}
void spi_free_slave(struct spi_slave *slave)
{
struct atmel_spi_slave *as = to_atmel_spi(slave);
free(as);
}
int spi_claim_bus(struct spi_slave *slave)
{
struct atmel_spi_slave *as = to_atmel_spi(slave);
/* Enable the SPI hardware */
spi_writel(as, CR, ATMEL_SPI_CR_SPIEN);
/*
* Select the slave. This should set SCK to the correct
* initial state, etc.
*/
spi_writel(as, MR, as->mr);
return 0;
}
void spi_release_bus(struct spi_slave *slave)
{
struct atmel_spi_slave *as = to_atmel_spi(slave);
/* Disable the SPI hardware */
spi_writel(as, CR, ATMEL_SPI_CR_SPIDIS);
}
int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
{
struct atmel_spi_slave *as = to_atmel_spi(slave);
unsigned int len_tx;
unsigned int len_rx;
unsigned int len;
u32 status;
const u8 *txp = dout;
u8 *rxp = din;
u8 value;
if (bitlen == 0)
/* Finish any previously submitted transfers */
goto out;
/*
* TODO: The controller can do non-multiple-of-8 bit
* transfers, but this driver currently doesn't support it.
*
* It's also not clear how such transfers are supposed to be
* represented as a stream of bytes...this is a limitation of
* the current SPI interface.
*/
if (bitlen % 8) {
/* Errors always terminate an ongoing transfer */
flags |= SPI_XFER_END;
goto out;
}
len = bitlen / 8;
/*
* The controller can do automatic CS control, but it is
* somewhat quirky, and it doesn't really buy us much anyway
* in the context of U-Boot.
*/
if (flags & SPI_XFER_BEGIN) {
spi_cs_activate(slave);
/*
* sometimes the RDR is not empty when we get here,
* in theory that should not happen, but it DOES happen.
* Read it here to be on the safe side.
* That also clears the OVRES flag. Required if the
* following loop exits due to OVRES!
*/
spi_readl(as, RDR);
}
for (len_tx = 0, len_rx = 0; len_rx < len; ) {
status = spi_readl(as, SR);
if (status & ATMEL_SPI_SR_OVRES)
return -1;
if (len_tx < len && (status & ATMEL_SPI_SR_TDRE)) {
if (txp)
value = *txp++;
else
value = 0;
spi_writel(as, TDR, value);
len_tx++;
}
if (status & ATMEL_SPI_SR_RDRF) {
value = spi_readl(as, RDR);
if (rxp)
*rxp++ = value;
len_rx++;
}
}
out:
if (flags & SPI_XFER_END) {
/*
* Wait until the transfer is completely done before
* we deactivate CS.
*/
do {
status = spi_readl(as, SR);
} while (!(status & ATMEL_SPI_SR_TXEMPTY));
spi_cs_deactivate(slave);
}
return 0;
}
|
/*
* Copyright (C) 2004-2010 NXP Software
* Copyright (C) 2010 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.
*/
/**********************************************************************************
INCLUDE FILES
***********************************************************************************/
#include "VectorArithmetic.h"
/**********************************************************************************
FUNCTION LoadConst_32
***********************************************************************************/
void LoadConst_32(const LVM_INT32 val,
LVM_INT32 *dst,
LVM_INT16 n )
{
LVM_INT16 ii;
for (ii = n; ii != 0; ii--)
{
*dst = val;
dst++;
}
return;
}
/**********************************************************************************/
|
#ifndef _LINUX_NAMEI_H
#define _LINUX_NAMEI_H
#include <linux/dcache.h>
#include <linux/linkage.h>
#include <linux/path.h>
struct vfsmount;
struct open_intent {
int flags;
int create_mode;
struct file *file;
};
enum { MAX_NESTED_LINKS = 8 };
struct nameidata {
struct path path;
struct qstr last;
unsigned int flags;
int last_type;
unsigned depth;
char *saved_names[MAX_NESTED_LINKS + 1];
/* Intent data */
union {
struct open_intent open;
} intent;
};
/*
* Type of the last component on LOOKUP_PARENT
*/
enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
/*
* The bitmask for a lookup event:
* - follow links at the end
* - require a directory
* - ending slashes ok even for nonexistent files
* - internal "there are more path compnents" flag
* - locked when lookup done with dcache_lock held
* - dentry cache is untrusted; force a real lookup
*/
#define LOOKUP_FOLLOW 1
#define LOOKUP_DIRECTORY 2
#define LOOKUP_CONTINUE 4
#define LOOKUP_PARENT 16
#define LOOKUP_NOALT 32
#define LOOKUP_REVAL 64
/*
* Intent data
*/
#define LOOKUP_OPEN (0x0100)
#define LOOKUP_CREATE (0x0200)
#define LOOKUP_ACCESS (0x0400)
#define LOOKUP_CHDIR (0x0800)
extern int __user_walk(const char __user *, unsigned, struct nameidata *);
extern int __user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *);
#define user_path_walk(name,nd) \
__user_walk_fd(AT_FDCWD, name, LOOKUP_FOLLOW, nd)
#define user_path_walk_link(name,nd) \
__user_walk_fd(AT_FDCWD, name, 0, nd)
extern int path_lookup(const char *, unsigned, struct nameidata *);
extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
const char *, unsigned int, struct nameidata *);
extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
int (*open)(struct inode *, struct file *));
extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
extern void release_open_intent(struct nameidata *);
extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
extern struct dentry *lookup_one_noperm(const char *, struct dentry *);
extern int follow_down(struct vfsmount **, struct dentry **);
extern int follow_up(struct vfsmount **, struct dentry **);
extern struct dentry *lock_rename(struct dentry *, struct dentry *);
extern void unlock_rename(struct dentry *, struct dentry *);
static inline void nd_set_link(struct nameidata *nd, char *path)
{
nd->saved_names[nd->depth] = path;
}
static inline char *nd_get_link(struct nameidata *nd)
{
return nd->saved_names[nd->depth];
}
#endif /* _LINUX_NAMEI_H */
|
/* UNIX shadow password file access module */
/* A lot of code has been taken from pwdmodule.c */
/* For info also see http://www.unixpapa.com/incnote/passwd.html */
#include "Python.h"
#include "structseq.h"
#include <sys/types.h>
#ifdef HAVE_SHADOW_H
#include <shadow.h>
#endif
PyDoc_STRVAR(spwd__doc__,
"This module provides access to the Unix shadow password database.\n\
It is available on various Unix versions.\n\
\n\
Shadow password database entries are reported as 9-tuples of type struct_spwd,\n\
containing the following items from the password database (see `<shadow.h>'):\n\
sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max, sp_warn, sp_inact, sp_expire, sp_flag.\n\
The sp_namp and sp_pwdp are strings, the rest are integers.\n\
An exception is raised if the entry asked for cannot be found.\n\
You have to be root to be able to use this module.");
#if defined(HAVE_GETSPNAM) || defined(HAVE_GETSPENT)
static PyStructSequence_Field struct_spwd_type_fields[] = {
{"sp_nam", "login name"},
{"sp_pwd", "encrypted password"},
{"sp_lstchg", "date of last change"},
{"sp_min", "min #days between changes"},
{"sp_max", "max #days between changes"},
{"sp_warn", "#days before pw expires to warn user about it"},
{"sp_inact", "#days after pw expires until account is blocked"},
{"sp_expire", "#days since 1970-01-01 until account is disabled"},
{"sp_flag", "reserved"},
{0}
};
PyDoc_STRVAR(struct_spwd__doc__,
"spwd.struct_spwd: Results from getsp*() routines.\n\n\
This object may be accessed either as a 9-tuple of\n\
(sp_nam,sp_pwd,sp_lstchg,sp_min,sp_max,sp_warn,sp_inact,sp_expire,sp_flag)\n\
or via the object attributes as named in the above tuple.");
static PyStructSequence_Desc struct_spwd_type_desc = {
"spwd.struct_spwd",
struct_spwd__doc__,
struct_spwd_type_fields,
9,
};
static int initialized;
static PyTypeObject StructSpwdType;
static void
sets(PyObject *v, int i, char* val)
{
if (val)
PyStructSequence_SET_ITEM(v, i, PyString_FromString(val));
else {
PyStructSequence_SET_ITEM(v, i, Py_None);
Py_INCREF(Py_None);
}
}
static PyObject *mkspent(struct spwd *p)
{
int setIndex = 0;
PyObject *v = PyStructSequence_New(&StructSpwdType);
if (v == NULL)
return NULL;
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
#define SETS(i,val) sets(v, i, val)
SETS(setIndex++, p->sp_namp);
SETS(setIndex++, p->sp_pwdp);
SETI(setIndex++, p->sp_lstchg);
SETI(setIndex++, p->sp_min);
SETI(setIndex++, p->sp_max);
SETI(setIndex++, p->sp_warn);
SETI(setIndex++, p->sp_inact);
SETI(setIndex++, p->sp_expire);
SETI(setIndex++, p->sp_flag);
#undef SETS
#undef SETI
if (PyErr_Occurred()) {
Py_DECREF(v);
return NULL;
}
return v;
}
#endif /* HAVE_GETSPNAM || HAVE_GETSPENT */
#ifdef HAVE_GETSPNAM
PyDoc_STRVAR(spwd_getspnam__doc__,
"getspnam(name) -> (sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max,\n\
sp_warn, sp_inact, sp_expire, sp_flag)\n\
Return the shadow password database entry for the given user name.\n\
See spwd.__doc__ for more on shadow password database entries.");
static PyObject* spwd_getspnam(PyObject *self, PyObject *args)
{
char *name;
struct spwd *p;
if (!PyArg_ParseTuple(args, "s:getspnam", &name))
return NULL;
if ((p = getspnam(name)) == NULL) {
PyErr_SetString(PyExc_KeyError, "getspnam(): name not found");
return NULL;
}
return mkspent(p);
}
#endif /* HAVE_GETSPNAM */
#ifdef HAVE_GETSPENT
PyDoc_STRVAR(spwd_getspall__doc__,
"getspall() -> list_of_entries\n\
Return a list of all available shadow password database entries, \
in arbitrary order.\n\
See spwd.__doc__ for more on shadow password database entries.");
static PyObject *
spwd_getspall(PyObject *self, PyObject *args)
{
PyObject *d;
struct spwd *p;
if ((d = PyList_New(0)) == NULL)
return NULL;
setspent();
while ((p = getspent()) != NULL) {
PyObject *v = mkspent(p);
if (v == NULL || PyList_Append(d, v) != 0) {
Py_XDECREF(v);
Py_DECREF(d);
endspent();
return NULL;
}
Py_DECREF(v);
}
endspent();
return d;
}
#endif /* HAVE_GETSPENT */
static PyMethodDef spwd_methods[] = {
#ifdef HAVE_GETSPNAM
{"getspnam", spwd_getspnam, METH_VARARGS, spwd_getspnam__doc__},
#endif
#ifdef HAVE_GETSPENT
{"getspall", spwd_getspall, METH_NOARGS, spwd_getspall__doc__},
#endif
{NULL, NULL} /* sentinel */
};
PyMODINIT_FUNC
initspwd(void)
{
PyObject *m;
m=Py_InitModule3("spwd", spwd_methods, spwd__doc__);
if (m == NULL)
return;
if (!initialized)
PyStructSequence_InitType(&StructSpwdType,
&struct_spwd_type_desc);
Py_INCREF((PyObject *) &StructSpwdType);
PyModule_AddObject(m, "struct_spwd", (PyObject *) &StructSpwdType);
initialized = 1;
}
|
/* $NetBSD: init.h,v 1.10 2003/08/07 09:05:32 agc Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* 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.
*
* @(#)init.h 8.2 (Berkeley) 5/4/95
*/
void init(void);
void reset(void);
void initshellproc(void);
|
/*
* 'raw' table, which is the very first hooked in at PRE_ROUTING and LOCAL_OUT .
*
* Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
*/
#include <linux/module.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT))
/* Standard entry. */
struct ipt_standard
{
struct ipt_entry entry;
struct ipt_standard_target target;
};
struct ipt_error_target
{
struct ipt_entry_target target;
char errorname[IPT_FUNCTION_MAXNAMELEN];
};
struct ipt_error
{
struct ipt_entry entry;
struct ipt_error_target target;
};
static struct
{
struct ipt_replace repl;
struct ipt_standard entries[2];
struct ipt_error term;
} initial_table __initdata = {
.repl = {
.name = "raw",
.valid_hooks = RAW_VALID_HOOKS,
.num_entries = 3,
.size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error),
.hook_entry = {
[NF_IP_PRE_ROUTING] = 0,
[NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) },
.underflow = {
[NF_IP_PRE_ROUTING] = 0,
[NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) },
},
.entries = {
/* PRE_ROUTING */
{
.entry = {
.target_offset = sizeof(struct ipt_entry),
.next_offset = sizeof(struct ipt_standard),
},
.target = {
.target = {
.u = {
.target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
},
},
.verdict = -NF_ACCEPT - 1,
},
},
/* LOCAL_OUT */
{
.entry = {
.target_offset = sizeof(struct ipt_entry),
.next_offset = sizeof(struct ipt_standard),
},
.target = {
.target = {
.u = {
.target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
},
},
.verdict = -NF_ACCEPT - 1,
},
},
},
/* ERROR */
.term = {
.entry = {
.target_offset = sizeof(struct ipt_entry),
.next_offset = sizeof(struct ipt_error),
},
.target = {
.target = {
.u = {
.user = {
.target_size = IPT_ALIGN(sizeof(struct ipt_error_target)),
.name = IPT_ERROR_TARGET,
},
},
},
.errorname = "ERROR",
},
}
};
static struct ipt_table packet_raw = {
.name = "raw",
.table = &initial_table.repl,
.valid_hooks = RAW_VALID_HOOKS,
.lock = RW_LOCK_UNLOCKED,
.me = THIS_MODULE
};
/* The work comes in here from netfilter.c. */
static unsigned int
ipt_hook(unsigned int hook,
struct sk_buff **pskb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
return ipt_do_table(pskb, hook, in, out, &packet_raw, NULL);
}
/* 'raw' is the very first table. */
static struct nf_hook_ops ipt_ops[] = {
{
.hook = ipt_hook,
.pf = PF_INET,
.hooknum = NF_IP_PRE_ROUTING,
.priority = NF_IP_PRI_RAW
},
{
.hook = ipt_hook,
.pf = PF_INET,
.hooknum = NF_IP_LOCAL_OUT,
.priority = NF_IP_PRI_RAW
},
};
static int __init init(void)
{
int ret;
/* Register table */
ret = ipt_register_table(&packet_raw);
if (ret < 0)
return ret;
/* Register hooks */
ret = nf_register_hook(&ipt_ops[0]);
if (ret < 0)
goto cleanup_table;
ret = nf_register_hook(&ipt_ops[1]);
if (ret < 0)
goto cleanup_hook0;
return ret;
cleanup_hook0:
nf_unregister_hook(&ipt_ops[0]);
cleanup_table:
ipt_unregister_table(&packet_raw);
return ret;
}
static void __exit fini(void)
{
unsigned int i;
for (i = 0; i < sizeof(ipt_ops)/sizeof(struct nf_hook_ops); i++)
nf_unregister_hook(&ipt_ops[i]);
ipt_unregister_table(&packet_raw);
}
module_init(init);
module_exit(fini);
MODULE_LICENSE("GPL");
|
/*
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie control firmware
*
* Copyright (C) 2015 Bitcraze AB
*
* 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, in version 3.
*
* 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/>.
*
* maxSonar.c - Implementation for the MaxSonar MB1040 (LV-MaxSonar-EZ04)
*/
#include <stddef.h>
#include "config.h"
#include "log.h"
#include "maxsonar.h"
#include "deck.h"
#define IN2MM(x) ((x) * 25.4f)
/* Internal tracking of last measured distance. */
static uint32_t maxSonarDistance = 0;
static uint32_t maxSonarAccuracy = 0; /* 0 accuracy means no measurement or unknown accuracy. */
#if defined(MAXSONAR_LOG_ENABLED)
/* Define a log group. */
LOG_GROUP_START(maxSonar)
LOG_ADD(LOG_UINT32, distance, &maxSonarDistance)
LOG_ADD(LOG_UINT32, accuracy, &maxSonarAccuracy)
LOG_GROUP_STOP(maxSonar)
#endif
/**
* Gets the accuracy for a distance measurement from an MB1040 sonar range finder (LV-MaxSonar-EZ4).
*
* @param distance The distance measurement to report the accuracy for (mm).
*
* @return Accuracy in millimeters.
*/
static uint32_t maxSonarGetAccuracyMB1040(uint32_t distance)
{
/* Specify the accuracy of the measurement from the MB1040 (LV-MaxBotix-EZ4) sensor. */
if(distance <= IN2MM(6)) {
/**
* The datasheet for the MB1040 specifies that any distance below 6 inches is reported as 6 inches.
* Since all measurements are given in 1 inch steps, the actual distance can be anything
* from 7 (exclusive) to 0 (inclusive) inches.
*
* The accuracy is therefore set to 7(!) inches.
*/
maxSonarAccuracy = IN2MM(7);
}
else if(distance >= IN2MM(20)) {
/**
* The datasheet for the MB1040 specifies that any distance between 6 and 20 inches may result in
* measurement inaccuracies up to 2 inches.
*/
maxSonarAccuracy = IN2MM(2);
}
else if(distance > IN2MM(254)) {
/**
* The datasheet for the MB1040 specifies that maximum reported distance is 254 inches. If we for
* some reason should measure more than this, set the accuracy to 0.
*/
maxSonarAccuracy = 0;
}
else {
/**
* Otherwise the accuracy is specified by the datasheet for the MB1040 to be 1 inch.
*/
maxSonarAccuracy = IN2MM(1);
}
/* Report accuracy if the caller asked for this. */
return maxSonarAccuracy;
}
/**
* Reads distance measurement from an MB1040 sonar range finder (LV-MaxBotix-EZ4) via an analog input interface.
*
* @param pin The GPIO pin to use for ADC conversion.
* @param accuracy If not NULL, this function will write the accuracy of the distance measurement (in mm) to this parameter.
*
* @return The distance measurement in millimeters.
*/
static uint32_t maxSonarReadDistanceMB1040AN(uint8_t pin, uint32_t *accuracy)
{
/*
* analogRead() returns a 12-bit (0-4095) value scaled to the range between GND (0V) and VREF.
* The voltage conversion is: V = analogRead() / 4096 * VREF)
*
* The MB1040 sensor returns a voltage between GND and VREF, but scaled to VREF / 512 (volts-per-inch).
* Inches-per-volt is therefore expressed by (512 / VREF).
*
* The distance conversion is: D = (512 / VREF) * V
* Expanding V, we get: D = (512 / VREF) * (analogRead() / 4096 * VREF)
* Which can be simplified to: D = analogRead() / 8
* Last, we convert inches to millimeters: D = 25.4 * analogRead() / 8
* Which can be written as: D = IN2MM(analogRead()) / 8
* (to retain the sample's LSB)
*
* The above conversion assumes the ADC VREF is the same as the LV-MaxSonar-EZ4 VREF. This means
* that the MB1040 Sensor must have its VCC pin connected to the VCC pin on the deck port.
*
* According to the datasheet for the MB1040, the sensor draws typically 2mA, so powering it with
* the VCC pin on the deck port is safe.
*/
maxSonarDistance = (uint32_t) (IN2MM(analogRead(pin)) / 8);
if(NULL != accuracy) {
*accuracy = maxSonarGetAccuracyMB1040(maxSonarDistance);
}
return maxSonarDistance;
}
/**
* Reads distance measurement from the specified sensor type.
*
* @param type The MaxSonar sensor type.
* @param accuracy If not NULL, this function will write the accuracy of the distance measurement (in mm) to this parameter.
*
* @return The distance measurement in millimeters.
*/
uint32_t maxSonarReadDistance(maxSonarSensor_t type, uint32_t *accuracy)
{
switch(type) {
case MAXSONAR_MB1040_AN: {
return maxSonarReadDistanceMB1040AN(MAXSONAR_DECK_GPIO, accuracy);
}
}
maxSonarDistance = 0;
maxSonarAccuracy = 0;
if(accuracy) {
*accuracy = maxSonarAccuracy;
}
return(maxSonarDistance);
}
|
/*
* Copyright (c) The Shogun Machine Learning Toolbox
* Written (W) 2016 Fredrik Hallgren
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the Shogun Development Team.
*/
#ifndef _KRRNYSTROM_H__
#define _KRRNYSTROM_H__
#include <shogun/regression/KernelRidgeRegression.h>
namespace shogun {
/** @brief Class KRRNystrom implements the Nyström method for kernel ridge
* regression, using a low-rank approximation to the kernel matrix.
*
* The method is equivalent to ordinary kernel ridge regression, but through
* projecting the data on a subset of the data points, the full
* kernel matrix does not need to be computed, and the resulting system of
* equations for the alphas is cheaper to solve.
*
* Instead of the original linear system, the following approximate system
* is solved
*
* \f[
* {\bf \alpha} = (\tau K_{m,m} + K_{m,n}K_{n,m})^+K_{m,n} {\bf y}
* ]
*
* where \f$K_{n,m}\f$ is a submatrix containing all n rows and the m columns
* corresponding to the m chosen training examples, \f$K_{m,n}\f$ is its
* transpose and \f$K_{m,m} is the submatrix with the m rows and columns
* corresponding to the training examples chosen. \f$+\f$ indicates the
* Moore-Penrose pseudoinverse. The complexity is \f$O(m^2n)\f$.
*
* Several ways to subsample columns/rows have been proposed. Here they are
* subsampled uniformly. To implement another sampling method one has to
* override the method 'subsample_indices'.
*/
class CKRRNystrom : public CKernelRidgeRegression
{
public:
MACHINE_PROBLEM_TYPE(PT_REGRESSION);
/** Default constructor */
CKRRNystrom();
/** Constructor
*
* @param tau regularization parameter tau
* @param m number of rows/columns to choose
* @param k kernel
* @param lab labels
*/
CKRRNystrom(float64_t tau, int32_t m, CKernel* k, CLabels* lab);
/** Default destructor */
virtual ~CKRRNystrom() {}
/** Set the number of columns/rows to choose
*
* @param m new m
*/
inline void set_num_rkhs_basis(int32_t m)
{
m_num_rkhs_basis=m;
if (kernel!=NULL)
{
int32_t n=kernel->get_num_vec_lhs();
REQUIRE(m_num_rkhs_basis<=n, "Number of sampled rows (%d) must be \
less than number of data points (%d)\n", m_num_rkhs_basis, n);
}
};
/** @return object name */
virtual const char* get_name() const { return "KRRNystrom"; }
protected:
/** Train regression using the Nyström method.
*
* @return boolean to indicate success
*/
virtual bool solve_krr_system();
/** Sample indices to pick rows/columns from kernel matrix
*
* @return SGVector<int32_t> with sampled indices
*/
SGVector<int32_t> subsample_indices();
/** Number of columns/rows to be sampled */
int32_t m_num_rkhs_basis;
private:
void init();
};
}
#endif // _KRRNYSTROM_H__
|
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2013 Sanjiban Bairagya <sanjiban22393@gmail.com>
//
#ifndef KMLXTARGETHREFHANDLER_H
#define KMLXTARGETHREFHANDLER_H
#include "GeoTagHandler.h"
namespace Marble
{
namespace kml
{
class KmltargetHrefTagHandler : public GeoTagHandler
{
public:
virtual GeoNode* parse(GeoParser&) const;
};
}
}
#endif
|
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "Function.h"
class MTPiecewiseConst3D : public Function
{
public:
static InputParameters validParams();
MTPiecewiseConst3D(const InputParameters & parameters);
virtual Real value(Real t, const Point & p) const;
};
|
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_FRAMEWORK_OP_GEN_LIB_H_
#define TENSORFLOW_FRAMEWORK_OP_GEN_LIB_H_
#include <string>
#include <unordered_map>
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/env.h"
namespace tensorflow {
// Forward declare protos so their symbols can be removed from .so exports
class OpDef;
class OpGenOverride;
inline string Spaces(int n) { return string(n, ' '); }
// Wrap prefix + str to be at most width characters, indenting every line
// after the first by prefix.size() spaces. Intended use case is something
// like prefix = " Foo(" and str is a list of arguments (terminated by a ")").
// TODO(josh11b): Option to wrap on ", " instead of " " when possible.
string WordWrap(StringPiece prefix, StringPiece str, int width);
// Looks for an "=" at the beginning of *description. If found, strips it off
// (and any following spaces) from *description and return true. Otherwise
// returns false.
bool ConsumeEquals(StringPiece* description);
// Convert text-serialized protobufs to/from multiline format.
string PBTxtToMultiline(StringPiece pbtxt,
const std::vector<string>& multi_line_fields);
string PBTxtFromMultiline(StringPiece multiline_pbtxt);
// Takes a list of files with OpGenOverrides text protos, and allows you to
// look up the specific override for any given op.
class OpGenOverrideMap {
public:
OpGenOverrideMap();
~OpGenOverrideMap();
// `filenames` is a comma-separated list of file names. If an op
// is mentioned in more than one file, the last one takes priority.
Status LoadFileList(Env* env, const string& filenames);
// Load a single file. If more than one file is loaded, later ones
// take priority for any ops in common.
Status LoadFile(Env* env, const string& filename);
// Look up the override for `*op_def` from the loaded files, and
// mutate `*op_def` to reflect the requested changes. Does not apply
// 'skip', 'hide', or 'alias' overrides. Caller has to deal with
// those since they can't be simulated by mutating `*op_def`.
// Returns nullptr if op is not in any loaded file. Otherwise, the
// pointer must not be referenced beyond the lifetime of *this or
// the next file load.
const OpGenOverride* ApplyOverride(OpDef* op_def) const;
private:
std::unordered_map<string, std::unique_ptr<OpGenOverride>> map_;
};
} // namespace tensorflow
#endif // TENSORFLOW_FRAMEWORK_OP_GEN_LIB_H_
|
/**
* WinPR: Windows Portable Runtime
* Serial Communication API
*
* Copyright 2014 Hewlett-Packard Development Company, L.P.
*
* 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 <stdio.h>
#include <sys/stat.h>
#ifndef _WIN32
#include <termios.h>
#endif
#include <winpr/comm.h>
#include <winpr/crt.h>
#include "../comm.h"
static BOOL test_generic(HANDLE hComm)
{
COMMTIMEOUTS timeouts, timeouts2;
timeouts.ReadIntervalTimeout = 1;
timeouts.ReadTotalTimeoutMultiplier = 2;
timeouts.ReadTotalTimeoutConstant = 3;
timeouts.WriteTotalTimeoutMultiplier = 4;
timeouts.WriteTotalTimeoutConstant = 5;
if (!SetCommTimeouts(hComm, &timeouts))
{
fprintf(stderr, "SetCommTimeouts failure, GetLastError: 0x%08x\n", GetLastError());
return FALSE;
}
ZeroMemory(&timeouts2, sizeof(COMMTIMEOUTS));
if (!GetCommTimeouts(hComm, &timeouts2))
{
fprintf(stderr, "GetCommTimeouts failure, GetLastError: 0x%08x\n", GetLastError());
return FALSE;
}
if (memcmp(&timeouts, &timeouts2, sizeof(COMMTIMEOUTS)) != 0)
{
fprintf(stderr, "TestTimeouts failure, didn't get back the same timeouts.\n");
return FALSE;
}
/* not supported combination */
timeouts.ReadIntervalTimeout = MAXULONG;
timeouts.ReadTotalTimeoutConstant = MAXULONG;
if (SetCommTimeouts(hComm, &timeouts))
{
fprintf(stderr,
"SetCommTimeouts succeeded with ReadIntervalTimeout and ReadTotalTimeoutConstant "
"set to MAXULONG. GetLastError: 0x%08x\n",
GetLastError());
return FALSE;
}
if (GetLastError() != ERROR_INVALID_PARAMETER)
{
fprintf(stderr,
"SetCommTimeouts failure, expected GetLastError to return ERROR_INVALID_PARAMETER "
"and got: 0x%08x\n",
GetLastError());
return FALSE;
}
return TRUE;
}
int TestTimeouts(int argc, char* argv[])
{
struct stat statbuf;
BOOL result;
HANDLE hComm;
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
result = DefineCommDevice("COM1", "/dev/ttyS0");
if (!result)
{
fprintf(stderr, "DefineCommDevice failure: 0x%x\n", GetLastError());
return EXIT_FAILURE;
}
hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
return EXIT_FAILURE;
}
_comm_setServerSerialDriver(hComm, SerialDriverSerialSys);
if (!test_generic(hComm))
{
fprintf(stderr, "test_SerialSys failure\n");
return EXIT_FAILURE;
}
_comm_setServerSerialDriver(hComm, SerialDriverSerCxSys);
if (!test_generic(hComm))
{
fprintf(stderr, "test_SerCxSys failure\n");
return EXIT_FAILURE;
}
_comm_setServerSerialDriver(hComm, SerialDriverSerCx2Sys);
if (!test_generic(hComm))
{
fprintf(stderr, "test_SerCx2Sys failure\n");
return EXIT_FAILURE;
}
if (!CloseHandle(hComm))
{
fprintf(stderr, "CloseHandle failure, GetLastError()=%08x\n", GetLastError());
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
|
//
// NSDictionary+Merge.h
// IOS-Categories
//
// Created by Jakey on 15/1/25.
// Copyright (c) 2015年 www.skyfox.org. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSDictionary (Merge)
+ (NSDictionary *)dictionaryByMerging:(NSDictionary *)dict1 with:(NSDictionary *)dict2;
- (NSDictionary *)dictionaryByMergingWith:(NSDictionary *)dict;
@end
|
/* Copyright (C) 2011-2014 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef COMMON_LINUX_PTRACE_H
#define COMMON_LINUX_PTRACE_H
struct buffer;
#include <sys/ptrace.h>
#ifdef __UCLIBC__
#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
/* PTRACE_TEXT_ADDR and friends. */
#include <asm/ptrace.h>
#define HAS_NOMMU
#endif
#endif
#if !defined(PTRACE_TYPE_ARG3)
#define PTRACE_TYPE_ARG3 void *
#endif
#if !defined(PTRACE_TYPE_ARG4)
#define PTRACE_TYPE_ARG4 void *
#endif
#ifndef PTRACE_GETSIGINFO
# define PTRACE_GETSIGINFO 0x4202
# define PTRACE_SETSIGINFO 0x4203
#endif /* PTRACE_GETSIGINF */
/* If the system headers did not provide the constants, hard-code the normal
values. */
#ifndef PTRACE_EVENT_FORK
#define PTRACE_SETOPTIONS 0x4200
#define PTRACE_GETEVENTMSG 0x4201
/* options set using PTRACE_SETOPTIONS */
#define PTRACE_O_TRACESYSGOOD 0x00000001
#define PTRACE_O_TRACEFORK 0x00000002
#define PTRACE_O_TRACEVFORK 0x00000004
#define PTRACE_O_TRACECLONE 0x00000008
#define PTRACE_O_TRACEEXEC 0x00000010
#define PTRACE_O_TRACEVFORKDONE 0x00000020
#define PTRACE_O_TRACEEXIT 0x00000040
/* Wait extended result codes for the above trace options. */
#define PTRACE_EVENT_FORK 1
#define PTRACE_EVENT_VFORK 2
#define PTRACE_EVENT_CLONE 3
#define PTRACE_EVENT_EXEC 4
#define PTRACE_EVENT_VFORK_DONE 5
#define PTRACE_EVENT_EXIT 6
#endif /* PTRACE_EVENT_FORK */
#if (defined __bfin__ || defined __frv__ || defined __sh__) \
&& !defined PTRACE_GETFDPIC
#define PTRACE_GETFDPIC 31
#define PTRACE_GETFDPIC_EXEC 0
#define PTRACE_GETFDPIC_INTERP 1
#endif
/* We can't always assume that this flag is available, but all systems
with the ptrace event handlers also have __WALL, so it's safe to use
in some contexts. */
#ifndef __WALL
#define __WALL 0x40000000 /* Wait for any child. */
#endif
extern void linux_ptrace_attach_warnings (pid_t pid, struct buffer *buffer);
extern void linux_ptrace_init_warnings (void);
extern void linux_enable_event_reporting (pid_t pid);
extern int linux_supports_tracefork (void);
extern int linux_supports_traceclone (void);
extern int linux_supports_tracevforkdone (void);
extern int linux_supports_tracesysgood (void);
#endif /* COMMON_LINUX_PTRACE_H */
|
#ifndef __BACKPORT_BYTEORDER_GENERIC_H
#define __BACKPORT_BYTEORDER_GENERIC_H
#include_next <linux/byteorder/generic.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
/* The patch:
* commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865
* Author: Marcin Slusarz <marcin.slusarz@gmail.com>
* Date: Fri Feb 8 04:20:12 2008 -0800
*
* byteorder: move le32_add_cpu & friends from OCFS2 to core
*
* moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core
* header (1st) and converted some existing code to it. We port
* it here as later kernels will most likely use it.
*/
static inline void le16_add_cpu(__le16 *var, u16 val)
{
*var = cpu_to_le16(le16_to_cpu(*var) + val);
}
static inline void le32_add_cpu(__le32 *var, u32 val)
{
*var = cpu_to_le32(le32_to_cpu(*var) + val);
}
static inline void le64_add_cpu(__le64 *var, u64 val)
{
*var = cpu_to_le64(le64_to_cpu(*var) + val);
}
static inline void be16_add_cpu(__be16 *var, u16 val)
{
u16 v = be16_to_cpu(*var);
*var = cpu_to_be16(v + val);
}
static inline void be32_add_cpu(__be32 *var, u32 val)
{
u32 v = be32_to_cpu(*var);
*var = cpu_to_be32(v + val);
}
static inline void be64_add_cpu(__be64 *var, u64 val)
{
u64 v = be64_to_cpu(*var);
*var = cpu_to_be64(v + val);
}
#endif
#endif /* __BACKPORT_BYTEORDER_GENERIC_H */
|
#ifndef ANT_H_BRIDGE_H
#define ANT_H_BRIDGE_H
#include "std.h"
void ant_h_bridge_init( void );
void ant_h_bridge_set ( int16_t value);
#endif /* ANT_H_BRIDGE_H */
|
/*
* This file is part of Cleanflight and Betaflight.
*
* Cleanflight and Betaflight are free software. You can redistribute
* this software and/or modify this software 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 and Betaflight are distributed in the hope that they
* 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 software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifdef USE_VTX_TABLE
#include <stdint.h>
#include <stdbool.h>
#include "pg/pg.h"
#include "drivers/vtx_table.h"
typedef struct vtxTableConfig_s {
uint8_t bands;
uint8_t channels;
uint16_t frequency[VTX_TABLE_MAX_BANDS][VTX_TABLE_MAX_CHANNELS];
char bandNames[VTX_TABLE_MAX_BANDS][VTX_TABLE_BAND_NAME_LENGTH + 1];
char bandLetters[VTX_TABLE_MAX_BANDS];
char channelNames[VTX_TABLE_MAX_CHANNELS][VTX_TABLE_CHANNEL_NAME_LENGTH + 1];
bool isFactoryBand[VTX_TABLE_MAX_BANDS];
uint8_t powerLevels;
uint16_t powerValues[VTX_TABLE_MAX_POWER_LEVELS];
char powerLabels[VTX_TABLE_MAX_POWER_LEVELS][VTX_TABLE_POWER_LABEL_LENGTH + 1];
} vtxTableConfig_t;
struct vtxTableConfig_s;
PG_DECLARE(struct vtxTableConfig_s, vtxTableConfig);
#endif
|
/*
* Copyright (C) 1997 Martin Jones (mjones@kde.org)
* (C) 1997 Torben Weis (weis@kde.org)
* (C) 1998 Waldo Bastian (bastian@kde.org)
* (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef RenderTableSection_h
#define RenderTableSection_h
#include "RenderTable.h"
#include <wtf/Vector.h>
namespace WebCore {
class RenderTableCell;
class RenderTableRow;
class RenderTableSection : public RenderBox {
public:
RenderTableSection(Node*);
virtual ~RenderTableSection();
const RenderObjectChildList* children() const { return &m_children; }
RenderObjectChildList* children() { return &m_children; }
virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
virtual int firstLineBoxBaseline() const;
void addCell(RenderTableCell*, RenderTableRow* row);
void setCellWidths();
int calcRowHeight();
int layoutRows(int height);
RenderTable* table() const { return toRenderTable(parent()); }
struct CellStruct {
RenderTableCell* cell;
bool inColSpan; // true for columns after the first in a colspan
};
typedef Vector<CellStruct> Row;
struct RowStruct {
Row* row;
RenderTableRow* rowRenderer;
int baseline;
Length height;
};
CellStruct& cellAt(int row, int col) { return (*m_grid[row].row)[col]; }
const CellStruct& cellAt(int row, int col) const { return (*m_grid[row].row)[col]; }
void appendColumn(int pos);
void splitColumn(int pos, int newSize);
int calcOuterBorderTop() const;
int calcOuterBorderBottom() const;
int calcOuterBorderLeft(bool rtl) const;
int calcOuterBorderRight(bool rtl) const;
void recalcOuterBorder();
int outerBorderTop() const { return m_outerBorderTop; }
int outerBorderBottom() const { return m_outerBorderBottom; }
int outerBorderLeft() const { return m_outerBorderLeft; }
int outerBorderRight() const { return m_outerBorderRight; }
int numRows() const { return m_gridRows; }
int numColumns() const;
void recalcCells();
void recalcCellsIfNeeded()
{
if (m_needsCellRecalc)
recalcCells();
}
bool needsCellRecalc() const { return m_needsCellRecalc; }
void setNeedsCellRecalc()
{
m_needsCellRecalc = true;
table()->setNeedsSectionRecalc();
}
int getBaseline(int row) { return m_grid[row].baseline; }
private:
virtual RenderObjectChildList* virtualChildren() { return children(); }
virtual const RenderObjectChildList* virtualChildren() const { return children(); }
virtual const char* renderName() const { return isAnonymous() ? "RenderTableSection (anonymous)" : "RenderTableSection"; }
virtual bool isTableSection() const { return true; }
virtual void destroy();
virtual void layout();
virtual void removeChild(RenderObject* oldChild);
virtual int lowestPosition(bool includeOverflowInterior, bool includeSelf) const;
virtual int rightmostPosition(bool includeOverflowInterior, bool includeSelf) const;
virtual int leftmostPosition(bool includeOverflowInterior, bool includeSelf) const;
virtual void paint(PaintInfo&, int tx, int ty);
virtual void paintObject(PaintInfo&, int tx, int ty);
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
virtual int lineHeight(bool, bool) const { return 0; }
bool ensureRows(int);
void clearGrid();
RenderObjectChildList m_children;
Vector<RowStruct> m_grid;
Vector<int> m_rowPos;
int m_gridRows;
// the current insertion position
int m_cCol;
int m_cRow;
int m_outerBorderLeft;
int m_outerBorderRight;
int m_outerBorderTop;
int m_outerBorderBottom;
bool m_needsCellRecalc;
bool m_hasOverflowingCell;
};
inline RenderTableSection* toRenderTableSection(RenderObject* object)
{
ASSERT(!object || object->isTableSection());
return static_cast<RenderTableSection*>(object);
}
inline const RenderTableSection* toRenderTableSection(const RenderObject* object)
{
ASSERT(!object || object->isTableSection());
return static_cast<const RenderTableSection*>(object);
}
// This will catch anyone doing an unnecessary cast.
void toRenderTableSection(const RenderTableSection*);
} // namespace WebCore
#endif // RenderTableSection_h
|
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "MooseError.h"
#include "MooseTypes.h"
#include "ADReal.h"
#include "libmesh/fparser_ad.hh"
class ADFParser : public FunctionParserAD
{
public:
ADFParser();
ADFParser(const ADFParser & cpy);
bool JITCompile();
Real Eval(const Real *) { mooseError("Not implemented."); }
ADReal Eval(const ADReal * Vars);
protected:
const Real _epsilon;
};
|
/*****************************************************************************
* x264_encode_status_window.h: h264 gtk encoder frontend
*****************************************************************************
* Copyright (C) 2006 Vincent Torri
*
* 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 02111, USA.
*****************************************************************************/
#ifndef X264_GTK_ENCODE_STATUS_WINDOW_H
#define X264_GTK_ENCODE_STATUS_WINDOW_H
GtkWidget *x264_gtk_encode_status_window (X264_Thread_Data *thread_data);
#endif /* X264_GTK_ENCODE_STATUS_WINDOW_H */
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_COMMON_API_SOCKETS_SOCKETS_MANIFEST_DATA_H_
#define EXTENSIONS_COMMON_API_SOCKETS_SOCKETS_MANIFEST_DATA_H_
#include <vector>
#include "base/strings/string16.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handler.h"
namespace content {
struct SocketPermissionRequest;
}
namespace extensions {
class SocketsManifestPermission;
}
namespace extensions {
// The parsed form of the "sockets" manifest entry.
class SocketsManifestData : public Extension::ManifestData {
public:
explicit SocketsManifestData(
std::unique_ptr<SocketsManifestPermission> permission);
~SocketsManifestData() override;
// Gets the SocketsManifestData for |extension|, or NULL if none was
// specified.
static SocketsManifestData* Get(const Extension* extension);
static bool CheckRequest(const Extension* extension,
const content::SocketPermissionRequest& request);
// Tries to construct the info based on |value|, as it would have appeared in
// the manifest. Sets |error| and returns an empty scoped_ptr on failure.
static std::unique_ptr<SocketsManifestData> FromValue(
const base::Value& value,
base::string16* error);
const SocketsManifestPermission* permission() const {
return permission_.get();
}
private:
std::unique_ptr<SocketsManifestPermission> permission_;
};
} // namespace extensions
#endif // EXTENSIONS_COMMON_API_SOCKETS_SOCKETS_MANIFEST_DATA_H_
|
/*===
*** test_1 (duk_safe_call)
this binding: 'undefined'
result=33
final top: 0
==> rc=0, result='undefined'
*** test_2 (duk_safe_call)
this binding: 'undefined'
==> rc=1, result='TypeError: argument 2 is not a number'
===*/
static duk_ret_t my_adder(duk_context *ctx) {
duk_idx_t i, n;
double res = 0.0;
duk_push_this(ctx);
printf("this binding: '%s'\n", duk_to_string(ctx, -1));
duk_pop(ctx);
n = duk_get_top(ctx);
for (i = 0; i < n; i++) {
if (!duk_is_number(ctx, i)) {
duk_error(ctx, DUK_ERR_TYPE_ERROR, "argument %ld is not a number", (long) i);
}
res += duk_get_number(ctx, i);
}
duk_push_number(ctx, res);
return 1;
}
static duk_ret_t test_1(duk_context *ctx) {
duk_set_top(ctx, 0);
duk_push_c_function(ctx, my_adder, 3 /*nargs*/);
duk_push_int(ctx, 10);
duk_push_int(ctx, 11);
duk_push_int(ctx, 12);
duk_push_int(ctx, 13); /* clipped */
duk_push_int(ctx, 14); /* clipped */
duk_call(ctx, 5);
printf("result=%s\n", duk_to_string(ctx, -1));
duk_pop(ctx);
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
static duk_ret_t test_2(duk_context *ctx) {
duk_set_top(ctx, 0);
duk_push_c_function(ctx, my_adder, 3 /*nargs*/);
duk_push_int(ctx, 10);
duk_push_int(ctx, 11);
duk_push_string(ctx, "foo"); /* causes error */
duk_push_int(ctx, 13); /* clipped */
duk_push_int(ctx, 14); /* clipped */
duk_call(ctx, 5);
printf("result=%s\n", duk_to_string(ctx, -1));
duk_pop(ctx);
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
void test(duk_context *ctx) {
TEST_SAFE_CALL(test_1);
TEST_SAFE_CALL(test_2);
}
|
/* Copyright (c) 2011, 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 DIAGFWD_SDIO_H
#define DIAGFWD_SDIO_H
#include <mach/sdio_al.h>
#define N_MDM_WRITE 2 /* Upgrade to 2 with ping pong buffer */
#define N_MDM_READ 1
extern int sdio_diag_initialized;
void diagfwd_sdio_init(const char *);
void diagfwd_sdio_exit(void);
int diagfwd_connect_sdio(void);
int diagfwd_disconnect_sdio(void);
int diagfwd_read_complete_sdio(void);
int diagfwd_write_complete_sdio(void);
#endif
|
/******************************************************************************
Copyright (C) 2014 by Zachary Lund <admin@computerquip.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#include "gl-nix.h"
const struct gl_winsys_vtable *gl_x11_glx_get_winsys_vtable(void);
|
/*--------------------------------------------------------------------*/
/*--- Address space manager. pub_tool_aspacemgr.h ---*/
/*--------------------------------------------------------------------*/
/*
This file is part of Valgrind, a dynamic binary instrumentation
framework.
Copyright (C) 2000-2012 Julian Seward
jseward@acm.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA.
The GNU General Public License is contained in the file COPYING.
*/
#ifndef __PUB_TOOL_ASPACEMGR_H
#define __PUB_TOOL_ASPACEMGR_H
//--------------------------------------------------------------
// Definition of address-space segments
/* Describes segment kinds. */
typedef
enum {
SkFree, // unmapped space
SkAnonC, // anonymous mapping belonging to the client
SkAnonV, // anonymous mapping belonging to valgrind
SkFileC, // file mapping belonging to the client
SkFileV, // file mapping belonging to valgrind
SkShmC, // shared memory segment belonging to the client
SkResvn // reservation
}
SegKind;
/* Describes how a reservation segment can be resized. */
typedef
enum {
SmLower, // lower end can move up
SmFixed, // cannot be shrunk
SmUpper // upper end can move down
}
ShrinkMode;
/* Describes a segment. Invariants:
kind == SkFree:
// the only meaningful fields are .start and .end
kind == SkAnon{C,V}:
// smode==SmFixed
// there's no associated file:
dev==ino==foff = 0, fnidx == -1
// segment may have permissions
kind == SkFile{C,V}:
// smode==SmFixed
moveLo == moveHi == NotMovable, maxlen == 0
// there is an associated file
// segment may have permissions
kind == SkShmC:
// smode==SmFixed
// there's no associated file:
dev==ino==foff = 0, fnidx == -1
// segment may have permissions
kind == SkResvn
// the segment may be resized if required
// there's no associated file:
dev==ino==foff = 0, fnidx == -1
// segment has no permissions
hasR==hasW==hasX==anyTranslated == False
Also: anyTranslated==True is only allowed in SkFileV and SkAnonV
(viz, not allowed to make translations from non-client areas)
*/
typedef
struct {
SegKind kind;
/* Extent (SkFree, SkAnon{C,V}, SkFile{C,V}, SkResvn) */
Addr start; // lowest address in range
Addr end; // highest address in range
/* Shrinkable? (SkResvn only) */
ShrinkMode smode;
/* Associated file (SkFile{C,V} only) */
ULong dev;
ULong ino;
Off64T offset;
UInt mode;
Int fnIdx; // file name table index, if name is known
/* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
Bool hasR;
Bool hasW;
Bool hasX;
Bool hasT; // True --> translations have (or MAY have)
// been taken from this segment
Bool isCH; // True --> is client heap (SkAnonC ONLY)
/* Admin */
Bool mark;
}
NSegment;
/* Collect up the start addresses of all non-free, non-resvn segments.
The interface is a bit strange in order to avoid potential
segment-creation races caused by dynamic allocation of the result
buffer *starts.
The function first computes how many entries in the result
buffer *starts will be needed. If this number <= nStarts,
they are placed in starts[0..], and the number is returned.
If nStarts is not large enough, nothing is written to
starts[0..], and the negation of the size is returned.
Correct use of this function may mean calling it multiple times in
order to establish a suitably-sized buffer. */
extern Int VG_(am_get_segment_starts)( Addr* starts, Int nStarts );
// See pub_core_aspacemgr.h for description.
extern NSegment const * VG_(am_find_nsegment) ( Addr a );
// See pub_core_aspacemgr.h for description.
extern HChar* VG_(am_get_filename)( NSegment const * );
// See pub_core_aspacemgr.h for description.
extern Bool VG_(am_is_valid_for_client) ( Addr start, SizeT len,
UInt prot );
// See pub_core_aspacemgr.h for description.
/* Really just a wrapper around VG_(am_mmap_anon_float_valgrind). */
extern void* VG_(am_shadow_alloc)(SizeT size);
/* Unmap the given address range and update the segment array
accordingly. This fails if the range isn't valid for valgrind. */
extern SysRes VG_(am_munmap_valgrind)( Addr start, SizeT length );
#endif // __PUB_TOOL_ASPACEMGR_H
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
|
/*
* $Id$
*
* Various lcr related constant, types, and external variables
*
* Copyright (C) 2005-2014 Juha Heinanen
*
* This file is part of SIP Router, a free SIP server.
*
* SIP Router 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
*
* SIP Router is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
* 2005-02-06: created by jh
*/
/*!
* \file
* \brief SIP-router lcr :: Various LCR related constant, types, and external variables
* \ingroup lcr
* Module: \ref lcr
*/
#ifndef LCR_MOD_H
#define LCR_MOD_H
#include <stdio.h>
#include <pcre.h>
#include "../../lib/kmi/mi.h"
#include "../../locking.h"
#include "../../parser/parse_uri.h"
#include "../../ip_addr.h"
#define MAX_PREFIX_LEN 16
#define MAX_URI_LEN 256
#define MAX_HOST_LEN 64
#define MAX_NO_OF_GWS 128
#define MAX_NAME_LEN 128
#define MAX_TAG_LEN 64
#define MAX_USER_LEN 64
#define MAX_PARAMS_LEN 64
#define MAX_NO_OF_REPLY_CODES 15
typedef enum sip_protos uri_transport;
struct rule_info {
unsigned int rule_id;
char prefix[MAX_PREFIX_LEN];
unsigned short prefix_len;
char from_uri[MAX_URI_LEN + 1];
unsigned short from_uri_len;
pcre *from_uri_re;
char request_uri[MAX_URI_LEN + 1];
unsigned short request_uri_len;
pcre *request_uri_re;
unsigned short stopper;
unsigned int enabled;
struct target *targets;
struct rule_info *next;
};
struct rule_id_info {
unsigned int rule_id;
struct rule_info *rule_addr;
struct rule_id_info *next;
};
struct target {
unsigned short gw_index;
unsigned short priority;
unsigned short weight;
struct target *next;
};
struct instance {
unsigned short instance_id;
struct instance *next;
};
/* gw states */
/* if state > GW_INACTIVE has not yet reached failure threshold */
#define GW_ACTIVE 0
#define GW_PINGING 1
#define GW_INACTIVE 2
struct gw_info {
unsigned int gw_id;
char gw_name[MAX_NAME_LEN];
unsigned short gw_name_len;
char scheme[5];
unsigned short scheme_len;
struct ip_addr ip_addr;
char hostname[MAX_HOST_LEN];
unsigned short hostname_len;
unsigned int port;
uri_transport transport_code;
char transport[15];
unsigned int transport_len;
char params[MAX_PARAMS_LEN];
unsigned short params_len;
unsigned int strip;
char prefix[MAX_PREFIX_LEN];
unsigned short prefix_len;
char tag[MAX_TAG_LEN];
unsigned short tag_len;
unsigned int flags;
unsigned short state;
char uri[MAX_URI_LEN];
unsigned short uri_len;
unsigned int defunct_until;
};
extern unsigned int lcr_rule_hash_size_param;
extern unsigned int lcr_count_param;
extern gen_lock_t *reload_lock;
extern struct gw_info **gw_pt;
extern struct rule_info ***rule_pt;
extern struct rule_id_info **rule_id_hash_table;
extern int reload_tables();
extern int rpc_defunct_gw(unsigned int, unsigned int, unsigned int);
#endif /* LCR_MOD_H */
|
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//
// head.h: Rcpp R/C++ interface class library -- head
//
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
// Rcpp 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.
//
// Rcpp 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 Rcpp. If not, see <http://www.gnu.org/licenses/>.
#ifndef Rcpp__sugar__head_h
#define Rcpp__sugar__head_h
namespace Rcpp{
namespace sugar{
template <int RTYPE, bool NA, typename T>
class Head : public Rcpp::VectorBase< RTYPE ,NA, Head<RTYPE,NA,T> > {
public:
typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
Head( const VEC_TYPE& object_, int n_ ) : object(object_), n(n_) {
if( n < 0 ){
n = object.size() + n ;
}
}
inline STORAGE operator[]( int i ) const {
return object[ i ] ;
}
inline int size() const { return n; }
private:
const VEC_TYPE& object ;
int n ;
} ;
} // sugar
template <int RTYPE,bool NA, typename T>
inline sugar::Head<RTYPE,NA,T> head(
const VectorBase<RTYPE,NA,T>& t,
int n
){
return sugar::Head<RTYPE,NA,T>( t, n ) ;
}
} // Rcpp
#endif
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QIMAGEPIXMAP_CLEANUPHOOKS_P_H
#define QIMAGEPIXMAP_CLEANUPHOOKS_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtGui/qpixmap.h>
QT_BEGIN_NAMESPACE
typedef void (*_qt_image_cleanup_hook_64)(qint64);
typedef void (*_qt_pixmap_cleanup_hook_pmd)(QPlatformPixmap*);
class QImagePixmapCleanupHooks;
class Q_GUI_EXPORT QImagePixmapCleanupHooks
{
public:
static QImagePixmapCleanupHooks *instance();
static void enableCleanupHooks(const QImage &image);
static void enableCleanupHooks(const QPixmap &pixmap);
static void enableCleanupHooks(QPlatformPixmap *handle);
static bool isImageCached(const QImage &image);
static bool isPixmapCached(const QPixmap &pixmap);
// Gets called when a pixmap data is about to be modified:
void addPlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd);
// Gets called when a pixmap data is about to be destroyed:
void addPlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd);
// Gets called when an image is about to be modified or destroyed:
void addImageHook(_qt_image_cleanup_hook_64);
void removePlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd);
void removePlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd);
void removeImageHook(_qt_image_cleanup_hook_64);
static void executePlatformPixmapModificationHooks(QPlatformPixmap*);
static void executePlatformPixmapDestructionHooks(QPlatformPixmap*);
static void executeImageHooks(qint64 key);
private:
QList<_qt_image_cleanup_hook_64> imageHooks;
QList<_qt_pixmap_cleanup_hook_pmd> pixmapModificationHooks;
QList<_qt_pixmap_cleanup_hook_pmd> pixmapDestructionHooks;
};
QT_END_NAMESPACE
#endif // QIMAGEPIXMAP_CLEANUPHOOKS_P_H
|
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
/*
* blockimport.c
* testObjects
*
* Created by Blaine Garst on 10/13/08.
*
*/
//
// pure C nothing more needed
// CONFIG rdar://6289344
#include <stdio.h>
#include <Block.h>
#include <Block_private.h>
int main(int argc, char *argv[]) {
int i = 1;
int (^intblock)(void) = ^{ return i*10; };
void (^vv)(void) = ^{
if (argc > 0) {
printf("intblock returns %d\n", intblock());
}
};
#if 0
//printf("Block dump %s\n", _Block_dump(vv));
{
struct Block_layout *layout = (struct Block_layout *)(void *)vv;
printf("isa %p\n", layout->isa);
printf("flags %x\n", layout->flags);
printf("descriptor %p\n", layout->descriptor);
printf("descriptor->size %d\n", layout->descriptor->size);
}
#endif
void (^vvcopy)(void) = Block_copy(vv);
Block_release(vvcopy);
printf("%s: success\n", argv[0]);
return 0;
}
|
/*
* cn_test.c
*
* 2004+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
* 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. 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/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/skbuff.h>
#include <linux/timer.h>
#include <linux/connector.h>
static struct cb_id cn_test_id = { 0x123, 0x456 };
static char cn_test_name[] = "cn_test";
static struct sock *nls;
static struct timer_list cn_test_timer;
void cn_test_callback(void *data)
{
struct cn_msg *msg = (struct cn_msg *)data;
printk("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n",
__func__, jiffies, msg->id.idx, msg->id.val,
msg->seq, msg->ack, msg->len, (char *)msg->data);
}
/*
* Do not remove this function even if no one is using it as
* this is an example of how to get notifications about new
* connector user registration
*/
#if 0
static int cn_test_want_notify(void)
{
struct cn_ctl_msg *ctl;
struct cn_notify_req *req;
struct cn_msg *msg = NULL;
int size, size0;
struct sk_buff *skb;
struct nlmsghdr *nlh;
u32 group = 1;
size0 = sizeof(*msg) + sizeof(*ctl) + 3 * sizeof(*req);
size = NLMSG_SPACE(size0);
skb = alloc_skb(size, GFP_ATOMIC);
if (!skb) {
printk(KERN_ERR "Failed to allocate new skb with size=%u.\n",
size);
return -ENOMEM;
}
nlh = NLMSG_PUT(skb, 0, 0x123, NLMSG_DONE, size - sizeof(*nlh));
msg = (struct cn_msg *)NLMSG_DATA(nlh);
memset(msg, 0, size0);
msg->id.idx = -1;
msg->id.val = -1;
msg->seq = 0x123;
msg->ack = 0x345;
msg->len = size0 - sizeof(*msg);
ctl = (struct cn_ctl_msg *)(msg + 1);
ctl->idx_notify_num = 1;
ctl->val_notify_num = 2;
ctl->group = group;
ctl->len = msg->len - sizeof(*ctl);
req = (struct cn_notify_req *)(ctl + 1);
/*
* Idx.
*/
req->first = cn_test_id.idx;
req->range = 10;
/*
* Val 0.
*/
req++;
req->first = cn_test_id.val;
req->range = 10;
/*
* Val 1.
*/
req++;
req->first = cn_test_id.val + 20;
req->range = 10;
NETLINK_CB(skb).dst_group = ctl->group;
//netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC);
netlink_unicast(nls, skb, 0, 0);
printk(KERN_INFO "Request was sent. Group=0x%x.\n", ctl->group);
return 0;
nlmsg_failure:
printk(KERN_ERR "Failed to send %u.%u\n", msg->seq, msg->ack);
kfree_skb(skb);
return -EINVAL;
}
#endif
static u32 cn_test_timer_counter;
static void cn_test_timer_func(unsigned long __data)
{
struct cn_msg *m;
char data[32];
m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC);
if (m) {
memcpy(&m->id, &cn_test_id, sizeof(m->id));
m->seq = cn_test_timer_counter;
m->len = sizeof(data);
m->len =
scnprintf(data, sizeof(data), "counter = %u",
cn_test_timer_counter) + 1;
memcpy(m + 1, data, m->len);
cn_netlink_send(m, 0, GFP_ATOMIC);
kfree(m);
}
cn_test_timer_counter++;
mod_timer(&cn_test_timer, jiffies + HZ);
}
static int cn_test_init(void)
{
int err;
err = cn_add_callback(&cn_test_id, cn_test_name, cn_test_callback);
if (err)
goto err_out;
cn_test_id.val++;
err = cn_add_callback(&cn_test_id, cn_test_name, cn_test_callback);
if (err) {
cn_del_callback(&cn_test_id);
goto err_out;
}
setup_timer(&cn_test_timer, cn_test_timer_func, 0);
cn_test_timer.expires = jiffies + HZ;
add_timer(&cn_test_timer);
return 0;
err_out:
if (nls && nls->sk_socket)
sock_release(nls->sk_socket);
return err;
}
static void cn_test_fini(void)
{
del_timer_sync(&cn_test_timer);
cn_del_callback(&cn_test_id);
cn_test_id.val--;
cn_del_callback(&cn_test_id);
if (nls && nls->sk_socket)
sock_release(nls->sk_socket);
}
module_init(cn_test_init);
module_exit(cn_test_fini);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
MODULE_DESCRIPTION("Connector's test module");
|
/*
* 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.sun.com/software/products/lustre/docs/GPLv2.pdf
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
* GPL HEADER END
*/
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char ** argv)
{
int i, rc = 0, count;
char dirname[4096];
if (argc < 3) {
printf("Usage %s dirnamebase count\n", argv[0]);
return 1;
}
if (strlen(argv[1]) > 4080) {
printf("name too long\n");
return 1;
}
count = strtoul(argv[2], NULL, 0);
for (i = 0; i < count; i++) {
sprintf(dirname, "%s-%d", argv[1], i);
rc = mkdir(dirname, 0444);
if (rc) {
printf("mkdir(%s) error: %s\n",
dirname, strerror(errno));
break;
}
if ((i % 10000) == 0)
printf(" - created %d (time %ld)\n", i, time(0));
}
return rc;
}
|
/*
* [origin: Linux kernel include/asm-arm/arch-at91/at91sam9rl.h]
*
* Copyright (C) 2007 Atmel Corporation
*
* Common definitions.
* Based on AT91SAM9RL datasheet revision A. (Preliminary)
*
* 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.
*/
#ifndef AT91SAM9RL_H
#define AT91SAM9RL_H
/*
* defines to be used in other places
*/
#define CONFIG_AT91FAMILY /* it's a member of AT91 */
/*
* Peripheral identifiers/interrupts.
*/
#define ATMEL_ID_FIQ 0 /* Advanced Interrupt Controller (FIQ) */
#define ATMEL_ID_SYS 1 /* System Peripherals */
#define ATMEL_ID_PIOA 2 /* Parallel IO Controller A */
#define ATMEL_ID_PIOB 3 /* Parallel IO Controller B */
#define ATMEL_ID_PIOC 4 /* Parallel IO Controller C */
#define ATMEL_ID_PIOD 5 /* Parallel IO Controller D */
#define ATMEL_ID_USART0 6 /* USART 0 */
#define ATMEL_ID_USART1 7 /* USART 1 */
#define ATMEL_ID_USART2 8 /* USART 2 */
#define ATMEL_ID_USART3 9 /* USART 3 */
#define ATMEL_ID_MCI 10 /* Multimedia Card Interface */
#define ATMEL_ID_TWI0 11 /* TWI 0 */
#define ATMEL_ID_TWI1 12 /* TWI 1 */
#define ATMEL_ID_SPI 13 /* Serial Peripheral Interface */
#define ATMEL_ID_SSC0 14 /* Serial Synchronous Controller 0 */
#define ATMEL_ID_SSC1 15 /* Serial Synchronous Controller 1 */
#define ATMEL_ID_TC0 16 /* Timer Counter 0 */
#define ATMEL_ID_TC1 17 /* Timer Counter 1 */
#define ATMEL_ID_TC2 18 /* Timer Counter 2 */
#define ATMEL_ID_PWMC 19 /* Pulse Width Modulation Controller */
#define ATMEL_ID_TSC 20 /* Touch Screen Controller */
#define ATMEL_ID_DMA 21 /* DMA Controller */
#define ATMEL_ID_UDPHS 22 /* USB Device HS */
#define ATMEL_ID_LCDC 23 /* LCD Controller */
#define ATMEL_ID_AC97C 24 /* AC97 Controller */
#define ATMEL_ID_IRQ0 31 /* Advanced Interrupt Controller (IRQ0) */
/*
* User Peripheral physical base addresses.
*/
#define ATMEL_BASE_TCB0 0xfffa0000
#define ATMEL_BASE_TC0 0xfffa0000
#define ATMEL_BASE_TC1 0xfffa0040
#define ATMEL_BASE_TC2 0xfffa0080
#define ATMEL_BASE_MCI 0xfffa4000
#define ATMEL_BASE_TWI0 0xfffa8000
#define ATMEL_BASE_TWI1 0xfffac000
#define ATMEL_BASE_USART0 0xfffb0000
#define ATMEL_BASE_USART1 0xfffb4000
#define ATMEL_BASE_USART2 0xfffb8000
#define ATMEL_BASE_USART3 0xfffbc000
#define ATMEL_BASE_SSC0 0xfffc0000
#define ATMEL_BASE_SSC1 0xfffc4000
#define ATMEL_BASE_PWMC 0xfffc8000
#define ATMEL_BASE_SPI0 0xfffcc000
#define ATMEL_BASE_TSC 0xfffd0000
#define ATMEL_BASE_UDPHS 0xfffd4000
#define ATMEL_BASE_AC97C 0xfffd8000
#define ATMEL_BASE_SYS 0xffffc000
/*
* System Peripherals
*/
#define ATMEL_BASE_DMA 0xffffe600
#define ATMEL_BASE_ECC 0xffffe800
#define ATMEL_BASE_SDRAMC 0xffffea00
#define ATMEL_BASE_SMC 0xffffec00
#define ATMEL_BASE_MATRIX 0xffffee00
#define ATMEL_BASE_CCFG 0xffffef10
#define ATMEL_BASE_AIC 0xfffff000
#define ATMEL_BASE_DBGU 0xfffff200
#define ATMEL_BASE_PIOA 0xfffff400
#define ATMEL_BASE_PIOB 0xfffff600
#define ATMEL_BASE_PIOC 0xfffff800
#define ATMEL_BASE_PIOD 0xfffffa00
#define ATMEL_BASE_PMC 0xfffffc00
#define ATMEL_BASE_RSTC 0xfffffd00
#define ATMEL_BASE_SHDWC 0xfffffd10
#define ATMEL_BASE_RTT 0xfffffd20
#define ATMEL_BASE_PIT 0xfffffd30
#define ATMEL_BASE_WDT 0xfffffd40
#define ATMEL_BASE_SCKCR 0xfffffd50
#define ATMEL_BASE_GPBR 0xfffffd60
#define ATMEL_BASE_RTC 0xfffffe00
/*
* Internal Memory.
*/
#define ATMEL_BASE_SRAM 0x00300000 /* Internal SRAM base address */
#define ATMEL_BASE_ROM 0x00400000 /* Internal ROM base address */
#define ATMEL_BASE_LCDC 0x00500000 /* LCD Controller */
#define ATMEL_UHP_BASE 0x00600000 /* USB Device HS controller */
/*
* External memory
*/
#define ATMEL_BASE_CS0 0x10000000
#define ATMEL_BASE_CS1 0x20000000 /* SDRAM */
#define ATMEL_BASE_CS2 0x30000000
#define ATMEL_BASE_CS3 0x40000000 /* NAND */
#define ATMEL_BASE_CS4 0x50000000 /* Compact Flash Slot 0 */
#define ATMEL_BASE_CS5 0x60000000 /* Compact Flash Slot 1 */
/* Timer */
#define CONFIG_SYS_TIMER_COUNTER 0xfffffd3c
/*
* Other misc defines
*/
#define ATMEL_PIO_PORTS 4 /* this SoC has 4 PIO */
#define ATMEL_BASE_PIO ATMEL_BASE_PIOA
/*
* Cpu Name
*/
#define ATMEL_CPU_NAME "AT91SAM9RL"
#endif
|
// Scintilla source code edit control
/** @file Style.h
** Defines the font and colour style for a class of text.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef STYLE_H
#define STYLE_H
#ifdef SCI_NAMESPACE
namespace Scintilla {
#endif
/**
*/
class Style {
public:
ColourPair fore;
ColourPair back;
bool aliasOfDefaultFont;
bool bold;
bool italic;
int size;
const char *fontName;
int characterSet;
bool eolFilled;
bool underline;
enum ecaseForced {caseMixed, caseUpper, caseLower};
ecaseForced caseForce;
bool visible;
bool changeable;
bool hotspot;
Font font;
int sizeZoomed;
unsigned int lineHeight;
unsigned int ascent;
unsigned int descent;
unsigned int externalLeading;
unsigned int aveCharWidth;
unsigned int spaceWidth;
Style();
Style(const Style &source);
~Style();
Style &operator=(const Style &source);
void Clear(ColourDesired fore_, ColourDesired back_,
int size_,
const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_,
bool visible_, bool changeable_, bool hotspot_);
void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0, bool extraFontFlag = false);
bool IsProtected() const { return !(changeable && visible);};
};
#ifdef SCI_NAMESPACE
}
#endif
#endif
|
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_BASE_RANDOM_H_
#define WEBRTC_BASE_RANDOM_H_
#include <limits>
#include "webrtc/typedefs.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/checks.h"
namespace webrtc {
class Random {
public:
// TODO(tommi): Change this so that the seed can be initialized internally,
// e.g. by offering two ways of constructing or offer a static method that
// returns a seed that's suitable for initialization.
// The problem now is that callers are calling clock_->TimeInMicroseconds()
// which calls TickTime::Now().Ticks(), which can return a very low value on
// Mac and can result in a seed of 0 after conversion to microseconds.
// Besides the quality of the random seed being poor, this also requires
// the client to take on extra dependencies to generate a seed.
// If we go for a static seed generator in Random, we can use something from
// webrtc/base and make sure that it works the same way across platforms.
// See also discussion here: https://codereview.webrtc.org/1623543002/
explicit Random(uint64_t seed);
// Return pseudo-random integer of the specified type.
// We need to limit the size to 32 bits to keep the output close to uniform.
template <typename T>
T Rand() {
static_assert(std::numeric_limits<T>::is_integer &&
std::numeric_limits<T>::radix == 2 &&
std::numeric_limits<T>::digits <= 32,
"Rand is only supported for built-in integer types that are "
"32 bits or smaller.");
return static_cast<T>(NextOutput());
}
// Uniformly distributed pseudo-random number in the interval [0, t].
uint32_t Rand(uint32_t t);
// Uniformly distributed pseudo-random number in the interval [low, high].
uint32_t Rand(uint32_t low, uint32_t high);
// Uniformly distributed pseudo-random number in the interval [low, high].
int32_t Rand(int32_t low, int32_t high);
// Normal Distribution.
double Gaussian(double mean, double standard_deviation);
// Exponential Distribution.
double Exponential(double lambda);
private:
// Outputs a nonzero 64-bit random number.
uint64_t NextOutput() {
state_ ^= state_ >> 12;
state_ ^= state_ << 25;
state_ ^= state_ >> 27;
RTC_DCHECK(state_ != 0x0ULL);
return state_ * 2685821657736338717ull;
}
uint64_t state_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Random);
};
// Return pseudo-random number in the interval [0.0, 1.0).
template <>
float Random::Rand<float>();
// Return pseudo-random number in the interval [0.0, 1.0).
template <>
double Random::Rand<double>();
// Return pseudo-random boolean value.
template <>
bool Random::Rand<bool>();
} // namespace webrtc
#endif // WEBRTC_BASE_RANDOM_H_
|
/*
* Copyright (C) 2004-2005 Arabella Software Ltd.
* Yuli Barcohen <yuli@arabellasw.com>
*
* Support for Analogue&Micro Adder boards family.
* Tested on AdderII and Adder87x.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* 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 <common.h>
#include <mpc8xx.h>
#if defined(CONFIG_OF_LIBFDT)
#include <libfdt.h>
#endif
/*
* SDRAM is single Samsung K4S643232F-T70 chip (8MB)
* or single Micron MT48LC4M32B2TG-7 chip (16MB).
* Minimal CPU frequency is 40MHz.
*/
static uint sdram_table[] = {
/* Single read (offset 0x00 in UPM RAM) */
0x1f07fc24, 0xe0aefc04, 0x10adfc04, 0xe0bbbc00,
0x10f77c44, 0xf3fffc07, 0xfffffc04, 0xfffffc04,
/* Burst read (offset 0x08 in UPM RAM) */
0x1f07fc24, 0xe0aefc04, 0x10adfc04, 0xf0affc00,
0xf0affc00, 0xf0affc00, 0xf0affc00, 0x10a77c44,
0xf7bffc47, 0xfffffc35, 0xfffffc34, 0xfffffc35,
0xfffffc35, 0x1ff77c35, 0xfffffc34, 0x1fb57c35,
/* Single write (offset 0x18 in UPM RAM) */
0x1f27fc24, 0xe0aebc04, 0x00b93c00, 0x13f77c47,
0xfffdfc04, 0xfffffc04, 0xfffffc04, 0xfffffc04,
/* Burst write (offset 0x20 in UPM RAM) */
0x1f07fc24, 0xeeaebc00, 0x10ad7c00, 0xf0affc00,
0xf0affc00, 0xe0abbc00, 0x1fb77c47, 0xfffffc04,
0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04,
0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04,
/* Refresh (offset 0x30 in UPM RAM) */
0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04,
0xfffffc84, 0xfffffc07, 0xfffffc04, 0xfffffc04,
0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04,
/* Exception (offset 0x3C in UPM RAM) */
0xfffffc27, 0xfffffc04, 0xfffffc04, 0xfffffc04
};
phys_size_t initdram (int board_type)
{
long int msize;
volatile immap_t *immap = (volatile immap_t *)CFG_IMMR;
volatile memctl8xx_t *memctl = &immap->im_memctl;
upmconfig(UPMA, sdram_table, sizeof(sdram_table) / sizeof(uint));
/* Configure SDRAM refresh */
memctl->memc_mptpr = MPTPR_PTP_DIV32; /* BRGCLK/32 */
memctl->memc_mamr = (94 << 24) | CFG_MAMR; /* No refresh */
udelay(200);
/* Run precharge from location 0x15 */
memctl->memc_mar = 0x0;
memctl->memc_mcr = 0x80002115;
udelay(200);
/* Run 8 refresh cycles */
memctl->memc_mcr = 0x80002830;
udelay(200);
/* Run MRS pattern from location 0x16 */
memctl->memc_mar = 0x88;
memctl->memc_mcr = 0x80002116;
udelay(200);
memctl->memc_mamr |= MAMR_PTAE; /* Enable refresh */
memctl->memc_or1 = ~(CFG_SDRAM_MAX_SIZE - 1) | OR_CSNT_SAM;
memctl->memc_br1 = CFG_SDRAM_BASE | BR_PS_32 | BR_MS_UPMA | BR_V;
msize = get_ram_size(CFG_SDRAM_BASE, CFG_SDRAM_MAX_SIZE);
memctl->memc_or1 |= ~(msize - 1);
return msize;
}
int checkboard( void )
{
puts("Board: Adder");
#if defined(CONFIG_MPC885_FAMILY)
puts("87x\n");
#elif defined(CONFIG_MPC866_FAMILY)
puts("II\n");
#endif
return 0;
}
#if defined(CONFIG_OF_BOARD_SETUP)
void ft_board_setup(void *blob, bd_t *bd)
{
ft_cpu_setup(blob, bd);
}
#endif
|
// Copyright 2011 Software Freedom Conservancy
// 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 WEBDRIVER_IE_GETELEMENTTEXTCOMMANDHANDLER_H_
#define WEBDRIVER_IE_GETELEMENTTEXTCOMMANDHANDLER_H_
#include "../Browser.h"
#include "../IECommandHandler.h"
#include "../IECommandExecutor.h"
#include "../Generated/atoms.h"
namespace webdriver {
class GetElementTextCommandHandler : public IECommandHandler {
public:
GetElementTextCommandHandler(void) {
}
~GetElementTextCommandHandler(void) {
}
protected:
void ExecuteInternal(const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator id_parameter_iterator = command_parameters.find("id");
if (id_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter in URL: id");
return;
} else {
std::string element_id = id_parameter_iterator->second.asString();
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get browser");
return;
}
ElementHandle element_wrapper;
status_code = this->GetElement(executor, element_id, &element_wrapper);
if (status_code == WD_SUCCESS) {
// The atom is just the definition of an anonymous
// function: "function() {...}"; Wrap it in another function so
// we can invoke it with our arguments without polluting the
// current namespace.
std::wstring script_source = L"(function() { return (";
script_source += atoms::asString(atoms::GET_TEXT);
script_source += L")})();";
CComPtr<IHTMLDocument2> doc;
browser_wrapper->GetDocument(&doc);
Script script_wrapper(doc, script_source, 1);
script_wrapper.AddArgument(element_wrapper->element());
status_code = script_wrapper.Execute();
if (status_code == WD_SUCCESS) {
std::string text = "";
bool is_null = script_wrapper.ConvertResultToString(&text);
response->SetSuccessResponse(text);
return;
} else {
response->SetErrorResponse(status_code,
"Unable to get element text");
return;
}
} else {
response->SetErrorResponse(status_code, "Element is no longer valid");
return;
}
}
}
};
} // namespace webdriver
#endif // WEBDRIVER_IE_GETELEMENTTEXTCOMMANDHANDLER_H_
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_
#define CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_
#include "base/basictypes.h"
#include "base/process/kill.h"
#include "components/metrics/metrics_provider.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class PrefRegistrySimple;
namespace content {
class RenderProcessHost;
class WebContents;
}
namespace metrics {
class MetricsService;
}
namespace chromecast {
namespace metrics {
// CastStabilityMetricsProvider gathers and logs stability-related metrics.
// Loosely based on ChromeStabilityMetricsProvider from chrome/browser/metrics.
class CastStabilityMetricsProvider
: public ::metrics::MetricsProvider,
public content::BrowserChildProcessObserver,
public content::NotificationObserver {
public:
// Registers local state prefs used by this class.
static void RegisterPrefs(PrefRegistrySimple* registry);
explicit CastStabilityMetricsProvider(
::metrics::MetricsService* metrics_service);
~CastStabilityMetricsProvider() override;
// metrics::MetricsDataProvider implementation:
void OnRecordingEnabled() override;
void OnRecordingDisabled() override;
void ProvideStabilityMetrics(
::metrics::SystemProfileProto* system_profile_proto) override;
// Logs an external crash, presumably from the ExternalMetrics service.
void LogExternalCrash(const std::string& crash_type);
private:
// content::NotificationObserver implementation:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// content::BrowserChildProcessObserver implementation:
void BrowserChildProcessCrashed(
const content::ChildProcessData& data) override;
// Records a renderer process crash.
void LogRendererCrash(content::RenderProcessHost* host,
base::TerminationStatus status,
int exit_code);
// Records a renderer process hang.
void LogRendererHang();
// Registrar for receiving stability-related notifications.
content::NotificationRegistrar registrar_;
// Reference to the current MetricsService. Raw pointer is safe, since
// MetricsService is responsible for the lifetime of
// CastStabilityMetricsProvider.
::metrics::MetricsService* metrics_service_;
DISALLOW_COPY_AND_ASSIGN(CastStabilityMetricsProvider);
};
} // namespace metrics
} // namespace chromecast
#endif // CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
keyboard.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Forrest Yu, 2005
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include "type.h"
#include "const.h"
#include "protect.h"
#include "string.h"
#include "proc.h"
#include "tty.h"
#include "console.h"
#include "global.h"
#include "proto.h"
#include "keyboard.h"
#include "keymap.h"
PRIVATE KB_INPUT kb_in;
PRIVATE int code_with_E0;
PRIVATE int shift_l; /* l shift state */
PRIVATE int shift_r; /* r shift state */
PRIVATE int alt_l; /* l alt state */
PRIVATE int alt_r; /* r left state */
PRIVATE int ctrl_l; /* l ctrl state */
PRIVATE int ctrl_r; /* l ctrl state */
PRIVATE int caps_lock; /* Caps Lock */
PRIVATE int num_lock; /* Num Lock */
PRIVATE int scroll_lock; /* Scroll Lock */
PRIVATE int column;
PRIVATE u8 get_byte_from_kbuf();
/*======================================================================*
keyboard_handler
*======================================================================*/
PUBLIC void keyboard_handler(int irq)
{
u8 scan_code = in_byte(KB_DATA);
if (kb_in.count < KB_IN_BYTES) {
*(kb_in.p_head) = scan_code;
kb_in.p_head++;
if (kb_in.p_head == kb_in.buf + KB_IN_BYTES) {
kb_in.p_head = kb_in.buf;
}
kb_in.count++;
}
}
/*======================================================================*
init_keyboard
*======================================================================*/
PUBLIC void init_keyboard()
{
kb_in.count = 0;
kb_in.p_head = kb_in.p_tail = kb_in.buf;
shift_l = shift_r = 0;
alt_l = alt_r = 0;
ctrl_l = ctrl_r = 0;
put_irq_handler(KEYBOARD_IRQ, keyboard_handler);/*设定键盘中断处理程序*/
enable_irq(KEYBOARD_IRQ); /*开键盘中断*/
}
/*======================================================================*
keyboard_read
*======================================================================*/
PUBLIC void keyboard_read(TTY* p_tty)
{
u8 scan_code;
char output[2];
int make; /* 1: make; 0: break. */
u32 key = 0;/* 用一个整型来表示一个键。比如,如果 Home 被按下,
* 则 key 值将为定义在 keyboard.h 中的 'HOME'。
*/
u32* keyrow; /* 指向 keymap[] 的某一行 */
if(kb_in.count > 0){
code_with_E0 = 0;
scan_code = get_byte_from_kbuf();
/* 下面开始解析扫描码 */
if (scan_code == 0xE1) {
int i;
u8 pausebrk_scode[] = {0xE1, 0x1D, 0x45,
0xE1, 0x9D, 0xC5};
int is_pausebreak = 1;
for(i=1;i<6;i++){
if (get_byte_from_kbuf() != pausebrk_scode[i]) {
is_pausebreak = 0;
break;
}
}
if (is_pausebreak) {
key = PAUSEBREAK;
}
}
else if (scan_code == 0xE0) {
scan_code = get_byte_from_kbuf();
/* PrintScreen 被按下 */
if (scan_code == 0x2A) {
if (get_byte_from_kbuf() == 0xE0) {
if (get_byte_from_kbuf() == 0x37) {
key = PRINTSCREEN;
make = 1;
}
}
}
/* PrintScreen 被释放 */
if (scan_code == 0xB7) {
if (get_byte_from_kbuf() == 0xE0) {
if (get_byte_from_kbuf() == 0xAA) {
key = PRINTSCREEN;
make = 0;
}
}
}
/* 不是PrintScreen, 此时scan_code为0xE0紧跟的那个值. */
if (key == 0) {
code_with_E0 = 1;
}
}
if ((key != PAUSEBREAK) && (key != PRINTSCREEN)) {
/* 首先判断Make Code 还是 Break Code */
make = (scan_code & FLAG_BREAK ? 0 : 1);
/* 先定位到 keymap 中的行 */
keyrow = &keymap[(scan_code & 0x7F) * MAP_COLS];
column = 0;
if (shift_l || shift_r) {
column = 1;
}
if (code_with_E0) {
column = 2;
code_with_E0 = 0;
}
key = keyrow[column];
switch(key) {
case SHIFT_L:
shift_l = make;
break;
case SHIFT_R:
shift_r = make;
break;
case CTRL_L:
ctrl_l = make;
break;
case CTRL_R:
ctrl_r = make;
break;
case ALT_L:
alt_l = make;
break;
case ALT_R:
alt_l = make;
break;
default:
break;
}
if (make) { /* 忽略 Break Code */
key |= shift_l ? FLAG_SHIFT_L : 0;
key |= shift_r ? FLAG_SHIFT_R : 0;
key |= ctrl_l ? FLAG_CTRL_L : 0;
key |= ctrl_r ? FLAG_CTRL_R : 0;
key |= alt_l ? FLAG_ALT_L : 0;
key |= alt_r ? FLAG_ALT_R : 0;
in_process(p_tty, key);
}
}
}
}
/*======================================================================*
get_byte_from_kbuf
*======================================================================*/
PRIVATE u8 get_byte_from_kbuf() /* 从键盘缓冲区中读取下一个字节 */
{
u8 scan_code;
while (kb_in.count <= 0) {} /* 等待下一个字节到来 */
disable_int();
scan_code = *(kb_in.p_tail);
kb_in.p_tail++;
if (kb_in.p_tail == kb_in.buf + KB_IN_BYTES) {
kb_in.p_tail = kb_in.buf;
}
kb_in.count--;
enable_int();
return scan_code;
}
|
/* Copyright (c) 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// GTLYouTubeLiveStreamListResponse.h
//
// ----------------------------------------------------------------------------
// NOTE: This file is generated from Google APIs Discovery Service.
// Service:
// YouTube Data API (youtube/v3)
// Description:
// Programmatic access to YouTube features.
// Documentation:
// https://developers.google.com/youtube/v3
// Classes:
// GTLYouTubeLiveStreamListResponse (0 custom class methods, 9 custom properties)
#if GTL_BUILT_AS_FRAMEWORK
#import "GTL/GTLObject.h"
#else
#import "GTLObject.h"
#endif
@class GTLYouTubeLiveStream;
@class GTLYouTubePageInfo;
@class GTLYouTubeTokenPagination;
// ----------------------------------------------------------------------------
//
// GTLYouTubeLiveStreamListResponse
//
// This class supports NSFastEnumeration over its "items" property. It also
// supports -itemAtIndex: to retrieve individual objects from "items".
@interface GTLYouTubeLiveStreamListResponse : GTLCollectionObject
// Etag of this resource.
@property (nonatomic, copy) NSString *ETag;
// Serialized EventId of the request which produced this response.
@property (nonatomic, copy) NSString *eventId;
// A list of live streams that match the request criteria.
@property (nonatomic, retain) NSArray *items; // of GTLYouTubeLiveStream
// Identifies what kind of resource this is. Value: the fixed string
// "youtube#liveStreamListResponse".
@property (nonatomic, copy) NSString *kind;
// The token that can be used as the value of the pageToken parameter to
// retrieve the next page in the result set.
@property (nonatomic, copy) NSString *nextPageToken;
@property (nonatomic, retain) GTLYouTubePageInfo *pageInfo;
// The token that can be used as the value of the pageToken parameter to
// retrieve the previous page in the result set.
@property (nonatomic, copy) NSString *prevPageToken;
@property (nonatomic, retain) GTLYouTubeTokenPagination *tokenPagination;
// The visitorId identifies the visitor.
@property (nonatomic, copy) NSString *visitorId;
@end
|
// Copyright (c) 2011-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_RECEIVEREQUESTDIALOG_H
#define BITCOIN_QT_RECEIVEREQUESTDIALOG_H
#include <qt/walletmodel.h>
#include <QDialog>
#include <QImage>
#include <QLabel>
#include <QPainter>
namespace Ui {
class ReceiveRequestDialog;
}
QT_BEGIN_NAMESPACE
class QMenu;
QT_END_NAMESPACE
/* Label widget for QR code. This image can be dragged, dropped, copied and saved
* to disk.
*/
class QRImageWidget : public QLabel
{
Q_OBJECT
public:
explicit QRImageWidget(QWidget *parent = 0);
QImage exportImage();
public Q_SLOTS:
void saveImage();
void copyImage();
protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void contextMenuEvent(QContextMenuEvent *event);
private:
QMenu *contextMenu;
};
class ReceiveRequestDialog : public QDialog
{
Q_OBJECT
public:
explicit ReceiveRequestDialog(QWidget *parent = 0);
~ReceiveRequestDialog();
void setModel(WalletModel *model);
void setInfo(const SendCoinsRecipient &info);
private Q_SLOTS:
void on_btnCopyURI_clicked();
void on_btnCopyAddress_clicked();
void update();
private:
Ui::ReceiveRequestDialog *ui;
WalletModel *model;
SendCoinsRecipient info;
};
#endif // BITCOIN_QT_RECEIVEREQUESTDIALOG_H
|
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#include <linux/module.h>
#include <linux/poll.h>
int __weak exec_ccci_kern_func_by_md_id(int md_id, unsigned int id, char *buf, unsigned int len)
{
printk("[ccci/dummy] exec_ccci_kern_func_by_md_id no support!\n");
return 0;
}
int __weak switch_sim_mode(int id, char *buf, unsigned int len)
{
printk("[ccci0/port] switch_sim_mode no support!\n");
return 0;
}
unsigned int __weak get_sim_switch_type(void)
{
printk("[ccci0/port] get_sim_switch_type no support!\n");
return 0;
} |
/* Conversion from and to ISO 8859-2.
Copyright (C) 1997-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* Get the conversion table. */
#include <stdint.h>
#include <iso8859-2.h>
#define CHARSET_NAME "ISO-8859-2//"
#define HAS_HOLES 0 /* All 256 character are defined. */
#include <8bit-generic.c>
|
/* Copyright (C) 2007-2016 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* \file
*
* \author Victor Julien <victor@inliniac.net>
*/
#ifndef __UTIL_LUAJIT_H__
#define __UTIL_LUAJIT_H__
#ifdef HAVE_LUAJIT
int LuajitSetupStatesPool(void);
void LuajitFreeStatesPool(void);
lua_State *LuajitGetState(void);
void LuajitReturnState(lua_State *s);
#endif /* HAVE_LUAJIT */
#endif /* __UTIL_LUAJIT_H__ */
|
/*
*
* Copyright (c) 2009 by Stefan Riepenhausen <rhn@gmx.net>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
*/
#include <avr/io.h>
#include <util/twi.h>
#include "config.h"
#include "core/debug.h"
#include "i2c_master.h"
#ifdef I2C_PCF8574X_SUPPORT
int8_t
i2c_pcf8574x_read(uint8_t address){
uint8_t data[2];
uint8_t ret;
#ifdef DEBUG_I2C
debug_printf("I2C: pcf8574X read\n");
#endif
if (!i2c_master_select(address, TW_READ)) { ret = 0xff; goto end; }
if (i2c_master_transmit_with_ack() != TW_MR_DATA_ACK) { ret = 0xff; goto end; }
data[0] = TWDR;
#ifdef DEBUG_I2C
debug_printf("I2C: pcf8574X read value1: %X\n", data[0]);
#endif
if (i2c_master_transmit() != TW_MR_DATA_NACK) { ret = 0xff; goto end; }
data[1] = TWDR;
#ifdef DEBUG_I2C
debug_printf("I2C: pcf8574X read value2: %X\n", data[1]);
#endif
ret = data[0] ;
end:
i2c_master_stop();
return ret;
}
int16_t
i2c_pcf8574x_set(uint8_t address, uint8_t value){
uint16_t ret=0xffff;
#ifdef DEBUG_I2C
debug_printf("I2C: pcf8574X set\n");
#endif
i2c_master_select(address, TW_WRITE);
#ifdef DEBUG_I2C
debug_printf("I2C: pcf8574X: 0x%X", i2c_master_transmit_with_ack());
debug_printf("I2C: pcf8574X read value: %X\n",value);
#endif
TWDR=value;
i2c_master_transmit();
i2c_master_stop();
return ret;
}
#endif /* I2C_PCF8574X_SUPPORT */
|
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
// MOOSE includes
#include "AuxKernel.h"
// Forward Declarations
class ElementLengthAux;
template <>
InputParameters validParams<ElementLengthAux>();
/**
* Computes the min or max of element length.
*/
class ElementLengthAux : public AuxKernel
{
public:
static InputParameters validParams();
ElementLengthAux(const InputParameters & parameters);
protected:
/**
* Returns the min/max of the current element.
*/
virtual Real computeValue() override;
/// The type of calculation to perform min or max
const bool _use_min;
};
|
/***************************************************************************
* (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* FreeCAD is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* *
* Juergen Riegel 2002 *
***************************************************************************/
#ifndef BASE_FACTORY_H
#define BASE_FACTORY_H
#include<typeinfo>
#include<string>
#include<map>
#include<list>
#include"../FCConfig.h"
namespace Base
{
/// Abstract base class of all producers
class BaseExport AbstractProducer
{
public:
AbstractProducer() {}
virtual ~AbstractProducer() {}
/// overwriten by a concret producer to produce the needed object
virtual void* Produce (void) const = 0;
};
/** Base class of all factories
* This class has the purpose to produce at runtime instances
* of classes not known at compile time. It holds a map of so called
* producers which are able to produce an instance of a special class.
* Producer can be registered at runtime through e.g. application modules
*/
class BaseExport Factory
{
public:
/// Adds a new prducer instance
void AddProducer (const char* sClassName, AbstractProducer *pcProducer);
/// returns true if there is a producer for this class registered
bool CanProduce(const char* sClassName) const;
/// returns a list of all registered producer
std::list<std::string> CanProduce() const;
protected:
/// produce a class with the given name
void* Produce (const char* sClassName) const;
std::map<const std::string, AbstractProducer*> _mpcProducers;
/// construction
Factory (void){}
/// destruction
virtual ~Factory ();
};
// --------------------------------------------------------------------
/** The ScriptFactorySingleton singleton
*/
class BaseExport ScriptFactorySingleton : public Factory
{
public:
static ScriptFactorySingleton& Instance(void);
static void Destruct (void);
const char* ProduceScript (const char* sScriptName) const;
private:
static ScriptFactorySingleton* _pcSingleton;
ScriptFactorySingleton(){}
~ScriptFactorySingleton(){}
};
inline ScriptFactorySingleton& ScriptFactory(void)
{
return ScriptFactorySingleton::Instance();
}
// --------------------------------------------------------------------
/** Script Factory
* This class produce Scirpts.
* @see Factory
*/
class BaseExport ScriptProducer: public AbstractProducer
{
public:
/// Constructor
ScriptProducer (const char* name, const char* script) : mScript(script)
{
ScriptFactorySingleton::Instance().AddProducer(name, this);
}
virtual ~ScriptProducer (void){}
/// Produce an instance
virtual void* Produce (void) const
{
return (void*)mScript;
}
private:
const char* mScript;
};
} //namespace Base
#endif
|
#include <strings.h>
#include <ctype.h>
int strncasecmp(const char *_l, const char *_r, size_t n)
{
const unsigned char *l=(void *)_l, *r=(void *)_r;
if (!n--) return 0;
for (; *l && *r && n && (*l == *r || tolower(*l) == tolower(*r)); l++, r++, n--);
return tolower(*l) - tolower(*r);
}
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gglobal.c"
#endif
|
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/bitops.h>
#include <linux/cpumask.h>
#include <linux/export.h>
#include <linux/bootmem.h>
int __first_cpu(const cpumask_t *srcp)
{
return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
}
EXPORT_SYMBOL(__first_cpu);
int __next_cpu(int n, const cpumask_t *srcp)
{
return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
}
EXPORT_SYMBOL(__next_cpu);
#if NR_CPUS > 64
int __next_cpu_nr(int n, const cpumask_t *srcp)
{
return min_t(int, nr_cpu_ids,
find_next_bit(srcp->bits, nr_cpu_ids, n+1));
}
EXPORT_SYMBOL(__next_cpu_nr);
#endif
int __any_online_cpu(const cpumask_t *mask)
{
int cpu;
for_each_cpu_mask(cpu, *mask) {
if (cpu_online(cpu))
break;
}
return cpu;
}
EXPORT_SYMBOL(__any_online_cpu);
/**
* cpumask_next_and - get the next cpu in *src1p & *src2p
* @n: the cpu prior to the place to search (ie. return will be > @n)
* @src1p: the first cpumask pointer
* @src2p: the second cpumask pointer
*
* Returns >= nr_cpu_ids if no further cpus set in both.
*/
int cpumask_next_and(int n, const struct cpumask *src1p,
const struct cpumask *src2p)
{
while ((n = cpumask_next(n, src1p)) < nr_cpu_ids)
if (cpumask_test_cpu(n, src2p))
break;
return n;
}
EXPORT_SYMBOL(cpumask_next_and);
/**
* cpumask_any_but - return a "random" in a cpumask, but not this one.
* @mask: the cpumask to search
* @cpu: the cpu to ignore.
*
* Often used to find any cpu but smp_processor_id() in a mask.
* Returns >= nr_cpu_ids if no cpus set.
*/
int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
{
unsigned int i;
cpumask_check(cpu);
for_each_cpu(i, mask)
if (i != cpu)
break;
return i;
}
/* These are not inline because of header tangles. */
#ifdef CONFIG_CPUMASK_OFFSTACK
/**
* alloc_cpumask_var_node - allocate a struct cpumask on a given node
* @mask: pointer to cpumask_var_t where the cpumask is returned
* @flags: GFP_ flags
*
* Only defined when CONFIG_CPUMASK_OFFSTACK=y, otherwise is
* a nop returning a constant 1 (in <linux/cpumask.h>)
* Returns TRUE if memory allocation succeeded, FALSE otherwise.
*
* In addition, mask will be NULL if this fails. Note that gcc is
* usually smart enough to know that mask can never be NULL if
* CONFIG_CPUMASK_OFFSTACK=n, so does code elimination in that case
* too.
*/
bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
{
*mask = kmalloc_node(cpumask_size(), flags, node);
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
if (!*mask) {
printk(KERN_ERR "=> alloc_cpumask_var: failed!\n");
dump_stack();
}
#endif
/* FIXME: Bandaid to save us from old primitives which go to NR_CPUS. */
if (*mask) {
unsigned char *ptr = (unsigned char *)cpumask_bits(*mask);
unsigned int tail;
tail = BITS_TO_LONGS(NR_CPUS - nr_cpumask_bits) * sizeof(long);
memset(ptr + cpumask_size() - tail, 0, tail);
}
return *mask != NULL;
}
EXPORT_SYMBOL(alloc_cpumask_var_node);
bool zalloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
{
return alloc_cpumask_var_node(mask, flags | __GFP_ZERO, node);
}
EXPORT_SYMBOL(zalloc_cpumask_var_node);
/**
* alloc_cpumask_var - allocate a struct cpumask
* @mask: pointer to cpumask_var_t where the cpumask is returned
* @flags: GFP_ flags
*
* Only defined when CONFIG_CPUMASK_OFFSTACK=y, otherwise is
* a nop returning a constant 1 (in <linux/cpumask.h>).
*
* See alloc_cpumask_var_node.
*/
bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
{
return alloc_cpumask_var_node(mask, flags, numa_node_id());
}
EXPORT_SYMBOL(alloc_cpumask_var);
bool zalloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
{
return alloc_cpumask_var(mask, flags | __GFP_ZERO);
}
EXPORT_SYMBOL(zalloc_cpumask_var);
/**
* alloc_bootmem_cpumask_var - allocate a struct cpumask from the bootmem arena.
* @mask: pointer to cpumask_var_t where the cpumask is returned
*
* Only defined when CONFIG_CPUMASK_OFFSTACK=y, otherwise is
* a nop (in <linux/cpumask.h>).
* Either returns an allocated (zero-filled) cpumask, or causes the
* system to panic.
*/
void __init alloc_bootmem_cpumask_var(cpumask_var_t *mask)
{
*mask = alloc_bootmem(cpumask_size());
}
/**
* free_cpumask_var - frees memory allocated for a struct cpumask.
* @mask: cpumask to free
*
* This is safe on a NULL mask.
*/
void free_cpumask_var(cpumask_var_t mask)
{
kfree(mask);
}
EXPORT_SYMBOL(free_cpumask_var);
/**
* free_bootmem_cpumask_var - frees result of alloc_bootmem_cpumask_var
* @mask: cpumask to free
*/
void __init free_bootmem_cpumask_var(cpumask_var_t mask)
{
free_bootmem((unsigned long)mask, cpumask_size());
}
#endif
|
/*
* drivers/clk/clkdev.c
*
* Copyright (C) 2008 Russell King.
*
* 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.
*
* Helper for the clk API to assist looking up a struct clk.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/string.h>
#include <linux/mutex.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
static LIST_HEAD(clocks);
static DEFINE_MUTEX(clocks_mutex);
/*
* Find the correct struct clk for the device and connection ID.
* We do slightly fuzzy matching here:
* An entry with a NULL ID is assumed to be a wildcard.
* If an entry has a device ID, it must match
* If an entry has a connection ID, it must match
* Then we take the most specific entry - with the following
* order of precedence: dev+con > dev only > con only.
*/
static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
{
struct clk_lookup *p, *cl = NULL;
int match, best = 0;
list_for_each_entry(p, &clocks, node) {
match = 0;
if (p->dev_id) {
if (!dev_id || strcmp(p->dev_id, dev_id))
continue;
match += 2;
}
if (p->con_id) {
if (!con_id || strcmp(p->con_id, con_id))
continue;
match += 1;
}
if (match > best) {
cl = p;
if (match != 3)
best = match;
else
break;
}
}
return cl;
}
struct clk *clk_get_sys(const char *dev_id, const char *con_id)
{
struct clk_lookup *cl;
mutex_lock(&clocks_mutex);
cl = clk_find(dev_id, con_id);
if (cl && !__clk_get(cl->clk))
cl = NULL;
mutex_unlock(&clocks_mutex);
return cl ? cl->clk : ERR_PTR(-ENOENT);
}
EXPORT_SYMBOL(clk_get_sys);
struct clk *clk_get(struct device *dev, const char *con_id)
{
const char *dev_id = dev ? dev_name(dev) : NULL;
return clk_get_sys(dev_id, con_id);
}
EXPORT_SYMBOL(clk_get);
void clk_put(struct clk *clk)
{
__clk_put(clk);
}
EXPORT_SYMBOL(clk_put);
void clkdev_add(struct clk_lookup *cl)
{
mutex_lock(&clocks_mutex);
list_add_tail(&cl->node, &clocks);
mutex_unlock(&clocks_mutex);
}
EXPORT_SYMBOL(clkdev_add);
void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
{
mutex_lock(&clocks_mutex);
while (num--) {
list_add_tail(&cl->node, &clocks);
cl++;
}
mutex_unlock(&clocks_mutex);
}
#define MAX_DEV_ID 20
#define MAX_CON_ID 16
struct clk_lookup_alloc {
struct clk_lookup cl;
char dev_id[MAX_DEV_ID];
char con_id[MAX_CON_ID];
};
static struct clk_lookup * __init_refok
vclkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt,
va_list ap)
{
struct clk_lookup_alloc *cla;
cla = __clkdev_alloc(sizeof(*cla));
if (!cla)
return NULL;
cla->cl.clk = clk;
if (con_id) {
strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
cla->cl.con_id = cla->con_id;
}
if (dev_fmt) {
vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
cla->cl.dev_id = cla->dev_id;
}
return &cla->cl;
}
struct clk_lookup * __init_refok
clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
{
struct clk_lookup *cl;
va_list ap;
va_start(ap, dev_fmt);
cl = vclkdev_alloc(clk, con_id, dev_fmt, ap);
va_end(ap);
return cl;
}
EXPORT_SYMBOL(clkdev_alloc);
int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
struct device *dev)
{
struct clk *r = clk_get(dev, id);
struct clk_lookup *l;
if (IS_ERR(r))
return PTR_ERR(r);
l = clkdev_alloc(r, alias, alias_dev_name);
clk_put(r);
if (!l)
return -ENODEV;
clkdev_add(l);
return 0;
}
EXPORT_SYMBOL(clk_add_alias);
/*
* clkdev_drop - remove a clock dynamically allocated
*/
void clkdev_drop(struct clk_lookup *cl)
{
mutex_lock(&clocks_mutex);
list_del(&cl->node);
mutex_unlock(&clocks_mutex);
kfree(cl);
}
EXPORT_SYMBOL(clkdev_drop);
/**
* clk_register_clkdev - register one clock lookup for a struct clk
* @clk: struct clk to associate with all clk_lookups
* @con_id: connection ID string on device
* @dev_id: format string describing device name
*
* con_id or dev_id may be NULL as a wildcard, just as in the rest of
* clkdev.
*
* To make things easier for mass registration, we detect error clks
* from a previous clk_register() call, and return the error code for
* those. This is to permit this function to be called immediately
* after clk_register().
*/
int clk_register_clkdev(struct clk *clk, const char *con_id,
const char *dev_fmt, ...)
{
struct clk_lookup *cl;
va_list ap;
if (IS_ERR(clk))
return PTR_ERR(clk);
va_start(ap, dev_fmt);
cl = vclkdev_alloc(clk, con_id, dev_fmt, ap);
va_end(ap);
if (!cl)
return -ENOMEM;
clkdev_add(cl);
return 0;
}
/**
* clk_register_clkdevs - register a set of clk_lookup for a struct clk
* @clk: struct clk to associate with all clk_lookups
* @cl: array of clk_lookup structures with con_id and dev_id pre-initialized
* @num: number of clk_lookup structures to register
*
* To make things easier for mass registration, we detect error clks
* from a previous clk_register() call, and return the error code for
* those. This is to permit this function to be called immediately
* after clk_register().
*/
int clk_register_clkdevs(struct clk *clk, struct clk_lookup *cl, size_t num)
{
unsigned i;
if (IS_ERR(clk))
return PTR_ERR(clk);
for (i = 0; i < num; i++, cl++) {
cl->clk = clk;
clkdev_add(cl);
}
return 0;
}
EXPORT_SYMBOL(clk_register_clkdevs);
|
/* $Id$
*
* Copyright (C) 2008 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
*
* ser is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "ip_set.h"
#include "../../resolve.h"
#include <stdio.h>
#include <string.h>
void ip_set_init(struct ip_set *ip_set, int use_shm) {
memset(ip_set, 0, sizeof(*ip_set));
ip_set->use_shm = use_shm;
ip_tree_init(&ip_set->ipv4_tree);
ip_tree_init(&ip_set->ipv6_tree);
}
void ip_set_destroy(struct ip_set *ip_set) {
ip_tree_destroy(&ip_set->ipv4_tree, 0, ip_set->use_shm);
ip_tree_destroy(&ip_set->ipv6_tree, 0, ip_set->use_shm);
}
int ip_set_add_ip(struct ip_set *ip_set, struct ip_addr *ip, unsigned int network_prefix) {
switch (ip->af) {
case AF_INET:
return ip_tree_add_ip(&ip_set->ipv4_tree, ip->u.addr, (ip->len*8<network_prefix)?ip->len*8:network_prefix, ip_set->use_shm);
case AF_INET6:
return ip_tree_add_ip(&ip_set->ipv6_tree, ip->u.addr, (ip->len*8<network_prefix)?ip->len*8:network_prefix, ip_set->use_shm);
default:
return -1;
}
}
int ip_set_ip_exists(struct ip_set *ip_set, struct ip_addr *ip) {
struct ip_tree_find h;
switch (ip->af) {
case AF_INET:
return ip_tree_find_ip(ip_set->ipv4_tree, ip->u.addr, ip->len*8, &h) > 0;
case AF_INET6:
return ip_tree_find_ip(ip_set->ipv6_tree, ip->u.addr, ip->len*8, &h) > 0;
default:
return -1;
}
}
void ip_set_print(FILE *stream, struct ip_set *ip_set) {
fprintf(stream, "IPv4:\n");
ip_tree_print(stream, ip_set->ipv4_tree, 2);
fprintf(stream, "IPv6:\n");
ip_tree_print(stream, ip_set->ipv6_tree, 2);
}
int ip_set_add_list(struct ip_set *ip_set, str ip_set_s){
str ip_s, mask_s;
/* parse comma delimited string of IPs and masks, e.g. 1.2.3.4,2.3.5.3/24,[abcd:12456:2775:ab::7533],9.8.7.6/255.255.255.0 */
while (ip_set_s.len) {
while (ip_set_s.len && (*ip_set_s.s == ',' || *ip_set_s.s == ';' || *ip_set_s.s == ' ')) {
ip_set_s.s++;
ip_set_s.len--;
}
if (!ip_set_s.len) break;
ip_s.s = ip_set_s.s;
ip_s.len = 0;
while (ip_s.len < ip_set_s.len && (ip_s.s[ip_s.len] != ',' && ip_s.s[ip_s.len] != ';' && ip_s.s[ip_s.len] != ' ' && ip_s.s[ip_s.len] != '/')) {
ip_s.len++;
}
ip_set_s.s += ip_s.len;
ip_set_s.len -= ip_s.len;
mask_s.len = 0;
mask_s.s=0;
if (ip_set_s.len && ip_set_s.s[0] == '/') {
ip_set_s.s++;
ip_set_s.len--;
mask_s.s = ip_set_s.s;
while (mask_s.len < ip_set_s.len && (mask_s.s[mask_s.len] != ',' && mask_s.s[mask_s.len] != ';' && mask_s.s[mask_s.len] != ' ')) {
mask_s.len++;
}
ip_set_s.s += mask_s.len;
ip_set_s.len -= mask_s.len;
}
if (ip_set_add_ip_s(ip_set, ip_s, mask_s) < 0) {
return -1;
}
}
return 0;
}
int ip_set_add_ip_s(struct ip_set *ip_set, str ip_s, str mask_s){
int fl;
struct ip_addr *ip, ip_buff;
unsigned int prefix, i;
if ( ((ip = str2ip(&ip_s))==0)
&& ((ip = str2ip6(&ip_s))==0)
){
ERR("ip_set_add_ip_s: string to ip conversion error '%.*s'\n", ip_s.len, ip_s.s);
return -1;
}
ip_buff = *ip;
if (mask_s.len > 0) {
i = 0;
fl = 0;
while (i < mask_s.len &&
((mask_s.s[i] >= '0' && mask_s.s[i] <= '9') ||
(mask_s.s[i] >= 'a' && mask_s.s[i] <= 'f') ||
(mask_s.s[i] >= 'A' && mask_s.s[i] <= 'F') ||
mask_s.s[i] == '.' ||
mask_s.s[i] == ':' ||
mask_s.s[i] == '[' ||
mask_s.s[i] == ']'
) ) {
fl |= mask_s.s[i] < '0' || mask_s.s[i] > '9';
i++;
}
if (fl) { /* 255.255.255.0 format */
if ( ((ip = str2ip(&mask_s))==0)
&& ((ip = str2ip6(&mask_s))==0)
){
ERR("ip_set_add_ip_s: string to ip mask conversion error '%.*s'\n", mask_s.len, mask_s.s);
return -1;
}
if (ip_buff.af != ip->af) {
ERR("ip_set_add_ip_s: IPv4 vs. IPv6 near '%.*s' vs. '%.*s'\n", ip_s.len, ip_s.s, mask_s.len, mask_s.s);
return -1;
}
fl = 0;
prefix = 0;
for (i=0; i<ip->len; i++) {
unsigned char msk;
msk = 0x80;
while (msk) {
if ((ip->u.addr[i] & msk) != 0) {
if (fl) {
ERR("ip_set_add_ip_s: bad IP mask '%.*s'\n", mask_s.len, mask_s.s);
return -1;
}
prefix++;
}
else {
fl = 1;
}
msk /= 2;
}
}
}
else { /* 24 format */
if (str2int(&mask_s, &prefix) < 0) {
ERR("ip_set_add_ip_s: cannot convert mask '%.*s'\n", mask_s.len, mask_s.s);
return -1;
}
}
}
else {
prefix = ip_buff.len*8;
}
if (ip_set_add_ip(ip_set, &ip_buff, prefix) < 0) {
ERR("ip_set_add_ip_s: cannot add IP into ip set\n");
return -1;
}
return 0;
}
|
/*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
*
* 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 would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
/*
* DETAILED DESCRIPTION
* This is a Phase I test for the fstatfs(2) system call. It is intended
* to provide a limited exposure of the system call, for now. It
* should/will be extended when full functional tests are written for
* fstatfs(2).
*/
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/statfs.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include "test.h"
#include "safe_macros.h"
static void setup(void);
static void cleanup(void);
char *TCID = "fstatfs01";
static int file_fd;
static int pipe_fd;
static struct tcase {
int *fd;
const char *msg;
} tcases[2] = {
{&file_fd, "fstatfs() on a file"},
{&pipe_fd, "fstatfs() on a pipe"},
};
int TST_TOTAL = ARRAY_SIZE(tcases);
int main(int ac, char **av)
{
int lc, i;
struct statfs stats;
tst_parse_opts(ac, av, NULL, NULL);
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
for (i = 0; i < TST_TOTAL; i++) {
TEST(fstatfs(*tcases[i].fd, &stats));
if (TEST_RETURN == -1) {
tst_resm(TFAIL | TTERRNO, "%s", tcases[i].msg);
} else {
tst_resm(TPASS, "%s - f_type=%lx",
tcases[i].msg, stats.f_type);
}
}
}
cleanup();
tst_exit();
}
static void setup(void)
{
int pipe[2];
tst_sig(NOFORK, DEF_HANDLER, cleanup);
TEST_PAUSE;
tst_tmpdir();
file_fd = SAFE_OPEN(cleanup, "test_file", O_RDWR | O_CREAT, 0700);
SAFE_PIPE(cleanup, pipe);
pipe_fd = pipe[0];
SAFE_CLOSE(cleanup, pipe[1]);
}
static void cleanup(void)
{
if (file_fd > 0 && close(file_fd))
tst_resm(TWARN | TERRNO, "close(file_fd) failed");
if (pipe_fd > 0 && close(pipe_fd))
tst_resm(TWARN | TERRNO, "close(pipe_fd) failed");
tst_rmdir();
}
|
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@protocol RevMobAdsDelegate <NSObject>
/**
Fired by Fullscreen, banner and popup. Called when the communication with the server is finished with error.
@param error: contains error information.
*/
- (void)revmobAdDidFailWithError:(NSError *)error;
@optional
# pragma mark Ad Callbacks (Fullscreen, Banner and Popup)
/**
Fired when session is started.
*/
- (void)revmobSessionIsStarted;
/**
Fired when session fails to start.
*/
- (void)revmobSessionNotStartedWithError:(NSError *)error;
/**
Fired by Fullscreen, banner and popup. Called when the communication with the server is finished with success.
*/
- (void)revmobAdDidReceive;
/**
Fired by Fullscreen, banner and popup. Called when the Ad is displayed in the screen.
*/
- (void)revmobAdDisplayed;
/**
Fired by Fullscreen, banner, button and popup.
*/
- (void)revmobUserClickedInTheAd;
/**
Fired by Fullscreen and popup.
*/
- (void)revmobUserClosedTheAd;
# pragma mark Advertiser Callbacks
/**
Called if install is successfully registered
*/
- (void)installDidReceive;
/**
Called if install couldn't be registered
*/
- (void)installDidFail;
@end
|
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#if !defined( OVERLAYTEXT_H )
#define OVERLAYTEXT_H
#ifdef _WIN32
#pragma once
#endif
#include "mathlib/vector.h"
class OverlayText_t
{
public:
OverlayText_t()
{
nextOverlayText = 0;
origin.Init();
bUseOrigin = false;
lineOffset = 0;
flXPos = 0;
flYPos = 0;
text[ 0 ] = 0;
m_flEndTime = 0.0f;
m_nServerCount = -1;
m_nCreationTick = -1;
r = g = b = a = 255;
}
bool IsDead();
void SetEndTime( float duration );
Vector origin;
bool bUseOrigin;
int lineOffset;
float flXPos;
float flYPos;
char text[512];
float m_flEndTime; // When does this text go away
int m_nCreationTick; // If > 0, show only one server frame
int m_nServerCount; // compare server spawn count to remove stale overlays
int r;
int g;
int b;
int a;
OverlayText_t *nextOverlayText;
};
#endif // OVERLAYTEXT_H |
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNETWORKCONFIGURATION_H
#define QNETWORKCONFIGURATION_H
#ifndef QT_MOBILITY_BEARER
# include <QtCore/qglobal.h>
#else
# include "qmobilityglobal.h"
#endif
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
#if defined(Q_OS_WIN) && defined(interface)
#undef interface
#endif
QT_BEGIN_HEADER
#ifndef QT_MOBILITY_BEARER
QT_BEGIN_NAMESPACE
QT_MODULE(Network)
#define QNetworkConfigurationExport Q_NETWORK_EXPORT
#else
QTM_BEGIN_NAMESPACE
#define QNetworkConfigurationExport Q_BEARER_EXPORT
#endif
class QNetworkConfigurationPrivate;
class QNetworkConfigurationExport QNetworkConfiguration
{
public:
QNetworkConfiguration();
QNetworkConfiguration(const QNetworkConfiguration& other);
QNetworkConfiguration &operator=(const QNetworkConfiguration &other);
~QNetworkConfiguration();
bool operator==(const QNetworkConfiguration &other) const;
inline bool operator!=(const QNetworkConfiguration &other) const
{ return !operator==(other); }
enum Type {
InternetAccessPoint = 0,
ServiceNetwork,
UserChoice,
Invalid
};
enum Purpose {
UnknownPurpose = 0,
PublicPurpose,
PrivatePurpose,
ServiceSpecificPurpose
};
enum StateFlag {
Undefined = 0x0000001,
Defined = 0x0000002,
Discovered = 0x0000006,
Active = 0x000000e
};
Q_DECLARE_FLAGS(StateFlags, StateFlag)
#ifndef QT_MOBILITY_BEARER
enum BearerType {
BearerUnknown,
BearerEthernet,
BearerWLAN,
Bearer2G,
BearerCDMA2000,
BearerWCDMA,
BearerHSPA,
BearerBluetooth,
BearerWiMAX
};
#endif
StateFlags state() const;
Type type() const;
Purpose purpose() const;
#ifndef QT_MOBILITY_BEARER
#ifdef QT_DEPRECATED
// Required to maintain source compatibility with Qt Mobility.
QT_DEPRECATED inline QString bearerName() const { return bearerTypeName(); }
#endif
BearerType bearerType() const;
QString bearerTypeName() const;
#else
QString bearerName() const;
#endif
QString identifier() const;
bool isRoamingAvailable() const;
QList<QNetworkConfiguration> children() const;
QString name() const;
bool isValid() const;
private:
friend class QNetworkConfigurationPrivate;
friend class QNetworkConfigurationManager;
friend class QNetworkConfigurationManagerPrivate;
friend class QNetworkSessionPrivate;
QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> d;
};
#ifndef QT_MOBILITY_BEARER
QT_END_NAMESPACE
#else
QTM_END_NAMESPACE
#endif
QT_END_HEADER
#endif // QNETWORKCONFIGURATION_H
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.