text stringlengths 4 6.14k |
|---|
/*
* Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#ifndef MODULEUPDATELOADER_H
#define MODULEUPDATELOADER_H
#ifdef WIN32
#ifdef PX_X64
#define UPDATE_LOADER_DLL_NAME "PhysXUpdateLoader64.dll"
#else
#define UPDATE_LOADER_DLL_NAME "PhysXUpdateLoader.dll"
#endif
// This GUID should change any time we release APEX with a public interface change.
#if NX_SDK_VERSION_MAJOR == 2
#define DEFAULT_APP_GUID "165F143C-15CB-47FA-ACE3-2002B3684026"
#else
#define DEFAULT_APP_GUID "1AE7180B-79E5-4234-91A7-E387331B5993"
#endif
#include "PsWindowsInclude.h"
class ModuleUpdateLoader
{
public:
ModuleUpdateLoader(const char* updateLoaderDllName);
~ModuleUpdateLoader();
// Loads the given module through the update loader. Loads it from the path if
// the update loader doesn't find the requested module. Returns NULL if no
// module found.
HMODULE loadModule(const char* moduleName, const char* appGuid);
protected:
HMODULE mUpdateLoaderDllHandle;
FARPROC mGetUpdatedModuleFunc;
// unit test fixture
friend class ModuleUpdateLoaderTest;
};
#endif // WIN32
#endif // MODULEUPDATELOADER_H
|
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "LMLayoutView.h"
/**
* Box view alignment options.
*/
typedef NS_ENUM(NSInteger, LMBoxViewAlignment) {
/** Top layout alignment. */
LMBoxViewAlignmentTop,
/** Bottom layout alignment. */
LMBoxViewAlignmentBottom,
/** Left layout alignment. */
LMBoxViewAlignmentLeft,
/** Right layout alignment. */
LMBoxViewAlignmentRight,
/** Leading layout alignment. */
LMBoxViewAlignmentLeading,
/** Trailing layout alignment. */
LMBoxViewAlignmentTrailing,
/** Center layout alignment. */
LMBoxViewAlignmentCenter,
/** Baseline layout alignment. */
LMBoxViewAlignmentBaseline,
/** Fill layout alignment. */
LMBoxViewAlignmentFill
};
/**
* Abstract base class for box views.
*/
@interface LMBoxView : LMLayoutView
/**
* Defines how subviews are aligned.
*/
@property (nonatomic) LMBoxViewAlignment alignment;
/**
* The amount of spacing between successive subviews.
*/
@property (nonatomic) CGFloat spacing;
@end
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/kinesisanalyticsv2/KinesisAnalyticsV2_EXPORTS.h>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace KinesisAnalyticsV2
{
namespace Model
{
/**
* <p>Describes updates to whether snapshots are enabled for a Flink-based Kinesis
* Data Analytics application.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/kinesisanalyticsv2-2018-05-23/ApplicationSnapshotConfigurationUpdate">AWS
* API Reference</a></p>
*/
class AWS_KINESISANALYTICSV2_API ApplicationSnapshotConfigurationUpdate
{
public:
ApplicationSnapshotConfigurationUpdate();
ApplicationSnapshotConfigurationUpdate(Aws::Utils::Json::JsonView jsonValue);
ApplicationSnapshotConfigurationUpdate& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>Describes updates to whether snapshots are enabled for an application.</p>
*/
inline bool GetSnapshotsEnabledUpdate() const{ return m_snapshotsEnabledUpdate; }
/**
* <p>Describes updates to whether snapshots are enabled for an application.</p>
*/
inline bool SnapshotsEnabledUpdateHasBeenSet() const { return m_snapshotsEnabledUpdateHasBeenSet; }
/**
* <p>Describes updates to whether snapshots are enabled for an application.</p>
*/
inline void SetSnapshotsEnabledUpdate(bool value) { m_snapshotsEnabledUpdateHasBeenSet = true; m_snapshotsEnabledUpdate = value; }
/**
* <p>Describes updates to whether snapshots are enabled for an application.</p>
*/
inline ApplicationSnapshotConfigurationUpdate& WithSnapshotsEnabledUpdate(bool value) { SetSnapshotsEnabledUpdate(value); return *this;}
private:
bool m_snapshotsEnabledUpdate;
bool m_snapshotsEnabledUpdateHasBeenSet;
};
} // namespace Model
} // namespace KinesisAnalyticsV2
} // namespace Aws
|
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/gamelift/GameLift_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
namespace Aws
{
namespace GameLift
{
namespace Model
{
enum class PolicyType
{
NOT_SET,
RuleBased,
TargetBased
};
namespace PolicyTypeMapper
{
AWS_GAMELIFT_API PolicyType GetPolicyTypeForName(const Aws::String& name);
AWS_GAMELIFT_API Aws::String GetNameForPolicyType(PolicyType value);
} // namespace PolicyTypeMapper
} // namespace Model
} // namespace GameLift
} // namespace Aws
|
/*
* Copyright (c) 2010-2015 Wind River Systems, Inc.
* Copyright (c) 2017 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief Kernel swapper code for POSIX
*
* This module implements the arch_swap() routine for the POSIX architecture.
*
*/
#include "kernel.h"
#include <kernel_structs.h>
#include "posix_core.h"
#include "irq.h"
#include "kswap.h"
#include <pm/pm.h>
int arch_swap(unsigned int key)
{
/*
* struct k_thread * _current is the currently runnig thread
* struct k_thread * _kernel.ready_q.cache contains the next thread to
* run (cannot be NULL)
*
* Here a "real" arch would save all processor registers, stack pointer
* and so forth. But we do not need to do so because we use posix
* threads => those are all nicely kept by the native OS kernel
*/
#if CONFIG_INSTRUMENT_THREAD_SWITCHING
z_thread_mark_switched_out();
#endif
_current->callee_saved.key = key;
_current->callee_saved.retval = -EAGAIN;
/* retval may be modified with a call to
* arch_thread_return_value_set()
*/
posix_thread_status_t *ready_thread_ptr =
(posix_thread_status_t *)
_kernel.ready_q.cache->callee_saved.thread_status;
posix_thread_status_t *this_thread_ptr =
(posix_thread_status_t *)
_current->callee_saved.thread_status;
_current = _kernel.ready_q.cache;
#if CONFIG_INSTRUMENT_THREAD_SWITCHING
z_thread_mark_switched_in();
#endif
/*
* Here a "real" arch would load all processor registers for the thread
* to run. In this arch case, we just block this thread until allowed
* to run later, and signal to whomever is allowed to run to
* continue.
*/
posix_swap(ready_thread_ptr->thread_idx,
this_thread_ptr->thread_idx);
/* When we continue, _kernel->current points back to this thread */
irq_unlock(_current->callee_saved.key);
return _current->callee_saved.retval;
}
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
/* This is just a version of arch_swap() in which we do not save anything
* about the current thread.
*
* Note that we will never come back to this thread: posix_main_thread_start()
* does never return.
*/
void arch_switch_to_main_thread(struct k_thread *main_thread, char *stack_ptr,
k_thread_entry_t _main)
{
ARG_UNUSED(stack_ptr);
ARG_UNUSED(_main);
posix_thread_status_t *ready_thread_ptr =
(posix_thread_status_t *)
_kernel.ready_q.cache->callee_saved.thread_status;
#ifdef CONFIG_INSTRUMENT_THREAD_SWITCHING
z_thread_mark_switched_out();
#endif
_current = _kernel.ready_q.cache;
#ifdef CONFIG_INSTRUMENT_THREAD_SWITCHING
z_thread_mark_switched_in();
#endif
posix_main_thread_start(ready_thread_ptr->thread_idx);
} /* LCOV_EXCL_LINE */
#endif
#ifdef CONFIG_PM
/**
* If the kernel is in idle mode, take it out
*/
void posix_irq_check_idle_exit(void)
{
if (_kernel.idle) {
int32_t idle_val = _kernel.idle;
_kernel.idle = 0;
z_pm_save_idle_exit(idle_val);
}
}
#endif
|
//
// MobFoxNativeCustomEventSmaato.h
// MobFoxCoreDemo
//
// Created by Shimon Shnitzer on 17/5/16.
// Copyright © 2015 Shimon Shnitzer. All rights reserved.
//
#ifndef MobFoxNativeCustomEventSmaato_h
#define MobFoxNativeCustomEventSmaato_h
#import <MobFoxSDKCore/MobFoxSDKCore.h>
#import <iSoma/iSoma.h>
@interface MobFoxNativeCustomEventSmaato : MobFoxNativeCustomEvent <SOMANativeAdDelegate>
@property (strong, nonatomic) UIViewController *parentViewController;
@property (strong, nonatomic) SOMANativeAd *nativeAd;
@end
#endif /* MobFoxNativeCustomEventSmaato_h */
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/gamelift/GameLift_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace Utils
{
namespace Json
{
class JsonValue;
} // namespace Json
} // namespace Utils
namespace GameLift
{
namespace Model
{
/**
* <p>Represents the returned data in response to a request
* operation.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/gamelift-2015-10-01/StartFleetActionsOutput">AWS
* API Reference</a></p>
*/
class AWS_GAMELIFT_API StartFleetActionsResult
{
public:
StartFleetActionsResult();
StartFleetActionsResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
StartFleetActionsResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
/**
* <p>A unique identifier for the fleet to restart actions on.</p>
*/
inline const Aws::String& GetFleetId() const{ return m_fleetId; }
/**
* <p>A unique identifier for the fleet to restart actions on.</p>
*/
inline void SetFleetId(const Aws::String& value) { m_fleetId = value; }
/**
* <p>A unique identifier for the fleet to restart actions on.</p>
*/
inline void SetFleetId(Aws::String&& value) { m_fleetId = std::move(value); }
/**
* <p>A unique identifier for the fleet to restart actions on.</p>
*/
inline void SetFleetId(const char* value) { m_fleetId.assign(value); }
/**
* <p>A unique identifier for the fleet to restart actions on.</p>
*/
inline StartFleetActionsResult& WithFleetId(const Aws::String& value) { SetFleetId(value); return *this;}
/**
* <p>A unique identifier for the fleet to restart actions on.</p>
*/
inline StartFleetActionsResult& WithFleetId(Aws::String&& value) { SetFleetId(std::move(value)); return *this;}
/**
* <p>A unique identifier for the fleet to restart actions on.</p>
*/
inline StartFleetActionsResult& WithFleetId(const char* value) { SetFleetId(value); return *this;}
/**
* <p>The Amazon Resource Name (<a
* href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>)
* that is assigned to a GameLift fleet resource and uniquely identifies it. ARNs
* are unique across all Regions. Format is
* <code>arn:aws:gamelift:<region>::fleet/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912</code>.</p>
*/
inline const Aws::String& GetFleetArn() const{ return m_fleetArn; }
/**
* <p>The Amazon Resource Name (<a
* href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>)
* that is assigned to a GameLift fleet resource and uniquely identifies it. ARNs
* are unique across all Regions. Format is
* <code>arn:aws:gamelift:<region>::fleet/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912</code>.</p>
*/
inline void SetFleetArn(const Aws::String& value) { m_fleetArn = value; }
/**
* <p>The Amazon Resource Name (<a
* href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>)
* that is assigned to a GameLift fleet resource and uniquely identifies it. ARNs
* are unique across all Regions. Format is
* <code>arn:aws:gamelift:<region>::fleet/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912</code>.</p>
*/
inline void SetFleetArn(Aws::String&& value) { m_fleetArn = std::move(value); }
/**
* <p>The Amazon Resource Name (<a
* href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>)
* that is assigned to a GameLift fleet resource and uniquely identifies it. ARNs
* are unique across all Regions. Format is
* <code>arn:aws:gamelift:<region>::fleet/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912</code>.</p>
*/
inline void SetFleetArn(const char* value) { m_fleetArn.assign(value); }
/**
* <p>The Amazon Resource Name (<a
* href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>)
* that is assigned to a GameLift fleet resource and uniquely identifies it. ARNs
* are unique across all Regions. Format is
* <code>arn:aws:gamelift:<region>::fleet/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912</code>.</p>
*/
inline StartFleetActionsResult& WithFleetArn(const Aws::String& value) { SetFleetArn(value); return *this;}
/**
* <p>The Amazon Resource Name (<a
* href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>)
* that is assigned to a GameLift fleet resource and uniquely identifies it. ARNs
* are unique across all Regions. Format is
* <code>arn:aws:gamelift:<region>::fleet/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912</code>.</p>
*/
inline StartFleetActionsResult& WithFleetArn(Aws::String&& value) { SetFleetArn(std::move(value)); return *this;}
/**
* <p>The Amazon Resource Name (<a
* href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>)
* that is assigned to a GameLift fleet resource and uniquely identifies it. ARNs
* are unique across all Regions. Format is
* <code>arn:aws:gamelift:<region>::fleet/fleet-a1234567-b8c9-0d1e-2fa3-b45c6d7e8912</code>.</p>
*/
inline StartFleetActionsResult& WithFleetArn(const char* value) { SetFleetArn(value); return *this;}
private:
Aws::String m_fleetId;
Aws::String m_fleetArn;
};
} // namespace Model
} // namespace GameLift
} // namespace Aws
|
/* $NetBSD: fsspace.c,v 1.1.1.1 2009/06/23 10:08:59 tron Exp $ */
/*++
/* NAME
/* fsspace 3
/* SUMMARY
/* determine available file system space
/* SYNOPSIS
/* #include <fsspace.h>
/*
/* struct fsspace {
/* .in +4
/* unsigned long block_size;
/* unsigned long block_free;
/* .in -4
/* };
/*
/* void fsspace(path, sp)
/* const char *path;
/* struct fsspace *sp;
/* DESCRIPTION
/* fsspace() returns the amount of available space in the file
/* system specified in \fIpath\fR, in terms of the block size and
/* of the number of available blocks.
/* DIAGNOSTICS
/* All errors are fatal.
/* BUGS
/* Use caution when doing computations with the result from fsspace().
/* It is easy to cause overflow (by multiplying large numbers) or to
/* cause underflow (by subtracting unsigned numbers).
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/
/* System library. */
#include <sys_defs.h>
#if defined(STATFS_IN_SYS_MOUNT_H)
#include <sys/param.h>
#include <sys/mount.h>
#elif defined(STATFS_IN_SYS_VFS_H)
#include <sys/vfs.h>
#elif defined(STATVFS_IN_SYS_STATVFS_H)
#include <sys/statvfs.h>
#elif defined(STATFS_IN_SYS_STATFS_H)
#include <sys/statfs.h>
#else
#ifdef USE_STATFS
#error "please specify the include file with `struct statfs'"
#else
#error "please specify the include file with `struct statvfs'"
#endif
#endif
/* Utility library. */
#include <msg.h>
#include <fsspace.h>
/* fsspace - find amount of available file system space */
void fsspace(const char *path, struct fsspace * sp)
{
const char *myname = "fsspace";
#ifdef USE_STATFS
#ifdef USE_STRUCT_FS_DATA /* Ultrix */
struct fs_data fsbuf;
if (statfs(path, &fsbuf) < 0)
msg_fatal("statfs %s: %m", path);
sp->block_size = 1024;
sp->block_free = fsbuf.fd_bfreen;
#else
struct statfs fsbuf;
if (statfs(path, &fsbuf) < 0)
msg_fatal("statfs %s: %m", path);
sp->block_size = fsbuf.f_bsize;
sp->block_free = fsbuf.f_bavail;
#endif
#endif
#ifdef USE_STATVFS
struct statvfs fsbuf;
if (statvfs(path, &fsbuf) < 0)
msg_fatal("statvfs %s: %m", path);
sp->block_size = fsbuf.f_frsize;
sp->block_free = fsbuf.f_bavail;
#endif
if (msg_verbose)
msg_info("%s: %s: block size %lu, blocks free %lu",
myname, path, sp->block_size, sp->block_free);
}
#ifdef TEST
/*
* Proof-of-concept test program: print free space unit and count for all
* listed file systems.
*/
#include <vstream.h>
int main(int argc, char **argv)
{
struct fsspace sp;
if (argc == 1)
msg_fatal("usage: %s filesystem...", argv[0]);
while (--argc && *++argv) {
fsspace(*argv, &sp);
vstream_printf("%10s: block size %lu, blocks free %lu\n",
*argv, sp.block_size, sp.block_free);
vstream_fflush(VSTREAM_OUT);
}
return (0);
}
#endif
|
/*
* Copyright 2006-2011 The FLWOR Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifndef ZORBA_LINK_H
#define ZORBA_LINK_H
#include <zorba/zorba.h>
#include <zorba/external_module.h>
#include <zorba/function.h>
namespace zorba { namespace linkmodule {
class XercesFuncFunction;
class OurFuncFunction;
class LinkModule : public ExternalModule
{
public:
LinkModule();
virtual ~LinkModule();
virtual void destroy();
virtual zorba::ExternalFunction*
getExternalFunction(const zorba::String& aLocalname);
virtual zorba::String
getURI() const { return "http://zorba-tests.28.io/modules/link"; }
private:
XercesFuncFunction* theXercesFunc;
OurFuncFunction* theOurFunc;
};
class XercesFuncFunction : public ContextualExternalFunction
{
public:
XercesFuncFunction(const LinkModule* aModule);
virtual ~XercesFuncFunction() {}
virtual zorba::String
getLocalName() const { return "xerces-func"; }
virtual zorba::String
getURI() const { return theModule->getURI(); }
virtual zorba::ItemSequence_t
evaluate(Arguments_t const& aArgs, zorba::StaticContext const* aSctx,
zorba::DynamicContext const* aDctx) const;
private:
LinkModule const* theModule;
};
class OurFuncFunction : public ContextualExternalFunction
{
public:
OurFuncFunction(const LinkModule* aModule);
virtual ~OurFuncFunction() {}
virtual zorba::String
getLocalName() const { return "our-func"; }
virtual zorba::String
getURI() const { return theModule->getURI(); }
virtual zorba::ItemSequence_t
evaluate(Arguments_t const& aArgs, zorba::StaticContext const* aSctx,
zorba::DynamicContext const* aDctx) const;
private:
LinkModule const* theModule;
};
} /* namespace linkmodule */
} /* namespace zorba */
#endif /* ZORBA_LINK_H */
|
// -*- C++ -*-
//=============================================================================
/**
* @file HTBP_Notifier.h
*
* $Id: HTBP_Notifier.h 80826 2008-03-04 14:51:23Z wotte $
*
* @author Phil Mesnier, Priyanka Gontla
*/
//=============================================================================
#ifndef ACE_HTBP_NOTIFIER_H
#define ACE_HTBP_NOTIFIER_H
#include /**/ "ace/pre.h"
#include "ace/Event_Handler.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "HTBP_Export.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE
{
namespace HTBP
{
// Forward declarations.
class Channel;
class HTBP_Export Notifier : public ACE_Event_Handler
{
public:
Notifier (Channel *ch);
int handle_input(ACE_HANDLE );
int handle_output(ACE_HANDLE );
void unregister (void);
ACE_HANDLE get_handle (void) const;
private:
Channel *channel_;
};
}
}
ACE_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif /* ACE_HTBP_NOTIFIER_H */
|
////////////////////////////////////////////////////////////////////////////////
//
// APPS QUICKLY
// Copyright 2015 Apps Quickly Pty Ltd
// All Rights Reserved.
//
// NOTICE: Prepared by AppsQuick.ly on behalf of Apps Quickly. This software
// is proprietary information. Unauthorized use is prohibited.
//
////////////////////////////////////////////////////////////////////////////////
#import "TRCRequest.h"
@interface RequestToGetIssues : NSObject <TRCRequest>
@property (nonatomic) NSRange range;
@property (nonatomic) NSNumber *projectId;
@end
|
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* BSD linked list implementation - extracted for use with liberasurecode
*
*/
#ifndef _LIST_H
#define _LIST_H
/*
* A singly-linked list is headed by a single forward pointer. The elements
* are singly linked for minimum space and pointer manipulation overhead at
* the expense of O(n) removal for arbitrary elements. New elements can be
* added to the list after an existing element or at the head of the list.
* Elements being removed from the head of the list should use the explicit
* macro for this purpose for optimum efficiency. A singly-linked list may
* only be traversed in the forward direction. Singly-linked lists are ideal
* for applications with large datasets and few or no removals or for
* implementing a LIFO queue.
*/
/*
* Singly-linked List declarations.
*/
#define SLIST_HEAD(name, type) \
struct name { \
struct type *slh_first; /* first element */ \
}
#define SLIST_HEAD_INITIALIZER(head) \
{ NULL }
#define SLIST_ENTRY(type) \
struct { \
struct type *sle_next; /* next element */ \
}
/*
* Singly-linked List functions.
*/
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
#define SLIST_FIRST(head) ((head)->slh_first)
#define SLIST_FOREACH(var, head, field) \
for ((var) = SLIST_FIRST((head)); \
(var); \
(var) = SLIST_NEXT((var), field))
#define SLIST_INIT(head) do { \
SLIST_FIRST((head)) = NULL; \
} while (0)
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
SLIST_NEXT((slistelm), field) = (elm); \
} while (0)
#define SLIST_INSERT_HEAD(head, elm, field) do { \
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
SLIST_FIRST((head)) = (elm); \
} while (0)
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
#define SLIST_REMOVE(head, elm, type, field) do { \
if (SLIST_FIRST((head)) == (elm)) { \
SLIST_REMOVE_HEAD((head), field); \
} \
else { \
struct type *curelm = SLIST_FIRST((head)); \
while (SLIST_NEXT(curelm, field) != (elm)) \
curelm = SLIST_NEXT(curelm, field); \
SLIST_NEXT(curelm, field) = \
SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
} \
} while (0)
#define SLIST_REMOVE_HEAD(head, field) do { \
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
} while (0)
#endif // _LIST_H
|
/*-
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. 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.
*
* @(#)limits.h 8.3 (Berkeley) 1/4/94
* $FreeBSD: release/9.1.0/sys/arm/include/_limits.h 217145 2011-01-08 11:13:34Z tijl $
*/
#ifndef _MACHINE__LIMITS_H_
#define _MACHINE__LIMITS_H_
/*
* According to ANSI (section 2.2.4.2), the values below must be usable by
* #if preprocessing directives. Additionally, the expression must have the
* same type as would an expression that is an object of the corresponding
* type converted according to the integral promotions. The subtraction for
* INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
* unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
*/
#define __CHAR_BIT 8 /* number of bits in a char */
#define __SCHAR_MAX 0x7f /* max value for a signed char */
#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
#define __UCHAR_MAX 0xff /* max value for an unsigned char */
#define __USHRT_MAX 0xffff /* max value for an unsigned short */
#define __SHRT_MAX 0x7fff /* max value for a short */
#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
#define __UINT_MAX 0xffffffff /* max value for an unsigned int */
#define __INT_MAX 0x7fffffff /* max value for an int */
#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
#define __LONG_MAX 0x7fffffffL /* max value for a long */
#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
/* max value for an unsigned long long */
#define __ULLONG_MAX 0xffffffffffffffffULL
#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */
#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */
#define __OFF_MAX __LLONG_MAX /* max value for a off_t */
#define __OFF_MIN __LLONG_MIN /* min value for a off_t */
/* Quads and long longs are the same size. Ensure they stay in sync. */
#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */
#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
#define __LONG_BIT 32
#define __WORD_BIT 32
/* Minimum signal stack size. */
#define __MINSIGSTKSZ (1024 * 4)
#endif /* !_MACHINE__LIMITS_H_ */
|
#ifndef TARANTOOL_UUID_H_INCLUDED
#define TARANTOOL_UUID_H_INCLUDED
/*
* Copyright 2010-2016, Tarantool AUTHORS, please see AUTHORS file.
*
* 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 <COPYRIGHT HOLDER> ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h> /* snprintf */
#include <lib/bit/bit.h>
#if defined(__cplusplus)
extern "C" {
#endif
enum { UUID_LEN = 16, UUID_STR_LEN = 36 };
/**
* \brief UUID structure struct
*/
struct tt_uuid {
uint32_t time_low;
uint16_t time_mid;
uint16_t time_hi_and_version;
uint8_t clock_seq_hi_and_reserved;
uint8_t clock_seq_low;
uint8_t node[6];
};
/**
* \brief Generate new UUID
* \param uu[out] UUID
*/
void
tt_uuid_create(struct tt_uuid *uu);
/**
* \brief Parse UUID from string.
* \param in string
* \param uu[out] UUID
* \return
*/
inline int
tt_uuid_from_string(const char *in, struct tt_uuid *uu)
{
if (strlen(in) != UUID_STR_LEN ||
sscanf(in, "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
&uu->time_low, &uu->time_mid, &uu->time_hi_and_version,
&uu->clock_seq_hi_and_reserved, &uu->clock_seq_low,
&uu->node[0], &uu->node[1], &uu->node[2], &uu->node[3],
&uu->node[4], &uu->node[5]) != 11)
return 1;
/* Check variant (NCS, RFC4122, MSFT) */
uint8_t n = uu->clock_seq_hi_and_reserved;
if ((n & 0x80) != 0x00 && (n & 0xc0) != 0x80 && (n & 0xe0) != 0xc0)
return 1;
return 0;
}
/**
* \brief Compare UUIDs lexicographically.
* \param a UUID
* \param b UUID
* \retval comparison result, as in strcmp()
*/
inline int
tt_uuid_compare(const struct tt_uuid *a, const struct tt_uuid *b)
{
#define cmp_tt_uuid_field(field) \
if (a->field > b->field) return 1; \
if (a->field < b->field) return -1;
cmp_tt_uuid_field(time_low);
cmp_tt_uuid_field(time_mid);
cmp_tt_uuid_field(time_hi_and_version);
cmp_tt_uuid_field(clock_seq_hi_and_reserved);
cmp_tt_uuid_field(clock_seq_low);
cmp_tt_uuid_field(node[0]);
cmp_tt_uuid_field(node[1]);
cmp_tt_uuid_field(node[2]);
cmp_tt_uuid_field(node[3]);
cmp_tt_uuid_field(node[4]);
cmp_tt_uuid_field(node[5]);
#undef cmp_tt_uuid_field
return 0;
}
/**
* \brief Format UUID to RFC 4122 string.
* \param uu uuid
* \param[out] out buffer, must be at least UUID_STR_LEN + 1 length
*/
inline void
tt_uuid_to_string(const struct tt_uuid *uu, char *out)
{
sprintf(out, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uu->time_low, uu->time_mid, uu->time_hi_and_version,
uu->clock_seq_hi_and_reserved, uu->clock_seq_low, uu->node[0],
uu->node[1], uu->node[2], uu->node[3], uu->node[4], uu->node[5]);
}
/**
* \brief Return byte order swapped UUID (LE -> BE and vice versa)
* \param uu
*/
inline void
tt_uuid_bswap(struct tt_uuid *uu)
{
uu->time_low = bswap_u32(uu->time_low);
uu->time_mid = bswap_u16(uu->time_mid);
uu->time_hi_and_version = bswap_u16(uu->time_hi_and_version);
}
/**
* \brief Test that uuid is nil
* \param uu UUID
* \retval true if all members of \a uu 0
* \retval false otherwise
*/
inline bool
tt_uuid_is_nil(const struct tt_uuid *uu)
{
const uint64_t *p = (const uint64_t *) uu;
return !p[0] && !p[1];
}
/**
* \brief Test that \a lhs equal \a rhs
* \param lhs UUID
* \param rhs UUID
* \retval true if \a lhs equal \a rhs
* \retval false otherwise
*/
inline bool
tt_uuid_is_equal(const struct tt_uuid *lhs, const struct tt_uuid *rhs)
{
const uint64_t *lp = (const uint64_t *) lhs;
const uint64_t *rp = (const uint64_t *) rhs;
return lp[0] == rp[0] && lp[1] == rp[1];
}
extern const struct tt_uuid uuid_nil;
char *
tt_uuid_str(const struct tt_uuid *uu);
int
tt_uuid_from_strl(const char *in, size_t len, struct tt_uuid *uu);
#if defined(__cplusplus)
} /* extern "C" */
#endif
#endif /* TARANTOOL_UUID_H_INCLUDED */
|
/*
* refuse() reports a refused connection, and takes the consequences: in
* case of a datagram-oriented service, the unread datagram is taken from
* the input queue (or inetd would see the same datagram again and again);
* the program is terminated.
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*
* $FreeBSD: soc2013/dpl/head/contrib/tcp_wrappers/refuse.c 57018 2000-02-03 10:27:03Z shin $
*/
#ifndef lint
static char sccsid[] = "@(#) refuse.c 1.5 94/12/28 17:42:39";
#endif
/* System libraries. */
#include <stdio.h>
#include <syslog.h>
/* Local stuff. */
#include "tcpd.h"
/* refuse - refuse request */
void refuse(request)
struct request_info *request;
{
#ifdef INET6
syslog(deny_severity, "refused connect from %s (%s)",
eval_client(request), eval_hostaddr(request->client));
#else
syslog(deny_severity, "refused connect from %s", eval_client(request));
#endif
clean_exit(request);
/* NOTREACHED */
}
|
/*
* Copyright (c) 2014, 2015, 2016
* Kyle Cardoza <Kyle.Cardoza@icloud.com>
*
* All rights reserved.
*
* This file is part of GTKKit. It may be distributed under the terms of the
* 2-clause BSD License, which can be found in the file COPYING.BSD included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU Lesser
* General Public License, either version 2 or 3, which can be found in the
* files COPYING.LGPL2 and COPYING.LGPL3, respectively, both also included in
* the packaging of this file.
*/
/*! @file GTKApplicationDelegate.h */
#import <ObjFW/ObjFW.h>
#import <gtk/gtk.h>
OF_ASSUME_NONNULL_BEGIN
/*!
* @brief This macro sets the class used as the app delegate, and provides the
* main() function.
*/
#define GTK_APPLICATION_DELEGATE(cls) \
int \
main(int argc, char *argv[]) \
{ \
GTKApp = [GTKApplication sharedApplication]; \
GTKApp.delegateClass = [cls class]; \
GTKApp.argc = &argc; \
GTKApp.argv = &argv; \
[GTKApp startup]; \
[GTKApp run]; \
return 0; \
}
/*!
* @brief The protocol adopted by classes which are used as GTKApplication
* delegates.
*/
@protocol GTKApplicationDelegate <OFObject, OFApplicationDelegate>
@optional
/*!
* @brief Ask the application delegate whether or not the application should
* allow itself to be terminated.
*/
- (bool)applicationShouldTerminate;
@end
OF_ASSUME_NONNULL_END
|
/*-
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* a) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* b) 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.
*
* c) Neither the name of Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: soc2013/dpl/head/sys/netinet/sctp_crc32.c 236193 2012-05-23 11:26:28Z tuexen $");
#include <netinet/sctp_os.h>
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#include <netinet/sctp_pcb.h>
#if !defined(SCTP_WITH_NO_CSUM)
static uint32_t
sctp_finalize_crc32c(uint32_t crc32c)
{
uint32_t result;
#if BYTE_ORDER == BIG_ENDIAN
uint8_t byte0, byte1, byte2, byte3;
#endif
/* Complement the result */
result = ~crc32c;
#if BYTE_ORDER == BIG_ENDIAN
/*
* For BIG-ENDIAN.. aka Motorola byte order the result is in
* little-endian form. So we must manually swap the bytes. Then we
* can call htonl() which does nothing...
*/
byte0 = result & 0x000000ff;
byte1 = (result >> 8) & 0x000000ff;
byte2 = (result >> 16) & 0x000000ff;
byte3 = (result >> 24) & 0x000000ff;
crc32c = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);
#else
/*
* For INTEL platforms the result comes out in network order. No
* htonl is required or the swap above. So we optimize out both the
* htonl and the manual swap above.
*/
crc32c = result;
#endif
return (crc32c);
}
uint32_t
sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
{
/*
* given a mbuf chain with a packetheader offset by 'offset'
* pointing at a sctphdr (with csum set to 0) go through the chain
* of SCTP_BUF_NEXT()'s and calculate the SCTP checksum. This also
* has a side bonus as it will calculate the total length of the
* mbuf chain. Note: if offset is greater than the total mbuf
* length, checksum=1, pktlen=0 is returned (ie. no real error code)
*/
uint32_t base = 0xffffffff;
struct mbuf *at;
at = m;
/* find the correct mbuf and offset into mbuf */
while ((at != NULL) && (offset > (uint32_t) SCTP_BUF_LEN(at))) {
offset -= SCTP_BUF_LEN(at); /* update remaining offset
* left */
at = SCTP_BUF_NEXT(at);
}
while (at != NULL) {
if ((SCTP_BUF_LEN(at) - offset) > 0) {
base = calculate_crc32c(base,
(unsigned char *)(SCTP_BUF_AT(at, offset)),
(unsigned int)(SCTP_BUF_LEN(at) - offset));
}
if (offset) {
/* we only offset once into the first mbuf */
if (offset < (uint32_t) SCTP_BUF_LEN(at))
offset = 0;
else
offset -= SCTP_BUF_LEN(at);
}
at = SCTP_BUF_NEXT(at);
}
base = sctp_finalize_crc32c(base);
return (base);
}
#endif /* !defined(SCTP_WITH_NO_CSUM) */
void
sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
{
#if defined(SCTP_WITH_NO_CSUM)
#ifdef INVARIANTS
panic("sctp_delayed_cksum() called when using no SCTP CRC.");
#endif
#else
uint32_t checksum;
checksum = sctp_calculate_cksum(m, offset);
SCTP_STAT_DECR(sctps_sendhwcrc);
SCTP_STAT_INCR(sctps_sendswcrc);
offset += offsetof(struct sctphdr, checksum);
if (offset + sizeof(uint32_t) > (uint32_t) (m->m_len)) {
SCTP_PRINTF("sctp_delayed_cksum(): m->len: %d, off: %d.\n",
(uint32_t) m->m_len, offset);
/*
* XXX this shouldn't happen, but if it does, the correct
* behavior may be to insert the checksum in the appropriate
* next mbuf in the chain.
*/
return;
}
*(uint32_t *) (m->m_data + offset) = checksum;
#endif
}
|
#pragma once
#include <node.h>
#include <v8.h>
#include <iostream>
#include <math.h>
#include <memory>
#include <algorithm>
#include <vector>
#include <string>
#include <stdio.h>
#include "Box2D/Box2D.h"
using std::vector;
using std::unique_ptr;
using std::shared_ptr;
using std::weak_ptr;
using std::cout;
using std::cerr;
using std::endl;
#define BOUNDARY_BLOCKING 0//bounce off edge, registers as collision
#define BOUNDARY_SLIDING 1//leave one side enter other
#define BOUNDARY_NONE 2//can leave map
|
// Copyright 2021 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_PAGE_INFO_PAGE_INFO_PERMISSION_CONTENT_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_PERMISSION_CONTENT_VIEW_H_
#include "components/page_info/page_info_ui.h"
#include "ui/views/view.h"
class ChromePageInfoUiDelegate;
class NonAccessibleImageView;
namespace views {
class Checkbox;
class Label;
class ToggleButton;
} // namespace views
// The view that is used as a content view of the permissions subpages in page
// info. It contains information about the permission (icon, title, state label)
// and controls to change the permission state (toggle, checkbox and manage
// button).
// *---------------------------------------------------------------*
// | Icon | Title | Toggle |
// | | State label | |
// | | | |
// | | "Remember this setting" checkbox | |
// |---------------------------------------------------------------|
// | Manage button |
// *---------------------------------------------------------------*
class PageInfoPermissionContentView : public views::View, public PageInfoUI {
public:
PageInfoPermissionContentView(PageInfo* presenter,
ChromePageInfoUiDelegate* ui_delegate,
ContentSettingsType type);
~PageInfoPermissionContentView() override;
// PageInfoUI implementations.
void SetPermissionInfo(const PermissionInfoList& permission_info_list,
ChosenObjectInfoList chosen_object_info_list) override;
private:
void OnToggleButtonPressed();
void OnRememberSettingPressed();
void PermissionChanged();
PageInfo* presenter_ = nullptr;
ContentSettingsType type_;
ChromePageInfoUiDelegate* ui_delegate_ = nullptr;
PageInfo::PermissionInfo permission_;
NonAccessibleImageView* icon_ = nullptr;
views::Label* title_ = nullptr;
views::Label* state_label_ = nullptr;
views::ToggleButton* toggle_button_ = nullptr;
views::Checkbox* remember_setting_ = nullptr;
};
#endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_PERMISSION_CONTENT_VIEW_H_
|
/* $NetBSD: puts.c,v 1.17 2018/02/04 01:13:45 mrg Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "fvwrite.h"
#include "reentrant.h"
#include "local.h"
/*
* Write the given string to stdout, appending a newline.
*/
int puts(char const *s) {
size_t c;
struct __suio uio;
struct __siov iov[2];
const void *vs = s;
int r;
/* This avoids -Werror=nonnull-compare. */
if (vs == NULL)
s = "(null)";
c = strlen(s);
iov[0].iov_base = __UNCONST(s);
iov[0].iov_len = c;
iov[1].iov_base = __UNCONST("\n");
iov[1].iov_len = 1;
uio.uio_resid = c + 1;
uio.uio_iov = &iov[0];
uio.uio_iovcnt = 2;
FLOCKFILE(stdout);
r = __sfvwrite(stdout, &uio);
FUNLOCKFILE(stdout);
return r ? EOF : '\n';
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE126_Buffer_Overread__CWE129_large_52a.c
Label Definition File: CWE126_Buffer_Overread__CWE129.label.xml
Template File: sources-sinks-52a.tmpl.c
*/
/*
* @description
* CWE: 126 Buffer Overread
* BadSource: large Large index value that is greater than 10-1
* GoodSource: Larger than zero but less than 10
* Sinks:
* GoodSink: Ensure the array index is valid
* BadSink : Improperly check the array index by not checking the upper bound
* Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
/* bad function declaration */
void CWE126_Buffer_Overread__CWE129_large_52b_badSink(int data);
void CWE126_Buffer_Overread__CWE129_large_52_bad()
{
int data;
/* Initialize data */
data = -1;
/* POTENTIAL FLAW: Use an invalid index */
data = 10;
CWE126_Buffer_Overread__CWE129_large_52b_badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE126_Buffer_Overread__CWE129_large_52b_goodG2BSink(int data);
static void goodG2B()
{
int data;
/* Initialize data */
data = -1;
/* FIX: Use a value greater than 0, but less than 10 to avoid attempting to
* access an index of the array in the sink that is out-of-bounds */
data = 7;
CWE126_Buffer_Overread__CWE129_large_52b_goodG2BSink(data);
}
/* goodB2G uses the BadSource with the GoodSink */
void CWE126_Buffer_Overread__CWE129_large_52b_goodB2GSink(int data);
static void goodB2G()
{
int data;
/* Initialize data */
data = -1;
/* POTENTIAL FLAW: Use an invalid index */
data = 10;
CWE126_Buffer_Overread__CWE129_large_52b_goodB2GSink(data);
}
void CWE126_Buffer_Overread__CWE129_large_52_good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE126_Buffer_Overread__CWE129_large_52_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE126_Buffer_Overread__CWE129_large_52_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_
#define CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_
#pragma once
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop_helpers.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "webkit/appcache/appcache_policy.h"
#include "webkit/appcache/appcache_service.h"
#include "webkit/quota/special_storage_policy.h"
class FilePath;
namespace content {
class ResourceContext;
}
// An AppCacheService subclass used by the chrome. There is an instance
// associated with each BrowserContext. This derivation adds refcounting
// semantics since a browser context has multiple URLRequestContexts which refer
// to the same object, and those URLRequestContexts are refcounted independently
// of the owning browser context.
//
// All methods, except the ctor, are expected to be called on
// the IO thread (unless specifically called out in doc comments).
//
// TODO(dpranke): Fix dependencies on AppCacheService so that we don't have
// to worry about clients calling AppCacheService methods.
class CONTENT_EXPORT ChromeAppCacheService
: public base::RefCountedThreadSafe<
ChromeAppCacheService, content::BrowserThread::DeleteOnIOThread>,
NON_EXPORTED_BASE(public appcache::AppCacheService),
NON_EXPORTED_BASE(public appcache::AppCachePolicy),
public content::NotificationObserver {
public:
explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy);
void InitializeOnIOThread(
const FilePath& cache_path, // may be empty to use in-memory structures
const content::ResourceContext* resource_context,
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
private:
friend class base::RefCountedThreadSafe<
ChromeAppCacheService,
content::BrowserThread::DeleteOnIOThread>;
friend class content::BrowserThread;
friend class base::DeleteHelper<ChromeAppCacheService>;
virtual ~ChromeAppCacheService();
// AppCachePolicy overrides
virtual bool CanLoadAppCache(const GURL& manifest_url,
const GURL& first_party) OVERRIDE;
virtual bool CanCreateAppCache(const GURL& manifest_url,
const GURL& first_party) OVERRIDE;
// content::NotificationObserver override
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
const content::ResourceContext* resource_context_;
content::NotificationRegistrar registrar_;
FilePath cache_path_;
DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService);
};
#endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_
|
/*
* Firepony
* Copyright (c) 2014-2015, NVIDIA 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 NVIDIA CORPORATION nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION 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.
*/
#pragma once
#include <thread>
#include "alignment_data.h"
#include "loader/alignments.h"
#include "loader/reference.h"
#include <queue>
#include <mutex>
#include <condition_variable>
#include <atomic>
namespace firepony {
struct semaphore
{
std::mutex sem_mutex;
std::condition_variable cond_var;
std::atomic<int> semaphore_value;
semaphore()
: semaphore_value(0)
{ }
void wait(void)
{
// this is a little unfortunate, but we're forced to take the lock and immediately release it
std::unique_lock<std::mutex> lock(sem_mutex);
while (semaphore_value == 0)
{
cond_var.wait(lock);
}
semaphore_value--;
}
void post(void)
{
semaphore_value++;
cond_var.notify_one();
}
};
template <typename T>
struct locked_queue
{
std::queue<T> queue;
std::mutex m;
size_t size(void)
{
std::lock_guard<std::mutex> lock(m);
return queue.size();
}
T pop(void)
{
std::lock_guard<std::mutex> lock(m);
T ret = queue.front();
queue.pop();
return ret;
}
void push(T elem)
{
std::lock_guard<std::mutex> lock(m);
queue.push(elem);
}
};
struct io_thread
{
const int NUM_BUFFERS;
semaphore sem_producer, sem_consumer;
// a queue with batches ready for processing
locked_queue<alignment_batch_host *> batches;
// a queue containing processed batches for reuse
locked_queue<alignment_batch_host *> empty_batches;
// the reference file handle on which we'll load reference sequences
reference_file_handle *reference;
alignment_file file;
uint32 data_mask;
std::thread thread;
io_thread(const char *fname, uint32 data_mask, const int consumers, reference_file_handle *reference);
~io_thread();
bool start(void);
void join(void);
alignment_batch_host *get_batch(void);
void retire_batch(alignment_batch_host *batch);
private:
void run(void);
};
} // namespace firepony
|
/* $OpenBSD: arc4random.c,v 1.41 2014/07/12 13:24:54 deraadt Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
* Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "config.h"
/*
* ChaCha based random number generator for OpenBSD.
*/
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#ifndef GETDNS_ON_WINDOWS
#include <sys/mman.h>
#endif
#define KEYSTREAM_ONLY
#include "chacha_private.h"
#define arc4_min(a, b) ((a) < (b) ? (a) : (b))
#ifdef __GNUC__
#define inline __inline
#else /* !__GNUC__ */
#define inline
#endif /* !__GNUC__ */
#define KEYSZ 32
#define IVSZ 8
#define BLOCKSZ 64
#define RSBUFSZ (16*BLOCKSZ)
/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */
static struct {
size_t rs_have; /* valid bytes at end of rs_buf */
size_t rs_count; /* bytes till reseed */
} *rs;
/* Preserved in fork children. */
static struct {
chacha_ctx rs_chacha; /* chacha context for random keystream */
u_char rs_buf[RSBUFSZ]; /* keystream blocks */
} *rsx;
static inline void _rs_rekey(u_char *dat, size_t datlen);
static inline void
_rs_init(u_char *buf, size_t n)
{
if (n < KEYSZ + IVSZ)
return;
if (rs == NULL) {
#ifndef GETDNS_ON_WINDOWS
if ((rs = mmap(NULL, sizeof(*rs), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
abort();
#ifdef MAP_INHERIT_ZERO
if (minherit(rs, sizeof(*rs), MAP_INHERIT_ZERO) == -1)
abort();
#endif
#else /* WINDOWS */
rs = malloc(sizeof(*rs));
if(!rs)
abort();
#endif
}
if (rsx == NULL) {
#ifndef GETDNS_ON_WINDOWS
if ((rsx = mmap(NULL, sizeof(*rsx), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
abort();
#else /* WINDOWS */
rsx = malloc(sizeof(*rsx));
if(!rsx)
abort();
#endif
}
chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8, 0);
chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ);
}
static void
_rs_stir(void)
{
u_char rnd[KEYSZ + IVSZ];
if (getentropy(rnd, sizeof rnd) == -1) {
#ifdef SIGKILL
raise(SIGKILL);
#else
exit(9); /* windows */
#endif
}
if (!rs)
_rs_init(rnd, sizeof(rnd));
else
_rs_rekey(rnd, sizeof(rnd));
explicit_bzero(rnd, sizeof(rnd)); /* discard source seed */
/* invalidate rs_buf */
rs->rs_have = 0;
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
rs->rs_count = 1600000;
}
static inline void
_rs_stir_if_needed(size_t len)
{
#ifndef MAP_INHERIT_ZERO
static pid_t _rs_pid = 0;
pid_t pid = getpid();
/* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
if (_rs_pid == 0 || _rs_pid != pid) {
_rs_pid = pid;
if (rs)
rs->rs_count = 0;
}
#endif
if (!rs || rs->rs_count <= len)
_rs_stir();
if (rs->rs_count <= len)
rs->rs_count = 0;
else
rs->rs_count -= len;
}
static inline void
_rs_rekey(u_char *dat, size_t datlen)
{
#ifndef KEYSTREAM_ONLY
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
#endif
/* fill rs_buf with the keystream */
chacha_encrypt_bytes(&rsx->rs_chacha, rsx->rs_buf,
rsx->rs_buf, sizeof(rsx->rs_buf));
/* mix in optional user provided data */
if (dat) {
size_t i, m;
m = arc4_min(datlen, KEYSZ + IVSZ);
for (i = 0; i < m; i++)
rsx->rs_buf[i] ^= dat[i];
}
/* immediately reinit for backtracking resistance */
_rs_init(rsx->rs_buf, KEYSZ + IVSZ);
memset(rsx->rs_buf, 0, KEYSZ + IVSZ);
rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ;
}
static inline void
_rs_random_buf(void *_buf, size_t n)
{
u_char *buf = (u_char *)_buf;
u_char *keystream;
size_t m;
_rs_stir_if_needed(n);
while (n > 0) {
if (rs->rs_have > 0) {
m = arc4_min(n, rs->rs_have);
keystream = rsx->rs_buf + sizeof(rsx->rs_buf)
- rs->rs_have;
memcpy(buf, keystream, m);
memset(keystream, 0, m);
buf += m;
n -= m;
rs->rs_have -= m;
}
if (rs->rs_have == 0)
_rs_rekey(NULL, 0);
}
}
static inline void
_rs_random_u32(uint32_t *val)
{
u_char *keystream;
_rs_stir_if_needed(sizeof(*val));
if (rs->rs_have < sizeof(*val))
_rs_rekey(NULL, 0);
keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have;
memcpy(val, keystream, sizeof(*val));
memset(keystream, 0, sizeof(*val));
rs->rs_have -= sizeof(*val);
}
uint32_t
arc4random(void)
{
uint32_t val;
_ARC4_LOCK();
_rs_random_u32(&val);
_ARC4_UNLOCK();
return val;
}
void
arc4random_buf(void *buf, size_t n)
{
_ARC4_LOCK();
_rs_random_buf(buf, n);
_ARC4_UNLOCK();
}
|
/* $OpenBSD: sha1_one.c,v 1.10 2014/06/12 15:49:30 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#include <stdio.h>
#include <string.h>
#include <openssl/opensslconf.h>
#include <openssl/crypto.h>
#include <openssl/sha.h>
#ifndef OPENSSL_NO_SHA1
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
{
SHA_CTX c;
static unsigned char m[SHA_DIGEST_LENGTH];
if (md == NULL) md=m;
if (!SHA1_Init(&c))
return NULL;
SHA1_Update(&c,d,n);
SHA1_Final(md,&c);
OPENSSL_cleanse(&c,sizeof(c));
return(md);
}
#endif
|
/* Copyright (c) 2001, Stanford University
* All rights reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#ifndef BINARYSWAP_SPU_H
#define BINARYSWAP_SPU_H
#ifdef WINDOWS
#define BINARYSWAPSPU_APIENTRY __stdcall
#else
#define BINARYSWAPSPU_APIENTRY
#endif
#include "cr_hash.h"
#include "cr_spu.h"
#include "cr_server.h"
#include "cr_threads.h"
#define BINARYSWAP_SPU_PORT 8192
#define CLEAR_BARRIER 52001
#define SWAP_BARRIER 52002
#define POST_SWAP_BARRIER 52003
#define CREATE_CONTEXT_BARRIER 52004
#define MAKE_CURRENT_BARRIER 52005
#define DESTROY_CONTEXT_BARRIER 52006
#define MUTEX_SEMAPHORE 52007
typedef struct {
GLint index; /**< my window number */
GLint renderWindow; /**< the super (render SPU) window */
GLint childWindow; /**< the child SPU's window handle */
GLint width, height;
GLint childWidth, childHeight;
GLubyte *msgBuffer;
GLint bytesPerColor, bytesPerDepth; /**< bytes per pixel */
GLenum depthType; /**< GL_UNSIGNED_SHORT or GL_FLOAT */
GLint superVisBits;
GLint childVisBits;
int* read_x;
int* read_y;
int* read_width;
int* read_height;
/**< window-space union of all bounding boxes */
CRrecti bboxUnion;
} WindowInfo;
/** Message header */
typedef struct {
CRMessageHeader header;
float depth;
int start_x, start_y;
int width, height;
int clipped_x, clipped_y;
int clipped_width, clipped_height;
} BinarySwapMsg;
typedef struct {
GLboolean inUse;
GLint renderContext;
GLint childContext;
WindowInfo *currentWindow;
GLint superVisBits;
GLint childVisBits;
} ContextInfo;
typedef struct {
int id;
int has_child;
SPUDispatchTable self, child, super;
CRServer *server;
/** config options */
/*@{*/
int resizable;
int local_visualization;
int renderToAppWindow;
int default_visual;
/*@}*/
CRHashTable *contextTable;
CRHashTable *windowTable;
#ifndef CHROMIUM_THREADSAFE
ContextInfo *currentContext;
#endif
GLint barrierSize;
/**< Store a list of all nodes in our swap network */
char ** peer_names;
/**< Stor a list of all nodes we will be swapping with */
char ** swap_partners;
/**< What is our number in the network. Used to find swap partners
from network list */
int node_num;
/**< What type of compositing will we be doing? */
int alpha_composite;
int depth_composite;
/**< Are we attempting to clip window? */
int clipped_window;
/**< How many peers do we have? */
int num_peers;
/**< What MTU do we use? */
unsigned int mtu;
/**< Used to store connections for swapping */
CRConnection **peer_send, **peer_recv;
/**< The offset for the header of the message */
int offset;
/**< How many times do we swap? */
int stages;
/**< Store if we are the top/bottom or left/right of swap */
int *highlow;
/**< What is the depth of the frame buffer */
float depth;
} Binaryswapspu;
extern Binaryswapspu binaryswap_spu;
#ifdef CHROMIUM_THREADSAFE
extern CRtsd _BinaryswapTSD;
#define GET_CONTEXT(C) ContextInfo *C = crGetTSD(&_BinaryswapTSD)
#define SET_CONTEXT(C) crSetTSD(&_BinaryswapTSD, C)
#else
#define GET_CONTEXT(C) ContextInfo *C = binaryswap_spu.currentContext
#define SET_CONTEXT(C) binaryswap_spu.currentContext = C
#endif
extern void binaryswapspuGatherConfiguration( Binaryswapspu *spu );
extern void binaryswapspuTweakVisBits(GLint visBits, GLint *childVisBits,
GLint *superVisBits);
#endif /* BINARYSWAP_SPU_H */
|
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2015, Esteban Tovagliari. 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 Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////
#ifndef IECOREAPPLESEED_RENDERERCONTROLLER_H
#define IECOREAPPLESEED_RENDERERCONTROLLER_H
#include "tbb/atomic.h"
#include "renderer/api/rendering.h"
namespace IECoreAppleseed
{
class RendererController : public renderer::DefaultRendererController
{
public :
RendererController()
{
m_status = ContinueRendering;
}
virtual Status get_status() const
{
return m_status;
}
void set_status( Status status )
{
m_status = status;
}
private :
tbb::atomic<Status> m_status;
};
} // namespace IECoreAppleseed
#endif // IECOREAPPLESEED_RENDERERCONTROLLER_H
|
/* Generated by re2c */
#line 1 "calc_008.b.re"
/* re2c lesson 001_upn_calculator, calc_008, (c) M. Boerger 2006 - 2007 */
#line 31 "calc_008.b.re"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define DEBUG(stmt) stmt
int stack[4];
int depth = 0;
int push_num(const char *t, const char *l, int radix)
{
int num = 0;
if (depth >= sizeof(stack))
{
return 3;
}
--t;
while(++t < l)
{
num = num * radix + (*t - '0');
}
DEBUG(printf("Num: %d\n", num));
stack[depth++] = num;
return 0;
}
int stack_add()
{
if (depth < 2) return 4;
--depth;
stack[depth-1] = stack[depth-1] + stack[depth];
DEBUG(printf("+\n"));
return 0;
}
int stack_sub()
{
if (depth < 2) return 4;
--depth;
stack[depth-1] = stack[depth-1] - stack[depth];
DEBUG(printf("+\n"));
return 0;
}
int scan(char *p)
{
char *t;
int res = 0;
while(!res)
{
t = p;
#line 65 "<stdout>"
{
unsigned char curr;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 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, 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,
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, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
curr = (unsigned char)*p;
if (curr <= '*') {
if (curr <= '\t') {
if (curr <= 0x00) goto scan11;
if (curr <= 0x08) goto scan13;
} else {
if (curr != ' ') goto scan13;
}
} else {
if (curr <= '-') {
if (curr <= '+') goto scan7;
if (curr <= ',') goto scan13;
goto scan9;
} else {
if (curr <= '/') goto scan13;
if (curr <= '0') goto scan4;
if (curr <= '9') goto scan6;
goto scan13;
}
}
++p;
curr = (unsigned char)*p;
goto scan21;
scan3:
#line 103 "calc_008.b.re"
{ continue; }
#line 129 "<stdout>"
scan4:
++p;
if ((curr = (unsigned char)*p) <= '/') goto scan5;
if (curr <= '9') goto scan17;
scan5:
#line 105 "calc_008.b.re"
{ res = push_num(t, p, 10); continue; }
#line 137 "<stdout>"
scan6:
curr = (unsigned char)*++p;
goto scan16;
scan7:
++p;
#line 106 "calc_008.b.re"
{ res = stack_add(); continue; }
#line 145 "<stdout>"
scan9:
++p;
#line 107 "calc_008.b.re"
{ res = stack_sub(); continue; }
#line 150 "<stdout>"
scan11:
++p;
#line 108 "calc_008.b.re"
{ res = depth == 1 ? 0 : 2; break; }
#line 155 "<stdout>"
scan13:
++p;
#line 109 "calc_008.b.re"
{ res = 1; continue; }
#line 160 "<stdout>"
scan15:
++p;
curr = (unsigned char)*p;
scan16:
if (yybm[0+curr] & 64) {
goto scan15;
}
goto scan5;
scan17:
++p;
curr = (unsigned char)*p;
if (curr <= '/') goto scan19;
if (curr <= '9') goto scan17;
scan19:
#line 104 "calc_008.b.re"
{ res = push_num(t, p, 8); continue; }
#line 177 "<stdout>"
scan20:
++p;
curr = (unsigned char)*p;
scan21:
if (yybm[0+curr] & 128) {
goto scan20;
}
goto scan3;
}
#line 110 "calc_008.b.re"
}
return res;
}
int main(int argc, char **argv)
{
if (argc > 1)
{
char *inp;
int res = 0, argp = 0, len;
while(!res && ++argp < argc)
{
inp = strdup(argv[argp]);
len = strlen(inp);
if (inp[0] == '\"' && inp[len-1] == '\"')
{
inp[len - 1] = '\0';
++inp;
}
res = scan(inp);
free(inp);
}
switch(res)
{
case 0:
printf("Result: %d\n", stack[0]);
return 0;
case 1:
fprintf(stderr, "Illegal character in input.\n");
return 1;
case 2:
fprintf(stderr, "Premature end of input.\n");
return 2;
case 3:
fprintf(stderr, "Stack overflow.\n");
return 3;
case 4:
fprintf(stderr, "Stack underflow.\n");
return 4;
}
}
else
{
fprintf(stderr, "%s <expr>\n", argv[0]);
return 0;
}
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE134_Uncontrolled_Format_String__char_listen_socket_printf_54e.c
Label Definition File: CWE134_Uncontrolled_Format_String.label.xml
Template File: sources-sinks-54e.tmpl.c
*/
/*
* @description
* CWE: 134 Uncontrolled Format String
* BadSource: listen_socket Read data using a listen socket (server side)
* GoodSource: Copy a fixed string into data
* Sinks: printf
* GoodSink: printf with "%s" as the first argument and data as the second
* BadSink : printf with only data as an argument
* Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define LISTEN_BACKLOG 5
#ifndef OMITBAD
void CWE134_Uncontrolled_Format_String__char_listen_socket_printf_54e_badSink(char * data)
{
/* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
printf(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE134_Uncontrolled_Format_String__char_listen_socket_printf_54e_goodG2BSink(char * data)
{
/* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
printf(data);
}
/* goodB2G uses the BadSource with the GoodSink */
void CWE134_Uncontrolled_Format_String__char_listen_socket_printf_54e_goodB2GSink(char * data)
{
/* FIX: Specify the format disallowing a format string vulnerability */
printf("%s\n", data);
}
#endif /* OMITGOOD */
|
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class edu_vt_cbil_visda_comp_FeaturePreSelector */
#ifndef _Included_edu_vt_cbil_visda_comp_FeaturePreSelector
#define _Included_edu_vt_cbil_visda_comp_FeaturePreSelector
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: edu_vt_cbil_visda_comp_FeaturePreSelector
* Method: veSNR
* Signature: (II[D[II[I[D)I
*/
JNIEXPORT jint JNICALL Java_edu_vt_cbil_visda_comp_FeaturePreSelector_veSNR
(JNIEnv *, jobject, jint, jint, jdoubleArray, jintArray, jint, jintArray, jdoubleArray);
#ifdef __cplusplus
}
#endif
#endif
|
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AnimationTranslationUtil_h
#define AnimationTranslationUtil_h
#include <wtf/PassOwnPtr.h>
namespace WebKit {
class WebAnimation;
}
namespace WebCore {
class KeyframeValueList;
class CSSAnimationData;
class FloatSize;
// Translates WebCore animation data into a WebAnimation. If we are unable
// to perform this translation, we return nullptr. This can happen if
// - a steps timing function is used,
// - a property other than AnimatedPropertyWebkitTransform, or AnimatedPropertyOpacity is animated, or
// - a transform animation involves a non-invertable transform.
PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList&, const CSSAnimationData*, int animationId, double timeOffset, const FloatSize& boxSize);
} // namespace WebCore
#endif // AnimationTranslationUtil_h
|
#define V_SIMD 128
#define V_SIMD_F64 1
/***************************
* Data Type
***************************/
typedef __m128 v_f32;
typedef __m128d v_f64;
#define v_nlanes_f32 4
#define v_nlanes_f64 2
/***************************
* Arithmetic
***************************/
#define v_add_f32 _mm_add_ps
#define v_add_f64 _mm_add_pd
#define v_sub_f32 _mm_sub_ps
#define v_sub_f64 _mm_sub_pd
#define v_mul_f32 _mm_mul_ps
#define v_mul_f64 _mm_mul_pd
#ifdef HAVE_FMA3
// multiply and add, a*b + c
#define v_muladd_f32 _mm_fmadd_ps
#define v_muladd_f64 _mm_fmadd_pd
// multiply and subtract, a*b - c
#define v_mulsub_f32 _mm_fmsub_ps
#define v_mulsub_f64 _mm_fmsub_pd
#elif defined(HAVE_FMA4)
// multiply and add, a*b + c
#define v_muladd_f32 _mm_macc_ps
#define v_muladd_f64 _mm_macc_pd
// multiply and subtract, a*b - c
#define v_mulsub_f32 _mm_msub_ps
#define v_mulsub_f64 _mm_msub_pd
#else
// multiply and add, a*b + c
BLAS_FINLINE v_f32 v_muladd_f32(v_f32 a, v_f32 b, v_f32 c)
{ return v_add_f32(v_mul_f32(a, b), c); }
BLAS_FINLINE v_f64 v_muladd_f64(v_f64 a, v_f64 b, v_f64 c)
{ return v_add_f64(v_mul_f64(a, b), c); }
// multiply and subtract, a*b - c
BLAS_FINLINE v_f32 v_mulsub_f32(v_f32 a, v_f32 b, v_f32 c)
{ return v_sub_f32(v_mul_f32(a, b), c); }
BLAS_FINLINE v_f64 v_mulsub_f64(v_f64 a, v_f64 b, v_f64 c)
{ return v_sub_f64(v_mul_f64(a, b), c); }
#endif // HAVE_FMA3
// Horizontal add: Calculates the sum of all vector elements.
BLAS_FINLINE float v_sum_f32(__m128 a)
{
#ifdef HAVE_SSE3
__m128 sum_halves = _mm_hadd_ps(a, a);
return _mm_cvtss_f32(_mm_hadd_ps(sum_halves, sum_halves));
#else
__m128 t1 = _mm_movehl_ps(a, a);
__m128 t2 = _mm_add_ps(a, t1);
__m128 t3 = _mm_shuffle_ps(t2, t2, 1);
__m128 t4 = _mm_add_ss(t2, t3);
return _mm_cvtss_f32(t4);
#endif
}
BLAS_FINLINE double v_sum_f64(__m128d a)
{
#ifdef HAVE_SSE3
return _mm_cvtsd_f64(_mm_hadd_pd(a, a));
#else
return _mm_cvtsd_f64(_mm_add_pd(a, _mm_unpackhi_pd(a, a)));
#endif
}
/***************************
* memory
***************************/
// unaligned load
#define v_loadu_f32 _mm_loadu_ps
#define v_loadu_f64 _mm_loadu_pd
#define v_storeu_f32 _mm_storeu_ps
#define v_storeu_f64 _mm_storeu_pd
#define v_setall_f32(VAL) _mm_set1_ps(VAL)
#define v_setall_f64(VAL) _mm_set1_pd(VAL)
#define v_zero_f32 _mm_setzero_ps
#define v_zero_f64 _mm_setzero_pd |
// Copyright (c) 2012 The Chromium Embedded Framework 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 CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_
#define CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_
#include <set>
#include "include/cef_cookie.h"
#include "libcef/browser/request_context_impl.h"
#include "base/files/file_path.h"
#include "net/cookies/cookie_monster.h"
// Implementation of the CefCookieManager interface.
class CefCookieManagerImpl : public CefCookieManager {
public:
CefCookieManagerImpl();
~CefCookieManagerImpl() override;
// Must be called immediately after this object is created.
void Initialize(CefRefPtr<CefRequestContextImpl> request_context,
const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback);
// Executes |callback| either synchronously or asynchronously with the cookie
// monster object when it's available. If |task_runner| is NULL the callback
// will be executed on the originating thread. The resulting cookie monster
// object can only be accessed on the IO thread.
typedef base::Callback<void(scoped_refptr<net::CookieMonster>)>
CookieMonsterCallback;
void GetCookieMonster(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const CookieMonsterCallback& callback);
// Returns the existing cookie monster object. Logs an error if the cookie
// monster does not yet exist. Must be called on the IO thread.
scoped_refptr<net::CookieMonster> GetExistingCookieMonster();
// CefCookieManager methods.
void SetSupportedSchemes(const std::vector<CefString>& schemes,
CefRefPtr<CefCompletionCallback> callback) override;
bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) override;
bool VisitUrlCookies(const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) override;
bool SetCookie(const CefString& url,
const CefCookie& cookie,
CefRefPtr<CefSetCookieCallback> callback) override;
bool DeleteCookies(const CefString& url,
const CefString& cookie_name,
CefRefPtr<CefDeleteCookiesCallback> callback) override;
bool SetStoragePath(const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback) override;
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
static bool GetCefCookie(const net::CanonicalCookie& cc, CefCookie& cookie);
static bool GetCefCookie(const GURL& url, const std::string& cookie_line,
CefCookie& cookie);
// Set the schemes supported by |cookie_monster|. Default schemes will always
// be supported.
static void SetCookieMonsterSchemes(net::CookieMonster* cookie_monster,
const std::set<std::string>& schemes);
private:
// Returns true if a context is or will be available.
bool HasContext();
// Execute |method| on the IO thread once the request context is available.
void RunMethodWithContext(
const CefRequestContextImpl::RequestContextCallback& method);
void InitWithContext(
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void SetStoragePathWithContext(
const CefString& path,
bool persist_session_cookies,
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void SetSupportedSchemesWithContext(
const std::set<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void GetCookieMonsterWithContext(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const CookieMonsterCallback& callback,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void SetSupportedSchemesInternal(
const std::set<std::string>& schemes,
CefRefPtr<CefCompletionCallback> callback);
void VisitAllCookiesInternal(
CefRefPtr<CefCookieVisitor> visitor,
scoped_refptr<net::CookieMonster> cookie_monster);
void VisitUrlCookiesInternal(
const CefString& url,
bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor,
scoped_refptr<net::CookieMonster> cookie_monster);
void SetCookieInternal(
const GURL& url,
const CefCookie& cookie,
CefRefPtr<CefSetCookieCallback> callback,
scoped_refptr<net::CookieMonster> cookie_monster);
void DeleteCookiesInternal(
const GURL& url,
const CefString& cookie_name,
CefRefPtr<CefDeleteCookiesCallback> callback,
scoped_refptr<net::CookieMonster> cookie_monster);
void FlushStoreInternal(
CefRefPtr<CefCompletionCallback> callback,
scoped_refptr<net::CookieMonster> cookie_monster);
// Used for cookie monsters owned by the context.
CefRefPtr<CefRequestContextImpl> request_context_;
scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_;
// Used for cookie monsters owned by this object.
base::FilePath storage_path_;
std::set<std::string> supported_schemes_;
scoped_refptr<net::CookieMonster> cookie_monster_;
IMPLEMENT_REFCOUNTING(CefCookieManagerImpl);
};
#endif // CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_
|
/* $NetBSD: aout_machdep.h,v 1.1 2000/05/25 22:11:59 is Exp $ */
#include <powerpc/aout_machdep.h>
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45.c
Label Definition File: CWE121_Stack_Based_Buffer_Overflow__dest.label.xml
Template File: sources-sink-45.tmpl.c
*/
/*
* @description
* CWE: 121 Stack Based Buffer Overflow
* BadSource: Set data pointer to the bad buffer
* GoodSource: Set data pointer to the good buffer
* Sinks: cat
* BadSink : Copy string to data using strcat
* Flow Variant: 45 Data flow: data passed as a static global variable from one function to another in the same source file
*
* */
#include "std_testcase.h"
#include <wchar.h>
static char * CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_badData;
static char * CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_goodG2BData;
#ifndef OMITBAD
static void badSink()
{
char * data = CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_badData;
{
char source[100];
memset(source, 'C', 100-1); /* fill with 'C's */
source[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possible buffer overflow if the sizeof(data)-strlen(data) is less than the length of source */
strcat(data, source);
printLine(data);
}
}
void CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_bad()
{
char * data;
char * dataBadBuffer = (char *)ALLOCA(50*sizeof(char));
char * dataGoodBuffer = (char *)ALLOCA(100*sizeof(char));
/* FLAW: Set a pointer to a "small" buffer. This buffer will be used in the sinks as a destination
* buffer in various memory copying functions using a "large" source buffer. */
data = dataBadBuffer;
data[0] = '\0'; /* null terminate */
CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_badData = data;
badSink();
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2BSink()
{
char * data = CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_goodG2BData;
{
char source[100];
memset(source, 'C', 100-1); /* fill with 'C's */
source[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possible buffer overflow if the sizeof(data)-strlen(data) is less than the length of source */
strcat(data, source);
printLine(data);
}
}
static void goodG2B()
{
char * data;
char * dataBadBuffer = (char *)ALLOCA(50*sizeof(char));
char * dataGoodBuffer = (char *)ALLOCA(100*sizeof(char));
/* FIX: Set a pointer to a "large" buffer, thus avoiding buffer overflows in the sinks. */
data = dataGoodBuffer;
data[0] = '\0'; /* null terminate */
CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_goodG2BData = data;
goodG2BSink();
}
void CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_good()
{
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_45_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/* Glue functions for the minIni library, based on the EFS Library, see
* http://www.efsl.be/
*
* Copyright (c) CompuPhase, 2008-2011
*
* 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.
*/
#define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */
#include "efs.h"
#define INI_FILETYPE EmbeddedFile
#define INI_LINETERM "\r\n" /* set line termination explicitly */
extern EmbeddedFileSystem g_efs;
#define ini_openread(filename,file) (file_fopen((file),&g_efs.myFs,(char*)(filename),'r') == 0)
#define ini_openwrite(filename,file) (file_fopen((file),&g_efs.myFs,(char*)(filename),'w') == 0)
#define ini_close(file) file_fclose(file)
#define ini_read(buffer,size,file) (file_read((file),(size),(buffer)) > 0)
#define ini_write(buffer,file) file_write((file),strlen(buffer),(char*)(buffer))
#define ini_remove(filename) rmfile(&g_efs.myFs,(char*)(filename))
#define ini_rewind(file) file_setpos(*(file),0)
/* EFSL lacks a rename function, so instead we copy the file to the new name
* and delete the old file
*/
static int ini_rename(char *source, const char *dest)
{
EmbeddedFile fr, fw;
int n;
if(file_fopen(&fr, &g_efs.myFs, source, 'r') != 0)
{
return 0;
}
if(rmfile(&g_efs.myFs, (char *)dest) != 0)
{
return 0;
}
if(file_fopen(&fw, &g_efs.myFs, (char *)dest, 'w') != 0)
{
return 0;
}
/* With some "insider knowledge", we can save some memory: the "source"
* parameter holds a filename that was built from the "dest" parameter. It
* was built in buffer and this buffer has the size INI_BUFFERSIZE. We can
* reuse this buffer for copying the file.
*/
while(n = file_read(&fr, INI_BUFFERSIZE, source))
{
file_write(&fw, n, source);
}
file_fclose(&fr);
file_fclose(&fw);
/* Now we need to delete the source file. However, we have garbled the buffer
* that held the filename of the source. So we need to build it again.
*/
ini_tempname(source, dest, INI_BUFFERSIZE);
return rmfile(&g_efs.myFs, source) == 0;
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE590_Free_Memory_Not_on_Heap__delete_int64_t_alloca_82.h
Label Definition File: CWE590_Free_Memory_Not_on_Heap__delete.pointer.label.xml
Template File: sources-sink-82.tmpl.h
*/
/*
* @description
* CWE: 590 Free Memory Not on Heap
* BadSource: alloca Data buffer is allocated on the stack with alloca()
* GoodSource: Allocate memory on the heap
* Sinks:
* BadSink : Print then free data
* Flow Variant: 82 Data flow: data passed in a parameter to a virtual method called via a pointer
*
* */
#include "std_testcase.h"
#include <wchar.h>
namespace CWE590_Free_Memory_Not_on_Heap__delete_int64_t_alloca_82
{
class CWE590_Free_Memory_Not_on_Heap__delete_int64_t_alloca_82_base
{
public:
/* pure virtual function */
virtual void action(int64_t * data) = 0;
};
#ifndef OMITBAD
class CWE590_Free_Memory_Not_on_Heap__delete_int64_t_alloca_82_bad : public CWE590_Free_Memory_Not_on_Heap__delete_int64_t_alloca_82_base
{
public:
void action(int64_t * data);
};
#endif /* OMITBAD */
#ifndef OMITGOOD
class CWE590_Free_Memory_Not_on_Heap__delete_int64_t_alloca_82_goodG2B : public CWE590_Free_Memory_Not_on_Heap__delete_int64_t_alloca_82_base
{
public:
void action(int64_t * data);
};
#endif /* OMITGOOD */
}
|
// 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 BASE_WIN_SCOPED_HDC_H_
#define BASE_WIN_SCOPED_HDC_H_
#include <windows.h>
#include "base/check.h"
#include "base/debug/gdi_debug_util_win.h"
#include "base/macros.h"
#include "base/win/scoped_handle.h"
namespace base {
namespace win {
// Like ScopedHandle but for HDC. Only use this on HDCs returned from
// GetDC.
class ScopedGetDC {
public:
explicit ScopedGetDC(HWND hwnd) : hwnd_(hwnd), hdc_(GetDC(hwnd)) {
if (hwnd_) {
DCHECK(IsWindow(hwnd_));
DCHECK(hdc_);
} else {
// If GetDC(NULL) returns NULL, something really bad has happened, like
// GDI handle exhaustion. In this case Chrome is going to behave badly no
// matter what, so we may as well just force a crash now.
if (!hdc_)
base::debug::CollectGDIUsageAndDie();
}
}
ScopedGetDC(const ScopedGetDC&) = delete;
ScopedGetDC& operator=(const ScopedGetDC&) = delete;
~ScopedGetDC() {
if (hdc_)
ReleaseDC(hwnd_, hdc_);
}
operator HDC() { return hdc_; }
private:
HWND hwnd_;
HDC hdc_;
};
// Like ScopedHandle but for HDC. Only use this on HDCs returned from
// CreateCompatibleDC, CreateDC and CreateIC.
class CreateDCTraits {
public:
typedef HDC Handle;
CreateDCTraits() = delete;
CreateDCTraits(const CreateDCTraits&) = delete;
CreateDCTraits& operator=(const CreateDCTraits&) = delete;
static bool CloseHandle(HDC handle) { return ::DeleteDC(handle) != FALSE; }
static bool IsHandleValid(HDC handle) { return handle != NULL; }
static HDC NullHandle() { return NULL; }
};
typedef GenericScopedHandle<CreateDCTraits, DummyVerifierTraits> ScopedCreateDC;
} // namespace win
} // namespace base
#endif // BASE_WIN_SCOPED_HDC_H_
|
/***************************************************************************
Copyright (c) 2014, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#define HAVE_KERNEL_16 1
static void sdot_kernel_16( BLASLONG n, FLOAT *x, FLOAT *y , FLOAT *dot) __attribute__ ((noinline));
static void sdot_kernel_16( BLASLONG n, FLOAT *x, FLOAT *y, FLOAT *dot)
{
BLASLONG register i = 0;
__asm__ __volatile__
(
"vxorps %%ymm4, %%ymm4, %%ymm4 \n\t"
"vxorps %%ymm5, %%ymm5, %%ymm5 \n\t"
"vxorps %%ymm6, %%ymm6, %%ymm6 \n\t"
"vxorps %%ymm7, %%ymm7, %%ymm7 \n\t"
".p2align 4 \n\t"
"1: \n\t"
"vmovups (%2,%0,4), %%ymm12 \n\t" // 2 * x
"vmovups 32(%2,%0,4), %%ymm13 \n\t" // 2 * x
"vmovups 64(%2,%0,4), %%ymm14 \n\t" // 2 * x
"vmovups 96(%2,%0,4), %%ymm15 \n\t" // 2 * x
"vfmadd231ps (%3,%0,4), %%ymm12, %%ymm4 \n\t" // 2 * y
"vfmadd231ps 32(%3,%0,4), %%ymm13, %%ymm5 \n\t" // 2 * y
"vfmadd231ps 64(%3,%0,4), %%ymm14, %%ymm6 \n\t" // 2 * y
"vfmadd231ps 96(%3,%0,4), %%ymm15, %%ymm7 \n\t" // 2 * y
#ifndef DSDOT
"addq $32 , %0 \n\t"
"subq $32 , %1 \n\t"
"jnz 1b \n\t"
#endif
"vextractf128 $1 , %%ymm4 , %%xmm12 \n\t"
"vextractf128 $1 , %%ymm5 , %%xmm13 \n\t"
"vextractf128 $1 , %%ymm6 , %%xmm14 \n\t"
"vextractf128 $1 , %%ymm7 , %%xmm15 \n\t"
"vaddps %%xmm4, %%xmm12, %%xmm4 \n\t"
"vaddps %%xmm5, %%xmm13, %%xmm5 \n\t"
"vaddps %%xmm6, %%xmm14, %%xmm6 \n\t"
"vaddps %%xmm7, %%xmm15, %%xmm7 \n\t"
"vaddps %%xmm4, %%xmm5, %%xmm4 \n\t"
"vaddps %%xmm6, %%xmm7, %%xmm6 \n\t"
"vaddps %%xmm4, %%xmm6, %%xmm4 \n\t"
"vhaddps %%xmm4, %%xmm4, %%xmm4 \n\t"
"vhaddps %%xmm4, %%xmm4, %%xmm4 \n\t"
"vmovss %%xmm4, (%4) \n\t"
"vzeroupper \n\t"
:
"+r" (i), // 0
"+r" (n) // 1
:
"r" (x), // 2
"r" (y), // 3
"r" (dot) // 4
: "cc",
"%xmm0", "%xmm1", "%xmm2", "%xmm3",
"%xmm4", "%xmm5", "%xmm6", "%xmm7",
"%xmm8", "%xmm9", "%xmm10", "%xmm11",
"%xmm12", "%xmm13", "%xmm14", "%xmm15",
"memory"
);
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE190_Integer_Overflow__short_fscanf_multiply_01.c
Label Definition File: CWE190_Integer_Overflow.label.xml
Template File: sources-sinks-01.tmpl.c
*/
/*
* @description
* CWE: 190 Integer Overflow
* BadSource: fscanf Read data from the console using fscanf()
* GoodSource: Set data to a small, non-zero number (two)
* Sinks: multiply
* GoodSink: Ensure there will not be an overflow before multiplying data by 2
* BadSink : If data is positive, multiply by 2, which can cause an overflow
* Flow Variant: 01 Baseline
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
void CWE190_Integer_Overflow__short_fscanf_multiply_01_bad()
{
short data;
data = 0;
/* POTENTIAL FLAW: Use a value input from the console */
fscanf (stdin, "%hd", &data);
if(data > 0) /* ensure we won't have an underflow */
{
/* POTENTIAL FLAW: if (data*2) > SHRT_MAX, this will overflow */
short result = data * 2;
printIntLine(result);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
static void goodG2B()
{
short data;
data = 0;
/* FIX: Use a small, non-zero value that will not cause an overflow in the sinks */
data = 2;
if(data > 0) /* ensure we won't have an underflow */
{
/* POTENTIAL FLAW: if (data*2) > SHRT_MAX, this will overflow */
short result = data * 2;
printIntLine(result);
}
}
/* goodB2G uses the BadSource with the GoodSink */
static void goodB2G()
{
short data;
data = 0;
/* POTENTIAL FLAW: Use a value input from the console */
fscanf (stdin, "%hd", &data);
if(data > 0) /* ensure we won't have an underflow */
{
/* FIX: Add a check to prevent an overflow from occurring */
if (data < (SHRT_MAX/2))
{
short result = data * 2;
printIntLine(result);
}
else
{
printLine("data value is too large to perform arithmetic safely.");
}
}
}
void CWE190_Integer_Overflow__short_fscanf_multiply_01_good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE190_Integer_Overflow__short_fscanf_multiply_01_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE190_Integer_Overflow__short_fscanf_multiply_01_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE127_Buffer_Underread__wchar_t_declare_memmove_54c.c
Label Definition File: CWE127_Buffer_Underread.stack.label.xml
Template File: sources-sink-54c.tmpl.c
*/
/*
* @description
* CWE: 127 Buffer Under-read
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sink: memmove
* BadSink : Copy data to string using memmove
* Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
/* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
#ifndef OMITBAD
/* bad function declaration */
void CWE127_Buffer_Underread__wchar_t_declare_memmove_54d_badSink(wchar_t * data);
void CWE127_Buffer_Underread__wchar_t_declare_memmove_54c_badSink(wchar_t * data)
{
CWE127_Buffer_Underread__wchar_t_declare_memmove_54d_badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declaration */
void CWE127_Buffer_Underread__wchar_t_declare_memmove_54d_goodG2BSink(wchar_t * data);
/* goodG2B uses the GoodSource with the BadSink */
void CWE127_Buffer_Underread__wchar_t_declare_memmove_54c_goodG2BSink(wchar_t * data)
{
CWE127_Buffer_Underread__wchar_t_declare_memmove_54d_goodG2BSink(data);
}
#endif /* OMITGOOD */
|
/*
* PMP demuxer.
* Copyright (c) 2011 Reimar Döffinger
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "internal.h"
typedef struct {
int cur_stream;
int num_streams;
int audio_packets;
int current_packet;
uint32_t *packet_sizes;
int packet_sizes_alloc;
} PMPContext;
static int pmp_probe(AVProbeData *p) {
if (AV_RN32(p->buf) == AV_RN32("pmpm") &&
AV_RL32(p->buf + 4) == 1)
return AVPROBE_SCORE_MAX;
return 0;
}
static int pmp_header(AVFormatContext *s)
{
PMPContext *pmp = s->priv_data;
AVIOContext *pb = s->pb;
int tb_num, tb_den;
uint32_t index_cnt;
int audio_codec_id = AV_CODEC_ID_NONE;
int srate, channels;
unsigned i;
uint64_t pos;
int64_t fsize = avio_size(pb);
AVStream *vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
avio_skip(pb, 8);
switch (avio_rl32(pb)) {
case 0:
vst->codec->codec_id = AV_CODEC_ID_MPEG4;
break;
case 1:
vst->codec->codec_id = AV_CODEC_ID_H264;
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported video format\n");
break;
}
index_cnt = avio_rl32(pb);
vst->codec->width = avio_rl32(pb);
vst->codec->height = avio_rl32(pb);
tb_num = avio_rl32(pb);
tb_den = avio_rl32(pb);
avpriv_set_pts_info(vst, 32, tb_num, tb_den);
vst->nb_frames = index_cnt;
vst->duration = index_cnt;
switch (avio_rl32(pb)) {
case 0:
audio_codec_id = AV_CODEC_ID_MP3;
break;
case 1:
av_log(s, AV_LOG_ERROR, "AAC not yet correctly supported\n");
audio_codec_id = AV_CODEC_ID_AAC;
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported audio format\n");
break;
}
pmp->num_streams = avio_rl16(pb) + 1;
avio_skip(pb, 10);
srate = avio_rl32(pb);
channels = avio_rl32(pb) + 1;
pos = avio_tell(pb) + 4LL*index_cnt;
for (i = 0; i < index_cnt; i++) {
uint32_t size = avio_rl32(pb);
int flags = size & 1 ? AVINDEX_KEYFRAME : 0;
if (url_feof(pb)) {
av_log(s, AV_LOG_FATAL, "Encountered EOF while reading index.\n");
return AVERROR_INVALIDDATA;
}
size >>= 1;
if (size < 9 + 4*pmp->num_streams) {
av_log(s, AV_LOG_ERROR, "Packet too small\n");
return AVERROR_INVALIDDATA;
}
av_add_index_entry(vst, pos, i, size, 0, flags);
pos += size;
if (fsize > 0 && i == 0 && pos > fsize) {
av_log(s, AV_LOG_ERROR, "File ends before first packet\n");
return AVERROR_INVALIDDATA;
}
}
for (i = 1; i < pmp->num_streams; i++) {
AVStream *ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_id = audio_codec_id;
ast->codec->channels = channels;
ast->codec->sample_rate = srate;
avpriv_set_pts_info(ast, 32, 1, srate);
}
return 0;
}
static int pmp_packet(AVFormatContext *s, AVPacket *pkt)
{
PMPContext *pmp = s->priv_data;
AVIOContext *pb = s->pb;
int ret = 0;
int i;
if (url_feof(pb))
return AVERROR_EOF;
if (pmp->cur_stream == 0) {
int num_packets;
pmp->audio_packets = avio_r8(pb);
if (!pmp->audio_packets) {
avpriv_request_sample(s, "0 audio packets");
return AVERROR_PATCHWELCOME;
}
num_packets = (pmp->num_streams - 1) * pmp->audio_packets + 1;
avio_skip(pb, 8);
pmp->current_packet = 0;
av_fast_malloc(&pmp->packet_sizes,
&pmp->packet_sizes_alloc,
num_packets * sizeof(*pmp->packet_sizes));
if (!pmp->packet_sizes_alloc) {
av_log(s, AV_LOG_ERROR, "Cannot (re)allocate packet buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < num_packets; i++)
pmp->packet_sizes[i] = avio_rl32(pb);
}
ret = av_get_packet(pb, pkt, pmp->packet_sizes[pmp->current_packet]);
if (ret >= 0) {
ret = 0;
// FIXME: this is a hack that should be removed once
// compute_pkt_fields() can handle timestamps properly
if (pmp->cur_stream == 0)
pkt->dts = s->streams[0]->cur_dts++;
pkt->stream_index = pmp->cur_stream;
}
if (pmp->current_packet % pmp->audio_packets == 0)
pmp->cur_stream = (pmp->cur_stream + 1) % pmp->num_streams;
pmp->current_packet++;
return ret;
}
static int pmp_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags)
{
PMPContext *pmp = s->priv_data;
pmp->cur_stream = 0;
// fallback to default seek now
return -1;
}
static int pmp_close(AVFormatContext *s)
{
PMPContext *pmp = s->priv_data;
av_freep(&pmp->packet_sizes);
return 0;
}
AVInputFormat ff_pmp_demuxer = {
.name = "pmp",
.long_name = NULL_IF_CONFIG_SMALL("Playstation Portable PMP"),
.priv_data_size = sizeof(PMPContext),
.read_probe = pmp_probe,
.read_header = pmp_header,
.read_packet = pmp_packet,
.read_seek = pmp_seek,
.read_close = pmp_close,
};
|
#ifndef LISTWINDOW_H
#define LISTWINDOW_H
#include <QMainWindow>
#include <QSharedPointer>
#include <QFile>
#include <QTextStream>
;
namespace Ui {
class ListWindow;
}
namespace DNSView
{
class NonEditableQStringListModel;
class PCapThread;
class ListWindow : public QMainWindow
{
Q_OBJECT
public:
explicit ListWindow(QWidget *parent = 0);
~ListWindow();
protected:
void closeEvent(QCloseEvent *event);
public slots:
void slotDataReady(const QString &value);
void slotError(const QString &value);
void slotOnStartClick();
void slotOnStopClick();
void slotOnSaveFileClick();
void slotDone();
void slotKbps(double value);
signals:
void sigStartPoll(const QString &dev);
void sigStopPoll();
void sigQuit();
private:
QSharedPointer<Ui::ListWindow> spUi_;
QSharedPointer<PCapThread> spPCapThread_;
QSharedPointer<NonEditableQStringListModel> spStringListModel_;
QFile qFile_;
QTextStream qTStream_;
};
}
#endif // LISTWINDOW_H
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61a.c
Label Definition File: CWE124_Buffer_Underwrite__malloc.label.xml
Template File: sources-sink-61a.tmpl.c
*/
/*
* @description
* CWE: 124 Buffer Underwrite
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sinks: ncpy
* BadSink : Copy string to data using wcsncpy
* Flow Variant: 61 Data flow: data returned from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifndef OMITBAD
/* bad function declaration */
wchar_t * CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61b_badSource(wchar_t * data);
void CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61_bad()
{
wchar_t * data;
data = NULL;
data = CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61b_badSource(data);
{
wchar_t source[100];
wmemset(source, L'C', 100-1); /* fill with 'C's */
source[100-1] = L'\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copying data to memory before the destination buffer */
wcsncpy(data, source, 100-1);
/* Ensure the destination buffer is null terminated */
data[100-1] = L'\0';
printWLine(data);
/* INCIDENTAL CWE-401: Memory Leak - data may not point to location
* returned by malloc() so can't safely call free() on it */
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
wchar_t * CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61b_goodG2BSource(wchar_t * data);
static void goodG2B()
{
wchar_t * data;
data = NULL;
data = CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61b_goodG2BSource(data);
{
wchar_t source[100];
wmemset(source, L'C', 100-1); /* fill with 'C's */
source[100-1] = L'\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copying data to memory before the destination buffer */
wcsncpy(data, source, 100-1);
/* Ensure the destination buffer is null terminated */
data[100-1] = L'\0';
printWLine(data);
/* INCIDENTAL CWE-401: Memory Leak - data may not point to location
* returned by malloc() so can't safely call free() on it */
}
}
void CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61_good()
{
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_61_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
// Copyright 2017 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef FXJS_XFA_CJX_EXTRAS_H_
#define FXJS_XFA_CJX_EXTRAS_H_
#include "fxjs/xfa/cjx_node.h"
#include "fxjs/xfa/jse_define.h"
class CXFA_Extras;
class CJX_Extras final : public CJX_Node {
public:
explicit CJX_Extras(CXFA_Extras* node);
~CJX_Extras() override;
// CJX_Object:
bool DynamicTypeIs(TypeTag eType) const override;
JSE_PROP(type);
private:
using Type__ = CJX_Extras;
using ParentType__ = CJX_Node;
static const TypeTag static_type__ = TypeTag::Extras;
};
#endif // FXJS_XFA_CJX_EXTRAS_H_
|
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#ifndef __mitkSTLFileIOFactory_h
#define __mitkSTLFileIOFactory_h
#ifdef _MSC_VER
#pragma warning(disable : 4786)
#endif
#include <MitkLegacyIOExports.h>
#include "itkObjectFactoryBase.h"
#include "mitkBaseData.h"
namespace mitk
{
//##Documentation
//## @brief Create instances of STLFileReader objects using an object factory.
//##
//## @ingroup MitkLegacyIOModule
//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead.
class DEPRECATED() MITKLEGACYIO_EXPORT STLFileIOFactory : public itk::ObjectFactoryBase
{
public:
/** Standard class typedefs. */
typedef STLFileIOFactory Self;
typedef itk::ObjectFactoryBase Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Class methods used to interface with the registered factories. */
const char *GetITKSourceVersion(void) const override;
const char *GetDescription(void) const override;
/** Method for class instantiation. */
itkFactorylessNewMacro(Self);
static STLFileIOFactory *FactoryNew() { return new STLFileIOFactory; }
/** Run-time type information (and related methods). */
itkTypeMacro(STLFileIOFactory, ObjectFactoryBase);
/**
* Register one factory of this type
* \deprecatedSince{2013_09}
*/
DEPRECATED(static void RegisterOneFactory(void))
{
STLFileIOFactory::Pointer STLFileIOFactory = STLFileIOFactory::New();
ObjectFactoryBase::RegisterFactory(STLFileIOFactory);
}
protected:
STLFileIOFactory();
~STLFileIOFactory() override;
private:
STLFileIOFactory(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
};
} // end namespace mitk
#endif
|
/* Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of the Mumble Developers 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 FOUNDATION 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 _GLOBAL_H
#define _GLOBAL_H
#include "Settings.h"
#include "Timer.h"
#include "Version.h"
// Global helper class to spread variables around across threads.
class MainWindow;
class ServerHandler;
class AudioInput;
class AudioOutput;
class Database;
class Log;
class Plugins;
class QSettings;
class LCD;
struct Global {
private:
Q_DISABLE_COPY(Global)
public:
static Global *g_global_struct;
MainWindow *mw;
Settings s;
ServerHandler *sh;
boost::shared_ptr<AudioInput> ai;
boost::shared_ptr<AudioOutput> ao;
Database *db;
Log *l;
Plugins *p;
QSettings *qs;
LCD *lcd;
QNetworkAccessManager *nam;
int iPushToTalk;
Timer tDoublePush;
quint64 uiDoublePush;
int iAltSpeak;
bool bPushToMute;
bool bCenterPosition;
bool bEchoTest;
bool bPosTest;
int iAudioPathTime;
unsigned int uiSession;
int iMaxBandwidth;
int iAudioBandwidth;
int iAudioQuality;
QString qsRegionalHost;
bool bAttenuateOthers;
Global();
};
// Class to handle ordered initialization of globals.
// This allows the same link-time magic as used everywhere else
// for globals that need an init before the GUI starts, but
// after we reach main().
class DeferInit {
private:
Q_DISABLE_COPY(DeferInit)
protected:
static QMultiMap<int, DeferInit *> *qmDeferers;
void add(int priority);
public:
DeferInit(int priority) {
add(priority);
};
DeferInit() {
add(0);
};
virtual ~DeferInit();
virtual void initialize() { };
virtual void destroy() { };
static void run_initializers();
static void run_destroyers();
};
// -Wshadow is bugged. If an inline function of a class uses a variable or
// parameter named 'g', that will generate a warning even if the class header
// is included long before this definition.
#define g (*Global::g_global_struct)
#endif
|
//
// US2ConditionCollection.h
// US2FormValidator
//
// Copyright (C) 2012 ustwo™
//
// 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.
//
#import <Foundation/Foundation.h>
#import "US2Condition.h"
#pragma mark - Condition collection protocol
@class US2ConditionCollection;
/**
A _condition collection_ must conform to US2ConditionCollection protocol methods.
*/
@protocol US2ConditionCollectionProtocol <NSObject>
@required
/**
Add a condition to collection.
@param condition US2Condition instance to add
*/
- (void)addCondition:(id <US2ConditionProtocol>)condition;
/**
Remove a condition from collection.
@param condition US2Condition instance to remove
*/
- (void)removeCondition:(id <US2ConditionProtocol>)condition;
/**
Remove a condition from collection at index.
@param index US2Condition instance to remove at index
*/
- (void)removeConditionAtIndex:(NSUInteger)index;
/**
Returns a condition of collection at index.
@param index Index of condition
@return Return US2Condition instance at index
*/
- (US2Condition *)conditionAtIndex:(NSUInteger)index;
/**
Remove all conditions from collection.
*/
- (void)removeAllConditions;
@end
#pragma mark - Condition collection interface
/**
The US2ConditionCollection is internally an array which contains conditions
of type US2Condition. Use US2ConditionCollection like an array, but in a
typecasted manner.
*Example:*
US2ConditionCollection *conditionCollection = [[US2ConditionCollection alloc] init];
US2Condition *condition1 = [[US2Condition alloc] init];
[conditionCollection addCondition:condition1];
[condition1 release];
US2Condition *condition2 = [conditionCollection conditionAtIndex:0];
[conditionCollection removeCondition:condition2];
BOOL isEmpty = conditionCollection.count == 0; // isEmpty == YES
*/
@interface US2ConditionCollection : NSObject <US2ConditionCollectionProtocol,
NSFastEnumeration>
{
NSMutableArray *_array;
}
/**
Add a condition to collection.
@param condition US2Condition instance to add
*/
- (void)addCondition:(id <US2ConditionProtocol>)condition;
/**
Remove a condition from collection.
@param condition US2Condition instance to remove
*/
- (void)removeCondition:(id <US2ConditionProtocol>)condition;
/**
Remove a condition from collection at index.
@param index US2Condition instance to remove at index
*/
- (void)removeConditionAtIndex:(NSUInteger)index;
/**
Returns a condition of collection at index.
@param index Index of condition
@return Return US2Condition instance at index
*/
- (US2Condition *)conditionAtIndex:(NSUInteger)index;
/**
Remove all conditions from collection.
*/
- (void) removeAllConditions;
/**
Number of conditions in collection.
*/
@property (nonatomic, assign, readonly) NSUInteger count;
@end
|
/* PM watchdog timer management. These functions in this file provide
* a convenient interface to the timers library that manages a list of
* watchdog timers. All details of scheduling an alarm at the CLOCK task
* are hidden behind this interface.
* Only system processes are allowed to set an alarm timer at the kernel.
* Therefore, the PM maintains a local list of timers for user processes
* that requested an alarm signal.
*
* The entry points into this file are:
* pm_set_timer: reset and existing or set a new watchdog timer
* pm_expire_timers: check for expired timers and run watchdog functions
* pm_cancel_timer: remove a time from the list of timers
*
*/
#include "pm.h"
#include <timers.h>
#include <minix/syslib.h>
#include <minix/com.h>
PRIVATE timer_t *pm_timers = NULL;
PRIVATE int pm_expiring = 0;
/*===========================================================================*
* pm_set_timer *
*===========================================================================*/
PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
{
int r;
clock_t now, prev_time = 0, next_time;
if ((r = getuptime(&now)) != OK)
panic("PM couldn't get uptime");
/* Set timer argument and add timer to the list. */
tmr_arg(tp)->ta_int = arg;
prev_time = tmrs_settimer(&pm_timers,tp,now+ticks,watchdog,&next_time);
/* Reschedule our synchronous alarm if necessary. */
if (pm_expiring == 0 && (! prev_time || prev_time > next_time)) {
if (sys_setalarm(next_time, 1) != OK)
panic("PM set timer couldn't set alarm");
}
return;
}
/*===========================================================================*
* pm_expire_timers *
*===========================================================================*/
PUBLIC void pm_expire_timers(clock_t now)
{
clock_t next_time;
/* Check for expired timers. Use a global variable to indicate that
* watchdog functions are called, so that sys_setalarm() isn't called
* more often than necessary when pm_set_timer or pm_cancel_timer are
* called from these watchdog functions. */
pm_expiring = 1;
tmrs_exptimers(&pm_timers, now, &next_time);
pm_expiring = 0;
/* Reschedule an alarm if necessary. */
if (next_time > 0) {
if (sys_setalarm(next_time, 1) != OK)
panic("PM expire timer couldn't set alarm");
}
}
/*===========================================================================*
* pm_cancel_timer *
*===========================================================================*/
PUBLIC void pm_cancel_timer(timer_t *tp)
{
clock_t next_time, prev_time;
prev_time = tmrs_clrtimer(&pm_timers, tp, &next_time);
/* If the earliest timer has been removed, we have to set the alarm to
* the next timer, or cancel the alarm altogether if the last timer has
* been cancelled (next_time will be 0 then).
*/
if (pm_expiring == 0 && (prev_time < next_time || ! next_time)) {
if (sys_setalarm(next_time, 1) != OK)
panic("PM expire timer couldn't set alarm");
}
}
|
/*
*
* Copyright (c) International Business Machines Corp., 2002
*
* 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
*/
/* 12/20/2002 Port to LTP robbiew@us.ibm.com */
/* 06/30/2001 Port to Linux nsharoff@us.ibm.com */
/*
* NAME
* shmt3
*
* CALLS
* shmctl(2) shmget(2) shmat(2)
*
* ALGORITHM
* Create one shared memory segment and attach it twice to the same process,
* at an address that is chosen by the system. After the first attach has
* completed, write to it and then do the second attach.
* Verify that the doubly attached segment contains the same data.
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
/** LTP Port **/
#include "test.h"
#include "usctest.h"
char *TCID="shmt03"; /* Test program identifier. */
int TST_TOTAL=4; /* Total number of test cases. */
extern int Tst_count; /* Test Case counter for tst_* routines */
/**************/
#define K_1 1024
#define SUCCESSFUL 1
int first_attach,
second_attach;
int rm_shm(int);
int main(void)
{
char *cp1, *cp2;
int shmid;
key_t key ;
key = (key_t) getpid() ;
errno = 0 ;
/*------------------------------------------------------------*/
if ((shmid = shmget(key, 16*K_1, IPC_CREAT|0666)) < 0) {
perror("shmget");
tst_resm(TFAIL, "shmget Failed: shmid = %d, errno = %d\n",
shmid, errno) ;
tst_exit() ;
}
tst_resm(TPASS,"shmget");
/*------------------------------------------------------------*/
if ((cp1 = (char *)shmat(shmid, (void *)0, 0)) == (char *)-1) {
perror("shmat");
tst_resm(TFAIL, "shmat Failed: shmid = %d, errno = %d\n",
shmid, errno) ;
} else {
*cp1 = '1' ;
*(cp1+5*K_1) = '2' ;
first_attach = SUCCESSFUL ;
}
tst_resm(TPASS,"1st shmat");
/*------------------------------------------------------------*/
if ((cp2 = (char *)shmat(shmid, (void *)0, 0)) == (char *)-1) {
perror("shmat");
tst_resm(TFAIL, "shmat Failed: shmid = %d, errno = %d\n",
shmid, errno) ;
}
else {
second_attach = SUCCESSFUL ;
if ( (*cp2 != '1' || *(cp2+5*K_1) != '2') &&
first_attach == SUCCESSFUL ) {
tst_resm(TFAIL,
"Error: Shared memory contents\n") ;
}
}
tst_resm(TPASS,"2nd shmat");
/*---------------------------------------------------------------*/
rm_shm(shmid) ;
if ( first_attach && second_attach ) {
if ( *cp2 != '1' || *(cp2+5*K_1) != '2' ||
*cp1 != '1' || *(cp1+5*K_1) != '2' ) {
tst_resm(TFAIL, "Error: Shared memory contents\n") ;
}
}
tst_resm(TPASS, "Correct shared memory contents");
/*-----------------------------------------------------------------*/
tst_exit() ;
/*----------------------------------------------------------------*/
return(0);
}
int rm_shm(shmid)
int shmid ;
{
if (shmctl(shmid, IPC_RMID, NULL) == -1) {
perror("shmctl");
tst_resm(TFAIL,
"shmctl Failed to remove: shmid = %d, errno = %d\n",
shmid, errno) ;
tst_exit();
}
return(0);
}
|
//
// ZDConcurrentOperation.h
// ZDToolKit
//
// Created by Zero.D.Saber on 2019/5/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^ZDTaskOnComplteBlock)(BOOL);
typedef void(^ZDOperationTaskBlock)(ZDTaskOnComplteBlock);
@interface ZDConcurrentOperation : NSOperation
+ (instancetype)operationWithBlock:(ZDOperationTaskBlock)block;
@end
NS_ASSUME_NONNULL_END
|
/**
* Basic header/include file for PromptOverlay.cpp.
*
* @author GabuEx, dawnmew
* @since 1.0
*
* Licensed under the MIT License.
*
* Copyright (c) 2014 Equestrian Dreamers
*
* 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 PROMPTOVERLAY_H
#define PROMPTOVERLAY_H
#include "../EasingFunctions.h"
#include "../LocalizableContent.h"
#include "../MLIFont.h"
#include "../Vector2.h"
#include <deque>
using namespace std;
class PromptButton : public ILocalizableTextOwner
{
public:
static void Initialize(MLIFont *pTextFont);
PromptButton(Vector2 position, const string &textId)
{
this->position = position;
this->textId = textId;
this->isMouseOver = false;
this->isMouseDown = false;
this->isClicked = false;
this->isEnabled = true;
ReloadLocalizableText();
}
virtual ~PromptButton() {}
bool GetIsClicked() { return this->isClicked; }
string GetText() { return this->text; }
void SetIsEnabled(bool isEnabled)
{
this->isEnabled = isEnabled;
if (!isEnabled)
{
this->isMouseOver = false;
this->isMouseDown = false;
this->isClicked = false;
}
}
static string GetClickSoundEffect() { return "ButtonClick3"; }
void Update(int delta);
void Draw(double opacity);
void Reset();
void ReloadLocalizableText() override;
private:
static MLIFont *pTextFont;
Vector2 position;
string textId;
string text;
bool isMouseOver;
bool isMouseDown;
bool isClicked;
bool isEnabled;
};
class PromptOverlay : public ILocalizableTextOwner
{
public:
static void Initialize(MLIFont *pTextFont, MLIFont *pTextEntryFont, Image *pDarkeningImage);
PromptOverlay(const string &headerTextId, bool allowsTextEntry);
virtual ~PromptOverlay();
bool GetIsShowing() { return this->isShowing; }
void SetHeaderTextId(const string &headerTextId);
void SetHeaderText(const string &headerText);
void AddButton(const string &textId);
void FinalizeButtons();
void Begin(const string &initialText = "");
void Update(int delta);
void Draw();
void Reset();
void SetMaxPixelWidth(int pixelWidth, MLIFont *pFontToCheckAgainst) { this->maxPixelWidth = pixelWidth; this->pFontToCheckAgainst = pFontToCheckAgainst; }
void KeepOpen();
void ReloadLocalizableText() override;
private:
static MLIFont *pTextFont;
static MLIFont *pTextEntryFont;
static Image *pDarkeningImage;
string headerTextId;
string headerText;
deque<string> headerTextLines;
bool allowsTextEntry;
string textEntered;
vector<string> buttonTextIdList;
vector<string> finalizedButtonTextIdList;
vector<PromptButton *> buttonList;
EasingFunction *pFadeInEase;
EasingFunction *pFadeOutEase;
double fadeOpacity;
bool isShowing;
int maxPixelWidth;
MLIFont *pFontToCheckAgainst;
double yOffset;
};
#endif
|
/* error.c
* Reseni IJC-DU1, priklad a) b), 28.2.2013
* Autor: Michal Kozubik, FIT, xkozub03@stud.fit.vutbr.cz
* Prelozeno: gcc 4.7.2
* Soubor obsahuje funkce pro vypis chybovych hlasek na standardni chybovy
* vystup. U obou se pracuje s promennym poctem parametru (pomoci stdarg.h)
* a s funkci vfprintf.
* Error: vypisuje chybovou hlasku na standardni chybovy vystup
* FatalError: vypisuje chybovou hlasku na standardni chybovy vystup a
* navic ukonci program pomoci exit(1)
*/
#include "error.h"
void Error(const char *fmt, ...)
{
/* V zadani je zmineno, ze se ma pouzit funkce vfprint. Neni uvedeno, zda je
* pro vypsani uvdni hlasky "CHYBA: " mozne pouzit fprintf(). Kazdopadne mi
* to prislo rozumnejsi. Krkolomejsi verze s vfprintf by vypadala takto:
* vfprintf(stderr, "CHYBA: ", NULL);
*/
va_list args;
fprintf(stderr, "CHYBA: ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
return;
}
void FatalError(const char *fmt, ...)
{
va_list args;
fprintf(stderr, "CHYBA: ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit(1);
} |
//
// ALPHAFileConverter.h
// Alpha
//
// Created by Dal Rupnik on 10/06/15.
// Copyright (c) 2015 Unified Sense. All rights reserved.
//
#import "ALPHADataConverterSource.h"
@interface ALPHAFileConverter : NSObject <ALPHADataConverterSource>
@end
|
//
// AppDelegate.h
// SoundPayDevice
//
// Created by François Le Brun on 27/05/2014.
// Copyright (c) 2014 LeBrun. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
|
//===- MCSectionXCore.h - XCore-specific section representation -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the MCSectionXCore class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_MCSECTION_XCORE_H
#define LLVM_MCSECTION_XCORE_H
#include "llvm/MC/MCSectionELF.h"
namespace llvm {
class MCSectionXCore : public MCSectionELF {
MCSectionXCore(const StringRef &Section, unsigned Type, unsigned Flags,
SectionKind K, bool isExplicit)
: MCSectionELF(Section, Type, Flags, K, isExplicit) {}
public:
enum {
/// SHF_CP_SECTION - All sections with the "c" flag are grouped together
/// by the linker to form the constant pool and the cp register is set to
/// the start of the constant pool by the boot code.
SHF_CP_SECTION = FIRST_TARGET_DEP_FLAG,
/// SHF_DP_SECTION - All sections with the "d" flag are grouped together
/// by the linker to form the data section and the dp register is set to
/// the start of the section by the boot code.
SHF_DP_SECTION = FIRST_TARGET_DEP_FLAG << 1
};
static MCSectionXCore *Create(const StringRef &Section, unsigned Type,
unsigned Flags, SectionKind K,
bool isExplicit, MCContext &Ctx);
/// PrintTargetSpecificSectionFlags - This handles the XCore-specific cp/dp
/// section flags.
virtual void PrintTargetSpecificSectionFlags(const MCAsmInfo &MAI,
raw_ostream &OS) const;
};
} // end namespace llvm
#endif
|
//
// IGLDropDownMenu.h
// IGLDropDownMenuDemo
//
// Created by Galvin Li on 8/30/14.
// Copyright (c) 2014 Galvin Li. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "IGLDropDownItem.h"
@class IGLDropDownMenu;
typedef NS_ENUM(NSUInteger, IGLDropDownMenuRotate) {
IGLDropDownMenuRotateNone,
IGLDropDownMenuRotateLeft,
IGLDropDownMenuRotateRight,
IGLDropDownMenuRotateRandom
};
typedef NS_ENUM(NSUInteger, IGLDropDownMenuType) {
IGLDropDownMenuTypeNormal,
IGLDropDownMenuTypeStack,
IGLDropDownMenuTypeSlidingInBoth,
IGLDropDownMenuTypeSlidingInFromLeft,
IGLDropDownMenuTypeSlidingInFromRight
};
typedef NS_ENUM(NSUInteger, IGLDropDownMenuDirection) {
IGLDropDownMenuDirectionDown,
IGLDropDownMenuDirectionUp,
};
@protocol IGLDropDownMenuDelegate <NSObject>
- (void)dropDownMenu:(IGLDropDownMenu*)dropDownMenu selectedItemAtIndex:(NSInteger)index;
@end
@interface IGLDropDownMenu : UIControl
@property (nonatomic, strong, readonly) IGLDropDownItem *menuButton;
@property (nonatomic, copy) NSString* menuText;
@property (nonatomic, strong) id object;
@property (nonatomic, strong) UIImage *menuIconImage;
@property (nonatomic, copy) NSArray* dropDownItems;
@property (nonatomic, assign) CGSize itemSize;
@property (nonatomic, assign, readonly) NSInteger selectedIndex;
@property (nonatomic, assign) CGFloat paddingLeft;
@property (nonatomic, assign) CGFloat animationDuration;
@property (nonatomic, assign) UIViewAnimationOptions animationOption;
@property (nonatomic, assign) CGFloat itemAnimationDelay;
@property (nonatomic, assign) IGLDropDownMenuRotate rotate;
@property (nonatomic, assign) IGLDropDownMenuType type;
@property (nonatomic, assign) IGLDropDownMenuDirection direction;
@property (nonatomic, assign) CGFloat slidingInOffset;
@property (nonatomic, assign) CGFloat gutterY;
@property (nonatomic, assign) CGFloat alphaOnFold;
@property (nonatomic, assign, getter = isExpanding) BOOL expanding;
@property (nonatomic, assign, getter = shouldFlipWhenToggleView) BOOL flipWhenToggleView;
@property (nonatomic, assign, getter = shouldUseSpringAnimation) BOOL useSpringAnimation;
@property (nonatomic, assign) id<IGLDropDownMenuDelegate> delegate;
- (void)reloadView;
- (void)resetParams;
- (void)selectItemAtIndex:(NSUInteger)index;
- (void)addSelectedItemChangeBlock:(void (^)(NSInteger selectedIndex))block;
@end
|
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#ifndef MOAIFONTSHADER_FSH_H
#define MOAIFONTSHADER_FSH_H
#define SHADER(str) #str
static cc8* _fontShaderFSH = SHADER (
varying LOWP vec4 colorVarying;
varying MEDP vec2 uvVarying;
uniform sampler2D sampler;
void main () {
gl_FragColor [ 0 ] = colorVarying [ 0 ];
gl_FragColor [ 1 ] = colorVarying [ 1 ];
gl_FragColor [ 2 ] = colorVarying [ 2 ];
gl_FragColor [ 3 ] = colorVarying [ 3 ] * texture2D ( sampler, uvVarying )[ 3 ];
}
);
#endif
|
//
// PKTCategoryItemFieldValue.h
// PodioKit
//
// Created by Sebastian Rehnby on 28/04/14.
// Copyright (c) 2014 Citrix Systems, Inc. All rights reserved.
//
#import "PKTItemFieldValue.h"
@interface PKTCategoryItemFieldValue : PKTItemFieldValue
@end
|
// This file was generated based on 'C:\ProgramData\Uno\Packages\Uno.Data.Xml\0.19.2\Source\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.Object.h>
namespace g{
namespace Uno{
namespace Data{
namespace Xml{
// internal class TargetSpecificXmlNode :54
// {
uType* TargetSpecificXmlNode_typeof();
struct TargetSpecificXmlNode : uObject
{
};
// }
}}}} // ::g::Uno::Data::Xml
|
/**
* Copyright (C) 2013 Qualcomm Retail Solutions, Inc. All rights reserved.
*
* This software is the confidential and proprietary information of Qualcomm
* Retail Solutions, Inc.
*
* The following sample code illustrates various aspects of the FYX iOS SDK.
*
* The sample code herein is provided for your convenience, and has not been
* tested or designed to work on any particular system configuration. It is
* provided pursuant to the License Agreement for FYX Software and Developer
* Portal AS IS, and your use of this sample code, whether as provided or with
* any modification, is at your own risk. Neither Qualcomm Retail Solutions,
* Inc. nor any affiliate takes any liability nor responsibility with respect
* to the sample code, and disclaims all warranties, express and implied,
* including without limitation warranties on merchantability, fitness for a
* specified purpose, and against infringement.
*/
#import <Foundation/Foundation.h>
#import "FYXTransmitter.h"
/// comment for documentation
@interface FYXVisit : NSObject
/// comment for documentation
@property (nonatomic) FYXTransmitter *transmitter;
/// comment for documentation
@property (nonatomic) NSDate *startTime;
/// comment for documentation
@property (nonatomic) NSDate *lastUpdateTime;
/// comment for documentation
@property (nonatomic) NSTimeInterval dwellTime;
@end
|
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for
// full license information.
#include <windows.h>
#include "seh.h"
char test[] = "SEH0045.c";
int perfect;
int main() {
ULONG Index1;
ULONG Index2 = 1;
LONG Counter;
Counter = 0;
Index1 = 1;
switch (Index2) {
case 0:
/* never gets here, Index2 is 1 */
Counter += 100;
break;
case 1:
try {
if ((Index1 & 0x1) == 1) {
/* break out of switch stmt */
break;
} else {
Counter += 1;
}
}
finally {
/*
* set counter to 2 after "break"
* in 'case 1'
*/
Counter += 2;
}
Counter += 3;
}
if (Counter != 2) {
printf("TEST 45 FAILED. Counter = %d\n\r", Counter);
return -1;
}
return 0;
}
|
// MESSAGE STATUSTEXT PACKING
#define MAVLINK_MSG_ID_STATUSTEXT 254
typedef struct __mavlink_statustext_t
{
uint8_t severity; ///< Severity of status, 0 = info message, 255 = critical fault
int8_t text[50]; ///< Status text message, without null termination character
} mavlink_statustext_t;
#define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50
/**
* @brief Send a statustext message
*
* @param severity Severity of status, 0 = info message, 255 = critical fault
* @param text Status text message, without null termination character
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t severity, const int8_t* text)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
i += put_uint8_t_by_index(severity, i, msg->payload); //Severity of status, 0 = info message, 255 = critical fault
i += put_array_by_index(text, 50, i, msg->payload); //Status text message, without null termination character
return mavlink_finalize_message(msg, system_id, component_id, i);
}
static inline uint16_t mavlink_msg_statustext_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_statustext_t* statustext)
{
return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text);
}
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const int8_t* text)
{
mavlink_message_t msg;
mavlink_msg_statustext_pack(mavlink_system.sysid, mavlink_system.compid, &msg, severity, text);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE STATUSTEXT UNPACKING
/**
* @brief Get field severity from statustext message
*
* @return Severity of status, 0 = info message, 255 = critical fault
*/
static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload)[0];
}
/**
* @brief Get field text from statustext message
*
* @return Status text message, without null termination character
*/
static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, int8_t* r_data)
{
memcpy(r_data, msg->payload+sizeof(uint8_t), 50);
return 50;
}
static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext)
{
statustext->severity = mavlink_msg_statustext_get_severity(msg);
mavlink_msg_statustext_get_text(msg, statustext->text);
}
|
/*
* This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MANGOS_FORMULAS_H
#define MANGOS_FORMULAS_H
#include "World/World.h"
namespace MaNGOS
{
namespace Honor
{
inline float hk_honor_at_level(uint32 level, uint32 count = 1)
{
return (float)ceil(count * (-0.53177f + 0.59357f * exp((level + 23.54042f) / 26.07859f)));
}
}
namespace XP
{
inline bool IsTrivialLevelDifference(uint32 unitLvl, uint32 targetLvl)
{
if (unitLvl > targetLvl)
{
const uint32 diff = (unitLvl - targetLvl);
switch (unitLvl / 5)
{
case 0: // 0-4
case 1: // 5-9
return (diff > 4);
case 2: // 10-14
case 3: // 15-19
return (diff > 5);
case 4: // 20-24
case 5: // 25-29
return (diff > 6);
case 6: // 30-34
case 7: // 35-39
return (diff > 7);
default: // 40+
return (diff > 8);
}
}
return false;
}
enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY };
inline uint32 GetGrayLevel(uint32 pl_level)
{
if (pl_level <= 5)
return 0;
else if (pl_level <= 39)
return pl_level - 5 - pl_level / 10;
else if (pl_level <= 59)
return pl_level - 1 - pl_level / 5;
else
return pl_level - 9;
}
inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level)
{
if (mob_level >= pl_level + 5)
return RED;
else if (mob_level >= pl_level + 3)
return ORANGE;
else if (mob_level >= pl_level - 2)
return YELLOW;
else if (mob_level > GetGrayLevel(pl_level))
return GREEN;
else
return GRAY;
}
inline uint32 GetZeroDifference(uint32 pl_level)
{
if (pl_level < 8) return 5;
if (pl_level < 10) return 6;
if (pl_level < 12) return 7;
if (pl_level < 16) return 8;
if (pl_level < 20) return 9;
if (pl_level < 30) return 11;
if (pl_level < 40) return 12;
if (pl_level < 45) return 13;
if (pl_level < 50) return 14;
if (pl_level < 55) return 15;
if (pl_level < 60) return 16;
return 17;
}
inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content)
{
uint32 nBaseExp;
switch (content)
{
case CONTENT_1_60: nBaseExp = 45; break;
case CONTENT_61_70: nBaseExp = 235; break;
default:
sLog.outError("BaseGain: Unsupported content level %u", content);
nBaseExp = 45; break;
}
if (mob_level >= pl_level)
{
uint32 nLevelDiff = mob_level - pl_level;
if (nLevelDiff > 4)
nLevelDiff = 4;
return ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2;
}
else
{
uint32 gray_level = GetGrayLevel(pl_level);
if (mob_level > gray_level)
{
uint32 ZD = GetZeroDifference(pl_level);
return (pl_level * 5 + nBaseExp) * (ZD + mob_level - pl_level) / ZD;
}
return 0;
}
}
inline uint32 Gain(Player* pl, Unit* u)
{
if (Creature* creatureUnit = dynamic_cast<Creature*>(u))
{
uint32 xp_gain = 1;
if (creatureUnit->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_XP_AT_KILL)
return 0;
else if (creatureUnit->IsElite())
xp_gain *= 2;
xp_gain *= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(), pl->GetZoneId()));
xp_gain *= creatureUnit->GetCreatureInfo()->ExperienceMultiplier;
return (uint32)(xp_gain * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL));
}
else
return 0;
}
inline float xp_in_group_rate(uint32 count, bool isRaid)
{
if (isRaid)
{
// FIX ME: must apply decrease modifiers dependent from raid size
return 1.0f;
}
else
{
switch (count)
{
case 0:
case 1:
case 2:
return 1.0f;
case 3:
return 1.166f;
case 4:
return 1.3f;
case 5:
default:
return 1.4f;
}
}
}
}
}
#endif
|
/* MiniDLNA media server
* Copyright (C) 2013 NETGEAR
*
* This file is part of MiniDLNA.
*
* MiniDLNA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* MiniDLNA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(HAVE_LINUX_SENDFILE_API)
#include <sys/sendfile.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
return sendfile(sock, sendfd, offset, len);
}
#elif defined(HAVE_DARWIN_SENDFILE_API)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
int ret;
ret = sendfile(sendfd, sock, *offset, &len, NULL, 0);
*offset += len;
return ret;
}
#elif defined(HAVE_FREEBSD_SENDFILE_API)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
int ret;
size_t nbytes = len;
ret = sendfile(sendfd, sock, *offset, nbytes, NULL, &len, 0);
*offset += len;
return ret;
}
#else
#include <errno.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
errno = EINVAL;
return -1;
}
#endif
|
//
// iTermShortcutInputView.h
// iTerm
//
// Created by George Nachman on 4/7/14.
//
//
#import <Cocoa/Cocoa.h>
#import "iTermShortcut.h"
@class iTermShortcutInputView;
@protocol iTermShortcutInputViewDelegate <NSObject>
- (void)shortcutInputView:(iTermShortcutInputView *)view didReceiveKeyPressEvent:(NSEvent *)event;
@end
// Use this class for text fields that take a shortcut as input. Any keydown
// event will be sent to -handleShortcutEvent: while this field's NSTextView is
// the first responder. Events are immediately passed to the shortcutDelegate.
// You can assign the shortcutDelegate in IB as it is an IBOutlet.
@interface iTermShortcutInputView : NSView
@property(nonatomic, weak) IBOutlet id<iTermShortcutInputViewDelegate> shortcutDelegate;
@property(nonatomic, assign) BOOL disableKeyRemapping;
@property(nonatomic, assign, getter=isEnabled) BOOL enabled;
@property(nonatomic, copy) NSString *stringValue;
@property(nonatomic, assign) NSBackgroundStyle backgroundStyle;
@property(nonatomic, retain) iTermShortcut *shortcut;
- (void)handleShortcutEvent:(NSEvent *)event;
- (void)setShortcut:(iTermShortcut *)shortcut;
- (NSString *)identifierForCode:(NSUInteger)code
modifiers:(NSEventModifierFlags)modifiers
character:(NSUInteger)character;
@end
|
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by OcsWmi.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 3000
#define _APS_NEXT_CONTROL_VALUE 3000
#define _APS_NEXT_SYMED_VALUE 3000
#define _APS_NEXT_COMMAND_VALUE 32771
#endif
#endif
|
/*
* max98096.c -- MAX98095/6 ALSA SoC Audio driver
*
* Copyright 2012 Maxim Integrated Products
*
* 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.
*/
#define DEVICE_MAX98096
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/stddef.h>
#include <linux/printk.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/fs.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <linux/spi/spi.h>
#include <linux/spinlock.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/version.h>
#include <sound/max98096.h>
#include "max9809X.h"
#include "max9809X-dsp.h"
#include "max9809X.c"
#include "max9809X-dsp.c"
|
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2014 - 2010 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _IDDETAILSDIALOG_H
#define _IDDETAILSDIALOG_H
#include <QDialog>
#include "util/TokenQueue.h"
#include <retroshare/rsidentity.h>
namespace Ui {
class IdDetailsDialog;
}
class UIStateHelper;
class IdDetailsDialog : public QDialog, public TokenResponse
{
Q_OBJECT
public:
/** Default constructor */
IdDetailsDialog(const RsGxsGroupId &id, QWidget *parent = 0);
/** Default destructor */
~IdDetailsDialog();
/* TokenResponse */
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots:
void modifyReputation();
void toggleAutoBanIdentities(bool b);
static QString inviteMessage();
void sendInvite();
private :
void requestIdDetails();
void insertIdDetails(uint32_t token);
void requestRepList();
void insertRepList(uint32_t token);
private:
RsGxsGroupId mId;
TokenQueue *mIdQueue;
UIStateHelper *mStateHelper;
/** Qt Designer generated object */
Ui::IdDetailsDialog *ui;
};
#endif
|
/*
* Testing memory allocation.
*/
#include <runtime/lib.h>
#include <kernel/uos.h>
#include <random/rand15.h>
#include <mem/mem.h>
/*
* Installed SRAM 64k*8.
*/
#define RAM_START 0x1000
#define RAM_END 0xffff
#define MEM_SIZE 15000
#define NPTR 40
ARRAY (task, 0x400);
mem_pool_t pool;
unsigned long allocated;
void *array [NPTR];
unsigned short size [NPTR];
void print_allocated ()
{
unsigned char i;
debug_printf ("allocated:");
for (i=0; i<NPTR; ++i)
if (array[i]) {
debug_printf (" %p-%p",
array[i], array[i] + mem_size (array[i]) - 1);
}
debug_printf ("\n");
}
void allocate (unsigned char i, unsigned short len)
{
unsigned long real_size;
size[i] = len;
array[i] = mem_alloc (&pool, size[i]);
if (! array[i]) {
/* Failed to allocate */
debug_printf ("\tfailed %d (free %d)\n",
size[i], mem_available (&pool));
/* mem_print_free_list (&pool);*/
/* print_allocated ();*/
return;
}
debug_printf ("+");
real_size = mem_size (array[i]);
allocated += real_size;
memset (array[i], 0, size[i]);
}
void dispose (unsigned char i)
{
unsigned long real_size;
debug_printf ("\b \b");
real_size = mem_size (array[i]);
mem_free (array[i]);
array[i] = 0;
allocated -= real_size;
}
void hello (void *arg)
{
unsigned long available, len;
unsigned char i;
/* srand15 (time(0));*/
for (;;) {
available = mem_available (&pool);
#if 0
if (available + allocated > MEM_SIZE) {
debug_printf ("Mismatch: available(%ld) + allocated(%ld) > %ld\n",
available, allocated, MEM_SIZE);
abort();
}
#endif
/* Keep 60% free memory. */
if (available > (unsigned short) (MEM_SIZE * 60L/100)) {
/* Try to allocate */
for (i=0; i<NPTR; ++i) {
if (! array[i]) {
/* Allocate chunks not more than
* 10% of total memory. */
len = rand15 () % (unsigned short) (MEM_SIZE * 10L/100);
allocate (i, len);
break;
}
}
}
if (array [i = rand15() % NPTR]) {
if (rand15() & 1) {
/* Try to truncate */
unsigned long new_size;
len = mem_size (array[i]);
allocated -= len;
size[i] = rand15() % len;
mem_truncate (array[i], size[i]);
new_size = mem_size (array[i]);
allocated += new_size;
} else {
/* Try to free */
dispose (i);
}
}
}
}
void uos_init (void)
{
/* Baud 9600. */
UBRR = ((int) (KHZ * 1000L / 9600) + 8) / 16 - 1;
/* Enable external RAM: port A - address/data, port C - address. */
setb (SRE, MCUCR);
mem_init (&pool, RAM_START, RAM_END);
task_create (hello, 0, "hello", 1, task, sizeof (task), 0);
}
|
/*
Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef COLORSCHEMEEDITOR_H
#define COLORSCHEMEEDITOR_H
// Qt
#include <QWidget>
class QTableWidgetItem;
namespace Ui
{
class ColorSchemeEditor;
}
namespace Konsole
{
class ColorScheme;
/**
* A dialog for editing color schemes.
*
* After creation, the dialog can be initialized with the settings
* of a color scheme using the setup() method.
*
* The dialog creates a copy of the supplied color scheme to which
* any changes made are applied. The modified color scheme
* can be retrieved using the colorScheme() method.
*
* When changes are made the colorsChanged() signal is emitted.
*/
class ColorSchemeEditor : public QWidget
{
Q_OBJECT
public:
/** Constructs a new color scheme editor with the specified parent. */
explicit ColorSchemeEditor(QWidget* parent = 0);
virtual ~ColorSchemeEditor();
/** Initializes the dialog with the properties of the specified color scheme. */
void setup(const ColorScheme* scheme);
/** Returns the modified color scheme. */
ColorScheme* colorScheme() const;
signals:
/** Emitted when the colors in the color scheme change. */
void colorsChanged(ColorScheme* scheme);
public slots:
/** Sets the text displayed in the description edit field. */
void setDescription(const QString& description);
private slots:
void setTransparencyPercentLabel(int percent);
void setRandomizedBackgroundColor(bool randomized);
void editColorItem(QTableWidgetItem* item);
void wallpaperPathChanged(const QString& path);
void selectWallpaper();
private:
void setupColorTable(const ColorScheme* table);
Ui::ColorSchemeEditor* _ui;
ColorScheme* _colors;
};
}
#endif // COLORSCHEMEEDITOR_H
|
#include "../../corelibs/U2View/src/ov_sequence/sequence_info/DNAStatisticsTask.h"
|
/*
* Copyright (c) 2011 The Chromium OS Authors.
* (C) Copyright 2008,2009
* Graeme Russ, <graeme.russ@gmail.com>
*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <malloc.h>
#include <pci.h>
#include <asm/io.h>
#include <asm/pci.h>
DECLARE_GLOBAL_DATA_PTR;
static struct pci_controller *get_hose(void)
{
if (gd->hose)
return gd->hose;
return pci_bus_to_hose(0);
}
unsigned int x86_pci_read_config8(pci_dev_t dev, unsigned where)
{
uint8_t value;
if (pci_hose_read_config_byte(get_hose(), dev, where, &value))
return -1U;
return value;
}
unsigned int x86_pci_read_config16(pci_dev_t dev, unsigned where)
{
uint16_t value;
if (pci_hose_read_config_word(get_hose(), dev, where, &value))
return -1U;
return value;
}
unsigned int x86_pci_read_config32(pci_dev_t dev, unsigned where)
{
uint32_t value;
if (pci_hose_read_config_dword(get_hose(), dev, where, &value))
return -1U;
return value;
}
void x86_pci_write_config8(pci_dev_t dev, unsigned where, unsigned value)
{
pci_hose_write_config_byte(get_hose(), dev, where, value);
}
void x86_pci_write_config16(pci_dev_t dev, unsigned where, unsigned value)
{
pci_hose_write_config_word(get_hose(), dev, where, value);
}
void x86_pci_write_config32(pci_dev_t dev, unsigned where, unsigned value)
{
pci_hose_write_config_dword(get_hose(), dev, where, value);
}
int pci_x86_read_config(struct udevice *bus, pci_dev_t bdf, uint offset,
ulong *valuep, enum pci_size_t size)
{
outl(bdf | (offset & 0xfc) | PCI_CFG_EN, PCI_REG_ADDR);
switch (size) {
case PCI_SIZE_8:
*valuep = inb(PCI_REG_DATA + (offset & 3));
break;
case PCI_SIZE_16:
*valuep = inw(PCI_REG_DATA + (offset & 2));
break;
case PCI_SIZE_32:
*valuep = inl(PCI_REG_DATA);
break;
}
return 0;
}
int pci_x86_write_config(struct udevice *bus, pci_dev_t bdf, uint offset,
ulong value, enum pci_size_t size)
{
outl(bdf | (offset & 0xfc) | PCI_CFG_EN, PCI_REG_ADDR);
switch (size) {
case PCI_SIZE_8:
outb(value, PCI_REG_DATA + (offset & 3));
break;
case PCI_SIZE_16:
outw(value, PCI_REG_DATA + (offset & 2));
break;
case PCI_SIZE_32:
outl(value, PCI_REG_DATA);
break;
}
return 0;
}
void pci_assign_irqs(int bus, int device, u8 irq[4])
{
pci_dev_t bdf;
int func;
u16 vendor;
u8 pin, line;
for (func = 0; func < 8; func++) {
bdf = PCI_BDF(bus, device, func);
vendor = x86_pci_read_config16(bdf, PCI_VENDOR_ID);
if (vendor == 0xffff || vendor == 0x0000)
continue;
pin = x86_pci_read_config8(bdf, PCI_INTERRUPT_PIN);
/* PCI spec says all values except 1..4 are reserved */
if ((pin < 1) || (pin > 4))
continue;
line = irq[pin - 1];
if (!line)
continue;
debug("Assigning IRQ %d to PCI device %d.%x.%d (INT%c)\n",
line, bus, device, func, 'A' + pin - 1);
x86_pci_write_config8(bdf, PCI_INTERRUPT_LINE, line);
}
}
|
// license:BSD-3-Clause
// copyright-holders:hap, Sean Riddle, Kevin Horton
/*
TMS1000 MCU series tabletops/handhelds or other simple devices.
*/
#ifndef _HH_TMS1K_H_
#define _HH_TMS1K_H_
#include "emu.h"
#include "cpu/tms1000/tms1000.h"
#include "cpu/tms1000/tms1100.h"
#include "cpu/tms1000/tms1400.h"
#include "cpu/tms1000/tms0970.h"
#include "cpu/tms1000/tms0980.h"
#include "cpu/tms1000/tms0270.h"
#include "cpu/tms1000/tp0320.h"
#include "sound/speaker.h"
class hh_tms1k_state : public driver_device
{
public:
hh_tms1k_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_inp_matrix(*this, "IN"),
m_speaker(*this, "speaker"),
m_display_wait(33),
m_display_maxy(1),
m_display_maxx(0)
{ }
// devices
required_device<tms1k_base_device> m_maincpu;
optional_ioport_array<18> m_inp_matrix; // max 18
optional_device<speaker_sound_device> m_speaker;
// misc common
UINT16 m_r; // MCU R-pins data
UINT16 m_o; // MCU O-pins data
UINT32 m_inp_mux; // multiplexed inputs mask
bool m_power_on;
bool m_power_led;
UINT8 read_inputs(int columns);
UINT8 read_rotated_inputs(int columns, UINT8 rowmask = 0xf);
virtual DECLARE_INPUT_CHANGED_MEMBER(power_button);
virtual DECLARE_WRITE_LINE_MEMBER(auto_power_off);
// display common
int m_display_wait; // led/lamp off-delay in microseconds (default 33ms)
int m_display_maxy; // display matrix number of rows
int m_display_maxx; // display matrix number of columns (max 31 for now)
UINT32 m_grid; // VFD/LED current row data
UINT32 m_plate; // VFD/LED current column data
UINT32 m_display_state[0x20]; // display matrix rows data (last bit is used for always-on)
UINT16 m_display_segmask[0x20]; // if not 0, display matrix row is a digit, mask indicates connected segments
UINT32 m_display_cache[0x20]; // (internal use)
UINT8 m_display_decay[0x20][0x20]; // (internal use)
TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick);
void display_update();
void set_display_size(int maxx, int maxy);
void set_display_segmask(UINT32 digits, UINT32 mask);
void display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety, bool update = true);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
};
// LED segments
enum
{
lA = 0x01,
lB = 0x02,
lC = 0x04,
lD = 0x08,
lE = 0x10,
lF = 0x20,
lG = 0x40,
lDP = 0x80
};
#endif /* _HH_TMS1K_H_ */
|
/* AbiWord
* Copyright (C) 2005 Martin Sevior <msevior@physics.unimel.edu.au>
*
* 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.
*/
/*****************************************************************
******************************************************************
** IT IS IMPORTANT THAT THIS FILE ALLOW ITSELF TO BE INCLUDED
** MORE THAN ONE TIME.
******************************************************************
*****************************************************************/
BeginLayout(ContextEmbedLayoutT,EV_EMC_EMBED)
BeginPopupMenu()
MenuItem(AP_MENU_ID_FMT_EMBED)
MenuItem(AP_MENU_ID_FILE_SAVEEMBED)
Separator()
MenuItem(AP_MENU_ID_EDIT_CUTEMBED)
MenuItem(AP_MENU_ID_EDIT_COPYEMBED)
MenuItem(AP_MENU_ID_EDIT_DELETEEMBED)
EndPopupMenu()
EndLayout()
|
/*
* llist.c: linked list routines
*
* Some code copyright (C) 2002-2003, Philip S Tellis <philip . tellis AT gmx . net>
* Other code copyright Meredydd Luff <meredydd AT everybuddy.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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Some of this code was borrowed from elist.c in the eb-lite sources
*
*/
#include <stdlib.h>
#include "llist.h"
LList *l_list_append(LList *list, void *data)
{
LList *n;
LList *new_list = malloc(sizeof(LList));
LList *attach_to = NULL;
new_list->next = NULL;
new_list->data = data;
for (n = list; n != NULL; n = n->next) {
attach_to = n;
}
if (attach_to == NULL) {
new_list->prev = NULL;
return new_list;
} else {
new_list->prev = attach_to;
attach_to->next = new_list;
return list;
}
}
LList *l_list_prepend(LList *list, void *data)
{
LList *n = malloc(sizeof(LList));
n->next = list;
n->prev = NULL;
n->data = data;
if (list)
list->prev = n;
return n;
}
LList *l_list_concat(LList *list, LList *add)
{
LList *l;
if (!list)
return add;
if (!add)
return list;
for (l = list; l->next; l = l->next) ;
l->next = add;
add->prev = l;
return list;
}
LList *l_list_remove(LList *list, void *data)
{
LList *n;
for (n = list; n != NULL; n = n->next) {
if (n->data == data) {
LList *new = l_list_remove_link(list, n);
free(n);
return new;
}
}
return list;
}
/* Warning */
/* link MUST be part of list */
LList *l_list_remove_link(LList *list, const LList *link)
{
if (!link)
return list;
if (link->next)
link->next->prev = link->prev;
if (link->prev)
link->prev->next = link->next;
if (link == list)
list = link->next;
return list;
}
int l_list_length(const LList *list)
{
int retval = 0;
const LList *n = list;
for (n = list; n != NULL; n = n->next) {
retval++;
}
return retval;
}
/* well, you could just check for list == NULL, but that would be
* implementation dependent
*/
int l_list_empty(const LList *list)
{
if (!list)
return 1;
else
return 0;
}
int l_list_singleton(const LList *list)
{
if (!list || list->next)
return 0;
return 1;
}
LList *l_list_copy(LList *list)
{
LList *n;
LList *copy = NULL;
for (n = list; n != NULL; n = n->next) {
copy = l_list_append(copy, n->data);
}
return copy;
}
void l_list_free_1(LList *list)
{
free(list);
}
void l_list_free(LList *list)
{
LList *n = list;
while (n != NULL) {
LList *next = n->next;
free(n);
n = next;
}
}
LList *l_list_find(LList *list, const void *data)
{
LList *l;
for (l = list; l && l->data != data; l = l->next) ;
return l;
}
void l_list_foreach(LList *list, LListFunc fn, void *user_data)
{
for (; list; list = list->next)
fn(list->data, user_data);
}
LList *l_list_find_custom(LList *list, const void *data, LListCompFunc comp)
{
LList *l;
for (l = list; l; l = l->next)
if (comp(l->data, data) == 0)
return l;
return NULL;
}
LList *l_list_nth(LList *list, int n)
{
int i = n;
for (; list && i; list = list->next, i--) ;
return list;
}
LList *l_list_insert_sorted(LList *list, void *data, LListCompFunc comp)
{
LList *l, *n, *prev = NULL;
if (!list)
return l_list_append(list, data);
n = malloc(sizeof(LList));
n->data = data;
for (l = list; l && comp(l->data, n->data) <= 0; l = l->next)
prev = l;
if (l) {
n->prev = l->prev;
l->prev = n;
} else
n->prev = prev;
n->next = l;
if (n->prev) {
n->prev->next = n;
return list;
} else {
return n;
}
}
|
#ifndef _ASM_X86_BOOTPARAM_H
#define _ASM_X86_BOOTPARAM_H
#include <linux/types.h>
#include <linux/screen_info.h>
#include <linux/apm_bios.h>
#include <linux/edd.h>
#include <asm/e820.h>
#include <asm/ist.h>
#include <asm/video/edid.h>
/* setup data types */
enum {
SETUP_NONE = 0,
SETUP_E820_EXT,
SETUP_DTB,
};
/* extensible setup data list node */
struct setup_data {
__u64 next;
__u32 type;
__u32 len;
__u8 data[0];
};
struct setup_header {
__u8 setup_sects;
__u16 root_flags;
__u32 syssize;
__u16 ram_size;
#define RAMDISK_IMAGE_START_MASK 0x07FF
#define RAMDISK_PROMPT_FLAG 0x8000
#define RAMDISK_LOAD_FLAG 0x4000
__u16 vid_mode;
__u16 root_dev;
__u16 boot_flag;
__u16 jump;
__u32 header;
__u16 version;
__u32 realmode_swtch;
__u16 start_sys;
__u16 kernel_version;
__u8 type_of_loader;
__u8 loadflags;
#define LOADED_HIGH (1<<0)
#define QUIET_FLAG (1<<5)
#define KEEP_SEGMENTS (1<<6)
#define CAN_USE_HEAP (1<<7)
__u16 setup_move_size;
__u32 code32_start;
__u32 ramdisk_image;
__u32 ramdisk_size;
__u32 bootsect_kludge;
__u16 heap_end_ptr;
__u8 ext_loader_ver;
__u8 ext_loader_type;
__u32 cmd_line_ptr;
__u32 initrd_addr_max;
__u32 kernel_alignment;
__u8 relocatable_kernel;
__u8 _pad2[3];
__u32 cmdline_size;
__u32 hardware_subarch;
__u64 hardware_subarch_data;
__u32 payload_offset;
__u32 payload_length;
__u64 setup_data;
__u64 pref_address;
__u32 init_size;
__u32 handover_offset;
} __attribute__((packed));
struct sys_desc_table {
__u16 length;
__u8 table[14];
};
struct efi_info {
__u32 efi_loader_signature;
__u32 efi_systab;
__u32 efi_memdesc_size;
__u32 efi_memdesc_version;
__u32 efi_memmap;
__u32 efi_memmap_size;
__u32 efi_systab_hi;
__u32 efi_memmap_hi;
};
/* The so-called "zeropage" */
struct boot_params {
struct screen_info screen_info; /* 0x000 */
struct apm_bios_info apm_bios_info; /* 0x040 */
__u8 _pad2[4]; /* 0x054 */
__u64 tboot_addr; /* 0x058 */
struct ist_info ist_info; /* 0x060 */
__u64 acpi_rsdp_addr; /* 0x070 */
__u8 _pad3[8]; /* 0x078 */
__u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
__u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
struct sys_desc_table sys_desc_table; /* 0x0a0 */
__u8 _pad4[144]; /* 0x0b0 */
struct edid_info edid_info; /* 0x140 */
struct efi_info efi_info; /* 0x1c0 */
__u32 alt_mem_k; /* 0x1e0 */
__u32 scratch; /* Scratch field! */ /* 0x1e4 */
__u8 e820_entries; /* 0x1e8 */
__u8 eddbuf_entries; /* 0x1e9 */
__u8 edd_mbr_sig_buf_entries; /* 0x1ea */
__u8 _pad6[6]; /* 0x1eb */
struct setup_header hdr; /* setup header */ /* 0x1f1 */
__u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
__u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
struct e820_entry e820_map[E820MAX]; /* 0x2d0 */
__u8 _pad8[48]; /* 0xcd0 */
struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */
__u8 _pad9[276]; /* 0xeec */
} __attribute__((packed));
enum {
X86_SUBARCH_PC = 0,
X86_SUBARCH_LGUEST,
X86_SUBARCH_XEN,
X86_SUBARCH_INTEL_MID,
X86_SUBARCH_CE4100,
X86_NR_SUBARCHS,
};
#endif /* _ASM_X86_BOOTPARAM_H */
|
#ifndef QHIMDDETECTION_H
#define QHIMDDETECTION_H
#include <QObject>
#include <QList>
#include <QString>
#include <qmddevice.h>
// known vendor IDs
#define SONY 0x054c
#define SHARP 0x4dd
// known himd-mode product IDs
#define MZ_NH1_HIMD 0x017f
#define MZ_NH3D_HIMD 0x0181
#define MZ_NH900_HIMD 0x0183
#define MZ_NH700_HIMD 0x0185
#define MZ_NH600_HIMD 0x0187
#define LAM_3_HIMD 0x018b
#define MZ_DH10P_HIMD 0x01ea
#define MZ_RH10_HIMD 0x021a
#define MZ_RH910_HIMD 0x021c
#define CMT_AH10_HIMD 0x022d
#define DS_HMD1_HIMD 0x023d
#define MZ_RH1_HIMD 0x0287
// known Sony/Aiwa netmd-mode product IDs
#define PCLK_XX 0x34
#define UNKNOWN_A 0x36
#define MZ_N1 0x75
#define UNKNOWN_B 0x7c
#define LAM_1 0x80
#define MDS_JE780 0x81 // or MDS-JE980
#define MZ_N505 0x84
#define MZ_S1 0x85
#define MZ_N707 0x86
#define CMT_C7NT 0x8e
#define PCGA_MDN1 0x97
#define CMT_L7HD 0xad
#define MZ_N10 0xc6
#define MZ_N910 0xc7
#define MZ_N710 0xc8 // or MZ-NE810/NF810
#define MZ_N510 0xc9 // or MZ-NF610
#define MZ_NE410 0xca // or MZ-DN430/NF520
#define MZ_NE810 0xeb // or MZ-NE910
#define CMT_M333NT 0xe7 // or CMT-M373NT
#define LAM_10 0x101
#define AIWA_AM_NX1 0x113
#define AIWA_AM_NX9 0x14c
#define MZ_NH1 0x17e
#define MZ_NH3D 0x180
#define MZ_NH900 0x182
#define MZ_NH700 0x184 // or MZ-NH800
#define MZ_NH600 0x186 // or MZ-NH600D
#define MZ_N920 0x188
#define LAM_3 0x18a
#define MZ_DH10P 0x1e9
#define MZ_RH10 0x219
#define MZ_RH910 0x21b
#define CMT_AH10_A 0x21d
#define CMT_AH10_B 0x22c
#define DS_HMD1 0x23c
#define MZ_RH1 0x286
// known Sharp netmd-mode product IDs
#define IM_MT880H 0x7202 // or IM-MT899H
#define IM_DR400 0x9013 // or IM-DR410
#define IM_DR80 0x9014 // or IM-DR420/DR580 / Kenwood DMC-S9NET
const char * identify_usb_device(int vid, int pid);
typedef QList<QMDDevice *> QMDDevicePtrList;
class QHiMDDetection : public QObject {
Q_OBJECT
Q_DISABLE_COPY(QHiMDDetection)
protected:
QMDDevicePtrList dlist;
netmd_device * dev_list;
public:
explicit QHiMDDetection(QObject *parent = 0);
virtual ~QHiMDDetection();
virtual void clearDeviceList();
virtual void cleanup_netmd_list();
void rescan_netmd_devices();
void scan_for_minidisc_devices();
virtual void scan_for_himd_devices(){}
virtual void remove_himddevice(QString path);
void scan_for_netmd_devices();
QMDDevice *find_by_path(QString path);
QMDDevice *find_by_name(QString name);
signals:
void deviceListChanged(QMDDevicePtrList list);
};
QHiMDDetection * createDetection(QObject * parent = NULL);
#endif // QHIMDDETECTION_H
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <console/console.h>
#include <fsp/util.h>
struct hob_type_name {
uint16_t type;
const char *name;
} __packed;
static const struct hob_type_name hob_type_names[] = {
{ HOB_TYPE_HANDOFF, "HOB_TYPE_HANDOFF" },
{ HOB_TYPE_MEMORY_ALLOCATION, "HOB_TYPE_MEMORY_ALLOCATION" },
{ HOB_TYPE_RESOURCE_DESCRIPTOR, "HOB_TYPE_RESOURCE_DESCRIPTOR" },
{ HOB_TYPE_GUID_EXTENSION, "HOB_TYPE_GUID_EXTENSION" },
{ HOB_TYPE_FV, "HOB_TYPE_FV" },
{ HOB_TYPE_CPU, "HOB_TYPE_CPU" },
{ HOB_TYPE_MEMORY_POOL, "HOB_TYPE_MEMORY_POOL" },
{ HOB_TYPE_FV2, "HOB_TYPE_FV2" },
{ HOB_TYPE_LOAD_PEIM_UNUSED, "HOB_TYPE_LOAD_PEIM_UNUSED" },
{ HOB_TYPE_UCAPSULE, "HOB_TYPE_UCAPSULE" },
{ HOB_TYPE_UNUSED, "HOB_TYPE_UNUSED" },
{ HOB_TYPE_END_OF_HOB_LIST, "HOB_TYPE_END_OF_HOB_LIST" }
};
static const char *resource_names[] = {
[EFI_RESOURCE_SYSTEM_MEMORY] = "SYSTEM_MEMORY",
[EFI_RESOURCE_MEMORY_MAPPED_IO] = "MMIO",
[EFI_RESOURCE_IO] = "IO",
[EFI_RESOURCE_FIRMWARE_DEVICE] = "FIRMWARE_DEVICE",
[EFI_RESOURCE_MEMORY_MAPPED_IO_PORT] = "MMIO_PORT",
[EFI_RESOURCE_MEMORY_RESERVED] = "MEMORY_RESERVED",
[EFI_RESOURCE_IO_RESERVED] = "IO_RESERVED",
};
static const uint8_t bootloader_temp_memory_guid[16] = {
0x6c, 0xf4, 0xcf, 0xbb, 0xd3, 0xc8, 0x13, 0x41,
0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
};
static const uint8_t empty_guid[16] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static const uint8_t fsp_graphics_info_guid[16] = {
0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
};
static const uint8_t fsp_info_header_guid[16] = {
0xbe, 0x40, 0x27, 0x91, 0x84, 0x22, 0x34, 0x47,
0xb9, 0x71, 0x84, 0xb0, 0x27, 0x35, 0x3f, 0x0c
};
static const uint8_t smbios_memory_info_guid[16] = {
0x8c, 0x10, 0xa1, 0x01, 0xee, 0x9d, 0x84, 0x49,
0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89
};
static const uint8_t tseg_guid[16] = {
0x7c, 0x74, 0x38, 0xd0, 0x0c, 0xd0, 0x80, 0x49,
0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55
};
struct guid_name_map {
const void *guid;
const char *name;
};
static const struct guid_name_map guid_names[] = {
{ bootloader_temp_memory_guid, "FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" },
{ fsp_bootloader_tolum_guid, "BOOTLOADER_TOLUM" },
{ empty_guid, "No GUID specified" },
{ fsp_info_header_guid, "FSP_INFO_HEADER_GUID" },
{ fsp_reserved_memory_guid, "FSP_RESERVED_MEMORY" },
{ fsp_nv_storage_guid, "FSP_NV_STORAGE" },
{ fsp_graphics_info_guid, "GRAPHICS INFO" },
{ smbios_memory_info_guid, "FSP_SMBIOS_MEMORY_INFO_GUID" },
{ tseg_guid, "TSEG" },
};
static const char *resource_name(uint32_t type)
{
if (type >= ARRAY_SIZE(resource_names))
return "UNKNOWN";
return resource_names[type];
}
void fsp_print_resource_descriptor(const void *base)
{
const struct hob_resource *res;
res = fsp_hob_header_to_resource(base);
printk(BIOS_SPEW, "Resource %s, attribute %x\n",
resource_name(res->type), res->attribute_type);
printk(BIOS_SPEW, "\t0x%08llx + 0x%08llx\n", res->addr, res->length);
if (!fsp_guid_compare(res->owner_guid, empty_guid)) {
printk(BIOS_SPEW, "\tOwner GUID: ");
fsp_print_guid(res->owner_guid);
printk(BIOS_SPEW, " (%s)\n",
fsp_get_guid_name(res->owner_guid));
}
}
void fsp_print_memory_resource_hobs(void)
{
const struct hob_header *hob = fsp_get_hob_list();
for (; hob->type != HOB_TYPE_END_OF_HOB_LIST;
hob = fsp_next_hob(hob)) {
if (hob->type == HOB_TYPE_RESOURCE_DESCRIPTOR)
fsp_print_resource_descriptor(hob);
}
}
const char *fsp_get_hob_type_name(const struct hob_header *hob)
{
size_t index;
const char *name;
for (index = 0; index < ARRAY_SIZE(hob_type_names); index++)
if (hob->type == hob_type_names[index].type)
return hob_type_names[index].name;
/* Get name for SOC specific hob */
name = soc_get_hob_type_name(hob);
if (name != NULL)
return name;
return "Unknown HOB type";
}
const char *fsp_get_guid_name(const uint8_t *guid)
{
size_t index;
const char *name;
/* Compare the GUID values in this module */
for (index = 0; index < ARRAY_SIZE(guid_names); index++)
if (fsp_guid_compare(guid, guid_names[index].guid))
return guid_names[index].name;
/* Get GUID name from SOC */
name = soc_get_guid_name(guid);
if (name != NULL)
return name;
return "Unknown GUID";
}
__weak const char *soc_get_hob_type_name(
const struct hob_header *hob)
{
return NULL;
}
void fsp_print_guid_extension_hob(const struct hob_header *hob)
{
const struct hob_resource *res;
res = fsp_hob_header_to_resource(hob);
printk(BIOS_SPEW, "\t");
fsp_print_guid(res->owner_guid);
printk(BIOS_SPEW, ": %s\n", fsp_get_guid_name(res->owner_guid));
/* Some of the SoC FSP specific hobs are of type HOB_TYPE_GUID_EXTENSION */
soc_display_hob(hob);
}
__weak const char *soc_get_guid_name(const uint8_t *guid)
{
return NULL;
}
void fsp_display_hobs(void)
{
const struct hob_header *hob = fsp_get_hob_list();
/* Display the HOB list pointer */
printk(BIOS_SPEW, "\n=== FSP HOBs ===\n");
printk(BIOS_SPEW, "%p: hob_list_ptr\n", hob);
/* Walk the list of HOBs */
while (1) {
/* Display the HOB header */
printk(BIOS_SPEW, "%p, 0x%08x bytes: %s\n", hob, hob->length,
fsp_get_hob_type_name(hob));
switch (hob->type) {
default:
soc_display_hob(hob);
break;
case HOB_TYPE_END_OF_HOB_LIST:
printk(BIOS_SPEW, "=== End of FSP HOBs ===\n\n");
return;
case HOB_TYPE_RESOURCE_DESCRIPTOR:
fsp_print_resource_descriptor(hob);
break;
case HOB_TYPE_GUID_EXTENSION:
fsp_print_guid_extension_hob(hob);
break;
}
hob = fsp_next_hob(hob);
}
}
__weak void soc_display_hob(const struct hob_header *hob)
{
}
|
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: crystal.xiong REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/*
* mq_timedreceive() test plan:
* mq_timedreceive() will fail with EBADF, if mqdes is not a valid message
* message queue descriptor.
*/
#include <stdio.h>
#include <errno.h>
#include <mqueue.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "posixtest.h"
#define TEST "14-1"
#define FUNCTION "mq_timedreceive"
#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
#define NAMESIZE 50
#define BUFFER 40
int main()
{
char mqname[NAMESIZE];
mqd_t mqdes;
char msgrv[BUFFER];
struct timespec ts;
struct mq_attr attr;
int unresolved = 0, failure = 0;
sprintf(mqname, "/" FUNCTION "_" TEST "_%d", getpid());
attr.mq_msgsize = BUFFER;
attr.mq_maxmsg = BUFFER;
mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
if (mqdes == (mqd_t)-1) {
perror(ERROR_PREFIX "mq_open()");
unresolved = 1;
}
mqdes = mqdes + 1;
ts.tv_sec = time(NULL) + 1;
ts.tv_nsec = 0;
if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) {
if (EBADF != errno) {
printf("errno != EBADF \n");
failure = 1;
}
}
else {
printf("mq_timedreceive() succeed unexpectly \n");
failure = 1;
}
if (mq_close(mqdes - 1) != 0) {
perror(ERROR_PREFIX "mq_close()");
unresolved=1;
}
if (mq_unlink(mqname) != 0) {
perror(ERROR_PREFIX "mq_unlink()");
unresolved=1;
}
if (failure==1) {
printf("Test FAILED\n");
return PTS_FAIL;
}
if (unresolved==1) {
printf("Test UNRESOLVED\n");
return PTS_UNRESOLVED;
}
printf("Test PASSED\n");
return PTS_PASS;
}
|
#pragma once
#include "gcm_enums.h"
namespace rsx
{
class fragment_texture
{
protected:
const u8 m_index;
std::array<u32, 0x10000 / 4> ®isters;
public:
fragment_texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
fragment_texture() = delete;
// Offset
u32 offset() const;
// Format
u8 location() const;
bool cubemap() const;
u8 border_type() const;
rsx::texture_dimension dimension() const;
/**
* 2d texture can be either plane or cubemap texture depending on cubemap bit.
* Since cubemap is a format per se in all gfx API this function directly returns
* cubemap as a separate dimension.
*/
rsx::texture_dimension_extended get_extended_texture_dimension() const;
u8 format() const;
bool is_compressed_format() const;
u16 mipmap() const;
/**
* mipmap() returns value from register which can be higher than the actual number of mipmap level.
* This function clamp the result with the mipmap count allowed by texture size.
*/
u16 get_exact_mipmap_count() const;
// Address
rsx::texture_wrap_mode wrap_s() const;
rsx::texture_wrap_mode wrap_t() const;
rsx::texture_wrap_mode wrap_r() const;
rsx::comparison_function zfunc() const;
u8 unsigned_remap() const;
u8 gamma() const;
u8 aniso_bias() const;
u8 signed_remap() const;
// Control0
bool enabled() const;
f32 min_lod() const;
f32 max_lod() const;
rsx::texture_max_anisotropy max_aniso() const;
bool alpha_kill_enabled() const;
// Control1
u32 remap() const;
/**
* returns a pair of arrays
* First array is a redirection table into the channel indices
* Second array is a lookup reference deciding whether to use the redirection table or use constants 0 and 1
* Both arrays have components in A-R-G-B format
*/
std::pair<std::array<u8, 4>, std::array<u8, 4>> decoded_remap() const;
// Filter
f32 bias() const;
rsx::texture_minify_filter min_filter() const;
rsx::texture_magnify_filter mag_filter() const;
u8 convolution_filter() const;
u8 argb_signed() const;
bool a_signed() const;
bool r_signed() const;
bool g_signed() const;
bool b_signed() const;
// Image Rect
u16 width() const;
u16 height() const;
// Border Color
u32 border_color() const;
u16 depth() const;
u32 pitch() const;
};
class vertex_texture
{
protected:
const u8 m_index;
std::array<u32, 0x10000 / 4> ®isters;
public:
vertex_texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
vertex_texture() = delete;
// Offset
u32 offset() const;
// Format
u8 location() const;
bool cubemap() const;
u8 border_type() const;
rsx::texture_dimension dimension() const;
u8 format() const;
u16 mipmap() const;
// Address
rsx::texture_wrap_mode wrap_s() const;
rsx::texture_wrap_mode wrap_t() const;
rsx::texture_wrap_mode wrap_r() const;
std::pair<std::array<u8, 4>, std::array<u8, 4>> decoded_remap() const;
u32 remap() const;
// Control0
bool enabled() const;
f32 min_lod() const;
f32 max_lod() const;
// Filter
f32 bias() const;
rsx::texture_minify_filter min_filter() const;
rsx::texture_magnify_filter mag_filter() const;
// Image Rect
u16 width() const;
u16 height() const;
// Border Color
u32 border_color() const;
u16 depth() const;
u32 pitch() const;
rsx::texture_dimension_extended get_extended_texture_dimension() const;
u16 get_exact_mipmap_count() const;
};
}
|
/*
* Copyright (C) 2012 Samsung Electronics
* Alim Akhtar <alim.akhtar@samsung.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, write to the Free Software
* Foundation, Inc.
*/
#ifndef __MAX77686_H_
#define __MAX77686_H_
enum max77686_regnum {
PMIC_BUCK1 = 0,
PMIC_BUCK2,
PMIC_BUCK3,
PMIC_BUCK4,
PMIC_BUCK5,
PMIC_BUCK6,
PMIC_BUCK7,
PMIC_BUCK8,
PMIC_BUCK9,
PMIC_LDO1,
PMIC_LDO2,
PMIC_LDO3,
PMIC_LDO4,
PMIC_LDO5,
PMIC_LDO6,
PMIC_LDO7,
PMIC_LDO8,
PMIC_LDO9,
PMIC_LDO10,
PMIC_LDO11,
PMIC_LDO12,
PMIC_LDO13,
PMIC_LDO14,
PMIC_LDO15,
PMIC_LDO16,
PMIC_LDO17,
PMIC_LDO18,
PMIC_LDO19,
PMIC_LDO20,
PMIC_LDO21,
PMIC_LDO22,
PMIC_LDO23,
PMIC_LDO24,
PMIC_LDO25,
PMIC_LDO26,
PMIC_EN32KHZ_CP,
};
/**
* struct max77686_para - max77686 register parameters
* @param vol_addr i2c address of the given buck/ldo register
* @param vol_bitpos bit position to be set or clear within register
* @param vol_bitmask bit mask value
* @param reg_enaddr control register address, which enable the given
* given buck/ldo.
* @param reg_enbitpos bit position to be enabled
* @param reg_enbiton value to be written to buck/ldo to make it ON
* @param reg_enbitoff value to be written to buck/ldo to make it OFF
* @param vol_min minimum voltage level supported by given buck/ldo
* @param vol_div voltage division value of given buck/ldo
*/
struct max77686_para {
u8 vol_addr;
u8 vol_bitpos;
u8 vol_bitmask;
u8 reg_enaddr;
u8 reg_enbitpos;
u8 reg_enbitmask;
u8 reg_enbiton;
u8 reg_enbitoff;
u16 vol_min;
u16 vol_div;
};
/* I2C device address for pmic max77686 */
#define MAX77686_I2C_ADDR (0x12 >> 1)
enum {
REG_DISABLE = 0,
REG_ENABLE
};
enum {
MAX77686_MV = 0, /* mili volt */
MAX77686_UV /* micro volt */
};
/**
* This function enables the 32KHz coprocessor clock.
*
* @param bus i2c bus
*
* Return 0 if ok, else -1
*/
int max77686_enable_32khz_cp(unsigned int bus);
/**
* Set the required voltage level of pmic
*
* @param bus i2c bus
* @param reg register number of buck/ldo to be set
* @param volt voltage level to be set
* @param enable enable or disable bit
* @param volt_units MAX77686_MV or MAX77686_UV, unit of the
* voltage parameters
*
* @return Return 0 if ok, else -1
*/
int max77686_volsetting(unsigned int bus, enum max77686_regnum reg,
unsigned int volt, int enable, int volt_units);
/**
* Disable charging of the RTC backup battery
*
* @param bus i2c bus
*
* @return Return 0 if ok, else -1
*/
int max77686_disable_backup_batt(unsigned int bus);
#endif /* __MAX77686_PMIC_H_ */
|
/* SPDX-License-Identifier: GPL-2.0-only */
#include <symbols.h>
#include <soc/addressmap.h>
#include <soc/mmu.h>
#include <soc/sdram.h>
#include <arch/mmu.h>
void soc_mmu_init(void)
{
const unsigned long devmem = MA_DEV | MA_S | MA_RW;
const unsigned long secure_mem = MA_MEM | MA_S | MA_RW;
mmu_init();
/*
* Need to use secure mem attribute, as firmware is running in ARM TZ
* region.
*/
mmu_config_range((void *)_ttb, REGION_SIZE(ttb), secure_mem);
mmu_config_range((void *)_dram, sdram_size_mb() * MiB, secure_mem);
/* IO space has the MSB set and is divided into 4 sub-regions:
* * NCB
* * SLI
* * RSL
* * AP
*/
mmu_config_range((void *)IO_SPACE_START, IO_SPACE_SIZE, devmem);
mmu_enable();
}
|
/*
* Seven Kingdoms 2: The Fryhtan War
*
* Copyright 1999 Enlight Software Ltd.
*
* 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/>.
*
*/
// Filename : OSERES.H
// Description : Header file of sound resource
// Onwer : Gilbert
#ifndef __OSERES_H
#define __OSERES_H
// ------------- Define struct SERec -------------//
struct SERec
{
enum { RECNO_LEN=3, CODE_LEN=12, VERB_LEN=4, OUT_FRAME_LEN=3, FILE_NAME_LEN=8};
char subject_type;
char subject_code[CODE_LEN];
char subject_id[RECNO_LEN];
char action[VERB_LEN];
char object_type;
char object_id[RECNO_LEN];
char out_frame[OUT_FRAME_LEN];
char file_name[FILE_NAME_LEN];
};
// ------------- Define struct SEInfo -------------//
struct SEInfo
{
enum { VERB_LEN=4, FILE_NAME_LEN=8 };
char subject_type; // S=sprite, U=unit, R=race, F=firm, T=town
short subject_id;
char action[VERB_LEN+1]; // '\0' padding
char object_type;
short object_id;
short out_frame;
char file_name[FILE_NAME_LEN+1];
short effect_id; // id returned from se_ctrl.scan
int match(char, short, const char *, char, short);
};
// ---------- Define struct SEInfoIndex -------//
struct SEInfoIndex
{
char subject_type;
char dummy;
short subject_id;
int start_rec;
int end_rec;
};
// ---------- Define struct SETypeIndex -------//
struct SETypeIndex
{
char subject_type;
char dummy;
int start_rec;
int end_rec;
};
// ------------- Define class SERes -------------//
class SECtrl;
class SERes
{
public:
int init_flag;
SECtrl* se_output;
int se_array_count;
SEInfo* se_array;
int se_index_count;
SEInfoIndex *se_index_array;
int type_index_count;
SETypeIndex *type_index_array;
static unsigned long last_select_time;
static unsigned long last_command_time;
static unsigned long select_sound_length;
unsigned seed;
public:
SERes();
~SERes();
void init1(); // init before se_ctrl.init
void init2(SECtrl*); // init after se_ctrl.init
void deinit();
SEInfo* scan(char,short, const char *, char,short, int findFirst=0);
short scan_id(char,short, const char *, char,short, int findFirst=0);
SEInfo* operator[] (int);
void sound(short xLoc, short yLoc, short frame, char,short, const char *, char=0,short=0);
void far_sound(short xLoc, short yLoc, short frame, char,short, const char *, char=0,short=0);
static int mark_select_object_time(); // return false if this sound should be skipped due to too frequent
static int mark_command_time(); // return false if this sound should be skipped due to too frequent
private:
void load_info();
void sort_info();
void build_index();
unsigned random(unsigned);
};
extern SERes se_res;
#endif
|
#ifndef __BIOS_H
#define __BIOS_H
#include <features.h>
union REGS
{
struct { unsigned int ax, bx, cx, dx, si, di, cflag, flags; } x;
struct { unsigned char al, ah, bl, bh, cl, ch, dl, dh; } h;
};
struct SREGS
{
unsigned int es, cs, ss, ds;
};
unsigned int __get_cs __P((void));
unsigned int __get_ds __P((void));
unsigned int __get_es __P((void));
void __set_es __P((unsigned int seg));
int __peek_es __P((unsigned int off));
int __deek_es __P((unsigned int off));
#define movedata __movedata
long _bios_get_dpt(drive);
#ifdef __LIBC__
extern int __nofiles();
extern int (*__files)();
#define CMD_OPEN 0
#define CMD_READ 1
#define CMD_WRITE 2
#define CMD_LSEEK 3
#define CMD_CLOSE 4
#endif
#endif
|
#ifndef __CONFIG_H
#define __CONFIG_H
#define AT91_MAIN_CLOCK 6000000 /* 6.000 MHz crystal */
#endif /* __CONFIG_H */
|
/* Copyright (C) 2006, 2007 William McCune
This file is part of the LADR Deduction Library.
The LADR Deduction Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License,
version 2.
The LADR Deduction Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LADR Deduction Library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "clausify.h"
/* Private definitions and types */
/*************
*
* formula_to_literal()
*
*************/
/* DOCUMENTATION
This routine takes a Formula f and returns a Literals representation.
If the formula is not an ATOM_FORM or the negation of an ATOM_FORM,
NULL is returned.
<P>
The returned literal is an entirely new copy,
and the given formula is not changed.
*/
/* PUBLIC */
Literals formula_to_literal(Formula f)
{
if (f->type == NOT_FORM && f->kids[0]->type == ATOM_FORM)
return new_literal(FALSE, copy_term(f->kids[0]->atom));
else if (f->type == ATOM_FORM)
return new_literal(TRUE, copy_term(f->atom));
else
return NULL;
} /* formula_to_literal */
/*************
*
* formula_to_literals()
*
*************/
/* DOCUMENTATION
*/
/* PUBLIC */
Literals formula_to_literals(Formula f)
{
Literals lits = NULL;
if (f->type == ATOM_FORM || f->type == NOT_FORM)
lits = append_literal(lits, formula_to_literal(f));
else if (f->type == OR_FORM) {
int i;
for (i = 0; i < f->arity; i++)
lits = append_literal(lits,formula_to_literal(f->kids[i]));
}
else {
fatal_error("formula_to_literals, formula not ATOM, NOT, or OR");
}
return lits;
} /* formula_to_literals */
/*************
*
* formula_to_clause()
*
*************/
/* DOCUMENTATION
This routine takes a Formula f and returns a Topform representation.
If f is not an atom, literal, or disjunction of literals, the
returned clause will be NULL or not well formed.
<P>
The returned clause is an entirely new copy, and the given formula
is not changed.
*/
/* PUBLIC */
Topform formula_to_clause(Formula f)
{
Topform c = get_topform();
c->literals = formula_to_literals(f);
upward_clause_links(c);
return c;
} /* formula_to_clause */
/*************
*
* formula_to_clauses()
*
*************/
/* DOCUMENTATION
This routine takes a Formula f and returns a Plist of clauses
representation.
If f is not an atom, literal, or disjunction of literals, or a
conjunction of those things, the clauses in the returned list may be NULL
or not well formed.
<P>
The returned clauses are entirely new copies, and the given formula
is not changed.
*/
/* PUBLIC */
Plist formula_to_clauses(Formula f)
{
Plist lst = NULL;
if (f->type == AND_FORM) {
int i;
for (i = 0; i < f->arity; i++)
lst = plist_append(lst, formula_to_clause(f->kids[i]));
}
else if (f->type == OR_FORM || f->type == NOT_FORM || f->type == ATOM_FORM)
lst = plist_append(lst, formula_to_clause(f));
return lst;
} /* formula_to_clauses */
/*************
*
* clausify_formula()
*
*************/
/* DOCUMENTATION
This routine translates a Formula f into a Plist of clauses.
The translation includes Skolemization, so the result should
be unsatisfiable iff f is unsatisfiable. The variables in
each clause are renumbered. If there are more than MAX_VARS
variables in a clause, a fatal error occurs.
<P>
Formula f is not changed.
*/
/* PUBLIC */
Plist clausify_formula(Formula f)
{
Formula g;
Plist clauses, p;
g = clausify_prepare(formula_copy(f));
clauses = formula_to_clauses(g);
for (p = clauses; p; p = p->next) {
Topform c = p->v;
renumber_variables(c, MAX_VARS);
}
zap_formula(g);
return clauses;
} /* clausify_formula */
/*************
*
* vars_to_names()
*
*************/
static
Term vars_to_names(Term t)
{
if (VARIABLE(t)) {
Term a;
char *s1 = malloc(25);
char *s2 = malloc(25);
Variable_style v = variable_style();
s2 = int_to_str(VARNUM(t), s2, 25);
switch (v) {
case INTEGER_STYLE: s1 = strcpy(s1, ""); break;
case STANDARD_STYLE: s1 = strcpy(s1, "var_"); break;
case PROLOG_STYLE: s1 = strcpy(s1, "VAR_"); break;
}
s1 = strcat(s1, s2);
a = get_rigid_term(s1, 0);
free_term(t);
free(s1);
free(s2);
return a;
}
else {
int i;
for (i = 0; i < ARITY(t); i++)
ARG(t,i) = vars_to_names(ARG(t,i));
return t;
}
} /* vars_to_names */
/*************
*
* literal_to_formula()
*
*************/
static
Formula literal_to_formula(Literals lit)
{
Formula a = formula_get(0, ATOM_FORM);
a->atom = vars_to_names(copy_term(lit->atom));
if (lit->sign)
return a;
else {
Formula n = formula_get(1, NOT_FORM);
n->kids[0] = a;
return n;
}
} /* literal_to_formula */
/*************
*
* clause_to_formula()
*
*************/
/* DOCUMENTATION
Return an entirely new formula.
*/
/* PUBLIC */
Formula clause_to_formula(Topform c)
{
if (c->literals == NULL) {
Formula f = formula_get(0, ATOM_FORM);
f->atom = get_rigid_term(false_sym(), 0);
return f;
}
else {
Literals lit;
int i;
Formula f = formula_get(number_of_literals(c->literals), OR_FORM);
for (lit = c->literals, i = 0; lit; lit = lit->next, i++) {
f->kids[i] = literal_to_formula(lit);
}
return f;
}
} /* clause_to_formula */
|
/* { dg-do compile } */
/* { dg-require-effective-target power10_ok } */
/* { dg-options "-Wno-psabi -mdejagnu-cpu=power10 -O2" } */
typedef unsigned char vec_t __attribute__((vector_size(16)));
void
foo (__vector_quad *dst, vec_t *src)
{
__vector_quad acc;
__builtin_mma_assemble_acc (&acc, src[0], src[4], src[8], src[12]);
*dst = acc;
}
void
bar (vec_t *dst, __vector_quad *src)
{
vec_t res[4];
__builtin_mma_disassemble_acc (res, src);
dst[0] = res[0];
dst[4] = res[1];
dst[8] = res[2];
dst[12] = res[3];
}
/* { dg-final { scan-assembler-times {\mlxv\M} 4 } } */
/* { dg-final { scan-assembler-times {\mlxvp\M} 2 } } */
/* { dg-final { scan-assembler-times {\mstxv\M} 4 } } */
/* { dg-final { scan-assembler-times {\mstxvp\M} 2 } } */
/* { dg-final { scan-assembler-times {\mxxmfacc\M} 2 } } */
/* { dg-final { scan-assembler-times {\mxxmtacc\M} 2 } } */
|
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef SOUTHBRIDGE_VIA_K8T890_K8T890_H
#define SOUTHBRIDGE_VIA_K8T890_K8T890_H
/* Static resources for K8T890. */
#define K8T890_APIC_ID 0x3
/*
* Please check the datasheet and traf_ctrl_enable before change!
* It can't be changed to an arbitrary address.
*/
#define K8T890_APIC_BASE 0xfecc0000
/* The 256 bytes of NVRAM for S3 storage, 256B aligned */
#define K8T890_NVRAM_IO_BASE 0xf00
#define K8T890_NVRAM_TOP_OF_RAM 0xfc
#define K8T890_MMCONFIG_MBAR 0x61
#define K8T890_MULTIPLE_FN_EN 0x4f
/* the FB size in MB (min is 8MB max is 512MB) */
#define K8M890_FBSIZEMB 64
#ifdef __PRE_RAM__
u8 k8t890_early_setup_ht(void);
int s3_save_nvram_early(u32 dword, int size, int nvram_pos);
int s3_load_nvram_early(int size, u32 *old_dword, int nvram_pos);
#define k8x8xx_early_setup_ht() k8t890_early_setup_ht()
#else
#include <device/device.h>
#if 0
extern void writeback(struct device *dev, u16 where, u8 what);
extern void dump_south(device_t dev);
#endif
#endif
#include <southbridge/via/vt8237r/vt8237r.h>
int k8m890_host_fb_size_get(void);
//void k8m890_host_fb_direct_set(uint32_t fb_address);
#endif
|
/*
* Copyright (c) 2009 Atheros Communications Inc.
* All rights reserved.
*
*
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
//
*
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <a_config.h>
#include <a_osapi.h>
#include "a_types.h"
#include "a_hci.h"
#include "pal_api.h"
#include "paldebug.h"
#include "pal_util.h"
typedef struct event_code_tbl_t {
A_UINT8 event_code;
A_UINT8 *evt_name;
}EVENT_CODE_TBL;
#define N(a) (sizeof(a) / sizeof(a[0]))
EVENT_CODE_TBL evt_tbl[] = {
{PAL_COMMAND_COMPLETE_EVENT, (A_UINT8 *)"COMMAND_COMPLETE_EVENT"},
{PAL_COMMAND_STATUS_EVENT, (A_UINT8 *)"COMMAND_STATUS_EVENT"},
{PAL_HARDWARE_ERROR_EVENT, (A_UINT8 *)"HARDWARE_ERROR_EVENT"},
{PAL_FLUSH_OCCURRED_EVENT, (A_UINT8 *)"FLUSH_OCCURRED_EVENT"},
{PAL_LOOPBACK_EVENT, (A_UINT8 *)"LOOPBACK_EVENT"},
{PAL_BUFFER_OVERFLOW_EVENT, (A_UINT8 *)"BUFFER_OVERFLOW_EVENT"},
{PAL_QOS_VIOLATION_EVENT, (A_UINT8 *)"QOS_VIOLATION_EVENT"},
{PAL_CHANNEL_SELECT_EVENT, (A_UINT8 *)"CHANNEL_SELECT_EVENT"},
{PAL_PHYSICAL_LINK_COMPL_EVENT, (A_UINT8 *)"PAL_PHYSICAL_LINK_COMPL_EVENT"},
{PAL_LOGICAL_LINK_COMPL_EVENT, (A_UINT8 *)"PAL_LOGICAL_LINK_COMPL_EVENT"},
{PAL_DISCONNECT_LOGICAL_LINK_COMPL_EVENT, (A_UINT8 *)"PAL_DISCONNECT_LOGICAL_LINK_COMPL_EVENT"},
{PAL_DISCONNECT_PHYSICAL_LINK_EVENT, (A_UINT8 *)"DISCONNECT_PHYSICAL_LINK_EVENT"},
{PAL_FLOW_SPEC_MODIFY_COMPL_EVENT, (A_UINT8 *)"FLOW_SPEC_MODIFY_COMPL_EVENT"},
{PAL_NUM_COMPL_DATA_BLOCK_EVENT, (A_UINT8 *)"NUM_COMPL_DATA_BLOCK_EVENT"},
{PAL_SHORT_RANGE_MODE_CHANGE_COMPL_EVENT, (A_UINT8 *)"PAL_SHORT_RANGE_MODE_CHANGE_COMPL_EVENT"},
};
void
pal_decode_event(A_UINT8 *buf, A_UINT16 sz)
{
A_UINT8 i;
for(i = 0; i < (N(evt_tbl) - 1); i++) {
if(evt_tbl[i].event_code == ((HCI_EVENT_PKT *)buf)->event_code)
break;
}
PAL_PRINT("PAL Send event -> %s\n", evt_tbl[i].evt_name);
dump_frame(buf, sz);
}
void
dump_frame(A_UINT8 *frm, A_UINT32 len)
{
unsigned int i;
PAL_PRINT("\n----------------------------------------------\n");
for(i = 0; i < len; i++) {
PAL_PRINT("0x%02x ", frm[i]);
if((i+1) % 16 == 0)
PAL_PRINT("\n");
}
PAL_PRINT("\n===============================================\n\n");
}
A_UINT32 log_param=0;
FILE *fp = 0;
void PRINTF(char *format,...)
{
char buffer[2000]; /* Output Buffer */
int len;
va_list args;
if(!log_param)
return;
va_start(args, format);
len = vsnprintf(buffer, sizeof(buffer), format, args);
va_end(args);
if (log_param & 0x1) {
fwrite(buffer, sizeof(char), strlen(buffer), fp);
fflush(fp);
}
if(log_param & 0x2) {
printf("%s",buffer);
}
}
void
pal_log_cfg(void * dev, A_UINT32 log_cfg)
{
log_param = log_cfg;
if(log_cfg & 0x1) {
if ((fp = fopen("pal.log", "a")) == NULL) {
printf("CAN NOT OPEN file\n");
exit (1);
}
}
}
|
/** @file
* VirtualBox - Global Guest Operating System definition.
*/
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_ostypes_h
#define ___VBox_ostypes_h
#include <iprt/cdefs.h>
RT_C_DECLS_BEGIN
/**
* Global list of guest operating system types.
*
* They are grouped into families. A family identifer is always has
* mod 0x10000 == 0. New entries can be added, however other components
* depend on the values (e.g. the Qt GUI and guest additions) so the
* existing values MUST stay the same.
*
* Note: distinguish between 32 & 64 bits guest OSes by checking bit 8 (mod 0x100)
*/
typedef enum VBOXOSTYPE
{
VBOXOSTYPE_Unknown = 0,
VBOXOSTYPE_DOS = 0x10000,
VBOXOSTYPE_Win31 = 0x15000,
VBOXOSTYPE_Win9x = 0x20000,
VBOXOSTYPE_Win95 = 0x21000,
VBOXOSTYPE_Win98 = 0x22000,
VBOXOSTYPE_WinMe = 0x23000,
VBOXOSTYPE_WinNT = 0x30000,
VBOXOSTYPE_WinNT4 = 0x31000,
VBOXOSTYPE_Win2k = 0x32000,
VBOXOSTYPE_WinXP = 0x33000,
VBOXOSTYPE_WinXP_x64 = 0x33100,
VBOXOSTYPE_Win2k3 = 0x34000,
VBOXOSTYPE_Win2k3_x64 = 0x34100,
VBOXOSTYPE_WinVista = 0x35000,
VBOXOSTYPE_WinVista_x64 = 0x35100,
VBOXOSTYPE_Win2k8 = 0x36000,
VBOXOSTYPE_Win2k8_x64 = 0x36100,
VBOXOSTYPE_Win7 = 0x37000,
VBOXOSTYPE_Win7_x64 = 0x37100,
VBOXOSTYPE_Win8 = 0x38000,
VBOXOSTYPE_Win8_x64 = 0x38100,
VBOXOSTYPE_OS2 = 0x40000,
VBOXOSTYPE_OS2Warp3 = 0x41000,
VBOXOSTYPE_OS2Warp4 = 0x42000,
VBOXOSTYPE_OS2Warp45 = 0x43000,
VBOXOSTYPE_ECS = 0x44000,
VBOXOSTYPE_Linux = 0x50000,
VBOXOSTYPE_Linux_x64 = 0x50100,
VBOXOSTYPE_Linux22 = 0x51000,
VBOXOSTYPE_Linux24 = 0x52000,
VBOXOSTYPE_Linux24_x64 = 0x52100,
VBOXOSTYPE_Linux26 = 0x53000,
VBOXOSTYPE_Linux26_x64 = 0x53100,
VBOXOSTYPE_ArchLinux = 0x54000,
VBOXOSTYPE_ArchLinux_x64 = 0x54100,
VBOXOSTYPE_Debian = 0x55000,
VBOXOSTYPE_Debian_x64 = 0x55100,
VBOXOSTYPE_OpenSUSE = 0x56000,
VBOXOSTYPE_OpenSUSE_x64 = 0x56100,
VBOXOSTYPE_FedoraCore = 0x57000,
VBOXOSTYPE_FedoraCore_x64 = 0x57100,
VBOXOSTYPE_Gentoo = 0x58000,
VBOXOSTYPE_Gentoo_x64 = 0x58100,
VBOXOSTYPE_Mandriva = 0x59000,
VBOXOSTYPE_Mandriva_x64 = 0x59100,
VBOXOSTYPE_RedHat = 0x5A000,
VBOXOSTYPE_RedHat_x64 = 0x5A100,
VBOXOSTYPE_Turbolinux = 0x5B000,
VBOXOSTYPE_Turbolinux_x64 = 0x5B100,
VBOXOSTYPE_Ubuntu = 0x5C000,
VBOXOSTYPE_Ubuntu_x64 = 0x5C100,
VBOXOSTYPE_Xandros = 0x5D000,
VBOXOSTYPE_Xandros_x64 = 0x5D100,
VBOXOSTYPE_Oracle = 0x5E000,
VBOXOSTYPE_Oracle_x64 = 0x5E100,
VBOXOSTYPE_FreeBSD = 0x60000,
VBOXOSTYPE_FreeBSD_x64 = 0x60100,
VBOXOSTYPE_OpenBSD = 0x61000,
VBOXOSTYPE_OpenBSD_x64 = 0x61100,
VBOXOSTYPE_NetBSD = 0x62000,
VBOXOSTYPE_NetBSD_x64 = 0x62100,
VBOXOSTYPE_Netware = 0x70000,
VBOXOSTYPE_Solaris = 0x80000,
VBOXOSTYPE_Solaris_x64 = 0x80100,
VBOXOSTYPE_OpenSolaris = 0x81000,
VBOXOSTYPE_OpenSolaris_x64 = 0x81100,
VBOXOSTYPE_Solaris11_x64 = 0x82100,
VBOXOSTYPE_L4 = 0x90000,
VBOXOSTYPE_QNX = 0xA0000,
VBOXOSTYPE_MacOS = 0xB0000,
VBOXOSTYPE_MacOS_x64 = 0xB0100,
VBOXOSTYPE_JRockitVE = 0xC0000,
/** The bit number which indicates 64-bit or 32-bit. */
#define VBOXOSTYPE_x64_BIT 8
/** The mask which indicates 64-bit. */
VBOXOSTYPE_x64 = 1 << VBOXOSTYPE_x64_BIT,
/** The usual 32-bit hack. */
VBOXOSTYPE_32BIT_HACK = 0x7fffffff
} VBOXOSTYPE;
/**
* Global list of guest OS families.
*/
typedef enum VBOXOSFAMILY
{
VBOXOSFAMILY_Unknown = 0,
VBOXOSFAMILY_Windows32 = 1,
VBOXOSFAMILY_Windows64 = 2,
VBOXOSFAMILY_Linux32 = 3,
VBOXOSFAMILY_Linux64 = 4,
VBOXOSFAMILY_FreeBSD32 = 5,
VBOXOSFAMILY_FreeBSD64 = 6,
VBOXOSFAMILY_Solaris32 = 7,
VBOXOSFAMILY_Solaris64 = 8,
VBOXOSFAMILY_MacOSX32 = 9,
VBOXOSFAMILY_MacOSX64 = 10,
/** The usual 32-bit hack. */
VBOXOSFAMILY_32BIT_HACK = 0x7fffffff
} VBOXOSFAMILY;
RT_C_DECLS_END
#endif
|
#ifndef __LINUX_CMA_H
#define __LINUX_CMA_H
/*
* Contiguous Memory Allocator for DMA mapping framework
* Copyright (c) 2010-2011 by Samsung Electronics.
* Written by:
* Marek Szyprowski <m.szyprowski@samsung.com>
* Michal Nazarewicz <mina86@mina86.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 optional) any later version of the license.
*/
/*
*/
#ifdef __KERNEL__
struct cma;
struct page;
struct device;
#ifdef CONFIG_CMA
/*
*/
#define MAX_CMA_AREAS (1 + CONFIG_CMA_AREAS)
extern struct cma *dma_contiguous_default_area;
void dma_contiguous_reserve(phys_addr_t addr_limit);
int dma_declare_contiguous(struct device *dev, unsigned long size,
phys_addr_t base, phys_addr_t limit);
struct page *dma_alloc_from_contiguous(struct device *dev, int count,
unsigned int order);
bool dma_release_from_contiguous(struct device *dev, struct page *pages,
int count);
#else
#define MAX_CMA_AREAS (0)
static inline void dma_contiguous_reserve(phys_addr_t limit) { }
static inline
int dma_declare_contiguous(struct device *dev, unsigned long size,
phys_addr_t base, phys_addr_t limit)
{
return -ENOSYS;
}
static inline
struct page *dma_alloc_from_contiguous(struct device *dev, int count,
unsigned int order)
{
return NULL;
}
static inline
bool dma_release_from_contiguous(struct device *dev, struct page *pages,
int count)
{
return false;
}
#endif
#endif
#endif
|
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <vector>
#include "Common/CommonTypes.h"
#include "VideoBackends/Software/NativeVertexFormat.h"
#include "VideoBackends/Software/SetupUnit.h"
#include "VideoCommon/VertexManagerBase.h"
class SWVertexLoader : public VertexManagerBase
{
public:
SWVertexLoader();
~SWVertexLoader();
NativeVertexFormat* CreateNativeVertexFormat(const PortableVertexDeclaration& vdec) override;
protected:
void ResetBuffer(u32 stride) override;
u16* GetIndexBuffer() { return &LocalIBuffer[0]; }
private:
void vFlush(bool useDstAlpha) override;
std::vector<u8> LocalVBuffer;
std::vector<u16> LocalIBuffer;
InputVertexData m_Vertex;
void ParseVertex(const PortableVertexDeclaration& vdec, int index);
SetupUnit m_SetupUnit;
bool m_TexGenSpecialCase;
public:
void SetFormat(u8 attributeIndex, u8 primitiveType);
};
|
/*
* This file is part of Cleanflight.
*
* Cleanflight is 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 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 software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdbool.h"
#include "stdint.h"
#include "platform.h"
#include "build_config.h"
#ifdef USE_CLI_DEBUG_PRINT
#warning Do not use USE_CLI_DEBUG_PRINT for production builds.
#endif
mcuTypeId_e getMcuTypeId(void)
{
#if defined(SIMULATOR_BUILD)
return MCU_TYPE_SIMULATOR;
#elif defined(STM32F1)
return MCU_TYPE_F103;
#elif defined(STM32F3)
return MCU_TYPE_F303;
#elif defined(STM32F40_41xxx)
return MCU_TYPE_F40X;
#elif defined(STM32F411xE)
return MCU_TYPE_F411;
#elif defined(STM32F446xx)
return MCU_TYPE_F446;
#elif defined(STM32F722xx)
return MCU_TYPE_F722;
#elif defined(STM32F745xx)
return MCU_TYPE_F745;
#elif defined(STM32F746xx)
return MCU_TYPE_F746;
#elif defined(STM32F765xx)
return MCU_TYPE_F765;
#elif defined(STM32H750xx)
return MCU_TYPE_H750;
#elif defined(STM32H743xx)
switch (HAL_GetREVID()) {
case REV_ID_Y:
return MCU_TYPE_H743_REV_Y;
case REV_ID_X:
return MCU_TYPE_H743_REV_X;
case REV_ID_V:
return MCU_TYPE_H743_REV_V;
default:
return MCU_TYPE_H743_REV_UNKNOWN;
}
#else
return MCU_TYPE_UNKNOWN;
#endif
}
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CALAMARES_PYTHONJOB_H
#define CALAMARES_PYTHONJOB_H
#include "Job.h"
#include <QVariant>
namespace CalamaresPython
{
class PythonJobInterface;
class Helper;
}
namespace Calamares {
class PythonJob : public Job
{
Q_OBJECT
public:
explicit PythonJob( const QString& scriptFile,
const QString& workingPath,
const QVariantMap& moduleConfiguration = QVariantMap(),
QObject* parent = nullptr );
virtual ~PythonJob();
QString prettyName() const override;
JobResult exec() override;
private:
friend class CalamaresPython::Helper;
friend class CalamaresPython::PythonJobInterface;
void emitProgress( double progressValue );
CalamaresPython::Helper* helper();
QString m_scriptFile;
QString m_workingPath;
QVariantMap m_configurationMap;
};
} // namespace Calamares
#endif // CALAMARES_PYTHONJOB_H
|
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
#include "liburi.h"
void lib_clean_uri(struct uri *p)
{
if (p->params)
free(p->params);
memset(p, 0, sizeof(*p));
}
const char *lib_uri_param(struct uri *p, const char *key)
{
int j;
for (j = 0; j < p->nparams; j += 2) {
if (!strcmp(p->params[j], key))
/* return value, or empty non-null string */
return p->params[j+1] ?: "";
}
return NULL;
}
void lib_parse_uri(const char *uri, struct uri *p)
{
static char *copy;
static char *hoststr;
char *str, *tmp;
memset(p, 0, sizeof(*p));
if (copy)
free(copy);
copy = strdup(uri ?: "");
uri = copy;
str = strstr(uri, "://");
if (str) {
/* save proto */
*str = 0;
p->scheme = uri;
uri = str+3;
}
str = strchr(uri, '?');
if (str) {
/* save params */
*str++ = 0;
for (str = strtok(str, "&"); str; str = strtok(NULL, "&")) {
if (p->nparams +2 > p->sparams) {
p->sparams += 16;
p->params = realloc(p->params, sizeof(void *)*p->sparams);
#if 0
if (!p->params)
mylog(LOG_ERR, "realloc %u params: %s",
p->sparams, ESTR(errno));
#endif
}
p->params[p->nparams++] = str;
str = strchr(str, '=');
if (str)
*str++ = 0;
p->params[p->nparams++] = str;
}
}
str = strchr(uri, '#');
if (str) {
/* save fragment */
*str++ = 0;
p->fragment = str;
}
if (*uri == '@' || *uri == '/')
goto unix_sock;
str = strchr(uri, '@');
if (str) {
*str++ = 0;
tmp = strchr(uri, ':');
if (tmp)
*tmp++ = 0;
p->user = uri;
p->pass = tmp;
uri = str;
}
if (*uri == '[') {
/* ipv6 numerical */
p->host = uri+1;
str = strchr(uri+1, ']');
if (str) {
*str = 0;
uri = str+1;
str = strpbrk(uri, ":/?");
} else
/* not good ... but return */
goto done;
}
str = strpbrk(uri, ":/");
if (!str) {
if (*uri)
p->host = uri;
goto done;
}
if (*str == ':') {
if (!strchr(str+1, '/') && strchr(str+1, ':')) {
/* multiple ::, no /, suspect ipv6 hostname */
if (*uri)
p->host = uri;
goto done;
}
*str = 0;
if (str > uri)
/* save host */
p->host = uri;
uri = str+1;
p->port = strtoul(uri, &str, 10);
if (str > uri && (!*str || *str == '/'))
/* looks like a IP port identifier */
uri = str;
else if (str > uri && *str == ':')
/* looks like a IP port identifier */
uri = str+1;
else
p->port = 0;
} else if (str > uri) {
/* duplicate host, without loosing the seperating / */
if (hoststr)
free(hoststr);
hoststr = strndup(uri, str-uri);
p->host = hoststr;
uri = str;
}
unix_sock:
if (*uri)
/* save path */
p->path = uri;
done:
str = strpbrk(uri, ":/");
return;
}
|
/*
Unix SMB/CIFS implementation.
Generic Authentication Interface
Copyright (C) Andrew Tridgell 2003
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2006
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "auth/gensec/gensec.h"
#include "auth/gensec/gensec_internal.h"
#include "auth/common_auth.h"
#include "../lib/util/asn1.h"
NTSTATUS gensec_generate_session_info_pac(TALLOC_CTX *mem_ctx,
struct gensec_security *gensec_security,
struct smb_krb5_context *smb_krb5_context,
DATA_BLOB *pac_blob,
const char *principal_string,
const struct tsocket_address *remote_address,
struct auth_session_info **session_info)
{
uint32_t session_info_flags = 0;
if (gensec_security->want_features & GENSEC_FEATURE_UNIX_TOKEN) {
session_info_flags |= AUTH_SESSION_INFO_UNIX_TOKEN;
}
session_info_flags |= AUTH_SESSION_INFO_DEFAULT_GROUPS;
if (!pac_blob) {
if (gensec_setting_bool(gensec_security->settings, "gensec", "require_pac", false)) {
DEBUG(1, ("Unable to find PAC in ticket from %s, failing to allow access\n",
principal_string));
return NT_STATUS_ACCESS_DENIED;
}
DEBUG(1, ("Unable to find PAC for %s, resorting to local user lookup\n",
principal_string));
}
if (gensec_security->auth_context && gensec_security->auth_context->generate_session_info_pac) {
return gensec_security->auth_context->generate_session_info_pac(gensec_security->auth_context,
mem_ctx,
smb_krb5_context,
pac_blob,
principal_string,
remote_address,
session_info_flags,
session_info);
} else {
DEBUG(0, ("Cannot generate a session_info without the auth_context\n"));
return NT_STATUS_INTERNAL_ERROR;
}
}
/*
magic check a GSS-API wrapper packet for an Kerberos OID
*/
static bool gensec_gssapi_check_oid(const DATA_BLOB *blob, const char *oid)
{
bool ret = false;
struct asn1_data *data = asn1_init(NULL);
if (!data) return false;
if (!asn1_load(data, *blob)) goto err;
if (!asn1_start_tag(data, ASN1_APPLICATION(0))) goto err;
if (!asn1_check_OID(data, oid)) goto err;
ret = !asn1_has_error(data);
err:
asn1_free(data);
return ret;
}
/**
* Check if the packet is one for the KRB5 mechansim
*
* NOTE: This is a helper that can be employed by multiple mechanisms, do
* not make assumptions about the private_data
*
* @param gensec_security GENSEC state, unused
* @param in The request, as a DATA_BLOB
* @return Error, INVALID_PARAMETER if it's not a packet for us
* or NT_STATUS_OK if the packet is ok.
*/
NTSTATUS gensec_magic_check_krb5_oid(struct gensec_security *unused,
const DATA_BLOB *blob)
{
if (gensec_gssapi_check_oid(blob, GENSEC_OID_KERBEROS5)) {
return NT_STATUS_OK;
} else {
return NT_STATUS_INVALID_PARAMETER;
}
}
|
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 1.1 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* 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(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$Id: get_myaddress.c,v 1.4 2002/02/19 20:36:23 epeyton Exp $";
#endif
/*
* get_myaddress.c
*
* Get client's IP address via ioctl. This avoids using the yellowpages.
* Copyright (C) 1984, Sun Microsystems, Inc.
*
* Re-worked for 4.4BSD by Marc Majka at Apple.
*/
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
#include <sys/socket.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int
get_myaddress(struct sockaddr_in *addr)
{
struct ifconf ifc;
struct ifreq *ifr;
char buf[BUFSIZ];
int offset, x, addrlen, s;
bzero(addr, sizeof(struct sockaddr_in));
addr->sin_family = AF_INET;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
{
addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
return 0;
}
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0)
{
addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
close(s);
return 0;
}
addrlen = sizeof(struct ifreq) - IFNAMSIZ;
offset = 0;
while (offset <= ifc.ifc_len)
{
ifr = (struct ifreq *)(ifc.ifc_buf + offset);
offset += IFNAMSIZ;
if (ifr->ifr_addr.sa_len > addrlen) offset += ifr->ifr_addr.sa_len;
else offset += addrlen;
if (ifr->ifr_addr.sa_family != AF_INET) continue;
if (ioctl(s, SIOCGIFFLAGS, ifr) < 0) continue;
x = ((struct sockaddr_in *)&(ifr->ifr_addr))->sin_addr.s_addr;
if
(
(ifr->ifr_flags & IFF_UP) &&
(!(ifr->ifr_flags & IFF_LOOPBACK)) &&
(x != 0) &&
(x != -1)
)
{
addr->sin_addr.s_addr = x;
close(s);
return 0;
}
}
close(s);
addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
return 0;
}
|
/*
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely.
*/
/* Program to load a wave file and loop playing it using SDL audio */
/* loopwaves.c is much more robust in handling WAVE files --
This is only for simple WAVEs
*/
#include "SDL_config.h"
#include <stdio.h>
#include <stdlib.h>
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#endif
#include "SDL.h"
static struct
{
SDL_AudioSpec spec;
Uint8 *sound; /* Pointer to wave data */
Uint32 soundlen; /* Length of wave data */
int soundpos; /* Current play position */
} wave;
static SDL_AudioDeviceID device;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
quit(int rc)
{
SDL_Quit();
exit(rc);
}
static void
close_audio()
{
if (device != 0) {
SDL_CloseAudioDevice(device);
device = 0;
}
}
static void
open_audio()
{
/* Initialize fillerup() variables */
device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0);
if (!device) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
SDL_FreeWAV(wave.sound);
quit(2);
}
/* Let the audio run */
SDL_PauseAudioDevice(device, SDL_FALSE);
}
static void reopen_audio()
{
close_audio();
open_audio();
}
void SDLCALL
fillerup(void *unused, Uint8 * stream, int len)
{
Uint8 *waveptr;
int waveleft;
/* Set up the pointers */
waveptr = wave.sound + wave.soundpos;
waveleft = wave.soundlen - wave.soundpos;
/* Go! */
while (waveleft <= len) {
SDL_memcpy(stream, waveptr, waveleft);
stream += waveleft;
len -= waveleft;
waveptr = wave.sound;
waveleft = wave.soundlen;
wave.soundpos = 0;
}
SDL_memcpy(stream, waveptr, len);
wave.soundpos += len;
}
static int done = 0;
void
poked(int sig)
{
done = 1;
}
#ifdef __EMSCRIPTEN__
void
loop()
{
if(done || (SDL_GetAudioDeviceStatus(device) != SDL_AUDIO_PLAYING))
emscripten_cancel_main_loop();
}
#endif
int
main(int argc, char *argv[])
{
int i;
char filename[4096];
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_EVENTS) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
if (argc > 1) {
SDL_strlcpy(filename, argv[1], sizeof(filename));
} else {
SDL_strlcpy(filename, "sample.wav", sizeof(filename));
}
/* Load the wave file into memory */
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
quit(1);
}
wave.spec.callback = fillerup;
/* Show the list of available drivers */
SDL_Log("Available audio drivers:");
for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
}
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
open_audio();
SDL_FlushEvents(SDL_AUDIODEVICEADDED, SDL_AUDIODEVICEREMOVED);
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done) {
SDL_Event event;
while (SDL_PollEvent(&event) > 0) {
if (event.type == SDL_QUIT) {
done = 1;
}
if ((event.type == SDL_AUDIODEVICEADDED && !event.adevice.iscapture) ||
(event.type == SDL_AUDIODEVICEREMOVED && !event.adevice.iscapture && event.adevice.which == device)) {
reopen_audio();
}
}
SDL_Delay(100);
}
#endif
/* Clean up on signal */
close_audio();
SDL_FreeWAV(wave.sound);
SDL_Quit();
return (0);
}
/* vi: set ts=4 sw=4 expandtab: */
|
/*
* This file is part of APRIL-ANN toolkit (A
* Pattern Recognizer In Lua with Artificial Neural Networks).
*
* Copyright 2012, Salvador España-Boquera, Adrian Palacios Corella, Francisco
* Zamora-Martinez
*
* The APRIL-ANN toolkit is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef MATHCORE_H
#define MATHCORE_H
#include <cstdio>
#ifdef USE_CUDA
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <cublas_v2.h>
#include <cusparse_v2.h>
#include "cublas_error.h"
#include "cusparse_error.h"
#endif
#include "cblas_headers.h"
#include "lapack_headers.h"
#include "cublas_error.h"
#include "cusparse_error.h"
#include "cuda_utils.h"
#include "gpu_helper.h"
#include "gpu_mirrored_memory_block.h"
/**
* @brief The namespace AprilMath contains operations over different scalar types by
* using templatized functions and C++ functors.
*
* - **Reduce operations**: they are defined over vector spans, taking two
* functors which allow the reduce computation. The first functor computes the
* reduce from the input typename into the output typename. The second functor
* allows to reduce output typename scalars and is needed because it is possible
* to need intermediate partial results in the output space before the reduction
* is computed:
* - AprilMath::genericReduce1Call
* - AprilMath::genericReduce2Call
* - AprilMath::genericReduceMinMAxCall
*
* - **Map operations**: they are defined over vector spans, taking a functor
* which implement the map operation over a vector span.
* - AprilMath::genericMap1Call
* - AprilMath::genericMap2Call
*
* Previous functions take mathematicals functors like ones declared in
* AprilMath::Functors namespace. For simplicity, some of this functors has a
* function which allows to call @c operator() without an explicit instantiation
* of the functor object. This functions are in AprilMath namespace under the
* same name as their equivalent AprilMath::Functors object declaration.
*
* @note All of this operations are exported to CUDA and can be used safely in
* functions implemented to run in GPU device or CPU host.
*
* @note Some of the math operations defined in AprilMath has a curried version
* that allow to call the function with a fixed parameter.
*/
namespace AprilMath {
//////////////////////////////////////////////////////////////////////
int doSearchCSCSparseIndexOf(const Int32GPUMirroredMemoryBlock *indices,
const Int32GPUMirroredMemoryBlock *first_index,
const int c1, const int c2, bool use_gpu);
int doSearchCSRSparseIndexOf(const Int32GPUMirroredMemoryBlock *indices,
const Int32GPUMirroredMemoryBlock *first_index,
const int c1, const int c2, bool use_gpu);
int doSearchCSCSparseIndexOfFirst(const Int32GPUMirroredMemoryBlock *indices,
const Int32GPUMirroredMemoryBlock *first_index,
const int c1, const int c2, bool use_gpu);
int doSearchCSRSparseIndexOfFirst(const Int32GPUMirroredMemoryBlock *indices,
const Int32GPUMirroredMemoryBlock *first_index,
const int c1, const int c2, bool use_gpu);
}
#endif // MATHCORE_H
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.