Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Revert "[GeoCAD] Protect all of OpenCascade headers from declaring Printf." | // @(#)geom/geocad:$Id$
// Author: Cinzia Luzzi 5/5/2012
/*************************************************************************
* Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TOCCExports
#define ROOT_TOCCExports
// Combine all OCE headers used by geocad.
// After including them, #undef Handle.
#define Printf Printf_opencascade
#include <TDF_Label.hxx>
#include <TDocStd_Document.hxx>
#include <Standard_Version.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
#undef Printf
// ROOT-9837
#if defined(Handle) && !defined(R__Needs_Handle)
#undef Handle
#endif
#endif
| // @(#)geom/geocad:$Id$
// Author: Cinzia Luzzi 5/5/2012
/*************************************************************************
* Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TOCCExports
#define ROOT_TOCCExports
// Combine all OCE headers used by geocad.
// After including them, #undef Handle.
#include <TDF_Label.hxx>
#include <TDocStd_Document.hxx>
#include <Standard_Version.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#define Printf Printf_opencascade
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
#undef Printf
// ROOT-9837
#if defined(Handle) && !defined(R__Needs_Handle)
#undef Handle
#endif
#endif
|
Add methods for detecting different kinds of files by their magic number, getting the suffix for shared objects, and extracting the basename from a path. | //===- llvm/System/Process.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the llvm::sys::Process class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SYSTEM_PROCESS_H
#define LLVM_SYSTEM_PROCESS_H
namespace llvm {
namespace sys {
/// This class provides an abstraction for getting information about the
/// currently executing process.
/// @since 1.4
/// @brief An abstraction for operating system processes.
class Process {
/// @name Accessors
/// @{
public:
/// This static function will return the operating system's virtual memory
/// page size.
/// @returns The number of bytes in a virtual memory page.
/// @throws nothing
/// @brief Get the virtual memory page size
static unsigned GetPageSize();
/// @}
};
}
}
// vim: sw=2
#endif
| |
Add missing destructor bodies... oops | //===-- ModelSync.h - Wireless Syncing of GameModel ---------------- c++ --===//
//
// UWH Timer
//
// This file is distributed under the BSD 3-Clause License.
// See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MODELSYNC_H
#define MODELSYNC_H
#include "uwhd/model/GameModel.h"
#include <string>
#include <vector>
struct ModelSync {
virtual ~ModelSync() = 0;
virtual void Init() = 0;
virtual void setMgr(GameModelManager *M) = 0;
virtual GameModelManager &getMgr() = 0;
};
//struct ModelSyncPeer {
// virtual std::string name() const = 0;
// virtual std::string addr() const = 0;
//};
struct ModelSyncServer : public ModelSync {
virtual ~ModelSyncServer() = 0;
//virtual std::vector<ModelSyncPeer*> peers() = 0;
//virtual void claimPeer(const ModelSyncPeer *P) = 0;
//virtual void getPeerWallClock(const ModelSyncPeer *P) = 0;
//virtual void setPeerWallClock(const ModelSyncPeer *P) = 0;
//virtual void adjustPeerWallClock(const ModelSyncPeer *P, int Delta) = 0;
};
ModelSync *CreateSocketServer(const std::string &Port);
ModelSync *CreateSocketClient(const std::string &Host, const std::string &Port);
ModelSyncServer *CreateXBeeSyncServer();
ModelSync *CreateXBeeSyncClient();
#endif
| //===-- ModelSync.h - Wireless Syncing of GameModel ---------------- c++ --===//
//
// UWH Timer
//
// This file is distributed under the BSD 3-Clause License.
// See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MODELSYNC_H
#define MODELSYNC_H
#include "uwhd/model/GameModel.h"
#include <string>
#include <vector>
struct ModelSync {
virtual ~ModelSync() {};
virtual void Init() = 0;
virtual void setMgr(GameModelManager *M) = 0;
virtual GameModelManager &getMgr() = 0;
};
//struct ModelSyncPeer {
// virtual std::string name() const = 0;
// virtual std::string addr() const = 0;
//};
struct ModelSyncServer : public ModelSync {
virtual ~ModelSyncServer() {};
//virtual std::vector<ModelSyncPeer*> peers() = 0;
//virtual void claimPeer(const ModelSyncPeer *P) = 0;
//virtual void getPeerWallClock(const ModelSyncPeer *P) = 0;
//virtual void setPeerWallClock(const ModelSyncPeer *P) = 0;
//virtual void adjustPeerWallClock(const ModelSyncPeer *P, int Delta) = 0;
};
ModelSync *CreateSocketServer(const std::string &Port);
ModelSync *CreateSocketClient(const std::string &Host, const std::string &Port);
ModelSyncServer *CreateXBeeSyncServer();
ModelSync *CreateXBeeSyncClient();
#endif
|
Add comment for font list |
#ifndef _U8G2_FONTS_H
#define _U8G2_FONTS_H
#define U8G2_FONT_TABLE_ENTRY(font)
// ***************************************************************************
// Configure U8glib fonts
//
#ifndef U8G2_FONT_TABLE_EXTRA
//
// Add a U8G2_FONT_TABLE_ENTRY for each font you want to compile into the image
#define U8G2_FONT_TABLE \
U8G2_FONT_TABLE_ENTRY(font_6x10_tf) \
U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \
#else
//
// The font table can be defined in an external file.
#define U8G2_FONT_TABLE \
U8G2_FONT_TABLE_EXTRA
#endif
// ***************************************************************************
#endif /* _U8G2_FONTS_H */
|
#ifndef _U8G2_FONTS_H
#define _U8G2_FONTS_H
#define U8G2_FONT_TABLE_ENTRY(font)
// ***************************************************************************
// Configure U8glib fonts
//
#ifndef U8G2_FONT_TABLE_EXTRA
//
// Add a U8G2_FONT_TABLE_ENTRY for each font you want to compile into the image
// See https://github.com/olikraus/u8g2/wiki/fntlistall for a complete list of
// available fonts. Drop the 'u8g2_' prefix when you add them here.
#define U8G2_FONT_TABLE \
U8G2_FONT_TABLE_ENTRY(font_6x10_tf) \
U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \
#else
//
// The font table can be defined in an external file.
#define U8G2_FONT_TABLE \
U8G2_FONT_TABLE_EXTRA
#endif
// ***************************************************************************
#endif /* _U8G2_FONTS_H */
|
Fix typos in DEBUG_MSG and ERROR_MSG macros | #ifndef GVKILL_DEBUG_H
#define GVKILL_DEBUG_H
#include <cstdlib>
#include <iostream>
// FIXME: These need to be made Windows comptabile
#define DEBUG(X) if (getenv("GVKI_DEBUG") != NULL) X
#define DEBUG_MSG(X) DEBUG( std::cerr << "\033[32m***GVKILL:" << X << "***\033[0m" << std::endl)
// FIXME: This belongs in its own header file
#define ERROR_MSG(X) std::cerr << "\033[31m**GVKILL ERROR:" << X << "***\033\[0m" << std::endl
#endif
| #ifndef GVKILL_DEBUG_H
#define GVKILL_DEBUG_H
#include <cstdlib>
#include <iostream>
// FIXME: These need to be made Windows comptabile
#define DEBUG(X) if (getenv("GVKI_DEBUG") != NULL) X
#define DEBUG_MSG(X) DEBUG( std::cerr << "\033[32m***GVKI:" << X << "***\033[0m" << std::endl)
// FIXME: This belongs in its own header file
#define ERROR_MSG(X) std::cerr << "\033[31m**GVKI ERROR:" << X << "***\033\[0m" << std::endl
#endif
|
Implement a minimalistic version for x86. | /* libunwind - a platform-independent unwind library
Copyright (C) 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_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
{
struct cursor *c = (struct cursor *) cursor;
#if 0
int ret;
#endif
memset (pi, 0, sizeof (*pi));
pi->start_ip = c->eip;
pi->end_ip = c->eip + 1;
#if 0
if ((ret = ia64_make_proc_info (c)) < 0)
return ret;
#endif
return 0;
}
| |
Add a test rule to reset the FFF fakes | /* Copyright 2021 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "test_mocks.h"
DEFINE_FFF_GLOBALS;
/* Mocks for common/init_rom.c */
DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int);
DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int);
DEFINE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int);
| /* Copyright 2021 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <ztest.h>
#include "test_mocks.h"
DEFINE_FFF_GLOBALS;
/* Mocks for common/init_rom.c */
DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int);
DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int);
DEFINE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int);
/**
* @brief Reset all the fakes before each test.
*/
static void fff_reset_rule_before(const struct ztest_unit_test *test,
void *data)
{
ARG_UNUSED(test);
ARG_UNUSED(data);
RESET_FAKE(init_rom_map);
RESET_FAKE(init_rom_unmap);
RESET_FAKE(init_rom_copy);
}
ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL);
|
Fix the constructor typo. The new type should follow PI spec. | /** @file
Internal Header file for PEI Services Table Pointer Library.
Copyright (c) 2006, Intel Corporation<BR>
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,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _PEI_SERVICE_TABLE_POINTER_INTERNAL_H_
#define _PEI_SERVICE_TABLE_POINTER_INTERNAL_H_
/**
The constructor function caches the pointer to PEI services.
The constructor function caches the pointer to PEI services.
It will always return EFI_SUCCESS.
@param FfsHeader Pointer to FFS header the loaded driver.
@param PeiServices Pointer to the PEI services.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
PeiServicesTablePointerLibConstructor (
IN EFI_PEI_FILE_HANDLE *FfsHeader,
IN EFI_PEI_SERVICES **PeiServices
)
;
#endif
| /** @file
Internal Header file for PEI Services Table Pointer Library.
Copyright (c) 2006, Intel Corporation<BR>
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,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _PEI_SERVICE_TABLE_POINTER_INTERNAL_H_
#define _PEI_SERVICE_TABLE_POINTER_INTERNAL_H_
/**
The constructor function caches the pointer to PEI services.
The constructor function caches the pointer to PEI services.
It will always return EFI_SUCCESS.
@param FfsHeader Pointer to FFS header the loaded driver.
@param PeiServices Pointer to the PEI services.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
PeiServicesTablePointerLibConstructor (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN EFI_PEI_SERVICES **PeiServices
)
;
#endif
|
Add helper functions for state | //
// RTRNodeState.h
// Router
//
// Created by Nick Tymchenko on 14/09/15.
// Copyright (c) 2015 Pixty. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, RTRNodeState) {
RTRNodeStateNotInitialized = 0,
RTRNodeStateInactive = 1,
RTRNodeStateDeactivating = 2,
RTRNodeStateActivating = 3,
RTRNodeStateActive = 4
}; | //
// RTRNodeState.h
// Router
//
// Created by Nick Tymchenko on 14/09/15.
// Copyright (c) 2015 Pixty. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, RTRNodeState) {
RTRNodeStateNotInitialized = 0,
RTRNodeStateInactive = 1,
RTRNodeStateDeactivating = 2,
RTRNodeStateActivating = 3,
RTRNodeStateActive = 4
};
static inline BOOL RTRNodeStateIsInitialized(RTRNodeState state) {
return state != RTRNodeStateNotInitialized;
}
static inline BOOL RTRNodeStateIsTransitioning(RTRNodeState state) {
return state == RTRNodeStateDeactivating || state == RTRNodeStateActivating;
} |
Add support for NPB classes. |
enum npb_class { S, W, A, B, C, D };
static const int NKEY_LOG2[] = { 16, 20, 23, 25, 27, 29 };
static const int MAX_KEY_LOG2[] = { 11, 16, 19, 21, 23, 27 };
static const int NBUCKET_LOG2[] = { 10, 10, 10, 10, 10, 10 };
inline npb_class get_npb_class(char c) {
switch (c) {
case 'S': return S;
case 'W': return W;
case 'A': return A;
case 'B': return B;
case 'C': return C;
case 'D': return D;
}
}
| |
Add getters for branch and files. | #ifndef __PARSE_GIT_ST_H
#define __PARSE_GIT_ST_H
#include <vector>
#include <string>
const int PIPE_LINE_BUFFER_SIZE = 256;
class GitStatusParser {
std::vector<std::string*> pipe_buffer;
std::string* branch;
std::vector<std::string*> new_files;
std::vector<std::string*> modified_files;
std::vector<std::string*> untracked_files;
public:
GitStatusParser();
~GitStatusParser();
void parse();
private:
void load();
void parseBranch();
void parseNewFiles();
void parseModifiedFiles();
void parseUntrackedFiles();
};
#endif
| #ifndef __PARSE_GIT_ST_H
#define __PARSE_GIT_ST_H
#include <vector>
#include <string>
const int PIPE_LINE_BUFFER_SIZE = 256;
class GitStatusParser {
std::vector<std::string*> pipe_buffer;
std::string* branch;
std::vector<std::string*> new_files;
std::vector<std::string*> modified_files;
std::vector<std::string*> untracked_files;
public:
GitStatusParser();
~GitStatusParser();
void parse();
std::string* getBranch() { return branch; }
std::vector<std::string*> getNewFiles() { return new_files; }
std::vector<std::string*> getModifiedFiles() { return modified_files; }
std::vector<std::string*> getUntrackedFiles() { return untracked_files; }
private:
void load();
void parseBranch();
void parseNewFiles();
void parseModifiedFiles();
void parseUntrackedFiles();
};
#endif
|
Test application was jumping to a wrong address. | #include "config.h"
#include <util/delay.h>
#include "usart.h"
void send_block(unsigned bytes, char *buff)
{
for(int i = 0; i < bytes; ++i)
{
usart_transmit(buff[i]);
}
}
int main(int argc, char **argv)
{
usart_init();
char msg[] = "Loading bootloader in 3 seconds.";
send_block(sizeof(msg), msg);
_delay_ms(3000);
typedef void (* fn_ptr_t) (void);
fn_ptr_t my_ptr = (fn_ptr_t)0x1800;
my_ptr();
}
| #include "config.h"
#include <util/delay.h>
#include "usart.h"
void send_block(unsigned bytes, char *buff)
{
for(int i = 0; i < bytes; ++i)
{
usart_transmit(buff[i]);
}
}
int main(int argc, char **argv)
{
usart_init();
char msg[] = "Loading bootloader in 3 seconds.";
send_block(sizeof(msg), msg);
_delay_ms(3000);
typedef void (* fn_ptr_t) (void);
fn_ptr_t my_ptr = (fn_ptr_t)BOOTLOAD;
my_ptr();
}
|
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.cend(); }
template <typename T> auto crend(const T &c) { return c.crend(); }
}
| |
Fix a typo - this unbreaks llvm-gcc build on arm | //===-- llvm/Target/ARMTargetObjectFile.h - ARM Object Info -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TARGET_ARM_TARGETOBJECTFILE_H
#define LLVM_TARGET_ARM_TARGETOBJECTFILE_H
#include "llvm/Target/TargetLoweringObjectFile.h"
namespace llvm {
class ARMElfTargetObjectFile : public TargetLoweringObjectFileELF {
public:
ARMElfTargetObjectFile() : TargetLoweringObjectFileELF(true) {}
void Initialize(MCContext &Ctx, const TargetMachine &TM) {
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
// FIXME: Add new attribute/flag to MCSection for init_array/fini_array.
// That will allow not treating these as "directives".
if (TM.getSubtarget<ARMSubtarget>().isAAPCS_ABI()) {
StaticCtorSection =
getOrCreateSection("\t.section .init_array,\"aw\",%init_array", false,
SectionKind::getDataRel());
StaticDtorSection =
getOrCreateSection("\t.section .fini_array,\"aw\",%fini_array", false,
SectionKind::getDataRel());
}
}
};
} // end namespace llvm
#endif
| //===-- llvm/Target/ARMTargetObjectFile.h - ARM Object Info -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TARGET_ARM_TARGETOBJECTFILE_H
#define LLVM_TARGET_ARM_TARGETOBJECTFILE_H
#include "llvm/Target/TargetLoweringObjectFile.h"
namespace llvm {
class ARMElfTargetObjectFile : public TargetLoweringObjectFileELF {
public:
ARMElfTargetObjectFile() : TargetLoweringObjectFileELF(true) {}
void Initialize(MCContext &Ctx, const TargetMachine &TM) {
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
// FIXME: Add new attribute/flag to MCSection for init_array/fini_array.
// That will allow not treating these as "directives".
if (TM.getSubtarget<ARMSubtarget>().isAAPCS_ABI()) {
StaticCtorSection =
getOrCreateSection(".init_array,\"aw\",%init_array", false,
SectionKind::getDataRel());
StaticDtorSection =
getOrCreateSection(".fini_array,\"aw\",%fini_array", false,
SectionKind::getDataRel());
}
}
};
} // end namespace llvm
#endif
|
Add basic operation function declaration | #include <stdlib.h>
#ifndef __QUEUE_H__
#define __QUEUE_H__
struct Queue;
typedef struct Queue Queue;
#endif | #include <stdlib.h>
#ifndef __QUEUE_H__
#define __QUEUE_H__
struct Queue;
typedef struct Queue Queue;
Queue* Queue_Create(size_t n);
void Queue_Destroy(Queue* q);
void Queue_Enqueue(Queue* q, void* e);
void* Queue_Dequeue(Queue* q);
#endif |
Fix sparse warning about 1-bit signed bit-field | /*
* Driver for VIA PadLock
*
* Copyright (c) 2004 Michal Ludvig <michal@logix.cz>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/
#ifndef _CRYPTO_PADLOCK_H
#define _CRYPTO_PADLOCK_H
#define PADLOCK_ALIGNMENT 16
/* Control word. */
struct cword {
int __attribute__ ((__packed__))
rounds:4,
algo:3,
keygen:1,
interm:1,
encdec:1,
ksize:2;
} __attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
#define PFX "padlock: "
#ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES
int padlock_init_aes(void);
void padlock_fini_aes(void);
#endif
#endif /* _CRYPTO_PADLOCK_H */
| /*
* Driver for VIA PadLock
*
* Copyright (c) 2004 Michal Ludvig <michal@logix.cz>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/
#ifndef _CRYPTO_PADLOCK_H
#define _CRYPTO_PADLOCK_H
#define PADLOCK_ALIGNMENT 16
/* Control word. */
struct cword {
unsigned int __attribute__ ((__packed__))
rounds:4,
algo:3,
keygen:1,
interm:1,
encdec:1,
ksize:2;
} __attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
#define PFX "padlock: "
#ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES
int padlock_init_aes(void);
void padlock_fini_aes(void);
#endif
#endif /* _CRYPTO_PADLOCK_H */
|
DELETE USELESS CLASSES -ok that was fun | #ifndef GUI_COMPONENTS
#define GUI_COMPONENTS
void typewriterTextEffect() {
}
//reminder: use composition
//reminder: game will be played almost entirely through keyboard
class TextBox {
};
class ContextMenu {};
#endif
| #ifndef GUI_COMPONENTS
#define GUI_COMPONENTS
#endif
|
Update clock file from other repo | #include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <board_driver/uart.h>
#include <board_driver/rtc.h>
int main(void) {
uart_init();
printf("Starting\n\n");
printf("RTC status: %d\n", BSP_RTC_Init());
struct tm ti;
char month[3];
sscanf(__DATE__, "%s %d %d", month, &ti.tm_mday, &ti.tm_year);
ti.tm_year -= 1900;
if(!strcmp(month, "Jan"))
ti.tm_mon = 1;
else if(!strcmp(month, "Feb"))
ti.tm_mon = 2;
else if(!strcmp(month, "Mar"))
ti.tm_mon = 3;
else if(!strcmp(month, "Apr"))
ti.tm_mon = 4;
else if(!strcmp(month, "May"))
ti.tm_mon = 5;
else if(!strcmp(month, "Jun"))
ti.tm_mon = 6;
else if(!strcmp(month, "Jul"))
ti.tm_mon = 7;
else if(!strcmp(month, "Aug"))
ti.tm_mon = 8;
else if(!strcmp(month, "Sep"))
ti.tm_mon = 9;
else if(!strcmp(month, "Oct"))
ti.tm_mon = 10;
else if(!strcmp(month, "Nov"))
ti.tm_mon = 11;
else if(!strcmp(month, "Dec"))
ti.tm_mon = 12;
sscanf(__TIME__, "%d:%d:%d", &ti.tm_hour, &ti.tm_min, &ti.tm_sec);
uint32_t unixTime = mktime(&ti);
RTC_Update_Date_Time(unixTime);
while (1) {
Date_Time_t now;
RTC_Get_Date_Time(&now);
printf("time: %02d:%02d:%02d, %02d/%02d/%02d\n", now.hours, now.minutes, now.seconds, now.date, now.month, (now.year + 1900));
HAL_Delay(1000);
}
}
| |
Use reset() to make optional empty | #pragma once
#include <memory>
#include <nonstd/optional.hpp>
#include "xchainer/array.h"
namespace xchainer {
class OpNode;
class ArrayNode {
public:
ArrayNode() = default;
const std::shared_ptr<OpNode>& next_node() { return next_node_; }
std::shared_ptr<const OpNode> next_node() const { return next_node_; }
void set_next_node(std::shared_ptr<OpNode> next_node) { next_node_ = std::move(next_node); }
const nonstd::optional<Array>& grad() const { return grad_; }
void set_grad(Array grad) { grad_.emplace(std::move(grad)); };
void ClearGrad() { grad_ = nonstd::nullopt; }
private:
std::shared_ptr<OpNode> next_node_;
nonstd::optional<Array> grad_;
};
} // xchainer
| #pragma once
#include <memory>
#include <nonstd/optional.hpp>
#include "xchainer/array.h"
namespace xchainer {
class OpNode;
class ArrayNode {
public:
ArrayNode() = default;
const std::shared_ptr<OpNode>& next_node() { return next_node_; }
std::shared_ptr<const OpNode> next_node() const { return next_node_; }
void set_next_node(std::shared_ptr<OpNode> next_node) { next_node_ = std::move(next_node); }
const nonstd::optional<Array>& grad() const { return grad_; }
void set_grad(Array grad) { grad_.emplace(std::move(grad)); };
void ClearGrad() { grad_.reset(); }
private:
std::shared_ptr<OpNode> next_node_;
nonstd::optional<Array> grad_;
};
} // xchainer
|
Add user-defined constructor to the wfd::Driver class | /*
* This file is part of wysiwidi
*
* Copyright (C) 2014 Intel Corporation.
*
* 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
*/
#ifndef DRIVER_H_
#define DRIVER_H_
#include <string>
#include <memory>
#include "scanner.h"
#include "message.h"
#include "payload.h"
#include "parser.tab.hpp"
namespace wfd {
class Driver {
public:
~Driver();
void Parse(const std::string& input, Message*& message /*out*/);
private:
std::unique_ptr<Parser> parser_;
std::unique_ptr<Scanner> scanner_;
};
} // namespace wfd
#endif // DRIVER_H_
| /*
* This file is part of wysiwidi
*
* Copyright (C) 2014 Intel Corporation.
*
* 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
*/
#ifndef DRIVER_H_
#define DRIVER_H_
#include <string>
#include <memory>
#include "scanner.h"
#include "message.h"
#include "payload.h"
#include "parser.tab.hpp"
namespace wfd {
class Driver {
public:
Driver() = default;
~Driver();
void Parse(const std::string& input, Message*& message /*out*/);
private:
std::unique_ptr<Parser> parser_;
std::unique_ptr<Scanner> scanner_;
};
} // namespace wfd
#endif // DRIVER_H_
|
Synchronize the mailbox after expunging messages to actually get them expunged. | /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
| /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "commands.h"
#include "imap-expunge.h"
bool cmd_close(struct client_command_context *cmd)
{
struct client *client = cmd->client;
struct mailbox *mailbox = client->mailbox;
struct mail_storage *storage;
if (!client_verify_open_mailbox(cmd))
return TRUE;
storage = mailbox_get_storage(mailbox);
client->mailbox = NULL;
if (!imap_expunge(mailbox, NULL))
client_send_untagged_storage_error(client, storage);
else if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
client_send_untagged_storage_error(client, storage);
if (mailbox_close(&mailbox) < 0)
client_send_untagged_storage_error(client, storage);
client_update_mailbox_flags(client, NULL);
client_send_tagline(cmd, "OK Close completed.");
return TRUE;
}
|
Include stdio.h in case bzlib.h needs it. | /* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-internal.h"
#include "istream-zlib.h"
#ifdef HAVE_BZLIB
#include <bzlib.h>
#define BZLIB_INCLUDE
#define gzFile BZFILE
#define gzdopen BZ2_bzdopen
#define gzclose BZ2_bzclose
#define gzread BZ2_bzread
#define gzseek BZ2_bzseek
#define i_stream_create_zlib i_stream_create_bzlib
#include "istream-zlib.c"
#endif
| /* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-internal.h"
#include "istream-zlib.h"
#ifdef HAVE_BZLIB
#include <stdio.h>
#include <bzlib.h>
#define BZLIB_INCLUDE
#define gzFile BZFILE
#define gzdopen BZ2_bzdopen
#define gzclose BZ2_bzclose
#define gzread BZ2_bzread
#define gzseek BZ2_bzseek
#define i_stream_create_zlib i_stream_create_bzlib
#include "istream-zlib.c"
#endif
|
Update files, Alura, Introdução a C, Aula 2.9 | #include <stdio.h>
#define NUMERO_DE_TENTATIVAS 5
int main() {
// imprime o cabecalho do nosso jogo
printf("******************************************\n");
printf("* Bem vindo ao nosso jogo de adivinhação *\n");
printf("******************************************\n");
int numerosecreto = 42;
int chute;
for(int i = 1; i <= NUMERO_DE_TENTATIVAS; i++) {
printf("Tentativa %d de %d\n", i, NUMERO_DE_TENTATIVAS);
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
int acertou = chute == numerosecreto;
int maior = chute > numerosecreto;
int menor = chute < numerosecreto;
if(acertou) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
break;
}
else if(maior) {
printf("Seu chute foi maior que o número secreto\n");
}
else {
printf("Seu chute foi menor que o número secreto\n");
}
}
printf("Fim de jogo!\n");
}
| #include <stdio.h>
#define NUMERO_DE_TENTATIVAS 5
int main() {
// imprime o cabecalho do nosso jogo
printf("******************************************\n");
printf("* Bem vindo ao nosso jogo de adivinhação *\n");
printf("******************************************\n");
int numerosecreto = 42;
int chute;
for(int i = 1; i <= NUMERO_DE_TENTATIVAS; i++) {
printf("Tentativa %d de %d\n", i, NUMERO_DE_TENTATIVAS);
printf("Qual é o seu chute? ");
scanf("%d", &chute);
printf("Seu chute foi %d\n", chute);
if(chute < 0) {
printf("Você não pode chutar números negativos!\n");
i--;
continue;
}
int acertou = chute == numerosecreto;
int maior = chute > numerosecreto;
int menor = chute < numerosecreto;
if(acertou) {
printf("Parabéns! Você acertou!\n");
printf("Jogue de novo, você é um bom jogador!\n");
break;
}
else if(maior) {
printf("Seu chute foi maior que o número secreto\n");
}
else {
printf("Seu chute foi menor que o número secreto\n");
}
}
printf("Fim de jogo!\n");
}
|
Add nullable annotations to header | //
// JMAttributedFormat.h
// JMAttributedFormat
//
// Created by Jonathon Mah on 2015-04-11.
// This file is licensed under the MIT License. See LICENSE.txt for full details.
//
#import <Foundation/Foundation.h>
@interface NSObject (JMAttributedFormat_Optional)
- (NSAttributedString *)attributedDescription;
@end
@interface NSAttributedString (JMAttributedFormat)
+ (instancetype)attributedStringWithFormat:(NSString *)formatString, ... NS_FORMAT_FUNCTION(1,2);
+ (instancetype)attributedStringWithBaseAttributes:(NSDictionary *)baseAttributes format:(NSString *)formatString, ... NS_FORMAT_FUNCTION(2,3);
- (instancetype)initWithBaseAttributes:(NSDictionary *)baseAttributes format:(NSString *)formatString, ... NS_FORMAT_FUNCTION(2,3);
- (instancetype)initWithBaseAttributes:(NSDictionary *)baseAttributes format:(NSString *)formatString arguments:(va_list)argList NS_FORMAT_FUNCTION(2,0);
@end
| //
// JMAttributedFormat.h
// JMAttributedFormat
//
// Created by Jonathon Mah on 2015-04-11.
// This file is licensed under the MIT License. See LICENSE.txt for full details.
//
#import <Foundation/Foundation.h>
@interface NSObject (JMAttributedFormat_Optional)
- (nullable NSAttributedString *)attributedDescription;
@end
@interface NSAttributedString (JMAttributedFormat)
+ (nullable instancetype)attributedStringWithFormat:(nonnull NSString *)formatString, ... NS_FORMAT_FUNCTION(1,2);
+ (nullable instancetype)attributedStringWithBaseAttributes:(nullable NSDictionary *)baseAttributes format:(nonnull NSString *)formatString, ... NS_FORMAT_FUNCTION(2,3);
- (nullable instancetype)initWithBaseAttributes:(nullable NSDictionary *)baseAttributes format:(nonnull NSString *)formatString, ... NS_FORMAT_FUNCTION(2,3);
- (nullable instancetype)initWithBaseAttributes:(nullable NSDictionary *)baseAttributes format:(nonnull NSString *)formatString arguments:(va_list)argList NS_FORMAT_FUNCTION(2,0);
@end
|
Remove map not used anymore. | /*
* hooks.h
* StatusSpec project
*
* Copyright (c) 2014 thesupremecommander
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#pragma once
#include "stdafx.h"
#include <map>
#define CLIENT_DLL
#define GLOWS_ENABLE
#include "cdll_int.h"
#include "KeyValues.h"
#include "igameresources.h"
#include "vgui/vgui.h"
#include "vgui/IPanel.h"
#include "cbase.h"
#include "c_basecombatcharacter.h"
#include "glow_outline_effect.h"
#include <sourcehook/sourcehook_impl.h>
#include <sourcehook/sourcehook.h>
using namespace vgui;
class C_TFPlayer;
#if defined _WIN32
#define OFFSET_GETGLOWEFFECTCOLOR 223
#define OFFSET_UPDATEGLOWEFFECT 224
#define OFFSET_DESTROYGLOWEFFECT 225
#endif
static std::map<EHANDLE, int> onDataChangedHooks;
extern SourceHook::ISourceHook *g_SHPtr;
extern int g_PLID; | /*
* hooks.h
* StatusSpec project
*
* Copyright (c) 2014 thesupremecommander
* BSD 2-Clause License
* http://opensource.org/licenses/BSD-2-Clause
*
*/
#pragma once
#include "stdafx.h"
#include <map>
#define CLIENT_DLL
#define GLOWS_ENABLE
#include "cdll_int.h"
#include "KeyValues.h"
#include "igameresources.h"
#include "vgui/vgui.h"
#include "vgui/IPanel.h"
#include "cbase.h"
#include "c_basecombatcharacter.h"
#include "glow_outline_effect.h"
#include <sourcehook/sourcehook_impl.h>
#include <sourcehook/sourcehook.h>
using namespace vgui;
class C_TFPlayer;
#if defined _WIN32
#define OFFSET_GETGLOWEFFECTCOLOR 223
#define OFFSET_UPDATEGLOWEFFECT 224
#define OFFSET_DESTROYGLOWEFFECT 225
#endif
extern SourceHook::ISourceHook *g_SHPtr;
extern int g_PLID; |
Correct compillation for GCC apparently... | //PLEASE INCLUDE THIS FILE ON ANY ANNWVYN HEADER
/*This file conrain macro and symbols definition that have to be
* parsed by precompiler on each file.
* They handle diferencies between compilers
*/
//-------------------------DLL EXPORT -------------------------------//
//DLL management for visual studio compiller.
#undef DLL
#ifdef DLLDIR_EX //Defined in Annwvyn MSVC project file
//To contruct a DLL, The macro __declspec(dllexport) have to be called in front of the exported symbol
#define DLL __declspec(dllexport) // export DLL information
#else
//To reference symbols from a DLL the macro __declspec(dllimport) have to be called the same way
#define DLL __declspec(dllimport) // import DLL information
#endif
//Bypass on GNU/Linux :
#ifdef __gnu_linux__ //All that stuff is handeled by the makefile and the way g++ is called. DLL have to be empty but declared.
#undef DLL
#define DLL
#endif
//--------------------------------------------------------------------//
//--------------------Application Entrypoint definition--------------//
//Main definition :
#undef AnnMain()
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
//On windows :
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#define AnnMain() INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
#else
//On others :
#define AnnMain() int main(int argc, char** argv)
#endif
//---------------------------------------------------------------------//
| //PLEASE INCLUDE THIS FILE ON ANY ANNWVYN HEADER
/*This file conrain macro and symbols definition that have to be
* parsed by precompiler on each file.
* They handle diferencies between compilers
*/
//-------------------------DLL EXPORT -------------------------------//
//DLL management for visual studio compiller.
#undef DLL
#ifdef DLLDIR_EX //Defined in Annwvyn MSVC project file
//To contruct a DLL, The macro __declspec(dllexport) have to be called in front of the exported symbol
#define DLL __declspec(dllexport) // export DLL information
#else
//To reference symbols from a DLL the macro __declspec(dllimport) have to be called the same way
#define DLL __declspec(dllimport) // import DLL information
#endif
//Bypass on GNU/Linux :
#ifdef __gnu_linux__ //All that stuff is handeled by the makefile and the way g++ is called. DLL have to be empty but declared.
#undef DLL
#define DLL
#endif
//--------------------------------------------------------------------//
//--------------------Application Entrypoint definition--------------//
//Main definition :
#undef AnnMain
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#define AnnMain() INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
#else
//On others :
#define AnnMain() int main(int argc, char** argv)
#endif
//---------------------------------------------------------------------//
|
Initialize all the global vars in the hope it will stop MacOS from complaining | #include <sys/types.h>
#include <stdint.h>
typedef int8_t s8;
typedef uint8_t u8;
typedef int16_t s16;
typedef uint16_t u16;
typedef int32_t s32;
typedef uint32_t u32;
typedef int64_t s64;
typedef uint64_t u64;
typedef signed long sL;
typedef unsigned long uL;
typedef float f32;
typedef double f64;
typedef unsigned long ulong;
typedef void* pointer;
#define GVAR(T) \
T gvar_##T; \
T gvar_##T##_get() { return gvar_##T; }; \
void gvar_##T##_set(T v) { gvar_##T = v; }
GVAR(s8);
GVAR(u8);
GVAR(s16);
GVAR(u16);
GVAR(s32);
GVAR(u32);
GVAR(s64);
GVAR(u64);
GVAR(long);
GVAR(ulong);
GVAR(pointer);
| #include <sys/types.h>
#include <stdint.h>
typedef int8_t s8;
typedef uint8_t u8;
typedef int16_t s16;
typedef uint16_t u16;
typedef int32_t s32;
typedef uint32_t u32;
typedef int64_t s64;
typedef uint64_t u64;
typedef signed long sL;
typedef unsigned long uL;
typedef float f32;
typedef double f64;
typedef unsigned long ulong;
typedef void* pointer;
#define GVAR(T) \
extern T gvar_##T; \
T gvar_##T = (T) -1; \
T gvar_##T##_get() { return gvar_##T; }; \
void gvar_##T##_set(T v) { gvar_##T = v; }
GVAR(s8);
GVAR(u8);
GVAR(s16);
GVAR(u16);
GVAR(s32);
GVAR(u32);
GVAR(s64);
GVAR(u64);
GVAR(long);
GVAR(ulong);
GVAR(pointer);
|
Document 2 FIXME's for an app-embedded LG library | /* There is no include guard here - by purpose. This file can be included
* after system includes that redefine the assert() macro.
* The actual problem for which this file got separated from utilities.h
* happens in the sat-solver code, when local include files include
* Solver.h which in turn includes the system's assert.h. */
#include "error.h" /* for prt_error() */
#ifndef STRINGIFY
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#endif /* STRINGIFY */
#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)
#ifdef _WIN32
#define DEBUG_TRAP (*((volatile int*) 0x0) = 42)
#else
#define DEBUG_TRAP __builtin_trap()
#endif
#define assert(ex, ...) { \
if (!(ex)) { \
fprintf(stderr, "Fatal error: \nAssertion (" #ex ") failed at " FILELINE ": " __VA_ARGS__); \
fprintf(stderr, "\n"); \
DEBUG_TRAP; /* leave stack trace in debugger */ \
} \
}
| /* There is no include guard here - by purpose. This file can be included
* after system includes that redefine the assert() macro.
* The actual problem for which this file got separated from utilities.h
* happens in the sat-solver code, when local include files include
* Solver.h which in turn includes the system's assert.h. */
#include "error.h" /* for prt_error() */
#ifndef STRINGIFY
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#endif /* STRINGIFY */
#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)
#ifdef _WIN32
#define DEBUG_TRAP (*((volatile int*) 0x0) = 42)
#else
#define DEBUG_TRAP __builtin_trap()
#endif
/* FIXME:
* 1. If the error_handler is not NULL, use prt_error() too (after calling
* fprintf()), in order to allow an error_handler to log, produce trace, or
* show the assert() message in a (possibly pop-up) window.
* 2. Don't use DEBUG_TRAP (or exit) directly, but instead call a function
* pointer like lg_exit(code) to allow the LG library to be embedded in an
* application like an editor. If not set, the default will still be
* DEBUG_TRAP. */
#define assert(ex, ...) { \
if (!(ex)) { \
fprintf(stderr, "Fatal error: \nAssertion (" #ex ") failed at " FILELINE ": " __VA_ARGS__); \
fprintf(stderr, "\n"); \
DEBUG_TRAP; /* leave stack trace in debugger */ \
} \
}
|
Update the zebra launcher to use chpl_launch_using_exec() as implemented in r18010. | #include <stdio.h>
#include <string.h>
#include "chpllaunch.h"
#include "chpl_mem.h"
#include "error.h"
static char* chpl_launch_create_command(int argc, char* argv[],
int32_t numLocales) {
int i;
int size;
char baseCommand[256];
char* command;
chpl_compute_real_binary_name(argv[0]);
sprintf(baseCommand, "zebra -fast -r %s", chpl_get_real_binary_name());
size = strlen(baseCommand) + 1;
for (i=1; i<argc; i++) {
size += strlen(argv[i]) + 3;
}
command = chpl_malloc(size, sizeof(char), CHPL_RT_MD_COMMAND_BUFFER, -1, "");
sprintf(command, "%s", baseCommand);
for (i=1; i<argc; i++) {
strcat(command, " '");
strcat(command, argv[i]);
strcat(command, "'");
}
if (strlen(command)+1 > size) {
chpl_internal_error("buffer overflow");
}
return command;
}
int chpl_launch(int argc, char* argv[], int32_t numLocales) {
return chpl_launch_using_system(chpl_launch_create_command(argc, argv, numLocales),
argv[0]);
}
int chpl_launch_handle_arg(int argc, char* argv[], int argNum,
int32_t lineno, chpl_string filename) {
return 0;
}
void chpl_launch_print_help(void) {
}
| #include <stdio.h>
#include <string.h>
#include "chpllaunch.h"
#include "chpl_mem.h"
#include "error.h"
static char** chpl_launch_create_argv(int argc, char* argv[]) {
const int largc = 3;
char *largv[largc];
largv[0] = (char *) "zebra";
largv[1] = (char *) "-fast";
largv[2] = (char *) "-r";
return chpl_bundle_exec_args(argc, argv, largc, largv);
}
int chpl_launch(int argc, char* argv[], int32_t numLocales) {
if (numLocales != 1) {
// This error should be taken care of before we get to this point
chpl_internal_error("The XMT launcher only supports numLocales==1");
}
return chpl_launch_using_exec("zebra",
chpl_launch_create_argv(argc, argv),
argv[0]);
}
int chpl_launch_handle_arg(int argc, char* argv[], int argNum,
int32_t lineno, chpl_string filename) {
return 0;
}
void chpl_launch_print_help(void) {
}
|
Update to catch up with renames of internal structures. | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 __SYS_CONFIG_FCB_H_
#define __SYS_CONFIG_FCB_H_
#ifdef FCB_PRESENT
#include <fcb/fcb.h>
#include "config/config.h"
struct conf_file {
struct cf_storage cf_itf;
struct fcb cf_fcb;
};
int conf_fcb_src(struct conf_fcb *fcb);
int conf_fcb_dst(struct conf_fcb *fcb);
#endif
#endif /* __SYS_CONFIG_FCB_H_ */
| /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 __SYS_CONFIG_FCB_H_
#define __SYS_CONFIG_FCB_H_
#ifdef FCB_PRESENT
#include <fcb/fcb.h>
#include "config/config.h"
struct conf_fcb {
struct conf_store cf_store;
struct fcb cf_fcb;
};
int conf_fcb_src(struct conf_fcb *fcb);
int conf_fcb_dst(struct conf_fcb *fcb);
#endif
#endif /* __SYS_CONFIG_FCB_H_ */
|
Make some sample blocks for merging | #include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "base.h"
int main( int argc, char** argv ) {
srand( 23898645 );
uint16 blocks = 4;
uint64 elements = 128;
if( argc == 3 ) {
blocks = (uint16) atoi( argv[1] );
elements = (uint64) atoi( argv[2] );
}
print("Making %hu blocks of %lu elements", blocks, elements );
uint64 block[elements];
for( uint16 i = 0; i<blocks; i++ ) {
char filename[255];
sprintf( filename, "sample_%06hu.block", i);
print("Generating file: %s", filename);
uint64 step = rand() % 100; // ensure some collisions between multiple sample files
block[0] = rand() % 100; // ensure some overlap
FILE* fp = fopen( filename, "w" );
if( !fp ) {
perror("File opening failed");
exit( EXIT_FAILURE );
}
for( uint64 j = 1; j < elements; j++ ) {
block[j] = block[ j-1 ] + step;
}
fwrite( block, sizeof(uint64), elements, fp );
fclose(fp);
}
exit( EXIT_SUCCESS );
}
| |
Add Drawing Kit header in general header | //
// iOSKit.h
// iOSKit
//
// Created by Yarik Smirnov on 1/23/12.
// Copyright (c) 2012 e-Legion ltd. All rights reserved.
//
#ifndef Elegion_iOSKit_h
#define Elegion_iOSKit_h
#import "ELIconView.h"
#import "ELInfoView.h"
#import "ELPickerView.h"
#import "ELSwipeController.h"
#endif
| //
// iOSKit.h
// iOSKit
//
// Created by Yarik Smirnov on 1/23/12.
// Copyright (c) 2012 e-Legion ltd. All rights reserved.
//
#ifndef Elegion_iOSKit_h
#define Elegion_iOSKit_h
#import "ELIconView.h"
#import "ELInfoView.h"
#import "ELPickerView.h"
#import "ELSwipeController.h"
#endif
|
Fix DEBUG_HIGHMEM build break from d4515646699 | #ifndef _ASM_POWERPC_KMAP_TYPES_H
#define _ASM_POWERPC_KMAP_TYPES_H
#ifdef __KERNEL__
/*
* 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.
*/
enum km_type {
KM_BOUNCE_READ,
KM_SKB_SUNRPC_DATA,
KM_SKB_DATA_SOFTIRQ,
KM_USER0,
KM_USER1,
KM_BIO_SRC_IRQ,
KM_BIO_DST_IRQ,
KM_PTE0,
KM_PTE1,
KM_IRQ0,
KM_IRQ1,
KM_SOFTIRQ0,
KM_SOFTIRQ1,
KM_PPC_SYNC_PAGE,
KM_PPC_SYNC_ICACHE,
KM_TYPE_NR
};
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_KMAP_TYPES_H */
| #ifndef _ASM_POWERPC_KMAP_TYPES_H
#define _ASM_POWERPC_KMAP_TYPES_H
#ifdef __KERNEL__
/*
* 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.
*/
enum km_type {
KM_BOUNCE_READ,
KM_SKB_SUNRPC_DATA,
KM_SKB_DATA_SOFTIRQ,
KM_USER0,
KM_USER1,
KM_BIO_SRC_IRQ,
KM_BIO_DST_IRQ,
KM_PTE0,
KM_PTE1,
KM_IRQ0,
KM_IRQ1,
KM_SOFTIRQ0,
KM_SOFTIRQ1,
KM_PPC_SYNC_PAGE,
KM_PPC_SYNC_ICACHE,
KM_TYPE_NR
};
/*
* This is a temporary build fix that (so they say on lkml....) should no longer
* be required after 2.6.33, because of changes planned to the kmap code.
* Let's try to remove this cruft then.
*/
#ifdef CONFIG_DEBUG_HIGHMEM
#define KM_NMI (-1)
#define KM_NMI_PTE (-1)
#define KM_IRQ_PTE (-1)
#endif
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_KMAP_TYPES_H */
|
Move system header files to top in order to get rid of redefine warnings for Visual C++. | /* $Id$
Everything needed by the C demo programs.
Created to avoid junking up plplot.h with this stuff.
*/
#ifndef __PLCDEMOS_H__
#define __PLCDEMOS_H__
#include "plConfig.h"
#include "plplot.h"
#include <math.h>
#include <string.h>
#include <ctype.h>
/* define PI if not defined by math.h */
/* Actually M_PI seems to be more widely used so we deprecate PI. */
#ifndef PI
#define PI 3.1415926535897932384
#endif
#ifndef M_PI
#define M_PI 3.1415926535897932384
#endif
/* various utility macros */
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef ROUND
#define ROUND(a) (PLINT)((a)<0. ? ((a)-.5) : ((a)+.5))
#endif
#endif /* __PLCDEMOS_H__ */
| /* $Id$
Everything needed by the C demo programs.
Created to avoid junking up plplot.h with this stuff.
*/
#ifndef __PLCDEMOS_H__
#define __PLCDEMOS_H__
#include <math.h>
#include <string.h>
#include <ctype.h>
#include "plConfig.h"
#include "plplot.h"
/* define PI if not defined by math.h */
/* Actually M_PI seems to be more widely used so we deprecate PI. */
#ifndef PI
#define PI 3.1415926535897932384
#endif
#ifndef M_PI
#define M_PI 3.1415926535897932384
#endif
/* various utility macros */
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef ROUND
#define ROUND(a) (PLINT)((a)<0. ? ((a)-.5) : ((a)+.5))
#endif
#endif /* __PLCDEMOS_H__ */
|
Add typedefs for Point3f and Point3d | /******************************************************************************
**
** Copyright (C) 2009-2011 Kyle Lutz <kyle.r.lutz@gmail.com>
**
** This file is part of chemkit. For more information see
** <http://www.chemkit.org>.
**
** chemkit is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** chemkit 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 chemkit. If not, see <http://www.gnu.org/licenses/>.
**
******************************************************************************/
#ifndef CHEMKIT_POINT3_H
#define CHEMKIT_POINT3_H
#include "chemkit.h"
#include "genericpoint.h"
namespace chemkit {
/// A three-dimensional point.
typedef GenericPoint<Float> Point3;
} // end chemkit namespace
#endif // CHEMKIT_POINT3_H
| /******************************************************************************
**
** Copyright (C) 2009-2011 Kyle Lutz <kyle.r.lutz@gmail.com>
**
** This file is part of chemkit. For more information see
** <http://www.chemkit.org>.
**
** chemkit is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** chemkit 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 chemkit. If not, see <http://www.gnu.org/licenses/>.
**
******************************************************************************/
#ifndef CHEMKIT_POINT3_H
#define CHEMKIT_POINT3_H
#include "chemkit.h"
#include "genericpoint.h"
namespace chemkit {
/// A three-dimensional point.
typedef GenericPoint<Float> Point3;
typedef GenericPoint<float> Point3f;
typedef GenericPoint<double> Point3d;
} // end chemkit namespace
#endif // CHEMKIT_POINT3_H
|
Update a test to FileCheck. | // RUN: clang-cc -triple i386-unknown-unknown --emit-llvm-bc -o - %s | opt --std-compile-opts | llvm-dis > %t
// RUN: grep "ret i32" %t | count 1
// RUN: grep "ret i32 1" %t | count 1
// PR2001
/* Test that the result of the assignment properly uses the value *in
the bitfield* as opposed to the RHS. */
static int foo(int i) {
struct {
int f0 : 2;
} x;
return (x.f0 = i);
}
int bar() {
return foo(-5) == -1;
}
| // RUN: clang-cc -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | FileCheck %s
// PR2001
/* Test that the result of the assignment properly uses the value *in
the bitfield* as opposed to the RHS. */
static int foo(int i) {
struct {
int f0 : 2;
} x;
return (x.f0 = i);
}
int bar() {
// CHECK: ret i32 1
return foo(-5) == -1;
}
|
Check cplusplus in header files. | /*
* Open Chinese Convert
*
* Copyright 2010 BYVoid <byvoid1@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OPENCC_CONVERT_H_
#define __OPENCC_CONVERT_H_
#include "opencc_utils.h"
#define SEGMENT_BUFF_SIZE 1048576
wchar_t * words_segmention(wchar_t * dest, const wchar_t * text);
wchar_t * simp_to_trad(wchar_t * dest, const wchar_t * text);
#endif /* __OPENCC_CONVERT_H_ */
| /*
* Open Chinese Convert
*
* Copyright 2010 BYVoid <byvoid1@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OPENCC_CONVERT_H_
#define __OPENCC_CONVERT_H_
#include "opencc_utils.h"
#define SEGMENT_BUFF_SIZE 1048576
#ifdef __cplusplus
extern "C" {
#endif
wchar_t * words_segmention(wchar_t * dest, const wchar_t * text);
wchar_t * simp_to_trad(wchar_t * dest, const wchar_t * text);
#ifdef __cplusplus
};
#endif
#endif /* __OPENCC_CONVERT_H_ */
|
Check that we don't warn on this testcase. This is basically a test that Decl::isUsed checks the attribute. If the function had a body just the check is DeclMustBeEmitted would be sufficient. | // RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
extern int l0 __attribute__((used)); // expected-warning {{used attribute ignored}}
__private_extern__ int l1 __attribute__((used)); // expected-warning {{used attribute ignored}}
struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variables and functions}}
int x;
};
int a __attribute__((used));
static void __attribute__((used)) f0(void) {
}
void f1() {
static int a __attribute__((used));
int b __attribute__((used)); // expected-warning {{used attribute ignored}}
}
| // RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
extern int l0 __attribute__((used)); // expected-warning {{used attribute ignored}}
__private_extern__ int l1 __attribute__((used)); // expected-warning {{used attribute ignored}}
struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variables and functions}}
int x;
};
int a __attribute__((used));
static void __attribute__((used)) f0(void) {
}
void f1() {
static int a __attribute__((used));
int b __attribute__((used)); // expected-warning {{used attribute ignored}}
}
static void __attribute__((used)) f0(void);
|
Fix strerror_r on some esoteric platforms | #ifndef __HIREDIS_FMACRO_H
#define __HIREDIS_FMACRO_H
#if defined(__linux__)
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#endif
#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
#elif defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define _XOPEN_SOURCE 600
#else
#define _XOPEN_SOURCE
#endif
#if __APPLE__ && __MACH__
#define _OSX
#endif
#endif
| #ifndef __HIREDIS_FMACRO_H
#define __HIREDIS_FMACRO_H
#if defined(__linux__)
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#endif
#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
#else
#define _XOPEN_SOURCE 600
#endif
#if __APPLE__ && __MACH__
#define _OSX
#endif
#endif
|
Fix "assignment operator could not be generated" warning | #ifndef UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H
#define UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H
#include "HelperMacros.h"
#include "ThrowingTestReporter.h"
namespace UnitTest {
class TestResults;
// This RAII class decorates the current TestReporter with
// a version that throws after reporting a failure.
class UNITTEST_LINKAGE RequiredCheckTestReporter
{
public:
explicit RequiredCheckTestReporter(TestResults& results);
~RequiredCheckTestReporter();
bool Next();
private:
TestResults& m_results;
TestReporter* m_originalTestReporter;
ThrowingTestReporter m_throwingReporter;
int m_continue;
};
}
#endif
| #ifndef UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H
#define UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H
#include "HelperMacros.h"
#include "ThrowingTestReporter.h"
namespace UnitTest {
class TestResults;
// This RAII class decorates the current TestReporter with
// a version that throws after reporting a failure.
class UNITTEST_LINKAGE RequiredCheckTestReporter
{
public:
explicit RequiredCheckTestReporter(TestResults& results);
~RequiredCheckTestReporter();
bool Next();
private:
RequiredCheckTestReporter(RequiredCheckTestReporter const&);
RequiredCheckTestReporter& operator =(RequiredCheckTestReporter const&);
TestResults& m_results;
TestReporter* m_originalTestReporter;
ThrowingTestReporter m_throwingReporter;
int m_continue;
};
}
#endif
|
Add heap sort in C | #include<stdio.h>
void create(int []);
void down_adjust(int [],int);
void main()
{
int heap[30],n,i,last,temp;
printf("Enter no. of elements:");
scanf("%d",&n);
printf("\nEnter elements:");
for(i=1;i<=n;i++)
scanf("%d",&heap[i]);
//create a heap
heap[0]=n;
create(heap);
//sorting
while(heap[0] > 1)
{
//swap heap[1] and heap[last]
last=heap[0];
temp=heap[1];
heap[1]=heap[last];
heap[last]=temp;
heap[0]--;
down_adjust(heap,1);
}
//print sorted data
printf("\nArray after sorting:\n");
for(i=1;i<=n;i++)
printf("%d ",heap[i]);
}
void create(int heap[])
{
int i,n;
n=heap[0]; //no. of elements
for(i=n/2;i>=1;i--)
down_adjust(heap,i);
}
void down_adjust(int heap[],int i)
{
int j,temp,n,flag=1;
n=heap[0];
while(2*i<=n && flag==1)
{
j=2*i; //j points to left child
if(j+1<=n && heap[j+1] > heap[j])
j=j+1;
if(heap[i] > heap[j])
flag=0;
else
{
temp=heap[i];
heap[i]=heap[j];
heap[j]=temp;
i=j;
}
}
} | |
Rewrite recursion test to calculate Fibonacci | /**
* @file
* @brief tests proper stack usage (particularly, right handling
* of window overflow/underflow on SPARC).
*
* @date 14.08.09
* @author Eldar Abusalimov
*/
#include <embox/test.h>
#include <test/misc.h>
#define RECURSION_DEPTH 32
EMBOX_TEST(run);
static int run(void) {
return test_misc_recursion(RECURSION_DEPTH);
}
| /**
* @file
* @brief Tests proper stack usage.
*
* @date 14.08.09
* @author Eldar Abusalimov
*/
#include <embox/test.h>
#include <test/misc.h>
EMBOX_TEST_SUITE("Stack usage tests");
static int fib(int k) {
if (k < 2) {
return k;
} else {
return fib(k - 1) + fib(k - 2);
}
}
TEST_CASE("Recursively calculating Fibonacci number") {
test_assert_equal(fib(0), 0);
test_assert_equal(fib(1), 1);
test_assert_equal(fib(2), 1);
test_assert_equal(fib(3), 2);
test_assert_equal(fib(4), 3);
test_assert_equal(fib(5), 5);
/* This is madness. This is SPARC!!! */
test_assert_equal(fib(17), 1597);
}
|
Use GtkDialog, not GnomeDialog. (GnomeAbout, GnomeAbout): Derive from | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* gnome-window.h: wrappers for setting window properties
*
* Author: Chema Celorio <chema@celorio.com>
*/
/*
* These functions are a convenience wrapper for gtk_window_set_title
* This allows all the gnome-apps to have a consitent way of setting
* the window & dialogs titles. We could also add a configurable way
* of setting the windows titles in the future..
*
* These functions were added with the 1.2.5 release of the GNOME libraries
* in Oct, 2000. This means that not all users will have this functionality
* in the GNOME libraries, and should only be used accordingly. The header file
* must be explicitely included, also (#include <libgnomeui/gnome-window.h>).
*/
#ifndef GNOME_WINDOW_H
#define GNOME_WINDOW_H
#include <gtk/gtkwindow.h>
G_BEGIN_DECLS
/* set the window title */
void gnome_window_toplevel_set_title (GtkWindow *w,
const gchar *doc_name,
const gchar *app_name,
const gchar *extension);
G_END_DECLS
#endif /* GNOME_WINDOW_H */
| /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* gnome-window.h: wrappers for setting window properties
*
* Author: Chema Celorio <chema@celorio.com>
*/
/*
* These functions are a convenience wrapper for gtk_window_set_title
* This allows all the gnome-apps to have a consitent way of setting
* the window & dialogs titles. We could also add a configurable way
* of setting the windows titles in the future..
*
* These functions were added with the 1.2.5 release of the GNOME libraries
* in Oct, 2000. This means that not all users will have this functionality
* in the GNOME libraries, and should only be used accordingly. The header file
* must be explicitely included, also (#include <libgnomeui/gnome-window.h>).
*/
#ifndef GNOME_WINDOW_H
#define GNOME_WINDOW_H
#include <gtk/gtkwindow.h>
G_BEGIN_DECLS
/* set the window title */
void gnome_window_toplevel_set_title (GtkWindow *w,
const gchar *doc_name,
const gchar *app_name,
const gchar *extension);
void gnome_window_set_icon (GtkWindow *window,
GdkPixbuf *pixbuf,
gboolean overwrite);
void gnome_window_set_icon_from_file (GtkWindow *window,
const char *filename,
gboolean overwrite);
G_END_DECLS
#endif /* GNOME_WINDOW_H */
|
Fix _LZO_H vs. LZO_H typo | /*
* LZO 1x decompression
* copyright (c) 2006 Reimar Doeffinger
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _LZO_H
#define LZO_H
#define LZO_INPUT_DEPLETED 1
#define LZO_OUTPUT_FULL 2
#define LZO_INVALID_BACKPTR 4
#define LZO_ERROR 8
#define LZO_INPUT_PADDING 4
#define LZO_OUTPUT_PADDING 12
int lzo1x_decode(void *out, int *outlen, void *in, int *inlen);
#endif
| /*
* LZO 1x decompression
* copyright (c) 2006 Reimar Doeffinger
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LZO_H
#define LZO_H
#define LZO_INPUT_DEPLETED 1
#define LZO_OUTPUT_FULL 2
#define LZO_INVALID_BACKPTR 4
#define LZO_ERROR 8
#define LZO_INPUT_PADDING 4
#define LZO_OUTPUT_PADDING 12
int lzo1x_decode(void *out, int *outlen, void *in, int *inlen);
#endif
|
Use __inline to fix MSVC build. | /**************************************************************************
*
* Copyright 2016 Jose Fonseca
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, 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 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 NON-INFRINGEMENT. NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OF OR CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
#pragma once
#include <windows.h>
// http://wiki.winehq.org/DeveloperFaq#detect-wine
static inline BOOL
insideWine(void)
{
HMODULE hNtDll = GetModuleHandleA("ntdll");
if (!hNtDll) {
return FALSE;
}
return GetProcAddress(hNtDll, "wine_get_version") != NULL;
}
| /**************************************************************************
*
* Copyright 2016 Jose Fonseca
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, 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 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 NON-INFRINGEMENT. NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OF OR CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
#pragma once
#include <windows.h>
// http://wiki.winehq.org/DeveloperFaq#detect-wine
static __inline BOOL
insideWine(void)
{
HMODULE hNtDll = GetModuleHandleA("ntdll");
if (!hNtDll) {
return FALSE;
}
return GetProcAddress(hNtDll, "wine_get_version") != NULL;
}
|
Add Nonmovable inheritance to Model. | #ifndef PRIMITIV_MODEL_H_
#define PRIMITIV_MODEL_H_
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
namespace primitiv {
class Parameter;
/**
* Set of parameters and specific algorithms.
*/
class Model {
Model(const Model &) = delete;
Model &operator=(const Model &) = delete;
public:
Model() = default;
Model(Model &&) = default;
Model &operator=(Model &&) = default;
virtual ~Model() = default;
/**
* Registers a new parameter.
* @param name Name of the parameter.
* @param param Reference to the parameter.
*/
void add_parameter(const std::string &name, Parameter ¶m);
/**
* Retrieves all parameters in the model which are trainable.
* @return List of pointers of trainable parameters.
*/
std::vector<Parameter *>get_trainable_parameters() const;
private:
std::unordered_map<std::string, Parameter *> param_kv_;
std::unordered_set<Parameter *> param_set_; // Shortcut to find parameters.
};
} // namespace primitiv
#endif // PRIMITIV_MODEL_H_
| #ifndef PRIMITIV_MODEL_H_
#define PRIMITIV_MODEL_H_
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <primitiv/mixins.h>
namespace primitiv {
class Parameter;
/**
* Set of parameters and specific algorithms.
*/
class Model : mixins::Nonmovable<Model> {
public:
Model() = default;
virtual ~Model() = default;
/**
* Registers a new parameter.
* @param name Name of the parameter.
* @param param Reference to the parameter.
*/
void add_parameter(const std::string &name, Parameter ¶m);
/**
* Retrieves all parameters in the model which are trainable.
* @return List of pointers of trainable parameters.
*/
std::vector<Parameter *>get_trainable_parameters() const;
private:
std::unordered_map<std::string, Parameter *> param_kv_;
std::unordered_set<Parameter *> param_set_; // Shortcut to find parameters.
};
} // namespace primitiv
#endif // PRIMITIV_MODEL_H_
|
UPDATE Lever entity sync state | #ifndef SSPAPPLICATION_ENTITIES_LEVERENTITY_H
#define SSPAPPLICATION_ENTITIES_LEVERENTITY_H
#include "Entity.h"
struct LeverSyncState {
};
class LeverEntity :
public Entity
{
private:
//Variables
bool m_isActive;
float m_range;
public:
LeverEntity();
virtual ~LeverEntity();
int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp);
int Update(float dT, InputHandler* inputHandler);
int React(int entityID, EVENT reactEvent);
//For now we check only if the player is close enough
int CheckPressed(DirectX::XMFLOAT3 playerPos);
private:
//Functions
};
#endif | #ifndef SSPAPPLICATION_ENTITIES_LEVERENTITY_H
#define SSPAPPLICATION_ENTITIES_LEVERENTITY_H
#include "Entity.h"
struct LeverSyncState {
int entityID;
bool iActive;
};
class LeverEntity :
public Entity
{
private:
//Variables
bool m_isActive;
float m_range;
bool m_needSync;
public:
LeverEntity();
virtual ~LeverEntity();
int Initialize(int entityID, PhysicsComponent* pComp, GraphicsComponent* gComp);
int Update(float dT, InputHandler* inputHandler);
int React(int entityID, EVENT reactEvent);
//For now we check only if the player is close enough
int CheckPressed(DirectX::XMFLOAT3 playerPos);
private:
//Functions
};
#endif |
Add Uefi Capsule Definition header file. | /** @file
Defines for the EFI Capsule functionality.
Copyright (c) 2006, Intel Corporation
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,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Capsule.h
@par Revision Reference:
These definitions are from Uefi Spec.
**/
#ifndef _EFI_CAPSULE_H_
#define _EFI_CAPSULE_H_
typedef struct {
EFI_GUID CapsuleGuid;
UINT32 HeaderSize;
UINT32 Flags;
UINT32 CapsuleImageSize;
} EFI_CAPSULE_HEADER;
#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000
#endif // #ifndef _EFI_CAPSULE_H_
| |
Include typeinfo header for RTTI | #ifndef APIMOCK_IOC_H
#define APIMOCK_IOC_H
#include <unordered_map>
#include <string>
namespace ApiMock {
class ServiceRegistry {
static std::unordered_map<std::string, void*> container;
public:
template<typename T>
static void Register(T* object) {
container[typeid(T).name()] = reinterpret_cast<void*>(object);
}
template<typename T>
static T* Resolve() {
return static_cast<T*>(container[typeid(T).name()]);
}
};
std::unordered_map<std::string, void*> ServiceRegistry::container;
};
#endif | #ifndef APIMOCK_IOC_H
#define APIMOCK_IOC_H
#include <unordered_map>
#include <typeinfo>
#include <string>
namespace ApiMock {
class ServiceRegistry {
static std::unordered_map<std::string, void*> container;
public:
template<typename T>
static void Register(T* object) {
container[typeid(T).name()] = reinterpret_cast<void*>(object);
}
template<typename T>
static T* Resolve() {
return static_cast<T*>(container[typeid(T).name()]);
}
};
std::unordered_map<std::string, void*> ServiceRegistry::container;
};
#endif |
Add uninitialized values test case. | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
struct s {
int data;
};
struct s global;
void g(int);
void f4() {
int a;
if (global.data == 0)
a = 3;
if (global.data == 0) // When the true branch is feasible 'a = 3'.
g(a); // no-warning
}
| // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
struct s {
int data;
};
struct s global;
void g(int);
void f4() {
int a;
if (global.data == 0)
a = 3;
if (global.data == 0) // When the true branch is feasible 'a = 3'.
g(a); // no-warning
}
// Test uninitialized value due to part of the structure being uninitialized.
struct TestUninit { int x; int y; };
struct TestUninit test_uninit_aux();
void test_uninit_pos() {
struct TestUninit v1 = { 0, 0 };
struct TestUninit v2 = test_uninit_aux();
int z;
v1.y = z;
test_unit_aux2(v2.x + v1.y); // expected-warning{{Pass-by-value argument in function call is undefined}}
}
void test_uninit_neg() {
struct TestUninit v1 = { 0, 0 };
struct TestUninit v2 = test_uninit_aux();
test_unit_aux2(v2.x + v1.y); // no-warning
}
|
Use an unsigned long for non-negative longs. | #ifndef MONSOON_METRIC_VALUE_INL_H
#define MONSOON_METRIC_VALUE_INL_H
#include <utility>
namespace monsoon {
inline metric_value::metric_value(metric_value&& other) noexcept
: value_(std::move(other.value_))
{}
inline auto metric_value::operator=(metric_value&& other) noexcept
-> metric_value& {
value_ = std::move(other.value_);
return *this;
}
inline metric_value::metric_value(bool v) noexcept
: value_(types::create<0>(v))
{}
inline metric_value::metric_value(long v) noexcept
: value_(types::create<1>(v))
{}
inline metric_value::metric_value(unsigned long v) noexcept
: value_(types::create<2>(v))
{}
inline metric_value::metric_value(double v) noexcept
: value_(types::create<3>(v))
{}
inline metric_value::metric_value(std::string v) noexcept
: value_(types::create<4>(std::move(v)))
{}
inline auto metric_value::operator!=(const metric_value& other) const noexcept
-> bool {
return !(*this == other);
}
inline auto metric_value::get() const noexcept -> const optional<types>& {
return value_;
}
} /* namespace monsoon */
#endif /* MONSOON_METRIC_VALUE_INL_H */
| #ifndef MONSOON_METRIC_VALUE_INL_H
#define MONSOON_METRIC_VALUE_INL_H
#include <utility>
namespace monsoon {
inline metric_value::metric_value(metric_value&& other) noexcept
: value_(std::move(other.value_))
{}
inline auto metric_value::operator=(metric_value&& other) noexcept
-> metric_value& {
value_ = std::move(other.value_);
return *this;
}
inline metric_value::metric_value(bool v) noexcept
: value_(types::create<0>(v))
{}
inline metric_value::metric_value(long v) noexcept
: value_(v >= 0 ? types::create<2>(v) : types::create<1>(v))
{}
inline metric_value::metric_value(unsigned long v) noexcept
: value_(types::create<2>(v))
{}
inline metric_value::metric_value(double v) noexcept
: value_(types::create<3>(v))
{}
inline metric_value::metric_value(std::string v) noexcept
: value_(types::create<4>(std::move(v)))
{}
inline auto metric_value::operator!=(const metric_value& other) const noexcept
-> bool {
return !(*this == other);
}
inline auto metric_value::get() const noexcept -> const optional<types>& {
return value_;
}
} /* namespace monsoon */
#endif /* MONSOON_METRIC_VALUE_INL_H */
|
Fix analyzer warning that title is not read | // Part of FoundationKit http://foundationk.it
#import <mach/mach_time.h>
#import "FKInternal.h"
/**
If we are in Debug-Mode this functions benchmarks the given block and logs
information about it's duration. Otherwise the block is just executed.
@param title the name of the benchmark
@param block the block to benchmark
*/
NS_INLINE void FKBenchmark(NSString *title, dispatch_block_t block) {
if (block == nil) {
return;
}
if (title == nil) {
title = @"<untitled>";
}
#ifdef FK_DEBUG
^{
FKLogAlways(@"'%@' benchmark started...", title);
const uint64_t start = mach_absolute_time();
block();
const uint64_t end = mach_absolute_time();
const uint64_t elapsedMTU = end - start;
// Get information for converting from MTU to nanoseconds
mach_timebase_info_data_t info;
mach_timebase_info(&info);
// Get elapsed time in nanoseconds:
const double elapsedNS = (double)elapsedMTU * (double)info.numer / (double)info.denom;
FKLogAlways(@"'%@' benchmark finished: %fs (%fns)", title, elapsedNS / NSEC_PER_SEC, elapsedNS);
}();
#else
block();
#endif
}
| // Part of FoundationKit http://foundationk.it
#import <mach/mach_time.h>
#import "FKInternal.h"
/**
If we are in Debug-Mode this functions benchmarks the given block and logs
information about it's duration. Otherwise the block is just executed.
@param title the name of the benchmark
@param block the block to benchmark
*/
NS_INLINE void FKBenchmark(NSString *title, dispatch_block_t block) {
if (block == nil) {
return;
}
#ifdef FK_DEBUG
^{
if (title == nil) {
title = @"<untitled>";
}
FKLogAlways(@"'%@' benchmark started...", title);
const uint64_t start = mach_absolute_time();
block();
const uint64_t end = mach_absolute_time();
const uint64_t elapsedMTU = end - start;
// Get information for converting from MTU to nanoseconds
mach_timebase_info_data_t info;
mach_timebase_info(&info);
// Get elapsed time in nanoseconds:
const double elapsedNS = (double)elapsedMTU * (double)info.numer / (double)info.denom;
FKLogAlways(@"'%@' benchmark finished: %fs (%fns)", title, elapsedNS / NSEC_PER_SEC, elapsedNS);
}();
#else
block();
#endif
}
|
Add a little header explaining the purpose of phase-01 | #include <stdlib.h>
int main(int argc, char *argv[])
{
return EXIT_SUCCESS;
}
| /**
* Phase 01 - Get a Window that works and can be closed.
*
* This code won't be structured very well, just trying to get stuff working.
*/
#include <stdlib.h>
int main(int argc, char *argv[])
{
return EXIT_SUCCESS;
}
|
Check in new macro vappend()- not actually used | /*
* tools.h
*
* Created on: May 4, 2011
* Author: wozniak
*/
#ifndef TOOLS_H
#define TOOLS_H
/**
Determine the length of an array of pointers
*/
int array_length(void** array);
#define append(string, args...) string += sprintf(string, ## args)
#endif /* TOOLS_H_ */
| /*
* tools.h
*
* Created on: May 4, 2011
* Author: wozniak
*/
#ifndef TOOLS_H
#define TOOLS_H
/**
Determine the length of an array of pointers
*/
int array_length(void** array);
#define append(string, args...) string += sprintf(string, ## args)
#define vappend(string, args...) string += vsprintf(string, ## args)
#endif
|
Add edge weights to side calculations | #ifndef ENGPAR_SIDES_H
#define ENGPAR_SIDES_H
#include <ngraph.h>
#include <PCU.h>
#include "engpar_container.h"
#include <engpar_metrics.h>
#include "engpar_diffusive_input.h"
namespace engpar {
class Sides : public Container<int> {
public:
Sides(agi::Ngraph* g, agi::etype t) {
agi::Ngraph* graph = g;
agi::GraphEdge* edge;
agi::EdgeIterator* eitr = graph->begin(t);
while ((edge = graph->iterate(eitr))) {
agi::Peers res;
g->getResidence(edge,res);
if (res.size()>1) {
agi::Peers::iterator itr;
for (itr=res.begin();itr!=res.end();itr++) {
if (*itr!=PCU_Comm_Self()) {
increment2(*itr);
}
}
my_total++;
}
}
g->destroy(eitr);
}
};
Sides* makeSides(DiffusiveInput* in);
Sides* makeSides(agi::Ngraph* g, agi::etype t);
}
#endif
| #ifndef ENGPAR_SIDES_H
#define ENGPAR_SIDES_H
#include <ngraph.h>
#include <PCU.h>
#include "engpar_container.h"
#include <engpar_metrics.h>
#include "engpar_diffusive_input.h"
namespace engpar {
class Sides : public Container<int> {
public:
Sides(agi::Ngraph* g, agi::etype t) {
agi::Ngraph* graph = g;
agi::GraphEdge* edge;
agi::EdgeIterator* eitr = graph->begin(t);
while ((edge = graph->iterate(eitr))) {
agi::Peers res;
g->getResidence(edge,res);
if (res.size()>1) {
agi::Peers::iterator itr;
for (itr=res.begin();itr!=res.end();itr++) {
if (*itr != PCU_Comm_Self()) {
(*this)[*itr]+=g->weight(edge);
}
}
my_total+= g->weight(edge);
}
}
g->destroy(eitr);
}
};
Sides* makeSides(DiffusiveInput* in);
Sides* makeSides(agi::Ngraph* g, agi::etype t);
}
#endif
|
Fix clang build that have been broken by 81364. | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#define CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#include "base/basictypes.h"
#include "content/browser/browser_message_filter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaType.h"
class GURL;
class QuotaDispatcherHost : public BrowserMessageFilter {
public:
~QuotaDispatcherHost();
bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok);
private:
void OnQueryStorageUsageAndQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type);
void OnRequestStorageQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type,
int64 requested_size);
};
#endif // CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_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 CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#define CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
#include "base/basictypes.h"
#include "content/browser/browser_message_filter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaType.h"
class GURL;
class QuotaDispatcherHost : public BrowserMessageFilter {
public:
~QuotaDispatcherHost();
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok);
private:
void OnQueryStorageUsageAndQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type);
void OnRequestStorageQuota(
int request_id,
const GURL& origin_url,
WebKit::WebStorageQuotaType type,
int64 requested_size);
};
#endif // CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_
|
Fix implied ms_abi where it shouldn't be | #pragma once
#include <cstdio>
// HACK: No idea where this should actually be defined
#define nullptr 0x0
#pragma GCC diagnostic ignored "-Wattributes"
#include "openvr.h"
#pragma GCC diagnostic warning "-Wattributes"
using namespace vr;
#ifdef __x86_64__
// MS instead of SysV ABI for 64bit
#define WOVR_ENTRY __attribute__((ms_abi))
#else
// Thispointer-in-ECX for 32bit
#define WOVR_ENTRY __attribute__((thiscall))
#endif
| #pragma once
#include <cstdio>
// HACK: No idea where this should actually be defined
#define nullptr 0x0
// If _WIN32 is defined, openvr.h will decorate the exported functions with __declspec(dllimport) which implies
// __attribute__((ms_abi)). This makes things explode, as we need to call them with SysV ABI.
#undef _WIN32
#include "openvr.h"
using namespace vr;
#ifdef __x86_64__
// MS instead of SysV ABI for 64bit
#define WOVR_ENTRY __attribute__((ms_abi))
#else
// Thispointer-in-ECX for 32bit
#define WOVR_ENTRY __attribute__((thiscall))
#endif
|
Add some allocator constants like minimum alignment or maximum small size. | // Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved.
// Please see the AUTHORS file for details. Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.
#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_
#include <stddef.h> // size_t
#include "config.h"
#define UNLIKELY(x) __builtin_expect((x), 0)
#define LIKELY(x) __builtin_expect((x), 1)
#define cache_aligned __attribute__((aligned(64)))
#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))
const size_t kSystemPageSize = PAGE_SIZE;
// Prohibit reordering of instructions by the compiler.
inline void CompilerBarrier() {
__asm__ __volatile__("" : : : "memory");
}
// Full memory fence on x86-64
inline void MemoryBarrier() {
__asm__ __volatile__("mfence" : : : "memory");
}
always_inline size_t PadSize(size_t size, size_t multiple) {
return (size + multiple - 1) / multiple * multiple;
}
#endif // SCALLOC_COMMON_H_
| // Copyright (c) 2012-2013, the scalloc Project Authors. All rights reserved.
// Please see the AUTHORS file for details. Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.
#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_
#include <stddef.h> // size_t
#include "config.h"
#define UNLIKELY(x) __builtin_expect((x), 0)
#define LIKELY(x) __builtin_expect((x), 1)
#define cache_aligned __attribute__((aligned(64)))
#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))
const size_t kSystemPageSize = PAGE_SIZE;
const size_t kMinAlignment = 16;
const size_t kMaxSmallSize = 512;
const size_t kNumClasses = kMaxSmallSize / kMinAlignment;
// Prohibit reordering of instructions by the compiler.
inline void CompilerBarrier() {
__asm__ __volatile__("" : : : "memory");
}
// Full memory fence on x86-64
inline void MemoryBarrier() {
__asm__ __volatile__("mfence" : : : "memory");
}
always_inline size_t PadSize(size_t size, size_t multiple) {
return (size + multiple - 1) / multiple * multiple;
}
#endif // SCALLOC_COMMON_H_
|
Add comment regarding mixed content preprocessor | //
// AshtonObjcMixedContentPreprocessor.h
// Ashton
//
// Created by Michael Schwarz on 15.01.18.
// Copyright © 2018 Michael Schwarz. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface AshtonObjcMixedContentPreprocessor: NSObject
- (NSString *)preprocessHTMLString:(NSString *)htmlString;
@end
NS_ASSUME_NONNULL_END
| //
// AshtonObjcMixedContentPreprocessor.h
// Ashton
//
// Created by Michael Schwarz on 15.01.18.
// Copyright © 2018 Michael Schwarz. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// TBXML parser cannot handle html mixed content, therefore we have to preprocess it
/// mixedContent = "<html>test <strong>sample</strong></html>", will be processed to
/// "<html><wrapped>test </wrapped><strong><wrapped>sample</wrapped></strong></html>
@interface AshtonObjcMixedContentPreprocessor: NSObject
- (NSString *)preprocessHTMLString:(NSString *)htmlString;
@end
NS_ASSUME_NONNULL_END
|
Add a facility to concatenate preprocessor strings. | /*!
* This file defines an interface to fold preprocessor strings into one token.
*
* @author Louis Dionne
*/
#ifndef JOY_INTERNAL_STRCAT_H
#define JOY_INTERNAL_STRCAT_H
#include <chaos/preprocessor/recursion/expr.h>
#include <chaos/preprocessor/algorithm/fold_right.h>
#include <chaos/preprocessor/string/core.h>
#define JOY_STRING_CAT(string) \
JOY_STRING_CAT_S(CHAOS_PP_STATE(), string)
#define JOY_STRING_CAT_S(state, string) \
CHAOS_PP_EXPR_S(state) ( \
CHAOS_PP_FOLD_RIGHT_S(state, \
JOY_I_STRING_CAT_TWO, \
(CHAOS_PP_STRING) string, \
/* no initial state of accumulation */ \
) \
) \
/**/
#define JOY_I_STRING_CAT_TWO(state, head, tail) \
CHAOS_PP_CAT(head, tail)
#endif /* !JOY_INTERNAL_STRCAT_H */
| |
Add include for smmintrin.h to this test. | // RUN: %clang -fsyntax-only %s
// RUN: %clang -fsyntax-only -fno-lax-vector-conversions %s
// RUN: %clang -fsyntax-only -x c++ %s
#if defined(i386) || defined(__x86_64__)
# if defined(__MMX__)
#include <emmintrin.h>
#include <mm_malloc.h>
# endif
# if defined(__SSE__)
#include <xmmintrin.h>
# endif
# if defined(__SSE3__)
#include <pmmintrin.h>
# endif
# if defined(__SSSE3__)
#include <tmmintrin.h>
# endif
#endif
| // RUN: %clang -fsyntax-only %s
// RUN: %clang -fsyntax-only -fno-lax-vector-conversions %s
// RUN: %clang -fsyntax-only -x c++ %s
#if defined(i386) || defined(__x86_64__)
# if defined(__MMX__)
#include <emmintrin.h>
#include <mm_malloc.h>
# endif
# if defined(__SSE__)
#include <xmmintrin.h>
# endif
# if defined(__SSE3__)
#include <pmmintrin.h>
# endif
# if defined(__SSSE3__)
#include <tmmintrin.h>
# endif
# if defined(__SSE4_1__)
#include <smmintrin.h>
# endif
#endif
|
Fix for complex reference on Mac. | #include "v3p_f2c.h"
#ifdef KR_headers
extern double sqrt(), f__cabs();
VOID c_sqrt(r, z) complex *r, *z;
#else
#undef abs
#include "math.h"
#ifdef __cplusplus
extern "C" {
#endif
extern double f__cabs(double, double);
void c_sqrt(complex *r, complex *z)
#endif
{
double mag, t;
double zi = z->i, zr = z->r;
if( (mag = f__cabs(zr, zi)) == 0.)
r->r = r->i = 0.;
else if(zr > 0)
{
r->r = t = sqrt(0.5 * (mag + zr) );
t = zi / t;
r->i = 0.5 * t;
}
else
{
t = sqrt(0.5 * (mag - zr) );
if(zi < 0)
t = -t;
r->i = t;
t = zi / t;
r->r = 0.5 * t;
}
}
#ifdef __cplusplus
}
#endif
| #include "v3p_f2c.h"
#ifdef KR_headers
extern double sqrt(), f__cabs();
VOID c_sqrt(r, z) complex *r, *z;
#else
#undef abs
#include "math.h"
#ifdef __cplusplus
extern "C" {
#endif
extern double f__cabs(double, double);
#undef complex
#define complex v3p_netlib_complex
void c_sqrt(complex *r, complex *z)
#endif
{
double mag, t;
double zi = z->i, zr = z->r;
if( (mag = f__cabs(zr, zi)) == 0.)
r->r = r->i = 0.;
else if(zr > 0)
{
r->r = t = sqrt(0.5 * (mag + zr) );
t = zi / t;
r->i = 0.5 * t;
}
else
{
t = sqrt(0.5 * (mag - zr) );
if(zi < 0)
t = -t;
r->i = t;
t = zi / t;
r->r = 0.5 * t;
}
}
#ifdef __cplusplus
}
#endif
|
Improve name AT_ARG changed to AT_TYPE | #ifndef SIMPLEAT_H
#define SIMPLEAT_H
#include <stdint.h>
#define AT_MAX_NUMBER_OF_ARGS 4
#define CLIENT_FUNCTION_TYPE uint16_t
#define ECHO_MODE_ON 1
#define AT_NO_ARGS {0}
#define AT_ARGS(...) {__VA_ARGS__, -1}
#define AT_ARG(x) ((uint8_t) sizeof (x))
#define AT_COMMAND(name, args, client) {(char*)#name, 0, args , 0, client}
#define ATReplyByteArray(x) ((uint8_t *) &x), sizeof(x)
typedef struct {
char *command;
uint8_t sizeOfCommand;
int8_t argsSize[AT_MAX_NUMBER_OF_ARGS];
uint8_t numberOfArgs;
void (*client)(const CLIENT_FUNCTION_TYPE*);
} ATCommandDescriptor;
void ATEngineDriverInit(uint8_t (*open)(void),
uint8_t (*read)(void),
void (*write)(uint8_t),
uint8_t (*available)(void));
void ATEngineInit(ATCommandDescriptor *engine, uint8_t sizeOfEngine);
uint8_t ATEngineRun();
void ATReplyWithByteArray(uint8_t *data, int size);
void ATReplyWithByte(uint8_t data);
void ATReplyWithString(char *str);
#endif // SIMPLEAT_H
| #ifndef SIMPLEAT_H
#define SIMPLEAT_H
#include <stdint.h>
#define AT_MAX_NUMBER_OF_ARGS 4
#define CLIENT_FUNCTION_TYPE uint16_t
#define ECHO_MODE_ON 1
#define AT_NO_ARGS {0}
#define AT_ARGS(...) {__VA_ARGS__, -1}
#define AT_TYPE(x) ((uint8_t) sizeof (x))
#define AT_COMMAND(name, args, client) {(char*)#name, 0, args , 0, client}
#define ATReplyByteArray(x) ((uint8_t *) &x), sizeof(x)
typedef struct {
char *command;
uint8_t sizeOfCommand;
int8_t argsSize[AT_MAX_NUMBER_OF_ARGS];
uint8_t numberOfArgs;
void (*client)(const CLIENT_FUNCTION_TYPE*);
} ATCommandDescriptor;
void ATEngineDriverInit(uint8_t (*open)(void),
uint8_t (*read)(void),
void (*write)(uint8_t),
uint8_t (*available)(void));
void ATEngineInit(ATCommandDescriptor *engine, uint8_t sizeOfEngine);
uint8_t ATEngineRun();
void ATReplyWithByteArray(uint8_t *data, int size);
void ATReplyWithByte(uint8_t data);
void ATReplyWithString(char *str);
#endif // SIMPLEAT_H
|
Correct previous merge with master | /*
* Copyright 2016, General Dynamics C4 Systems
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
*/
#ifndef __PLAT_MACHINE_HARDWARE_H
#define __PLAT_MACHINE_HARDWARE_H
#define physBase 0x80000000
#define kernelBase 0xe0000000
#define physMappingOffset (kernelBase - physBase)
#define BASE_OFFSET physMappingOffset
#define PPTR_TOP 0xfff00000
#define PADDR_TOP (PPTR_TOP - BASE_OFFSET)
#endif
| /*
* Copyright 2016, General Dynamics C4 Systems
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
*/
#ifndef __PLAT_MACHINE_HARDWARE_H
#define __PLAT_MACHINE_HARDWARE_H
#include <plat/machine/hardware_gen.h>
#define physBase 0x80000000
#define kernelBase 0xe0000000
#define physMappingOffset (kernelBase - physBase)
#define BASE_OFFSET physMappingOffset
#define PPTR_TOP 0xfff00000
#define PADDR_TOP (PPTR_TOP - BASE_OFFSET)
#endif
|
Add a header w/ macro to suppress unsigned integer UBSan warnings. | /*
* Copyright 2021 Scott Vokes
*
* See LICENCE for the full copyright terms.
*/
#ifndef LIBFSM_COMMON_H
#define LIBFSM_COMMON_H
#if defined(__clang__)
/* Newer versions of clang's UBSan emit warnings about *all* unsigned
* integer overflows. While they are defined behavior, overflow can
* cause bugs. This macro ignores them for a particular function.
* Overflow/rollover is expected in when hashing, for example. */
#define SUPPRESS_EXPECTED_UNSIGNED_INTEGER_OVERFLOW() \
__attribute__((no_sanitize("integer")))
#else
#define SUPPRESS_EXPECTED_UNSIGNED_INTEGER_OVERFLOW()
#endif
#endif
| |
Add WM8350 watchdog register definitions | /*
* wdt.h -- Watchdog Driver for Wolfson WM8350 PMIC
*
* Copyright 2007 Wolfson Microelectronics PLC
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef __LINUX_MFD_WM8350_WDT_H_
#define __LINUX_MFD_WM8350_WDT_H_
#define WM8350_WDOG_HIB_MODE 0x0080
#define WM8350_WDOG_DEBUG 0x0040
#define WM8350_WDOG_MODE_MASK 0x0030
#define WM8350_WDOG_TO_MASK 0x0007
#define WM8350_IRQ_SYS_WDOG_TO 24
#endif
| |
Remove __restrict when not supported -Erik |
#ifndef __FEATURES_H
#define __FEATURES_H
/* Major and minor version number of the uCLibc library package. Use
these macros to test for features in specific releases. */
#define __UCLIBC__ 0
#define __UCLIBC_MAJOR__ 9
#define __UCLIBC_MINOR__ 1
#ifdef __STDC__
#define __P(x) x
#define __const const
/* Almost ansi */
#if __STDC__ != 1
#define const
#define volatile
#endif
#else /* K&R */
#define __P(x) ()
#define __const
#define const
#define volatile
#endif
/* No C++ */
#define __BEGIN_DECLS
#define __END_DECLS
/* GNUish things */
#define __CONSTVALUE
#define __CONSTVALUE2
#define __USE_BSD
#define __USE_MISC
#define __USE_POSIX
#define __USE_POSIX2
#define _POSIX_THREAD_SAFE_FUNCTIONS
#include <sys/cdefs.h>
#endif
|
#ifndef __FEATURES_H
#define __FEATURES_H
/* Major and minor version number of the uCLibc library package. Use
these macros to test for features in specific releases. */
#define __UCLIBC__ 0
#define __UCLIBC_MAJOR__ 9
#define __UCLIBC_MINOR__ 1
/* __restrict is known in EGCS 1.2 and above. */
#if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ <
92)
# define __restrict /* Ignore */
#endif
#ifdef __STDC__
#define __P(x) x
#define __const const
/* Almost ansi */
#if __STDC__ != 1
#define const
#define volatile
#endif
#else /* K&R */
#define __P(x) ()
#define __const
#define const
#define volatile
#endif
/* No C++ */
#define __BEGIN_DECLS
#define __END_DECLS
/* GNUish things */
#define __CONSTVALUE
#define __CONSTVALUE2
#define __USE_BSD
#define __USE_MISC
#define __USE_POSIX
#define __USE_POSIX2
#define _POSIX_THREAD_SAFE_FUNCTIONS
#include <sys/cdefs.h>
#endif
|
Add more common __VERIFIER functions | void __VERIFIER_error() { abort(); }
int __VERIFIER_nondet_int() { int val; return val; } | void __VERIFIER_error() { abort(); }
// Some files define __VERIFIER_assume, some declare as extern. What happens when redefined?
void __VERIFIER_assume(int expression) { if (!expression) { LOOP: goto LOOP; }; return; }
// #define __VERIFIER_nondet(X) X __VERIFIER_nondet_##X() { X val; return val; }
#define __VERIFIER_nondet2(X, Y) X __VERIFIER_nondet_##Y() { X val; return val; }
#define __VERIFIER_nondet(X) __VERIFIER_nondet2(X, X)
__VERIFIER_nondet2(_Bool, bool)
__VERIFIER_nondet(char)
__VERIFIER_nondet2(unsigned char, uchar)
// int __VERIFIER_nondet_int() { int val; return val; }
__VERIFIER_nondet(int)
__VERIFIER_nondet2(unsigned int, uint)
__VERIFIER_nondet(long)
__VERIFIER_nondet2(unsigned long, ulong)
// void* __VERIFIER_nondet_pointer() { void* val; return val; }
__VERIFIER_nondet2(void*, pointer) |
Use a valid option (-msse) for testing QA_OVERRIDE_GCC3_OPTIONS. | // RUN: env QA_OVERRIDE_GCC3_OPTIONS="#+-Os +-Oz +-O +-O3 +-Oignore +a +b +c xb Xa Omagic ^-### " %clang -target x86_64-apple-darwin %s -O2 b -O3 2>&1 | FileCheck %s
// RUN: env QA_OVERRIDE_GCC3_OPTIONS="x-Werror +-mfoo" %clang -target x86_64-apple-darwin -Werror %s -c -### 2>&1 | FileCheck %s -check-prefix=RM-WERROR
// CHECK: "-cc1"
// CHECK-NOT: "-Oignore"
// CHECK: "-Omagic"
// CHECK-NOT: "-Oignore"
// RM-WERROR: ### QA_OVERRIDE_GCC3_OPTIONS: x-Werror +-mfoo
// RM-WERROR-NEXT: ### Deleting argument -Werror
// RM-WERROR-NEXT: ### Adding argument -mfoo at end
// RM-WERROR: warning: argument unused during compilation: '-mfoo'
// RM-WERROR-NOT: "-Werror"
| // RUN: env QA_OVERRIDE_GCC3_OPTIONS="#+-Os +-Oz +-O +-O3 +-Oignore +a +b +c xb Xa Omagic ^-### " %clang -target x86_64-apple-darwin %s -O2 b -O3 2>&1 | FileCheck %s
// RUN: env QA_OVERRIDE_GCC3_OPTIONS="x-Werror +-msse" %clang -target x86_64-apple-darwin -Werror %s -c -### 2>&1 | FileCheck %s -check-prefix=RM-WERROR
// CHECK: "-cc1"
// CHECK-NOT: "-Oignore"
// CHECK: "-Omagic"
// CHECK-NOT: "-Oignore"
// RM-WERROR: ### QA_OVERRIDE_GCC3_OPTIONS: x-Werror +-msse
// RM-WERROR-NEXT: ### Deleting argument -Werror
// RM-WERROR-NEXT: ### Adding argument -msse at end
// RM-WERROR-NOT: "-Werror"
|
Fix PPC failure. Adjust CHECK pattern. | // Test that function entry counts are set correctly.
// RUN: llvm-profdata merge %S/Inputs/func-entry.proftext -o %t.profdata
// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s
void foo(void);
// CHECK: define void @foo() #0 !prof [[FOO:![0-9]+]]
void foo() { return; }
// CHECK: define i32 @main() #1 !prof [[MAIN:![0-9]+]]
int main() {
int i;
for (i = 0; i < 10000; i++) foo();
return 0;
}
// CHECK: [[FOO]] = !{!"function_entry_count", i64 1000}
// CHECK: [[MAIN]] = !{!"function_entry_count", i64 1}
| // Test that function entry counts are set correctly.
// RUN: llvm-profdata merge %S/Inputs/func-entry.proftext -o %t.profdata
// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s
void foo(void);
// CHECK: @foo() #0 !prof [[FOO:![0-9]+]]
void foo() { return; }
// CHECK: @main() #1 !prof [[MAIN:![0-9]+]]
int main() {
int i;
for (i = 0; i < 10000; i++) foo();
return 0;
}
// CHECK: [[FOO]] = !{!"function_entry_count", i64 1000}
// CHECK: [[MAIN]] = !{!"function_entry_count", i64 1}
|
Complete the rename of LHASH functions and types | /*
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
struct lhash_node_st {
void *data;
struct lhash_node_st *next;
unsigned long hash;
};
struct lhash_st {
LHASH_NODE **b;
OPENSSL_LH_COMPFUNC comp;
OPENSSL_LH_HASHFUNC hash;
unsigned int num_nodes;
unsigned int num_alloc_nodes;
unsigned int p;
unsigned int pmax;
unsigned long up_load; /* load times 256 */
unsigned long down_load; /* load times 256 */
unsigned long num_items;
unsigned long num_expands;
unsigned long num_expand_reallocs;
unsigned long num_contracts;
unsigned long num_contract_reallocs;
unsigned long num_hash_calls;
unsigned long num_comp_calls;
unsigned long num_insert;
unsigned long num_replace;
unsigned long num_delete;
unsigned long num_no_delete;
unsigned long num_retrieve;
unsigned long num_retrieve_miss;
unsigned long num_hash_comps;
int error;
};
| /*
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
struct lhash_node_st {
void *data;
struct lhash_node_st *next;
unsigned long hash;
};
struct lhash_st {
OPENSSL_LH_NODE **b;
OPENSSL_LH_COMPFUNC comp;
OPENSSL_LH_HASHFUNC hash;
unsigned int num_nodes;
unsigned int num_alloc_nodes;
unsigned int p;
unsigned int pmax;
unsigned long up_load; /* load times 256 */
unsigned long down_load; /* load times 256 */
unsigned long num_items;
unsigned long num_expands;
unsigned long num_expand_reallocs;
unsigned long num_contracts;
unsigned long num_contract_reallocs;
unsigned long num_hash_calls;
unsigned long num_comp_calls;
unsigned long num_insert;
unsigned long num_replace;
unsigned long num_delete;
unsigned long num_no_delete;
unsigned long num_retrieve;
unsigned long num_retrieve_miss;
unsigned long num_hash_comps;
int error;
};
|
Add seven segment control code for debugging | #ifndef __SSEG_H
#define __SSEG_H
// aaa
// f b
// ggg
// e c
// ddd
const int kSegA = 1;
const int kSegB = 2;
const int kSegC = 4;
const int kSegD = 8;
const int kSegE = 16;
const int kSegF = 32;
const int kSegG = 64;
static char digits[] = {
~(kSegA | kSegB | kSegC | kSegD | kSegE | kSegF), // 0
~(kSegB | kSegC), // 1
~(kSegA | kSegB | kSegD | kSegE | kSegG), // 2
~(kSegA | kSegB | kSegC | kSegD | kSegG), // 3
~(kSegB | kSegC | kSegF | kSegG), // 4
~(kSegA | kSegC | kSegD | kSegF | kSegG), // 5
~(kSegA | kSegF | kSegG | kSegE | kSegC | kSegG), // 6
~(kSegA | kSegB | kSegC), // 7
~(kSegA | kSegB | kSegC | kSegD | kSegE | kSegF | kSegG), // 8
~(kSegA | kSegB | kSegC | kSegD | kSegF | kSegG), // 9
~(kSegA | kSegF | kSegB | kSegG | kSegE | kSegC), // A
~(kSegF | kSegG | kSegE | kSegC | kSegD), // b
~(kSegA | kSegF | kSegE | kSegD), // C
~(kSegB | kSegG | kSegE | kSegC | kSegD), // d
~(kSegA | kSegF | kSegG | kSegE | kSegD), // E
~(kSegA | kSegF | kSegG | kSegE) // F
};
volatile unsigned int * const kLedRegBase = (volatile unsigned int*) 0xffff0008;
#endif
| |
Add skeleton for demuxer modules | /* *
* $Id$
*
* This file is part of Fenice
*
* Fenice -- Open Media Server
*
* Copyright (C) 2007 by
* - Dario Gallucci <dario.gallucci@polito.it>
*
* Fenice 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.
*
* Fenice is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Fenice; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* */
#include <fenice/demuxer.h>
#include <fenice/demuxer_module.h>
static DemuxerInfo info = {
"Skeleton demuxer_module",
"skel",
"LScube Team",
"",
"skl"
};
FNC_LIB_DEMUXER(skel);
static int skel_probe(InputStream * i_stream)
{
return RESOURCE_NOT_FOUND;
}
static int skel_init(Resource * r)
{
return RESOURCE_DAMAGED;
}
static int skel_read_packet(Resource * r)
{
return RESOURCE_NOT_PARSEABLE;
}
static int skel_seek(Resource * r, double time_sec)
{
return RESOURCE_NOT_SEEKABLE;
}
static int skel_uninit(Resource * r)
{
return RESOURCE_OK;
}
| |
Update project to Xcode 11 beta 7 | //
// EZForm
//
// Copyright 2011-2013 Chris Miles. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "EZFormField.h"
@class EZForm;
@interface EZFormField (Private)
@property (nonatomic, assign, readwrite) EZForm *form;
@end
| //
// EZForm
//
// Copyright 2011-2013 Chris Miles. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "EZFormField.h"
@class EZForm;
@interface EZFormField (Private)
@property (nonatomic, weak, readwrite) EZForm *form;
@end
|
Solve Euler problem 44 on min. pentagon numbers. | // Copyright 2018 Dennis Decker Jensen
// Date: 29 April 2018
// Purpose: Minimum difference of pentagon numbers.
// Tectonics: cc -std=c11 -pedantic -Wall -O2 -o euler044 euler044.c
//
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
enum { npentagons = 10000 }; // N.B! Trial and error
unsigned pentagon[npentagons];
int
cmp(const void *a, const void *b)
{
unsigned ua = *(unsigned *)a, ub = *(unsigned *)b;
if (ua < ub) return -1;
else if (ua > ub) return 1;
else return 0;
}
int
main()
{
size_t i, j, m = 0, n = 0, si = 0, di = 0;
unsigned sum = 0, difference = 0, min = UINT_MAX, s, *b;
for (i = 0; i < npentagons; ++i)
pentagon[i] = i * (3 * i - 1) / 2;
for (i = 1; i < npentagons; ++i)
for (j = i + 1; j < npentagons
&& (s = pentagon[i] + pentagon[j])
<= pentagon[npentagons - 1]; ++j) {
b = bsearch(&s, pentagon, npentagons,
sizeof(unsigned), cmp);
if (b == NULL)
continue;
si = b - pentagon;
difference = pentagon[j] - pentagon[i];
b = bsearch(&difference, pentagon, npentagons,
sizeof(unsigned), cmp);
if (b == NULL)
continue;
di = b - pentagon;
if (difference < min) {
min = difference;
sum = s;
m = i;
n = j;
printf(">P%zu - P%zu = %u\n", m, n, min);
printf(">P%zu + P%zu = %u\n", m, n, sum);
}
}
printf("Minimum, P%zu - P%zu = P%zu (%u)\n", m, n, di, min);
printf(" P%zu + P%zu = P%zu (%u)\n", m, n, si, sum);
return 0;
}
| |
Check user address explicitly in copy_from_user_nmi() | /*
* User address space access functions.
*
* For licencing details see kernel-base/COPYING
*/
#include <linux/highmem.h>
#include <linux/module.h>
#include <asm/word-at-a-time.h>
/*
* best effort, GUP based copy_from_user() that is NMI-safe
*/
unsigned long
copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
{
unsigned long offset, addr = (unsigned long)from;
unsigned long size, len = 0;
struct page *page;
void *map;
int ret;
do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
break;
offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len);
map = kmap_atomic(page);
memcpy(to, map+offset, size);
kunmap_atomic(map);
put_page(page);
len += size;
to += size;
addr += size;
} while (len < n);
return len;
}
EXPORT_SYMBOL_GPL(copy_from_user_nmi);
| /*
* User address space access functions.
*
* For licencing details see kernel-base/COPYING
*/
#include <linux/highmem.h>
#include <linux/module.h>
#include <asm/word-at-a-time.h>
#include <linux/sched.h>
/*
* best effort, GUP based copy_from_user() that is NMI-safe
*/
unsigned long
copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
{
unsigned long offset, addr = (unsigned long)from;
unsigned long size, len = 0;
struct page *page;
void *map;
int ret;
if (__range_not_ok(from, n, TASK_SIZE) == 0)
return len;
do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
break;
offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len);
map = kmap_atomic(page);
memcpy(to, map+offset, size);
kunmap_atomic(map);
put_page(page);
len += size;
to += size;
addr += size;
} while (len < n);
return len;
}
EXPORT_SYMBOL_GPL(copy_from_user_nmi);
|
Add short hand for help command | #include "commands.h"
#include <stdbool.h>
#include <stdio.h>
#include "util.h"
static const char* quit_matches[] = {"quit"};
static const char* help_matches[] = {"help"};
static void print_commands_help() {
puts(" Commands available:\n");
puts(" :quit \tExit laco");
puts(" :help \tDisplay this list of commands");
}
static inline bool is_quit(const char* command) {
return laco_is_match(quit_matches, command);
}
static inline bool is_help(const char* command) {
return laco_is_match(help_matches, command);
}
void handle_command(struct LacoState* laco, char* line) {
if(laco != NULL && line != NULL) {
const char* command = line + 1;
if(is_quit(command)) {
laco_kill(laco, 0, "Exiting laco...");
} else if(is_help(command)) {
print_commands_help();
}
/* Make it seem like this was an empty line */
line[0] = '\0';
}
}
| #include "commands.h"
#include <stdbool.h>
#include <stdio.h>
#include "util.h"
static const char* quit_matches[] = {"quit"};
static const char* help_matches[] = {"help", "?"};
static void print_commands_help() {
puts(" Commands available:\n");
puts(" :quit \tExit laco");
puts(" :help, :? \tDisplay this list of commands");
}
static inline bool is_quit(const char* command) {
return laco_is_match(quit_matches, command);
}
static inline bool is_help(const char* command) {
return laco_is_match(help_matches, command);
}
void handle_command(struct LacoState* laco, char* line) {
if(laco != NULL && line != NULL) {
const char* command = line + 1;
if(is_quit(command)) {
laco_kill(laco, 0, "Exiting laco...");
} else if(is_help(command)) {
print_commands_help();
}
/* Make it seem like this was an empty line */
line[0] = '\0';
}
}
|
Add imports in main library header | //
// TATLayout.h
// TATLayout
//
// An expressive, simple yet poweful way for coding layout constraints in iOS.
//
// Copyright (c) 2014 Claudio Romandini.
//
// 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 "NSLayoutConstraint+TATConstraintFactory.h"
#import "UIView+TATViewConstraints.h"
| //
// TATLayout.h
// TATLayout
//
// An expressive, simple yet poweful way for coding layout constraints in iOS.
//
// Copyright (c) 2014 Claudio Romandini.
//
// 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 "NSLayoutConstraint+TATConstraintFactory.h"
#import "UIView+TATViewConstraints.h"
#import "TATLayoutManager.h"
#import "TATLayoutHelper.h"
|
Fix for no cuda environment | #ifndef INCLUDE_GUARD_CUPY_CUDA_THRUST_H
#define INCLUDE_GUARD_CUPY_CUDA_THRUST_H
#ifndef CUPY_NO_CUDA
namespace cupy {
namespace thrust {
template <typename T>
void _sort(void *, size_t *, const std::vector<ptrdiff_t>&, size_t, void *);
template <typename T>
void _lexsort(size_t *, void *, size_t, size_t, size_t, void *);
template <typename T>
void _argsort(size_t *, void *, void *, const std::vector<ptrdiff_t>&, size_t,
void *);
} // namespace thrust
} // namespace cupy
#else // CUPY_NO_CUDA
#include "cupy_common.h"
namespace cupy {
namespace thrust {
template <typename T> void _sort(...) { return; }
template <typename T> void _lexsort(...) { return; }
template <typename T> void _argsort(...) { return; }
} // namespace thrust
} // namespace cupy
#endif // #ifndef CUPY_NO_CUDA
#endif // INCLUDE_GUARD_CUPY_CUDA_THRUST_H
| #ifndef INCLUDE_GUARD_CUPY_CUDA_THRUST_H
#define INCLUDE_GUARD_CUPY_CUDA_THRUST_H
#ifndef CUPY_NO_CUDA
namespace cupy {
namespace thrust {
template <typename T>
void _sort(void *, size_t *, const std::vector<ptrdiff_t>&, size_t, void *);
template <typename T>
void _lexsort(size_t *, void *, size_t, size_t, size_t, void *);
template <typename T>
void _argsort(size_t *, void *, void *, const std::vector<ptrdiff_t>&, size_t,
void *);
} // namespace thrust
} // namespace cupy
#else // CUPY_NO_CUDA
#include "cupy_common.h"
namespace cupy {
namespace thrust {
template <typename T>
void _sort(void *, size_t *, const std::vector<ptrdiff_t>&, size_t, void *) {
return;
}
template <typename T>
void _lexsort(size_t *, void *, size_t, size_t, size_t, void *) {
return;
}
template <typename T>
void _argsort(size_t *, void *, void *, const std::vector<ptrdiff_t>&, size_t,
void *) {
return;
}
} // namespace thrust
} // namespace cupy
#endif // #ifndef CUPY_NO_CUDA
#endif // INCLUDE_GUARD_CUPY_CUDA_THRUST_H
|
Add an add_member method for adding members. Change visibility of everything. | #ifndef CONFIG_CLASS_H
#define CONFIG_CLASS_H
#include <map>
class Config;
class ConfigObject;
class ConfigType;
class ConfigValue;
class ConfigClass {
friend class Config;
std::string name_;
std::map<std::string, ConfigType *> members_;
protected:
ConfigClass(const std::string& name)
: name_(name),
members_()
{ }
private:
~ConfigClass();
virtual bool activate(ConfigObject *)
{
return (true);
}
bool set(ConfigObject *, const std::string&, ConfigValue *);
ConfigType *member(const std::string& mname) const
{
std::map<std::string, ConfigType *>::const_iterator it;
it = members_.find(mname);
if (it == members_.end())
return (NULL);
return (it->second);
}
};
#endif /* !CONFIG_CLASS_H */
| #ifndef CONFIG_CLASS_H
#define CONFIG_CLASS_H
#include <map>
class Config;
class ConfigObject;
class ConfigType;
class ConfigValue;
class ConfigClass {
friend class Config;
std::string name_;
std::map<std::string, ConfigType *> members_;
protected:
ConfigClass(const std::string& name)
: name_(name),
members_()
{ }
private:
~ConfigClass();
protected:
void add_member(const std::string& mname, ConfigType *type)
{
ASSERT(members_.find(mname) == members_.end());
members_[mname] = type;
}
private:
virtual bool activate(ConfigObject *)
{
return (true);
}
bool set(ConfigObject *, const std::string&, ConfigValue *);
ConfigType *member(const std::string& mname) const
{
std::map<std::string, ConfigType *>::const_iterator it;
it = members_.find(mname);
if (it == members_.end())
return (NULL);
return (it->second);
}
};
#endif /* !CONFIG_CLASS_H */
|
Remove chipselect member - not needed | /*
High_Temp.h
2014 Copyright (c) Seeed Technology Inc. All right reserved.
Loovee
2013-4-14
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
*/
#ifndef __HIGH_TEMP_MCP320x_H__
#define __HIGH_TEMP_MCPx320x_H__
#include <MCP3208.h>
#include <High_Temp.h>
class HighTempMCP320x: public HighTemp{
public:
HighTempMCP320x(int _spiCS, int _pinTmp, int _pinThmc);
private:
int spiChipSelect;
MCP3208 adc;
public:
int getAnalog(int pin);
};
#endif
| /*
High_Temp.h
2014 Copyright (c) Seeed Technology Inc. All right reserved.
Loovee
2013-4-14
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
*/
#ifndef __HIGH_TEMP_MCP320x_H__
#define __HIGH_TEMP_MCPx320x_H__
#include <MCP3208.h>
#include <High_Temp.h>
class HighTempMCP320x: public HighTemp{
public:
HighTempMCP320x(int _spiCS, int _pinTmp, int _pinThmc);
private:
MCP3208 adc;
public:
int getAnalog(int pin);
};
#endif
|
Remove texts for understanding to Wiki pages | #ifndef GPIOLIB_H
#define GPIOLIB_H
#define FORWARD 1
#define BACKWARD 0
namespace GPIO
{
int init();
int controlLeft(int direction,int speed);
int controlRight(int direction,int speed);
int stopLeft();
int stopRight();
int resetCounter();
void getCounter(int *countLeft,int *countRight);
int turnTo(int angle);
void delay(int milliseconds);
}
#endif
| #ifndef GPIOLIB_H
#define GPIOLIB_H
#define FORWARD 1
#define BACKWARD 0
namespace GPIO
{
int init();
int controlLeft(int direction,int speed);
int controlRight(int direction,int speed);
int stopLeft();
int stopRight();
int resetCounter();
void getCounter(int *countLeft,int *countRight);
int turnTo(int angle);
void delay(int milliseconds);
}
#endif
|
Work around undocumented feature/bug in perlapi function is_utf8_string() by short-circuiting StrHelp_utf8_valid() to return true when the length of the string is 0. | /* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "xs/XSBind.h"
#include "KinoSearch/Util/StringHelper.h"
// TODO: replace with code from ICU in common/ucnv_u8.c.
chy_bool_t
kino_StrHelp_utf8_valid(const char *ptr, size_t size)
{
const U8 *uptr = (const U8*)ptr;
return is_utf8_string(uptr, size);
}
| /* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "xs/XSBind.h"
#include "KinoSearch/Util/StringHelper.h"
// TODO: replace with code from ICU in common/ucnv_u8.c.
chy_bool_t
kino_StrHelp_utf8_valid(const char *ptr, size_t size)
{
const U8 *uptr = (const U8*)ptr;
return size == 0 ? true : !!is_utf8_string(uptr, size);
}
|
Add missing property for WebUtils mock | /****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Raine Makelainen <raine.makelainen@jolla.com>
**
****************************************************************************/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DECLARATIVEWEBUTILS_H
#define DECLARATIVEWEBUTILS_H
#include <QObject>
#include <QString>
#include <QColor>
#include <qqml.h>
class DeclarativeWebUtils : public QObject
{
Q_OBJECT
Q_PROPERTY(QString homePage READ homePage NOTIFY homePageChanged FINAL)
public:
explicit DeclarativeWebUtils(QObject *parent = 0);
Q_INVOKABLE int getLightness(QColor color) const;
Q_INVOKABLE QString displayableUrl(QString fullUrl) const;
static DeclarativeWebUtils *instance();
QString homePage() const;
bool firstUseDone() const;
void setFirstUseDone(bool firstUseDone);
signals:
void homePageChanged();
private:
QString m_homePage;
bool m_firstUseDone;
};
QML_DECLARE_TYPE(DeclarativeWebUtils)
#endif
| /****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Raine Makelainen <raine.makelainen@jolla.com>
**
****************************************************************************/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DECLARATIVEWEBUTILS_H
#define DECLARATIVEWEBUTILS_H
#include <QObject>
#include <QString>
#include <QColor>
#include <qqml.h>
class DeclarativeWebUtils : public QObject
{
Q_OBJECT
Q_PROPERTY(QString homePage READ homePage NOTIFY homePageChanged FINAL)
Q_PROPERTY(bool firstUseDone READ firstUseDone NOTIFY firstUseDoneChanged FINAL)
public:
explicit DeclarativeWebUtils(QObject *parent = 0);
Q_INVOKABLE int getLightness(QColor color) const;
Q_INVOKABLE QString displayableUrl(QString fullUrl) const;
static DeclarativeWebUtils *instance();
QString homePage() const;
bool firstUseDone() const;
void setFirstUseDone(bool firstUseDone);
signals:
void homePageChanged();
void firstUseDoneChanged();
private:
QString m_homePage;
bool m_firstUseDone;
};
QML_DECLARE_TYPE(DeclarativeWebUtils)
#endif
|
Add helper program to lookup C constants | #include <fcntl.h>
#include <stdio.h>
int
main(void)
{
printf("F_GETFL=%d\n", F_GETFL);
printf("F_SETFL=%d\n", F_SETFL);
printf("O_NONBLOCK=%d\n", O_NONBLOCK);
return 0;
}
| |
Add a small test program for century_offset(), passes. | #include "decode_time.h"
#include <stdio.h>
int
main(int argc, char *argv[])
{
/* start with 2000-01-01 = Saturday (matches `ncal 2000`) */
uint8_t century, lday, co;
struct tm time;
time.tm_wday = 6; /* Saturday */
/* check for every date if it matches */
for (century = 0; century < 4; century++)
for (time.tm_year = 0; time.tm_year < 100; time.tm_year++)
for (time.tm_mon = 1; time.tm_mon < 13; time.tm_mon++) {
time.tm_year += 2000 + century * 100;
lday = lastday(time);
time.tm_year -= 2000 + century * 100;
for (time.tm_mday = 1; time.tm_mday <= lday; time.tm_mday++) {
co = century_offset(time);
if (co != century)
printf("%d-%d-%d,%d : %d should be %d\n", time.tm_year, time.tm_mon, time.tm_mday, time.tm_wday, co, century);
time.tm_wday++;
if (time.tm_wday == 8)
time.tm_wday = 1;
}
}
printf("done\n");
return 0;
}
| |
Use iopoll instead of poll directly. | #include <errno.h>
#include <sys/poll.h>
#include "iobuf.h"
int iobuf_timeout(iobuf* io, int poll_out)
{
struct pollfd pfd;
int result;
if (!io->timeout) return 1;
pfd.fd = io->fd;
pfd.events = poll_out ? POLLOUT : POLLIN;
while ((result = poll(&pfd, 1, io->timeout)) == -1) {
if (errno == EAGAIN) continue;
IOBUF_SET_ERROR(io);
}
if (result) return 1;
io->flags |= IOBUF_TIMEOUT;
return 0;
}
| #include <errno.h>
#include "iobuf.h"
#include "iopoll.h"
int iobuf_timeout(iobuf* io, int poll_out)
{
iopoll_fd pfd;
int result;
if (!io->timeout) return 1;
pfd.fd = io->fd;
pfd.events = poll_out ? IOPOLL_WRITE : IOPOLL_READ;
while ((result = iopoll(&pfd, 1, io->timeout)) == -1) {
if (errno == EAGAIN) continue;
IOBUF_SET_ERROR(io);
}
if (result) return 1;
io->flags |= IOBUF_TIMEOUT;
return 0;
}
|
Fix export macro for non-MS compilers | ///////////////////////////////////////////////////////////////////////////////
// This source file is part of Zeroth.
//
// Copyright (c) 2016 Colin Hill
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <Hect/Core/Export.h>
#ifdef HECT_WINDOWS_BUILD
#ifdef ZEROTH_EXPORTS
#define ZEROTH_EXPORT __declspec(dllexport)
#else
#define ZEROTH_EXPORT __declspec(dllimport)
#endif
#else
#define ZEROTH_EXPORTS
#endif
| ///////////////////////////////////////////////////////////////////////////////
// This source file is part of Zeroth.
//
// Copyright (c) 2016 Colin Hill
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <Hect/Core/Export.h>
#ifdef HECT_WINDOWS_BUILD
#ifdef ZEROTH_EXPORTS
#define ZEROTH_EXPORT __declspec(dllexport)
#else
#define ZEROTH_EXPORT __declspec(dllimport)
#endif
#else
#define ZEROTH_EXPORT
#endif
|
Switch HDC1000 to file descriptor design | /* @author: Samuel G samuel.genois@mail.mcgill.ca
Modification Log:
Date Author Modification
-----------------------------------------------------------------
31-Oct-2018 Samuel G Created the file
==================================================================*/
#define HDC1000_CONFIG_TEMPERATURE_RESOLUTION_14BIT 0x0000
#define HDC1000_CONFIG_HUMIDITY_RESOLUTION_14BIT 0x0000
typedef struct {
//TODO
} HDC1000;
int HDC1000_init(HDC1000 *handle);
void setTemperatureResolution(int resolution);
void setHumidityResolution(int resolution);
int readTemperature(HDC1000 *handle, int *data);
int readHumidity(HDC1000 *handle, int *data); | /* @author: Samuel G samuel.genois@mail.mcgill.ca
Modification Log:
Date Author Modification
-----------------------------------------------------------------
31-Oct-2018 Samuel G Created the file
07-Nov-2018 Matthew L-K Switch to file descriptor design
==================================================================*/
#define HDC1000_CONFIG_TEMPERATURE_RESOLUTION_14BIT 0x0000
#define HDC1000_CONFIG_HUMIDITY_RESOLUTION_14BIT 0x0000
int HDC1000_temp_open();
int HDC1000_humid_open();
int read_temperature(int *data);
int read_humidity(int *data);
int HDC1000_temp_close();
int HDC1000_humid_close(); |
Remove attribute ignored by compiler | #pragma once
#include <truth/cpu.h>
#include <truth/types.h>
#include <truth/log.h>
#define Not_Reached false
#define assert(x) \
if (!(x)) { \
logf("Assertion failed: (%s) function %s, file %s, line %d.", \
(#x), __func__, __FILE__, __LINE__); \
panic(); \
}
#define assert_ok(x) \
if (x != Ok) { \
logf("Assertion failed (%s) status: %s, function %s, file %s, " \
"line %d.", (#x), status_message(x), __func__, __FILE__, \
__LINE__); \
panic(); \
}
static inline void no_return panic() {
disable_interrupts();
halt();
}
| #pragma once
#include <truth/cpu.h>
#include <truth/types.h>
#include <truth/log.h>
#define Not_Reached false
#define assert(x) \
if (!(x)) { \
logf("Assertion failed: (%s) function %s, file %s, line %d.", \
(#x), __func__, __FILE__, __LINE__); \
panic(); \
}
#define assert_ok(x) \
if (x != Ok) { \
logf("Assertion failed (%s) status: %s, function %s, file %s, " \
"line %d.", (#x), status_message(x), __func__, __FILE__, \
__LINE__); \
panic(); \
}
static inline void panic() {
disable_interrupts();
halt();
}
|
Remove exception handling before loading pgo sample profile data | // Test if PGO sample use passes are invoked.
//
// Ensure Pass PGOInstrumentationGenPass is invoked.
// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s
// CHECK: Remove unused exception handling info
// CHECK: Sample profile pass
| // Test if PGO sample use passes are invoked.
//
// Ensure Pass PGOInstrumentationGenPass is invoked.
// RUN: %clang_cc1 -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=LEGACY
// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=NEWPM
// LEGACY: Remove unused exception handling info
// LEGACY: Sample profile pass
// NEWPM: SimplifyCFGPass
// NEWPM: SampleProfileLoaderPass
int func(int a) { return a; }
|
Include maxdispargs.h instead of defs.h. | #include <netinet/in.h>
#include "defs.h" /* for MAXDISPARGS */
#define MAXTEXTARGS ((MAXDISPARGS*sizeof(double))/512)
#define MYPORT (IPPORT_RESERVED + 78)
/* IPPORT_RESERVED is 1024, so this is socket 1102
IPPORT_MAXPORT is 65535 on SGIs */
typedef struct sockdata {
char name[100]; /* the cmix command name */
union {
double p[MAXDISPARGS]; /* the p-fields */
char text[MAXTEXTARGS][512]; /* or text arrays */
} data;
int n_args; /* number of p-fields used */
} RTsockstr;
| #include <netinet/in.h>
#include "maxdispargs.h"
#define MAXTEXTARGS ((MAXDISPARGS*sizeof(double))/512)
#define MYPORT (IPPORT_RESERVED + 78)
/* IPPORT_RESERVED is 1024, so this is socket 1102
IPPORT_MAXPORT is 65535 on SGIs */
typedef struct sockdata {
char name[100]; /* the cmix command name */
union {
double p[MAXDISPARGS]; /* the p-fields */
char text[MAXTEXTARGS][512]; /* or text arrays */
} data;
int n_args; /* number of p-fields used */
} RTsockstr;
|
Add functions to perform simple approximate inference | #ifndef GRIDINF_INCLUDE_ESTIMATORS_H
#define GRIDINF_INCLUDE_ESTIMATORS_H
#include "core.h"
namespace ginf {
// Find the labeling where every node chooses the label that minimizes the data cost
template <typename T>
void decodeMaxPrior(Grid<T> *grid, Matrix<int> *result) {
for (int y = 0; y < grid->getHeight(); y++) {
for (int x = 0; x < grid->getWidth(); x++) {
int minLabel = 0;
for (int i = 1; i < grid->getNumLabels(); i++) {
if (grid->getDataCost(x, y, i) < grid->getDataCost(x, y, minLabel)) {
result->get(x, y) = i;
minLabel = i;
}
}
}
}
}
}
#endif
| |
Remove gen from loadable code | #include "csdl.h"
#include <math.h>
void tanhtable(FUNC *ftp, FGDATA *ff)
{
MYFLT *fp = ftp->ftable;
MYFLT range = ff->e.p[5];
double step = (double)range/(ff->e.p[3]);
int i;
double x;
for (i=0, x=FL(0.0); i<ff->e.p[3]; i++, x+=step)
*fp++ = (MYFLT)tanh(x);
}
static void gentune(FUNC *ftp, FGDATA *ff) /* Gab 1/3/2005 */
{
int j;
int notenum;
int grade;
int numgrades;
int basekeymidi;
MYFLT basefreq, factor,interval;
MYFLT *fp = ftp->ftable, *pp = &(ff->e.p[5]);
int nvals = ff->e.pcnt - 4;
numgrades = (int) *pp++;
interval = *pp++;
basefreq = *pp++;
basekeymidi= (int) *pp++;
nvals = ff->flenp1 - 1;
for (j =0; j < nvals; j++) {
notenum = j;
if (notenum < basekeymidi) {
notenum = basekeymidi - notenum;
grade = (numgrades-(notenum % numgrades)) % numgrades;
factor = - (MYFLT)(int) ((notenum+numgrades-1) / numgrades) ;
}
else {
notenum = notenum - basekeymidi;
grade = notenum % numgrades;
factor = (MYFLT)(int) (notenum / numgrades);
}
factor = (MYFLT)pow((double)interval, (double)factor);
fp[j] = pp[grade] * factor * basefreq;
}
}
static NGFENS localfgens[] = {
{ "tanh", (void(*)(void))tanhtable},
{ "cpstune", (void(*)(void))gentune},
{ NULL, NULL}
};
#define S sizeof
static OENTRY localops[] = {};
FLINKAGE
| #include "csdl.h"
#include <math.h>
void tanhtable(FUNC *ftp, FGDATA *ff)
{
MYFLT *fp = ftp->ftable;
MYFLT range = ff->e.p[5];
double step = (double)range/(ff->e.p[3]);
int i;
double x;
for (i=0, x=FL(0.0); i<ff->e.p[3]; i++, x+=step)
*fp++ = (MYFLT)tanh(x);
}
static NGFENS localfgens[] = {
{ "tanh", (void(*)(void))tanhtable},
{ NULL, NULL}
};
#define S sizeof
static OENTRY localops[] = {};
FLINKAGE
|
Fix a couple typos in the CHECK macros. | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0`
#ifndef OPENTITAN_SW_DEVICE_LIB_RUNTIME_CHECK_H_
#define OPENTITAN_SW_DEVICE_LIB_RUNTIME_CHECK_H_
#include <stdbool.h>
#include "sw/device/lib/base/log.h"
#include "sw/device/lib/runtime/abort.h"
/**
* Runtime assertion macros with log.h integration.
*/
/**
* Checks that the given condition is true. If the condition is false, this
* function logs and then aborts.
*
* @param condition an expression to check.
* @param ... arguments to a LOG_* macro, which are evaluated if the check
* fails.
*/
#define CHECK(condition, ...) \
do { \
if (!(condition)) { \
LOG_ERROR("CHECK-fail: " __VA_ARGS__); \
abort(); \
} \
} while (false)
/**
* Shorthand for CHECK(value == 0).
*
* @param condition a value to check.
* @param ... arguments to a LOG_* macro, which are evaluated if the check
* fails.
*/
#define CHECKZ(value, ...) CHECK((value) == 0, ...)
#endif // OPENTITAN_SW_DEVICE_LIB_RUNTIME_CHECK_H_
| // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0`
#ifndef OPENTITAN_SW_DEVICE_LIB_RUNTIME_CHECK_H_
#define OPENTITAN_SW_DEVICE_LIB_RUNTIME_CHECK_H_
#include <stdbool.h>
#include "sw/device/lib/base/log.h"
#include "sw/device/lib/runtime/hart.h"
/**
* Runtime assertion macros with log.h integration.
*/
/**
* Checks that the given condition is true. If the condition is false, this
* function logs and then aborts.
*
* @param condition an expression to check.
* @param ... arguments to a LOG_* macro, which are evaluated if the check
* fails.
*/
#define CHECK(condition, ...) \
do { \
if (!(condition)) { \
LOG_ERROR("CHECK-fail: " __VA_ARGS__); \
abort(); \
} \
} while (false)
/**
* Shorthand for CHECK(value == 0).
*
* @param condition a value to check.
* @param ... arguments to a LOG_* macro, which are evaluated if the check
* fails.
*/
#define CHECKZ(value, ...) CHECK((value) == 0, ##__VA_ARGS__)
#endif // OPENTITAN_SW_DEVICE_LIB_RUNTIME_CHECK_H_
|
Fix implicit conversion warning when building with floating point Lua | /**
* \file string_hash.c
* \brief Computes a hash value for a string.
* \author Copyright (c) 2012-2014 Jason Perkins and the Premake project
*/
#include "premake.h"
#include <string.h>
int string_hash(lua_State* L)
{
const char* str = luaL_checkstring(L, 1);
unsigned long seed = luaL_optint(L, 2, 0);
lua_pushnumber(L, do_hash(str, seed));
return 1;
}
unsigned long do_hash(const char* str, int seed)
{
/* DJB2 hashing; see http://www.cse.yorku.ca/~oz/hash.html */
unsigned long hash = 5381;
if (seed != 0) {
hash = hash * 33 + seed;
}
while (*str) {
hash = hash * 33 + (*str);
str++;
}
return hash;
}
| /**
* \file string_hash.c
* \brief Computes a hash value for a string.
* \author Copyright (c) 2012-2014 Jason Perkins and the Premake project
*/
#include "premake.h"
#include <string.h>
int string_hash(lua_State* L)
{
const char* str = luaL_checkstring(L, 1);
unsigned long seed = luaL_optint(L, 2, 0);
lua_pushnumber(L, (lua_Number)do_hash(str, seed));
return 1;
}
unsigned long do_hash(const char* str, int seed)
{
/* DJB2 hashing; see http://www.cse.yorku.ca/~oz/hash.html */
unsigned long hash = 5381;
if (seed != 0) {
hash = hash * 33 + seed;
}
while (*str) {
hash = hash * 33 + (*str);
str++;
}
return hash;
}
|
Add forward declarations for ansilove_ctx and ansilove_options structs. | /*
* types.h
* Ansilove 4.1.0
* https://www.ansilove.org
*
* Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus
* All rights reserved.
*
* Ansilove is licensed under the BSD 2-Clause License.
* See LICENSE file for details.
*/
#ifndef TYPES_H
#define TYPES_H
#define ANSILOVE_FILETYPE_ANS 1
#define ANSILOVE_FILETYPE_ADF 2
#define ANSILOVE_FILETYPE_BIN 3
#define ANSILOVE_FILETYPE_IDF 4
#define ANSILOVE_FILETYPE_PCB 5
#define ANSILOVE_FILETYPE_TND 6
#define ANSILOVE_FILETYPE_XB 7
extern char *types[];
extern int filetypes[];
extern int (*loaders[])(struct ansilove_ctx *, struct ansilove_options *);
#endif /* TYPES_H */
| /*
* types.h
* Ansilove 4.1.0
* https://www.ansilove.org
*
* Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus
* All rights reserved.
*
* Ansilove is licensed under the BSD 2-Clause License.
* See LICENSE file for details.
*/
#ifndef TYPES_H
#define TYPES_H
#define ANSILOVE_FILETYPE_ANS 1
#define ANSILOVE_FILETYPE_ADF 2
#define ANSILOVE_FILETYPE_BIN 3
#define ANSILOVE_FILETYPE_IDF 4
#define ANSILOVE_FILETYPE_PCB 5
#define ANSILOVE_FILETYPE_TND 6
#define ANSILOVE_FILETYPE_XB 7
struct ansilove_ctx;
struct ansilove_options;
extern char *types[];
extern int filetypes[];
extern int (*loaders[])(struct ansilove_ctx *, struct ansilove_options *);
#endif /* TYPES_H */
|
Make it explicit that the 'end' in a range [start, end[ is _not_ inclusive. | #ifndef EFDL_RANGE_H
#define EFDL_RANGE_H
#include <QPair>
#include <QDebug>
namespace efdl {
typedef QPair<qint64, qint64> Range; // (start, end)
}
QDebug operator<<(QDebug dbg, const efdl::Range &r);
#endif // EFDL_RANGE_H
| #ifndef EFDL_RANGE_H
#define EFDL_RANGE_H
#include <QPair>
#include <QDebug>
namespace efdl {
/**
* Encapsulates a file data range of the form [start, end[
*
* Note that "end" is not inclusive!
*/
typedef QPair<qint64, qint64> Range;
}
QDebug operator<<(QDebug dbg, const efdl::Range &r);
#endif // EFDL_RANGE_H
|
Add idle multiprocess system test. | /*
* kinetic-c
* Copyright (C) 2014 Seagate Technology.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <unistd.h>
#include <err.h>
#include "system_test_fixture.h"
#include "kinetic_client.h"
static SystemTestFixture Fixture;
#define IDLE_SECONDS 10
void setUp(void)
{
}
void tearDown(void)
{
}
static void child_task(void) {
SystemTestSetup(&Fixture, 0);
sleep(IDLE_SECONDS);
SystemTestTearDown(&Fixture);
exit(0);
}
void test_idle_system_should_go_dormant(void)
{
const int children = 16;
for (int i = 0; i < children; i++) {
pid_t pid = fork();
if (pid == 0) {
child_task();
} else if (pid == -1) {
err(1, "fork");
} else {
/* nop */
}
}
sleep(IDLE_SECONDS);
for (int i = 0; i < children; i++) {
int stat_loc = 0;
wait(&stat_loc);
}
}
| |
Include the no-buffer length when testing this function. | #include <string.h>
#include "number.h"
/** Format padding for a signed number. */
unsigned fmt_sign_pad(char* buffer, int sign, unsigned width, char pad)
{
char* s = buffer;
if (buffer == 0)
return width + (sign != 0);
if (!width) {
if (sign)
*s++ = '-';
}
else {
if (pad != '0') {
memset(s, pad, width);
s += width;
}
if (sign)
*s++ = '-';
if (pad == '0') {
memset(s, pad, width);
s += width;
}
}
return s - buffer;
}
#ifdef SELFTEST_MAIN
#include "selftest.c"
void test(int sign, unsigned width, char pad)
{
char buf[10];
buf[fmt_sign_pad(buf, sign, width, pad)] = 0;
obuf_puts(&outbuf, buf);
NL();
}
MAIN
{
test(0, 0, 0);
test(1, 0, 0);
test(0, 4, 'x');
test(1, 4, 'x');
test(0, 4, '0');
test(1, 4, '0');
}
#endif
#ifdef SELFTEST_EXP
-
xxxx
xxxx-
0000
-0000
#endif
| #include <string.h>
#include "number.h"
/** Format padding for a signed number. */
unsigned fmt_sign_pad(char* buffer, int sign, unsigned width, char pad)
{
char* s = buffer;
if (buffer == 0)
return width + (sign != 0);
if (!width) {
if (sign)
*s++ = '-';
}
else {
if (pad != '0') {
memset(s, pad, width);
s += width;
}
if (sign)
*s++ = '-';
if (pad == '0') {
memset(s, pad, width);
s += width;
}
}
return s - buffer;
}
#ifdef SELFTEST_MAIN
#include "selftest.c"
void test(int sign, unsigned width, char pad)
{
char buf[10];
obuf_putu(&outbuf, fmt_sign_pad(0, sign, width, pad));
obuf_putc(&outbuf, ':');
buf[fmt_sign_pad(buf, sign, width, pad)] = 0;
obuf_puts(&outbuf, buf);
NL();
}
MAIN
{
test(0, 0, 0);
test(1, 0, 0);
test(0, 4, 'x');
test(1, 4, 'x');
test(0, 4, '0');
test(1, 4, '0');
}
#endif
#ifdef SELFTEST_EXP
0:
1:-
4:xxxx
5:xxxx-
4:0000
5:-0000
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.