Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add minimize and maximize function on Linux | #ifndef APPJS_WINDOW_H
#define APPJS_WINDOW_H
#pragma once
#include "appjs.h"
// GTK+ binding for linux
#if defined(__LINUX__)
#include "linux/mainwindow.h"
// Mac files
#elif defined(__MAC__)
#include "mac/mainwindow.h"
// Windows necessary files
#elif defined(__WIN__)
#include "windows/mainwindow.h"
#endif
namespace appjs {
using namespace v8;
class Window : public node::ObjectWrap {
DECLARE_NODE_OBJECT_FACTORY(Window);
DEFINE_CPP_METHOD(OpenDevTools);
DEFINE_CPP_METHOD(CloseDevTools);
DEFINE_CPP_METHOD(Show);
DEFINE_CPP_METHOD(Hide);
DEFINE_CPP_METHOD(Destroy);
DEFINE_CPP_METHOD(RunInBrowser);
DEFINE_CPP_METHOD(SendSync);
DEFINE_CPP_METHOD(SetMaximize);
DEFINE_CPP_METHOD(SetMinimize);
};
} /* appjs */
#endif /* end of APPJS_WINDOW_H */
| #ifndef APPJS_WINDOW_H
#define APPJS_WINDOW_H
#pragma once
#include "appjs.h"
// GTK+ binding for linux
#if defined(__LINUX__)
#include "linux/mainwindow.h"
// Mac files
#elif defined(__MAC__)
#include "mac/mainwindow.h"
// Windows necessary files
#elif defined(__WIN__)
#include "windows/mainwindow.h"
#endif
namespace appjs {
using namespace v8;
class Window : public node::ObjectWrap {
DECLARE_NODE_OBJECT_FACTORY(Window);
DEFINE_CPP_METHOD(OpenDevTools);
DEFINE_CPP_METHOD(CloseDevTools);
DEFINE_CPP_METHOD(Show);
DEFINE_CPP_METHOD(Hide);
DEFINE_CPP_METHOD(Destroy);
DEFINE_CPP_METHOD(RunInBrowser);
DEFINE_CPP_METHOD(SendSync);
DEFINE_CPP_METHOD(SetMaximize);
DEFINE_CPP_METHOD(SetMinimize);
DEFINE_CPP_METHOD(SetMaximize);
DEFINE_CPP_METHOD(SetMinimize);
};
} /* appjs */
#endif /* end of APPJS_WINDOW_H */
|
Enforce actor addition through Engine | /**
* An efficient c++ simulation demo
*
* @author Skylar Kelty <skylarkelty@gmail.com>
*/
#pragma once
#include "src/common.h"
/**
* A linked list
*/
template <typename T>
class LinkedList {
private:
LLNode<T> *head;
LLNode<T> *tail;
public:
LinkedList();
~LinkedList();
void append(LLNode<T> *node);
/**
* Get the first element of the list
*/
inline LLNode<T> *first() {
return this->head;
}
/**
* Get the last element of the list
*/
inline LLNode<T> *last() {
return this->tail;
}
/**
* Get the length of the list
*/
inline int length() {
return this->head->length();
}
};
| /**
* An efficient c++ simulation demo
*
* @author Skylar Kelty <skylarkelty@gmail.com>
*/
#pragma once
#include "src/common.h"
/**
* A linked list
*/
template <typename T>
class LinkedList {
friend class Engine;
private:
LLNode<T> *head;
LLNode<T> *tail;
protected:
void append(LLNode<T> *node);
public:
LinkedList();
~LinkedList();
/**
* Get the first element of the list
*/
inline LLNode<T> *first() {
return this->head;
}
/**
* Get the last element of the list
*/
inline LLNode<T> *last() {
return this->tail;
}
/**
* Get the length of the list
*/
inline int length() {
return this->head->length();
}
};
|
Define PIT interrupt more correctly if using the IOAPIC | /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef _PLATSUPPORT_PIT_H
#define _PLATSUPPORT_PIT_H
#include <platsupport/timer.h>
#include <platsupport/io.h>
#define PIT_INTERRUPT 0
/*
* Get the pit interface. This may only be called once.
*
* @param io_port_ops io port operations. This is all the pit requires.
* @return initialised interface, NULL on error.
*/
pstimer_t * pit_get_timer(ps_io_port_ops_t *io_port_ops);
#endif /* _PLATSUPPORT_PIT_H */
| /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#ifndef _PLATSUPPORT_PIT_H
#define _PLATSUPPORT_PIT_H
#include <autoconf.h>
#include <platsupport/timer.h>
#include <platsupport/io.h>
#ifdef CONFIG_IRQ_PIC
#define PIT_INTERRUPT 0
#else
#define PIT_INTERRUPT 2
#endif
/*
* Get the pit interface. This may only be called once.
*
* @param io_port_ops io port operations. This is all the pit requires.
* @return initialised interface, NULL on error.
*/
pstimer_t * pit_get_timer(ps_io_port_ops_t *io_port_ops);
#endif /* _PLATSUPPORT_PIT_H */
|
Fix types in this test case | #include <stdlib.h>
int y;
int *g = &y;
int* arr[100];
void f(int *p) {
g = p;
}
int main() {
y = rand();
/* y = 1; */
/* y *= 10; */
f(&arr[y]);
y = y / 4;
return 0;
}
| #include <stdlib.h>
int y;
int *g = &y;
int arr[100];
void f(int *p) {
g = p;
}
int main() {
y = rand();
/* y = 1; */
/* y *= 10; */
f(&arr[y]);
y = y / 4;
return 0;
}
|
Include a header we use. | /** @file
@brief Header declaring device callback types
Must be c-safe!
@date 2014
@author
Ryan Pavlik
<ryan@sensics.com>
<http://sensics.com>
*/
/*
// Copyright 2014 Sensics, Inc.
//
// All rights reserved.
//
// (Final version intended to be licensed under
// the Apache License, Version 2.0)
*/
#ifndef INCLUDED_DeviceCallbackTypesC_h_GUID_46F72CEE_3327_478F_2DED_ADAAF2EC783C
#define INCLUDED_DeviceCallbackTypesC_h_GUID_46F72CEE_3327_478F_2DED_ADAAF2EC783C
/* Internal Includes */
#include <ogvr/Util/ReturnCodesC.h>
/* Library/third-party includes */
/* none */
/* Standard includes */
/* none */
OGVR_EXTERN_C_BEGIN
/** @addtogroup PluginKit
@{
*/
/** @brief Function type of a Sync Device Update callback */
typedef OGVR_ReturnCode (*OGVR_SyncDeviceUpdateCallback)(void *userData);
/** @brief Function type of an Async Device Wait callback */
typedef OGVR_ReturnCode (*OGVR_AsyncDeviceWaitCallback)(void *userData);
/** @} */
OGVR_EXTERN_C_END
#endif
| /** @file
@brief Header declaring device callback types
Must be c-safe!
@date 2014
@author
Ryan Pavlik
<ryan@sensics.com>
<http://sensics.com>
*/
/*
// Copyright 2014 Sensics, Inc.
//
// All rights reserved.
//
// (Final version intended to be licensed under
// the Apache License, Version 2.0)
*/
#ifndef INCLUDED_DeviceCallbackTypesC_h_GUID_46F72CEE_3327_478F_2DED_ADAAF2EC783C
#define INCLUDED_DeviceCallbackTypesC_h_GUID_46F72CEE_3327_478F_2DED_ADAAF2EC783C
/* Internal Includes */
#include <ogvr/Util/APIBaseC.h>
#include <ogvr/Util/ReturnCodesC.h>
/* Library/third-party includes */
/* none */
/* Standard includes */
/* none */
OGVR_EXTERN_C_BEGIN
/** @addtogroup PluginKit
@{
*/
/** @brief Function type of a Sync Device Update callback */
typedef OGVR_ReturnCode (*OGVR_SyncDeviceUpdateCallback)(void *userData);
/** @brief Function type of an Async Device Wait callback */
typedef OGVR_ReturnCode (*OGVR_AsyncDeviceWaitCallback)(void *userData);
/** @} */
OGVR_EXTERN_C_END
#endif
|
Add comment to NSData's MD5 category method | //
// NSData+YZLibrary.h
// YZLibrary
//
// Copyright (c) 2016 Yichi Zhang
// https://github.com/yichizhang
// zhang-yi-chi@hotmail.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h>
@interface NSData (YZLibrary)
- (NSString *)yz_MD5String;
@end | //
// NSData+YZLibrary.h
// YZLibrary
//
// Copyright (c) 2016 Yichi Zhang
// https://github.com/yichizhang
// zhang-yi-chi@hotmail.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h>
@interface NSData (YZLibrary)
/**
* Returns the MD5 hash of data contained in the receiver.
*/
- (NSString *)yz_MD5String;
@end |
Update the documentation - no more Boost | /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2013 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_MUTEX_H
#define AVOGADRO_CORE_MUTEX_H
#include "avogadrocore.h"
namespace Avogadro {
namespace Core {
/**
* @class Mutex mutex.h <avogadro/core/mutex.h>
* @brief The Mutex class provides a simple wrapper for the C++11 or Boost mutex
* class
* @author Marcus D. Hanwell
*
* A very simple, and thin wrapper around the C++11 (or Boost fallback) mutex
* class, allowing for lock, tryLock and unlock.
*/
class AVOGADROCORE_EXPORT Mutex
{
public:
Mutex();
~Mutex();
/**
* @brief Obtain an exclusive lock.
*/
void lock();
/**
* @brief Attempt to obtain an exclusive lock.
* @return True on success, false on failure.
*/
bool tryLock();
/**
* @brief Unlocks the lock.
*/
void unlock();
private:
class PIMPL;
PIMPL* d;
};
}
}
#endif // AVOGADRO_CORE_MUTEX_H
| /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2013 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_MUTEX_H
#define AVOGADRO_CORE_MUTEX_H
#include "avogadrocore.h"
namespace Avogadro {
namespace Core {
/**
* @class Mutex mutex.h <avogadro/core/mutex.h>
* @brief The Mutex class provides a simple wrapper for the C++11 mutex
* class
* @author Marcus D. Hanwell
*
* A very simple, and thin wrapper around the C++11 mutex class, allowing for
* lock, tryLock and unlock.
*/
class AVOGADROCORE_EXPORT Mutex
{
public:
Mutex();
~Mutex();
/**
* @brief Obtain an exclusive lock.
*/
void lock();
/**
* @brief Attempt to obtain an exclusive lock.
* @return True on success, false on failure.
*/
bool tryLock();
/**
* @brief Unlocks the lock.
*/
void unlock();
private:
class PIMPL;
PIMPL* d;
};
}
}
#endif // AVOGADRO_CORE_MUTEX_H
|
Add sort of numerical sequence by bit array | #include <stdio.h>
int main()
{
unsigned int bit_array = 0;
unsigned int a = 1;
unsigned int result;
FILE *fr;
FILE *fw;
char row[10];
fr = fopen("out/testdata", "r");
if (!fr) {
puts("read error");
exit(1);
}
while(fgets(row, sizeof(row), fr) != NULL) {
int x = atoi(row);
bit_array = bit_array | (a << x);
}
fclose(fr);
fw = fopen("out/output_bit_array_sort", "w");
unsigned i;
for (i = 0; i < 1000000; i++) {
if(fprintf(fw , "%07u\n", bit_array & i) < 0) {
puts("write error");
exit(1);
}
}
fclose(fw);
return 0;
}
| |
Switch from std::shared_mutex to libuv's uv_rwlock | #ifndef HunspellContext_H
#define HunspellContext_H
#include <hunspell.hxx>
#include <napi.h>
#include <mutex>
#include <shared_mutex>
class HunspellContext {
public:
Hunspell* instance;
HunspellContext(Hunspell* instance): instance(instance) {};
~HunspellContext() {
if (instance) {
delete instance;
instance = NULL;
}
}
void lockRead() {
rwLock.lock_shared();
}
void unlockRead() {
rwLock.unlock_shared();
}
void lockWrite() {
rwLock.lock();
}
void unlockWrite() {
rwLock.unlock();
}
private:
/*
* The Hunspell instance is not thread safe, so we use a mutex
* to manage asynchronous usage.
*/
std::shared_mutex rwLock;
};
#endif | #ifndef HunspellContext_H
#define HunspellContext_H
#include <hunspell.hxx>
#include <napi.h>
#include <mutex>
#include <shared_mutex>
#include <uv.h>
class HunspellContext {
public:
Hunspell* instance;
HunspellContext(Hunspell* instance): instance(instance) {
uv_rwlock_init(&rwLock);
};
~HunspellContext() {
if (instance) {
delete instance;
instance = NULL;
}
uv_rwlock_destroy(&rwLock);
}
void lockRead() {
uv_rwlock_rdlock(&rwLock);
}
void unlockRead() {
uv_rwlock_rdunlock(&rwLock);
}
void lockWrite() {
uv_rwlock_wrlock(&rwLock);
}
void unlockWrite() {
uv_rwlock_wrunlock(&rwLock);
}
private:
/*
* The Hunspell instance is not thread safe, so we use a mutex
* to manage asynchronous usage.
*/
uv_rwlock_t rwLock;
};
#endif |
Store haBuffer shared_ptr in Node. | #ifndef SRC_NODE_H_
#define SRC_NODE_H_
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <memory>
#include "./graphics/render_data.h"
#include "./math/obb.h"
#include "./graphics/gl.h"
/**
* \brief Base class for nodes which are managed by the
* Nodes class
*
* The only virtual method which must be implemented is
* Node::render.
*/
class Node
{
public:
virtual ~Node()
{
}
virtual void render(Graphics::Gl *gl, RenderData renderData) = 0;
virtual std::shared_ptr<Math::Obb> getObb()
{
return std::shared_ptr<Math::Obb>();
}
bool isPersistable()
{
return persistable;
}
protected:
Node()
{
}
bool persistable = true;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive &ar, unsigned int version) const
{
}
};
#endif // SRC_NODE_H_
| #ifndef SRC_NODE_H_
#define SRC_NODE_H_
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <memory>
#include "./graphics/render_data.h"
#include "./math/obb.h"
#include "./graphics/gl.h"
#include "./graphics/ha_buffer.h"
/**
* \brief Base class for nodes which are managed by the
* Nodes class
*
* The only virtual method which must be implemented is
* Node::render.
*/
class Node
{
public:
virtual ~Node()
{
}
virtual void render(Graphics::Gl *gl, RenderData renderData) = 0;
void render(Graphics::Gl *gl, std::shared_ptr<Graphics::HABuffer> haBuffer,
RenderData renderData)
{
this->haBuffer = haBuffer;
render(gl, renderData);
}
virtual std::shared_ptr<Math::Obb> getObb()
{
return std::shared_ptr<Math::Obb>();
}
bool isPersistable()
{
return persistable;
}
protected:
Node()
{
}
bool persistable = true;
std::shared_ptr<Graphics::HABuffer> haBuffer;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive &ar, unsigned int version) const
{
}
};
#endif // SRC_NODE_H_
|
CREATE was broken if namespace prefixes were set. Patch by Andreas Fuchs. | /* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "commands.h"
int cmd_create(struct client *client)
{
struct mail_storage *storage;
const char *mailbox;
int directory;
size_t len;
/* <mailbox> */
if (!client_read_string_args(client, 1, &mailbox))
return FALSE;
storage = client_find_storage(client, &mailbox);
if (storage == NULL)
return TRUE;
len = strlen(mailbox);
if (mailbox[len-1] != mail_storage_get_hierarchy_sep(storage))
directory = FALSE;
else {
/* name ends with hierarchy separator - client is just
informing us that it wants to create children under this
mailbox. */
directory = TRUE;
mailbox = t_strndup(mailbox, len-1);
}
if (!client_verify_mailbox_name(client, mailbox, FALSE, TRUE))
return TRUE;
if (mail_storage_mailbox_create(storage, mailbox, directory) < 0)
client_send_storage_error(client, storage);
else
client_send_tagline(client, "OK Create completed.");
return TRUE;
}
| /* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "commands.h"
int cmd_create(struct client *client)
{
struct mail_storage *storage;
const char *mailbox, *full_mailbox;
int directory;
size_t len;
/* <mailbox> */
if (!client_read_string_args(client, 1, &mailbox))
return FALSE;
full_mailbox = mailbox;
storage = client_find_storage(client, &mailbox);
if (storage == NULL)
return TRUE;
len = strlen(mailbox);
if (mailbox[len-1] != mail_storage_get_hierarchy_sep(storage))
directory = FALSE;
else {
/* name ends with hierarchy separator - client is just
informing us that it wants to create children under this
mailbox. */
directory = TRUE;
mailbox = t_strndup(mailbox, len-1);
}
if (!client_verify_mailbox_name(client, full_mailbox, FALSE, TRUE))
return TRUE;
if (mail_storage_mailbox_create(storage, mailbox, directory) < 0)
client_send_storage_error(client, storage);
else
client_send_tagline(client, "OK Create completed.");
return TRUE;
}
|
Fix CMAKE_CXX_STANDARD 17 build on Windows | /* guiddatabase.h
Copyright (c) 2017, LongSoft. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#ifndef GUID_DATABASE_H
#define GUID_DATABASE_H
#include <map>
#include <string>
#include "basetypes.h"
#include "ustring.h"
#include "ffsparser.h"
#include "ffs.h"
#include "utility.h"
struct OperatorLessForGuids : public std::binary_function<EFI_GUID, EFI_GUID, bool>
{
bool operator()(const EFI_GUID& lhs, const EFI_GUID& rhs) const
{
return (memcmp(&lhs, &rhs, sizeof(EFI_GUID)) < 0);
}
};
typedef std::map<EFI_GUID, UString, OperatorLessForGuids> GuidDatabase;
UString guidDatabaseLookup(const EFI_GUID & guid);
void initGuidDatabase(const UString & path = "", UINT32* numEntries = NULL);
GuidDatabase guidDatabaseFromTreeRecursive(TreeModel * model, const UModelIndex index);
USTATUS guidDatabaseExportToFile(const UString & outPath, GuidDatabase & db);
#endif // GUID_DATABASE_H
| /* guiddatabase.h
Copyright (c) 2017, LongSoft. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#ifndef GUID_DATABASE_H
#define GUID_DATABASE_H
#include <map>
#include <string>
#include "basetypes.h"
#include "ustring.h"
#include "ffsparser.h"
#include "ffs.h"
#include "utility.h"
struct OperatorLessForGuids
{
bool operator()(const EFI_GUID& lhs, const EFI_GUID& rhs) const
{
return (memcmp(&lhs, &rhs, sizeof(EFI_GUID)) < 0);
}
};
typedef std::map<EFI_GUID, UString, OperatorLessForGuids> GuidDatabase;
UString guidDatabaseLookup(const EFI_GUID & guid);
void initGuidDatabase(const UString & path = "", UINT32* numEntries = NULL);
GuidDatabase guidDatabaseFromTreeRecursive(TreeModel * model, const UModelIndex index);
USTATUS guidDatabaseExportToFile(const UString & outPath, GuidDatabase & db);
#endif // GUID_DATABASE_H
|
Remove MATHD and SORTD macros | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2018 Raymond Jennings
*
* 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/>.
*/
#include <config.h>
/* daemons */
#define MATHD (USR_DIR + "/Utility/sys/mathd")
#define SORTD (USR_DIR + "/Utility/sys/sortd")
#define SUBD (USR_DIR + "/Utility/sys/subd")
| /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2018 Raymond Jennings
*
* 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/>.
*/
#include <config.h>
/* daemons */
#define SUBD (USR_DIR + "/Utility/sys/subd")
|
Make gcc4 happy as well | /* vi: set sw=4 ts=4: */
/*
* getgid() for uClibc
*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include "syscalls.h"
#include <unistd.h>
#if defined __NR_getxgid
# define __NR_getgid __NR_getxgid
#endif
_syscall0(gid_t, getgid);
libc_hidden_proto(getgid)
libc_hidden_def(getgid)
| /* vi: set sw=4 ts=4: */
/*
* getgid() for uClibc
*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include "syscalls.h"
#include <unistd.h>
#if defined __NR_getxgid
# define __NR_getgid __NR_getxgid
#endif
libc_hidden_proto(getgid)
_syscall0(gid_t, getgid);
libc_hidden_def(getgid)
|
Use std::function instead of boost::function | #ifndef PICTUS_ACTIONMAP_H
#define PICTUS_ACTIONMAP_H
#include <boost/function.hpp>
#include <map>
namespace App {
template <typename _key, typename _param>
class ActionMapParam {
public:
typedef boost::function<void(_param)> Function_Type;
void AddAction(_key id, Function_Type f) {
m_map[id] = f;
}
bool Execute(_key id, _param e) {
auto i = m_map.find(id);
if(i == m_map.end())
return false;
(i->second)(e);
return true;
}
private:
typedef std::map<_key, Function_Type> FunctionMap;
FunctionMap m_map;
};
template <typename _key>
class ActionMapNoParam {
public:
typedef boost::function<void()> Function_Type;
void AddAction(_key id, Function_Type f) {
m_map[id] = f;
}
bool Execute(_key id) {
auto i = m_map.find(id);
if(i == m_map.end())
return false;
(i->second)();
return true;
}
private:
typedef std::map<_key, Function_Type> FunctionMap;
FunctionMap m_map;
};
}
#endif
| #ifndef PICTUS_ACTIONMAP_H
#define PICTUS_ACTIONMAP_H
#include <functional>
#include <map>
namespace App {
template <typename _key, typename _param>
class ActionMapParam {
public:
typedef typename std::function<void(_param)> Function_Type;
void AddAction(_key id, Function_Type f) {
m_map[id] = f;
}
bool Execute(_key id, _param e) {
auto i = m_map.find(id);
if(i == m_map.end())
return false;
(i->second)(e);
return true;
}
private:
typedef std::map<_key, Function_Type> FunctionMap;
FunctionMap m_map;
};
template <typename _key>
class ActionMapNoParam {
public:
typedef std::function<void()> Function_Type;
void AddAction(_key id, Function_Type f) {
m_map[id] = f;
}
bool Execute(_key id) {
auto i = m_map.find(id);
if(i == m_map.end())
return false;
(i->second)();
return true;
}
private:
typedef std::map<_key, Function_Type> FunctionMap;
FunctionMap m_map;
};
}
#endif
|
Use override keyword on methods in DummyInvocationLog | #pragma once
#include "invocation_log.h"
namespace shk {
class DummyInvocationLog : public InvocationLog {
public:
void createdDirectory(const std::string &path) throw(IoError) {}
void removedDirectory(const std::string &path) throw(IoError) {}
void ranCommand(
const Hash &build_step_hash,
std::unordered_set<std::string> &&output_files,
std::unordered_map<std::string, DependencyType> &&input_files)
throw(IoError) {}
void cleanedCommand(
const Hash &build_step_hash) throw(IoError) {}
};
} // namespace shk
| #pragma once
#include "invocation_log.h"
namespace shk {
class DummyInvocationLog : public InvocationLog {
public:
void createdDirectory(const std::string &path)
throw(IoError) override {}
void removedDirectory(const std::string &path)
throw(IoError) override {}
void ranCommand(
const Hash &build_step_hash,
std::unordered_set<std::string> &&output_files,
std::unordered_map<std::string, DependencyType> &&input_files)
throw(IoError) override {}
void cleanedCommand(
const Hash &build_step_hash) throw(IoError) override {}
};
} // namespace shk
|
Fix typos.. The vector for "int 0x12" (get base mem) is not written in hex as "0x1a". :-) Fix a comment about the extended memory checks, that's int 0x15. | /*
* mjs copyright
*/
/*
* Obtain memory configuration information from the BIOS
*
* Note that we don't try too hard here; knowing the size of
* base memory and extended memory out to 16 or 64M is enough for
* the requirements of the bootstrap.
*
* We also maintain a pointer to the top of physical memory
* once called to allow rangechecking of load/copy requests.
*/
#include <stand.h>
#include "btxv86.h"
vm_offset_t memtop;
/*
* Return base memory size in kB.
*/
int
getbasemem(void)
{
v86.ctl = 0;
v86.addr = 0x1a; /* int 0x12 */
v86int();
return(v86.eax & 0xffff);
}
/*
* Return extended memory size in kB
*/
int
getextmem(void)
{
int extkb;
v86.ctl = 0;
v86.addr = 0x15; /* int 0x12 function 0x88*/
v86.eax = 0x8800;
v86int();
extkb = v86.eax & 0xffff;
/* Set memtop to actual top or 16M, whicheve is less */
memtop = min((0x100000 + (extkb * 1024)), (16 * 1024 * 1024));
return(extkb);
}
| /*
* mjs copyright
*/
/*
* Obtain memory configuration information from the BIOS
*
* Note that we don't try too hard here; knowing the size of
* base memory and extended memory out to 16 or 64M is enough for
* the requirements of the bootstrap.
*
* We also maintain a pointer to the top of physical memory
* once called to allow rangechecking of load/copy requests.
*/
#include <stand.h>
#include "btxv86.h"
vm_offset_t memtop;
/*
* Return base memory size in kB.
*/
int
getbasemem(void)
{
v86.ctl = 0;
v86.addr = 0x12; /* int 0x12 */
v86int();
return(v86.eax & 0xffff);
}
/*
* Return extended memory size in kB
*/
int
getextmem(void)
{
int extkb;
v86.ctl = 0;
v86.addr = 0x15; /* int 0x15 function 0x88*/
v86.eax = 0x8800;
v86int();
extkb = v86.eax & 0xffff;
/* Set memtop to actual top or 16M, whicheve is less */
memtop = min((0x100000 + (extkb * 1024)), (16 * 1024 * 1024));
return(extkb);
}
|
Add git r done version of detail::raw_pointer_cast | /*
* Copyright 2008-2009 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*! \file casts.h
* \brief Unsafe casts for internal use.
*/
#pragma once
#include <thrust/iterator/iterator_traits.h>
namespace thrust
{
namespace detail
{
namespace dispatch
{
template<typename TrivialIterator>
typename thrust::iterator_traits<TrivialIterator>::value_type *
raw_pointer_cast(TrivialIterator i,
thrust::random_access_host_iterator_tag)
{
typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer;
// cast away constness
return const_cast<Pointer>(&*i);
} // end raw_pointer_cast()
// this path will work for device_ptr & device_vector::iterator
template<typename TrivialIterator>
typename thrust::iterator_traits<TrivialIterator>::value_type *
raw_pointer_cast(TrivialIterator i,
thrust::random_access_device_iterator_tag)
{
typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer;
// cast away constness
return const_cast<Pointer>((&*i).get());
} // end raw_pointer_cast()
} // end dispatch
template<typename TrivialIterator>
typename thrust::iterator_traits<TrivialIterator>::value_type *raw_pointer_cast(TrivialIterator i)
{
return detail::dispatch::raw_pointer_cast(i, thrust::iterator_traits<TrivialIterator>::iterator_category());
} // end raw_pointer_cast()
} // end detail
} // end thrust
| |
Add dummy "syscall()" routine for AIX so we can at least test compiling and linking. | /*******************************************************************
**
** Manage system call mode and do remote system calls.
**
*******************************************************************/
#define _POSIX_SOURCE
#include <stdio.h>
#include "condor_syscalls.h"
static int SyscallMode;
int
SetSyscalls( int mode )
{
int answer;
answer = SyscallMode;
SyscallMode = mode;
return answer;
}
BOOL
LocalSysCalls()
{
return SyscallMode & SYS_LOCAL;
}
BOOL
RemoteSysCalls()
{
return (SyscallMode & SYS_LOCAL) == 0;
}
BOOL
MappingFileDescriptors()
{
return (SyscallMode & SYS_MAPPED);
}
int
REMOTE_syscall( int syscall_num, ... )
{
fprintf(
stderr,
"Don't know how to do system call %d remotely - yet\n",
syscall_num
);
abort();
return -1;
}
| /*******************************************************************
**
** Manage system call mode and do remote system calls.
**
*******************************************************************/
#define _POSIX_SOURCE
#include <stdio.h>
#include "condor_syscalls.h"
static int SyscallMode;
int
SetSyscalls( int mode )
{
int answer;
answer = SyscallMode;
SyscallMode = mode;
return answer;
}
BOOL
LocalSysCalls()
{
return SyscallMode & SYS_LOCAL;
}
BOOL
RemoteSysCalls()
{
return (SyscallMode & SYS_LOCAL) == 0;
}
BOOL
MappingFileDescriptors()
{
return (SyscallMode & SYS_MAPPED);
}
int
REMOTE_syscall( int syscall_num, ... )
{
fprintf(
stderr,
"Don't know how to do system call %d remotely - yet\n",
syscall_num
);
abort();
return -1;
}
#if defined(AIX32) /* Just to test linking */
int syscall( int num, ... )
{
return 0;
}
#endif
|
Add success / error message | #include <stdio.h>
#include <CUnit/CUnit.h>
#include <CUnit/Basic.h>
#include "hashtable/hashtable.h"
#include "dll/dll.h"
int main(int argc, char *argv[]) {
CU_initialize_registry();
test_hashtable_init();
test_dll_init();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
unsigned int nr_of_fails = CU_get_number_of_tests_failed();
nr_of_fails += CU_get_number_of_failures();
CU_cleanup_registry();
return nr_of_fails > 0 ? 1 : 0;
} | #include <stdio.h>
#include <CUnit/CUnit.h>
#include <CUnit/Basic.h>
#include "hashtable/hashtable.h"
#include "dll/dll.h"
int main(int argc, char *argv[]) {
CU_initialize_registry();
test_hashtable_init();
test_dll_init();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
unsigned int nr_of_fails = CU_get_number_of_tests_failed();
nr_of_fails += CU_get_number_of_failures();
CU_cleanup_registry();
if(nr_of_fails == 0) {
printf("\n\x1b[1;37;42m\x1b[2K%s\n\x1b[0m\x1b[37;41m\x1b[0m\x1b[2K\n", "Success!");
} else {
printf("\n\x1b[1;37;41m\x1b[2K%s\n\x1b[0m\x1b[37;41m\x1b[2K\x1b[0m\x1b[2K\n", "FAILURES!");
}
return nr_of_fails > 0 ? 1 : 0;
}
|
Add Thread support on Win32 API | #ifndef ELOG_THREAD_WIN32_H_
#define ELOG_THREAD_WIN32_H_
#include <functional>
#include <process.h>
#include <windows.h>
#include "util.h"
namespace LOG {
class ScopedThreadHandle : NonCopyable {
public:
explicit ScopedThreadHandle(HANDLE handle = NULL)
: handle_(handle) {
}
~ScopedThreadHandle() {
Reset();
}
HANDLE Get() const {
return handle_;
}
void Reset(HANDLE handle = NULL) {
if (handle_) {
CloseHandle(handle_);
}
handle_ = handle;
}
private:
HANDLE handle_;
};
class Thread : NonCopyable {
public:
Thread() {
}
template <typename ThreadBody>
explicit Thread(ThreadBody thread_body)
: thread_body_(thread_body) {
}
~Thread() {
}
template <typename ThreadBody>
void set_thread_body(ThreadBody thread_body) {
thread_body_ = thread_body;
}
void Run() {
HANDLE handle = reinterpret_cast<HANDLE>(
_beginthreadex(NULL, 0, StaticThreadBody, NULL, 0, NULL));
thread_handle_.Reset(handle);
}
void Detach() {
// do nothing
}
void Join() {
HANDLE handle = thread_handle_.Get();
if (handle) {
WaitForSingleObject(handle, INFINITE);
}
}
private:
static int WINAPI StaticThreadBody(LPVOID self_ptr) {
Thread& self = *reinterpret_cast<Thread*>(self_ptr);
self.thread_body_();
return NULL;
}
ScopedThreadHandle thread_handle_;
std::tr1::function<void ()> thread_body_;
};
} // namespace LOG
#endif // ELOG_THREAD_WIN32_H_
| |
Fix OOB indexing, buffer check, realloc size | #include <stdio.h>
#include <stdlib.h>
char* Input(char *buffer){
unsigned int size = 10;
unsigned int len = 0;
int ch;
buffer = malloc(sizeof(char)*size);
if(!buffer){
printf("Error allocating memory");
return buffer;
}
while((ch = fgetc(stdin)) != EOF && ch != '\n'){
buffer[len] = ch;
if(len == size-1){
size = size << 4;
buffer = realloc(buffer,sizeof(char)*size);
if(!buffer){
printf("Error reallocating memory");
return buffer;
}
}
len++;
}
buffer[len] = '\0';
buffer = realloc(buffer,sizeof(buffer));
return buffer;
}
| |
Add RValueWrapper, a wrapper for passing rvalue through std::bind and allow binding to function with rvalue reference parameters. | /**
* rvalue_wrapper.h
*/
#ifndef UTIL_RVALUE_WRAPPER_H_
#define UTIL_RVALUE_WRAPPER_H_
/**
* A wrapper for holding and passing rvalues through std::bind. The rvalue wrapped will be stored
* inside the wrapper until the functor returned by std::bind is invoked, at when the stored rvalue
* will be moved from. The functor can be invoked ONLY ONCE.
*/
template<typename T>
struct RValueWrapper {
public:
template<typename = typename std::enable_if<std::is_rvalue_reference<T&&>::value>::type>
explicit RValueWrapper(T &&t) noexcept :
t(std::move(t)) {
}
RValueWrapper(const RValueWrapper &rhs) = default;
RValueWrapper(RValueWrapper &&rhs) = default;
RValueWrapper& operator=(const RValueWrapper &rhs) = default;
RValueWrapper& operator=(RValueWrapper &&rhs) = default;
template <class ...Args>
T &&operator()(Args ...) {
return std::move(t);
}
private:
T t;
};
namespace std {
template<typename T>
struct is_bind_expression<RValueWrapper<T>> : std::true_type {
};
}
template<typename T,
typename = typename std::enable_if<std::is_rvalue_reference<T&&>::value>::type>
RValueWrapper<T> rval(T &&t) {
return RValueWrapper<T>(std::move(t));
}
template<typename T>
RValueWrapper<T> rval(T &t) {
return RValueWrapper<T>(T(t));
}
#endif /* UTIL_RVALUE_WRAPPER_H_ */
| |
Split int from float instantiations | /*ckwg +5
* Copyright 2011-2012 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#include <boost/cstdint.hpp>
#define VISTK_IMAGE_INSTANTIATE(cls) \
template class cls<bool>; \
template class cls<uint8_t>; \
template class cls<float>; \
template class cls<double>
| /*ckwg +5
* Copyright 2011-2012 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef VISTK_IMAGE_INSTANTIATE_H
#define VISTK_IMAGE_INSTANTIATE_H
#include <boost/cstdint.hpp>
/**
* \file image/instantiate.h
*
* \brief Types for instantiation of image library templates.
*/
#define VISTK_IMAGE_INSTANTIATE_INT(cls) \
template class cls<bool>; \
template class cls<uint8_t>
#define VISTK_IMAGE_INSTANTIATE_FLOAT(cls) \
template class cls<float>; \
template class cls<double>
#define VISTK_IMAGE_INSTANTIATE(cls) \
VISTK_IMAGE_INSTANTIATE_INT(cls); \
VISTK_IMAGE_INSTANTIATE_FLOAT(cls)
#endif // VISTK_IMAGE_INSTANTIATE_H
|
Clarify the need for calling tensorflow::port::InitMain() before using the rest of TensorFlow. | /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_CORE_PLATFORM_INIT_MAIN_H_
#define TENSORFLOW_CORE_PLATFORM_INIT_MAIN_H_
namespace tensorflow {
namespace port {
// Platform-specific initialization routine that may be invoked by a
// main() program that uses TensorFlow.
//
// Default implementation does nothing.
void InitMain(const char* usage, int* argc, char*** argv);
} // namespace port
} // namespace tensorflow
#endif // TENSORFLOW_CORE_PLATFORM_INIT_MAIN_H_
| /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_CORE_PLATFORM_INIT_MAIN_H_
#define TENSORFLOW_CORE_PLATFORM_INIT_MAIN_H_
namespace tensorflow {
namespace port {
// Platform-specific initialization routine that should be invoked by a
// main() program that uses TensorFlow.
// This performs necessary initialization on some platforms; TensorFlow
// may not work unless it has been called.
void InitMain(const char* usage, int* argc, char*** argv);
} // namespace port
} // namespace tensorflow
#endif // TENSORFLOW_CORE_PLATFORM_INIT_MAIN_H_
|
Fix crash when hardware acceleration is disabled. | /*
Copyright © 2018-2019 Atlas Engineer LLC.
Use of this file is governed by the license that can be found in LICENSE.
*/
#include <gtk/gtk.h>
#include <stdlib.h>
#include "server.h"
static void on_name_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data) {
g_message("Starting platform port");
}
static void on_name_lost(GDBusConnection *_connection,
const gchar *_name,
gpointer _user_data) {
g_message("Platform port disconnected");
// TODO: Call stop_server here?
exit(1);
}
int main(int argc, char *argv[]) {
// TODO: Use GtkApplication?
guint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
PLATFORM_PORT_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
start_server,
on_name_acquired,
on_name_lost,
NULL,
NULL);
// TODO: Start the RPC server first? If GUI is started, then we can
// report RPC startup issues graphically.
gtk_main();
stop_server();
g_bus_unown_name(owner_id);
return EXIT_SUCCESS;
}
| /*
Copyright © 2018-2019 Atlas Engineer LLC.
Use of this file is governed by the license that can be found in LICENSE.
*/
#include <gtk/gtk.h>
#include <stdlib.h>
#include "server.h"
static void on_name_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data) {
g_message("Starting platform port");
}
static void on_name_lost(GDBusConnection *_connection,
const gchar *_name,
gpointer _user_data) {
g_message("Platform port disconnected");
// TODO: Call stop_server here?
exit(1);
}
int main(int argc, char *argv[]) {
// It's safer to initialize GTK before the server is started. In particular,
// without it the program would crash if hardware acceleration is disabled
// (e.g. with the WEBKIT_DISABLE_COMPOSITING_MODE=1 environment variable).
gtk_init(NULL, NULL);
// TODO: Use GtkApplication?
guint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
PLATFORM_PORT_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
start_server,
on_name_acquired,
on_name_lost,
NULL,
NULL);
// TODO: Start the RPC server first? If GUI is started, then we can
// report RPC startup issues graphically.
gtk_main();
stop_server();
g_bus_unown_name(owner_id);
return EXIT_SUCCESS;
}
|
Fix the gc_instrumentation test on toolchain bots. | /*
* Copyright 2010 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can
* be found in the LICENSE file.
*/
/*
* gc_noinst.c : Functions that shouldn't be instrumented by the compiler
*/
__thread unsigned int thread_suspend_if_needed_count = 0;
/* TODO(elijahtaylor): This will need to be changed
* when the compiler instrumentation changes.
*/
void __nacl_suspend_thread_if_needed() {
thread_suspend_if_needed_count++;
}
| /*
* Copyright (c) 2011 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/*
* gc_noinst.c : Functions that shouldn't be instrumented by the compiler
*/
__thread unsigned int thread_suspend_if_needed_count = 0;
/* TODO(elijahtaylor): This will need to be changed
* when the compiler instrumentation changes.
*/
volatile int __nacl_thread_suspension_needed = 1;
void __nacl_suspend_thread_if_needed() {
thread_suspend_if_needed_count++;
}
|
Delete second argument to FB_LINK_REQUIRE_ | /*
* Copyright (c) 2004-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#ifndef FB_SK_MACROS_H
#define FB_SK_MACROS_H
#define FB_LINK_REQUIRE_(NAME, UNIQUE)
#define FB_LINKABLE(NAME)
#define FB_LINK_REQUIRE(NAME)
#endif
| /*
* Copyright (c) 2004-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#ifndef FB_SK_MACROS_H
#define FB_SK_MACROS_H
#define FB_LINK_REQUIRE_(NAME)
#define FB_LINKABLE(NAME)
#define FB_LINK_REQUIRE(NAME)
#endif
|
Add a tool similar to hexdump, but for text files. | /* strdump.c -- similar to hexdump but with ascii strings */
#include <stdio.h>
#include <string.h>
int
strdump(FILE *fo, FILE *fi)
{
int c, n;
n = 0;
fputs("\"", fo);
c = fgetc(fi);
while (c != -1)
{
if (c == '\n' || c == '\r')
fputs("\\n\"\n\"", fo);
else
putc(c, fo);
c = fgetc(fi);
n ++;
}
fputs("\"\n", fo);
return n;
}
int
main(int argc, char **argv)
{
FILE *fo;
FILE *fi;
char name[256];
char *realname;
char *p;
int i, len;
if (argc < 3)
{
fprintf(stderr, "usage: hexdump output.c input.dat\n");
return 1;
}
fo = fopen(argv[1], "wb");
if (!fo)
{
fprintf(stderr, "hexdump: could not open output file\n");
return 1;
}
for (i = 2; i < argc; i++)
{
fi = fopen(argv[i], "rb");
if (!fi)
{
fprintf(stderr, "hexdump: could not open input file\n");
return 1;
}
realname = strrchr(argv[i], '/');
if (!realname)
realname = strrchr(argv[i], '\\');
if (realname)
realname ++;
else
realname = argv[i];
strcpy(name, argv[i]);
p = name;
while (*p)
{
if ((*p == '/') || (*p == '.') || (*p == '\\') || (*p == '-'))
*p = '_';
p ++;
}
fprintf(fo, "const char %s_name[] = \"%s\";\n", name, realname);
fprintf(fo, "const char %s_buf[] = {\n", name);
len = strdump(fo, fi);
fprintf(fo, "};\n");
fprintf(fo, "const int %s_len = %d;\n", name, len);
fprintf(fo, "\n");
fclose(fi);
}
return 0;
}
| |
Move fibers out of experimental | /*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <folly/experimental/fibers/FiberManagerMap.h>
#include <wangle/concurrent/IOExecutor.h>
namespace wangle {
/**
* @class FiberIOExecutor
* @brief An IOExecutor that executes funcs under mapped fiber context
*
* A FiberIOExecutor wraps an IOExecutor, but executes funcs on the FiberManager
* mapped to the underlying IOExector's event base.
*/
class FiberIOExecutor : public IOExecutor {
public:
explicit FiberIOExecutor(
const std::shared_ptr<IOExecutor>& ioExecutor)
: ioExecutor_(ioExecutor) {}
virtual void add(std::function<void()> f) override {
auto eventBase = ioExecutor_->getEventBase();
getFiberManager(*eventBase).add(std::move(f));
}
virtual EventBase* getEventBase() override {
return ioExecutor_->getEventBase();
}
private:
std::shared_ptr<IOExecutor> ioExecutor_;
};
} // namespace wangle
| /*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <folly/fibers/FiberManagerMap.h>
#include <wangle/concurrent/IOExecutor.h>
namespace wangle {
/**
* @class FiberIOExecutor
* @brief An IOExecutor that executes funcs under mapped fiber context
*
* A FiberIOExecutor wraps an IOExecutor, but executes funcs on the FiberManager
* mapped to the underlying IOExector's event base.
*/
class FiberIOExecutor : public IOExecutor {
public:
explicit FiberIOExecutor(
const std::shared_ptr<IOExecutor>& ioExecutor)
: ioExecutor_(ioExecutor) {}
virtual void add(std::function<void()> f) override {
auto eventBase = ioExecutor_->getEventBase();
getFiberManager(*eventBase).add(std::move(f));
}
virtual EventBase* getEventBase() override {
return ioExecutor_->getEventBase();
}
private:
std::shared_ptr<IOExecutor> ioExecutor_;
};
} // namespace wangle
|
Fix 'redundant redeclaration' warning due to missing include guard | /* JSON_checker.h */
#ifdef JSON_checker_EXPORTS
#if defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
#define JSON_CHECKER_PUBLIC_API __global
#elif defined __GNUC__
#define JSON_CHECKER_PUBLIC_API __attribute__ ((visibility("default")))
#elif defined(_MSC_VER)
#define JSON_CHECKER_PUBLIC_API __declspec(dllexport)
#else
/* unknown compiler */
#define JSON_CHECKER_PUBLIC_API
#endif
#else
#if defined(_MSC_VER)
#define JSON_CHECKER_PUBLIC_API __declspec(dllimport)
#else
#define JSON_CHECKER_PUBLIC_API
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
JSON_CHECKER_PUBLIC_API
int checkUTF8JSON(const unsigned char* data, size_t size);
#ifdef __cplusplus
}
#endif
| /* JSON_checker.h */
#pragma once
#ifdef JSON_checker_EXPORTS
#if defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
#define JSON_CHECKER_PUBLIC_API __global
#elif defined __GNUC__
#define JSON_CHECKER_PUBLIC_API __attribute__ ((visibility("default")))
#elif defined(_MSC_VER)
#define JSON_CHECKER_PUBLIC_API __declspec(dllexport)
#else
/* unknown compiler */
#define JSON_CHECKER_PUBLIC_API
#endif
#else
#if defined(_MSC_VER)
#define JSON_CHECKER_PUBLIC_API __declspec(dllimport)
#else
#define JSON_CHECKER_PUBLIC_API
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
JSON_CHECKER_PUBLIC_API
int checkUTF8JSON(const unsigned char* data, size_t size);
#ifdef __cplusplus
}
#endif
|
Fix warning for a missing nonnull | //
// HauteStreamsController.h
// Hauth
//
// Created by Rizwan Sattar on 11/7/15.
// Copyright © 2015 Rizwan Sattar. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface HauthStreamsController : NSObject
@property (strong, nonatomic, nullable) NSInputStream *inputStream;
@property (strong, nonatomic, nullable) NSOutputStream *outputStream;
@property (assign, nonatomic) NSUInteger streamOpenCount;
- (void)openStreams;
- (void)closeStreams;
- (void)sendData:(nonnull NSData *)data;
- (void)handleReceivedData:(nonnull NSData *)data;
- (void)handleStreamEnd:(NSStream *)stream;
@end
| //
// HauteStreamsController.h
// Hauth
//
// Created by Rizwan Sattar on 11/7/15.
// Copyright © 2015 Rizwan Sattar. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface HauthStreamsController : NSObject
@property (strong, nonatomic, nullable) NSInputStream *inputStream;
@property (strong, nonatomic, nullable) NSOutputStream *outputStream;
@property (assign, nonatomic) NSUInteger streamOpenCount;
- (void)openStreams;
- (void)closeStreams;
- (void)sendData:(nonnull NSData *)data;
- (void)handleReceivedData:(nonnull NSData *)data;
- (void)handleStreamEnd:(nonnull NSStream *)stream;
@end
|
Add {c|r}{begin|end} since gcc doesnt know it. | #pragma once
namespace std {
template <typename T> auto cbegin(const T &c) { return c.cbegin(); }
template <typename T> auto crbegin(const T &c) { return c.crbegin(); }
template <typename T> auto cend(const T &c) { return c.crbegin(); }
template <typename T> auto crend(const T &c) { return c.crbegin(); }
}
| |
Put destructor to private according to chromium style | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_MESSAGE_PUMP_UV_H_
#define BASE_MESSAGE_PUMP_UV_H_
#pragma once
#include "base/message_pump.h"
#include "base/time.h"
#include "base/base_export.h"
#include "third_party/libuv/include/uv.h"
namespace base {
class BASE_EXPORT MessagePumpUV : public MessagePump {
public:
MessagePumpUV();
virtual ~MessagePumpUV();
// MessagePump methods:
virtual void Run(Delegate* delegate) OVERRIDE;
virtual void Quit() OVERRIDE;
virtual void ScheduleWork() OVERRIDE;
virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
private:
// This flag is set to false when Run should return.
bool keep_running_;
struct uv_async_s wakeup_event_;
TimeTicks delayed_work_time_;
DISALLOW_COPY_AND_ASSIGN(MessagePumpUV);
};
} // namespace base
#endif // BASE_MESSAGE_PUMP_UV_H_
| // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_MESSAGE_PUMP_UV_H_
#define BASE_MESSAGE_PUMP_UV_H_
#pragma once
#include "base/message_pump.h"
#include "base/time.h"
#include "base/base_export.h"
#include "third_party/libuv/include/uv.h"
namespace base {
class BASE_EXPORT MessagePumpUV : public MessagePump {
public:
MessagePumpUV();
// MessagePump methods:
virtual void Run(Delegate* delegate) OVERRIDE;
virtual void Quit() OVERRIDE;
virtual void ScheduleWork() OVERRIDE;
virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
private:
virtual ~MessagePumpUV();
// This flag is set to false when Run should return.
bool keep_running_;
struct uv_async_s wakeup_event_;
TimeTicks delayed_work_time_;
DISALLOW_COPY_AND_ASSIGN(MessagePumpUV);
};
} // namespace base
#endif // BASE_MESSAGE_PUMP_UV_H_
|
Change scan to login guide url | //
// APIConstant.h
// PHPHub
//
// Created by Aufree on 9/30/15.
// Copyright (c) 2015 ESTGroup. All rights reserved.
//
#define APIAccessTokenURL [NSString stringWithFormat:@"%@%@", APIBaseURL, @"/oauth/access_token"]
#define QiniuUploadTokenIdentifier @"QiniuUploadTokenIdentifier"
#if DEBUG
#define APIBaseURL @"https://staging_api.phphub.org"
#else
#define APIBaseURL @"https://api.phphub.org"
#endif
#define PHPHubHost @"phphub.org"
#define PHPHubUrl @"https://phphub.org/"
#define GitHubURL @"https://github.com/"
#define TwitterURL @"https://twitter.com/"
#define ProjectURL @"https://github.com/phphub/phphub-ios"
#define AboutPageURL @"https://phphub.org/about"
#define ESTGroupURL @"http://est-group.org"
#define PHPHubGuide @"https://phphub.org/helps/qr-login-guide"
#define PHPHubTopicURL @"https://phphub.org/topics/"
#define SinaRedirectURL @"http://sns.whalecloud.com/sina2/callback" | //
// APIConstant.h
// PHPHub
//
// Created by Aufree on 9/30/15.
// Copyright (c) 2015 ESTGroup. All rights reserved.
//
#define APIAccessTokenURL [NSString stringWithFormat:@"%@%@", APIBaseURL, @"/oauth/access_token"]
#define QiniuUploadTokenIdentifier @"QiniuUploadTokenIdentifier"
#if DEBUG
#define APIBaseURL @"https://staging_api.phphub.org"
#else
#define APIBaseURL @"https://api.phphub.org"
#endif
#define PHPHubHost @"phphub.org"
#define PHPHubUrl @"https://phphub.org/"
#define GitHubURL @"https://github.com/"
#define TwitterURL @"https://twitter.com/"
#define ProjectURL @"https://github.com/phphub/phphub-ios"
#define AboutPageURL @"https://phphub.org/about"
#define ESTGroupURL @"http://est-group.org"
#define PHPHubGuide @"http://7xnqwn.com1.z0.glb.clouddn.com/index.html"
#define PHPHubTopicURL @"https://phphub.org/topics/"
#define SinaRedirectURL @"http://sns.whalecloud.com/sina2/callback" |
Disable copy on Mutex objects | /**
* Mutex management astraction layer
*/
#ifndef EPYX_MUTEX_H
#define EPYX_MUTEX_H
#include <pthread.h>
#include "exception.h"
namespace Epyx
{
class Mutex
{
private:
pthread_mutex_t mutex;
public:
inline Mutex ()
{
int status = pthread_mutex_init (&(this->mutex), NULL);
if (status)
throw FailException("Mutex", "pthread_mutex init error");
}
inline ~Mutex ()
{
int status = pthread_mutex_destroy (&(this->mutex));
if (status)
throw FailException("Mutex", "pthread_mutex destroy error");
}
inline void lock ()
{
int status = pthread_mutex_lock (&(this->mutex));
if (status)
throw FailException("Mutex", "pthread_mutex lock error");
}
inline void unlock ()
{
int status = pthread_mutex_unlock (&(this->mutex));
if (status)
throw FailException("Mutex", "pthread_mutex unlock error");
}
};
}
#endif /* EPYX_THREAD_H */
| /**
* Mutex management astraction layer
*/
#ifndef EPYX_MUTEX_H
#define EPYX_MUTEX_H
#include <pthread.h>
#include "exception.h"
namespace Epyx
{
class Mutex
{
private:
pthread_mutex_t mutex;
// Disable copy construction and assignment.
Mutex (const Mutex&);
const Mutex &operator = (const Mutex&);
public:
inline Mutex ()
{
int status = pthread_mutex_init (&(this->mutex), NULL);
if (status)
throw FailException("Mutex", "pthread_mutex init error");
}
inline ~Mutex ()
{
int status = pthread_mutex_destroy (&(this->mutex));
if (status)
throw FailException("Mutex", "pthread_mutex destroy error");
}
inline void lock ()
{
int status = pthread_mutex_lock (&(this->mutex));
if (status)
throw FailException("Mutex", "pthread_mutex lock error");
}
inline void unlock ()
{
int status = pthread_mutex_unlock (&(this->mutex));
if (status)
throw FailException("Mutex", "pthread_mutex unlock error");
}
};
}
#endif /* EPYX_THREAD_H */
|
Improve new file in future | #define GET_CLASS_INFO_EXTENDS(extends, ...) \
extends
#define GET_CLASS_INFO_IMPLEMENTS(x, y, implements...) \
implements
#define GET_CLASS_INFO_NB_IMPLEMENTS(x, nb, ...) \
nb
#define GET_CLASS_INFO(what, extends, nbInter, interfaces...) \
GET_CLASS_INFO_ ## what(extends, nbInter, ##interfaces)
#define CLASS_INFO_String(what) \
GET_CLASS_INFO(what, Object, 1, toString)
#define CLASS_INFO(name, what) \
CLASS_INFO_ ## name(what)
CLASS_INFO(String, EXTENDS)
CLASS_INFO(String, IMPLEMENTS)
CLASS_INFO(String, NB_IMPLEMENTS)
| #define GET_CLASS_INFO_EXTENDS(extends, ...) \
extends
#define GET_CLASS_INFO_IMPLEMENTS(x, y, implements...) \
implements
#define GET_CLASS_INFO_NB_IMPLEMENTS(x, nb, ...) \
nb
#define CLASS_INFO_String(what) \
GET_CLASS_INFO_ ## what(Object, 2, toString, Serializable)
#define CLASS_INFO(name, what) \
CLASS_INFO_ ## name(what)
CLASS_INFO(String, EXTENDS)
CLASS_INFO(String, NB_IMPLEMENTS)
CLASS_INFO(String, IMPLEMENTS)
|
Migrate ::StringPiece to absl::string_view. PiperOrigin-RevId: 222828687 | /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_PLATFORM_REGEXP_H_
#define TENSORFLOW_PLATFORM_REGEXP_H_
#include "tensorflow/core/platform/platform.h"
#include "tensorflow/core/platform/types.h"
#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID) || \
defined(GOOGLE_RE2)
#include "tensorflow/core/platform/google/build_config/re2.h"
namespace tensorflow {
typedef ::StringPiece RegexpStringPiece;
} // namespace tensorflow
#else
#include "re2/re2.h"
namespace tensorflow {
typedef re2::StringPiece RegexpStringPiece;
} // namespace tensorflow
#endif
#endif // TENSORFLOW_PLATFORM_REGEXP_H_
| /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_PLATFORM_REGEXP_H_
#define TENSORFLOW_PLATFORM_REGEXP_H_
#include "absl/strings/string_view.h"
#include "tensorflow/core/platform/platform.h"
#include "tensorflow/core/platform/types.h"
#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID) || \
defined(GOOGLE_RE2)
#include "tensorflow/core/platform/google/build_config/re2.h"
namespace tensorflow {
typedef absl::string_view RegexpStringPiece;
} // namespace tensorflow
#else
#include "re2/re2.h"
namespace tensorflow {
typedef re2::StringPiece RegexpStringPiece;
} // namespace tensorflow
#endif
#endif // TENSORFLOW_PLATFORM_REGEXP_H_
|
Remove errant comment from copypasta | #pragma once
#include "drake/drakeOptimization_export.h"
#include "drake/solvers/MathematicalProgram.h"
namespace drake {
namespace solvers {
class DRAKEOPTIMIZATION_EXPORT LinearSystemSolver :
public MathematicalProgramSolverInterface {
public:
// This solver is implemented in various pieces depending on if
// Ipopt was available during compilation.
bool available() const override;
SolutionResult Solve(OptimizationProblem& prog) const override;
};
} // namespace solvers
} // namespace drake
| #pragma once
#include "drake/drakeOptimization_export.h"
#include "drake/solvers/MathematicalProgram.h"
namespace drake {
namespace solvers {
class DRAKEOPTIMIZATION_EXPORT LinearSystemSolver :
public MathematicalProgramSolverInterface {
public:
bool available() const override;
SolutionResult Solve(OptimizationProblem& prog) const override;
};
} // namespace solvers
} // namespace drake
|
Add basic binary search implementation | /*
* Copyright (c) 2014-2015, NVIDIA CORPORATION
* Copyright (c) 2015, Nuno Subtil <subtil@gmail.com>
* Copyright (c) 2015, Roche Molecular Systems Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the copyright holders 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 HOLDERS 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.
*/
#pragma once
#include "../types.h"
namespace lift {
// perform a binary search on a sorted array
// returns the index of any element in the array that is equal to val, or -1 if not found
template <typename T>
CUDA_HOST_DEVICE uint32 binary_search(const T *data, uint32 size, const T val)
{
uint32 first = 0;
uint32 last = size;
while(last - first > 0)
{
uint32 i = first + ((last - first) / 2);
if (data[i] == val)
return i;
if (data[i] < val)
{
if (i == first)
{
first++;
} else {
first = i;
}
} else {
if (i == last)
{
last--;
} else {
last = i;
}
}
}
return uint32(-1);
}
} // namespace lift
| |
Update driver version to 5.02.00-k16 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k15"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2010 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k16"
|
Update driver version to 5.03.00-k0 | /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.02.00-k20"
| /*
* QLogic iSCSI HBA Driver
* Copyright (c) 2003-2012 QLogic Corporation
*
* See LICENSE.qla4xxx for copyright and licensing details.
*/
#define QLA4XXX_DRIVER_VERSION "5.03.00-k0"
|
Add minimal pfscan regression test due to combine problem | #include <pthread.h>
struct __anonstruct_PQUEUE_63 {
int closed ;
pthread_mutex_t mtx ;
};
typedef struct __anonstruct_PQUEUE_63 PQUEUE;
PQUEUE pqb;
int pqueue_init(PQUEUE *qp)
{
qp->closed = 0;
pthread_mutex_init(& qp->mtx, NULL);
return (0);
}
void pqueue_close(PQUEUE *qp )
{
pthread_mutex_lock(& qp->mtx);
qp->closed = 1;
pthread_mutex_unlock(& qp->mtx);
return;
}
int pqueue_put(PQUEUE *qp)
{
pthread_mutex_lock(& qp->mtx);
if (qp->closed) {
// pfscan actually has a bug and is missing the following unlock at early return
// pthread_mutex_unlock(& qp->mtx);
return (0);
}
pthread_mutex_unlock(& qp->mtx);
return (1);
}
void *worker(void *arg )
{
return NULL;
}
int main(int argc , char **argv )
{
pthread_t tid;
PQUEUE *qp = &pqb;
pqueue_init(& pqb);
pthread_create(& tid, NULL, & worker, NULL);
for (int i = 1; i < argc; i++) {
pqueue_put(& pqb);
}
pqueue_close(& pqb);
return 0;
}
| |
Move a call to exitChplThreads() to after the final barrier | #include <stdio.h>
#include <stdlib.h>
#include "chplcomm.h"
#include "chplexit.h"
#include "chplmem.h"
#include "chplrt.h"
#include "gdb.h"
#undef exit
static void _chpl_exit_common(int status, int all) {
fflush(stdout);
fflush(stderr);
if (status != 0) {
gdbShouldBreakHere();
}
if (all) {
exitChplThreads(); // tear down the threads
}
if (all) {
_chpl_comm_barrier("_chpl_comm_exit_all");
_chpl_comm_exit_all(status);
} else {
_chpl_comm_exit_any(status);
}
exit(status);
}
void _chpl_exit_all(int status) {
printFinalMemStat(0, 0); // print the final memory statistics
_chpl_exit_common(status, 1);
}
void _chpl_exit_any(int status) {
_chpl_exit_common(status, 0);
}
| #include <stdio.h>
#include <stdlib.h>
#include "chplcomm.h"
#include "chplexit.h"
#include "chplmem.h"
#include "chplrt.h"
#include "gdb.h"
#undef exit
static void _chpl_exit_common(int status, int all) {
fflush(stdout);
fflush(stderr);
if (status != 0) {
gdbShouldBreakHere();
}
if (all) {
_chpl_comm_barrier("_chpl_comm_exit_all");
exitChplThreads(); // tear down the threads
_chpl_comm_exit_all(status);
} else {
_chpl_comm_exit_any(status);
}
exit(status);
}
void _chpl_exit_all(int status) {
printFinalMemStat(0, 0); // print the final memory statistics
_chpl_exit_common(status, 1);
}
void _chpl_exit_any(int status) {
_chpl_exit_common(status, 0);
}
|
Remove no longer used SkipEncodingUnusedStreams. | /*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_EXPERIMENTS_H_
#define WEBRTC_EXPERIMENTS_H_
#include "webrtc/typedefs.h"
namespace webrtc {
struct RemoteBitrateEstimatorMinRate {
RemoteBitrateEstimatorMinRate() : min_rate(30000) {}
RemoteBitrateEstimatorMinRate(uint32_t min_rate) : min_rate(min_rate) {}
uint32_t min_rate;
};
struct SkipEncodingUnusedStreams {
SkipEncodingUnusedStreams() : enabled(false) {}
explicit SkipEncodingUnusedStreams(bool set_enabled)
: enabled(set_enabled) {}
virtual ~SkipEncodingUnusedStreams() {}
const bool enabled;
};
struct AimdRemoteRateControl {
AimdRemoteRateControl() : enabled(false) {}
explicit AimdRemoteRateControl(bool set_enabled)
: enabled(set_enabled) {}
virtual ~AimdRemoteRateControl() {}
const bool enabled;
};
} // namespace webrtc
#endif // WEBRTC_EXPERIMENTS_H_
| /*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_EXPERIMENTS_H_
#define WEBRTC_EXPERIMENTS_H_
#include "webrtc/typedefs.h"
namespace webrtc {
struct RemoteBitrateEstimatorMinRate {
RemoteBitrateEstimatorMinRate() : min_rate(30000) {}
RemoteBitrateEstimatorMinRate(uint32_t min_rate) : min_rate(min_rate) {}
uint32_t min_rate;
};
struct AimdRemoteRateControl {
AimdRemoteRateControl() : enabled(false) {}
explicit AimdRemoteRateControl(bool set_enabled)
: enabled(set_enabled) {}
virtual ~AimdRemoteRateControl() {}
const bool enabled;
};
} // namespace webrtc
#endif // WEBRTC_EXPERIMENTS_H_
|
Check for GCC before checking version | #ifndef PSTDALIGN_H
#define PSTDALIGN_H
#ifndef __alignas_is_defined
#ifndef __cplusplus
#if ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)) || defined(__IBMC__)
#undef PORTABLE_C11_STDALIGN_MISSING
#define PORTABLE_C11_STDALIGN_MISSING
#endif
#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && \
!defined(PORTABLE_C11_STDALIGN_MISSING)
/* C11 or newer */
#include <stdalign.h>
#else
#if defined(__GNUC__) || defined (__IBMC__) || defined(__clang__)
#define _Alignas(t) __attribute__((__aligned__(t)))
#define _Alignof(t) __alignof__(t)
#elif defined(_MSC_VER)
#define _Alignas(t) __declspec (align(t))
#define _Alignof(t) __alignof(t)
#define alignas _Alignas
#define alignof _Alignof
#define __alignas_is_defined 1
#define __alignof_is_defined 1
#else
#error please update pstdalign.h with support for current compiler
#endif
#endif /* __STDC__ */
#endif /* __cplusplus */
#endif /* __alignas__is_defined */
#endif /* PSTDALIGN_H */
| #ifndef PSTDALIGN_H
#define PSTDALIGN_H
#ifndef __alignas_is_defined
#ifndef __cplusplus
#if ((defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 7))) || defined(__IBMC__))
#undef PORTABLE_C11_STDALIGN_MISSING
#define PORTABLE_C11_STDALIGN_MISSING
#endif
#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && \
!defined(PORTABLE_C11_STDALIGN_MISSING)
/* C11 or newer */
#include <stdalign.h>
#else
#if defined(__GNUC__) || defined (__IBMC__) || defined(__clang__)
#define _Alignas(t) __attribute__((__aligned__(t)))
#define _Alignof(t) __alignof__(t)
#elif defined(_MSC_VER)
#define _Alignas(t) __declspec (align(t))
#define _Alignof(t) __alignof(t)
#define alignas _Alignas
#define alignof _Alignof
#define __alignas_is_defined 1
#define __alignof_is_defined 1
#else
#error please update pstdalign.h with support for current compiler
#endif
#endif /* __STDC__ */
#endif /* __cplusplus */
#endif /* __alignas__is_defined */
#endif /* PSTDALIGN_H */
|
Fix multiple def errors for strcasecmp && strncasecmp. | #include_next <string.h>
#ifndef LIBCRYPTOCOMPAT_STRING_H
#define LIBCRYPTOCOMPAT_STRING_H
#include <sys/types.h>
#ifdef __sun
/* Some functions historically defined in string.h were placed in strings.h by
* SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris.
*/
#include <strings.h>
#endif
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);
void explicit_bzero(void *, size_t);
int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
#ifdef __pnacl__
inline int strncasecmp(const char *str1, const char *str2, size_t n) {
size_t i = 0;
for(; str1[i] == str2[i] &&
str1[i] != '\0' && str2[i] != '\0' &&
i < n; ++i) { }
return (int)(str1[i] - str2[i]);
}
inline int strcasecmp(const char *str1, const char *str2) {
size_t i = 0;
for(; str1[i] == str2[i] &&
str1[i] != '\0' && str2[i] != '\0'; ++i) { }
return (int)(str1[i] - str2[i]);
}
#endif /* __pnacl__ */
#endif
| #include_next <string.h>
#ifndef LIBCRYPTOCOMPAT_STRING_H
#define LIBCRYPTOCOMPAT_STRING_H
#include <sys/types.h>
#ifdef __sun
/* Some functions historically defined in string.h were placed in strings.h by
* SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris.
*/
#include <strings.h>
#endif
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);
void explicit_bzero(void *, size_t);
int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
#endif
|
Add a comment that "changed" is unused. | /*************************************************************************/
/* Copyright (c) 2004 */
/* Daniel Sleator, David Temperley, and John Lafferty */
/* Copyright (c) 2014 Linas Vepstas */
/* All rights reserved */
/* */
/* Use of the link grammar parsing system is subject to the terms of the */
/* license set forth in the LICENSE file included with this software. */
/* This license allows free redistribution and use in source and binary */
/* forms, with or without modification, subject to certain conditions. */
/* */
/*************************************************************************/
#include "dict-api.h"
#include "structures.h"
/* The structure below stores a list of dictionary word files. */
struct Word_file_struct
{
Word_file * next;
const char *file; /* the file name */
bool changed; /* TRUE if this file has been changed */
};
void free_Word_file(Word_file * wf);
Dict_node * read_word_file(Dictionary dict, Dict_node * dn, char * filename);
| /*************************************************************************/
/* Copyright (c) 2004 */
/* Daniel Sleator, David Temperley, and John Lafferty */
/* Copyright (c) 2014 Linas Vepstas */
/* All rights reserved */
/* */
/* Use of the link grammar parsing system is subject to the terms of the */
/* license set forth in the LICENSE file included with this software. */
/* This license allows free redistribution and use in source and binary */
/* forms, with or without modification, subject to certain conditions. */
/* */
/*************************************************************************/
#include "dict-api.h"
#include "structures.h"
/* The structure below stores a list of dictionary word files. */
struct Word_file_struct
{
Word_file * next;
const char *file; /* the file name */
bool changed; /* TRUE if this file has been changed (XXX unused) */
};
void free_Word_file(Word_file * wf);
Dict_node * read_word_file(Dictionary dict, Dict_node * dn, char * filename);
|
Add CommandLine for easier command line parsing | /*
Copyright (c) 2013 Daniele Bartolini, Michele Rossi
Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "string_utils.h"
namespace crown
{
/// Helper for parsing command line.
struct CommandLine
{
CommandLine(int argc, char** argv)
: _argc(argc)
, _argv(argv)
{
}
int find_argument(const char* longopt, char shortopt)
{
for (int i = 0; i < _argc; i++)
{
if ((shortopt != '\0' && string::strlen(_argv[i]) > 1 && _argv[i][0] == '-' && _argv[i][1] == shortopt) ||
(string::strlen(_argv[i]) > 2 && _argv[i][0] == '-' && _argv[i][1] == '-' && string::strcmp(&_argv[i][2], longopt) == 0))
{
return i;
}
}
return _argc;
}
const char* get_parameter(const char* longopt, char shortopt = '\0')
{
int argc = find_argument(longopt, shortopt);
return argc < _argc ? _argv[argc + 1] : NULL;
}
bool has_argument(const char* longopt, char shortopt = '\0')
{
return find_argument(longopt, shortopt) < _argc;
}
private:
int _argc;
char** _argv;
};
} // namespace crown
| |
Remove a duplicate definition of __pmServerPresence | /*
* Copyright (c) 2013 Red Hat.
*
* 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.
*/
#ifndef AVAHI_H
#define AVAHI_H
typedef struct __pmServerPresence __pmServerPresence;
void __pmServerAvahiAdvertisePresence(__pmServerPresence *) _PCP_HIDDEN;
void __pmServerAvahiUnadvertisePresence(__pmServerPresence *) _PCP_HIDDEN;
int __pmAvahiDiscoverServices(const char *, int, char ***) _PCP_HIDDEN;
#endif /* AVAHI_H */
| /*
* Copyright (c) 2013 Red Hat.
*
* 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.
*/
#ifndef AVAHI_H
#define AVAHI_H
void __pmServerAvahiAdvertisePresence(__pmServerPresence *) _PCP_HIDDEN;
void __pmServerAvahiUnadvertisePresence(__pmServerPresence *) _PCP_HIDDEN;
int __pmAvahiDiscoverServices(const char *, int, char ***) _PCP_HIDDEN;
#endif /* AVAHI_H */
|
Add C implementation of insertion sort. | #include <stdio.h>
#include <stdlib.h>
const int N = 1e4;
void
isort(int *ns, int n)
{
int i, j, key;
for(i = 1; i < n; i++) {
key = ns[i];
for(j = i-1; j >= 0 && key < ns[j]; j--)
ns[j+1] = ns[j];
ns[j+1] = key;
}
}
int
main(void)
{
int i;
int *ns = malloc(sizeof(int)*N);
for(i = 0; i < N; i++) {
ns[i] = N-i;
}
isort(ns, N);
for(i = 0; i < N; i++) {
if(ns[i] != i+1) {
fprintf(stderr, "Index %d is %d, expected %d.\n", i, ns[i], i+1);
exit(EXIT_FAILURE);
}
}
return EXIT_SUCCESS;
}
| |
Add a bunch of tests | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <saneopt.h>
void test_no_arg() {
char** argv;
saneopt_t* opt = saneopt_init(0, argv);
assert(saneopt_get(opt, "no-option") == NULL);
free(opt);
}
void test_no_value() {
char** argv = malloc(1 * sizeof(char*));
argv[0] = "--option";
saneopt_t* opt = saneopt_init(1, argv);
assert(strcmp(saneopt_get(opt, "option"), "") == 0);
free(argv);
free(opt);
}
void test_value() {
char** argv = malloc(4 * sizeof(char*));
argv[0] = "--option";
argv[1] = "value";
argv[2] = "--next-option";
argv[3] = "--third-option";
saneopt_t* opt = saneopt_init(4, argv);
assert(strcmp(saneopt_get(opt, "option"), "value") == 0);
assert(strcmp(saneopt_get(opt, "next-option"), "") == 0);
assert(strcmp(saneopt_get(opt, "third-option"), "") == 0);
free(argv);
free(opt);
}
int main(int argc, char** argv) {
test_no_arg();
test_no_value();
test_value();
return 0;
}
| |
Add memory size info example | #include <stdio.h>
#include <sys/sysinfo.h>
#include <stdint.h>
uint64_t get_memory_size()
{
struct sysinfo info;
sysinfo( &info );
printf("total ram %lu, mem units %lu\n", (size_t)info.totalram, (size_t)info.mem_unit);
return (size_t)info.totalram * (size_t)info.mem_unit;
}
int main(int argc, char* argv[])
{
uint64_t total_memory = get_memory_size();
printf("Total physical memory: %lu\n", total_memory);
return 0;
}
| |
Add header which imports all files | //
// IGIdenticon.h
// IGIdenticon
//
// Created by Evgeniy Yurtaev on 29/07/15.
// Copyright (c) 2015 Evgeniy Yurtaev. All rights reserved.
//
#import "IGImageGenerator.h"
#import "IGSimpleIdenticon.h"
#import "IGGitHubIdenticon.h"
#import "IGHashFunctions.h"
| |
Add 3 new classes about User Defined Functions | /* include files for the package output */
#include "CDatum.h"
#include "COutput.h"
#include "COutputLine.h"
#include "COutputList.h"
#include "COutputEvent.h"
| /* include files for the package output */
#include "CDatum.h"
#include "COutput.h"
#include "COutputLine.h"
#include "COutputList.h"
#include "COutputEvent.h"
#include "CNodeO.h"
#include "CUDFunction.h"
#include "CUDFunctionDB.h" |
Fix thread initialisation race (thread sanitizer) | //
// log_thread.h
//
#ifndef log_thread_h
#define log_thread_h
#include "queue_atomic.h"
struct log_thread;
typedef std::shared_ptr<log_thread> log_thread_ptr;
#define LOG_BUFFER_SIZE 1024
struct log_thread : std::thread
{
static const bool debug;
static const int flush_interval_msecs;
FILE* file;
const size_t num_buffers;
queue_atomic<char*> log_buffers_free;
queue_atomic<char*> log_buffers_inuse;
time_t last_time;
std::atomic<bool> running;
std::atomic<bool> writer_waiting;
std::thread thread;
std::mutex log_mutex;
std::condition_variable log_cond;
std::condition_variable writer_cond;
log_thread(int fd, size_t num_buffers);
virtual ~log_thread();
void shutdown();
void create_buffers();
void delete_buffers();
void log(time_t current_time, const char* message);
void write_logs();
void mainloop();
};
#endif
| //
// log_thread.h
//
#ifndef log_thread_h
#define log_thread_h
#include "queue_atomic.h"
struct log_thread;
typedef std::shared_ptr<log_thread> log_thread_ptr;
#define LOG_BUFFER_SIZE 1024
struct log_thread : std::thread
{
static const bool debug;
static const int flush_interval_msecs;
FILE* file;
const size_t num_buffers;
queue_atomic<char*> log_buffers_free;
queue_atomic<char*> log_buffers_inuse;
time_t last_time;
std::atomic<bool> running;
std::atomic<bool> writer_waiting;
std::mutex log_mutex;
std::condition_variable log_cond;
std::condition_variable writer_cond;
std::thread thread;
log_thread(int fd, size_t num_buffers);
virtual ~log_thread();
void shutdown();
void create_buffers();
void delete_buffers();
void log(time_t current_time, const char* message);
void write_logs();
void mainloop();
};
#endif
|
Move the lhlo dialect into its own directory. | // Copyright 2020 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// This files defines a helper to trigger the registration of dialects to
// the system.
#ifndef IREE_TOOLS_INIT_XLA_DIALECTS_H_
#define IREE_TOOLS_INIT_XLA_DIALECTS_H_
#include "mlir-hlo/Dialect/mhlo/IR/chlo_ops.h"
#include "mlir-hlo/Dialect/mhlo/IR/hlo_ops.h"
#include "mlir-hlo/Dialect/mhlo/IR/lhlo_ops.h"
#include "mlir/IR/Dialect.h"
namespace mlir {
// Add all the XLA dialects to the provided registry.
inline void registerXLADialects(DialectRegistry ®istry) {
// clang-format off
registry.insert<mlir::chlo::HloClientDialect,
mlir::lmhlo::LmhloDialect,
mlir::mhlo::MhloDialect>();
// clang-format on
}
} // namespace mlir
#endif // IREE_TOOLS_INIT_XLA_DIALECTS_H_
| // Copyright 2020 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// This files defines a helper to trigger the registration of dialects to
// the system.
#ifndef IREE_TOOLS_INIT_XLA_DIALECTS_H_
#define IREE_TOOLS_INIT_XLA_DIALECTS_H_
#include "mlir-hlo/Dialect/mhlo/IR/chlo_ops.h"
#include "mlir-hlo/Dialect/mhlo/IR/hlo_ops.h"
#include "mlir/IR/Dialect.h"
namespace mlir {
// Add all the XLA dialects to the provided registry.
inline void registerXLADialects(DialectRegistry ®istry) {
// clang-format off
registry.insert<mlir::chlo::HloClientDialect,
mlir::mhlo::MhloDialect>();
// clang-format on
}
} // namespace mlir
#endif // IREE_TOOLS_INIT_XLA_DIALECTS_H_
|
Fix backslash warning from missing blank line at end of file | #include <iostream>
#include <vector>
#include <string>
#include "erosion.h"
#include "dilation.h"
#include "opening.h"
#include "closing.h"
#include "gradient.h"
/** run: A macro to call a function. */
#define run( function, ctype, dim ) \
if ( operation == #function ) \
{ \
if ( componentType == #ctype && Dimension == dim ) \
{ \
typedef itk::Image< ctype, dim > ImageType; \
if ( type == "grayscale" ) \
{ \
function##Grayscale< ImageType >( inputFileName, outputFileName, radius, boundaryCondition, useCompression ); \
supported = true; \
} \
else if ( type == "binary" ) \
{ \
function##Binary< ImageType >( inputFileName, outputFileName, radius, bin, useCompression ); \
supported = true; \
} \
else if ( type == "parabolic" ) \
{ \
function##Parabolic< ImageType >( inputFileName, outputFileName, radius, useCompression ); \
supported = true; \
} \
} \
}
/** run2: A macro to call a function. */
#define run2( function, ctype, dim ) \
if ( operation == #function ) \
{ \
if ( componentType == #ctype && Dimension == dim ) \
{ \
typedef itk::Image< ctype, dim > ImageType; \
function< ImageType >( inputFileName, outputFileName, radius, algorithm, useCompression ); \
supported = true; \
} \
} | #include <iostream>
#include <vector>
#include <string>
#include "erosion.h"
#include "dilation.h"
#include "opening.h"
#include "closing.h"
#include "gradient.h"
/** run: A macro to call a function. */
#define run( function, ctype, dim ) \
if ( operation == #function ) \
{ \
if ( componentType == #ctype && Dimension == dim ) \
{ \
typedef itk::Image< ctype, dim > ImageType; \
if ( type == "grayscale" ) \
{ \
function##Grayscale< ImageType >( inputFileName, outputFileName, radius, boundaryCondition, useCompression ); \
supported = true; \
} \
else if ( type == "binary" ) \
{ \
function##Binary< ImageType >( inputFileName, outputFileName, radius, bin, useCompression ); \
supported = true; \
} \
else if ( type == "parabolic" ) \
{ \
function##Parabolic< ImageType >( inputFileName, outputFileName, radius, useCompression ); \
supported = true; \
} \
} \
}
/** run2: A macro to call a function. */
#define run2( function, ctype, dim ) \
if ( operation == #function ) \
{ \
if ( componentType == #ctype && Dimension == dim ) \
{ \
typedef itk::Image< ctype, dim > ImageType; \
function< ImageType >( inputFileName, outputFileName, radius, algorithm, useCompression ); \
supported = true; \
} \
}
|
Remove one more reference to __interception::GetRealFunctionAddress (follow-up to r215707) | //===-- interception_linux.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
// Windows-specific interception methods.
//===----------------------------------------------------------------------===//
#ifdef _WIN32
#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
# error "interception_win.h should be included from interception library only"
#endif
#ifndef INTERCEPTION_WIN_H
#define INTERCEPTION_WIN_H
namespace __interception {
// returns true if the old function existed, false on failure.
bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func);
} // namespace __interception
#if defined(_DLL)
# define INTERCEPT_FUNCTION_WIN(func) \
::__interception::GetRealFunctionAddress( \
#func, (::__interception::uptr*)&REAL(func))
#else
# define INTERCEPT_FUNCTION_WIN(func) \
::__interception::OverrideFunction( \
(::__interception::uptr)func, \
(::__interception::uptr)WRAP(func), \
(::__interception::uptr*)&REAL(func))
#endif
#define INTERCEPT_FUNCTION_VER_WIN(func, symver) \
INTERCEPT_FUNCTION_WIN(func)
#endif // INTERCEPTION_WIN_H
#endif // _WIN32
| //===-- interception_linux.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
// Windows-specific interception methods.
//===----------------------------------------------------------------------===//
#ifdef _WIN32
#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
# error "interception_win.h should be included from interception library only"
#endif
#ifndef INTERCEPTION_WIN_H
#define INTERCEPTION_WIN_H
namespace __interception {
// returns true if the old function existed, false on failure.
bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func);
} // namespace __interception
#if defined(_DLL)
# error Not implemented yet
#else
# define INTERCEPT_FUNCTION_WIN(func) \
::__interception::OverrideFunction( \
(::__interception::uptr)func, \
(::__interception::uptr)WRAP(func), \
(::__interception::uptr*)&REAL(func))
#endif
#define INTERCEPT_FUNCTION_VER_WIN(func, symver) \
INTERCEPT_FUNCTION_WIN(func)
#endif // INTERCEPTION_WIN_H
#endif // _WIN32
|
Fix Py_Logger to raise instances of Exception instead of strings | #ifndef PYLOGGER_H
#define PYLOGGER_H
#include "Python.h"
#include <string>
#include "cantera/base/logger.h"
namespace Cantera
{
/// Logger for Python.
/// @ingroup textlogs
class Py_Logger : public Logger
{
public:
Py_Logger() {
PyRun_SimpleString("import sys");
}
virtual ~Py_Logger() {}
virtual void write(const std::string& s) {
std::string ss = "sys.stdout.write(\"\"\"";
ss += s;
ss += "\"\"\")";
PyRun_SimpleString(ss.c_str());
PyRun_SimpleString("sys.stdout.flush()");
}
virtual void error(const std::string& msg) {
std::string err = "raise \""+msg+"\"";
PyRun_SimpleString((char*)err.c_str());
}
};
}
#endif
| #ifndef PYLOGGER_H
#define PYLOGGER_H
#include "Python.h"
#include <string>
#include "cantera/base/logger.h"
namespace Cantera
{
/// Logger for Python.
/// @ingroup textlogs
class Py_Logger : public Logger
{
public:
Py_Logger() {
PyRun_SimpleString("import sys");
}
virtual ~Py_Logger() {}
virtual void write(const std::string& s) {
std::string ss = "sys.stdout.write(\"\"\"";
ss += s;
ss += "\"\"\")";
PyRun_SimpleString(ss.c_str());
PyRun_SimpleString("sys.stdout.flush()");
}
virtual void error(const std::string& msg) {
std::string err = "raise Exception(\"\"\""+msg+"\"\"\")";
PyRun_SimpleString(err.c_str());
}
};
}
#endif
|
Disable compiled format for GCC 8 & below | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <fmt/compile.h>
// Fallback to runtime format string processing for compatibility with fmt 6.x.
#ifndef FMT_COMPILE
#define FMT_COMPILE(format_str) format_str
#endif
| /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <fmt/compile.h>
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 8
// Forcefully disable compiled format strings for GCC 8 & below until fmt is
// updated to do this automatically.
#undef FMT_COMPILE
#endif
// Fallback to runtime format string processing for compatibility with fmt 6.x.
#ifndef FMT_COMPILE
#define FMT_COMPILE(format_str) format_str
#endif
|
Remove casting away of volatile and explicit call to seL4_Yield. | /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#include <camkes.h>
#include <stdio.h>
#include <string.h>
#include <sel4/sel4.h>
int run(void) {
char *shello = "hello world";
printf("Starting...\n");
printf("-----------\n");
strcpy((void*)DataOut, shello);
while(!*((char*)DataIn))
seL4_Yield();
printf("%s read %s\n", get_instance_name(), (char*)DataIn);
return 0;
}
| /*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
#include <camkes.h>
#include <stdio.h>
#include <string.h>
int run(void) {
char *shello = "hello world";
printf("Starting...\n");
printf("-----------\n");
strcpy((void*)DataOut, shello);
while(!*((volatile char*)DataIn));
printf("%s read %s\n", get_instance_name(), (char*)DataIn);
return 0;
}
|
Fix bug spotted by Justin Hibbits. | #include "visibility.h"
#include "objc/runtime.h"
#include "gc_ops.h"
#include "class.h"
#include <stdlib.h>
#include <stdio.h>
static id allocate_class(Class cls, size_t extraBytes)
{
intptr_t *addr = calloc(cls->instance_size + extraBytes + sizeof(intptr_t), 1);
return (id)(addr + 1);
}
static void free_object(id obj)
{
free((void*)(((intptr_t)obj) - 1));
}
static void *alloc(size_t size)
{
return calloc(size, 1);
}
PRIVATE struct gc_ops gc_ops_none =
{
.allocate_class = allocate_class,
.free_object = free_object,
.malloc = alloc,
.free = free
};
PRIVATE struct gc_ops *gc = &gc_ops_none;
PRIVATE BOOL isGCEnabled = NO;
#ifndef ENABLE_GC
PRIVATE void enableGC(BOOL exclusive)
{
fprintf(stderr, "Attempting to enable garbage collection, but your"
"Objective-C runtime was built without garbage collection"
"support\n");
abort();
}
#endif
| #include "visibility.h"
#include "objc/runtime.h"
#include "gc_ops.h"
#include "class.h"
#include <stdlib.h>
#include <stdio.h>
static id allocate_class(Class cls, size_t extraBytes)
{
intptr_t *addr = calloc(cls->instance_size + extraBytes + sizeof(intptr_t), 1);
return (id)(addr + 1);
}
static void free_object(id obj)
{
free((void*)(((intptr_t*)obj) - 1));
}
static void *alloc(size_t size)
{
return calloc(size, 1);
}
PRIVATE struct gc_ops gc_ops_none =
{
.allocate_class = allocate_class,
.free_object = free_object,
.malloc = alloc,
.free = free
};
PRIVATE struct gc_ops *gc = &gc_ops_none;
PRIVATE BOOL isGCEnabled = NO;
#ifndef ENABLE_GC
PRIVATE void enableGC(BOOL exclusive)
{
fprintf(stderr, "Attempting to enable garbage collection, but your"
"Objective-C runtime was built without garbage collection"
"support\n");
abort();
}
#endif
|
Add newline to end of header | /*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOAD_SYSTEM_ROOTS_H
#define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOAD_SYSTEM_ROOTS_H
namespace grpc_core {
// Returns a slice containing roots from the OS trust store
grpc_slice LoadSystemRootCerts();
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOAD_SYSTEM_ROOTS_H */ | /*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOAD_SYSTEM_ROOTS_H
#define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOAD_SYSTEM_ROOTS_H
namespace grpc_core {
// Returns a slice containing roots from the OS trust store
grpc_slice LoadSystemRootCerts();
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOAD_SYSTEM_ROOTS_H */
|
Add Function to get avaliable Effect name | #ifndef __SPU_H__
#define __SPU_H__
typedef enum {
NONE,
VOLUME,
COMPRESSOR,
DISTORTION,
OVERDRIVE,
DELAY,
REVERB,
FLANGER,
EQULIZER,
BACK,
EFFECT_TYPE_NUM
} EffectType_t;
void SignalProcessingUnit(void const * argument);
void attachNewEffect(uint32_t stage, EffectType_t effectType);
void demolishEffect(uint32_t stage);
#endif //__SPU_H__
| #ifndef __SPU_H__
#define __SPU_H__
typedef enum {
NONE,
VOLUME,
COMPRESSOR,
DISTORTION,
OVERDRIVE,
DELAY,
REVERB,
FLANGER,
EQULIZER,
EFFECT_TYPE_NUM
} EffectType_t;
void SignalProcessingUnit(void const * argument);
void attachEffect(uint32_t stage, EffectType_t effectType);
const char *cvtToEffectName(EffectType_t ee);
#endif //__SPU_H__
|
Fix test key initialization to be endian-neutral | #include "siphash.h"
#include <stdio.h>
int main(void)
{
uint64_t k0 = 0x0706050403020100ull;
uint64_t k1 = 0x0f0e0d0c0b0a0908ull;
uint8_t msg[] = {0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08, 0x09,
0x0a, 0x0b, 0x0c, 0x0d, 0x0e};
uint64_t s = siphash24(k0, k1, msg, sizeof(msg));
printf("SipHash-2-4 test: 0x%016llx (expected 0x%016llx)\n", s, 0xa129ca6149be45e5ull);
return 0;
}
| #include "siphash.h"
#include <stdio.h>
int main(void)
{
uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
uint64_t k0 = *(uint64_t*)(key + 0);
uint64_t k1 = *(uint64_t*)(key + 8);
uint8_t msg[] = {0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08, 0x09,
0x0a, 0x0b, 0x0c, 0x0d, 0x0e};
uint64_t s = siphash24(k0, k1, msg, sizeof(msg));
printf("SipHash-2-4 test: 0x%016llx (expected 0x%016llx)\n", s, 0xa129ca6149be45e5ull);
return 0;
}
|
Clarify row and column iterators | #ifndef LB_MATRIX_INCLUDED
typedef struct {
double* data;
unsigned int num_rows;
unsigned int num_cols;
} Matrix;
Matrix lb_create_matrix(double* data, unsigned int num_rows, unsigned int num_cols);
Matrix lb_allocate_matrix(unsigned int num_rows, unsigned int num_cols);
#define lb_mat_element_ptr(A,i,j) (A.data + j * A.num_cols + i)
#define lb_mat_element(A,i,j) A.data[j * A.num_cols + i]
#define lb_mat_row_element(A,row,offset) A.data[offset + row * A.num_cols]
#define lb_mat_col_element(A,col,offset) A.data[col + offset * A.num_cols]
#define lb_vec_element_ptr(v,j) v.data + j;
void lbmm(Matrix A, Matrix B, Matrix result);
void lbma(Matrix A, Matrix B, Matrix result);
#define LB_MATRIX_INCLUDED
#endif
| #ifndef LB_MATRIX_INCLUDED
typedef struct {
double* data;
unsigned int num_rows;
unsigned int num_cols;
} Matrix;
Matrix lb_create_matrix(double* data, unsigned int num_rows, unsigned int num_cols);
Matrix lb_allocate_matrix(unsigned int num_rows, unsigned int num_cols);
#define lb_mat_element_ptr(A,i,j) (A.data + j * A.num_cols + i)
#define lb_mat_element(A,i,j) A.data[j * A.num_cols + i]
#define lb_mat_row_element(A,i,j) A.data[i * A.num_cols + j]
#define lb_mat_col_element(A,i,j) A.data[j * A.num_cols + i]
#define lb_vec_element_ptr(v,j) v.data + j;
void lbmm(Matrix A, Matrix B, Matrix result);
void lbma(Matrix A, Matrix B, Matrix result);
#define LB_MATRIX_INCLUDED
#endif
|
Fix overflow bug introduced in f6b3328f | #include <ctype.h>
#include <stdio.h>
#include "debug.h"
#ifndef NDEBUG
const char * const col[] = {MAG, RED, YEL, CYN, BLU, GRN};
regex_t _comp;
// Initialize the regular expression used for restricting debug output
static void __attribute__((constructor)) premain()
{
if (regcomp(&_comp, DCOMPONENT, REG_EXTENDED | REG_ICASE | REG_NOSUB))
die("may not be a valid regexp: %s", DCOMPONENT);
}
// And free is again
static void __attribute__((destructor)) postmain() { regfree(&_comp); }
// Print a hexdump of the given block
void hexdump(const void * const ptr, const size_t len)
{
const uint8_t * const buf = ptr;
for (uint8_t i = 0; i < len; i += 16) {
fprintf(stderr, "%06x: ", i);
for (uint8_t j = 0; j < 16; j++) {
if (i + j < len)
fprintf(stderr, "%02hhx ", buf[i + j]);
else
fprintf(stderr, " ");
fprintf(stderr, " ");
}
for (uint8_t j = 0; j < 16; j++) {
if (i + j < len)
fprintf(stderr, "%c", isprint(buf[i + j]) ? buf[i + j] : '.');
}
fprintf(stderr, "\n");
}
}
#endif
| #include <ctype.h>
#include <stdio.h>
#include "debug.h"
#ifndef NDEBUG
const char * const col[] = {MAG, RED, YEL, CYN, BLU, GRN};
regex_t _comp;
// Initialize the regular expression used for restricting debug output
static void __attribute__((constructor)) premain()
{
if (regcomp(&_comp, DCOMPONENT, REG_EXTENDED | REG_ICASE | REG_NOSUB))
die("may not be a valid regexp: %s", DCOMPONENT);
}
// And free is again
static void __attribute__((destructor)) postmain() { regfree(&_comp); }
// Print a hexdump of the given block
void hexdump(const void * const ptr, const size_t len)
{
const uint8_t * const buf = ptr;
for (size_t i = 0; i < len; i += 16) {
fprintf(stderr, "%06lx: ", i);
for (size_t j = 0; j < 16; j++) {
if (i + j < len)
fprintf(stderr, "%02hhx ", buf[i + j]);
else
fprintf(stderr, " ");
fprintf(stderr, " ");
}
for (size_t j = 0; j < 16; j++) {
if (i + j < len)
fprintf(stderr, "%c", isprint(buf[i + j]) ? buf[i + j] : '.');
}
fprintf(stderr, "\n");
}
}
#endif
|
Make this darwin only for now while investigating to clear up x86_64 Release+Asserts linux tests. | // RUN: %clang_cc1 -emit-llvm %s -o /dev/null
struct foo { int X; };
struct bar { int Y; };
extern int Func(struct foo*) __asm__("Func64");
extern int Func64(struct bar*);
int Func(struct foo *F) {
return 1;
}
int Func64(struct bar* B) {
return 0;
}
int test() {
Func(0); /* should be renamed to call Func64 */
Func64(0);
}
| // RUN: %clang_cc1 -emit-llvm %s -triple x86_64-apple-darwin -o /dev/null
struct foo { int X; };
struct bar { int Y; };
extern int Func(struct foo*) __asm__("Func64");
extern int Func64(struct bar*);
int Func(struct foo *F) {
return 1;
}
int Func64(struct bar* B) {
return 0;
}
int test() {
Func(0); /* should be renamed to call Func64 */
Func64(0);
}
|
Test from PR2332; bug already fixed by r51311. | // RUN: clang -fsyntax-only %s -verify
x(a) int a; {return a;}
y(b) int b; {return a;} // expected-error {{use of undeclared identifier}}
| // RUN: clang -fsyntax-only %s -verify
x(a) int a; {return a;}
y(b) int b; {return a;} // expected-error {{use of undeclared identifier}}
// PR2332
a(a)int a;{a=10;return a;}
|
Disable another warning in GLFW. | #pragma once
#define GLFW_INCLUDE_GLU
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
# include <GLFW/glfw3.h>
#pragma GCC diagnostic pop
#if __clang__
#pragma clang diagnostic pop
#endif
| #pragma once
#define GLFW_INCLUDE_GLU
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
#endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
# include <GLFW/glfw3.h>
#pragma GCC diagnostic pop
#if __clang__
#pragma clang diagnostic pop
#endif
|
Define alias type, forward declaration | #ifndef MAP_H
#define MAP_H
#include <vector>
#include <map>
#include "DelaunayTriangulation.h"
#include "Structure.h"
#include "QuadTree.h"
#endif | #ifndef MAP_H
#define MAP_H
#include <vector>
#include <map>
#include "DelaunayTriangulation.h"
#include "Structure.h"
#include "QuadTree.h"
using pCenterQT = QuadTree<Center*>;
// Forward Declaration
class Vector2;
namespace Noise
{
namespace Module
{
class Perlin;
}
}
#endif |
Add missing backticks and period in media attachment header comment. | //
// LYRUIMediaAttachment.h
// LayerSample
//
// Created by Kevin Coleman on 9/12/14.
// Copyright (c) 2014 Layer, Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
/**
@abstract The `LYRUIMediaAttachment` class configures the appropriate size
for an NSTextAttachment to comfortably fit inside of a LYRUIMessageInputToolbar
*/
@interface LYRUIMediaAttachment : NSTextAttachment
@end
| //
// LYRUIMediaAttachment.h
// LayerSample
//
// Created by Kevin Coleman on 9/12/14.
// Copyright (c) 2014 Layer, Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
/**
@abstract The `LYRUIMediaAttachment` class configures the appropriate size
for an NSTextAttachment to comfortably fit inside of a `LYRUIMessageInputToolbar`.
*/
@interface LYRUIMediaAttachment : NSTextAttachment
@end
|
Update header documentation for BTAPIClient-Internal | #import "BTAnalyticsService.h"
#import "BTAPIClient.h"
#import "BTClientMetadata.h"
#import "BTClientToken.h"
#import "BTHTTP.h"
#import "BTJSON.h"
NS_ASSUME_NONNULL_BEGIN
@class BTPaymentMethodNonce;
@interface BTAPIClient ()
@property (nonatomic, copy, nullable) NSString *tokenizationKey;
@property (nonatomic, strong, nullable) BTClientToken *clientToken;
@property (nonatomic, strong) BTHTTP *http;
@property (nonatomic, strong) BTHTTP *configurationHTTP;
/*!
@brief Client metadata that is used for tracking the client session
*/
@property (nonatomic, readonly, strong) BTClientMetadata *metadata;
/*!
@brief Exposed for testing analytics
*/
@property (nonatomic, strong) BTAnalyticsService *analyticsService;
/*!
@brief Sends this event and all queued analytics events. Used by internal clients.
*/
- (void)sendAnalyticsEvent:(NSString *)eventName;
/*!
@brief Queues an analytics event to be sent.
*/
- (void)queueAnalyticsEvent:(NSString *)eventName;
/*!
@brief An internal initializer to toggle whether to send an analytics event during initialization.
@discussion This prevents copyWithSource:integration: from sending a duplicate event. It can also be used to suppress excessive network chatter during testing.
*/
- (nullable instancetype)initWithAuthorization:(NSString *)authorization sendAnalyticsEvent:(BOOL)sendAnalyticsEvent;
@end
NS_ASSUME_NONNULL_END
| #import "BTAnalyticsService.h"
#import "BTAPIClient.h"
#import "BTClientMetadata.h"
#import "BTClientToken.h"
#import "BTHTTP.h"
#import "BTJSON.h"
NS_ASSUME_NONNULL_BEGIN
@class BTPaymentMethodNonce;
@interface BTAPIClient ()
@property (nonatomic, copy, nullable) NSString *tokenizationKey;
@property (nonatomic, strong, nullable) BTClientToken *clientToken;
@property (nonatomic, strong) BTHTTP *http;
@property (nonatomic, strong) BTHTTP *configurationHTTP;
/*!
@brief Client metadata that is used for tracking the client session
*/
@property (nonatomic, readonly, strong) BTClientMetadata *metadata;
/*!
@brief Exposed for testing analytics
*/
@property (nonatomic, strong) BTAnalyticsService *analyticsService;
/*!
@brief Sends this event and all queued analytics events. Use `queueAnalyticsEvent` for low priority events.
*/
- (void)sendAnalyticsEvent:(NSString *)eventName;
/*!
@brief Queues an analytics event to be sent.
*/
- (void)queueAnalyticsEvent:(NSString *)eventName;
/*!
@brief An internal initializer to toggle whether to send an analytics event during initialization.
@discussion This prevents copyWithSource:integration: from sending a duplicate event. It can also be used to suppress excessive network chatter during testing.
*/
- (nullable instancetype)initWithAuthorization:(NSString *)authorization sendAnalyticsEvent:(BOOL)sendAnalyticsEvent;
@end
NS_ASSUME_NONNULL_END
|
Make assert in 36/01 stronger | // SKIP PARAM: --set solver td3 --enable ana.int.interval --set ana.base.arrays.domain partitioned --set ana.activated "['base','threadid','threadflag','expRelation','mallocWrapper','apron']" --set ana.base.privatization none --set ana.apron.privatization dummy
// Example from https://www-apr.lip6.fr/~mine/publi/article-mine-HOSC06.pdf
void main(void) {
int X = 0;
int N = rand();
if(N < 0) { N = 0; }
while(X < N) {
X++;
}
assert(X-N == 0);
assert(X == N);
if(X == N) {
N = 8;
} else {
// is dead code but if that is detected or not depends on what we do in branch
// currently we can't detect this
N = 42;
}
}
| // SKIP PARAM: --set solver td3 --enable ana.int.interval --set ana.base.arrays.domain partitioned --set ana.activated "['base','threadid','threadflag','expRelation','mallocWrapper','apron']" --set ana.base.privatization none --set ana.apron.privatization dummy
// Example from https://www-apr.lip6.fr/~mine/publi/article-mine-HOSC06.pdf
void main(void) {
int X = 0;
int N = rand();
if(N < 0) { N = 0; }
while(X < N) {
X++;
}
assert(X-N == 0);
assert(X == N);
if(X == N) {
N = 8;
} else {
// dead code
N = 42;
}
assert(N == 8);
}
|
Make the cache directory accessor public. | //
// CDAUtilities.h
// ContentfulSDK
//
// Created by Boris Bügling on 04/03/14.
//
//
#import <ContentfulDeliveryAPI/CDAClient.h>
#import <Foundation/Foundation.h>
NSString* CDACacheFileNameForQuery(CDAClient* client, CDAResourceType resourceType, NSDictionary* query);
NSString* CDACacheFileNameForResource(CDAResource* resource);
NSArray* CDAClassGetSubclasses(Class parentClass);
void CDADecodeObjectWithCoder(id object, NSCoder* aDecoder);
void CDAEncodeObjectWithCoder(id object, NSCoder* aCoder);
BOOL CDAIsNoNetworkError(NSError* error);
| //
// CDAUtilities.h
// ContentfulSDK
//
// Created by Boris Bügling on 04/03/14.
//
//
#import <ContentfulDeliveryAPI/CDAClient.h>
#import <Foundation/Foundation.h>
NSString* CDACacheDirectory();
NSString* CDACacheFileNameForQuery(CDAClient* client, CDAResourceType resourceType, NSDictionary* query);
NSString* CDACacheFileNameForResource(CDAResource* resource);
NSArray* CDAClassGetSubclasses(Class parentClass);
void CDADecodeObjectWithCoder(id object, NSCoder* aDecoder);
void CDAEncodeObjectWithCoder(id object, NSCoder* aCoder);
BOOL CDAIsNoNetworkError(NSError* error);
|
Change PointsToMeters ratio to a float, so we doing floating point math | //
// PHYGeometry.h
// PHYKit
//
// Created by Nora Trapp on 8/1/13.
// Copyright (c) 2013 Nora Trapp. All rights reserved.
//
#import <Box2D/Common/b2Math.h>
#define kPointsToMeterRatio (32)
#define PointsToMeters(points) (points / kPointsToMeterRatio)
#define MetersToPoints(meters) (meters * kPointsToMeterRatio)
#define CGPointTob2Vec2(point) (b2Vec2(PointsToMeters(point.x), PointsToMeters(point.y)))
#define b2Vec2ToCGPoint(vector) (CGPointMake(MetersToPoints(vector.x), MetersToPoints(vector.y)))
| //
// PHYGeometry.h
// PHYKit
//
// Created by Nora Trapp on 8/1/13.
// Copyright (c) 2013 Nora Trapp. All rights reserved.
//
#import <Box2D/Common/b2Math.h>
#define kPointsToMeterRatio (32.0)
#define PointsToMeters(points) (points / kPointsToMeterRatio)
#define MetersToPoints(meters) (meters * kPointsToMeterRatio)
#define CGPointTob2Vec2(point) (b2Vec2(PointsToMeters(point.x), PointsToMeters(point.y)))
#define b2Vec2ToCGPoint(vector) (CGPointMake(MetersToPoints(vector.x), MetersToPoints(vector.y)))
|
Reorder terms by expected size, though this does not affect calculation | #include "kernel/log.h"
#include "normalize.h"
#include "../reinterpret.h"
#include <math.h>
static double _finite(int64_t i)
{
const double ln2[] = { 0x1.62e42fefa4p-1, -0x1.8432a1b0e2634p-43 };
int64_t exponent = (i - 0x3FE6A09E667F3BCD) >> 52;
double x = reinterpret(double, i - (exponent << 52)) - 1;
double z = x / (x + 2);
double h = 0.5 * x * x;
return z * (h + _kernel_log(z)) + exponent * ln2[1] - h + x + exponent * ln2[0];
}
double log(double x)
{
int64_t i = reinterpret(int64_t, x);
if (i <= 0)
return i << 1 == 0 ? -INFINITY : NAN;
if (i < 0x7FF0000000000000)
return _finite(_normalize(i));
return x;
}
| #include "kernel/log.h"
#include "normalize.h"
#include "../reinterpret.h"
#include <math.h>
static double _finite(int64_t i)
{
const double ln2[] = { 0x1.62e42fefa4p-1, -0x1.8432a1b0e2634p-43 };
int64_t exponent = (i - 0x3FE6A09E667F3BCD) >> 52;
double x = reinterpret(double, i - (exponent << 52)) - 1;
double z = x / (x + 2);
double h = 0.5 * x * x;
return exponent * ln2[1] + z * (h + _kernel_log(z)) - h + x + exponent * ln2[0];
}
double log(double x)
{
int64_t i = reinterpret(int64_t, x);
if (i <= 0)
return i << 1 == 0 ? -INFINITY : NAN;
if (i < 0x7FF0000000000000)
return _finite(_normalize(i));
return x;
}
|
Add minimized test where abort fails. | // SKIP PARAM: --enable exp.solver.td3.restart.wpoint.enabled --enable exp.solver.td3.abort
#include<stdlib.h>
struct a {
int b;
} c(), *f;
int g;
void d();
void e();
int main() {
void *h = calloc(1, sizeof(struct a));
f = h;
d(e);
while (1) {
g = c;
if (c)
break;
f->b = 0;
}
d(h);
} | |
Change monitor_grid_set function to also accept the grid geometry (used for virtual-->canvas coordinate functions). | #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
Evas_Object *e_smart_monitor_add(Evas *evas);
void e_smart_monitor_crtc_set(Evas_Object *obj, Ecore_X_Randr_Crtc crtc, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch);
void e_smart_monitor_output_set(Evas_Object *obj, Ecore_X_Randr_Output output);
void e_smart_monitor_grid_set(Evas_Object *obj, Evas_Object *grid);
void e_smart_monitor_background_set(Evas_Object *obj, Evas_Coord dx, Evas_Coord dy);
# endif
#endif
| #ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
# define E_SMART_MONITOR_H
Evas_Object *e_smart_monitor_add(Evas *evas);
void e_smart_monitor_crtc_set(Evas_Object *obj, Ecore_X_Randr_Crtc crtc, Evas_Coord cx, Evas_Coord cy, Evas_Coord cw, Evas_Coord ch);
void e_smart_monitor_output_set(Evas_Object *obj, Ecore_X_Randr_Output output);
void e_smart_monitor_grid_set(Evas_Object *obj, Evas_Object *grid, Evas_Coord gx, Evas_Coord gy, Evas_Coord gw, Evas_Coord gh);
void e_smart_monitor_virtual_size_set(Evas_Object *obj, Evas_Coord vw, Evas_Coord vh);
void e_smart_monitor_background_set(Evas_Object *obj, Evas_Coord dx, Evas_Coord dy);
# endif
#endif
|
Convert all files on the master branch to unix line endings. | // Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../lpng_v163/png.h"
| // Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../lpng_v163/png.h"
|
Add SUNOS41 to an existing conditional compilation directive. | #ifndef _CONDOR_SYSCALLS_H
#define _CONDOR_SYSCALLS_H
#if defined( AIX32)
# include "syscall.aix32.h"
#else
# include <syscall.h>
#endif
typedef int BOOL;
static const int SYS_LOCAL = 1;
static const int SYS_REMOTE = 0;
static const int SYS_RECORDED = 2;
static const int SYS_MAPPED = 2;
static const int SYS_UNRECORDED = 0;
static const int SYS_UNMAPPED = 0;
#if defined(__cplusplus)
extern "C" {
#endif
int SetSyscalls( int mode );
int GetSyscallMode();
BOOL LocalSysCalls();
BOOL RemoteSysCalls();
BOOL MappingFileDescriptors();
int REMOTE_syscall( int syscall_num, ... );
#if defined(OSF1) || defined(HPUX9)
int syscall( int, ... );
#endif
#if defined(__cplusplus)
}
#endif
#endif
| #ifndef _CONDOR_SYSCALLS_H
#define _CONDOR_SYSCALLS_H
#if defined( AIX32)
# include "syscall.aix32.h"
#else
# include <syscall.h>
#endif
typedef int BOOL;
static const int SYS_LOCAL = 1;
static const int SYS_REMOTE = 0;
static const int SYS_RECORDED = 2;
static const int SYS_MAPPED = 2;
static const int SYS_UNRECORDED = 0;
static const int SYS_UNMAPPED = 0;
#if defined(__cplusplus)
extern "C" {
#endif
int SetSyscalls( int mode );
int GetSyscallMode();
BOOL LocalSysCalls();
BOOL RemoteSysCalls();
BOOL MappingFileDescriptors();
int REMOTE_syscall( int syscall_num, ... );
#if defined(OSF1) || defined(HPUX9) || defined(SUNOS41)
int syscall( int, ... );
#endif
#if defined(__cplusplus)
}
#endif
#endif
|
Make 64Bit Friendly, NonStatic for Ubuntu 14.04 delete unneeded files | #include "k2pktdef.h"
#define TRACE2_STA_LEN 7
#define TRACE2_CHAN_LEN 9 /* 4 bytes plus padding for loc and version */
#define TRACE2_NET_LEN 9
#define TRACE2_LOC_LEN 3
#define K2INFO_TYPE_STRING "TYPE_K2INFO_PACKET"
typedef struct {
char net[TRACE2_NET_LEN]; /* Network name */
char sta[TRACE2_STA_LEN]; /* Site name */
qint16 data_type; /* see K2INFO_TYPE #defines below */
quint32 epoch_sent; /* local time sent */
quint16 reserved[5]; /* reserved for future use */
} K2INFO_HEADER;
#define K2INFO_TYPE_HEADER 1 /* k2 header params */
#define K2INFO_TYPE_STATUS 2 /* k2 regular status packet */
#define K2INFO_TYPE_ESTATUS 3 /* k2 extended status packet (old) */
#define K2INFO_TYPE_E2STATUS 4 /* k2 extended status packet v2 */
#define K2INFO_TYPE_COMM 5 /* k2ew packet processing stats */
#define MAX_K2INFOBUF_SIZ 4096
typedef union {
qint8 msg[MAX_K2INFOBUF_SIZ];
K2INFO_HEADER k2info;
} K2infoPacket;
| #include "k2pktdef.h"
#define TRACE2_STA_LEN 7
#define TRACE2_CHAN_LEN 9 /* 4 bytes plus padding for loc and version */
#define TRACE2_NET_LEN 9
#define TRACE2_LOC_LEN 3
#define K2_TIME_CONV ((unsigned long)315532800)
#define K2INFO_TYPE_STRING "TYPE_K2INFO_PACKET"
typedef struct {
char net[TRACE2_NET_LEN]; /* Network name */
char sta[TRACE2_STA_LEN]; /* Site name */
qint16 data_type; /* see K2INFO_TYPE #defines below */
quint32 epoch_sent; /* local time sent */
quint16 reserved[5]; /* reserved for future use */
} K2INFO_HEADER;
#define K2INFO_TYPE_HEADER 1 /* k2 header params */
#define K2INFO_TYPE_STATUS 2 /* k2 regular status packet */
#define K2INFO_TYPE_ESTATUS 3 /* k2 extended status packet (old) */
#define K2INFO_TYPE_E2STATUS 4 /* k2 extended status packet v2 */
#define K2INFO_TYPE_COMM 5 /* k2ew packet processing stats */
#define MAX_K2INFOBUF_SIZ 4096
typedef union {
qint8 msg[MAX_K2INFOBUF_SIZ];
K2INFO_HEADER k2info;
} K2infoPacket;
|
Drop $Id$ and update copyright | /*
* $Id$
*
* Copyright (c) 2010-2011, Juniper Networks, Inc.
* All rights reserved.
* This SOFTWARE is licensed under the LICENSE provided in the
* ../Copyright file. By downloading, installing, copying, or otherwise
* using the SOFTWARE, you agree to be bound by the terms of that
* LICENSE.
*/
/**
* Called from the debugger when we want to profile a script.
*
* @docp document pointer for the script
* @returns TRUE is there was a problem
*/
int
slaxProfOpen (xmlDocPtr docp);
/**
* Called when we enter a instruction.
*
* @docp document pointer
* @inst instruction (slax/xslt code) pointer
*/
void
slaxProfEnter (xmlNodePtr inst);
/**
* Called when we exit an instruction
*/
void
slaxProfExit (void);
#if 0
typedef int (*slaxProfCallback_t)(void *, const char *fmt, ...);
#endif
/**
* Report the results
*/
void
slaxProfReport (int);
/**
* Clear all values
*/
void
slaxProfClear (void);
/**
* Done (free resources)
*/
void
slaxProfClose (void);
| /*
* Copyright (c) 2010-201e, Juniper Networks, Inc.
* All rights reserved.
* This SOFTWARE is licensed under the LICENSE provided in the
* ../Copyright file. By downloading, installing, copying, or otherwise
* using the SOFTWARE, you agree to be bound by the terms of that
* LICENSE.
*/
/**
* Called from the debugger when we want to profile a script.
*
* @docp document pointer for the script
* @returns TRUE is there was a problem
*/
int
slaxProfOpen (xmlDocPtr docp);
/**
* Called when we enter a instruction.
*
* @docp document pointer
* @inst instruction (slax/xslt code) pointer
*/
void
slaxProfEnter (xmlNodePtr inst);
/**
* Called when we exit an instruction
*/
void
slaxProfExit (void);
#if 0
typedef int (*slaxProfCallback_t)(void *, const char *fmt, ...);
#endif
/**
* Report the results
*/
void
slaxProfReport (int);
/**
* Clear all values
*/
void
slaxProfClear (void);
/**
* Done (free resources)
*/
void
slaxProfClose (void);
|
Add to header file IDPSingletonModel. | #import "IDPBlock.h"
#import "IDPBufferArray.h"
#import "IDPKVOContext.h"
#import "IDPKVOMutableArray.h"
#import "IDPKeyPathObserver.h"
#import "IDPMachTimer.h"
#import "IDPMutableArray.h"
#import "IDPMutableDictionary.h"
#import "IDPOCContext.h"
#import "IDPOCImplementation.h"
#import "IDPOCStack.h"
#import "NSObject+IDPOCExtensionsPrivate.h"
#import "IDPReference.h"
#import "IDPRetainingReference.h"
#import "IDPWeakReference.h"
#import "IDPRetainingDictionary.h"
#import "IDPStackArray.h"
#import "IDPURLConnection.h"
#import "IDPURLRequest.h"
#import "IDPWeakArray.h"
| #import "IDPBlock.h"
#import "IDPBufferArray.h"
#import "IDPKVOContext.h"
#import "IDPKVOMutableArray.h"
#import "IDPKeyPathObserver.h"
#import "IDPMachTimer.h"
#import "IDPMutableArray.h"
#import "IDPMutableDictionary.h"
#import "IDPOCContext.h"
#import "IDPOCImplementation.h"
#import "IDPOCStack.h"
#import "NSObject+IDPOCExtensionsPrivate.h"
#import "IDPReference.h"
#import "IDPRetainingReference.h"
#import "IDPWeakReference.h"
#import "IDPRetainingDictionary.h"
#import "IDPStackArray.h"
#import "IDPURLConnection.h"
#import "IDPURLRequest.h"
#import "IDPWeakArray.h"
#import "IDPSingletonModel.h"
|
Add color testing command with random order, to uncover subtle bugs | /*
* This file is part of Kotaka, a mud library for DGD
* http://github.com/shentino/kotaka
*
* Copyright (C) 2012 Raymond Jennings
*
* 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/>.
*/
#include <kotaka/paths.h>
#include <text/paths.h>
inherit LIB_BIN;
void main(string args)
{
object user;
object painter;
object gc;
int x, y, b;
user = query_user();
painter = new_object(LWO_PAINTER);
painter->set_size(16, 8);
gc = painter->create_gc();
gc->set_clip(0, 0, 15, 7);
b = random(128);
for (y = 0; y < 8; y++) {
for (x = 0; x < 16; x++) {
gc->set_color((x + y * 16) ^ b);
gc->move_pen(x, y);
gc->draw("X");
}
}
send_out(implode(painter->render_color(), "\n") + "\n");
}
| |
Add an option to force use of auto_ptr for legacy STL implementations. | // Copyright 2014 The open-vcdiff Authors. All Rights Reserved.
// Author: Mostyn Bramley-Moore
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OPEN_VCDIFF_UNIQUE_PTR_H_
#define OPEN_VCDIFF_UNIQUE_PTR_H_
// std::auto_ptr is deprecated in C++11, in favor of std::unique_ptr.
// Since C++11 is not widely available yet, the macro below is used to
// select the best available option.
#include <memory>
#if __cplusplus >= 201103L
// C++11
#define UNIQUE_PTR std::unique_ptr
#else
#define UNIQUE_PTR std::auto_ptr
#endif
#endif // OPEN_VCDIFF_UNIQUE_PTR_H_
| // Copyright 2014 The open-vcdiff Authors. All Rights Reserved.
// Author: Mostyn Bramley-Moore
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OPEN_VCDIFF_UNIQUE_PTR_H_
#define OPEN_VCDIFF_UNIQUE_PTR_H_
// std::auto_ptr is deprecated in C++11, in favor of std::unique_ptr.
// Since C++11 is not widely available yet, the macro below is used to
// select the best available option.
#include <memory>
#if __cplusplus >= 201103L && !defined(OPEN_VCDIFF_USE_AUTO_PTR) // C++11
#define UNIQUE_PTR std::unique_ptr
#else
#define UNIQUE_PTR std::auto_ptr
#endif // __cplusplus >= 201103L && !defined(OPEN_VCDIFF_USE_AUTO_PTR)
#endif // OPEN_VCDIFF_UNIQUE_PTR_H_
|
Make sure file stat actually finished. Don't check a size_t for neg. | //
// Created by gravypod on 9/20/17.
//
#include "files.h"
#include <sys/stat.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
long int fsize(const char *filename)
{
struct stat st;
if (stat(filename, &st) == 0)
return st.st_size;
return -1;
}
char* read_file(const char* filename)
{
const size_t file_size = (size_t) fsize(filename);
FILE *f;
if (file_size == -1 || !(f = fopen(filename, "rb"))) {
return NULL;
}
size_t data_left = file_size;
char *buffer = malloc(file_size + 1);
char *tmp = buffer;
while (data_left > 0)
{
const size_t len = fread((void *) tmp, sizeof(char), sizeof(buffer), f);
data_left -= len;
tmp += len;
}
buffer[file_size] = 0;
fclose(f);
return buffer;
} | //
// Created by gravypod on 9/20/17.
//
#include "files.h"
#include <sys/stat.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
long int fsize(const char *filename)
{
struct stat st;
if (stat(filename, &st) == 0)
return st.st_size;
return -1;
}
char* read_file(const char* filename)
{
long int reported_size = fsize(filename);
FILE *f;
if (reported_size == -1 || !(f = fopen(filename, "rb"))) {
return NULL;
}
const size_t file_size = (size_t) reported_size;
size_t data_left = file_size;
char *buffer = malloc(file_size + 1);
char *tmp = buffer;
while (data_left > 0)
{
const size_t len = fread((void *) tmp, sizeof(char), sizeof(buffer), f);
data_left -= len;
tmp += len;
}
buffer[file_size] = 0;
fclose(f);
return buffer;
} |
Add as_address on mnemonic argument. | #include <vector>
enum GHCMnemonic {
MOV,
INC,
DEC,
ADD,
SUB,
MUL,
DIV,
AND,
OR,
XOR,
JLT,
JEQ,
JGT,
INT,
HLT
};
enum GHCRegister {
A = 0,
B,
C,
D,
E,
F,
G,
H,
PC
};
enum GHCArgumentType {
Constant,
Register,
Memory
};
struct GHCArgument {
GHCArgumentType type;
unsigned int id;
};
struct GHCInstruction {
GHCMnemonic mnemonic;
std::vector<GHCArgument> arguments;
};
| #include <vector>
enum GHCMnemonic {
MOV,
INC,
DEC,
ADD,
SUB,
MUL,
DIV,
AND,
OR,
XOR,
JLT,
JEQ,
JGT,
INT,
HLT
};
enum GHCRegister {
A = 0,
B,
C,
D,
E,
F,
G,
H,
PC
};
enum GHCArgumentType {
Constant,
Register,
Memory
};
struct GHCArgument {
GHCArgumentType type;
bool as_address;
unsigned int id;
};
struct GHCInstruction {
GHCMnemonic mnemonic;
std::vector<GHCArgument> arguments;
};
|
Add ansi colors file header | #ifndef _ANSI_COLORS
#define _ANSI_COLORS
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_RESET "\x1b[0m"
#endif
| |
Use "is_signal_frame" instead of IA64_FLAG_SIGTRAMP flag bit. | /* libunwind - a platform-independent unwind library
Copyright (C) 2001-2002 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_is_signal_frame (unw_cursor_t *cursor)
{
struct ia64_cursor *c = (struct ia64_cursor *) cursor;
struct ia64_state_record sr;
int ret;
/* Crude and slow, but we need to peek ahead into the unwind
descriptors to find out if the current IP is inside the signal
trampoline. */
ret = ia64_create_state_record (c, &sr);
if (ret < 0)
return ret;
return sr.is_signal_frame;
}
| |
Add missing errno.h include for Linux/UNIX | /* Very simple example for parse buf example */
#include <string.h>
#include <stdlib.h>
#include "confuse.h"
int main(void)
{
cfg_t *cfg;
cfg_opt_t arg_opts[] = {
CFG_STR("value", "default", CFGF_NONE),
CFG_END()
};
cfg_opt_t opts[] = {
CFG_INT("delay", 3, CFGF_NONE),
CFG_STR("message", "This is a message", CFGF_NONE),
CFG_SEC("argument", arg_opts, CFGF_MULTI | CFGF_TITLE),
CFG_END()
};
char *buf =
" delay = 3\n"
"# message = 'asdfasfasfd tersf'\n"
" argument one { value = bar }\n"
" argument two { value=foo}\n";
cfg = cfg_init(opts, 0);
if (cfg_parse_buf(cfg, buf) != CFG_SUCCESS) {
fprintf(stderr, "Failed parsing configuration: %s\n", strerror(errno));
exit(1);
}
cfg_print(cfg, stdout);
return cfg_free(cfg);
}
| /* Very simple example for parse buf example */
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include "confuse.h"
int main(void)
{
cfg_t *cfg;
cfg_opt_t arg_opts[] = {
CFG_STR("value", "default", CFGF_NONE),
CFG_END()
};
cfg_opt_t opts[] = {
CFG_INT("delay", 3, CFGF_NONE),
CFG_STR("message", "This is a message", CFGF_NONE),
CFG_SEC("argument", arg_opts, CFGF_MULTI | CFGF_TITLE),
CFG_END()
};
char *buf =
" delay = 3\n"
"# message = 'asdfasfasfd tersf'\n"
" argument one { value = bar }\n"
" argument two { value=foo}\n";
cfg = cfg_init(opts, 0);
if (cfg_parse_buf(cfg, buf) != CFG_SUCCESS) {
fprintf(stderr, "Failed parsing configuration: %s\n", strerror(errno));
exit(1);
}
cfg_print(cfg, stdout);
return cfg_free(cfg);
}
|
Reduce implicit calls, add fix for large memory sections | /*
* kisskiss.h
*
* Tim "diff" Strazzere <strazz@gmail.com>
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/ptrace.h>
#include <dirent.h>
#include <fcntl.h> // open / O_RDONLY
static const char* odex_magic = "dey\n036";
static const char* static_safe_location = "/data/local/tmp/";
static const char* suffix = ".dumped_odex";
typedef struct {
uint32_t start;
uint32_t end;
} memory_region;
uint32_t get_clone_pid(uint32_t service_pid);
uint32_t get_process_pid(const char* target_package_name);
char *determine_filter(uint32_t clone_pid, int memory_fd);
int find_magic_memory(uint32_t clone_pid, int memory_fd, memory_region *memory, char* extra_filter);
int peek_memory(int memory_file, uint32_t address);
int dump_memory(int memory_fd, memory_region *memory, const char* file_name);
int attach_get_memory(uint32_t pid);
| /*
* kisskiss.h
*
* Tim "diff" Strazzere <strazz@gmail.com>
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/ptrace.h>
#include <dirent.h>
#include <fcntl.h> // open / O_RDONLY
#include <unistd.h> // close
#include <errno.h> // perror
#include <string.h> // strlen
static const char* odex_magic = "dey\n036";
static const char* static_safe_location = "/data/local/tmp/";
static const char* suffix = ".dumped_odex";
typedef struct {
uint64_t start;
uint64_t end;
} memory_region;
uint32_t get_clone_pid(uint32_t service_pid);
uint32_t get_process_pid(const char* target_package_name);
char *determine_filter(uint32_t clone_pid, int memory_fd);
int find_magic_memory(uint32_t clone_pid, int memory_fd, memory_region *memory, char* extra_filter);
int peek_memory(int memory_file, uint32_t address);
int dump_memory(int memory_fd, memory_region *memory, const char* file_name);
int attach_get_memory(uint32_t pid);
|
Change forward declaration of HttpRequestInfo from class to struct to fix build breakage. | // Copyright (c) 2010 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 NET_SPDY_SPDY_HTTP_UTILS_H_
#define NET_SPDY_SPDY_HTTP_UTILS_H_
#pragma once
#include "net/spdy/spdy_framer.h"
namespace net {
class HttpResponseInfo;
class HttpRequestInfo;
// Convert a SpdyHeaderBlock into an HttpResponseInfo.
// |headers| input parameter with the SpdyHeaderBlock.
// |info| output parameter for the HttpResponseInfo.
// Returns true if successfully converted. False if there was a failure
// or if the SpdyHeaderBlock was invalid.
bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers,
HttpResponseInfo* response);
// Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from
// a HttpRequestInfo block.
void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
spdy::SpdyHeaderBlock* headers,
bool direct);
} // namespace net
#endif // NET_SPDY_SPDY_HTTP_UTILS_H_
| // Copyright (c) 2010 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 NET_SPDY_SPDY_HTTP_UTILS_H_
#define NET_SPDY_SPDY_HTTP_UTILS_H_
#pragma once
#include "net/spdy/spdy_framer.h"
namespace net {
class HttpResponseInfo;
struct HttpRequestInfo;
// Convert a SpdyHeaderBlock into an HttpResponseInfo.
// |headers| input parameter with the SpdyHeaderBlock.
// |info| output parameter for the HttpResponseInfo.
// Returns true if successfully converted. False if there was a failure
// or if the SpdyHeaderBlock was invalid.
bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers,
HttpResponseInfo* response);
// Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from
// a HttpRequestInfo block.
void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
spdy::SpdyHeaderBlock* headers,
bool direct);
} // namespace net
#endif // NET_SPDY_SPDY_HTTP_UTILS_H_
|
Fix mp3 field size constants so that the ID3 information gets parsed correctly. |
#define MP3ID3_TITLELEN NAMELEN
#define MP3ID3_ARTISTLEN AUTHORLEN
#define MP3ID3_ALBUMLEN 30
#define MP3ID3_YEARLEN 4
#define MP3ID3_COMMENTLEN 30
typedef struct {
int present:1;
char title[MP3ID3_TITLELEN+1];
char artist[MP3ID3_ARTISTLEN+1];
char album[MP3ID3_ALBUMLEN+1];
char year[MP3ID3_YEARLEN+1];
char comment[MP3ID3_COMMENTLEN+1];
char genre[31];
} t_id3tag;
int mserv_mp3info_readlen(const char *fname, int *bitrate_ret,
t_id3tag *id3tag);
|
#define MP3ID3_TITLELEN 30
#define MP3ID3_ARTISTLEN 30
#define MP3ID3_ALBUMLEN 30
#define MP3ID3_YEARLEN 4
#define MP3ID3_COMMENTLEN 30
typedef struct {
int present:1;
char title[MP3ID3_TITLELEN+1];
char artist[MP3ID3_ARTISTLEN+1];
char album[MP3ID3_ALBUMLEN+1];
char year[MP3ID3_YEARLEN+1];
char comment[MP3ID3_COMMENTLEN+1];
char genre[31];
} t_id3tag;
int mserv_mp3info_readlen(const char *fname, int *bitrate_ret,
t_id3tag *id3tag);
|
Fix build with modern Panda headers | // Filename: config_lui.h
// Created by: tobspr (28Aug14)
//
#ifndef CONFIG_LUI_H
#define CONFIG_LUI_H
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include "dconfig.h"
#define EXPCL_LUI EXPORT_CLASS
#define EXPTP_LUI EXPORT_TEMPL
ConfigureDecl(config_lui, EXPCL_LUI, EXPTP_LUI);
NotifyCategoryDecl(lui, EXPCL_LUI, EXPTP_LUI);
extern EXPCL_LUI void init_lui();
#ifdef INTERROGATE
// Interrogate can't handle this
#define unordered_map pmap
#endif
#endif
| // Filename: config_lui.h
// Created by: tobspr (28Aug14)
//
#ifndef CONFIG_LUI_H
#define CONFIG_LUI_H
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include "dconfig.h"
#define EXPCL_LUI EXPORT_CLASS
#define EXPTP_LUI EXPORT_TEMPL
ConfigureDecl(config_lui, EXPCL_LUI, EXPTP_LUI);
NotifyCategoryDecl(lui, EXPCL_LUI, EXPTP_LUI);
extern EXPCL_LUI void init_lui();
using namespace std;
#endif
|
Add newline at end of file | /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/*
* Copyright (C) 2008 Collabora Ltd.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
*/
#ifndef __EMPATHY_TYPES_H__
#define __EMPATHY_TYPES_H__
typedef struct _EmpathyContactList EmpathyContactList;
typedef struct _EmpathyContactMonitor EmpathyContactMonitor;
#endif /* __EMPATHY_TYPES_H__ */ | /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/*
* Copyright (C) 2008 Collabora Ltd.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
*/
#ifndef __EMPATHY_TYPES_H__
#define __EMPATHY_TYPES_H__
typedef struct _EmpathyContactList EmpathyContactList;
typedef struct _EmpathyContactMonitor EmpathyContactMonitor;
#endif /* __EMPATHY_TYPES_H__ */
|
Delete todo comments and add assert to avoid null entry | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "phonebook_opt.h"
/* FILL YOUR OWN IMPLEMENTATION HERE! */
entry *findName(char lastname[], entry *pHead)
{
while (pHead != NULL) {
if (strcasecmp(lastname, pHead->lastName) == 0)
return pHead;
pHead = pHead->pNext;
}
return NULL;
}
entry *append(char lastName[], entry *e)
{
/* allocate memory for the new entry and put lastName */
e->pNext = (entry *) malloc(sizeof(entry));
e = e->pNext;
strcpy(e->lastName, lastName);
e->pNext = NULL;
return e;
}
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include "phonebook_opt.h"
entry *findName(char lastname[], entry *pHead)
{
while (pHead != NULL) {
if (strcasecmp(lastname, pHead->lastName) == 0)
return pHead;
pHead = pHead->pNext;
}
return NULL;
}
entry *append(char lastName[], entry *e)
{
/* check whther entry is null or not */
assert(e != NULL && "[error] entry is null");
/* allocate memory for the new entry and put lastName */
e->pNext = (entry *) malloc(sizeof(entry));
e = e->pNext;
strcpy(e->lastName, lastName);
e->pNext = NULL;
return e;
}
|
Fix typo in deprecation message | /*
* Copyright (C) Fondazione Istituto Italiano di Tecnologia
*
* Licensed under either the GNU Lesser General Public License v3.0 :
* https://www.gnu.org/licenses/lgpl-3.0.html
* or the GNU Lesser General Public License v2.1 :
* https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* at your option.
*/
#ifndef IDYNTREE_LINEAR_FORCE_VECTOR_3_H
#define IDYNTREE_LINEAR_FORCE_VECTOR_3_H
#warning <iDynTree/Core/LinearForceVector3.h> is deprecated. Please use GeomVector3 and <iDynTree/Model/GeomVector3.h>.
#include <iDynTree/Core/GeomVector3.h>
#endif /* IDYNTREE_LINEAR_FORCE_VECTOR_3_H */
| /*
* Copyright (C) Fondazione Istituto Italiano di Tecnologia
*
* Licensed under either the GNU Lesser General Public License v3.0 :
* https://www.gnu.org/licenses/lgpl-3.0.html
* or the GNU Lesser General Public License v2.1 :
* https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* at your option.
*/
#ifndef IDYNTREE_LINEAR_FORCE_VECTOR_3_H
#define IDYNTREE_LINEAR_FORCE_VECTOR_3_H
#warning <iDynTree/Core/LinearForceVector3.h> is deprecated. Please use GeomVector3 and <iDynTree/Core/GeomVector3.h>.
#include <iDynTree/Core/GeomVector3.h>
#endif /* IDYNTREE_LINEAR_FORCE_VECTOR_3_H */
|
Update pyramid of numbers in C language | /* Pyramid of numbers
Exercise #7 from my college
Make a program that's receive a number and print it like a pyramid in descending order.
Example with number 5 inputted. The output must be like that:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*/
#include <stdio.h>
int main() {
int number;
printf("Type a number: ");
scanf("%d", &number);
for (int i = 1; i <= number; i++) {
for (int j = 1; j <= i; j++) {
printf ("%d ", j);
}
printf ("\n");
}
return 0;
}
| /* Pyramid of numbers
Exercise #7 from my college
Make a program that's receive a number and print it like a pyramid in ascending order.
Example with number 5 inputted. The output must be like that:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*/
#include <stdio.h>
int main() {
int number;
printf("Type a number: ");
scanf("%d", &number);
for (int i = 1; i <= number; i++) {
for (int j = 1; j <= i; j++) {
printf ("%d ", j);
}
printf ("\n");
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.