text stringlengths 4 6.14k |
|---|
/*
* 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
*/
#ifndef AVCODEC_ALPHA_HPELDSP_ALPHA_H
#define AVCODEC_ALPHA_HPELDSP_ALPHA_H
#include <stdint.h>
#include <stddef.h>
void put_pixels_axp_asm(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h);
#endif /* AVCODEC_ALPHA_HPELDSP_ALPHA_H */
|
/*
* Support for Intel Camera Imaging ISP subsystem.
* Copyright (c) 2015, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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 __IA_CSS_STREAM_FORMAT_H
#define __IA_CSS_STREAM_FORMAT_H
/** @file
* This file contains formats usable for ISP streaming input
*/
#include <type_support.h> /* bool */
/** The ISP streaming input interface supports the following formats.
* These match the corresponding MIPI formats.
*/
enum ia_css_stream_format {
IA_CSS_STREAM_FORMAT_YUV420_8_LEGACY, /**< 8 bits per subpixel */
IA_CSS_STREAM_FORMAT_YUV420_8, /**< 8 bits per subpixel */
IA_CSS_STREAM_FORMAT_YUV420_10, /**< 10 bits per subpixel */
IA_CSS_STREAM_FORMAT_YUV420_16, /**< 16 bits per subpixel */
IA_CSS_STREAM_FORMAT_YUV422_8, /**< UYVY..UYVY, 8 bits per subpixel */
IA_CSS_STREAM_FORMAT_YUV422_10, /**< UYVY..UYVY, 10 bits per subpixel */
IA_CSS_STREAM_FORMAT_YUV422_16, /**< UYVY..UYVY, 16 bits per subpixel */
IA_CSS_STREAM_FORMAT_RGB_444, /**< BGR..BGR, 4 bits per subpixel */
IA_CSS_STREAM_FORMAT_RGB_555, /**< BGR..BGR, 5 bits per subpixel */
IA_CSS_STREAM_FORMAT_RGB_565, /**< BGR..BGR, 5 bits B and R, 6 bits G */
IA_CSS_STREAM_FORMAT_RGB_666, /**< BGR..BGR, 6 bits per subpixel */
IA_CSS_STREAM_FORMAT_RGB_888, /**< BGR..BGR, 8 bits per subpixel */
IA_CSS_STREAM_FORMAT_RAW_6, /**< RAW data, 6 bits per pixel */
IA_CSS_STREAM_FORMAT_RAW_7, /**< RAW data, 7 bits per pixel */
IA_CSS_STREAM_FORMAT_RAW_8, /**< RAW data, 8 bits per pixel */
IA_CSS_STREAM_FORMAT_RAW_10, /**< RAW data, 10 bits per pixel */
IA_CSS_STREAM_FORMAT_RAW_12, /**< RAW data, 12 bits per pixel */
IA_CSS_STREAM_FORMAT_RAW_14, /**< RAW data, 14 bits per pixel */
IA_CSS_STREAM_FORMAT_RAW_16, /**< RAW data, 16 bits per pixel, which is
not specified in CSI-MIPI standard*/
IA_CSS_STREAM_FORMAT_BINARY_8, /**< Binary byte stream, which is target at
JPEG. */
/** CSI2-MIPI specific format: Generic short packet data. It is used to
* keep the timing information for the opening/closing of shutters,
* triggering of flashes and etc.
*/
IA_CSS_STREAM_FORMAT_GENERIC_SHORT1, /**< Generic Short Packet Code 1 */
IA_CSS_STREAM_FORMAT_GENERIC_SHORT2, /**< Generic Short Packet Code 2 */
IA_CSS_STREAM_FORMAT_GENERIC_SHORT3, /**< Generic Short Packet Code 3 */
IA_CSS_STREAM_FORMAT_GENERIC_SHORT4, /**< Generic Short Packet Code 4 */
IA_CSS_STREAM_FORMAT_GENERIC_SHORT5, /**< Generic Short Packet Code 5 */
IA_CSS_STREAM_FORMAT_GENERIC_SHORT6, /**< Generic Short Packet Code 6 */
IA_CSS_STREAM_FORMAT_GENERIC_SHORT7, /**< Generic Short Packet Code 7 */
IA_CSS_STREAM_FORMAT_GENERIC_SHORT8, /**< Generic Short Packet Code 8 */
/** CSI2-MIPI specific format: YUV data.
*/
IA_CSS_STREAM_FORMAT_YUV420_8_SHIFT, /**< YUV420 8-bit (Chroma Shifted Pixel Sampling) */
IA_CSS_STREAM_FORMAT_YUV420_10_SHIFT, /**< YUV420 8-bit (Chroma Shifted Pixel Sampling) */
/** CSI2-MIPI specific format: Generic long packet data
*/
IA_CSS_STREAM_FORMAT_EMBEDDED, /**< Embedded 8-bit non Image Data */
/** CSI2-MIPI specific format: User defined byte-based data. For example,
* the data transmitter (e.g. the SoC sensor) can keep the JPEG data as
* the User Defined Data Type 4 and the MPEG data as the
* User Defined Data Type 7.
*/
IA_CSS_STREAM_FORMAT_USER_DEF1, /**< User defined 8-bit data type 1 */
IA_CSS_STREAM_FORMAT_USER_DEF2, /**< User defined 8-bit data type 2 */
IA_CSS_STREAM_FORMAT_USER_DEF3, /**< User defined 8-bit data type 3 */
IA_CSS_STREAM_FORMAT_USER_DEF4, /**< User defined 8-bit data type 4 */
IA_CSS_STREAM_FORMAT_USER_DEF5, /**< User defined 8-bit data type 5 */
IA_CSS_STREAM_FORMAT_USER_DEF6, /**< User defined 8-bit data type 6 */
IA_CSS_STREAM_FORMAT_USER_DEF7, /**< User defined 8-bit data type 7 */
IA_CSS_STREAM_FORMAT_USER_DEF8, /**< User defined 8-bit data type 8 */
};
#define IA_CSS_STREAM_FORMAT_NUM IA_CSS_STREAM_FORMAT_USER_DEF8
unsigned int ia_css_util_input_format_bpp(
enum ia_css_stream_format format,
bool two_ppc);
#endif /* __IA_CSS_STREAM_FORMAT_H */
|
#include <linux/export.h>
#include <linux/sched.h>
#include <linux/personality.h>
#include <linux/binfmts.h>
#include <linux/elf.h>
#include <asm/system_info.h>
int elf_check_arch(const struct elf32_hdr *x)
{
unsigned int eflags;
if (x->e_machine != EM_ARM)
return 0;
if (x->e_entry & 1) {
if (!(elf_hwcap & HWCAP_THUMB))
return 0;
} else if (x->e_entry & 3)
return 0;
eflags = x->e_flags;
if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN) {
unsigned int flt_fmt;
if ((eflags & EF_ARM_APCS_26) && !(elf_hwcap & HWCAP_26BIT))
return 0;
flt_fmt = eflags & (EF_ARM_VFP_FLOAT | EF_ARM_SOFT_FLOAT);
if (flt_fmt == EF_ARM_VFP_FLOAT && !(elf_hwcap & HWCAP_VFP))
return 0;
}
return 1;
}
EXPORT_SYMBOL(elf_check_arch);
void elf_set_personality(const struct elf32_hdr *x)
{
unsigned int eflags = x->e_flags;
unsigned int personality = current->personality & ~PER_MASK;
personality |= PER_LINUX;
if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN &&
(eflags & EF_ARM_APCS_26))
personality &= ~ADDR_LIMIT_32BIT;
else
personality |= ADDR_LIMIT_32BIT;
set_personality(personality);
if (elf_hwcap & HWCAP_IWMMXT &&
eflags & (EF_ARM_EABI_MASK | EF_ARM_SOFT_FLOAT)) {
set_thread_flag(TIF_USING_IWMMXT);
} else {
clear_thread_flag(TIF_USING_IWMMXT);
}
}
EXPORT_SYMBOL(elf_set_personality);
int arm_elf_read_implies_exec(const struct elf32_hdr *x, int executable_stack)
{
if (executable_stack != EXSTACK_DISABLE_X)
return 1;
if (cpu_architecture() < CPU_ARCH_ARMv6)
return 1;
return 0;
}
EXPORT_SYMBOL(arm_elf_read_implies_exec);
|
/*
* rbtx4939-flash (based on physmap.c)
*
* This is a simplified physmap driver with map_init callback function.
*
* 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.
*
* Copyright (C) 2009 Atsushi Nemoto <anemo@mba.ocn.ne.jp>
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#include <asm/txx9/rbtx4939.h>
struct rbtx4939_flash_info {
struct mtd_info *mtd;
struct map_info map;
};
static int rbtx4939_flash_remove(struct platform_device *dev)
{
struct rbtx4939_flash_info *info;
info = platform_get_drvdata(dev);
if (!info)
return 0;
if (info->mtd) {
mtd_device_unregister(info->mtd);
map_destroy(info->mtd);
}
return 0;
}
static const char * const rom_probe_types[] = {
"cfi_probe", "jedec_probe", NULL };
static int rbtx4939_flash_probe(struct platform_device *dev)
{
struct rbtx4939_flash_data *pdata;
struct rbtx4939_flash_info *info;
struct resource *res;
const char * const *probe_type;
int err = 0;
unsigned long size;
pdata = dev_get_platdata(&dev->dev);
if (!pdata)
return -ENODEV;
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!res)
return -ENODEV;
info = devm_kzalloc(&dev->dev, sizeof(struct rbtx4939_flash_info),
GFP_KERNEL);
if (!info)
return -ENOMEM;
platform_set_drvdata(dev, info);
size = resource_size(res);
pr_notice("rbtx4939 platform flash device: %pR\n", res);
if (!devm_request_mem_region(&dev->dev, res->start, size,
dev_name(&dev->dev)))
return -EBUSY;
info->map.name = dev_name(&dev->dev);
info->map.phys = res->start;
info->map.size = size;
info->map.bankwidth = pdata->width;
info->map.virt = devm_ioremap(&dev->dev, info->map.phys, size);
if (!info->map.virt)
return -EBUSY;
if (pdata->map_init)
(*pdata->map_init)(&info->map);
else
simple_map_init(&info->map);
probe_type = rom_probe_types;
for (; !info->mtd && *probe_type; probe_type++)
info->mtd = do_map_probe(*probe_type, &info->map);
if (!info->mtd) {
dev_err(&dev->dev, "map_probe failed\n");
err = -ENXIO;
goto err_out;
}
info->mtd->dev.parent = &dev->dev;
err = mtd_device_parse_register(info->mtd, NULL, NULL, pdata->parts,
pdata->nr_parts);
if (err)
goto err_out;
return 0;
err_out:
rbtx4939_flash_remove(dev);
return err;
}
#ifdef CONFIG_PM
static void rbtx4939_flash_shutdown(struct platform_device *dev)
{
struct rbtx4939_flash_info *info = platform_get_drvdata(dev);
if (mtd_suspend(info->mtd) == 0)
mtd_resume(info->mtd);
}
#else
#define rbtx4939_flash_shutdown NULL
#endif
static struct platform_driver rbtx4939_flash_driver = {
.probe = rbtx4939_flash_probe,
.remove = rbtx4939_flash_remove,
.shutdown = rbtx4939_flash_shutdown,
.driver = {
.name = "rbtx4939-flash",
},
};
module_platform_driver(rbtx4939_flash_driver);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("RBTX4939 MTD map driver");
MODULE_ALIAS("platform:rbtx4939-flash");
|
/******************************************************************************
*
* Module Name: osunixmap - Unix OSL for file mappings
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* 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 MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*/
#include "acpidump.h"
#include <unistd.h>
#include <sys/mman.h>
#ifdef _free_BSD
#include <sys/param.h>
#endif
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME("osunixmap")
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifdef _free_BSD
#define MMAP_FLAGS MAP_SHARED
#else
#define MMAP_FLAGS MAP_PRIVATE
#endif
#define SYSTEM_MEMORY "/dev/mem"
/*******************************************************************************
*
* FUNCTION: acpi_os_get_page_size
*
* PARAMETERS: None
*
* RETURN: Page size of the platform.
*
* DESCRIPTION: Obtain page size of the platform.
*
******************************************************************************/
static acpi_size acpi_os_get_page_size(void)
{
#ifdef PAGE_SIZE
return PAGE_SIZE;
#else
return sysconf(_SC_PAGESIZE);
#endif
}
/******************************************************************************
*
* FUNCTION: acpi_os_map_memory
*
* PARAMETERS: where - Physical address of memory to be mapped
* length - How much memory to map
*
* RETURN: Pointer to mapped memory. Null on error.
*
* DESCRIPTION: Map physical memory into local address space.
*
*****************************************************************************/
void *acpi_os_map_memory(acpi_physical_address where, acpi_size length)
{
u8 *mapped_memory;
acpi_physical_address offset;
acpi_size page_size;
int fd;
fd = open(SYSTEM_MEMORY, O_RDONLY | O_BINARY);
if (fd < 0) {
fprintf(stderr, "Cannot open %s\n", SYSTEM_MEMORY);
return (NULL);
}
/* Align the offset to use mmap */
page_size = acpi_os_get_page_size();
offset = where % page_size;
/* Map the table header to get the length of the full table */
mapped_memory = mmap(NULL, (length + offset), PROT_READ, MMAP_FLAGS,
fd, (where - offset));
if (mapped_memory == MAP_FAILED) {
fprintf(stderr, "Cannot map %s\n", SYSTEM_MEMORY);
close(fd);
return (NULL);
}
close(fd);
return (ACPI_CAST8(mapped_memory + offset));
}
/******************************************************************************
*
* FUNCTION: acpi_os_unmap_memory
*
* PARAMETERS: where - Logical address of memory to be unmapped
* length - How much memory to unmap
*
* RETURN: None.
*
* DESCRIPTION: Delete a previously created mapping. Where and Length must
* correspond to a previous mapping exactly.
*
*****************************************************************************/
void acpi_os_unmap_memory(void *where, acpi_size length)
{
acpi_physical_address offset;
acpi_size page_size;
page_size = acpi_os_get_page_size();
offset = (acpi_physical_address) where % page_size;
munmap((u8 *)where - offset, (length + offset));
}
|
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Cocoa/Cocoa.h>
@interface NSImage (WebExtras)
- (void)_web_scaleToMaxSize:(NSSize)size;
- (void)_web_dissolveToFraction:(float)delta;
// Debug method. Saves an image and opens it in the preferred TIFF viewing application.
- (void)_web_saveAndOpen;
@end
|
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
#ifndef __java_util_Collections$5__
#define __java_util_Collections$5__
#pragma interface
#include <java/util/Collections$UnmodifiableIterator.h>
class java::util::Collections$5 : public ::java::util::Collections$UnmodifiableIterator
{
public: // actually package-private
Collections$5(::java::util::Collections$UnmodifiableMap$UnmodifiableEntrySet *, ::java::util::Iterator *);
public:
virtual ::java::util::Map$Entry * Collections$5$next();
virtual ::java::lang::Object * next();
public: // actually package-private
::java::util::Collections$UnmodifiableMap$UnmodifiableEntrySet * __attribute__((aligned(__alignof__( ::java::util::Collections$UnmodifiableIterator)))) this$2;
public:
static ::java::lang::Class class$;
};
#endif // __java_util_Collections$5__
|
//******************************************************************************
//
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************
#import <UIKit/UIKit.h>
@interface SBDisplayModeViewController : UITableViewController<UIPickerViewDataSource, UIPickerViewDelegate>
@property (nonatomic, retain) NSMutableArray *rows;
@end
|
#ifndef _UAPI__IP_SET_BITMAP_H
#define _UAPI__IP_SET_BITMAP_H
#include <linux/netfilter/ipset/ip_set.h>
/* Bitmap type specific error codes */
enum {
/* The element is out of the range of the set */
IPSET_ERR_BITMAP_RANGE = IPSET_ERR_TYPE_SPECIFIC,
/* The range exceeds the size limit of the set type */
IPSET_ERR_BITMAP_RANGE_SIZE,
};
#endif /* _UAPI__IP_SET_BITMAP_H */
|
/* 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 <openssl/evp.h>
#include <openssl/digest.h>
#include <openssl/err.h>
#include "internal.h"
int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) {
return EVP_DigestInit_ex(ctx, type, impl);
}
int EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type) {
return EVP_DigestInit(ctx, type);
}
int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *data, size_t len) {
return EVP_DigestUpdate(ctx, data, len);
}
int EVP_SignFinal(const EVP_MD_CTX *ctx, uint8_t *sig,
unsigned int *out_sig_len, EVP_PKEY *pkey) {
uint8_t m[EVP_MAX_MD_SIZE];
unsigned int m_len;
int ret = 0;
EVP_MD_CTX tmp_ctx;
EVP_PKEY_CTX *pkctx = NULL;
size_t sig_len = EVP_PKEY_size(pkey);
*out_sig_len = 0;
EVP_MD_CTX_init(&tmp_ctx);
if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx) ||
!EVP_DigestFinal_ex(&tmp_ctx, m, &m_len)) {
goto out;
}
EVP_MD_CTX_cleanup(&tmp_ctx);
pkctx = EVP_PKEY_CTX_new(pkey, NULL);
if (!pkctx || !EVP_PKEY_sign_init(pkctx) ||
!EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) ||
!EVP_PKEY_sign(pkctx, sig, &sig_len, m, m_len)) {
goto out;
}
*out_sig_len = sig_len;
ret = 1;
out:
if (pkctx) {
EVP_PKEY_CTX_free(pkctx);
}
return ret;
}
int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) {
return EVP_DigestInit_ex(ctx, type, impl);
}
int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type) {
return EVP_DigestInit(ctx, type);
}
int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t len) {
return EVP_DigestUpdate(ctx, data, len);
}
int EVP_VerifyFinal(EVP_MD_CTX *ctx, const uint8_t *sig, size_t sig_len,
EVP_PKEY *pkey) {
uint8_t m[EVP_MAX_MD_SIZE];
unsigned int m_len;
int ret = 0;
EVP_MD_CTX tmp_ctx;
EVP_PKEY_CTX *pkctx = NULL;
EVP_MD_CTX_init(&tmp_ctx);
if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx) ||
!EVP_DigestFinal_ex(&tmp_ctx, m, &m_len)) {
EVP_MD_CTX_cleanup(&tmp_ctx);
goto out;
}
EVP_MD_CTX_cleanup(&tmp_ctx);
pkctx = EVP_PKEY_CTX_new(pkey, NULL);
if (!pkctx ||
!EVP_PKEY_verify_init(pkctx) ||
!EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest)) {
goto out;
}
ret = EVP_PKEY_verify(pkctx, sig, sig_len, m, m_len);
out:
EVP_PKEY_CTX_free(pkctx);
return ret;
}
|
/*
* TXx9 SoC AC Link Controller
*
* 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.
*/
#ifndef __TXX9ACLC_H
#define __TXX9ACLC_H
#include <linux/interrupt.h>
#include <asm/txx9/dmac.h>
#define ACCTLEN 0x00 /* control enable */
#define ACCTLDIS 0x04 /* control disable */
#define ACCTL_ENLINK 0x00000001 /* enable/disable AC-link */
#define ACCTL_AUDODMA 0x00000100 /* AUDODMA enable/disable */
#define ACCTL_AUDIDMA 0x00001000 /* AUDIDMA enable/disable */
#define ACCTL_AUDOEHLT 0x00010000 /* AUDO error halt
enable/disable */
#define ACCTL_AUDIEHLT 0x00100000 /* AUDI error halt
enable/disable */
#define ACREGACC 0x08 /* codec register access */
#define ACREGACC_DAT_SHIFT 0 /* data field */
#define ACREGACC_REG_SHIFT 16 /* address field */
#define ACREGACC_CODECID_SHIFT 24 /* CODEC ID field */
#define ACREGACC_READ 0x80000000 /* CODEC read */
#define ACREGACC_WRITE 0x00000000 /* CODEC write */
#define ACINTSTS 0x10 /* interrupt status */
#define ACINTMSTS 0x14 /* interrupt masked status */
#define ACINTEN 0x18 /* interrupt enable */
#define ACINTDIS 0x1c /* interrupt disable */
#define ACINT_CODECRDY(n) (0x00000001 << (n)) /* CODECn ready */
#define ACINT_REGACCRDY 0x00000010 /* ACREGACC ready */
#define ACINT_AUDOERR 0x00000100 /* AUDO underrun error */
#define ACINT_AUDIERR 0x00001000 /* AUDI overrun error */
#define ACDMASTS 0x80 /* DMA request status */
#define ACDMA_AUDO 0x00000001 /* AUDODMA pending */
#define ACDMA_AUDI 0x00000010 /* AUDIDMA pending */
#define ACAUDODAT 0xa0 /* audio out data */
#define ACAUDIDAT 0xb0 /* audio in data */
#define ACREVID 0xfc /* revision ID */
struct txx9aclc_dmadata {
struct resource *dma_res;
struct txx9dmac_slave dma_slave;
struct dma_chan *dma_chan;
struct tasklet_struct tasklet;
spinlock_t dma_lock;
int stream; /* SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE */
struct snd_pcm_substream *substream;
unsigned long pos;
dma_addr_t dma_addr;
unsigned long buffer_bytes;
unsigned long period_bytes;
unsigned long frag_bytes;
int frags;
int frag_count;
int dmacount;
};
struct txx9aclc_plat_drvdata {
void __iomem *base;
u64 physbase;
};
static inline struct txx9aclc_plat_drvdata *txx9aclc_get_plat_drvdata(
struct snd_soc_dai *dai)
{
return dev_get_drvdata(dai->dev);
}
#endif /* __TXX9ACLC_H */
|
/*
* Windfarm PowerMac thermal control. MAX6690 sensor.
*
* Copyright (C) 2005 Paul Mackerras, IBM Corp. <paulus@samba.org>
*
* Use and redistribute under the terms of the GNU GPL v2.
*/
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <asm/prom.h>
#include <asm/pmac_low_i2c.h>
#include "windfarm.h"
#define VERSION "1.0"
/* This currently only exports the external temperature sensor,
since that's all the control loops need. */
/* Some MAX6690 register numbers */
#define MAX6690_INTERNAL_TEMP 0
#define MAX6690_EXTERNAL_TEMP 1
struct wf_6690_sensor {
struct i2c_client *i2c;
struct wf_sensor sens;
};
#define wf_to_6690(x) container_of((x), struct wf_6690_sensor, sens)
static int wf_max6690_get(struct wf_sensor *sr, s32 *value)
{
struct wf_6690_sensor *max = wf_to_6690(sr);
s32 data;
if (max->i2c == NULL)
return -ENODEV;
/* chip gets initialized by firmware */
data = i2c_smbus_read_byte_data(max->i2c, MAX6690_EXTERNAL_TEMP);
if (data < 0)
return data;
*value = data << 16;
return 0;
}
static void wf_max6690_release(struct wf_sensor *sr)
{
struct wf_6690_sensor *max = wf_to_6690(sr);
kfree(max);
}
static struct wf_sensor_ops wf_max6690_ops = {
.get_value = wf_max6690_get,
.release = wf_max6690_release,
.owner = THIS_MODULE,
};
static int wf_max6690_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
const char *name, *loc;
struct wf_6690_sensor *max;
int rc;
loc = of_get_property(client->dev.of_node, "hwsensor-location", NULL);
if (!loc) {
dev_warn(&client->dev, "Missing hwsensor-location property!\n");
return -ENXIO;
}
/*
* We only expose the external temperature register for
* now as this is all we need for our control loops
*/
if (!strcmp(loc, "BACKSIDE") || !strcmp(loc, "SYS CTRLR AMBIENT"))
name = "backside-temp";
else if (!strcmp(loc, "NB Ambient"))
name = "north-bridge-temp";
else if (!strcmp(loc, "GPU Ambient"))
name = "gpu-temp";
else
return -ENXIO;
max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
if (max == NULL) {
printk(KERN_ERR "windfarm: Couldn't create MAX6690 sensor: "
"no memory\n");
return -ENOMEM;
}
max->i2c = client;
max->sens.name = (char *)name; /* XXX fix constness in structure */
max->sens.ops = &wf_max6690_ops;
i2c_set_clientdata(client, max);
rc = wf_register_sensor(&max->sens);
if (rc)
kfree(max);
return rc;
}
static int wf_max6690_remove(struct i2c_client *client)
{
struct wf_6690_sensor *max = i2c_get_clientdata(client);
max->i2c = NULL;
wf_unregister_sensor(&max->sens);
return 0;
}
static const struct i2c_device_id wf_max6690_id[] = {
{ "MAC,max6690", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wf_max6690_id);
static struct i2c_driver wf_max6690_driver = {
.driver = {
.name = "wf_max6690",
},
.probe = wf_max6690_probe,
.remove = wf_max6690_remove,
.id_table = wf_max6690_id,
};
module_i2c_driver(wf_max6690_driver);
MODULE_AUTHOR("Paul Mackerras <paulus@samba.org>");
MODULE_DESCRIPTION("MAX6690 sensor objects for PowerMac thermal control");
MODULE_LICENSE("GPL");
|
/*
* This file contains the processor specific definitions
* of the TI DM644x, DM355, DM365, and DM646x.
*
* Copyright (C) 2011 Texas Instruments Incorporated
* Copyright (c) 2007 Deep Root Systems, LLC
*
* 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.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __DAVINCI_H
#define __DAVINCI_H
#include <linux/clk.h>
#include <linux/videodev2.h>
#include <linux/davinci_emac.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/platform_data/davinci_asp.h>
#include <linux/platform_data/keyscan-davinci.h>
#include <mach/hardware.h>
#include <mach/edma.h>
#include <media/davinci/vpfe_capture.h>
#include <media/davinci/vpif_types.h>
#include <media/davinci/vpss.h>
#include <media/davinci/vpbe_types.h>
#include <media/davinci/vpbe_venc.h>
#include <media/davinci/vpbe.h>
#include <media/davinci/vpbe_osd.h>
#define DAVINCI_SYSTEM_MODULE_BASE 0x01c40000
#define SYSMOD_VIDCLKCTL 0x38
#define SYSMOD_VPSS_CLKCTL 0x44
#define SYSMOD_VDD3P3VPWDN 0x48
#define SYSMOD_VSCLKDIS 0x6c
#define SYSMOD_PUPDCTL1 0x7c
extern void __iomem *davinci_sysmod_base;
#define DAVINCI_SYSMOD_VIRT(x) (davinci_sysmod_base + (x))
void davinci_map_sysmod(void);
/* DM355 base addresses */
#define DM355_ASYNC_EMIF_CONTROL_BASE 0x01e10000
#define DM355_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
#define ASP1_TX_EVT_EN 1
#define ASP1_RX_EVT_EN 2
/* DM365 base addresses */
#define DM365_ASYNC_EMIF_CONTROL_BASE 0x01d10000
#define DM365_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
#define DM365_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
/* DM644x base addresses */
#define DM644X_ASYNC_EMIF_CONTROL_BASE 0x01e00000
#define DM644X_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
#define DM644X_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
#define DM644X_ASYNC_EMIF_DATA_CE2_BASE 0x06000000
#define DM644X_ASYNC_EMIF_DATA_CE3_BASE 0x08000000
/* DM646x base addresses */
#define DM646X_ASYNC_EMIF_CONTROL_BASE 0x20008000
#define DM646X_ASYNC_EMIF_CS2_SPACE_BASE 0x42000000
/* DM355 function declarations */
void __init dm355_init(void);
void dm355_init_spi0(unsigned chipselect_mask,
const struct spi_board_info *info, unsigned len);
void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata);
void dm355_set_vpfe_config(struct vpfe_config *cfg);
/* DM365 function declarations */
void __init dm365_init(void);
void __init dm365_init_asp(struct snd_platform_data *pdata);
void __init dm365_init_vc(struct snd_platform_data *pdata);
void __init dm365_init_ks(struct davinci_ks_platform_data *pdata);
void __init dm365_init_rtc(void);
void dm365_init_spi0(unsigned chipselect_mask,
const struct spi_board_info *info, unsigned len);
void dm365_set_vpfe_config(struct vpfe_config *cfg);
/* DM644x function declarations */
void __init dm644x_init(void);
void __init dm644x_init_asp(struct snd_platform_data *pdata);
int __init dm644x_init_video(struct vpfe_config *, struct vpbe_config *);
/* DM646x function declarations */
void __init dm646x_init(void);
void __init dm646x_init_mcasp0(struct snd_platform_data *pdata);
void __init dm646x_init_mcasp1(struct snd_platform_data *pdata);
int __init dm646x_init_edma(struct edma_rsv_info *rsv);
void dm646x_video_init(void);
void dm646x_setup_vpif(struct vpif_display_config *,
struct vpif_capture_config *);
#endif /*__DAVINCI_H */
|
/*
* Copyright (C) 2014 Free Electrons
*
* License Terms: GNU General Public License v2
* Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
*
* Allwinner A31 AR100 clock driver
*
*/
#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#define SUN6I_AR100_MAX_PARENTS 4
#define SUN6I_AR100_SHIFT_MASK 0x3
#define SUN6I_AR100_SHIFT_MAX SUN6I_AR100_SHIFT_MASK
#define SUN6I_AR100_SHIFT_SHIFT 4
#define SUN6I_AR100_DIV_MASK 0x1f
#define SUN6I_AR100_DIV_MAX (SUN6I_AR100_DIV_MASK + 1)
#define SUN6I_AR100_DIV_SHIFT 8
#define SUN6I_AR100_MUX_MASK 0x3
#define SUN6I_AR100_MUX_SHIFT 16
struct ar100_clk {
struct clk_hw hw;
void __iomem *reg;
};
static inline struct ar100_clk *to_ar100_clk(struct clk_hw *hw)
{
return container_of(hw, struct ar100_clk, hw);
}
static unsigned long ar100_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct ar100_clk *clk = to_ar100_clk(hw);
u32 val = readl(clk->reg);
int shift = (val >> SUN6I_AR100_SHIFT_SHIFT) & SUN6I_AR100_SHIFT_MASK;
int div = (val >> SUN6I_AR100_DIV_SHIFT) & SUN6I_AR100_DIV_MASK;
return (parent_rate >> shift) / (div + 1);
}
static int ar100_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
int nparents = clk_hw_get_num_parents(hw);
long best_rate = -EINVAL;
int i;
req->best_parent_hw = NULL;
for (i = 0; i < nparents; i++) {
unsigned long parent_rate;
unsigned long tmp_rate;
struct clk_hw *parent;
unsigned long div;
int shift;
parent = clk_hw_get_parent_by_index(hw, i);
parent_rate = clk_hw_get_rate(parent);
div = DIV_ROUND_UP(parent_rate, req->rate);
/*
* The AR100 clk contains 2 divisors:
* - one power of 2 divisor
* - one regular divisor
*
* First check if we can safely shift (or divide by a power
* of 2) without losing precision on the requested rate.
*/
shift = ffs(div) - 1;
if (shift > SUN6I_AR100_SHIFT_MAX)
shift = SUN6I_AR100_SHIFT_MAX;
div >>= shift;
/*
* Then if the divisor is still bigger than what the HW
* actually supports, use a bigger shift (or power of 2
* divider) value and accept to lose some precision.
*/
while (div > SUN6I_AR100_DIV_MAX) {
shift++;
div >>= 1;
if (shift > SUN6I_AR100_SHIFT_MAX)
break;
}
/*
* If the shift value (or power of 2 divider) is bigger
* than what the HW actually support, skip this parent.
*/
if (shift > SUN6I_AR100_SHIFT_MAX)
continue;
tmp_rate = (parent_rate >> shift) / div;
if (!req->best_parent_hw || tmp_rate > best_rate) {
req->best_parent_hw = parent;
req->best_parent_rate = parent_rate;
best_rate = tmp_rate;
}
}
if (best_rate < 0)
return best_rate;
req->rate = best_rate;
return 0;
}
static int ar100_set_parent(struct clk_hw *hw, u8 index)
{
struct ar100_clk *clk = to_ar100_clk(hw);
u32 val = readl(clk->reg);
if (index >= SUN6I_AR100_MAX_PARENTS)
return -EINVAL;
val &= ~(SUN6I_AR100_MUX_MASK << SUN6I_AR100_MUX_SHIFT);
val |= (index << SUN6I_AR100_MUX_SHIFT);
writel(val, clk->reg);
return 0;
}
static u8 ar100_get_parent(struct clk_hw *hw)
{
struct ar100_clk *clk = to_ar100_clk(hw);
return (readl(clk->reg) >> SUN6I_AR100_MUX_SHIFT) &
SUN6I_AR100_MUX_MASK;
}
static int ar100_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
unsigned long div = parent_rate / rate;
struct ar100_clk *clk = to_ar100_clk(hw);
u32 val = readl(clk->reg);
int shift;
if (parent_rate % rate)
return -EINVAL;
shift = ffs(div) - 1;
if (shift > SUN6I_AR100_SHIFT_MAX)
shift = SUN6I_AR100_SHIFT_MAX;
div >>= shift;
if (div > SUN6I_AR100_DIV_MAX)
return -EINVAL;
val &= ~((SUN6I_AR100_SHIFT_MASK << SUN6I_AR100_SHIFT_SHIFT) |
(SUN6I_AR100_DIV_MASK << SUN6I_AR100_DIV_SHIFT));
val |= (shift << SUN6I_AR100_SHIFT_SHIFT) |
(div << SUN6I_AR100_DIV_SHIFT);
writel(val, clk->reg);
return 0;
}
static struct clk_ops ar100_ops = {
.recalc_rate = ar100_recalc_rate,
.determine_rate = ar100_determine_rate,
.set_parent = ar100_set_parent,
.get_parent = ar100_get_parent,
.set_rate = ar100_set_rate,
};
static int sun6i_a31_ar100_clk_probe(struct platform_device *pdev)
{
const char *parents[SUN6I_AR100_MAX_PARENTS];
struct device_node *np = pdev->dev.of_node;
const char *clk_name = np->name;
struct clk_init_data init;
struct ar100_clk *ar100;
struct resource *r;
struct clk *clk;
int nparents;
ar100 = devm_kzalloc(&pdev->dev, sizeof(*ar100), GFP_KERNEL);
if (!ar100)
return -ENOMEM;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ar100->reg = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(ar100->reg))
return PTR_ERR(ar100->reg);
nparents = of_clk_get_parent_count(np);
if (nparents > SUN6I_AR100_MAX_PARENTS)
nparents = SUN6I_AR100_MAX_PARENTS;
of_clk_parent_fill(np, parents, nparents);
of_property_read_string(np, "clock-output-names", &clk_name);
init.name = clk_name;
init.ops = &ar100_ops;
init.parent_names = parents;
init.num_parents = nparents;
init.flags = 0;
ar100->hw.init = &init;
clk = clk_register(&pdev->dev, &ar100->hw);
if (IS_ERR(clk))
return PTR_ERR(clk);
return of_clk_add_provider(np, of_clk_src_simple_get, clk);
}
static const struct of_device_id sun6i_a31_ar100_clk_dt_ids[] = {
{ .compatible = "allwinner,sun6i-a31-ar100-clk" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, sun6i_a31_ar100_clk_dt_ids);
static struct platform_driver sun6i_a31_ar100_clk_driver = {
.driver = {
.name = "sun6i-a31-ar100-clk",
.of_match_table = sun6i_a31_ar100_clk_dt_ids,
},
.probe = sun6i_a31_ar100_clk_probe,
};
module_platform_driver(sun6i_a31_ar100_clk_driver);
MODULE_AUTHOR("Boris BREZILLON <boris.brezillon@free-electrons.com>");
MODULE_DESCRIPTION("Allwinner A31 AR100 clock Driver");
MODULE_LICENSE("GPL v2");
|
/* Tom Kelly's Scalable TCP
*
* See http://www.deneholme.net/tom/scalable/
*
* John Heffner <jheffner@sc.edu>
*/
#include <linux/module.h>
#include <net/tcp.h>
/* These factors derived from the recommended values in the aer:
* .01 and and 7/8. We use 50 instead of 100 to account for
* delayed ack.
*/
#define TCP_SCALABLE_AI_CNT 50U
#define TCP_SCALABLE_MD_SCALE 3
static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
{
struct tcp_sock *tp = tcp_sk(sk);
if (!tcp_is_cwnd_limited(sk))
return;
if (tcp_in_slow_start(tp))
tcp_slow_start(tp, acked);
else
tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
1);
}
static u32 tcp_scalable_ssthresh(struct sock *sk)
{
const struct tcp_sock *tp = tcp_sk(sk);
return max(tp->snd_cwnd - (tp->snd_cwnd>>TCP_SCALABLE_MD_SCALE), 2U);
}
static struct tcp_congestion_ops tcp_scalable __read_mostly = {
.ssthresh = tcp_scalable_ssthresh,
.undo_cwnd = tcp_reno_undo_cwnd,
.cong_avoid = tcp_scalable_cong_avoid,
.owner = THIS_MODULE,
.name = "scalable",
};
static int __init tcp_scalable_register(void)
{
return tcp_register_congestion_control(&tcp_scalable);
}
static void __exit tcp_scalable_unregister(void)
{
tcp_unregister_congestion_control(&tcp_scalable);
}
module_init(tcp_scalable_register);
module_exit(tcp_scalable_unregister);
MODULE_AUTHOR("John Heffner");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Scalable TCP");
|
/*
* Common Flash Interface support:
* Generic utility functions not dependant on command set
*
* Copyright (C) 2002 Red Hat
* Copyright (C) 2003 STMicroelectronics Limited
*
* This code is covered by the GPL.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <asm/byteorder.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/mtd/xip.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/cfi.h>
#include <linux/mtd/compatmac.h>
int __xipram cfi_qry_present(struct map_info *map, __u32 base,
struct cfi_private *cfi)
{
int osf = cfi->interleave * cfi->device_type; /* scale factor */
map_word val[3];
map_word qry[3];
qry[0] = cfi_build_cmd('Q', map, cfi);
qry[1] = cfi_build_cmd('R', map, cfi);
qry[2] = cfi_build_cmd('Y', map, cfi);
val[0] = map_read(map, base + osf*0x10);
val[1] = map_read(map, base + osf*0x11);
val[2] = map_read(map, base + osf*0x12);
if (!map_word_equal(map, qry[0], val[0]))
return 0;
if (!map_word_equal(map, qry[1], val[1]))
return 0;
if (!map_word_equal(map, qry[2], val[2]))
return 0;
return 1; /* "QRY" found */
}
EXPORT_SYMBOL_GPL(cfi_qry_present);
int __xipram cfi_qry_mode_on(uint32_t base, struct map_info *map,
struct cfi_private *cfi)
{
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
if (cfi_qry_present(map, base, cfi))
return 1;
/* QRY not found probably we deal with some odd CFI chips */
/* Some revisions of some old Intel chips? */
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
if (cfi_qry_present(map, base, cfi))
return 1;
/* ST M29DW chips */
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
cfi_send_gen_cmd(0x98, 0x555, base, map, cfi, cfi->device_type, NULL);
if (cfi_qry_present(map, base, cfi))
return 1;
/* QRY not found */
return 0;
}
EXPORT_SYMBOL_GPL(cfi_qry_mode_on);
void __xipram cfi_qry_mode_off(uint32_t base, struct map_info *map,
struct cfi_private *cfi)
{
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
}
EXPORT_SYMBOL_GPL(cfi_qry_mode_off);
struct cfi_extquery *
__xipram cfi_read_pri(struct map_info *map, __u16 adr, __u16 size, const char* name)
{
struct cfi_private *cfi = map->fldrv_priv;
__u32 base = 0; // cfi->chips[0].start;
int ofs_factor = cfi->interleave * cfi->device_type;
int i;
struct cfi_extquery *extp = NULL;
printk(" %s Extended Query Table at 0x%4.4X\n", name, adr);
if (!adr)
goto out;
extp = kmalloc(size, GFP_KERNEL);
if (!extp) {
printk(KERN_ERR "Failed to allocate memory\n");
goto out;
}
#ifdef CONFIG_MTD_XIP
local_irq_disable();
#endif
/* Switch it into Query Mode */
cfi_qry_mode_on(base, map, cfi);
/* Read in the Extended Query Table */
for (i=0; i<size; i++) {
((unsigned char *)extp)[i] =
cfi_read_query(map, base+((adr+i)*ofs_factor));
}
/* Make sure it returns to read mode */
cfi_qry_mode_off(base, map, cfi);
#ifdef CONFIG_MTD_XIP
(void) map_read(map, base);
xip_iprefetch();
local_irq_enable();
#endif
out: return extp;
}
EXPORT_SYMBOL(cfi_read_pri);
void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup *fixups)
{
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
struct cfi_fixup *f;
for (f=fixups; f->fixup; f++) {
if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi->mfr)) &&
((f->id == CFI_ID_ANY) || (f->id == cfi->id))) {
f->fixup(mtd, f->param);
}
}
}
EXPORT_SYMBOL(cfi_fixup);
int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
loff_t ofs, size_t len, void *thunk)
{
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
unsigned long adr;
int chipnum, ret = 0;
int i, first;
struct mtd_erase_region_info *regions = mtd->eraseregions;
if (ofs > mtd->size)
return -EINVAL;
if ((len + ofs) > mtd->size)
return -EINVAL;
/* Check that both start and end of the requested erase are
* aligned with the erasesize at the appropriate addresses.
*/
i = 0;
/* Skip all erase regions which are ended before the start of
the requested erase. Actually, to save on the calculations,
we skip to the first erase region which starts after the
start of the requested erase, and then go back one.
*/
while (i < mtd->numeraseregions && ofs >= regions[i].offset)
i++;
i--;
/* OK, now i is pointing at the erase region in which this
erase request starts. Check the start of the requested
erase range is aligned with the erase size which is in
effect here.
*/
if (ofs & (regions[i].erasesize-1))
return -EINVAL;
/* Remember the erase region we start on */
first = i;
/* Next, check that the end of the requested erase is aligned
* with the erase region at that address.
*/
while (i<mtd->numeraseregions && (ofs + len) >= regions[i].offset)
i++;
/* As before, drop back one to point at the region in which
the address actually falls
*/
i--;
if ((ofs + len) & (regions[i].erasesize-1))
return -EINVAL;
chipnum = ofs >> cfi->chipshift;
adr = ofs - (chipnum << cfi->chipshift);
i=first;
while(len) {
int size = regions[i].erasesize;
ret = (*frob)(map, &cfi->chips[chipnum], adr, size, thunk);
if (ret)
return ret;
adr += size;
ofs += size;
len -= size;
if (ofs == regions[i].offset + size * regions[i].numblocks)
i++;
if (adr >> cfi->chipshift) {
adr = 0;
chipnum++;
if (chipnum >= cfi->numchips)
break;
}
}
return 0;
}
EXPORT_SYMBOL(cfi_varsize_frob);
MODULE_LICENSE("GPL");
|
int __attribute__ ((noinline))
foo ()
{
const int a[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
int i, sum;
sum = 0;
for (i = 0; i < sizeof (a) / sizeof (*a); i++)
sum += a[i];
return sum;
}
int
main ()
{
if (foo () != 28)
abort ();
exit (0);
}
|
/***********************************************************************
Copyright (c) 2006-2011, Skype Limited. 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 Internet Society, IETF or IETF Trust, nor the
names of specific 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.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "SigProc_FIX.h"
opus_int32 silk_inner_prod_aligned_scale(
const opus_int16 *const inVec1, /* I input vector 1 */
const opus_int16 *const inVec2, /* I input vector 2 */
const opus_int scale, /* I number of bits to shift */
const opus_int len /* I vector lengths */
)
{
opus_int i;
opus_int32 sum = 0;
for( i = 0; i < len; i++ ) {
sum = silk_ADD_RSHIFT32( sum, silk_SMULBB( inVec1[ i ], inVec2[ i ] ), scale );
}
return sum;
}
|
/*
* Copyright 2014 Cisco Systems, Inc. All rights reserved.
*
* This program is free software; you may 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.
*
* 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 __SNIC_STATS_H
#define __SNIC_STATS_H
struct snic_io_stats {
atomic64_t active; /* Active IOs */
atomic64_t max_active; /* Max # active IOs */
atomic64_t max_sgl; /* Max # SGLs for any IO */
atomic64_t max_time; /* Max time to process IO */
atomic64_t max_qtime; /* Max time to Queue the IO */
atomic64_t max_cmpl_time; /* Max time to complete the IO */
atomic64_t sgl_cnt[SNIC_MAX_SG_DESC_CNT]; /* SGL Counters */
atomic64_t max_io_sz; /* Max IO Size */
atomic64_t compl; /* IO Completions */
atomic64_t fail; /* IO Failures */
atomic64_t req_null; /* req or req info is NULL */
atomic64_t alloc_fail; /* Alloc Failures */
atomic64_t sc_null;
atomic64_t io_not_found; /* IO Not Found */
atomic64_t num_ios; /* Number of IOs */
};
struct snic_abort_stats {
atomic64_t num; /* Abort counter */
atomic64_t fail; /* Abort Failure Counter */
atomic64_t drv_tmo; /* Abort Driver Timeouts */
atomic64_t fw_tmo; /* Abort Firmware Timeouts */
atomic64_t io_not_found;/* Abort IO Not Found */
atomic64_t q_fail; /* Abort Queuing Failed */
};
struct snic_reset_stats {
atomic64_t dev_resets; /* Device Reset Counter */
atomic64_t dev_reset_fail; /* Device Reset Failures */
atomic64_t dev_reset_aborts; /* Device Reset Aborts */
atomic64_t dev_reset_tmo; /* Device Reset Timeout */
atomic64_t dev_reset_terms; /* Device Reset terminate */
atomic64_t hba_resets; /* hba/firmware resets */
atomic64_t hba_reset_cmpl; /* hba/firmware reset completions */
atomic64_t hba_reset_fail; /* hba/firmware failures */
atomic64_t snic_resets; /* snic resets */
atomic64_t snic_reset_compl; /* snic reset completions */
atomic64_t snic_reset_fail; /* snic reset failures */
};
struct snic_fw_stats {
atomic64_t actv_reqs; /* Active Requests */
atomic64_t max_actv_reqs; /* Max Active Requests */
atomic64_t out_of_res; /* Firmware Out Of Resources */
atomic64_t io_errs; /* Firmware IO Firmware Errors */
atomic64_t scsi_errs; /* Target hits check condition */
};
struct snic_misc_stats {
u64 last_isr_time;
u64 last_ack_time;
atomic64_t ack_isr_cnt;
atomic64_t cmpl_isr_cnt;
atomic64_t errnotify_isr_cnt;
atomic64_t max_cq_ents; /* Max CQ Entries */
atomic64_t data_cnt_mismat; /* Data Count Mismatch */
atomic64_t io_tmo;
atomic64_t io_aborted;
atomic64_t sgl_inval; /* SGL Invalid */
atomic64_t abts_wq_alloc_fail; /* Abort Path WQ desc alloc failure */
atomic64_t devrst_wq_alloc_fail;/* Device Reset - WQ desc alloc fail */
atomic64_t wq_alloc_fail; /* IO WQ desc alloc failure */
atomic64_t no_icmnd_itmf_cmpls;
atomic64_t io_under_run;
atomic64_t qfull;
atomic64_t qsz_rampup;
atomic64_t qsz_rampdown;
atomic64_t last_qsz;
atomic64_t tgt_not_rdy;
};
struct snic_stats {
struct snic_io_stats io;
struct snic_abort_stats abts;
struct snic_reset_stats reset;
struct snic_fw_stats fw;
struct snic_misc_stats misc;
atomic64_t io_cmpl_skip;
};
int snic_stats_debugfs_init(struct snic *);
void snic_stats_debugfs_remove(struct snic *);
/* Auxillary function to update active IO counter */
static inline void
snic_stats_update_active_ios(struct snic_stats *s_stats)
{
struct snic_io_stats *io = &s_stats->io;
int nr_active_ios;
nr_active_ios = atomic64_read(&io->active);
if (atomic64_read(&io->max_active) < nr_active_ios)
atomic64_set(&io->max_active, nr_active_ios);
atomic64_inc(&io->num_ios);
}
/* Auxillary function to update IO completion counter */
static inline void
snic_stats_update_io_cmpl(struct snic_stats *s_stats)
{
atomic64_dec(&s_stats->io.active);
if (unlikely(atomic64_read(&s_stats->io_cmpl_skip)))
atomic64_dec(&s_stats->io_cmpl_skip);
else
atomic64_inc(&s_stats->io.compl);
}
#endif /* __SNIC_STATS_H */
|
#include "struct-layout-1.h"
struct Info info;
int fails;
int intarray[256];
int fn0 (void) { return 0; }
int fn1 (void) { return 1; }
int fn2 (void) { return 2; }
int fn3 (void) { return 3; }
int fn4 (void) { return 4; }
int fn5 (void) { return 5; }
int fn6 (void) { return 6; }
int fn7 (void) { return 7; }
int fn8 (void) { return 8; }
int fn9 (void) { return 9; }
/* This macro is intended for fields where their
addresses/sizes/alignments and value passing should be checked. */
#define F(n, x, v, w) \
info.flds[i] = &s##n.x; \
info.sizes[i] = sizeof (s##n.x); \
info.aligns[i] = __alignof__ (s##n.x); \
s##n.x = v; \
a##n[2].x = w; \
++i;
/* This macro is for fields where just their addresses/sizes/alignments
should be checked. */
#define N(n, x) \
info.flds[i] = &s##n.x; \
info.sizes[i] = sizeof (s##n.x); \
info.aligns[i] = __alignof__ (s##n.x); \
++i;
/* This macro is for fields where just value passing should be checked. */
#define B(n, x, v, w) \
s##n.x = v; \
a##n[2].x = w; \
++j;
#define TX(n, type, attrs, fields, ops) \
type S##n { fields } attrs; \
type S##n s##n; \
extern type S##n a##n[5]; \
extern type S##n check##n (type S##n, type S##n *, \
type S##n); \
extern void check##n##va (int i, ...); \
extern void checkx##n (type S##n); \
void test##n (void) \
{ \
int i, j; \
memset (&s##n, '\0', sizeof (s##n)); \
memset (a##n, '\0', sizeof (a##n)); \
memset (&info, '\0', sizeof (info)); \
info.sp = &s##n; \
info.a0p = &a##n[0]; \
info.a3p = &a##n[3]; \
info.sz = sizeof (s##n); \
info.als = __alignof__ (s##n); \
info.ala0 = __alignof__ (a##n[0]); \
info.ala3 = __alignof__ (a##n[3]); \
if (((long) &a##n[3]) & (info.als - 1)) \
FAIL (n, 1); \
i = 0; j = 0; \
ops \
info.nfields = i; \
info.nbitfields = j; \
checkx##n (check##n (s##n, &a##n[1], a##n[2])); \
check##n##va (1, 1.0, s##n, 2LL, a##n[2], a##n[2]); \
check##n##va (2, s##n, s##n, 2.0L, a##n[2], s##n); \
}
|
/* arch/arm/plat-samsung/include/plat/regs-iis.h
*
* Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
* http://www.simtec.co.uk/products/SWLINUX/
*
* 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.
*
* S3C2410 IIS register definition
*/
#ifndef __ASM_ARCH_REGS_IIS_H
#define __ASM_ARCH_REGS_IIS_H
#define S3C2410_IISCON (0x00)
#define S3C2410_IISCON_LRINDEX (1 << 8)
#define S3C2410_IISCON_TXFIFORDY (1 << 7)
#define S3C2410_IISCON_RXFIFORDY (1 << 6)
#define S3C2410_IISCON_TXDMAEN (1 << 5)
#define S3C2410_IISCON_RXDMAEN (1 << 4)
#define S3C2410_IISCON_TXIDLE (1 << 3)
#define S3C2410_IISCON_RXIDLE (1 << 2)
#define S3C2410_IISCON_PSCEN (1 << 1)
#define S3C2410_IISCON_IISEN (1 << 0)
#define S3C2410_IISMOD (0x04)
#define S3C2440_IISMOD_MPLL (1 << 9)
#define S3C2410_IISMOD_SLAVE (1 << 8)
#define S3C2410_IISMOD_NOXFER (0 << 6)
#define S3C2410_IISMOD_RXMODE (1 << 6)
#define S3C2410_IISMOD_TXMODE (2 << 6)
#define S3C2410_IISMOD_TXRXMODE (3 << 6)
#define S3C2410_IISMOD_LR_LLOW (0 << 5)
#define S3C2410_IISMOD_LR_RLOW (1 << 5)
#define S3C2410_IISMOD_IIS (0 << 4)
#define S3C2410_IISMOD_MSB (1 << 4)
#define S3C2410_IISMOD_8BIT (0 << 3)
#define S3C2410_IISMOD_16BIT (1 << 3)
#define S3C2410_IISMOD_BITMASK (1 << 3)
#define S3C2410_IISMOD_256FS (0 << 2)
#define S3C2410_IISMOD_384FS (1 << 2)
#define S3C2410_IISMOD_16FS (0 << 0)
#define S3C2410_IISMOD_32FS (1 << 0)
#define S3C2410_IISMOD_48FS (2 << 0)
#define S3C2410_IISMOD_FS_MASK (3 << 0)
#define S3C2410_IISPSR (0x08)
#define S3C2410_IISPSR_INTMASK (31 << 5)
#define S3C2410_IISPSR_INTSHIFT (5)
#define S3C2410_IISPSR_EXTMASK (31 << 0)
#define S3C2410_IISPSR_EXTSHFIT (0)
#define S3C2410_IISFCON (0x0c)
#define S3C2410_IISFCON_TXDMA (1 << 15)
#define S3C2410_IISFCON_RXDMA (1 << 14)
#define S3C2410_IISFCON_TXENABLE (1 << 13)
#define S3C2410_IISFCON_RXENABLE (1 << 12)
#define S3C2410_IISFCON_TXMASK (0x3f << 6)
#define S3C2410_IISFCON_TXSHIFT (6)
#define S3C2410_IISFCON_RXMASK (0x3f)
#define S3C2410_IISFCON_RXSHIFT (0)
#define S3C2410_IISFIFO (0x10)
#endif /* __ASM_ARCH_REGS_IIS_H */
|
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __U_RMNET_H
#define __U_RMNET_H
#include <linux/usb/composite.h>
#include <linux/usb/cdc.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
struct rmnet_ctrl_pkt {
void *buf;
int len;
struct list_head list;
};
struct grmnet {
struct usb_function func;
struct usb_ep *in;
struct usb_ep *out;
struct usb_endpoint_descriptor *in_desc;
struct usb_endpoint_descriptor *out_desc;
/* to usb host, aka laptop, windows pc etc. Will
* be filled by usb driver of rmnet functionality
*/
int (*send_cpkt_response)(struct grmnet *g,
struct rmnet_ctrl_pkt *pkt);
/* to modem, and to be filled by driver implementing
* control function
*/
int (*send_cpkt_request)(struct grmnet *g,
u8 port_num,
struct rmnet_ctrl_pkt *pkt);
void (*send_cbits_tomodem)(struct grmnet *g,
u8 port_num,
int cbits);
void (*disconnect)(struct grmnet *g);
void (*connect)(struct grmnet *g);
};
int gbam_setup(unsigned int count);
int gbam_connect(struct grmnet *, u8 port_num);
void gbam_disconnect(struct grmnet *, u8 port_num);
int gsmd_ctrl_connect(struct grmnet *gr, int port_num);
void gsmd_ctrl_disconnect(struct grmnet *gr, u8 port_num);
int gsmd_ctrl_setup(unsigned int count);
#endif /* __U_RMNET_H*/
|
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
/* Some ICMP messages should be passed to the transport protocols. This
is not implemented. */
#include "lwip/opt.h"
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
#include "lwip/icmp.h"
#include "lwip/inet.h"
#include "lwip/ip.h"
#include "lwip/def.h"
#include "lwip/stats.h"
void
icmp_input(struct pbuf *p, struct netif *inp)
{
u8_t type;
struct icmp_echo_hdr *iecho;
struct ip_hdr *iphdr;
struct ip_addr tmpaddr;
ICMP_STATS_INC(icmp.recv);
/* TODO: check length before accessing payload! */
type = ((u8_t *)p->payload)[0];
switch (type) {
case ICMP6_ECHO:
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
pbuf_free(p);
ICMP_STATS_INC(icmp.lenerr);
return;
}
iecho = p->payload;
iphdr = (struct ip_hdr *)((u8_t *)p->payload - IP_HLEN);
if (inet_chksum_pbuf(p) != 0) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
ICMP_STATS_INC(icmp.chkerr);
/* return;*/
}
LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %"S16_F" p->tot_len %"S16_F"\n", p->len, p->tot_len));
ip_addr_set(&tmpaddr, &(iphdr->src));
ip_addr_set(&(iphdr->src), &(iphdr->dest));
ip_addr_set(&(iphdr->dest), &tmpaddr);
iecho->type = ICMP6_ER;
/* adjust the checksum */
if (iecho->chksum >= htons(0xffff - (ICMP6_ECHO << 8))) {
iecho->chksum += htons(ICMP6_ECHO << 8) + 1;
} else {
iecho->chksum += htons(ICMP6_ECHO << 8);
}
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
ICMP_STATS_INC(icmp.xmit);
/* LWIP_DEBUGF("icmp: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
iphdr->hoplim, IP_PROTO_ICMP, inp);
break;
default:
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" not supported.\n", (s16_t)type));
ICMP_STATS_INC(icmp.proterr);
ICMP_STATS_INC(icmp.drop);
}
pbuf_free(p);
}
void
icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
{
struct pbuf *q;
struct ip_hdr *iphdr;
struct icmp_dur_hdr *idur;
/* @todo: can this be PBUF_LINK instead of PBUF_IP? */
q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM);
/* ICMP header + IP header + 8 bytes of data */
if (q == NULL) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_dest_unreach: failed to allocate pbuf for ICMP packet.\n"));
pbuf_free(p);
return;
}
LWIP_ASSERT("check that first pbuf can hold icmp message",
(q->len >= (8 + IP_HLEN + 8)));
iphdr = p->payload;
idur = q->payload;
idur->type = (u8_t)ICMP6_DUR;
idur->icode = (u8_t)t;
SMEMCPY((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8);
/* calculate checksum */
idur->chksum = 0;
idur->chksum = inet_chksum(idur, q->len);
ICMP_STATS_INC(icmp.xmit);
ip_output(q, NULL,
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
pbuf_free(q);
}
void
icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
{
struct pbuf *q;
struct ip_hdr *iphdr;
struct icmp_te_hdr *tehdr;
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded\n"));
/* @todo: can this be PBUF_LINK instead of PBUF_IP? */
q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM);
/* ICMP header + IP header + 8 bytes of data */
if (q == NULL) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_dest_unreach: failed to allocate pbuf for ICMP packet.\n"));
pbuf_free(p);
return;
}
LWIP_ASSERT("check that first pbuf can hold icmp message",
(q->len >= (8 + IP_HLEN + 8)));
iphdr = p->payload;
tehdr = q->payload;
tehdr->type = (u8_t)ICMP6_TE;
tehdr->icode = (u8_t)t;
/* copy fields from original packet */
SMEMCPY((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8);
/* calculate checksum */
tehdr->chksum = 0;
tehdr->chksum = inet_chksum(tehdr, q->len);
ICMP_STATS_INC(icmp.xmit);
ip_output(q, NULL,
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
pbuf_free(q);
}
#endif /* LWIP_ICMP */
|
/* Copyright (c) 2011, Nate Stedman <natesm@gmail.com>
*
* 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. */
#import <Foundation/Foundation.h>
@interface NSSet (FunSize)
/** Passes each element to the block, and returns `YES` if the block returns `YES` for all elements.
*
* @param block A block, which will receive each element as a parameter. */
-(BOOL)all:(BOOL(^)(id object))block;
/** Passes each element to the block, and returns `YES` if the block returns `YES` for any element.
*
* @param block A block, which will receive elements as a parameter until it returns `YES` (or the elements are
* exhausted). */
-(BOOL)any:(BOOL(^)(id object))block;
/** Returns an set of mapped values.
*
* @param mapBlock A block to map with. The block will receive each element of
* the set, and should return a mapped value to be inserted into the returned set. */
-(NSSet*)map:(id(^)(id object))mapBlock;
/** Returns an array of mapped values.
*
* @param mapBlock A block to map with. The block will receive each element of
* the set, and should return a mapped value to be inserted into the returned array. */
-(NSArray*)mapToArray:(id(^)(id object))mapBlock;
/** Similar to map:, but instead returns a dictionary, where the elements of
* this set are the keys and the mapped values are the values.
*
* @param mapBlock A block to map with. The block will receive each element of
* the set, and should return a mapped value to be inserted into the returned dictionary. */
-(NSDictionary*)mapToDictionary:(id(^)(id object))mapBlock;
/** Filters a set, returning an set with the filtered contents.
*
* @param filterBlock A block to filter with. The block will receive each
* element of this set, and should return `YES` if the element should be
* included in the filtered set, and `NO` if it should not. */
-(NSSet*)filter:(BOOL(^)(id object))filterBlock;
/** Filters a set, returning a set with the filtered contents.
*
* @param filterBlock A block to filter with. The block will receive each
* element of this set, and should return `YES` if the element should be
* included in the filtered array, and `NO` if it should not. */
-(NSArray*)filterToArray:(BOOL(^)(id object))filterBlock;
@end
|
#include <GL/gl.h>
#include <math.h>
float boxv[][3] = {
{ -0.5, -0.5, -0.5 },
{ 0.5, -0.5, -0.5 },
{ 0.5, 0.5, -0.5 },
{ -0.5, 0.5, -0.5 },
{ -0.5, -0.5, 0.5 },
{ 0.5, -0.5, 0.5 },
{ 0.5, 0.5, 0.5 },
{ -0.5, 0.5, 0.5 }
};
#define ALPHA 0.5
static float ang = 30.;
static gboolean
expose (GtkWidget *da, GdkEventExpose *event, gpointer user_data)
{
GdkGLContext *glcontext = gtk_widget_get_gl_context (da);
GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da);
// g_print (" :: expose\n");
if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
{
g_assert_not_reached ();
}
/* draw in here */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef (ang, 1, 0, 1);
// glRotatef (ang, 0, 1, 0);
// glRotatef (ang, 0, 0, 1);
glShadeModel(GL_FLAT);
#if 0
glBegin (GL_QUADS);
glColor4f(0.0, 0.0, 1.0, ALPHA);
glVertex3fv(boxv[0]);
glVertex3fv(boxv[1]);
glVertex3fv(boxv[2]);
glVertex3fv(boxv[3]);
glColor4f(1.0, 1.0, 0.0, ALPHA);
glVertex3fv(boxv[0]);
glVertex3fv(boxv[4]);
glVertex3fv(boxv[5]);
glVertex3fv(boxv[1]);
glColor4f(0.0, 1.0, 1.0, ALPHA);
glVertex3fv(boxv[2]);
glVertex3fv(boxv[6]);
glVertex3fv(boxv[7]);
glVertex3fv(boxv[3]);
glColor4f(1.0, 0.0, 0.0, ALPHA);
glVertex3fv(boxv[4]);
glVertex3fv(boxv[5]);
glVertex3fv(boxv[6]);
glVertex3fv(boxv[7]);
glColor4f(1.0, 0.0, 1.0, ALPHA);
glVertex3fv(boxv[0]);
glVertex3fv(boxv[3]);
glVertex3fv(boxv[7]);
glVertex3fv(boxv[4]);
glColor4f(0.0, 1.0, 0.0, ALPHA);
glVertex3fv(boxv[1]);
glVertex3fv(boxv[5]);
glVertex3fv(boxv[6]);
glVertex3fv(boxv[2]);
glEnd ();
#endif
glBegin (GL_LINES);
glColor3f (1., 0., 0.);
glVertex3f (0., 0., 0.);
glVertex3f (1., 0., 0.);
glEnd ();
glBegin (GL_LINES);
glColor3f (0., 1., 0.);
glVertex3f (0., 0., 0.);
glVertex3f (0., 1., 0.);
glEnd ();
glBegin (GL_LINES);
glColor3f (0., 0., 1.);
glVertex3f (0., 0., 0.);
glVertex3f (0., 0., 1.);
glEnd ();
glBegin(GL_LINES);
glColor3f (1., 1., 1.);
glVertex3fv(boxv[0]);
glVertex3fv(boxv[1]);
glVertex3fv(boxv[1]);
glVertex3fv(boxv[2]);
glVertex3fv(boxv[2]);
glVertex3fv(boxv[3]);
glVertex3fv(boxv[3]);
glVertex3fv(boxv[0]);
glVertex3fv(boxv[4]);
glVertex3fv(boxv[5]);
glVertex3fv(boxv[5]);
glVertex3fv(boxv[6]);
glVertex3fv(boxv[6]);
glVertex3fv(boxv[7]);
glVertex3fv(boxv[7]);
glVertex3fv(boxv[4]);
glVertex3fv(boxv[0]);
glVertex3fv(boxv[4]);
glVertex3fv(boxv[1]);
glVertex3fv(boxv[5]);
glVertex3fv(boxv[2]);
glVertex3fv(boxv[6]);
glVertex3fv(boxv[3]);
glVertex3fv(boxv[7]);
glEnd();
glPopMatrix ();
if (gdk_gl_drawable_is_double_buffered (gldrawable))
gdk_gl_drawable_swap_buffers (gldrawable);
else
glFlush ();
gdk_gl_drawable_gl_end (gldrawable);
return TRUE;
}
static gboolean
configure (GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
{
GdkGLContext *glcontext = gtk_widget_get_gl_context (da);
GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da);
if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
{
g_assert_not_reached ();
}
glLoadIdentity();
glViewport (0, 0, da->allocation.width, da->allocation.height);
glOrtho (-10,10,-10,10,-20050,10000);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glScalef (10., 10., 10.);
gdk_gl_drawable_gl_end (gldrawable);
return TRUE;
}
static gboolean
rotate (gpointer user_data)
{
GtkWidget *da = GTK_WIDGET (user_data);
ang++;
gdk_window_invalidate_rect (da->window, &da->allocation, FALSE);
gdk_window_process_updates (da->window, FALSE);
return TRUE;
}
int
main (int argc, char **argv)
{
g_signal_connect (da, "configure-event",
G_CALLBACK (configure), NULL);
g_signal_connect (da, "expose-event",
G_CALLBACK (expose), NULL);
gtk_widget_show_all (window);
g_timeout_add (1000 / 60, rotate, da);
gtk_main ();
}
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Metrocoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_HASH_H
#define BITCOIN_HASH_H
#include "uint256.h"
#include "serialize.h"
#include <openssl/sha.h>
#include <openssl/ripemd.h>
#include <vector>
template<typename T1>
inline uint256 Hash(const T1 pbegin, const T1 pend)
{
static unsigned char pblank[1];
uint256 hash1;
SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);
uint256 hash2;
SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
return hash2;
}
class CHashWriter
{
private:
SHA256_CTX ctx;
public:
int nType;
int nVersion;
void Init() {
SHA256_Init(&ctx);
}
CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {
Init();
}
CHashWriter& write(const char *pch, size_t size) {
SHA256_Update(&ctx, pch, size);
return (*this);
}
// invalidates the object
uint256 GetHash() {
uint256 hash1;
SHA256_Final((unsigned char*)&hash1, &ctx);
uint256 hash2;
SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
return hash2;
}
template<typename T>
CHashWriter& operator<<(const T& obj) {
// Serialize to this stream
::Serialize(*this, obj, nType, nVersion);
return (*this);
}
};
template<typename T1, typename T2>
inline uint256 Hash(const T1 p1begin, const T1 p1end,
const T2 p2begin, const T2 p2end)
{
static unsigned char pblank[1];
uint256 hash1;
SHA256_CTX ctx;
SHA256_Init(&ctx);
SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
SHA256_Final((unsigned char*)&hash1, &ctx);
uint256 hash2;
SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
return hash2;
}
template<typename T1, typename T2, typename T3>
inline uint256 Hash(const T1 p1begin, const T1 p1end,
const T2 p2begin, const T2 p2end,
const T3 p3begin, const T3 p3end)
{
static unsigned char pblank[1];
uint256 hash1;
SHA256_CTX ctx;
SHA256_Init(&ctx);
SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0]));
SHA256_Final((unsigned char*)&hash1, &ctx);
uint256 hash2;
SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
return hash2;
}
template<typename T>
uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
{
CHashWriter ss(nType, nVersion);
ss << obj;
return ss.GetHash();
}
inline uint160 Hash160(const std::vector<unsigned char>& vch)
{
uint256 hash1;
SHA256(&vch[0], vch.size(), (unsigned char*)&hash1);
uint160 hash2;
RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
return hash2;
}
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char>& vDataToHash);
#endif
|
/*
* ProjectEuler/src/c/Problem199.c
*
* Iterative Circle Packing
* ========================
* Published on Saturday, 21st June 2008, 06:00 am
*
* Three circles of equal radius are placed inside a larger circle such that
* each pair of circles is tangent to one another and the inner circles do not
* overlap. There are four uncovered "gaps" which are to be filled iteratively
* with more tangent circles. At each iteration, a maximally sized circle
* is placed in each gap, which creates more gaps for the next iteration. After
* 3 iterations (pictured), there are 108 gaps and the fraction of the area
* which is not covered by circles is 0.06790342, rounded to eight decimal
* places. What fraction of the area is not covered by circles after 10
* iterations? Give your answer rounded to eight decimal places using the
* format x.xxxxxxxx .
*/
#include <stdio.h>
#include "ProjectEuler/ProjectEuler.h"
#include "ProjectEuler/Problem199.h"
int main(int argc, char** argv) {
return 0;
} |
//
// AKRAssembly.h
// rss-pumper
//
// Created by Andrey Konstantinov on 07/06/15.
// Copyright (c) 2015 8of. All rights reserved.
//
// Typhoon-фабрика зависимостей между Фабрикой генерации RSS-записей и контроллером RSS-ленты
#import <Typhoon/TyphoonAssembly.h>
#import <Foundation/Foundation.h>
#import "AKRRssService.h"
#import "AKRRssListViewController.h"
@class AKRAssembly;
@class AKRRssService;
@interface AKRAssembly : TyphoonAssembly
- (AKRRssService *)rssService;
- (AKRRssListViewController *)baseViewController;
@end
|
//
// Xml.h
// JLIGameEngineTest
//
// Created by James Folk on 1/8/15.
// Copyright (c) 2015 James Folk. All rights reserved.
//
#ifndef __JLIGameEngineTest__Xml__
#define __JLIGameEngineTest__Xml__
#include "AbstractBuilder.h"
#include "AbstractFactoryObject.h"
#include "lua.hpp"
namespace njli {
class XmlBuilder;
/**
* <#Description#>
*/
ATTRIBUTE_ALIGNED16(class)
Xml : public AbstractFactoryObject
{
friend class WorldFactory;
protected:
Xml();
Xml(const AbstractBuilder&);
Xml(const Xml&);
BT_DECLARE_ALIGNED_ALLOCATOR();
virtual ~Xml();
Xml& operator=(const Xml&);
public:
using AbstractDecorator::setName;
using AbstractDecorator::getName;
using AbstractFactoryObject::create;
// using AbstractFactoryObject::clone;
using AbstractFactoryObject::getPointer;
using AbstractFactoryObject::getPointerValue;
using AbstractFactoryObject::serializeObject;
/**
* <#Description#>
*
* @return <#return value description#>
*/
virtual s32 calculateSerializeBufferSize() const;
/**
* <#Description#>
*
* @param btSerializer <#btSerializer description#>
*/
virtual void serialize(void*, btSerializer*) const;
/**
* <#Description#>
*
* @return <#return value description#>
*/
virtual const char* getClassName() const;
/**
* <#Description#>
*
* @return <#return value description#>
*/
virtual s32 getType() const;
/**
* <#Description#>
*
* @return <#return value description#>
*/
operator std::string() const;
/**
* <#Description#>
*
* @param size <#size description#>
*
* @return <#return value description#>
*/
static Xml** createArray(const u32 size);
/**
* <#Description#>
*
* @param array <#array description#>
*/
static void destroyArray(Xml * *array, const u32 size = 0);
/**
* <#Description#>
*
* @return <#return value description#>
*/
static Xml* create();
/**
* <#Description#>
*
* @param builder <#builder description#>
*
* @return <#return value description#>
*/
static Xml* create(const XmlBuilder& builder);
/**
* <#Description#>
*
* @param object <#object description#>
*
* @return <#return value description#>
*/
static Xml* clone(const Xml& object);
/**
* <#Description#>
*
* @param object <#object description#>
*
* @return <#return value description#>
*/
static Xml* copy(const Xml& object);
/**
* <#Description#>
*
* @param object <#object description#>
*/
static void destroy(Xml * object);
/**
* <#Description#>
*
* @param object <#object description#>
* @param L <#L description#>
* @param stack_index <#stack_index description#>
*/
static void load(Xml & object, lua_State * L, int stack_index);
/**
* <#Description#>
*
* @return <#return value description#>
*/
static u32 type();
public:
//TODO: fill in specific methods for Xml
protected:
private:
};
}
#endif /* defined(__JLIGameEngineTest__Xml__) */
|
#include <stdio.h>
#include <stdlib.h>
// Definição da estrutura da lista
typedef struct{
int tipo;
double tempo;
struct lista * proximo;
} lista;
lista * remover (lista * apontador);
lista * adicionar (lista * apontador, int n_tipo, double n_tempo);
void imprimir (lista * apontador);
|
//
// MyViewController.h
// Project 3
//
// Created by mac on 16/7/14.
// Copyright © 2016年 www. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController
@end
|
#include<stdio.h>
#include<assert.h>
int main() {
int i,j,k;
int x;
// Testing empty if
if (x) {
}
if (x) {
assert(x != 0);
i = 5;
j = 10;
} else {
assert(x == 0);
i = 7;
j = 10;
}
assert(i==5); // UNKNOWN!
assert(i==7); // UNKNOWN!
assert(i != 0);
assert(j == 10);
if (j)
k = 7;
else
k = 8;
assert(k == 7);
switch (x) {
case 5: k = 3 + x; assert (x == 5); break;
case 6: k = 2 + x; assert (x == 6); break;
default: k = 8; assert(x != 5); assert( x!= 6);
}
assert(k == 8);
return 0;
}
|
//
// YASMacros.h
// Copyright (c) 2015 Yuki Yasoshima.
//
// clang-format off
#ifndef __YASMacros_YASMacros_h
#define __YASMacros_YASMacros_h
#if ! __has_feature(objc_arc)
#define YASAutorelease(__v) [__v autorelease]
#define YASRetain(__v) [__v retain]
#define YASRelease(__v) [__v release]
#define YASRetainAndAutorelease(__v) [[__v retain] autorelease]
#define YASSuperDealloc [super dealloc]
#define YASDispatchQueueRelease(__v) dispatch_release(__v)
#else
#define YASAutorelease(__v) __v
#define YASRetain(__v) __v
#define YASRelease(__v)
#define YASRetainAndAutorelease(__v) __v
#define YASSuperDealloc
#if OS_OBJECT_USE_OBJC
#define YASDispatchQueueRelease(__v)
#else
#define YASDispatchQueueRelease(__v) dispatch_release(__v)
#endif
#endif
#if DEBUG
#define YASLog(...) NSLog(__VA_ARGS__)
#else
#define YASLog(...)
#endif
#endif
|
//
// DMHYAPI.h
// DMHY
//
// Created by 小笠原やきん on 15/8/31.
// Copyright © 2015年 yaqinking. All rights reserved.
//
#ifndef DMHYAPI_h
#define DMHYAPI_h
#define DMHYRSS @"https://share.dmhy.org/topics/rss/rss.xml"
#define DMHYSearchByKeyword @"https://share.dmhy.org/topics/rss/rss.xml?keyword=%@"
#define kXpathTorrentDownloadShortURL @"//div[@class='dis ui-tabs-panel ui-widget-content ui-corner-bottom']/a/@href"
#define kTest @"//div[@class='dis']//p//a//@href"
#define DMHYURLPrefixFormat @"https:%@"
#define kXPathTorrentItem @"//item"
#define kDownloadLinkType @"DownloadLinkType"
#define kSavePath @"SavePath"
#define kSelectKeyword @"SelectKeyword"
#define kSelectKeywordIsSubKeyword @"SelectKeywordIsSubKeyword"
#define DMHYDownloadLinkTypeNotification @"DMHYDownloadLinkTypeNotification"
#define DMHYSavePathChangedNotification @"DMHYSavaPathChangedNotification"
#define DMHYSelectKeywordChangedNotification @"DMHYSelectKeywordChangedNotification"
#define DMHYInitialWeekdayCompleteNotification @"DMHYInitialWeekdayCompleteNotification"
#define DMHYKeywordEntityKey @"Keyword"
#endif /* DMHYAPI_h */
|
//
// RSInjectorUtilsTests.h
// InDependence
//
// Created by Yan Rabovik on 27.02.13.
// Copyright (c) 2013 Yan Rabovik. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
@interface INDUtilsTests : SenTestCase
@end
|
#import <Foundation/Foundation.h>
@class IFBKCFMessage;
typedef void (^StreamOpenBlock)(NSHTTPURLResponse* httpResponse);
typedef void (^StreamDidReceiveMessageBlock)(IFBKCFMessage *message);
typedef void (^StreamDidEncounterErrorBlock)(NSError *error);
/**
Provides support for the streaming API of Campfire.
*/
@interface IFBKCampfireStreamingClient : NSObject
/**
The designated initializer.
@param roomId The Campfire API room identifier for which this client will handle the streaming connection.
@param authorizationToken The `API authentication token` available on the `My Info` screen of the Campfire web interface. The streaming API doesn't support OAuth.
*/
- (instancetype)initWithRoomId:(NSNumber *)roomId authorizationToken:(NSString *)authorizationToken;
@property (nonatomic, copy, readonly) NSNumber *roomId;
@property (nonatomic, copy,readonly) NSString *authorizationToken;
/**
Opens the streaming connection.
* @param success A block to be called upon the establishment of the connection; contains the response of the server.
* @param messageReceived A block to be called upon the reception of a new message; contains the received message.
* @param failure A block to be called upon failure; contains an NSError reference. This handle is not called if the connection was cancelled by the client.
*/
- (void)openConnection:(StreamOpenBlock)success messageReceived:(StreamDidReceiveMessageBlock)messageReceived failure:(StreamDidEncounterErrorBlock)failure;
/**
Reopens the streaming connection.
*/
- (void)reopenConnection;
/**
Terminates the streaming connection.
*/
- (void)closeConnection;
@end
|
//
// TriviaSceneQA.h
// Questionable
//
// Created by Nur Monson on 7/13/07.
// Copyright 2007 theidiotproject. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "RectangularBox.h"
#import "StringTexture.h"
#import "ArcTimer.h"
@interface TriviaSceneQA : NSObject <TextureScaling> {
NSSize _size;
float _scale;
RectangularBox *_QATitleBox;
RectangularBox *_QATextBox;
RectangularBox *_shine;
StringTexture *_titleString;
StringTexture *_textString;
ArcTimer *_qTimer;
}
- (void)updateColors;
- (void)setTitle:(NSString *)aTitle text:(NSString *)aText;
- (void)setProgress:(float)newProgress;
@end
|
//----------------------------------------------------------------------------//
//|
//| MachOKit - A Lightweight Mach-O Parsing Library
//! @file MKNodeFieldExportKindType.h
//!
//! @author D.V.
//! @copyright Copyright (c) 2014-2015 D.V. All rights reserved.
//|
//| Permission is hereby granted, free of charge, to any person obtaining a
//| copy of this software and associated documentation files (the "Software"),
//| to deal in the Software without restriction, including without limitation
//| the rights to use, copy, modify, merge, publish, distribute, sublicense,
//| and/or sell copies of the Software, and to permit persons to whom the
//| Software is furnished to do so, subject to the following conditions:
//|
//| The above copyright notice and this permission notice shall be included
//| in all copies or substantial portions of the Software.
//|
//| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
//| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
//| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#include <mach-o/loader.h>
#import <MachOKit/MKNodeFieldTypeByte.h>
#import <MachOKit/MKNodeFieldEnumerationType.h>
// <https://opensource.apple.com/source/dyld/dyld-519.2.1/src/ImageLoaderMachOCompressed.cpp.auto.html>
#ifndef EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE
#define EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE 0x02
#endif
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name Export Kind
//! @relates MKNodeFieldExportKindType
//!
//
typedef uint8_t MKExportKind NS_TYPED_EXTENSIBLE_ENUM;
static const MKExportKind MKExportKindRegular = EXPORT_SYMBOL_FLAGS_KIND_REGULAR;
static const MKExportKind MKExportKindThreadLocal = EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL;
static const MKExportKind MKExportKindAbsolute = EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE;
//----------------------------------------------------------------------------//
@interface MKNodeFieldExportKindType : MKNodeFieldTypeUnsignedByte <MKNodeFieldEnumerationType>
+ (instancetype)sharedInstance;
@end
NS_ASSUME_NONNULL_END
|
//
// IMAppDepedencies.h
// iTunesMusic
//
// Created by Toni on 13/01/16.
// Copyright © 2016 Toni. All rights reserved.
//
#import <Foundation/Foundation.h>
@import UIKit;
@interface IMAppDependencies : NSObject
- (void)installRootViewControllerIntoWindow:(UIWindow *)window;
@end
|
#ifndef __TCAR_DXT_IMAGE_H__
#define __TCAR_DXT_IMAGE_H__
#include <array>
#include <cstring>
#include <cstdint>
#include <memory>
#include <vector>
#include "image.h"
namespace GenTC {
union PhysicalDXTBlock {
struct {
uint16_t ep1;
uint16_t ep2;
uint32_t interpolation;
};
uint64_t dxt_block;
};
struct LogicalDXTBlock {
uint8_t ep1[4];
uint8_t ep2[4];
uint8_t palette[4][4];
uint8_t indices[16];
LogicalDXTBlock &operator=(const LogicalDXTBlock &other) {
memcpy(this, &other, sizeof(*this));
return *this;
}
bool operator==(const LogicalDXTBlock &other) const {
return memcmp(this, &other, sizeof(*this)) == 0;
}
};
class DXTImage {
public:
DXTImage(const char *orig_fn, const char *cmp_fn);
DXTImage(int width, int height, const uint8_t *rgb_data);
DXTImage(int width, int height, const std::vector<uint8_t> &rgb_data,
const std::vector<uint8_t> &dxt_data);
DXTImage(int width, int height, const std::vector<uint8_t> &dxt_data);
int Width() const { return _width; }
int Height() const { return _height; }
int BlocksWide() const { return _blocks_width; }
int BlocksHigh() const { return _blocks_height; }
// RGBA image
std::unique_ptr<RGBAImage> EndpointOneImage() const;
std::unique_ptr<RGBAImage> EndpointTwoImage() const;
std::unique_ptr<RGBAImage> DecompressedImage() const;
// RGB 565 separated into bytes
std::unique_ptr<RGB565Image> EndpointOneValues() const;
std::unique_ptr<RGB565Image> EndpointTwoValues() const;
static std::vector<uint8_t> TwoBitValuesToImage(const std::vector<uint8_t> &v);
// Byte-wise image where each byte takes on of four values in [0, 255]
std::vector<uint8_t> InterpolationImage() const {
return std::move(TwoBitValuesToImage(InterpolationValues()));
}
// Original interpolation values
std::vector<uint8_t> InterpolationValues() const;
const std::vector<PhysicalDXTBlock> &PhysicalBlocks() const {
return _physical_blocks;
}
const std::vector<LogicalDXTBlock> &LogicalBlocks() const {
return _logical_blocks;
}
const LogicalDXTBlock &LogicalBlockAt(int x, int y) const {
return _logical_blocks[BlockAt(x, y)];
}
const PhysicalDXTBlock &PhysicalBlockAt(int x, int y) const {
return _physical_blocks[BlockAt(x, y)];
}
uint8_t InterpolationValueAt(int x, int y) const;
void GetColorAt(int x, int y, uint8_t out[4]) const;
std::vector<uint8_t> PredictIndices(int chunk_width, int chunk_height) const;
std::vector<uint8_t> PredictIndicesLinearize(int chunk_width, int chunk_height) const;
void ReassignIndices(int mse_threshold);
std::vector<uint8_t> PaletteData() const;
const std::vector<uint8_t> &IndexDiffs() const { return _indices; }
private:
uint32_t BlockAt(int x, int y) const {
return (y / 4) * _blocks_width + (x / 4);
}
void Reencode();
double PSNR() const;
int _width;
int _height;
int _blocks_width;
int _blocks_height;
std::vector<PhysicalDXTBlock> _physical_blocks;
std::vector<LogicalDXTBlock> _logical_blocks;
std::vector<uint32_t> _index_palette;
std::vector<uint8_t> _indices;
std::vector<uint8_t> _src_img;
};
} // namespace GenTC
#endif
|
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2017 Torus Knot Software Ltd
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 _OgreMetalPixelFormatToShaderType_H_
#define _OgreMetalPixelFormatToShaderType_H_
#include "OgreMetalPrerequisites.h"
#include "OgrePixelFormat.h"
namespace Ogre
{
class _OgreMetalExport MetalPixelFormatToShaderType : public PixelFormatToShaderType
{
public:
virtual const char* getPixelFormatType( PixelFormat pixelFormat ) const;
};
}
#endif
|
// LAF OS Library
// Copyright (C) 2018-2020 Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef OS_OSX_COLOR_SPACE_H_INCLUDED
#define OS_OSX_COLOR_SPACE_H_INCLUDED
#pragma once
#include "os/color_space.h"
#ifdef __OBJC__
#include <Cocoa/Cocoa.h>
#endif
#include <vector>
namespace os {
#ifdef __OBJC__
os::ColorSpaceRef convert_nscolorspace_to_os_colorspace(NSColorSpace* nsColorSpace);
#endif
void list_display_colorspaces(std::vector<os::ColorSpaceRef>& list);
} // namespace os
#endif
|
#ifndef _FIFO
#define _FIFO
#include <vector>
#include "datatypes.h"
#include "sub.h"
namespace ps2emu
{
enum FIFO_REGISTERS {
VIF1_FIFO, IPU_out_FIFO
};
static const char *tFIFO_REGISTERS[] = {
"VIF1_FIFO", "IPU_out_FIFO"
};
class FIFO : public SubSystem {
public:
FIFO();
~FIFO();
static const int nREGISTERS;
std::vector<std::string> getRegisterText(const int reg);
private:
std::vector<std::string> unpack_VIF1_FIFO(const int reg);
std::vector<std::string> unpack_IPU_out_FIFO(const int reg);
};
#endif
}
|
#include <string>
class SharedLibrary {
public:
static char * getTemplateInfo();
SharedLibrary();
~SharedLibrary();
std::string hello(std::string world);
};
|
/*
* Generated by class-dump 3.3.3 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2010 by Steve Nygard.
*/
#import "NSTableHeaderCell.h"
@interface _MTMHeaderCell : NSTableHeaderCell
{
}
- (struct CGRect)drawingRectForBounds:(struct CGRect)arg1;
- (struct CGRect)sortIndicatorRectForBounds:(struct CGRect)arg1;
@end
|
#ifndef _LABELTESTLAYER_H_
#define _LABELTESTLAYER_H_
#include "cocos2d.h"
#include "cocos-ext.h"
class LabelTestLayer : public cocos2d::Layer {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(LabelTestLayer, create);
};
#endif |
//
// AZZJiraCreateIssueInputModel.h
// BugReporter
//
// Created by 朱安智 on 2016/11/25.
// Copyright © 2016年 Andrew. All rights reserved.
//
#import <Mantle/Mantle.h>
#import "AZZJiraProjectsModel.h"
#import "AZZJiraIssueTypeModel.h"
#import "AZZJiraUserModel.h"
#import "AZZJiraIssuePriorityModel.h"
#import "AZZJiraIssueVersionModel.h"
#import "AZZJiraComponentModel.h"
#import "AZZJiraIssueAttachment.h"
@interface AZZJiraCreateIssueInputModel : MTLModel<MTLJSONSerializing>
@property (nonatomic, copy) NSDictionary *update;
@property (nonatomic, copy) AZZJiraProjectsModel *project;
@property (nonatomic, copy) NSString *summary;
@property (nonatomic, copy) AZZJiraIssueTypeModel *issuetype;
@property (nonatomic, copy) AZZJiraUserModel *assignee;
@property (nonatomic, copy) AZZJiraUserModel *reporter;
@property (nonatomic, copy) NSDate *duedate;
@property (nonatomic, copy) AZZJiraIssuePriorityModel *priority;
@property (nonatomic, copy) NSArray *labels;
@property (nonatomic, copy) NSArray<AZZJiraIssueVersionModel *> *versions;
@property (nonatomic, copy) NSString *environment;
@property (nonatomic, copy) NSString *modelDescription;
@property (nonatomic, copy) NSArray<AZZJiraIssueVersionModel *> *fixVersions;
@property (nonatomic, copy) NSArray<AZZJiraComponentModel *> *components;
@property (nonatomic, copy) NSArray<AZZJiraIssueAttachment *> *attachment;
- (NSDictionary *)getJSONModel;
@end
|
//
// SKKeyframeSequence.h
// SpriteKit
//
// Created by Tim Oriol on 2/25/13.
//
//
#import <SpriteKit/SpriteKitBase.h>
typedef NS_ENUM(NSInteger, SKInterpolationMode) {
SKInterpolationModeLinear = 1,
SKInterpolationModeSpline = 2,
SKInterpolationModeStep = 3,
};
typedef NS_ENUM(NSInteger, SKRepeatMode) {
SKRepeatModeClamp = 1,
SKRepeatModeLoop = 2,
};
NS_ASSUME_NONNULL_BEGIN
SK_EXPORT @interface SKKeyframeSequence : NSObject <NSCoding, NSCopying>
/* Designated initializer */
- (instancetype)initWithKeyframeValues:(NSArray*)values times:(NSArray<NSNumber*> *)times NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCapacity:(NSUInteger)numItems;
/**
Support coding and decoding via NSKeyedArchiver.
*/
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
- (NSUInteger)count;
- (void)addKeyframeValue:(id)value time:(CGFloat)time;
- (void)removeLastKeyframe;
- (void)removeKeyframeAtIndex:(NSUInteger)index;
- (void)setKeyframeValue:(id)value forIndex:(NSUInteger)index;
- (void)setKeyframeTime:(CGFloat)time forIndex:(NSUInteger)index;
- (void)setKeyframeValue:(id)value time:(CGFloat)time forIndex:(NSUInteger)index;
- (id)getKeyframeValueForIndex:(NSUInteger)index;
- (CGFloat)getKeyframeTimeForIndex:(NSUInteger)index;
- (nullable id)sampleAtTime:(CGFloat)time;
/* defaults to SKInterpolationModeLinear */
@property (nonatomic) SKInterpolationMode interpolationMode;
/* defaults to SKRepeatModeClamp */
@property (nonatomic) SKRepeatMode repeatMode;
@end
NS_ASSUME_NONNULL_END
|
/**
* @brief NID lookup system
*/
#ifndef TAI_MODULE_HEADER
#define TAI_MODULE_HEADER
#include "taihen_internal.h"
/**
* @defgroup module NID Lookup Interface
*/
/** @{ */
int module_get_by_name_nid(SceUID pid, const char *name, uint32_t nid, tai_module_info_t *info);
int module_get_offset(SceUID pid, SceUID modid, int segidx, size_t offset, uintptr_t *addr);
int module_get_export_func(SceUID pid, const char *modname, uint32_t libnid, uint32_t funcnid, uintptr_t *func);
int module_get_import_func(SceUID pid, const char *modname, uint32_t target_libnid, uint32_t funcnid, uintptr_t *stub);
/** @} */
#endif // TAI_MODULE_HEADER
|
#pragma once
#include "Application.h"
#include "Globals.h"
#include <string>
class IJsonSerializable;
class JsonSerializer
{
public:
static bool Serialize(IJsonSerializable* pObj, std::string& output, std::string path);
static bool Deserialize(IJsonSerializable* pObj, std::string& input);
static bool Deserialize(IJsonSerializable* pObj, std::string path);
private:
JsonSerializer();
};
|
//
// Header.h
// IGJavaScriptConsole
//
// Created by Chong Francis on 14年1月13日.
// Copyright (c) 2014年 Francis Chong. All rights reserved.
//
#ifndef _IGJavaScriptConsole_
#define _IGJavaScriptConsole_
#import "IGJSConsoleConnection.h"
#import "IGJavaScriptEvaulatorWebSocket.h"
#import "IGRubyEvaulatorWebSocket.h"
#import "IGJavaScriptConsoleServer.h"
#endif
|
// Copyright (c) 2017-2021 Andrey Valyaev <dron.valyaev@gmail.com>
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
#pragma once
#include "Text.h"
namespace oout {
/// Text for string
class StringText final : public Text {
public:
/// Primary ctor
explicit StringText(const std::string &value);
/// Get value as string
std::string asString() const override;
private:
const std::string value;
};
}
|
//#define dimof(x) (sizeof(x) / sizeof(x[0]))
void *LoadFile(const char *fileName, int* size = nullptr);
bool SaveFile(const char *fileName, const uint8_t* buf, int size);
double GetTime();
float Random();
void GoMyDir();
void Toast(const char *text);
void PlayBgm(const char *fileName);
bool LoadImageViaGdiPlus(const char* name, IVec2& size, std::vector<uint32_t>& col);
SRVID LoadTextureViaOS(const char* name, IVec2& size);
template <class T, size_t N> inline size_t dimof(T(&)[N])
{
return N;
}
template <class T> inline void SAFE_DELETE(T& p)
{
delete p;
p = nullptr;
}
template <class T> inline void SAFE_RELEASE(T& p)
{
if (p) {
p->Release();
p = nullptr;
}
}
IBOID afCreateTiledPlaneIBO(int numTiles, int* numIndies = nullptr);
VBOID afCreateTiledPlaneVBO(int numTiles);
struct TexDesc {
IVec2 size;
int arraySize = 1;
bool isCubeMap = false;
};
SRVID afLoadTexture(const char* name, TexDesc& desc);
|
#pragma once
#include <string>
class FibonacciFinder
{
public:
FibonacciFinder(std::string newName);
std::string name;
unsigned long long findNextNumber(unsigned long long prePreviousMember, unsigned long long previousMember);
};
|
/**
* @file Wheel.h
* @brief Содержит объявление класса Wheel
* @author Shazhko Artem
* @version 0
* @date 18.09.17
*/
#pragma once
#include <string>
#include "StorageInterface.h"
#include "Units.hpp"
#include <iostream>
namespace Wheel {
/**
* Класс описывающий колесо
*/
class Wheel : public MStorageInterface {
public:
/**
* Конструктор по-умолчанию
*/
Wheel();
/**
* Конструктор с тремя параметром
* @param _diameter Диаметр
* @param _width Шырина
* @param _unit Единицы измерения
*/
Wheel(double _diameter, double _width, EUnits _unit);
/**
* Конструктор копировнаия
* @param wheel копируемый объект
*/
Wheel(const Wheel *wheel);
/**
* Зберігає дані в потік
* @param aStream Відкритий потік для збереження даних
*/
virtual void OnStore(std::ostream& aStream);
/**
* Завантажує дані із потоку
* @param aStream Відкритий потік для завантаження даних
*/
virtual void OnLoad(std::istream& aStream);
/**
* Деструктор
*/
virtual ~Wheel();
/**
* Подсчет объема колеса
* @return Объем колеса
*/
double Volume() const;
/**
* Задать диаметр
* @param _diameter диаметр
*/
void SetDiameter(const double _diameter);
/**
* Задать ширину
* @param _width ширина
*/
void SetWidth(const double _width);
/**
* Задать единицы измерения
* @param _units единицы измерения
*/
void SetUnits(const EUnits _units);
/**
* Возвращает единицы измерения
* @return Объем колеса
*/
EUnits GetUnits() const;
/**
* Возвращает диаметр
* @return диаметр
*/
double GetDiameter() const;
/**
* Возвращает ширину
* @return ширина
*/
double GetWidth() const;
virtual bool operator==(Wheel const &arg);
protected:
// Единицы измерения
EUnits units;
// Диаметр
double diameter;
// ширина
double width;
};
} |
/*
Copyright 2016 Matthew Holder
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.
*/
#pragma once
#include "Battery.h"
class CCommandProcessor
{
public:
CCommandProcessor() noexcept = default;
CCommandProcessor(CCommandProcessor &&) = delete;
CCommandProcessor(const CCommandProcessor &) = delete;
CCommandProcessor &operator =(CCommandProcessor &&) = delete;
CCommandProcessor &operator =(const CCommandProcessor &) = delete;
~CCommandProcessor() noexcept = default;
HRESULT Initialize() noexcept;
HRESULT Eval(_In_z_ LPCSTR pszCommandLine, CComPtr<IReplResult> &rpResult) noexcept;
BOOL Continue() const noexcept { return TRUE; }
LPCSTR ReportError(HRESULT hr, LPCSTR) noexcept;
HRESULT DefaultResult(CStringA &strResult) noexcept;
private:
typedef HRESULT(CCommandProcessor::*PFNCOMMAND)(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult);
static const int LAST_ERROR_BUFFER_LENGTH = 256;
CAtlMap<CStringA, PFNCOMMAND> m_rgPrimeHandlers;
CAtlMap<CStringA, PFNCOMMAND> m_rgListHandlers;
CAtlMap<CStringA, PFNCOMMAND> m_rgGetHandlers;
CAtlMap<HRESULT, CStringA> m_rgErrors;
CHeapPtr<CHAR> m_pszLastError;
CComPtr<CBatteryCollection> m_pBatteries;
CStringA m_strUserName;
CStringA m_strPassWord;
LPCSTR GetPart(_Inout_z_ LPSTR &pszLine) noexcept;
// Primary Commands:
HRESULT OnStartTls(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
HRESULT OnUserName(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
HRESULT OnPassWord(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
HRESULT OnGet(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
HRESULT OnList(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
HRESULT OnLogin(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
HRESULT OnLogout(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
// Sub-commands:
HRESULT OnGetVar(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
HRESULT OnListUps(_In_z_ LPSTR pszParameters, CComPtr<IReplResult> &rpResult) noexcept;
};
#include "CommandProcessor.inl.h"
|
#ifndef _BITMAP_H_
# define _BITMAP_H_
# include <stdio.h>
# include <stdlib.h>
# include <errno.h>
# include <windows.h>
# include <wingdi.h>
# include <GL/gl.h>
/*
* Make this header file work with C and C++ source code...
*/
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
extern void *LoadDIBitmap(char *filename, BITMAPINFO **info);
extern int SaveDIBitmap(char *filename, BITMAPINFO *info, void *bits);
extern void *ReadDIBitmap(BITMAPINFO **info);
extern int PrintDIBitmap(HWND owner, BITMAPINFO *info, void *bits);
extern GLubyte *ConvertRGB(BITMAPINFO *info, void *bits);
# ifdef __cplusplus
}
# endif /* __cplusplus */
#endif /* !_BITMAP_H_ */
|
#include "dht11.h"
void initDHT11()
{
lststate = 1;
counter = 0;
j = 0;
i = 0;
farenheit = 0;
for(i = 0; i < NUMBER_OF_DATA_BITS; i++)
{
dht11_val[i] = 0;
}
output_GPIO(DHT11PIN);
low_GPIO(DHT11PIN);//MCU will set voltage level from high to low
sleepMicro(FALLING_EDGE_INIT_DELAY);//and this process must take at least 18milliSeconds
high_GPIO(DHT11PIN); //pulling the pin high for 40 microseconds
sleepMicro(RISING_EDGE_INIT_DELAY);
input_GPIO(DHT11PIN); //setting te pin as input in order to read the DHT11 output
}
void getData()
{
for(i = 0; i < MAX_TIME; i++)
{
counter = 0;
while(read_GPIO(DHT11PIN) == lststate)
{
counter++;
sleepMicro(1);
if(counter == 255)
{
break;
}
}
lststate = read_GPIO(DHT11PIN);
if(counter == 255)
{
break;
}
// top 3 transistions are ignored
if( (i >= 4) && (i % 2 == 0) )
{
dht11_val[j/8] <<= 1;
if(counter > 16)
{
dht11_val[j/8] |= 1;
}
j++;
}
}
}
void checkSum()
{
// verify cheksum and print the verified data
if ( (j >= 40)
&&
( dht11_val[4] == ( (dht11_val[0] + dht11_val[1] + dht11_val[2] + dht11_val[3] ) & 0xFF) )
)
{
farenheit = dht11_val[2] * 9./5. + 32;
printf("Temperature = %d.%d *C (%.1f *F) Humidity = %d.%d %%\n",dht11_val[2], dht11_val[3], farenheit, dht11_val[0], dht11_val[1]);
temperature_humidity_global[0] = dht11_val[0];//Humidity
temperature_humidity_global[1] = dht11_val[2];//Temperature
}
else
{
printf("Invalid Data!!\n");
}
}
void readDHT11()
{
initDHT11();
getData();
checkSum();
}
|
//
// NCSetting+CoreDataProperties.h
// Neocom
//
// Created by Artem Shimanski on 16.02.16.
// Copyright © 2016 Shimanski Artem. All rights reserved.
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "NCSetting.h"
NS_ASSUME_NONNULL_BEGIN
@interface NCSetting (CoreDataProperties)
@property (nullable, nonatomic, retain) NSString *key;
@property (nullable, nonatomic, retain) id value;
@end
NS_ASSUME_NONNULL_END
|
//
// SearchMapController.h
// QiPinTong
//
// Created by 企聘通 on 2017/5/23.
// Copyright © 2017年 ShiJiJiaLian. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol SearchResultViewDelegate <NSObject>
@optional
-(void)didSelectRowIndexPath:(NSIndexPath *)indexPath andAreaText:(NSString *)area;
-(void)closeSearchState;
@end
@interface SearchMapController : UITableViewController
@property (nonatomic ,strong) NSMutableArray *mapArray;
@property (nonatomic ,copy) NSString *keyWords;//关键字
@property (nonatomic ,copy) NSString *currentCity;
@property (nonatomic ,assign) id <SearchResultViewDelegate> delegate;
-(void)loadSearchMapDataWith:(NSString *)keyWord andCity:(NSString *)city;
@end
|
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "../include/itoa.h"
/*
* Traditional itoa() implementation
*/
char *
int_itoa(int num, int base)
{
char *reference_chars = "0123456789abcdef";
unsigned int n_chars;
char *output;
char *w;
bool is_negative = (num < 0);
/* Calculate output length */
num = abs(num);
n_chars = (int32_t)ceil(log((double)num) / log((double)base));
if (is_negative) {
n_chars++;
}
/* Check the output base and allocate space for prefixes */
if (base < 2 || base > 16) {
return NULL;
} else if (base == 2 || base == 16) {
n_chars += 2;
} else if (base == 8) {
n_chars++;
}
output = calloc(n_chars, sizeof(char));
w = output + n_chars;
/* Working backwards, NUL-terminator */
*(w--) = '\0';
/* Working backwards, calculate and add the characters */
while (num > 0) {
int digit = num % base;
*(w--) = reference_chars[digit];
num /= base;
}
/* Add base-specific prefixes */
if (base == 2) {
*(w--) = 'b';
*(w--) = '0';
} else if (base == 16) {
*(w--) = 'x';
*(w--) = '0';
} else if (base == 8) {
*(w--) = '0';
}
/* add the negative sign if necessary */
if (is_negative) {
*w = '-';
}
return output;
}
|
//
// NSOperationTestViewController.h
// NSLockTest
//
// Created by yixiaoluo on 15/3/2.
// Copyright (c) 2015年 cn.gikoo. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NSOperationTest : UIViewController
@end
/**
* NSOperation本身是个抽象类,不能直接使用,只能使用系统封装好的NSBlockOperation和NSInvocationOperation,或者自己定制一个
* 这个类我们封装了一个用于图片下载的operation
*/
typedef NS_ENUM(NSUInteger, DownloadStatus) {
kDownloading,
kDownloaded,
kUnstart
};
@interface ImageDownloadOperation : NSOperation
- (instancetype)initWithImageURL:(NSURL *)url
compeltion:(void(^)(UIImage *image))downloadCompletion;
@end
|
//
// CCHTransportClientDelegate.h
// CCHTransportClient
//
// Copyright (C) 2015 Claus Höfele
//
// 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>
NS_ASSUME_NONNULL_BEGIN
@protocol CCHTransportClient;
@protocol CCHTransportClientDelegate <NSObject>
@optional
- (void)transportClientWillStartRequest:(NSObject<CCHTransportClient> *)transportClient;
- (void)transportClientDidFinishRequest:(NSObject<CCHTransportClient> *)transportClient;
@end
NS_ASSUME_NONNULL_END |
//
// iOS_Test_AppViewController.h
// iOS Test App
//
// Created by John Sheets on 11/1/10.
// Copyright (c) 2010 MobileMethod, LLC. All rights reserved.
//
// MIT License
//
// 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 <UIKit/UIKit.h>
@interface iOS_Test_AppViewController : UIViewController
{
}
@end
|
#include "mt_clock_internal.h"
#include "mt_clock_serv_internal.h"
#include <mach/clock.h>
#include <mach/clock_priv.h> /* the priv is for privileged */
#include <mach/mach_host.h>
#include <pthread.h>
#include <errno.h>
clock_serv_t
mt_clock_serv_monotonic(void)
{
static clock_serv_t clock = MACH_PORT_NULL;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
if (clock != MACH_PORT_NULL)
return clock;
int error = pthread_mutex_lock(&mutex);
if (error) {
errno = error;
return MACH_PORT_NULL;
}
if (clock == MACH_PORT_NULL) {
kern_return_t kerror =
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock);
if (kerror != KERN_SUCCESS)
errno = EINVAL;
}
pthread_mutex_unlock(&mutex);
return clock;
}
clock_serv_t
mt_clock_serv_realtime(void)
{
static clock_serv_t clock = MACH_PORT_NULL;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
if (clock != MACH_PORT_NULL)
return clock;
int error = pthread_mutex_lock(&mutex);
if (error) {
errno = error;
return MACH_PORT_NULL;
}
if (clock == MACH_PORT_NULL) {
kern_return_t kerror =
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &clock);
if (kerror != KERN_SUCCESS)
errno = EINVAL;
}
pthread_mutex_unlock(&mutex);
return clock;
}
int
mt_clock_serv_getres(clock_serv_t serv, struct timespec *res)
{
clock_res_t nsec;
mach_msg_type_number_t count;
if (serv == MACH_PORT_NULL) {
errno = EINVAL;
return -1;
}
kern_return_t error =
clock_get_attributes(serv, CLOCK_GET_TIME_RES, &nsec, &count);
if (error != KERN_SUCCESS) {
errno = EINVAL;
return -1;
}
res->tv_sec = nsec / MT_NSEC_PER_SEC;
res->tv_nsec = nsec % MT_NSEC_PER_SEC;
return 0;
}
int
mt_clock_serv_gettime(clock_serv_t serv, struct timespec *ts)
{
mach_timespec_t mts;
kern_return_t error = clock_get_time(serv, &mts);
if (serv == MACH_PORT_NULL) {
errno = EINVAL;
return -1;
}
if (error != KERN_SUCCESS) {
errno = EINVAL;
return -1;
}
ts->tv_sec = mts.tv_sec;
ts->tv_nsec = mts.tv_nsec;
return 0;
}
int
mt_clock_serv_settime(clock_serv_t serv, const struct timespec *ts)
{
mach_timespec_t mts = { ts->tv_sec, ts->tv_nsec };
if (serv == MACH_PORT_NULL) {
errno = EINVAL;
return -1;
}
/* This should always fail, but we'll give it a shot. */
kern_return_t error = clock_set_time(serv, mts);
if (error != KERN_SUCCESS) {
errno = EPERM;
return -1;
}
return 0;
}
|
//
// HWImageView.h
// Pods
//
// Created by HOMWAY on 27/03/2017.
//
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface HWImageView : UIView
@property(nonatomic, strong, readonly) UIImageView *imageView;
@property(nonatomic, strong, readonly) UITapGestureRecognizer *doubleTapGesture;
@end
NS_ASSUME_NONNULL_END
|
/*
* Copyright (c) 2017 FilipeCN
*
* The MIT License (MIT)
*
* 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 PONOS_GEOMETRY_PARAMETRIC_SURFACE_H
#define PONOS_GEOMETRY_PARAMETRIC_SURFACE_H
#include <ponos/geometry/surface.h>
namespace ponos {
/** Interface for parametric surfaces imerse in 2D.
*/
class ParametricCurveInterface {
public:
ParametricCurveInterface() {}
virtual ~ParametricCurveInterface() {}
virtual point2 operator()(real_t t) const = 0;
};
} // namespace ponos
#endif // PONOS_GEOMETRY_PARAMETRIC_SURFACE_H
|
// This file is part of the uSTL library, an STL implementation.
//
// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
// This file is free software, distributed under the MIT License.
#pragma once
#include "uexception.h"
/// Just like malloc, but throws on failure.
extern "C" void* tmalloc (size_t n) __attribute__((malloc));
/// Just like free, but doesn't crash when given a nullptr.
extern "C" void nfree (void* p) noexcept;
#if __clang__
// Turn off exception spec warnings for operator new/delete
// uSTL does not use explicit throw specifications on them
#pragma GCC diagnostic ignored "-Wmissing-exception-spec"
#endif
//
// These are replaceable signatures:
// - normal single new and delete (no arguments, throw @c bad_alloc on error)
// - normal array new and delete (same)
// - @c nothrow single new and delete (take a @c nothrow argument, return
// @c nullptr on error)
// - @c nothrow array new and delete (same)
//
// Placement new and delete signatures (take a memory address argument,
// does nothing) may not be replaced by a user's program.
//
void* operator new (size_t n);
void* operator new[] (size_t n);
void operator delete (void* p) noexcept;
void operator delete[] (void* p) noexcept;
void operator delete (void* p, size_t) noexcept;
void operator delete[] (void* p, size_t) noexcept;
// Default placement versions of operator new.
inline void* operator new (size_t, void* p) noexcept { return p; }
inline void* operator new[] (size_t, void* p) noexcept { return p; }
// Default placement versions of operator delete.
inline void operator delete (void*, void*) noexcept { }
inline void operator delete[](void*, void*) noexcept { }
|
//
// IDPStorageCacheManager.h
// IDPCompositePixStorage
//
// Created by 能登 要 on 2015/07/26.
// Copyright (c) 2015年 Irimasu Densan Planning. All rights reserved.
//
#import <UIKit/UIKit.h>
@class BFTask;
@interface IDPStorageCacheManager : NSObject
+ (instancetype) defaultManager;
- (NSOperation *) imageLoadWithPath:(NSString *)path completion:(void (^)(UIImage *image,NSError *error))completion;;
- (void) storeImage:(UIImage *)image withPath:(NSString *)path completion:(void (^)(NSError *error))completion;
- (void) storeData:(NSData *)data withPath:(NSString *)path completion:(void (^)(NSError *error))completion;
// for debug methods
- (void) clearAllCaches;
@end
|
//
// Stats.h
// coffeekit
//
// Created by giaunv on 4/4/15.
// Copyright (c) 2015 366. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Stats : NSObject
@property (nonatomic, strong) NSNumber *checkins;
@property (nonatomic, strong) NSNumber *tips;
@property (nonatomic, strong) NSNumber *users;
@end
|
/*
Copyright (c) 2012 <benemorius@gmail.com>
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.
*/
#define DELAY50MS() for(uint32_t i = 0; i < 416635; i++)
#define DELAY250MS() for(uint32_t i = 0; i < 2083175; i++)
#define DEBOUNCE_DELAY (20)
#define REFERENCE_VOLTAGE (3.0f)
extern "C" char* get_stack_top(void);
extern "C" char* get_heap_end(void);
#define SD_PRESENT_PORTNUM (0)
#define SD_PRESENT_PINNUM (5)
#define SPI0_MOSI_PORT (0)
#define SPI0_MOSI_PIN (18)
#define SPI0_MISO_PORT (0)
#define SPI0_MISO_PIN (17)
#define SPI0_SCK_PORT (0)
#define SPI0_SCK_PIN (15)
#define SPI0_CLOCKRATE (100000)
#define SPI1_MOSI_PORT (0)
#define SPI1_MOSI_PIN (9)
#define SPI1_MISO_PORT (0)
#define SPI1_MISO_PIN (8)
#define SPI1_SCK_PORT (0)
#define SPI1_SCK_PIN (7)
#define SPI1_CLOCKRATE (100000)
#define LCD_SELECT_PORT (2)
#define LCD_SELECT_PIN (7)
#define LCD_REFRESH_PORT (1)
#define LCD_REFRESH_PIN (28)
#define LCD_UNK0_PORT (2)
#define LCD_UNK0_PIN (5)
#define LCD_UNK1_PORT (2)
#define LCD_UNK1_PIN (6)
#define LCD_RESET_PORT (0)
#define LCD_RESET_PIN (22)
#define DEBUG_TX_PORTNUM (0)
#define DEBUG_TX_PINNUM (2)
#define DEBUG_RX_PORTNUM (0)
#define DEBUG_RX_PINNUM (3)
#define DEBUG_BAUD (115200)
#define KLINE_TX_PORTNUM (4)
#define KLINE_TX_PINNUM (28)
#define KLINE_RX_PORTNUM (4)
#define KLINE_RX_PINNUM (29)
#define KLINE_BAUD (9600)
#define LLINE_TX_PORTNUM (2)
#define LLINE_TX_PINNUM (8)
#define LLINE_RX_PORTNUM (2)
#define LLINE_RX_PINNUM (9)
#define LLINE_BAUD (9600)
#define LCD_BACKLIGHT_PORT (1)
#define LCD_BACKLIGHT_PIN (23)
#define CLOCK_BACKLIGHT_PORT (3)
#define CLOCK_BACKLIGHT_PIN (25)
#define LCD_BIASCLOCK_PORT (1)
#define LCD_BIASCLOCK_PIN (26)
#define KEYPAD_BACKLIGHT_PORT (3)
#define KEYPAD_BACKLIGHT_PIN (26)
#define OUT_RESET_PORT (0)
#define OUT_RESET_PIN (19)
#define OUT0_CS_PORT (0)
#define OUT0_CS_PIN (20)
#define OUT1_CS_PORT (2)
#define OUT1_CS_PIN (3)
#define RUN_PORT (2)
#define RUN_PIN (11)
#define SDCARD_DETECT_PORT (1)
#define SDCARD_DETECT_PIN (17)
#define SDCARD_CS_PORT (1)
#define SDCARD_CS_PIN (16)
#define CCM_DATA_PORT (1)
#define CCM_DATA_PIN (9)
#define CCM_CLOCK_PORT (1)
#define CCM_CLOCK_PIN (4)
#define CCM_LATCH_PORT (1)
#define CCM_LATCH_PIN (8)
#define FUEL_LEVEL_PORT (0)
#define FUEL_LEVEL_PIN (6)
#define STALK_BUTTON_PORT (2)
#define STALK_BUTTON_PIN (10)
#define SPEED_PORT (0)
#define SPEED_PIN (4)
#define FUEL_CONS_PORT (0)
#define FUEL_CONS_PIN (5)
#define BATTERY_VOLTAGE_PORT (0)
#define BATTERY_VOLTAGE_PIN (25)
#define EXT_TEMP_PORT (0)
#define EXT_TEMP_PIN (23)
|
/*
* Heap compiled function (Ecmascript function) representation.
*
* There is a single data buffer containing the Ecmascript function's
* bytecode, constants, and inner functions.
*/
#ifndef DUK_HCOMPILEDFUNCTION_H_INCLUDED
#define DUK_HCOMPILEDFUNCTION_H_INCLUDED
/*
* Accessor macros for function specific data areas
*/
/* Note: assumes 'data' is always a fixed buffer */
#define DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE(h) \
DUK_HBUFFER_FIXED_GET_DATA_PTR((duk_hbuffer_fixed *) (h)->data)
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(h) \
((duk_tval *) DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE((h)))
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(h) \
((h)->funcs)
#define DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(h) \
((h)->bytecode)
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(h) \
((duk_tval *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE((h)))
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(h) \
((duk_hobject **) DUK_HCOMPILEDFUNCTION_GET_CODE_BASE((h)))
#define DUK_HCOMPILEDFUNCTION_GET_CODE_END(h) \
((duk_instr_t *) (DUK_HBUFFER_FIXED_GET_DATA_PTR((duk_hbuffer_fixed *) (h)->data) + \
DUK_HBUFFER_GET_SIZE((h)->data)))
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE(h) \
( \
(duk_size_t) \
( \
((duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_END((h))) - \
((duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE((h))) \
) \
)
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE(h) \
( \
(duk_size_t) \
( \
((duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_END((h))) - \
((duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE((h))) \
) \
)
#define DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE(h) \
( \
(duk_size_t) \
( \
((duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CODE_END((h))) - \
((duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CODE_BASE((h))) \
) \
)
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_COUNT(h) \
((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE((h)) / sizeof(duk_tval)))
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_COUNT(h) \
((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE((h)) / sizeof(duk_hobject *)))
#define DUK_HCOMPILEDFUNCTION_GET_CODE_COUNT(h) \
((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE((h)) / sizeof(duk_instr_t)))
/*
* Main struct
*/
struct duk_hcompiledfunction {
/* shared object part */
duk_hobject obj;
/*
* Pointers to function data area for faster access. Function
* data is a buffer shared between all closures of the same
* "template" function. The data buffer is always fixed (non-
* dynamic, hence stable), with a layout as follows:
*
* constants (duk_tval)
* inner functions (duk_hobject *)
* bytecode (duk_instr_t)
*
* Note: bytecode end address can be computed from 'data' buffer
* size. It is not strictly necessary functionally, assuming
* bytecode never jumps outside its allocated area. However,
* it's a safety/robustness feature for avoiding the chance of
* executing random data as bytecode due to a compiler error.
*
* Note: values in the data buffer must be incref'd (they will
* be decref'd on release) for every compiledfunction referring
* to the 'data' element.
*/
duk_hbuffer *data; /* data area, fixed allocation, stable data ptrs */
/* no need for constants pointer */
duk_hobject **funcs;
duk_instr_t *bytecode;
/*
* 'nregs' registers are allocated on function entry, at most 'nargs'
* are initialized to arguments, and the rest to undefined. Arguments
* above 'nregs' are not mapped to registers. All registers in the
* active stack range must be initialized because they are GC reachable.
* 'nargs' is needed so that if the function is given more than 'nargs'
* arguments, the additional arguments do not 'clobber' registers
* beyond 'nregs' which must be consistently initialized to undefined.
*
* Usually there is no need to know which registers are mapped to
* local variables. Registers may be allocated to variable in any
* way (even including gaps). However, a register-variable mapping
* must be the same for the duration of the function execution and
* the register cannot be used for anything else.
*
* When looking up variables by name, the '_Varmap' map is used.
* When an activation closes, registers mapped to arguments are
* copied into the environment record based on the same map. The
* reverse map (from register to variable) is not currently needed
* at run time, except for debugging, so it is not maintained.
*/
duk_uint16_t nregs; /* regs to allocate */
duk_uint16_t nargs; /* number of arguments allocated to regs */
/*
* Additional control information is placed into the object itself
* as internal properties to avoid unnecessary fields for the
* majority of functions. The compiler tries to omit internal
* control fields when possible.
*
* Function templates:
*
* {
* name: "func", // declaration, named function expressions
* fileName: <debug info for creating nice errors>
* _Varmap: { "arg1": 0, "arg2": 1, "varname": 2 },
* _Formals: [ "arg1", "arg2" ],
* _Source: "function func(arg1, arg2) { ... }",
* _Pc2line: <debug info for pc-to-line mapping>,
* }
*
* Function instances:
*
* {
* length: 2,
* prototype: { constructor: <func> },
* caller: <thrower>,
* arguments: <thrower>,
* name: "func", // declaration, named function expressions
* fileName: <debug info for creating nice errors>
* _Varmap: { "arg1": 0, "arg2": 1, "varname": 2 },
* _Formals: [ "arg1", "arg2" ],
* _Source: "function func(arg1, arg2) { ... }",
* _Pc2line: <debug info for pc-to-line mapping>,
* _Varenv: <variable environment of closure>,
* _Lexenv: <lexical environment of closure (if differs from _Varenv)>
* }
*
* More detailed description of these properties can be found
* in the documentation.
*/
};
#endif /* DUK_HCOMPILEDFUNCTION_H_INCLUDED */
|
#include <stdlib.h>
#include <string.h>
#include "list.h"
#include "common.h"
//m[h
typedef struct _node node;
struct _node {
void* data;
node* next;
};
//Xg
struct _list {
int num;
dataType type;
node* first;
};
//Xgì¬
list list_create( dataType type ) {
list t = calloc( sizeof( struct _list ), 1 );
t->type = type;
return t;
}
//Xgí
void list_delete( list t ) {
node* n = t->first;
while( n != NULL ) {
node* a = n;
n = n->next;
//f[^íÊÂÊ
switch( t->type )
{
case STRING:
FREE( a->data );
break;
case STRUCT_SIGNAL:
FREE( ( ( signal* )a->data )->name );
FREE( ( ( signal* )a->data )->sendModuleName );
FREE( ( ( signal* )a->data )->receiveModuleName );
FREE( a->data );
break;
case STRUCT_FUNC:
FREE( ( ( func* )a->data )->mName );
FREE( ( ( func* )a->data )->name );
FREE( ( ( func* )a->data )->typeAndName );
list_delete( ( ( func* )a->data )->callFuncs );
FREE( a->data );
break;
default:
break;
}
FREE( a );
}
FREE( t );
}
node* list_getLastNode_s( list t ) {
node* n = t->first;
while( n != NULL ) {
if( n->next == NULL ) {
return n;
}
n = n->next;
}
}
//m[hÇÁ
//bool_ list_add( list t, void* v) {
int list_add( list t, void* v ) {
//m[hì¬A
node* newNode = ( node* )calloc( sizeof( struct _node ), 1 );
//f[^Ýè
switch( t->type )
{
case STRING:
newNode->data = ( char* )calloc( strlen( ( char* )v ) + 1, 1 );
strcpy( (char*)newNode->data, ( char* )v );
break;
case STRUCT_SIGNAL:
newNode->data = ( signal* )calloc( sizeof( signal ), 1 );
//M¼
(( signal* )newNode->data)->name = ( char* )calloc( strlen((( signal* )v )->name) + 1, 1 );
strcpy( ( char* )(( signal* )newNode->data)->name, ( ( signal* )v )->name );
//MW
[¼
( ( signal* )newNode->data )->sendModuleName = ( char* )calloc( strlen( ( ( signal* )v )->sendModuleName ) + 1, 1 );
strcpy( ( char* )( ( signal* )newNode->data )->sendModuleName, ( ( signal* )v )->sendModuleName );
//óMW
[¼
( ( signal* )newNode->data )->receiveModuleName = ( char* )calloc( strlen( ( ( signal* )v )->receiveModuleName ) + 1, 1 );
strcpy( ( char* )( ( signal* )newNode->data )->receiveModuleName, ( ( signal* )v )->receiveModuleName );
//NGXg©
( ( signal* )newNode->data )->isReq = ( ( signal* )v )->isReq;
break;
case STRUCT_FUNC:
newNode->data = ( func* )calloc( sizeof( func ), 1 );
//W
[¼
//( ( func* )newNode->data )->mName = ( char* )calloc( strlen( ( ( func* )v )->mName ) + 1, 1 );
//strcpy( ( char* )( ( func* )newNode->data )->mName, ( ( func* )v )->mName );
//ªXgÇÁ_Å¢èÅAãÅÂÊÉmalloc·é
//Ö¼
( ( func* )newNode->data )->name = ( char* )calloc( strlen( ( ( func* )v )->name ) + 1, 1 );
strcpy( ( char* )( ( func* )newNode->data )->name, ( ( func* )v )->name );
//ßèlÌ^ÆÖ¼
( ( func* )newNode->data )->typeAndName = ( char* )calloc( strlen( ( ( func* )v )->typeAndName ) + 1, 1 );
strcpy( ( char* )( ( func* )newNode->data )->typeAndName, ( ( func* )v )->typeAndName );
//ÄÑoµÖQ
( ( func* )newNode->data )->callFuncs = list_create( STRING );
break;
default:
break;
}
//öm[hÉÂÈ®
if( t->num != 0 ) {
node* n = list_getLastNode_s( t );
n->next = newNode;
}
else {
t->first = newNode;
}
( t->num )++;
return TRUE;
}
//m[hæ¾
int list_getNum( list t ) {
return t->num;
}
//m[hæ¾
void* list_getNode( list t, int i ) {
node* n = t->first;
if( i < t->num ) {
for( int j = 0; j < i; j++ ) {
n = n->next;
}
}
return n->data;
}
//¶ñm[hæ¾
char* list_getCharNode( list t, int i ) {
return ( char * )list_getNode(t, i);
} |
//
// JYCalendarDateDetailView.h
// JYCalendar
//
// Created by Justin Yang on 14-1-19.
// Copyright (c) 2014年 Nanjing University. All rights reserved.
//
@class JYCalendarWeekDetailView;
@protocol JYCalendarWeekDetailViewDelegate <NSObject>
- (void)weekDetailViewDidNavigateToPreviousDay:(JYCalendarWeekDetailView *)detailView;
- (void)weekDetailViewDidNavigateToNextDay:(JYCalendarWeekDetailView *)detailView;
@end
@interface JYCalendarWeekDetailView : UIView
@property (nonatomic, weak) id<JYCalendarWeekDetailViewDelegate> delegate;
@property (nonatomic, strong) NSArray *eventsForWeek;
- (void)showWeekday:(NSInteger)weekday animated:(BOOL)animated;
@end
|
#pragma once
#include <stdbool.h>
typedef struct Identifier ASTString;
typedef struct Identifier ASTIdentifier;
typedef struct SourceLoc ASTSourceLoc;
typedef struct Node ASTNode;
typedef struct TranslationUnit ASTTranslationUnit;
typedef union TopDecl ASTTopDecl;
typedef struct TypedefDecl ASTTypedefDecl;
typedef struct VariableDecl ASTVariableDecl;
typedef struct FunctionImpl ASTFunctionImpl;
typedef struct FunctionArgument ASTFunctionArgument;
typedef struct StatementBlock ASTStatementBlock;
typedef struct Statement ASTStatement;
typedef struct Type ASTType;
typedef enum TypeID ASTTypeID;
typedef enum StatementID ASTStatementID;
typedef uint32_t ASTInteger;
typedef uint32_t ASTFlags;
typedef bool ASTBool;
struct Identifier {
size_t length;
char* data;
};
struct SourceLoc {
ASTInteger column;
ASTInteger line;
};
struct Node {
ASTSourceLoc location;
};
enum TypeID {
Type_Int,
Type_UserDefined
};
enum StatementID {
Statement_Expression,
Statement_For,
Statement_While,
Statement_Do,
Statement_If,
Statement_ElseIf,
Statement_Else
};
struct Type {
ASTNode node;
ASTTypeID id;
ASTIdentifier name;
};
struct FunctionArgument {
ASTType type;
ASTIdentifier name;
};
struct Statement {
ASTStatementID id;
};
struct StatementBlock {
ASTStatement *statements;
};
struct FunctionImpl {
ASTNode node;
ASTFlags decl_spec_flags;
ASTType return_type;
ASTIdentifier name;
ASTFunctionArgument *arguments;
ASTStatementBlock statementblock;
};
struct VariableDecl {
ASTNode node;
ASTFlags decl_spec_flags;
ASTType type;
ASTIdentifier name;
};
struct TypedefDecl {
ASTNode node;
ASTBool is_const;
ASTType type;
ASTIdentifier name;
};
union TopDecl {
ASTFunctionImpl function;
ASTVariableDecl variable;
};
struct TranslationUnit {
ASTTopDecl *decl;
};
void ast_set_source_loc(ASTNode *node, struct HSPLexer *lexer);
|
// PARAM: --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set ana.activated[+] "'region'" --set exp.region-offsets true
extern int __VERIFIER_nondet_int();
extern void abort(void);
void assume_abort_if_not(int cond) {
if(!cond) {abort();}
}
#include<pthread.h>
#include<stdlib.h>
struct list_head {
struct list_head *next ;
struct list_head *prev ;
};
struct s {
int datum ;
struct list_head list ;
};
struct cache {
struct list_head slot[10] ;
pthread_mutex_t slots_mutex[10] ;
};
struct cache c ;
static inline void INIT_LIST_HEAD(struct list_head *list) {
list->next = list;
list->prev = list;
}
struct s *new(int x) {
struct s *p = malloc(sizeof(struct s));
p->datum = x;
INIT_LIST_HEAD(&p->list);
return p;
}
static inline void list_add(struct list_head *new, struct list_head *head) {
struct list_head *next = head->next;
next->prev = new;
new->next = next;
new->prev = head;
head->next = new;
}
void *f(void *arg) {
struct s *pos ;
int j = __VERIFIER_nondet_int();
assume_abort_if_not(0 <= j);
struct list_head const *p ;
struct list_head const *q ;
while (j < 10) {
pthread_mutex_lock(&c.slots_mutex[j]);
p = c.slot[j].next;
pos = (struct s *)((char *)p - (size_t)(& ((struct s *)0)->list));
while (& pos->list != & c.slot[j]) {
pos->datum++; // RACE!
q = pos->list.next;
pos = (struct s *)((char *)q - (size_t)(& ((struct s *)0)->list));
}
pthread_mutex_unlock(&c.slots_mutex[j]);
j ++;
}
return 0;
}
void *g(void *arg) {
struct s *pos ;
int j = __VERIFIER_nondet_int();
assume_abort_if_not(0 <= j);
struct list_head const *p ;
struct list_head const *q ;
while (j < 10) {
pthread_mutex_lock(&c.slots_mutex[j+1]);
p = c.slot[j].next;
pos = (struct s *)((char *)p - (size_t)(& ((struct s *)0)->list));
while (& pos->list != & c.slot[j]) {
pos->datum++; // RACE!
q = pos->list.next;
pos = (struct s *)((char *)q - (size_t)(& ((struct s *)0)->list));
}
pthread_mutex_unlock(&c.slots_mutex[j+1]);
j ++;
}
return 0;
}
int main() {
pthread_t t1, t2;
for (int i = 0; i < 10; i++) {
INIT_LIST_HEAD(&c.slot[i]);
pthread_mutex_init(&c.slots_mutex[i], NULL);
for (int j = 0; j < 30; j++) list_add(&new(j*i)->list, &c.slot[i]);
}
pthread_create(&t1, NULL, f, NULL);
pthread_create(&t2, NULL, g, NULL);
return 0;
}
|
#ifndef NEW_OPERATORS_H
#define NEW_OPERATORS_H
#include <map>
#include <unordered_set>
#include "expression.h"
#include "vtable_file.h"
#include "vtable_hierarchy.h"
struct NewOperator {
uint64_t addr;
uint64_t size;
ExpressionPtr expr;
std::unordered_set<uint32_t> vtbl_idxs;
};
typedef std::map<uint64_t, NewOperator> OperatorNewAddrMap;
class NewOperators {
private:
const std::string &_module_name;
const VTableFile &_vtable_file;
const VTableHierarchies &_vtable_hierarchies;
OperatorNewAddrMap _op_new_candidates;
public:
NewOperators(const std::string &module_name,
const VTableFile &vtable_file,
const VTableHierarchies &vtable_hierarchies);
void add_op_new_candidate(const NewOperator &new_op_candidate);
void export_new_operators(const std::string &target_dir);
const OperatorNewAddrMap& get_new_operators() const;
void copy_new_operators(const OperatorNewAddrMap &new_ops);
};
#endif //NEW_OPERATORS_H
|
#pragma once
// OSG
#include <osg/Referenced>
#include <osg/ref_ptr>
#include <osg/Shader>
#include <osg/Program>
#include <osg/PositionAttitudeTransform>
#include <osg/MatrixTransform>
// troen
#include "../forwarddeclarations.h"
#include "abstractview.h"
#include "../resourcepool.h"
#include "../omegascene.h"
namespace omega {
class SharedOStream; //foward declaration
}
namespace troen
{
class BikeView : public AbstractView, public SharedDataListener
{
public:
BikeView(const osg::Vec3 color, ResourcePool* resourcePool);
void setTexture(osg::ref_ptr<osg::StateSet> stateset, const ResourcePool::TextureResource textureName, const int unit);
osg::ref_ptr<osg::Node> createCyclePart(
ResourcePool::ModelResource objName,
ResourcePool::TextureResource specularTexturePath,
ResourcePool::TextureResource diffuseTexturePath,
ResourcePool::TextureResource normalTexturePath,
int modelIndex,
float glowIntensity = 1.f);
osg::ref_ptr<osg::PositionAttitudeTransform> m_pat;
osg::ref_ptr<osg::Node> m_MovieCycle_Body;
void update();
void createPlayerMarker(const osg::Vec3 color);
void commitSharedData(omega::SharedOStream& out);
void updateSharedData(omega::SharedIStream& in);
private:
osg::Vec3 m_playerColor;
osg::ref_ptr<osg::Node> m_playermarkerNode;
ResourcePool* m_resourcePool;
};
} |
/*
Copyright (c) 2014 Jesse Stojan
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.
*/
#pragma once
#include "include\irrlicht.h"
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;
using namespace io;
#ifndef _ITP_SCENE_H_
#define _ITP_SCENE_H_
namespace itp
{
} // namespace itp
#endif // _ITP_SCENE_H_ |
/*--------------------------------------------------*/
#import "NSString+GLBNS.h"
/*--------------------------------------------------*/
#import "UIImage+GLBUI.h"
/*--------------------------------------------------*/
#import "GLBApiProvider.h"
#import "GLBCache.h"
/*--------------------------------------------------*/
#if defined(GLB_TARGET_IOS)
/*--------------------------------------------------*/
@class GLBApiProvider;
@class GLBCache;
/*--------------------------------------------------*/
@protocol GLBImageManagerTarget;
/*--------------------------------------------------*/
typedef void(^GLBImageDownloadImageBlock)(UIImage* _Nonnull image);
/*--------------------------------------------------*/
@interface GLBImageManager : NSObject
@property(nonatomic, nonnull, readonly, strong) GLBApiProvider* provider;
@property(nonatomic, nonnull, readonly, strong) NSURLCache* urlCache;
@property(nonatomic, nonnull, readonly, strong) GLBCache* durableCache;
+ (nullable instancetype)defaultImageManager;
- (void)setup NS_REQUIRES_SUPER;
- (BOOL)existImageByUrl:(nonnull NSURL*)url;
- (BOOL)existImageByUrl:(nonnull NSURL*)url processing:(nullable NSString*)processing;
- (nullable UIImage*)imageByUrl:(nonnull NSURL*)url;
- (nullable UIImage*)imageByUrl:(nonnull NSURL*)url processing:(nullable NSString*)processing;
- (void)imageByUrl:(nonnull NSURL*)url complete:(nullable GLBImageDownloadImageBlock)complete;
- (void)imageByUrl:(nonnull NSURL*)url processing:(nullable NSString*)processing complete:(nullable GLBImageDownloadImageBlock)complete;
- (void)setImage:(nonnull UIImage*)image url:(nonnull NSURL*)url complete:(nullable GLBSimpleBlock)complete;
- (void)setImage:(nonnull UIImage*)image url:(nonnull NSURL*)url processing:(nullable NSString*)processing complete:(nullable GLBSimpleBlock)complete;
- (void)removeImageByUrl:(nonnull NSURL*)url complete:(nullable GLBSimpleBlock)complete;
- (void)removeImageByUrl:(nonnull NSURL*)url processing:(nullable NSString*)processing complete:(nullable GLBSimpleBlock)complete;
- (void)cleanupImagesComplete:(nullable GLBSimpleBlock)complete;
- (void)imageByUrl:(nonnull NSURL*)url target:(nullable id< GLBImageManagerTarget >)target;
- (void)imageByUrl:(nonnull NSURL*)url processing:(nullable NSString*)processing target:(nullable id< GLBImageManagerTarget >)target;
- (void)cancelByTarget:(nonnull id< GLBImageManagerTarget >)target;
@end
/*--------------------------------------------------*/
@protocol GLBImageManagerTarget < NSObject >
@required
- (void)imageManager:(nonnull GLBImageManager*)imageManager cacheImage:(nullable UIImage*)image;
@required
- (nullable UIImage*)imageManager:(nonnull GLBImageManager*)imageManager processing:(nullable NSString*)processing image:(nonnull UIImage*)image;
@required
- (void)startDownloadInImageManager:(nonnull GLBImageManager*)imageManager;
- (void)finishDownloadInImageManager:(nonnull GLBImageManager*)imageManager;
- (void)imageManager:(nonnull GLBImageManager*)imageManager downloadProgress:(nonnull NSProgress*)progress;
- (void)imageManager:(nonnull GLBImageManager*)imageManager downloadImage:(nonnull UIImage*)image;
- (void)imageManager:(nonnull GLBImageManager*)imageManager downloadError:(nullable NSError*)error;
@end
/*--------------------------------------------------*/
#endif
/*--------------------------------------------------*/
|
//
// ViewController.h
// WEDebugger
//
// Created by Lucas Ortis on 17/03/2016.
// Copyright © 2016 Lucas Ortis. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface DemoViewController : UIViewController
@end
|
/*
* Generated by class-dump 3.3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard.
*/
#import "NSObject.h"
@class NSString;
// Not exported
@interface NSSQLiteIntarrayTable : NSObject
{
struct sqlite3_intarray *_intarrayTable;
NSString *_intarrayTableName;
}
@property(retain) NSString *intarrayTableName; // @synthesize intarrayTableName=_intarrayTableName;
@property struct sqlite3_intarray *intarrayTable; // @synthesize intarrayTable=_intarrayTable;
- (void)dealloc;
@end
|
//
// CAHelloWorld.h
// Pods
//
// Created by ZhuShouyu on 6/30/15.
//
//
#import <Foundation/Foundation.h>
@interface CAHelloWorld : NSObject
/**
* 弹出一个hello world的弹出框
*/
+ (void)sayHelloWorld;
@end
|
#ifndef ARRAY_LIST_H_INCLUDED
#define ARRAY_LIST_H_INCLUDED
typedef struct arraylist ArrayList;
typedef struct arraylist
{
int current_size;
int max_size;
void **stuff; //Array of stuff
} ARRAYLIST;
ArrayList *array_list_create();
void array_list_add(ArrayList *list, void *item);
void *array_list_get(ArrayList *list, int id);
int array_list_find(ArrayList *list, void *item);
void array_list_clear(ArrayList *list);
void array_list_clear_with_remover(ArrayList *list, void (*remover)(void *));
void array_list_delete_id(ArrayList *list, int id);
void array_list_delete_id_with_remover(ArrayList *list, int id, void (*remover)(void *));
#endif
|
//
// FinalScoreLayer.h
// Angelina-Bubble-Pop-Universal
//
// Created by Karl Söderström on 2011-08-17.
// Copyright 2011 Commind AB. All rights reserved.
//
#import "cocos2d.h"
@interface FinalScoreLayer : CCLayer {
@private
CCLabelBMFont *_label;
}
@property (nonatomic, assign) CCLabelBMFont *label;
@end
|
/*
* This file is part of the Yildiz-Engine project, licenced under the MIT License (MIT)
*
* Copyright (c) 2019 Grégory Van den Borre
*
* More infos available: https://engine.yildiz-games.be
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "JniUtil.h"
#ifndef JNI_PARTICLE_SYSTEM_H
#define JNI_PARTICLE_SYSTEM_H
/**
*@author Grégory Van den Borre
*/
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_attachToNode(
JNIEnv* env,
jobject o,
POINTER pointer,
POINTER nodePointer);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_keepInLocalSpace(
JNIEnv*,
jobject,
POINTER pointer,
jboolean keep);
JNIEXPORT POINTER JNICALL Java_jni_JniParticleSystem_createEmitter(
JNIEnv *,
jobject,
POINTER);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_setBillboardOrigin(
JNIEnv*,
jobject,
POINTER pointer,
jint origin);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_setParticleOrientation(
JNIEnv *,
jobject,
POINTER pointer,
jint type);
JNIEXPORT POINTER JNICALL Java_jni_JniParticleSystem_createColorAffector(
JNIEnv *,
jobject,
POINTER);
JNIEXPORT POINTER JNICALL Java_jni_JniParticleSystem_createForceAffector(
JNIEnv *,
jobject,
POINTER);
JNIEXPORT POINTER JNICALL Java_jni_JniParticleSystem_createScaleAffector(
JNIEnv *,
jobject,
POINTER);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_setSize(
JNIEnv *,
jobject,
POINTER,
jfloat,
jfloat);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_setMaterial(
JNIEnv *,
jobject,
POINTER,
POINTER);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_setQuota(
JNIEnv *,
jobject,
POINTER,
jint);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_show(
JNIEnv *,
jobject,
POINTER);
JNIEXPORT void JNICALL Java_jni_JniParticleSystem_hide(
JNIEnv *,
jobject,
POINTER);
#ifdef __cplusplus
}
#endif
#endif
|
#include "parse.h"
#include <stdlib.h>
#include <string.h>
token* getToken(char* line);
void advanceCursor(char** pLine, int amount);
int TOKEN_MAX_SIZE = 20;
token* getNextToken(char** pLine){
//skip white space
while(**pLine == ' '){
(*pLine)++;
}
if(**pLine == '\n'){
return NULL;
}
token* t = getToken(*pLine);
int skips = t->str.length;
if(t->type == STRING){
skips += 2; //skip opening and closing "
}
advanceCursor(pLine, skips);
return t;
}
token* getToken(char* line){
char* endChars; //inclusive
token_type type;
//trying to avoid adding semantic meaning, that comes later
if(strchr("(){}[]+-*/=;", *line)){
char* str = (char*) malloc(sizeof(char));
*str = *line;
line++;
return new_token(*into_cstring(str), OTHER);
}else if(*line == '"'){
type = STRING;
endChars = "\"";
line++; //skip over first "
}else{
type = OTHER;
endChars = " (){}[]+-*/=;\n";
}
char* str = (char*) malloc(sizeof(char) * TOKEN_MAX_SIZE);
char* p = str;
while(!strchr(endChars, *line)){
*p = *line;
p++;
line++;
}
*p = '\0';
cstring* cstr = into_cstring(str);
return new_token(*cstr, type);
}
void advanceCursor(char** pLine, int amount){
for(; amount > 0; amount--){
(*pLine)++;
}
}
|
//
// WrappedController.h
// IIViewDeck
//
// Copyright (C) 2011, Tom Adriaenssen
//
// 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 <UIKit/UIKit.h>
@interface IIWrapController : UIViewController
@property (nonatomic, readonly, retain) UIViewController* wrappedController;
@property (nonatomic, copy) void(^onViewDidLoad)(IIWrapController* controller);
@property (nonatomic, copy) void(^onViewWillAppear)(IIWrapController* controller, BOOL animated);
@property (nonatomic, copy) void(^onViewDidAppear)(IIWrapController* controller, BOOL animated);
@property (nonatomic, copy) void(^onViewWillDisappear)(IIWrapController* controller, BOOL animated);
@property (nonatomic, copy) void(^onViewDidDisappear)(IIWrapController* controller, BOOL animated);
- (instancetype)initWithViewController:(UIViewController*)controller NS_DESIGNATED_INITIALIZER;
@end
// category on WrappedController to provide access to the viewDeckController in the
// contained viewcontrollers, a la UINavigationController.
@interface UIViewController (WrapControllerItem)
@property(nonatomic,readonly,assign) IIWrapController *wrapController;
@end |
//
// CloudView.h
// ScavengerApp
//
// Created by Lodewijk Loos on 30-05-13.
// Copyright (c) 2013 Code for Europe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CloudView : UIView
{
NSTimer *timer;
float maxCloudHeight;
float totalShift;
float smoothSpeed;
int noUpdateCnt;
}
@property (nonatomic) double speed;
- (void)startAnimation;
- (void)stopAnimation;
@end
|
#ifndef _H_PROCMAN
#define _H_PROCMAN
#include "config.h"
void send_all(int sig);
void restart_process(process_entry_t *process);
void restart_processes(int nproc, config_process_t *processes[]);
void stop_processes(int nproc, config_process_t *processes[]);
void startin_proc(char *term, int nproc, config_process_t *processes[]);
void start_processes(int nproc, config_process_t *processes[]);
void incr_processes(int nproc, config_process_t *processes[]);
void max_processes(int nproc, config_process_t *processes[]);
void decr_processes(int nproc, config_process_t *processes[]);
void min_processes(int nproc, config_process_t *processes[]);
void norestart_processes(int nproc, process_entry_t *processes[]);
void signal_proc(char *sig, int nproc, process_entry_t *processes[]);
void sigterm_processes(int nproc, process_entry_t *processes[]);
void sighup_processes(int nproc, process_entry_t *processes[]);
void sigkill_processes(int nproc, process_entry_t *processes[]);
void sigusr1_processes(int nproc, process_entry_t *processes[]);
void sigusr2_processes(int nproc, process_entry_t *processes[]);
void sigint_processes(int nproc, process_entry_t *processes[]);
void sigquit_processes(int nproc, process_entry_t *processes[]);
#endif // _H_PROCMAN
|
#pragma once
//#include "windows.h"
//extern "C" {
//#include ".\..\lua\lua.h"
//#include ".\..\lua\lauxlib.h"
//#include ".\..\lua\lualib.h"
//}
// The Library Name (for Lua 'require') should be defined below:============================
#define LUACLLIB_NAME "class"
#define LUACLLIB_NGEN(p) p##class
// =========================================================================================
// If building or consuming the library as a DLL, uncomment this block:=====================
//#if defined(LUACLLIB_BUILDING)
//#define LUACLLIB_API extern "C" __declspec(dllexport)
//#else
//#define LUACLLIB_API extern "C" __declspec(dllimport)
//#endif
// =========================================================================================
// If building or consuming the library as a static-link code library, uncomment this block:
//#define LUACLLIB_API extern
// =========================================================================================
// If compiling the library into an EXE file, uncomment this block:=========================
#define LUACLLIB_API
// =========================================================================================
LUACLLIB_API int LUACLLIB_NGEN(luaopen_)(lua_State* L);
// **********************
// 'C' Interface.
// **********************
// Where a Class 'name' is called for below, it should be a key in the package.loaded global table.
// Usually it will be the library name and the class name separated by a period character, but it may
// just be the class name if a library supplies just one class, or a heirarchical name if the library
// supplies the class within a sub-library. The name may be NULL in which case the Class is determined
// as the Class in whose context the function is called.
// A Lua error is raised if the Class cannot be found.
// Pushes a Class function closure, and returns 1, or pushes nothing and returns 0.
// 'init' is the initialisation function which will be enclosed, it may take any parameters and must return
// either a userdata or a table being an object of the class, or nothing.
// 'meth' is a function list which will be used to build the metatable. This metatable is set as the
// TID value of the closure and the closure is set as the first upvalue of each entry in the metatable.
// 'name' is the name of the parent class (see above) or NULL to create a new base class.
LUACLLIB_API int luaC_newclass(lua_State* L, lua_CFunction init, const luaL_Reg* meth, const char* name = NULL);
// Executes a Class closure, pushes one return value (assumed to be the object) and returns 1.
// 'name' is either a full Class name (see above), or NULL to create a new object of the same type within
// a method. If 'nargs' is greater than 0, that number of values is popped off the stack and passed as
// arguments to the Class closure.
LUACLLIB_API int luaC_newobject(lua_State* L, int nargs = 0, const char* name = NULL);
// Should be the first statement in a method. Checks that the method is correctly called and (optionally
// when 'stk' > 0) that there is at least 'stk' stack entries available.
LUACLLIB_API void luaC_checkmethod(lua_State* L, int stk = 0);
// Returns TRUE if the object at inx is an object of the Class specified by 'name' (see above). With a
// NULL name, the class may be that of either a method context or a class closure context.
LUACLLIB_API int luaC_isclass(lua_State* L, int inx, const char* name = NULL);
// Pushes the TID of the value at 'inx' onto the stack. 'inx' may be 0 if calling from the context of a
// 'C' closure, in which case the function may push nothing and return 0 if the TID cannot be determined.
// Returns 1 if the value is a Class, 2 if it is an object or any other type of value except, 3 if the TID
// is a metatable.
LUACLLIB_API int luaC_gettid(lua_State* L, int inx);
// Compares the values at ixo and ixc using TID rules and returns TRUE only if the first is of the same
// type or a compatable type as the second. 'inx' may be zero if called in the context of a class closure
// in which case the TID of the contextual class is returned. This is the lua comparison between the TID
// values unless: 1. The TID values are lua equal functions, in this case it is the (Boolean) result of
// calling this function passing it the two original values; or 2. The first TID is a metatable and the
// second value is a Class, in which case the Class TID is compared recursively with the metatable of the
// metatable etc.
LUACLLIB_API int luaC_istype(lua_State* L, int ixo, int ixc);
// Sorts a list-structure table at 'tabix' in place (by reassigning indexes). If 'funcix' is non-zero a
// function at that index is used as the comparison function (it should receive two parameters and return
// 'true' if the first parameter should be placed before the second), otherwise the lua '<' operator is used.
LUACLLIB_API void luaC_sortlist(lua_State* L, int tabix, int funcix = 0);
|
#import <Foundation/Foundation.h>
@interface NSDictionary (ParamUtils)
- (NSString*) toQueryString;
@end
|
#ifndef _HARDTESTWORDITERATORCREATOR_H_
#define _HARDTESTWORDITERATORCREATOR_H_
#include "WordIterator.h"
#include "WordIteratorCreator.h"
#include "UserWordIteratorCreator.h"
#include "DiscreteWordIterator.h"
#include "EvaluateStrategy.h"
#include "UserInfo.h"
#include "IDictionary.h"
#include <random>
#include <memory>
/// 生成更具挑战性测试用单词迭代器
class HardTestWordIteratorCreator
: public UserWordIteratorCreator
{
public:
using UserWordIteratorCreator::UserWordIteratorCreator;
std::shared_ptr<WordIterator> Create() override;
};
#endif // _HARDTESTWORDITERATORCREATOR_H_
|
#pragma once
using namespace ATL;
template <class T>
class CProxy_ISvcVersionEvents : public IConnectionPointImpl<T, &__uuidof( _ISvcVersionEvents ), CComDynamicUnkArray>
{
// WARNING: This class may be regenerated by the wizard
public:
};
|
// LAF Gfx Library
// Copyright (c) 2020 Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef GFX_MATRIX_H_INCLUDED
#define GFX_MATRIX_H_INCLUDED
#pragma once
#if defined(LAF_SKIA)
#include "gfx/matrix_skia.h"
#else
#include "gfx/matrix_none.h"
#endif
#endif
|
#include "abc.h"
#include "bgzf.h"
class abcSmartCounts:public abc{
private:
int doSmartCounts;
FILE *fidx;
BGZF *fbin;
int curChr;
int len;
public:
abcSmartCounts(const char *outfiles,argStruct *arguments,int inputtype);
~abcSmartCounts();
void getOptions(argStruct *arguments);
void run(funkyPars *pars);
void clean(funkyPars *pars);
void print(funkyPars *pars);
void printArg(FILE *argFile);
void changeChr(int refId);
};
|
/*
gpe_timer.h
This file is part of:
GAME PENCIL ENGINE
https://www.pawbyte.com/gamepencilengine
Copyright (c) 2014-2021 Nathan Hurde, Chase Lee.
Copyright (c) 2014-2021 PawByte LLC.
Copyright (c) 2014-2021 Game Pencil Engine contributors ( Contributors Page )
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.
-Game Pencil Engine <https://www.pawbyte.com/gamepencilengine>
*/
#ifndef gpe_timer_sdl_h
#define gpe_timer_sdl_h
#include "../gpe/gpe_runtime.h"
#include "../gpe/gpe_timer_base.h"
#include <math.h>
#include <SDL2/SDL.h>
namespace gpe
{
//The timer
class time_keeper_sdl: public time_keeper_base
{
protected:
public:
time_keeper_sdl( std::string t_name );
~time_keeper_sdl();
void cap_fps( bool is_minimized );
void delay( float delay_time );
void finish_timer();
float get_needed_ticks();
void start_timer();
void stop_timer();
void pause_timer();
void unpause_timer();
float get_delta_performance();
float get_delta_ticks();
float get_fps();
float get_fps_cap();
float get_performance_ms();
float get_performance_seconds();
uint64_t get_ticks();
float get_time_difference( uint64_t time_p, uint64_t time_c );
bool is_started();
bool is_paused();
void reset_timer();
void set_fps( float fps_new = 60 );
void set_average_fps_count( int new_count );
};
bool init_sdl_time_system();
void quit_sdl_time_system();
}
//The frames per second timer
#endif //gpe_timer_sdl_h
|
void register_water_types();
void unregister_water_types();
|
#include <gtk/gtk.h>
#include "gauge/cade-gauge.h"
gboolean timeout(gpointer data)
{
CadeGauge *gauge = CADE_GAUGE(data);
float value = cade_gauge_get_value(gauge);
if(value < 1)
value += 0.002;
else
value = 0;
cade_gauge_set_value(gauge, value);
return G_SOURCE_CONTINUE;
}
gboolean value_changed(GtkRange *r, GtkScrollType scroll, gdouble value, CadeGauge *gauge)
{
cade_gauge_set_value(gauge, value);
}
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
GtkWidget *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
CadeGauge *mem = cade_gauge_new();
CadeGauge *cpu = cade_gauge_new();
CadeGauge *custom = cade_gauge_new();
GtkWidget *grid = gtk_grid_new();
GtkGrid *g = GTK_GRID(grid);
gtk_grid_set_column_spacing(g, 10);
gtk_grid_attach(g, gtk_label_new("Processor"), 0, 0, 1, 1);
gtk_grid_attach(g, gtk_label_new("Memory"), 1, 0, 1, 1);
gtk_grid_attach(g, gtk_label_new("Custom"), 2, 0, 1, 1);
gtk_grid_attach(g, GTK_WIDGET(cpu), 0, 1, 1, 1);
gtk_grid_attach(g, GTK_WIDGET(mem), 1, 1, 1, 1);
gtk_grid_attach(g, GTK_WIDGET(custom), 2, 1, 1, 1);
gtk_grid_attach(g, gtk_label_new("Change Value:"), 0, 2, 3, 1);
GtkWidget *scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 1, 0.001);
gtk_grid_attach(g, GTK_WIDGET(scale), 0, 3, 3, 1);
g_signal_connect(scale, "change-value", G_CALLBACK(value_changed), custom);
g_timeout_add(10, timeout, mem);
g_timeout_add(7, timeout, cpu);
gtk_container_add(GTK_CONTAINER(w), grid);
g_signal_connect_swapped(w, "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(w);
gtk_main();
}
|
#pragma once
#include <string>
namespace wyc
{
class IShellCommand
{
public:
// command name
virtual const std::string& name() const = 0;
// short description
virtual const std::string& description() const = 0;
// execute command with std args
virtual bool execute(int argc, char *argv[]) = 0;
// execute command with string args
virtual bool execute(const std::string &cmdline) = 0;
};
} // namespace wyc
#ifdef WYC_SHELLCMD_IMPLEMENTATION
#include <boost/program_options.hpp>
#include <boost/tokenizer.hpp>
#include "stb_log.h"
namespace po = boost::program_options;
namespace wyc
{
class CShellCommand : public IShellCommand
{
public:
CShellCommand(const char* name, const char *desc)
: m_name(name)
, m_desc(desc)
, m_opt("")
, m_pos_opt()
{
}
virtual const std::string& name() const override {
return m_name;
}
virtual const std::string& description() const override {
return m_desc;
}
virtual bool execute(int argc, char *argv[]) override
{
po::variables_map args;
if (!parse(argc, argv, args))
return false;
if (args.count("help")) {
show_help();
return true;
}
return process(args);
}
virtual bool execute(const std::string &cmdline) override {
po::variables_map args;
if (!parse(cmdline, args))
return false;
if (args.count("help")) {
show_help();
return true;
}
return process(args);
}
virtual bool process(const po::variables_map &args)
{
return true;
}
virtual void show_help() const
{
std::stringstream ss;
ss << m_desc << std::endl << m_opt;
log_info(ss.str().c_str());
}
protected:
std::string m_name;
std::string m_desc;
po::options_description m_opt;
po::positional_options_description m_pos_opt;
bool parse(int argc, char *argv[], po::variables_map &args_table)
{
try {
po::store(po::command_line_parser(argc, argv).options(m_opt).positional(m_pos_opt).run(), args_table);
po::notify(args_table);
}
catch (const po::error &exp) {
log_error(exp.what());
show_help();
return false;
}
return true;
}
bool parse(const std::string &cmd_line, po::variables_map &args_table)
{
std::vector<std::string> result;
boost::escaped_list_separator<char> seperator("\\", "= ", "\"\'");
boost::tokenizer<decltype(seperator)> tokens(cmd_line, seperator);
for (auto &tok : tokens)
{
if (!tok.empty())
result.push_back(tok);
}
try {
po::store(po::command_line_parser(result).options(m_opt).positional(m_pos_opt).run(), args_table);
po::notify(args_table);
}
catch (const po::error &exp) {
log_error(exp.what());
show_help();
return false;
}
return true;
}
};
} // namespace wyc
#endif // WYC_SHELLCMD_IMPLEMENTATION
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.