/**
 * Copyright 2006 Mike Tsao. All rights reserved.
 *
 * Hello World using FastCGI and ClearSilver.
 */

#include "ClearSilver.h"
#include <string>
#include <fcgi_stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <syslog.h>

static bool quit = false;

static int cs_printf(void *ctx, const char *s, va_list args) {
  return printf(s, args);
}

static int cs_write(void *ctx, const char *s, int n) {
  return fwrite(const_cast<char *>(s), n, 1, FCGI_stdout);
}

int main(int argc, char **argv, char **envp) {
  openlog(argv[0], 0, LOG_USER);
  syslog(LOG_INFO, "%s started.", argv[0]);

  int hits = 0;
  while (FCGI_Accept() >= 0) {
    HDF *hdf = NULL;
    CGI *cgi = NULL;

    /* Note that we aren't doing any error handling here, we really should. */
    hdf_init(&hdf);

    // Takes ownership of HDF.
    cgi_init(&cgi, hdf);

    hits++;

    /* Initialize the standard cgiwrap environment.  FastCGI already wraps some
     * of the standard calls that cgiwrap wraps.  */
    cgiwrap_init_std(argc, argv, environ);

    /* Then, we install our own wrappers for some cgiwrap calls that aren't
     * already wrapped in the standard wrappers. */
    cgiwrap_init_emu(NULL, NULL, cs_printf, cs_write, NULL, NULL, NULL);

    hdf_read_file(cgi->hdf, "common.hdf");
    hdf_read_file(cgi->hdf, "hello_world.hdf");

    cgi_display(cgi, "hello_world.cs");

    // This destroys HDF.
    cgi_destroy(&cgi);
  }
  syslog(LOG_INFO, "%s ending.", argv[0]);
  return 0;
}

Add a very simple example which uses FastCGI, a stripped down version of one given by Mike Tsao.


#pragma once
//------------------------------------------------------------------------------
/**
    @class UI
    @brief imgui-based debugger UI
*/
#include "yakc/KC85Oryol.h"
#include "ui/WindowBase.h"
#include "ui/FileLoader.h"
#include "Time/TimePoint.h"
#include "Core/Containers/Array.h"
#include "IMUI/IMUI.h"

class UI {
public:
    /// setup the UI
    void Setup(yakc::kc85& kc);
    /// discard the UI
    void Discard();
    /// do one frame
    void OnFrame(yakc::kc85& kc);
    /// open a window
    void OpenWindow(yakc::kc85& kc, const Oryol::Ptr<WindowBase>& window);
    /// toggle the UI on/off
    void Toggle();

    static const ImVec4 ColorText;
    static const ImVec4 ColorDetail;
    static const ImVec4 ColorDetailBright;
    static const ImVec4 ColorDetailDark;
    static const ImVec4 ColorBackground;
    static const ImVec4 ColorBackgroundLight;

    struct settings {
        bool crtEffect = true;
        bool colorTV = true;
        float crtWarp = 1.0f/64.0f;
        int cpuSpeed = 1;
    } Settings;

private:
    FileLoader fileLoader;
    Oryol::TimePoint curTime;
    Oryol::Array<Oryol::Ptr<WindowBase>> windows;
    bool uiEnabled = false;
    bool helpOpen = true;
};

#pragma once
//------------------------------------------------------------------------------
/**
    @class UI
    @brief imgui-based debugger UI
*/
#include "yakc/KC85Oryol.h"
#include "ui/WindowBase.h"
#include "ui/FileLoader.h"
#include "Time/TimePoint.h"
#include "Core/Containers/Array.h"
#include "IMUI/IMUI.h"

class UI {
public:
    /// setup the UI
    void Setup(yakc::kc85& kc);
    /// discard the UI
    void Discard();
    /// do one frame
    void OnFrame(yakc::kc85& kc);
    /// open a window
    void OpenWindow(yakc::kc85& kc, const Oryol::Ptr<WindowBase>& window);
    /// toggle the UI on/off
    void Toggle();

    static const ImVec4 ColorText;
    static const ImVec4 ColorDetail;
    static const ImVec4 ColorDetailBright;
    static const ImVec4 ColorDetailDark;
    static const ImVec4 ColorBackground;
    static const ImVec4 ColorBackgroundLight;

    struct settings {
        bool crtEffect = false;
        bool colorTV = true;
        float crtWarp = 1.0f/64.0f;
        int cpuSpeed = 1;
    } Settings;

private:
    FileLoader fileLoader;
    Oryol::TimePoint curTime;
    Oryol::Array<Oryol::Ptr<WindowBase>> windows;
    bool uiEnabled = false;
    bool helpOpen = true;
};

Switch off CRT-effect off by default (until fixed)


#include <stdio.h>

// k&r farenheit to celcius table

int main()
{
    int fahr, celsius;
    int lower, upper, step;

    lower = 0;
    upper = 300;
    step = 20;

    fahr = lower;
    while (fahr <= upper) {
        celsius = 5 * (fahr - 32) / 9;
        printf("%d\t%d\t\n", fahr, celsius);
        fahr = fahr + step;
    }

    return 0;
}

#include <stdio.h>

// k&r farenheit to celcius table

int main()
{
    float fahr, celsius;
    int lower, upper, step;

    lower = 0;
    upper = 300;
    step = 20;

    // first print table header
    printf("%s  %s\n", "Fahr", "Cels");

    // then calculate values and print them to table
    fahr = lower;
    while (fahr <= upper) {
        celsius = (5.0 / 9.0) * (fahr - 32);
        printf("%3.0f %6.1f\n", fahr, celsius);
        fahr = fahr + step;
    }

    return 0;
}

Use floats instead of ints, print table header


typedef struct TrailDBMultiTrailFields {
	long timestamp;
	long num_items;
	long items;
	long db;
	long multi_cur;
	long cursor_idx;
} TrailDBMultiTrailFields;

typedef struct TrailDBTrailFields {
	long timestamp;
	long num_items;
	long items;
	long db;
	long cur;
} TrailDBTrailFields;

Add static header file for fiels struct

Add static header file for fiels struct


#ifndef LRPARAMS_
#define LRPARAMS_

#include "np2ver.h"

#define LR_SCREENWIDTH  640
#define LR_SCREENHEIGHT 480
#define LR_SCREENASPECT 4.0 / 3.0
#define LR_SCREENFPS    56.4

#define LR_SOUNDRATE    44100.0
//#define SNDSZ 735 //44100Hz/60fps=735 (sample/flame)
#define SNDSZ 782 //44100Hz/56.4fps=781.9 (sample/flame)

#define LR_CORENAME        "Neko Project II"
#define LR_LIBVERSION      NP2VER_CORE
#define LR_VALIDFILEEXT    "d88|88d|d98|98d|fdi|xdf|hdm|dup|2hd|tfd|nfd|hd4|hd5|hd9|fdd|h01|hdb|ddb|dd6|dcp|dcu|flp|bin|fim|thd|nhd|hdi|vhd|sln"
#define LR_NEEDFILEPATH    true
#define LR_BLOCKARCEXTRACT false
#define LR_REQUIRESROM     false

#endif

#ifndef LRPARAMS_
#define LRPARAMS_

#include "np2ver.h"

#define LR_SCREENWIDTH  640
#define LR_SCREENHEIGHT 480
#define LR_SCREENASPECT 4.0 / 3.0
#define LR_SCREENFPS    56.4

#define LR_SOUNDRATE    44100.0
//#define SNDSZ 735 //44100Hz/60fps=735 (sample/flame)
#define SNDSZ 782 //44100Hz/56.4fps=781.9 (sample/flame)

#define LR_CORENAME        "Neko Project II kai"
#define LR_LIBVERSION      NP2VER_CORE
#define LR_VALIDFILEEXT    "d88|88d|d98|98d|fdi|xdf|hdm|dup|2hd|tfd|nfd|hd4|hd5|hd9|fdd|h01|hdb|ddb|dd6|dcp|dcu|flp|bin|fim|thd|nhd|hdi|vhd|sln"
#define LR_NEEDFILEPATH    true
#define LR_BLOCKARCEXTRACT false
#define LR_REQUIRESROM     false

#endif

Add 'kai' to core name

Add 'kai' to core name


#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
#include "transaction.h"

namespace You {
namespace DataStore {
namespace UnitTests {}

class DataStore {
public:
	Transaction && begin();

	// Modifying methods
	bool post(TaskId, SerializedTask&);
	bool put(TaskId, SerializedTask&);
	bool erase(TaskId);

	std::vector<SerializedTask> getAllTask();

private:
	static DataStore& get();
	bool isServing = false;
	std::deque<Internal::IOperation> operationsQueue;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
#include "transaction.h"

namespace You {
namespace DataStore {
namespace UnitTests { class DataStoreApiTest; }

class DataStore {
	friend class UnitTests::DataStoreApiTest;
public:
	Transaction && begin();

	// Modifying methods
	bool post(TaskId, SerializedTask&);
	bool put(TaskId, SerializedTask&);
	bool erase(TaskId);

	std::vector<SerializedTask> getAllTask();

private:
	static DataStore& get();
	bool isServing = false;
	std::deque<Internal::IOperation> operationsQueue;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

Add unit test class declaration and friend class it in DataStore


/*
*  Copyright 2015 Samuel Ghineț
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/

#pragma once

#include <vector>
#include <string>

#include "zLib.h"

namespace Zen
{
    struct ZLIB_API ResultItem
    {
        /* fullName: default value - a) if result = not found / invalid; b) if filter, means 'any' */
        std::tstring fullName;
    };

    typedef std::vector<ResultItem> Results;

    class ZLIB_API Find
    {
    public:
        Find() : m_dirPath(T(".")) {}
        explicit Find(const std::tstring& path) : m_dirPath(path) {}

        Results operator()();

    private:
        std::tstring m_dirPath;
    };
}

/*
*  Copyright 2015 Samuel Ghineț
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/

#pragma once

#include <vector>
#include <string>

#include "zLib.h"

namespace Zen
{
    struct ZLIB_API ResultItem
    {
        /* fullName: default value - a) if result = not found / invalid; b) if filter, means 'any' */
        std::tstring fullName;
    };

    typedef std::vector<ResultItem> Results;

    class ZLIB_API IFind
    {
    public:
        virtual ~IFind() {}

        virtual Results operator()() = 0;
    };

    class ZLIB_API Find : public IFind
    {
    public:
        Find() : m_dirPath(T(".")) {}
        explicit Find(const std::tstring& path) : m_dirPath(path) {}

        Results operator()();

    private:
        std::tstring m_dirPath;
    };
}

Use a mock for class ZSearch

Use a mock for class ZSearch

ZSearch now needs a ref to an interface, Zen::IFind&. The tests that check the functionality of ZSearch - ignoring of OS-specific issues - will need to provide a mock implementing IFind.


/*! \file SwiftParticle.h
 *  \brief header file for the SWIFT particle type.

*/

#ifndef SWIFT_PARTICLE_H
#define SWIFT_PARTICLE_H

#define SWIFT_STRUCT_ALIGNMENT 32
#define SWIFT_STRUCT_ALIGN __attribute__((aligned(SWIFT_STRUCT_ALIGNMENT)))

namespace Swift
{

    /* The different types of particles a #gpart can link to.
       Note we use the historical values from Gadget for these fields. */
    enum part_type {
        swift_type_gas = 0,
        swift_type_dark_matter = 1,
        swift_type_star = 4,
        swift_type_black_hole = 5,
        swift_type_count
    } __attribute__((packed));

    typedef char timebin_t;

    /* Gravity particle. */
    struct gpart {

        /* Particle ID. If negative, it is the negative offset of the #part with
           which this gpart is linked. */
        long long id_or_neg_offset;

        /* Particle position. */
        double x[3];

        /* Offset between current position and position at last tree rebuild. */
        float x_diff[3];

        /* Particle velocity. */
        float v_full[3];

        /* Particle acceleration. */
        float a_grav[3];

        /* Particle mass. */
        float mass;

        /* Gravitational potential */
        float potential;

        /* Time-step length */
        timebin_t time_bin;

        /* Type of the #gpart (DM, gas, star, ...) */
        enum part_type type;

        //#ifdef SWIFT_DEBUG_CHECKS
        //
        //    /* Numer of gparts this gpart interacted with */
        //    long long num_interacted;
        //
        //    /* Time of the last drift */
        //    integertime_t ti_drift;
        //
        //    /* Time of the last kick */
        //    integertime_t ti_kick;
        //
        //#endif
        //
        //#ifdef SWIFT_GRAVITY_FORCE_CHECKS
        //
        //    /* Brute-force particle acceleration. */
        //    double a_grav_exact[3];
        //
        //#endif

    } SWIFT_STRUCT_ALIGN;

    extern "C" {
        #include "hydro_part.h"
    }
}

#endif

/*! \file SwiftParticle.h
 *  \brief header file for the SWIFT particle type.

*/

#ifndef SWIFT_PARTICLE_H
#define SWIFT_PARTICLE_H

namespace Swift
{
    /* Include some struct definitions from SWIFT. */
    extern "C" {
        #include "align.h"
        #include "timeline.h"
        #include "part_type.h"
        #include "gravity_part.h"
        #include "hydro_part.h"
    }
}

#endif

Include SWIFT struct definitions directly from SWIFT.


/*
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xerces" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache\@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation, and was
 * originally based on software copyright (c) 2001, International
 * Business Machines, Inc., http://www.ibm.com .  For more information
 * on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

/*
 * $Id$
 */

//	Objective C only
#if __OBJC__
#endif

//	C++ only
#if defined(__cplusplus)
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <memory>
#endif

//	Standard C headers
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>

//	Carbon Headers
#include <Carbon/Carbon.h>
#include <CoreFoundation/CoreFoundation.h>

Add prefix file for ProjectBuilder samples

git-svn-id: 3ec853389310512053d525963cab269c063bb453@174526 13f79535-47bb-0310-9956-ffa450edef68


#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

Remove __restrict when not supported -Erik


#pragma once

#include "polynomial.h"

template <typename Polytype>
class linear_equation_system : public std::vector<Polytype> {
  std::vector<Polytype> rows;

  linear_equation_system reduced_echelon_form() const {
    std::vector<Polytype> nrows(*this);

    /* make sure rows are sorted with the left-most elements at the top */
    std::sort(std::begin(nrows), std::end(nrows),
              [](const Polytype &lhs,
                 const Polytype &rhs) { return lhs.degree() > rhs.degree(); });

    for (auto first_row = nrows.begin(); first_row != nrows.end();
         ++first_row) {
      (*first_row) *= first_row->at(first_row->degree()).inverse();
      for (auto next_rows = first_row + 1; next_rows != nrows.end();
           ++next_rows) {
        /* only add if not already zero */
        if (next_rows->at(first_row->degree()))
          (*next_rows) += (*first_row) * next_rows->at(next_rows->degree());
      }
      // std::cout << matrix(nrows) << std::endl;
    }

    for (auto modify = nrows.rbegin() + 1; modify != nrows.rend(); ++modify) {
      for (auto row = nrows.crbegin(); row != modify; ++row) {
        const size_t index = std::distance(std::crbegin(nrows), row) + 1;
        auto factor = modify->at(index);
        (*modify) += (*row) * factor;
      }
    }

    return linear_equation_system(nrows);
  }

public:
  using std::vector<Polytype>::vector;

  linear_equation_system() = default;
  linear_equation_system(const std::vector<Polytype> &v)
      : std::vector<Polytype>::vector(v) {}
  linear_equation_system(std::vector<Polytype> &&v)
      : std::vector<Polytype>::vector(std::move(v)) {}

  Polytype solution() const {
    linear_equation_system copy(reduced_echelon_form());

    /*
     * Matrix:
     * x = 0 0 1
     * y = 0 1 0
     * z = 1 0 0
     *     ^ back()[1].
     * Must be non-zero, otherwise the system is overdetermined.
     * Since it is in row-echelon form, it must be one.
     */
    if (copy.back()[1] != typename Polytype::element_type(1))
      throw std::runtime_error("Linear equation system not solvable");

    Polytype s;
    for (const auto &row : copy) {
      s.push_back(row[0]);
    }

    return s;
  }
};

Add linear equations system class template


#include <glib.h>

#if !GLIB_CHECK_VERSION (2, 40, 0)
# define g_assert_true(expr)            g_assert ((expr))
# define g_assert_false(expr)           g_assert (!(expr))
# define g_assert_null(expr)            g_assert ((expr) == NULL)
# define g_assert_nonnull(expr)         g_assert ((expr) != NULL)
#endif

#define graphene_assert_fuzzy_equals(n1,n2,epsilon) \
  G_STMT_START { \
    typeof ((n1)) __n1 = (n1); \
    typeof ((n2)) __n2 = (n2); \
    typeof ((epsilon)) __epsilon = (epsilon); \
    if (__n1 > __n2) { \
      if ((__n1 - __n2) < __epsilon) ; else { \
        g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
                                    #n1 " == " #n2 " (+/- " #epsilon ")", \
                                    __n1, "==", __n2, 'f'); \
      } \
    } else { \
      if ((__n2 - __n1) < __epsilon) ; else { \
        g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
                                    #n1 " == " #n2 " (+/- " #epsilon ")", \
                                    __n1, "==", __n2, 'f'); \
      } \
    } \
  } G_STMT_END

Add a fuzzy comparison macro

tests: Add a fuzzy comparison macro

We use something like this in the matrix test suite, but it's useful for
other types.


#include "tclMatrix.h"

int Matrix_Init	(Tcl_Interp*);

int Matrix_Init( Tcl_Interp *interp ) {

    /* matrix -- matrix	support	command	*/
    Tcl_CreateCommand(interp, "matrix",	Tcl_MatrixCmd,
		      (ClientData) NULL, (void (*)(ClientData))	NULL);

    Tcl_PkgProvide(interp, "Matrix", "0.1");
    return TCL_OK;
}

Add newline to make compiler happy.

Add newline to make compiler happy.

svn path=/trunk/; revision=2015


/*
 *  nextpnr -- Next Generation Place and Route
 *
 *  Copyright (C) 2021  gatecat <gatecat@ds0.me>
 *
 *  Permission to use, copy, modify, and/or distribute this software for any
 *  purpose with or without fee is hereby granted, provided that the above
 *  copyright notice and this permission notice appear in all copies.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 */

#ifndef BASE_CLUSTERINFO_H
#define BASE_CLUSTERINFO_H

#include "idstring.h"
#include "nextpnr_namespaces.h"

NEXTPNR_NAMESPACE_BEGIN

struct CellInfo;

// The 'legacy' cluster data, used for existing arches and to provide a basic implementation for arches without complex
// clustering requirements
struct BaseClusterInfo
{
    std::vector<CellInfo *> constr_children;
    const int UNCONSTR = INT_MIN;
    int constr_x = UNCONSTR;   // this.x - parent.x
    int constr_y = UNCONSTR;   // this.y - parent.y
    int constr_z = UNCONSTR;   // this.z - parent.z
    bool constr_abs_z = false; // parent.z := 0
};

NEXTPNR_NAMESPACE_END

#endif /* BASE_ARCH_H */

Add BaseClusterInfo for base implementation

Signed-off-by: gatecat <c690b4516f836771c8bd4e23cd8f1cebc83093a6@ds0.me>


/*
 * TEST: Grid reduction OP=PS_SUM
 * DIM: 2
 * PRIORITY: 1
 */

#include <stdio.h>
#include <stdlib.h>
#include "physis/physis.h"

#define N 4
#define REAL double
#define PSGrid2D PSGrid2DDouble
#define PSGrid2DNew PSGrid2DDoubleNew

REAL reduce(REAL *g) {
  REAL v = 0.0;
  int i;
  for (i = 0; i < N*N; ++i) {
    v += g[i];
  }
  return v;
}

int main(int argc, char *argv[]) {
  PSInit(&argc, &argv, 2, N, N);
  PSGrid2D g1 = PSGrid2DNew(N, N);
  size_t nelms = N*N;
  REAL *indata = (REAL *)malloc(sizeof(REAL) * nelms);
  int i;
  for (i = 0; i < nelms; i++) {
    indata[i] = i;
  }
  PSGridCopyin(g1, indata);
  REAL v;
  PSReduce(&v, PS_SUM, g1);
  REAL v_ref = reduce(indata);
  fprintf(stderr, "Reduction result: %f, reference: %f\n", v, v_ref);
  if (v != v_ref) {
    fprintf(stderr, "Error: Non matching result\n");
    exit(1);
  }
  PSGridFree(g1);
  PSFinalize();
  free(indata);
  return 0;
}

Add a test case for reduction of 2D grids.


/*
 * Copyright (c) 2004-2007 Sergey Lyubka <valenok@gmail.com>
 * All rights reserved
 *
 * "THE BEER-WARE LICENSE" (Revision 42):
 * Sergey Lyubka wrote this file.  As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return.
 */

#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/mman.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>

#include <pwd.h>
#include <unistd.h>
#include <dirent.h>
#include <dlfcn.h>
#define	SSL_LIB				"libssl.so"
#define	DIRSEP				'/'
#define	IS_DIRSEP_CHAR(c)		((c) == '/')
#define	O_BINARY			0
#define	closesocket(a)			close(a)
#define	ERRNO				errno
#define	NO_GUI

#define	InitializeCriticalSection(x)	/* FIXME UNIX version is not MT safe */
#define	EnterCriticalSection(x)
#define	LeaveCriticalSection(x)

/*
 * Copyright (c) 2004-2007 Sergey Lyubka <valenok@gmail.com>
 * All rights reserved
 *
 * "THE BEER-WARE LICENSE" (Revision 42):
 * Sergey Lyubka wrote this file.  As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return.
 */

#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/mman.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>

#include <pwd.h>
#include <unistd.h>
#include <dirent.h>
#include <dlfcn.h>
#ifndef SSL_LIB
#define	SSL_LIB				"libssl.so"
#endif
#define	DIRSEP				'/'
#define	IS_DIRSEP_CHAR(c)		((c) == '/')
#define	O_BINARY			0
#define	closesocket(a)			close(a)
#define	ERRNO				errno
#define	NO_GUI

#define	InitializeCriticalSection(x)	/* FIXME UNIX version is not MT safe */
#define	EnterCriticalSection(x)
#define	LeaveCriticalSection(x)

Allow to override SSL_LIB during build

Allow to override SSL_LIB during build

SSL_LIB defaults to libssl.so which is only provided by a -devel
package and hence not loadable dynamically during runtime.


//===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- 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 defines things specific to Unix implementations.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that
//===          is guaranteed to work on all UNIX variants.
//===----------------------------------------------------------------------===//

#include "llvm/Config/config.h"     // Get autoconf configuration settings
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cerrno>
#include <sys/types.h>
#include <sys/param.h>
#include <assert.h>
#include <string>

inline void ThrowErrno(const std::string& prefix) {
    char buffer[MAXPATHLEN];
    throw prefix + ": " + strerror(errno);
}

//===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- 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 defines things specific to Unix implementations.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that
//===          is guaranteed to work on all UNIX variants.
//===----------------------------------------------------------------------===//

#include "llvm/Config/config.h"     // Get autoconf configuration settings
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cerrno>
#include <sys/types.h>
#include <sys/param.h>
#include <assert.h>
#include <string>
#include <algorithm>

inline void ThrowErrno(const std::string& prefix) {
    char buffer[MAXPATHLEN];
    throw prefix + ": " + strerror(errno);
}

Make this work with the ICC compiler, contributed by Bjørn Wennberg

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@18626 91177308-0d34-0410-b5e6-96231b3b80d8


//===- llvm/System/Unix/Unix.h - Common Unix Include File -----*- 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 defines things specific to Unix implementations.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that
//===          is guaranteed to work on all UNIX variants.
//===----------------------------------------------------------------------===//

#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h>

inline void ThrowErrno(const std::string& prefix) {
#if defined __USE_XOPEN2K || defined __USE_MISC
    char buffer[MAXPATHLEN];
    strerror_r(errno,buffer, MAXPATHLEN);
    throw prefix + ": " + buffer;
#else
    throw prefix + ": " + strerror(errno);
#endif
}

//===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- 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 defines things specific to Unix implementations.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that
//===          is guaranteed to work on all UNIX variants.
//===----------------------------------------------------------------------===//

#include "Config/config.h"     // Get autoconf configuration settings
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cerrno>
#include <sys/types.h>
#include <sys/param.h>

inline void ThrowErrno(const std::string& prefix) {
#if defined __USE_XOPEN2K || defined __USE_MISC
    char buffer[MAXPATHLEN];
    strerror_r(errno,buffer, MAXPATHLEN);
    throw prefix + ": " + buffer;
#else
    throw prefix + ": " + strerror(errno);
#endif
}

Include some additional header files.
Fix the banner length.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@16086 91177308-0d34-0410-b5e6-96231b3b80d8


// RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s

// CHECK: cc1as
// CHECK: -mrelax-all

// RUN: %clang -### -fintegrated-as -c -save-temps %s 2>&1 | FileCheck %s -check-prefix FIAS

// FIAS: cc1as

// RUN: %clang -### -fno-integrated-as -S %s 2>&1 \
// RUN:     | FileCheck %s -check-prefix NOFIAS

// NOFIAS-NOT: cc1as
// NOFIAS: -cc1
// NOFIAS: -no-integrated-as

// RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s

// CHECK: cc1as
// CHECK: -mrelax-all

// RUN: %clang -### -fintegrated-as -c -save-temps %s 2>&1 | FileCheck %s -check-prefix FIAS

// FIAS: cc1as

// RUN: %clang -target none -### -fno-integrated-as -S %s 2>&1 \
// RUN:     | FileCheck %s -check-prefix NOFIAS

// NOFIAS-NOT: cc1as
// NOFIAS: -cc1
// NOFIAS: -no-integrated-as

Use a dummy target so the test passes when default target is for a toolchain implements useIntegratedAs() -> true

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@338553 91177308-0d34-0410-b5e6-96231b3b80d8


#ifndef __EFFEKSEER_SIMD_BRIDGE_SSE_H__
#define __EFFEKSEER_SIMD_BRIDGE_SSE_H__

#include "Float4_SSE.h"
#include "Int4_SSE.h"
#include "Base.h"

#if defined(EFK_SIMD_SSE2)

namespace Effekseer
{

namespace SIMD
{

inline Int4 Float4::Convert4i() const { return _mm_cvtps_epi32(s); }

inline Int4 Float4::Cast4i() const { return _mm_castps_si128(s); }

inline Float4 Int4::Convert4f() const { return _mm_cvtepi32_ps(s); }

inline Float4 Int4::Cast4f() const { return _mm_castsi128_ps(s); }

} // namespace SIMD

} // namespace Effekseer

#endif

#endif // __EFFEKSEER_SIMD_BRIDGE_SSE_H__

#ifndef __EFFEKSEER_SIMD_BRIDGE_SSE_H__
#define __EFFEKSEER_SIMD_BRIDGE_SSE_H__

#include "Float4_SSE.h"
#include "Int4_SSE.h"
#include "Base.h"

#if defined(EFK_SIMD_SSE2)

namespace Effekseer
{

namespace SIMD
{

inline Int4 Float4::Convert4i() const { return _mm_cvttps_epi32(s); }

inline Int4 Float4::Cast4i() const { return _mm_castps_si128(s); }

inline Float4 Int4::Convert4f() const { return _mm_cvtepi32_ps(s); }

inline Float4 Int4::Cast4f() const { return _mm_castsi128_ps(s); }

} // namespace SIMD

} // namespace Effekseer

#endif

#endif // __EFFEKSEER_SIMD_BRIDGE_SSE_H__

Fix a SIMD instruction mistake that regarding integer rounding.


/* Esvg - SVG
 * Copyright (C) 2012 Jorge Luis Zapata
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */
#include <jsapi.h>
#include <stdlib.h>
/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
#if 0
int main(int argc, char **argv)
{
	static JSClass global_class = {
		"global", JSCLASS_GLOBAL_FLAGS,
		JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
		JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
		JSCLASS_NO_OPTIONAL_MEMBERS
	};

	JSRuntime *rt;
	JSContext *cx;
	JSObject  *global;

	/* Create an instance of the engine */

	rt = JS_NewRuntime(1024*1024);

	if (!rt) {
		exit(EXIT_FAILURE);
	}

	/* Create an execution context */

	cx = JS_NewContext(rt, 8192);

	if (!cx) {
		exit(EXIT_FAILURE);
	}

	/* Create a global object and a set of standard objects */

	global = JS_NewObject(cx, &global_class, NULL, NULL);

	if (!global) {
		exit(EXIT_FAILURE);
	}

	if (JS_InitStandardClasses(cx, global) != JS_TRUE) {
		exit(EXIT_FAILURE);
	}

	/* Do something */

	...

	/* Cleanup */

	JS_DestroyContext(cx);
	JS_DestroyRuntime(rt);
	JS_ShutDown();

	exit(EXIT_SUCCESS);
}
#endif
/*----------------------------------------------------------------------------*
 *                          The script  interface                             *
 *----------------------------------------------------------------------------*/
static Esvg_Script_Descriptor _descriptor = {

};
/*============================================================================*
 *                                 Global                                     *
 *============================================================================*/
void esvg_script_js_sm_init(void)
{
	esvg_script_descriptor_register(&descriptor, "application/ecmascript");
}

void esvg_script_js_sm_shutdown(void)
{
	esvg_script_descriptor_unregister(&descriptor, "application/ecmascript");
}
/*============================================================================*
 *                                   API                                      *
 *============================================================================*/

Add the spidermonkey prototype We need to generate the bindings dynamically at least for the properties until ender have support for real functions. On spidermonkey the objects are created using a class and a prototype, we need to figure out how to match an idl interface with such scheme. Then wrapping ender properties and classes should be simple


#pragma once

#include <regex>

#include "appc/schema/common.h"

namespace appc {
namespace schema {

const unsigned int max_ac_name_length = 512;

template<typename T>
struct ACName : StringType<T> {
  explicit ACName<T>(const std::string& name)
  : StringType<T>(name) {}

  virtual Status validate() const {
    if (this->value.empty()) {
      return Invalid("ACName must not be empty.");
    }
    if (this->value.size() > max_ac_name_length) {
      return Invalid("ACName must not be longer than " + max_ac_name_length);
    }
    const std::regex pattern("^[a-z0-9]+([a-z0-9-\\./]*[a-z0-9])*$",
                             std::regex::ECMAScript);
    if (!std::regex_match(this->value, pattern)) {
      return Invalid("ACName must comply with rfc1123 + allow '/'");
    }
    return Valid();
  }
};

} // namespace schema
} // namespace appc

#pragma once

#include <regex>

#include "appc/schema/common.h"

namespace appc {
namespace schema {

const unsigned int max_ac_name_length = 512;

template<typename T>
struct ACName : StringType<T> {
  explicit ACName<T>(const std::string& name)
  : StringType<T>(name) {}

  virtual Status validate() const {
    if (this->value.empty()) {
      return Invalid("ACName must not be empty.");
    }
    if (this->value.size() > max_ac_name_length) {
      return Invalid("ACName must not be longer than " + max_ac_name_length);
    }
    const std::regex pattern("^[A-Za-z0-9]+([\\-\\.\\/][A-Za-z0-9]+)*$",
                             std::regex::ECMAScript);
    if (!std::regex_match(this->value, pattern)) {
      return Invalid("ACName must comply with rfc1123 + allow '/'");
    }
    return Valid();
  }
};

} // namespace schema
} // namespace appc

schema: Fix for AC Name type adherence to rfc1123


/*$ -march=pentium3 $*/

int f(int a, int b) {
	return a && b ? 11 : 42;
}

int x = 2, y = 3;

int main(void) {
	int ret = 23 < f(x,y);
	printf("%d\n", ret);
	return ret;
}

Use march=pentium3 to use if-conv

Use march=pentium3 to use if-conv

[r21671]


//
//  OCTDirectoryContent.h
//  OctoKit
//
//  Created by Aron Cedercrantz on 14-07-2013.
//  Copyright (c) 2013 GitHub. All rights reserved.
//

#import "OCTContent.h"

//{
//    "type": "dir",
//    "size": 0,
//    "name": "octokit",
//    "path": "lib/octokit",
//    "sha": "a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
//    "url": "https://api.github.com/repos/pengwynn/octokit/contents/lib/octokit",
//    "git_url": "https://api.github.com/repos/pengwynn/octokit/git/trees/a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
//    "html_url": "https://github.com/pengwynn/octokit/tree/master/lib/octokit",
//    "_links": {
//      "self": "https://api.github.com/repos/pengwynn/octokit/contents/lib/octokit",
//      "git": "https://api.github.com/repos/pengwynn/octokit/git/trees/a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
//      "html": "https://github.com/pengwynn/octokit/tree/master/lib/octokit"
//    }
//  }

// A directory in a git repository.
@interface OCTDirectoryContent : OCTContent
@end

//
//  OCTDirectoryContent.h
//  OctoKit
//
//  Created by Aron Cedercrantz on 14-07-2013.
//  Copyright (c) 2013 GitHub. All rights reserved.
//

#import "OCTContent.h"

// A directory in a git repository.
@interface OCTDirectoryContent : OCTContent
@end

Remove comment on JSON structure.

Remove comment on JSON structure.

- Not sure how I missed that while looking through the code… :)

Signed-off-by: Aron Cedercrantz <ce30127eefa07a02d568832e3de6952fb491981c@cedercrantz.se>


//===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LINKER_LINKER_H
#define LLVM_LINKER_LINKER_H

#include "llvm/ADT/SmallPtrSet.h"

#include <functional>

namespace llvm {
class DiagnosticInfo;
class Module;
class StructType;

/// This class provides the core functionality of linking in LLVM. It keeps a
/// pointer to the merged module so far. It doesn't take ownership of the
/// module since it is assumed that the user of this class will want to do
/// something with it after the linking.
class Linker {
  public:
    typedef std::function<void(const DiagnosticInfo &)>
        DiagnosticHandlerFunction;

    Linker(Module *M, DiagnosticHandlerFunction DiagnosticHandler);
    Linker(Module *M);
    ~Linker();

    Module *getModule() const { return Composite; }
    void deleteModule();

    /// \brief Link \p Src into the composite. The source is destroyed.
    /// Returns true on error.
    bool linkInModule(Module *Src);

    static bool LinkModules(Module *Dest, Module *Src,
                            DiagnosticHandlerFunction DiagnosticHandler);

    static bool LinkModules(Module *Dest, Module *Src);

  private:
    Module *Composite;
    SmallPtrSet<StructType*, 32> IdentifiedStructTypes;
    DiagnosticHandlerFunction DiagnosticHandler;
};

} // End llvm namespace

#endif

//===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LINKER_LINKER_H
#define LLVM_LINKER_LINKER_H

#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/STLExtras.h"

namespace llvm {
class DiagnosticInfo;
class Module;
class StructType;

/// This class provides the core functionality of linking in LLVM. It keeps a
/// pointer to the merged module so far. It doesn't take ownership of the
/// module since it is assumed that the user of this class will want to do
/// something with it after the linking.
class Linker {
  public:
    typedef function_ref<void(const DiagnosticInfo &)>
        DiagnosticHandlerFunction;

    Linker(Module *M, DiagnosticHandlerFunction DiagnosticHandler);
    Linker(Module *M);
    ~Linker();

    Module *getModule() const { return Composite; }
    void deleteModule();

    /// \brief Link \p Src into the composite. The source is destroyed.
    /// Returns true on error.
    bool linkInModule(Module *Src);

    static bool LinkModules(Module *Dest, Module *Src,
                            DiagnosticHandlerFunction DiagnosticHandler);

    static bool LinkModules(Module *Dest, Module *Src);

  private:
    Module *Composite;
    SmallPtrSet<StructType*, 32> IdentifiedStructTypes;
    DiagnosticHandlerFunction DiagnosticHandler;
};

} // End llvm namespace

#endif

Use a function_ref now that it works (r221753).

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@221756 91177308-0d34-0410-b5e6-96231b3b80d8


/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
 *
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

int server_init(DBusConnection *conn, gboolean secure);
void server_exit(void);
int server_register(struct btd_adapter *adapter);
int server_unregister(struct btd_adapter *adapter);

int server_find_data(const char *path, const char *pattern);

Remove header declared but not defined

network: Remove header declared but not defined


// Copyright 2015-present 650 Industries. All rights reserved.

#import "RCTLog.h"

RCTLogFunction EXDefaultRCTLogFunction;

// EXFrame will use this when the manifest indicates we should enable developer debugging
// Kernel will use this when (DEBUG == 1)
RCTLogFunction EXDeveloperRCTLogFunction;

RCTLogFunction EXGetKernelRCTLogFunction(void);

// Copyright 2015-present 650 Industries. All rights reserved.

#import "RCTLog.h"

extern RCTLogFunction EXDefaultRCTLogFunction;

// EXFrame will use this when the manifest indicates we should enable developer debugging
// Kernel will use this when (DEBUG == 1)
extern RCTLogFunction EXDeveloperRCTLogFunction;

extern RCTLogFunction EXGetKernelRCTLogFunction(void);

Make the linker happy about these functions

fbshipit-source-id: 8476c5d


#ifndef LILY_VALUE_H
# define LILY_VALUE_H

# include "lily_syminfo.h"

lily_method_val *lily_try_new_method_val();
lily_object_val *lily_try_new_object_val();
lily_hash_val *lily_try_new_hash_val();
lily_hash_elem *lily_try_new_hash_elem();

void lily_deref_method_val(lily_method_val *);
void lily_deref_str_val(lily_str_val *);
void lily_deref_object_val(lily_object_val *);
void lily_deref_list_val_by(lily_sig *, lily_list_val *, int);
void lily_deref_list_val(lily_sig *, lily_list_val *);
void lily_deref_hash_val(lily_sig *, lily_hash_val *);
void lily_deref_unknown_val(lily_value *);
void lily_deref_unknown_raw_val(lily_sig *, lily_raw_value);

#endif

#ifndef LILY_VALUE_H
# define LILY_VALUE_H

# include "lily_syminfo.h"

lily_method_val *lily_try_new_method_val();
lily_object_val *lily_try_new_object_val();
lily_hash_val *lily_try_new_hash_val();
lily_hash_elem *lily_try_new_hash_elem();

void lily_deref_method_val(lily_method_val *);
void lily_deref_str_val(lily_str_val *);
void lily_deref_object_val(lily_object_val *);
void lily_deref_list_val(lily_sig *, lily_list_val *);
void lily_deref_hash_val(lily_sig *, lily_hash_val *);
void lily_deref_unknown_val(lily_value *);
void lily_deref_unknown_raw_val(lily_sig *, lily_raw_value);

#endif

Remove lily_deref_list_val_by. This is a relic from the circle_buster era.


// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#pragma once

namespace gfx {
class Point;
}

namespace views {

class View;

////////////////////////////////////////////////////////////////////////////////
//
// MenuButtonDelegate
//
// An interface that allows a component to tell a View about a menu that it
// has constructed that the view can show (e.g. for MenuButton views, or as a
// context menu.)
//
////////////////////////////////////////////////////////////////////////////////
class MenuButtonDelegate {
 public:
  // Creates and shows a menu at the specified position. |source| is the view
  // the MenuButtonDelegate was set on.
  virtual void RunMenu(View* source, const gfx::Point& point) = 0;

 protected:
  virtual ~MenuButtonDelegate() {}
};

}  // namespace views

#endif  // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#pragma once

#include "ui/views/views_export.h"

namespace gfx {
class Point;
}

namespace views {

class View;

////////////////////////////////////////////////////////////////////////////////
//
// MenuButtonDelegate
//
// An interface that allows a component to tell a View about a menu that it
// has constructed that the view can show (e.g. for MenuButton views, or as a
// context menu.)
//
////////////////////////////////////////////////////////////////////////////////
class VIEWS_EXPORT MenuButtonDelegate {
 public:
  // Creates and shows a menu at the specified position. |source| is the view
  // the MenuButtonDelegate was set on.
  virtual void RunMenu(View* source, const gfx::Point& point) = 0;

 protected:
  virtual ~MenuButtonDelegate() {}
};

}  // namespace views

#endif  // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_

views: Fix win builder by tagging MenuButtonDelegate with VIEWS_EXPORT.

BUG=117092
TBR=sky@chromium.org

Review URL: https://chromiumcodereview.appspot.com/9647003

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@125656 0039d316-1c4b-4281-b951-d872f2087c98


#ifndef LLIST_H
#define LLIST_H

/* Doubly linked list */
#define DLLIST_PREPEND(list, item) STMT_START { \
	(item)->prev = NULL; \
	(item)->next = *(list); \
	if (*(list) != NULL) (*(list))->prev = (item); \
	*(list) = (item); \
	} STMT_END

#define DLLIST_REMOVE(list, item) STMT_START { \
	if ((item)->prev == NULL) \
		*(list) = (item)->next; \
	else \
		(item)->prev->next = (item)->next; \
	if ((item)->next != NULL) \
		(item)->next->prev = (item)->prev; \
	} STMT_END

#endif

#ifndef LLIST_H
#define LLIST_H

/* Doubly linked list */
#define DLLIST_PREPEND(list, item) STMT_START { \
	(item)->prev = NULL; \
	(item)->next = *(list); \
	if (*(list) != NULL) (*(list))->prev = (item); \
	*(list) = (item); \
	} STMT_END

#define DLLIST_REMOVE(list, item) STMT_START { \
	if ((item)->prev == NULL) \
		*(list) = (item)->next; \
	else \
		(item)->prev->next = (item)->next; \
	if ((item)->next != NULL) { \
		(item)->next->prev = (item)->prev; \
		(item)->next = NULL; \
	} \
	(item)->prev = NULL; \
	} STMT_END

#endif

DLLIST_REMOVE(): Set removed item's prev/next pointers to NULL.


#include <stdlib.h>
#include <check.h>

#include "../src/roman_calculator.h"

void verify_addition(const char *left, const char *right, const char *expected_result) {
	char *actual_result = roman_calculator_add(left, right);
	ck_assert_msg(
			strcmp(expected_result, actual_result) == 0,
			"%s + %s: expected %s, but was %s",
			left, right, expected_result, actual_result);
	free(actual_result);
}

START_TEST(can_add_by_simple_repetition)
{
	verify_addition("I", "I", "II");
	verify_addition("I", "II", "III");
	verify_addition("XX", "X", "XXX");
	verify_addition("C", "C", "CC");
	verify_addition("M", "MM", "MMM");
}
END_TEST

TCase *addition_tests()
{
	TCase *test_case = tcase_create("addition tests");
	tcase_add_test(test_case, can_add_by_simple_repetition);
	return test_case;
}

#include <stdlib.h>
#include <check.h>

#include "../src/roman_calculator.h"

void verify_addition(const char *left, const char *right, const char *expected_result) {
	char *actual_result = roman_calculator_add(left, right);
	ck_assert_msg(
			strcmp(expected_result, actual_result) == 0,
			"%s + %s: expected %s, but was %s",
			left, right, expected_result, actual_result);
	free(actual_result);
}

START_TEST(can_add_by_simple_repetition)
{
	verify_addition("I", "I", "II");
	verify_addition("I", "II", "III");
	verify_addition("XX", "X", "XXX");
	verify_addition("C", "C", "CC");
	verify_addition("M", "MM", "MMM");
}
END_TEST

START_TEST(can_add_by_concatenation)
{
	verify_addition("X", "I", "XI");
	verify_addition("MCX", "XV", "MCXXV");
	verify_addition("DCI", "II", "DCIII");
	verify_addition("LX", "XVI", "LXXVI");
}
END_TEST

TCase *addition_tests()
{
	TCase *test_case = tcase_create("addition tests");
	tcase_add_test(test_case, can_add_by_simple_repetition);
	tcase_add_test(test_case, can_add_by_concatenation);
	return test_case;
}

Add clarifying test about addition by concatenation

It doesn't just apply to repeating the same numeral.


#include <kotaka/privilege.h>
#include <kotaka/paths.h>
#include <kotaka/log.h>

#include <trace.h>
#include <type.h>
#include <status.h>

inherit "call_guard";
inherit "callout_guard";
inherit "touch";
inherit "object";

object objd_canary;

/**********/
/* status */
/**********/

nomask void _F_dummy()
{
}

#include <kotaka/privilege.h>
#include <kotaka/paths.h>
#include <kotaka/log.h>

#include <trace.h>
#include <type.h>
#include <status.h>

inherit "call_guard";
inherit "callout_guard";
inherit "touch";
inherit "object";

object canary;

/**********/
/* status */
/**********/

void set_canary(object new_canary)
{
	ACCESS_CHECK(SYSTEM());

	canary = new_canary;
}

object query_canary()
{
	ACCESS_CHECK(SYSTEM());

	return canary;
}

nomask void _F_dummy()
{
}

Allow objects to be tagged with canaries that can be destructed globally


#include <err.h>
#include <unistd.h>

#include "pkg.h"

int
pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
{
	struct pkg **rdeps;
	struct pkg_file **files;

	if (pkg == NULL || db == NULL)
		return (-1);

	rdeps = pkg_rdeps(pkg);
	files = pkg_files(pkg);

	if (rdeps == NULL || files == NULL)
		return (-1);

	if (rdeps[0] != NULL && force == 0) {
		warnx("%s is required by other packages", pkg_get(pkg, PKG_ORIGIN));
		return (-1); /* TODO: special return code */
	}

	for (int i = 0; files[i] != NULL; i++) {
		if (unlink(pkg_file_path(files[i])) == -1) {
			warn("unlink(%s)", pkg_file_path(files[i]));
			continue;
		}
	}

	return (pkgdb_unregister_pkg(db, pkg_get(pkg, PKG_ORIGIN)));
}

#include <string.h>
#include <err.h>
#include <unistd.h>
#include <sha256.h>
#include <sys/stat.h>

#include "pkg.h"

int
pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
{
	struct pkg **rdeps;
	struct pkg_file **files;
	char sha256[65], *sha256_ptr;
	struct stat st;

	if (pkg == NULL || db == NULL)
		return (-1);

	rdeps = pkg_rdeps(pkg);
	files = pkg_files(pkg);

	if (rdeps == NULL || files == NULL)
		return (-1);

	if (rdeps[0] != NULL && force == 0) {
		warnx("%s is required by other packages", pkg_get(pkg, PKG_ORIGIN));
		return (-1); /* TODO: special return code */
	}

	for (int i = 0; files[i] != NULL; i++) {
		/* check sha256 */
		if (lstat(pkg_file_path(files[i]), &st) != -1 && !S_ISLNK(st.st_mode) &&
			((sha256_ptr = SHA256_File(pkg_file_path(files[i]), sha256)) == NULL ||
			strcmp(sha256_ptr, pkg_file_sha256(files[i])) != 0))
			warnx("%s fails original SHA256 checksum, not removed",
					pkg_file_path(files[i]));

		else if (unlink(pkg_file_path(files[i])) == -1) {
			warn("unlink(%s)", pkg_file_path(files[i]));
			continue;
		}
	}

	return (pkgdb_unregister_pkg(db, pkg_get(pkg, PKG_ORIGIN)));
}

Check files sha256 when delete pkg

Check files sha256 when delete pkg


#ifndef BUFFER_H
#define BUFFER_H

#include <stdio.h>

struct Buffer {
    char *buffer;
    size_t size;
    size_t head;
    size_t len;
};

struct Buffer *new_buffer();
void free_buffer(struct Buffer *);

ssize_t buffer_recv(struct Buffer *, int, int);
ssize_t buffer_send(struct Buffer *, int, int);
ssize_t buffer_read(struct Buffer *, int);
ssize_t buffer_write(struct Buffer *, int);
size_t buffer_peek(const struct Buffer *, void *, size_t);
size_t buffer_pop(struct Buffer *, void *, size_t);
size_t buffer_push(struct Buffer *, const void *, size_t);
inline size_t buffer_len(const struct Buffer *b) {
    return b->len;
}
inline size_t buffer_room(const struct Buffer *b) {
    return b->size - b->len;
}

#endif

#ifndef BUFFER_H
#define BUFFER_H

#include <stdio.h>

struct Buffer {
    char *buffer;
    size_t size;
    size_t head;
    size_t len;
};

struct Buffer *new_buffer();
void free_buffer(struct Buffer *);

ssize_t buffer_recv(struct Buffer *, int, int);
ssize_t buffer_send(struct Buffer *, int, int);
ssize_t buffer_read(struct Buffer *, int);
ssize_t buffer_write(struct Buffer *, int);
size_t buffer_peek(const struct Buffer *, void *, size_t);
size_t buffer_pop(struct Buffer *, void *, size_t);
size_t buffer_push(struct Buffer *, const void *, size_t);
static inline size_t buffer_len(const struct Buffer *b) {
    return b->len;
}
static inline size_t buffer_room(const struct Buffer *b) {
    return b->size - b->len;
}

#endif

Use static for inline methods in headers


#ifndef SCREENSHOT_H_INCLUDED_
#define SCREENSHOT_H_INCLUDED_
#include <vector>
#include <string>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/X.h>
using namespace std;

class X11Screenshot {
    public:
        X11Screenshot(XImage * image);
        bool save_to_png(const char * path);
        bool save_to_jpeg(const char * path, int quality);
        int get_width(void);
        int get_height(void);

    private:
        int width = 0;
        int height = 0;
        vector<vector<unsigned char>> image_data;
        vector<vector<unsigned char>> process_rgb_image(XImage * image);
};

#endif

#ifndef SCREENSHOT_H_INCLUDED_
#define SCREENSHOT_H_INCLUDED_
#include <vector>
#include <string>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/X.h>
using namespace std;

class X11Screenshot {
    public:
        X11Screenshot(XImage * image, int new_width=0, int new_height=0, string downscale_type="lineral");
        bool save_to_png(const char * path);
        bool save_to_jpeg(const char * path, int quality);
        int get_width(void);
        int get_height(void);

    private:
        int width = 0;
        int height = 0;
        vector<vector<unsigned char>> image_data = vector<vector<unsigned char>>();
        vector<vector<unsigned char>> process_original(XImage * image);
        vector<vector<unsigned char>> process_downscale_lineral(XImage * image, int new_width=0, int new_height=0);
        vector<vector<unsigned char>> process_downscale_bilineral(XImage * image, int new_width=0, int new_height=0);
};

#endif

Change X11Screenshot structure, add downscale options


#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

#if __has_include("RCTLog.h")
#import "RCTLog.h"
#else
#import <React/RCTLog.h>
#endif

#if __has_include("RCTUtils.h")
#import "RCTUtils.h"
#else
#import <React/RCTUtils.h>
#endif

#import "JKBigInteger.h"

@interface RNAWSCognito : NSObject <RCTBridgeModule>

@end

#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

#if __has_include("RCTLog.h")
#import "RCTLog.h"
#else
#import <React/RCTLog.h>
#endif

#if __has_include("RCTUtils.h")
#import "RCTUtils.h"
#else
#import <React/RCTUtils.h>
#endif

#import <JKBigInteger.h>

@interface RNAWSCognito : NSObject <RCTBridgeModule>

@end

Fix Cognito BigInteger import for versioning

fbshipit-source-id: ae0433a


#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class AliAnalysisTaskFemtoESE+;
#pragma link C++ class AliFemtoESEBasicParticle+;

Add Event-Shape-Engineering code for Femtoscopy


/*
 * remap_file_pages() for uClibc
 *
 * Copyright (C) 2008 Will Newton <will.newton@imgtec.com>
 *
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 */

#include <sys/syscall.h>

#ifdef __NR_remap_file_pages

_syscall5(int, remap_file_pages, unsigned long, start, unsigned long, size,
	  unsigned long, prot, unsigned long, pgoff, unsigned long, flags);

#endif

Add rempa_file_pages function by Will Newton <will.newton@imgtec.com>


#ifndef XMMSCLIENTPP_SUPERLIST_H
#define XMMSCLIENTPP_SUPERLIST_H

#include <xmmsclient/xmmsclient.h>

namespace Xmms
{

	namespace Detail
	{
		class SuperList
		{

			public:
				SuperList( xmmsc_result_t* result );
				SuperList( const SuperList& list );
				virtual SuperList& operator=( const SuperList& list );
				virtual ~SuperList();

				virtual void first();
				virtual void operator++();

				virtual bool isValid() const;

			protected:
				xmmsc_result_t* result_;
				bool constructed_;

				virtual void constructContents() = 0;

		};

		void dict_foreach( const void* key,
		                   xmmsc_result_value_type_t type,
						   const void* value,
						   void* udata );

		void propdict_foreach( const void* key,
		                       xmmsc_result_value_type_t type,
							   const void* value,
							   const char* source,
							   void* udata );

	}

}
#endif // XMMSCLIENTPP_SUPERLIST_H

#ifndef XMMSCLIENTPP_SUPERLIST_H
#define XMMSCLIENTPP_SUPERLIST_H

#include <xmmsclient/xmmsclient.h>

namespace Xmms
{

	namespace Detail
	{
		class SuperList
		{

			public:
				SuperList( xmmsc_result_t* result );
				SuperList( const SuperList& list );
				virtual SuperList& operator=( const SuperList& list );
				virtual ~SuperList();

				virtual void first();
				virtual void operator++();

				virtual bool isValid() const;

			protected:
				xmmsc_result_t* result_;
				bool constructed_;

				virtual void constructContents() = 0;

		};

	}

}
#endif // XMMSCLIENTPP_SUPERLIST_H

OTHER: Remove obsolete *_foreach function completely (Function declarations were still there).


// RUN: %llvmgcc -c -emit-llvm %s -o - | llvm-dis | grep llvm.noinline

static int bar(int x, int y) __attribute__((noinline));

static int bar(int x, int y)
{
 return x + y;
}

int foo(int a, int b) {
 return  bar(b, a);
}

// RUN: %llvmgcc -O2 -c -emit-llvm %s -o - | llvm-dis | grep call

static int bar(int x, int y) __attribute__((noinline));

static int bar(int x, int y)
{
 return x + y;
}

int foo(int a, int b) {
 return  bar(b, a);
}

Update test to check call instruction.

Update test to check call instruction.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@55702 91177308-0d34-0410-b5e6-96231b3b80d8


// PARAM: --enable ana.int.interval --enable exp.partition-arrays.enabled
#include <assert.h>
#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
#include <stddef.h>

// Test to check whether partitioned arrays can have an index expression evaluating to values largers than the max value of int64

#define LENGTH (LONG_MAX - 600)
#define STOP (LENGTH - 1)

int main(){
    // Check that ptdrdiff_t is at least as big as long, so we can index arrays with non-negative longs
    assert(sizeof(ptrdiff_t) >= sizeof(long));

    char *arr = calloc(LENGTH, sizeof(char));
    if(arr == NULL){
        printf("Could not allocate array, exiting.\n");
        return 1;
    }

    for(unsigned long i = 0; i < STOP; i++){
        arr[i] = 1;
    }

    // arr[0] ... arr[STOP - 1] should be 1, the others equal to 0
    assert(arr[0] == 1);
    assert(arr[INT_MAX + 1l] == 1);

    // j is the smallest index that checking triggers the unsoundness
    // long j = ((long) INT_MAX) * INT_MAX * 2 + INT_MAX - 1;
    long j = LONG_MAX - 6442450943;
    assert(0 < j);
    assert(j < STOP);

    // This check still works
    assert(arr[j - 1] == 1);

    // These two fail somehow
    assert(arr[j] == 1);
    assert(arr[STOP - 1] == 1);

    assert(arr[STOP] == 0);
    assert(arr[LENGTH - 1] == 0);
    return 0;
}

Add test with very large arrays where partitioned array is unsound


//
//  SDLDebugToolConsole.h
//  SmartDeviceLink-iOS
//
//  Created by Joel Fischer on 3/12/15.
//  Copyright (c) 2015 smartdevicelink. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol SDLDebugToolConsole <NSObject>

@required
- (void)logInfo:(NSString *)info;

@end

//
//  SDLDebugToolConsole.h
//  SmartDeviceLink-iOS

#import <Foundation/Foundation.h>

@protocol SDLDebugToolConsole <NSObject>

@required
- (void)logInfo:(NSString *)info;

@end

Remove copyright from new file

Remove copyright from new file


/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GMSampleView_DEFINED
#define GMSampleView_DEFINED

#include "SampleCode.h"
#include "gm.h"

class GMSampleView : public SampleView {
private:
    typedef skiagm::GM GM;

public:
    GMSampleView(GM* gm)
    : fGM(gm) {}

    virtual ~GMSampleView() {
        delete fGM;
    }

protected:
    virtual bool onQuery(SkEvent* evt) {
        if (SampleCode::TitleQ(*evt)) {
            SkString name("GM ");
            name.append(fGM->shortName());
            SampleCode::TitleR(evt, name.c_str());
            return true;
        }
        return this->INHERITED::onQuery(evt);
    }

    virtual void onDrawContent(SkCanvas* canvas) {
        fGM->drawContent(canvas);
    }

    virtual void onDrawBackground(SkCanvas* canvas) {
        fGM->drawBackground(canvas);
    }

private:
    GM* fGM;
    typedef SampleView INHERITED;
};

#endif

/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GMSampleView_DEFINED
#define GMSampleView_DEFINED

#include "SampleCode.h"
#include "gm.h"

class GMSampleView : public SampleView {
private:
    typedef skiagm::GM GM;

public:
    GMSampleView(GM* gm)
    : fGM(gm) {}

    virtual ~GMSampleView() {
        delete fGM;
    }

protected:
    virtual bool onQuery(SkEvent* evt) {
        if (SampleCode::TitleQ(*evt)) {
            SkString name("GM:");
            name.append(fGM->shortName());
            SampleCode::TitleR(evt, name.c_str());
            return true;
        }
        return this->INHERITED::onQuery(evt);
    }

    virtual void onDrawContent(SkCanvas* canvas) {
        fGM->drawContent(canvas);
    }

    virtual void onDrawBackground(SkCanvas* canvas) {
        fGM->drawBackground(canvas);
    }

private:
    GM* fGM;
    typedef SampleView INHERITED;
};

#endif

Use : as separator between "GM" and slide name in SampleApp. This makes it easier to jump to a GM slide using command line args on windows.

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@2846 2bbb7eff-a529-9590-31e7-b0007b416f81


/* j/3/xeb.c
**
*/
#include "all.h"

/* functions
*/
  u3_noun
  u3qc_xeb(u3_atom a)
  {
    mpz_t a_mp;

    if ( __(u3a_is_dog(a)) ) {
      u3r_mp(a_mp, a);
      size_t log = mpz_sizeinbase(a_mp, 2);
      mpz_t b_mp;
      mpz_init_set_ui(b_mp, log);
      return u3i_mp(b_mp);
    }
    else {
      mpz_init_set_ui(a_mp, a);
      c3_d x = mpz_sizeinbase(a_mp, 2);
      mpz_t b_mp;
      mpz_init_set_ui(b_mp, x);
      return u3i_mp(b_mp);
    }
  }
  u3_noun
  u3wc_xeb(
                  u3_noun cor)
  {
    u3_noun a;

    if ( (u3_none == (a = u3r_at(u3x_sam, cor))) ||
         (c3n == u3ud(a)) )
    {
      return u3m_bail(c3__exit);
    } else {
      return u3qc_xeb(a);
    }
  }

/* j/3/xeb.c
**
*/
#include "all.h"

/* functions
*/
  u3_noun
  u3qc_xeb(u3_atom a)
  {
    mpz_t a_mp;

    if ( __(u3a_is_dog(a)) ) {
      u3r_mp(a_mp, a);
      c3_d x = mpz_sizeinbase(a_mp, 2);
      mpz_t b_mp;
      mpz_init_set_ui(b_mp, x);
      return u3i_mp(b_mp);
    }
    else {
      mpz_init_set_ui(a_mp, a);
      c3_d x = mpz_sizeinbase(a_mp, 2);
      mpz_t b_mp;
      mpz_init_set_ui(b_mp, x);
      return u3i_mp(b_mp);
    }
  }
  u3_noun
  u3wc_xeb(
                  u3_noun cor)
  {
    u3_noun a;

    if ( (u3_none == (a = u3r_at(u3x_sam, cor))) ||
         (c3n == u3ud(a)) )
    {
      return u3m_bail(c3__exit);
    } else {
      return u3qc_xeb(a);
    }
  }

Use urbit types instead of size_t

Use urbit types instead of size_t


#include <math.h>
#include <stdio.h>

int main() {
    double a, b, c, delta;

    scanf("%lf %lf %lf", &a, &b, &c);

    delta = (b * b) - 4 * a * c;
    if (delta >= 0 && a != 0) {
        printf("R1 = %.5lf\n", ((b * -1) + sqrt(delta)) / (2 * a));
        printf("R2 = %.5lf\n", ((b * -1) - sqrt(delta)) / (2 * a));
    } else {
        printf("Impossivel calcular\n");
    }

    return 0;
}

Solve Bhaskara's Formula in c

Solve Bhaskara's Formula in c


#ifdef GUADALUPE_SPREAD

int cpumap(int i, int nprocs)
{
  return (i / 36) * 36 + (i % 2) * 18 + (i % 36 / 2);
}

#elif GUADALUPE_MIC_COMPACT

int cpumap(int i, int nprocs)
{
  return (i + 1) % 228;
}

#else

int cpumap(int id, int nprocs)
{
  return id % nprocs;
}

#endif

#ifdef GUADALUPE_SPREAD

int cpumap(int i, int nprocs)
{
  return (i / 36) * 36 + (i % 2) * 18 + (i % 36 / 2);
}

#elif GUADALUPE_MIC_COMPACT

int cpumap(int i, int nprocs)
{
  return (i + 1) % 228;
}

#elif BIOU_COMPACT

int cpumap(int i, int nprocs)
{
  return (i % 4) * 32 + i / 4;
}

#else

int cpumap(int id, int nprocs)
{
  return id % nprocs;
}

#endif

Add compact allocation on BioU.

Add compact allocation on BioU.


#pragma once

#include "scratch/bits/type-traits/is-foo.h"

namespace scratch {

template<class It> struct is_contiguous_iterator : is_pointer<It> {};

template<class It> inline constexpr bool is_contiguous_iterator_v = is_contiguous_iterator<It>::value;

} // namespace scratch

Implement `is_contiguous_iterator_v<It>`, for metaprogramming purposes.

This trait is being proposed for standardization; see for example N4183.
You'd expect to see a `contiguous_iterator_tag` derived from
`random_access_iterator_tag` in "iterator-tags.h", but for some reason
the Committee hasn't been quick to adopt that idea.


#include <stdint.h>
#include "stm8s208s.h"

void main(void)
{
    MEMLOC(CLK_CKDIVR) = 0x00; /* Set the frequency to 16 MHz */
    BITSET(CLK_PCKENR1, 7); /* Enable clk to TIM1 */

    // Configure timer
    // 250 ticks per second
    MEMLOC(TIM1_PSCRH) = (64000>>8);
    MEMLOC(TIM1_PSCRL) = (uint8_t)(64000 & 0xff);

    MEMLOC(TIM1_CR1) = 0x01; /* Enable timer */

    BITSET(PB_DDR, 0); /* Set PB0 as output */
    BITRST(PB_CR2, 0); /* Set low speed mode */
    BITSET(PB_CR1, 0); /* Set Push/Pull mode */

    for(;;) {
        if ((MEMLOC(TIM1_CNTRL)) % 250 <= 125) {
            BITTOG(PB_ODR, 0);
        }
    }
}

#include <stdint.h>
#include "stm8s208s.h"

void main(void)
{
    MEMLOC(CLK_CKDIVR) = 0x00; /* Set the frequency to 16 MHz */
    BITSET(CLK_PCKENR1, 7); /* Enable clk to TIM1 */

    // Configure timer
    // 250 ticks per second
    MEMLOC(TIM1_PSCRH) = (64000>>8);
    MEMLOC(TIM1_PSCRL) = (uint8_t)(64000 & 0xff);

    MEMLOC(TIM1_CR1) = 0x01; /* Enable timer */

    BITSET(PB_DDR, 0); /* Set PB0 as output */
    BITRST(PB_CR2, 0); /* Set low speed mode */
    BITSET(PB_CR1, 0); /* Set Push/Pull mode */

    for(;;)
    {
        if ((MEMLOC(TIM1_CNTRL)) % 250 < 125) {
            BITRST(PB_ODR, 0);
        } else {
            BITSET(PB_ODR, 0);
        }
    }
}

Fix stupid led toggle bug

Fix stupid led toggle bug


//
//  TypedKey.h
//  TypedKey
//
//  Created by 전수열 on 1/28/16.
//  Copyright © 2016 Suyeol Jeon. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for TypedKey.
FOUNDATION_EXPORT double TypedKeyVersionNumber;

//! Project version string for TypedKey.
FOUNDATION_EXPORT const unsigned char TypedKeyVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <TypedKey/PublicHeader.h>

// The MIT License (MIT)
//
// Copyright (c) 2016 Suyeol Jeon (xoul.kr)
//
// 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.

#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) || defined(TARGET_OS_MAC)

@import Foundation;

FOUNDATION_EXPORT double TypedKeyVersionNumber;
FOUNDATION_EXPORT const unsigned char TypedKeyVersionString[];

#endif

Add platform check preprocessor conditions


/* Copyright (c) 2013-2015 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "dict-private.h"

void dict_drivers_register_builtin(void)
{
	dict_driver_register(&dict_driver_client);
	dict_driver_register(&dict_driver_file);
	dict_driver_register(&dict_driver_fs);
	dict_driver_register(&dict_driver_memcached);
	dict_driver_register(&dict_driver_memcached_ascii);
	dict_driver_register(&dict_driver_redis);
}

void dict_drivers_unregister_builtin(void)
{
	dict_driver_unregister(&dict_driver_client);
	dict_driver_unregister(&dict_driver_file);
	dict_driver_unregister(&dict_driver_fs);
	dict_driver_unregister(&dict_driver_memcached);
	dict_driver_unregister(&dict_driver_memcached_ascii);
	dict_driver_unregister(&dict_driver_redis);
}

/* Copyright (c) 2013-2015 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "dict-private.h"

static int refcount = 0;

void dict_drivers_register_builtin(void)
{
	if (refcount++ > 0)
		return;
	dict_driver_register(&dict_driver_client);
	dict_driver_register(&dict_driver_file);
	dict_driver_register(&dict_driver_fs);
	dict_driver_register(&dict_driver_memcached);
	dict_driver_register(&dict_driver_memcached_ascii);
	dict_driver_register(&dict_driver_redis);
}

void dict_drivers_unregister_builtin(void)
{
	if (--refcount > 0)
		return;
	dict_driver_unregister(&dict_driver_client);
	dict_driver_unregister(&dict_driver_file);
	dict_driver_unregister(&dict_driver_fs);
	dict_driver_unregister(&dict_driver_memcached);
	dict_driver_unregister(&dict_driver_memcached_ascii);
	dict_driver_unregister(&dict_driver_redis);
}

lib-dict: Allow registering builtin dict drivers multiple times.


/*
 * Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
 *
 * SPDX-License-Identifier: LGPL-2.1+
 */

#pragma once

#include "fwupd-client.h"

#ifdef HAVE_GIO_UNIX
#include <gio/gunixinputstream.h>
#endif

#ifdef HAVE_GIO_UNIX
void		 fwupd_client_get_details_stream_async	(FwupdClient	*self,
							 GUnixInputStream *istr,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);
void		 fwupd_client_install_stream_async	(FwupdClient	*self,
							 const gchar	*device_id,
							 GUnixInputStream *istr,
							 const gchar	*filename_hint,
							 FwupdInstallFlags install_flags,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);
void		 fwupd_client_update_metadata_stream_async(FwupdClient	*self,
							 const gchar	*remote_id,
							 GUnixInputStream *istr,
							 GUnixInputStream *istr_sig,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);
void		 fwupd_client_download_bytes2_async	(FwupdClient	*self,
							 GPtrArray	*urls,
							 FwupdClientDownloadFlags flags,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);
#endif

/*
 * Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
 *
 * SPDX-License-Identifier: LGPL-2.1+
 */

#pragma once

#include "fwupd-client.h"

#ifdef HAVE_GIO_UNIX
#include <gio/gunixinputstream.h>
#endif

void		 fwupd_client_download_bytes2_async	(FwupdClient	*self,
							 GPtrArray	*urls,
							 FwupdClientDownloadFlags flags,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);

#ifdef HAVE_GIO_UNIX
void		 fwupd_client_get_details_stream_async	(FwupdClient	*self,
							 GUnixInputStream *istr,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);
void		 fwupd_client_install_stream_async	(FwupdClient	*self,
							 const gchar	*device_id,
							 GUnixInputStream *istr,
							 const gchar	*filename_hint,
							 FwupdInstallFlags install_flags,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);
void		 fwupd_client_update_metadata_stream_async(FwupdClient	*self,
							 const gchar	*remote_id,
							 GUnixInputStream *istr,
							 GUnixInputStream *istr_sig,
							 GCancellable	*cancellable,
							 GAsyncReadyCallback callback,
							 gpointer	 callback_data);
#endif

Fix a warning when compiling on Windows

trivial: Fix a warning when compiling on Windows

Move the function prototype out of the GUnixInputStream-using ones.


#ifndef	APIMOCK_MIMETYPES_H
#define APIMOCK_MIMETYPES_H

#include <unordered_map>

namespace ApiMock {
	class Mime {

	public:
		std::string GetMimeByFileName(const std::string& filename) {
			static const std::unordered_map<std::string, std::string> MIME_TYPES{
					{ ".css", "text/css" },
					{ ".html", "text/html" },
					{ ".js", "application/javascript" },
					{ ".jpg", "image/jpeg" },
					{ ".jpeg", "image/jpeg" },
					{ ".png", "image/png" },
			};

			// TODO: Uh. Implement
			return "";
		}
	};
}

#endif

Add some simple mime types

Add some simple mime types

It doesn't really resolve the type right now, but eh..


#include "health.h"

static bool s_health_available;

static void health_handler(HealthEventType event, void *context) {
  main_window_update_ui();
}

void health_init() {
  s_health_available = health_service_events_subscribe(health_handler, NULL);
  if(!s_health_available) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Health not available!");
  }
}

bool health_is_available() {
  return s_health_available;
}

int health_get_metric_sum(HealthMetric metric) {
  return (int)health_service_sum_today(metric);
}

#include "health.h"

static bool s_health_available;

static void health_handler(HealthEventType event, void *context) {
  main_window_update_ui();
}

void health_init() {
  s_health_available = health_service_events_subscribe(health_handler, NULL);
  if(!s_health_available) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Health not available!");
  }
}

bool health_is_available() {
  return s_health_available;
}

int health_get_metric_sum(HealthMetric metric) {
  HealthServiceAccessibilityMask mask = health_service_metric_accessible(metric,
    time_start_of_today(), time(NULL));
  if(mask == HealthServiceAccessibilityMaskAvailable) {
    return (int)health_service_sum_today(metric);
  } else {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Data unavailable!");
    return 0;
  }
}

Add accessible check to sum read

Add accessible check to sum read


#ifndef __LLL_UNITTEST_H__
#define __LLL_UNITTEST_H__
/***********************************************************************
 * Low Latency Library: Test framwork
 *
 * Released under the MIT license. The LICENSE file should be included
 * in the top level of the source tree
 ***********************************************************************/
#include <cstdio>
#include <cassert>
namespace lll {
namespace unittest {

class UnitTest;

extern UnitTest *lll_unittest_list;

class UnitTest {
    const char *name_;
    void (*fcn_)(void);
    UnitTest *next_;
public:
    UnitTest(const char *name, void (*fcn)(void)) :
	name_(name),
	fcn_(fcn)
    {
	next_ = lll_unittest_list;
	lll_unittest_list = this;
    }

    void run(void) const {
	std::printf("Starting  testcase %s\n", name_);
	fcn_();
	std::printf("Completed testcase %s\n", name_);
    }

    UnitTest *next() { return next_; }
};

} // test
} // lll

#endif

Add missing unittest header file

Add missing unittest header file


/*
 * build-tests/__builtin_expect.c
 *
 * test if the compiler has __builtin_expect().
 */

int main(void) {
  return __builtin_expect(1, 1) ? 1 : 0;
}

Add missing test source file.

Add missing test source file.


#ifndef _HARDWARE_H_
#define _HARDWARE_H_

#include <stdint.h>

// For disk/drive status
#define HW_NODRIVE 0
#define HW_NODISK 1
#define HW_HAVEDISK 2

// Drive geometry
#define HW_MAXHEADS 2
#define HW_MAXTRACKS 80

#define HW_NORMALSTEPPING 1
#define HW_DOUBLESTEPPING 2

extern int hw_currenttrack;
extern int hw_currenthead;

extern int hw_stepping;

// Initialisation
extern int hw_init();

// Drive control
extern unsigned char hw_detectdisk();
extern void hw_driveselect();
extern void hw_startmotor();
extern void hw_stopmotor();

// Track seeking
extern int hw_attrackzero();
extern void hw_seektotrackzero();
extern void hw_sideselect(const int side);

// Signaling and data sampling
extern int hw_writeprotected();
extern void hw_samplerawtrackdata(char* buf, uint32_t len);

// Clean up
extern void hw_done();

#endif

#ifndef _HARDWARE_H_
#define _HARDWARE_H_

#include <stdint.h>

// For disk/drive status
#define HW_NODRIVE 0
#define HW_NODISK 1
#define HW_HAVEDISK 2

// Drive geometry
#define HW_MAXHEADS 2
#define HW_MAXTRACKS 80

#define HW_NORMALSTEPPING 1
#define HW_DOUBLESTEPPING 2

extern int hw_currenttrack;
extern int hw_currenthead;

extern int hw_stepping;

// Initialisation
extern int hw_init();

// Drive control
extern unsigned char hw_detectdisk();
extern void hw_driveselect();
extern void hw_startmotor();
extern void hw_stopmotor();

// Track seeking
extern int hw_attrackzero();
extern void hw_seektotrackzero();
extern void hw_seektotrack(int track);
extern void hw_sideselect(const int side);

// Signaling and data sampling
extern void hw_waitforindex();
extern int hw_writeprotected();
extern void hw_samplerawtrackdata(char* buf, uint32_t len);

// Clean up
extern void hw_done();

#endif

Add externs for the functions used

Add externs for the functions used


// PARAM: --enable ana.int.interval --disable ana.int.def_exc --disable ana.int.enums
#include <assert.h>
#include <stdio.h>

int main(){
    unsigned int i = 3;

    // 3 * 2^30 == 3221225472u is outside of the range that Intervall32 can represent
    // Therefore, when trying to refine i, Base.invariant meets i -> [3;3] with i -> [(-2^31) / 2^30; ((2^31)-1) / 2^30] = [-2; 1]
    // We thus get i -> Bottom, and the code after the condition is considered unreachable
    if(i *  1073741824u == 3221225472u){
        printf("%u\n", i);
        assert(i == 3); // SUCCESS
    }
    assert(i == 3); // SUCCESS
    return 0;
}

Add test case for multiplication in conditions with Interval32.


/* $Id$ */
/* Copyright (c) 2007 The DeforaOS Project */

#ifndef LIBC_STDARG_H
# define LIBC_STDARG_H

/* types */
# ifndef va_list
#  define va_list va_list
typedef void * va_list;
# endif

/* macros */
# if defined(__i386__)
#  define va_start(ap, arg) (ap) = ((char*)&arg) + 4
#  define va_arg(ap, type) ((ap) += sizeof(type), \
		*(type*)((void*)ap - sizeof(type)))
#  define va_end(ap)
# else /* !__i386__ */
#  warning Unsupported architecture
#  define va_start(ap, arg)
#  define va_arg(ap, type) (type)(ap)
#  define va_end(ap)
# endif

#endif /* !LIBC_STDARG_H */

/* $Id$ */
/* Copyright (c) 2007 The DeforaOS Project */

#ifndef LIBC_STDARG_H
# define LIBC_STDARG_H

/* types */
# ifndef va_list
#  define va_list va_list
typedef void * va_list;
# endif

/* macros */
# if defined(__i386__)
#  define va_start(ap, arg)	(ap) = ((char*)&arg) + 4
#  define va_arg(ap, type)	((ap) += sizeof(type), \
		*(type*)((void*)ap - sizeof(type)))
#  define va_end(ap)
# elif defined(__sparc64__)	/* XXX compiler dependent */
#  define va_start(ap, arg)	__builtin_va_start(ap, arg)
#  define va_arg(ap, type)	__builtin_va_arg(ap, type)
#  define va_end(ap)		__builtin_va_end(ap)
# else /* !__i386__ */
#  warning Unsupported architecture
#  define va_start(ap, arg)
#  define va_arg(ap, type) (type)(ap)
#  define va_end(ap)
# endif

#endif /* !LIBC_STDARG_H */

Use GCC's builtins to implement va_list on sparc64 for now


/**
 * @file
 *
 * @brief
 *
 * @date 16.05.2012
 * @author Anton Bondarev
 */
#include <types.h>

uint64_t __udivdi3(uint64_t num, uint64_t den) {
	uint64_t result = 0;
	int steps;
	int i;

	if (0 == den) {
		return 0;
	}
	while (0x8000000000000000 != (den & 0x8000000000000000)) {
		den <<= 1;
		steps++;
	}

	for (i = 0; i <= steps; i++) {
		result <<= 1;
		if (num >= den) {
			result += 1;
			num -= den;
		}
		den >>= 1;
	}
	return result;
}

/**
 * @file
 * @brief
 *
 * @date 16.05.2012
 * @author Anton Bondarev
 */

#include <types.h>

uint64_t __udivdi3(uint64_t num, uint64_t den) {
	uint64_t result = 0;
	int steps = 0;
	int i;

	if (0 == den) {
		return 0;
	}
	while (0x8000000000000000 != (den & 0x8000000000000000)) {
		den <<= 1;
		steps++;
	}

	for (i = 0; i <= steps; i++) {
		result <<= 1;
		if (num >= den) {
			result += 1;
			num -= den;
		}
		den >>= 1;
	}
	return result;
}

Fix build error (maybe-uninitialized variable)


#pragma once

#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

namespace dev
{
namespace eth
{
namespace jit
{

using byte = uint8_t;
using bytes = std::vector<byte>;
using u256 = boost::multiprecision::uint256_t;
using bigint = boost::multiprecision::cpp_int;

struct NoteChannel {};	// FIXME: Use some log library?

enum class ReturnCode
{
	Stop = 0,
	Return = 1,
	Suicide = 2,

	BadJumpDestination = 101,
	OutOfGas = 102,
	StackTooSmall = 103,
	BadInstruction = 104,

	LLVMConfigError = 201,
	LLVMCompileError = 202,
	LLVMLinkError = 203,
};

/// Representation of 256-bit value binary compatible with LLVM i256
// TODO: Replace with h256
struct i256
{
	uint64_t a;
	uint64_t b;
	uint64_t c;
	uint64_t d;
};
static_assert(sizeof(i256) == 32, "Wrong i265 size");

#define UNTESTED assert(false)

}
}
}

#pragma once

#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

namespace dev
{
namespace eth
{
namespace jit
{

using byte = uint8_t;
using bytes = std::vector<byte>;
using u256 = boost::multiprecision::uint256_t;
using bigint = boost::multiprecision::cpp_int;

struct NoteChannel {};	// FIXME: Use some log library?

enum class ReturnCode
{
	Stop = 0,
	Return = 1,
	Suicide = 2,

	BadJumpDestination = 101,
	OutOfGas = 102,
	StackTooSmall = 103,
	BadInstruction = 104,

	LLVMConfigError = 201,
	LLVMCompileError = 202,
	LLVMLinkError = 203,
};

/// Representation of 256-bit value binary compatible with LLVM i256
// TODO: Replace with h256
struct i256
{
	uint64_t a = 0;
	uint64_t b = 0;
	uint64_t c = 0;
	uint64_t d = 0;
};
static_assert(sizeof(i256) == 32, "Wrong i265 size");

#define UNTESTED assert(false)

}
}
}

Fix some GCC initialization warnings

Fix some GCC initialization warnings


/*
* krypt-core API - C version
*
* Copyright (C) 2011
* Hiroshi Nakamura <nahi@ruby-lang.org>
* Martin Bosslet <martin.bosslet@googlemail.com>
* All rights reserved.
*
* This software is distributed under the same license as Ruby.
* See the file 'LICENSE' for further details.
*/

#if !defined(_KRYPT_OS_H_)
#define _KRYPT_OS_H_

#ifdef WIN32
#define krypt_last_sys_error()	GetLastError()
#define krypt_clear_sys_error()	SetLastError(0)
#else
#define krypt_last_sys_error()	errno
#define krypt_clear_sys_error()	errno=0
#endif

#endif /* _KRYPT_OS_H_ */

/*
* krypt-core API - C version
*
* Copyright (C) 2011
* Hiroshi Nakamura <nahi@ruby-lang.org>
* Martin Bosslet <martin.bosslet@googlemail.com>
* All rights reserved.
*
* This software is distributed under the same license as Ruby.
* See the file 'LICENSE' for further details.
*/

#if !defined(_KRYPT_OS_H_)
#define _KRYPT_OS_H_

#ifdef _WIN32
#define krypt_last_sys_error()	GetLastError()
#define krypt_clear_sys_error()	SetLastError(0)
#else
#define krypt_last_sys_error()	errno
#define krypt_clear_sys_error()	errno=0
#endif

#endif /* _KRYPT_OS_H_ */

Use _WIN32 macro instead of WIN32

Use _WIN32 macro instead of WIN32

_WIN32 is the official macro described in MSDN:

http://msdn.microsoft.com/en-us/library/b0084kay.aspx

(under Microsoft-Specific Predefined Macros)


#ifndef __BOARDVALUE
#define __BOARDVALUE

#include "playerValue.h"

enum BoardPieceValue {Empty, O, X};

class BoardValue
{
  public:

  BoardValue(BoardPieceValue boardPieceValue)
  {
    set(boardPieceValue);
  }

  friend bool operator== (const BoardValue & left, const BoardValue & right)
  {
    return left.boardPieceValue == right.boardPieceValue && left.playerValue == right.playerValue;
  }

  friend bool operator!= (const BoardValue & left, const BoardValue & right)
  {
    return left.boardPieceValue != right.boardPieceValue || left.playerValue != right.playerValue;
  }

  void set(BoardPieceValue boardPieceValue)
  {
    this->boardPieceValue = boardPieceValue;
    if (boardPieceValue == BoardPieceValue::O)
    {
      this->playerValueSet = true;
      this->playerValue = PlayerValue::PlayerOne;
    }
    else if (boardPieceValue == BoardPieceValue::X) this->playerValue = PlayerValue::PlayerTwo;
  }

  bool isEmpty()
  {
    return this->boardPieceValue == BoardPieceValue::Empty;
  }

  bool isPlayerBoardValue(const PlayerValue & playerValue)
  {
    return this->playerValue == playerValue;
  }

  private:

  bool boardPieceValueSet = false, playerValueSet = false;

  BoardPieceValue boardPieceValue;
  PlayerValue playerValue;
}

#endif

#ifndef __BOARDVALUE
#define __BOARDVALUE

enum BoardValue {Empty, O, X};

#endif

Revert "Started work to board value class"

This reverts commit ee19a31e31a15b020acce6e0200489a144858427.


// Based on https://github.com/nanopb/nanopb/blob/master/examples/simple/simple.c
#include <stdio.h>

#include "m-serial-json.h"
#include "m-tuple.h"
#include "m-string.h"

// Define a structure with one field
TUPLE_DEF2(SimpleMessage,
           (lucky_number, int))

int main(void)
{
  string_t buffer;
  m_serial_return_code_t status;

  string_init(buffer);
  /* Encode our message */
  {
    SimpleMessage_t message;
    SimpleMessage_init(message);

    /* Create a stream that will write to our buffer. */
    m_serial_str_json_write_t stream;
    m_serial_str_json_write_init(stream, buffer);

    /* Fill in the lucky number */
    message->lucky_number = 13;

    /* Now we are ready to encode the message! */
    status = SimpleMessage_out_serial(stream, message);

    /* Then just check for any errors.. */
    if (status != M_SERIAL_OK_DONE)
      {
        printf("Encoding failed: %d\n", status);
        return 1;
      }

    /* Clear the objets */
    m_serial_str_json_write_clear(stream);
    SimpleMessage_clear(message);
  }

  /* Now we could transmit the message over network, store it in a file
   * but we are doing it right now.
   */

  {
    /* Allocate another space for the decoded message. */
    SimpleMessage_t message;
    SimpleMessage_init(message);

    /* Create a stream that reads from the buffer. */
    m_serial_str_json_read_t stream;
    m_serial_str_json_read_init(stream, string_get_cstr(buffer));

    /* Now we are ready to decode the message. */
    status = SimpleMessage_in_serial(message, stream);

    /* Check for errors... */
    if (status != M_SERIAL_OK_DONE)
      {
        printf("Decoding failed: %d\n", status);
        return 1;
      }

    /* Print the data contained in the message. */
    printf("Your lucky number was %d!\n", message->lucky_number);

    /* Clear the objets */
    m_serial_str_json_read_clear(stream);
    SimpleMessage_clear(message);
  }

  string_clear(buffer);

  return 0;
}

Add example of JSON serialization on string


numbers: Add a .c file to test syntax highlighting on


//
//  PKMacros.h
//  PKToolBox
//
//  Created by Pavel Kunc on 17/07/2013.
//  Copyright (c) 2013 PKToolBox. All rights reserved.
//

#define PK_NIL_IF_NULL(obj) ((obj == [NSNull null]) ? nil : obj)
#define PK_NULL_IF_NIL(obj) ((obj == nil) ? [NSNull null] : obj)

#define PK_BOOL_TO_LOCALIZED_STRING(val) ((val == YES) ? NSLocalizedString(@"Yes", nil) : NSLocalizedString(@"No", nil))

#define PK_IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define PK_IS_IPHONE ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone )
#define PK_IS_IPHONE_5 ( PK_IS_IPHONE && PK_IS_WIDESCREEN )

#define PK_IS_IOS7 ( floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1 )

Add new macro to detect iOS7.

Add new macro to detect iOS7.


#include <stdlib.h>
#include "sphia-test.h"

#define EXPECTED_TEST_KEYS 1234

static void
test_count() {
  for (int i = 0; i < EXPECTED_TEST_KEYS; i++) {
    char *key = malloc(16);
    if (NULL == key) {
      fprintf(stderr, "Malloc error\n");
      exit(1);
    }
    sprintf(key, "key%03d", i);
    assert(0 == sphia_set(sphia, key, "hello world"));
    free(key);
  }
  assert(EXPECTED_TEST_KEYS == sphia_count(sphia));
}

TEST(test_count);

Add a simple test for sphia_count

Add a simple test for sphia_count

Just sets a significantly large number of key/value paris, then
counts them.


//PARAM: --enable ana.int.interval --disable ana.int.def_exc --disable ana.int.enums --set ana.octapron.no_signed_overflow false
#include <assert.h>

int main(){
    int a = 0;

    // maximum value for ulonglong
    unsigned long long x = 18446744073709551615ull;
    if(x > 18446744073709551612ull){
        a = 1;
    }
    // The following line should succeed, but is unknown for now
    assert(a); // UNKNOWN

    unsigned long long y = x + 4;
    // Unsigned overflow -- The following assertion should succeed, but is unknown for now
    assert(y == 3); // UNKNOWN

    // maximum value for long long
    signed long long s = 9223372036854775807;
    assert(s > 9223372036854775806);

    signed long long t = s + 2;
    // Signed overflow -- The following assertion must be UNKNOWN!
    assert(t == -9223372036854775807); // UNKNOWN!

    return 0;
}

//PARAM: --enable ana.int.interval --disable ana.int.def_exc --disable ana.int.enums --set ana.octapron.no_signed_overflow false
#include <assert.h>

int main(){
    int a = 0;

    // maximum value for ulonglong
    unsigned long long x = 18446744073709551615ull;
    if(x > 18446744073709551612ull){
        a = 1;
    }
    assert(a);

    unsigned long long y = x + 4;
    // Unsigned overflow -- The following assertion should succeed, but is unknown for now
    assert(y == 3); // UNKNOWN

    // maximum value for long long
    signed long long s = 9223372036854775807;
    assert(s > 9223372036854775806);

    signed long long t = s + 2;
    // Signed overflow -- The following assertion must be UNKNOWN!
    assert(t == -9223372036854775807); // UNKNOWN!

    return 0;
}

Remove unknown from completed assert in 31/13


// PARAM: --disable ana.int.def_exc --enable ana.int.interval --enable ana.int.congruence
#include <assert.h>

int main(){
    int r = -103;
    for (int i = 0; i < 40; i++) {
        r = r + 5;
    }
    // At this point r in the congr. dom should be 2 + 5Z
    int k = r;
    if (k >= 3) {
        // After refinement with congruences, the lower bound should be 7 as the numbers 3 - 6 are not in the congr. class
        assert (k < 7); // FAIL
    }

    if (r >= -11 && r <= -4) {
        assert (r == -8);
    }
    return 0;
}

Add (deactivated) refinement test for interval/congruence domain


#include <isl29035.h>
#include <stdio.h>
#include <stdbool.h>
#include <timer.h>
#include <tmp006.h>

void print_intensity(int intensity) {
  printf("Intensity: %d\n", intensity);
}

void intensity_cb(int intensity, int unused1, int unused2, void* ud) {
  print_intensity(intensity);
}

void temp_callback(int temp_value, int err, int unused, void* ud) {
  printf("Current Temp (%d) [0x%X]\n", temp_value, err);
}

void timer_fired(int arg0, int arg1, int arg2, void* ud) {
  isl29035_start_intensity_reading();
}

int main() {
  printf("Hello\n");

  isl29035_subscribe(intensity_cb, NULL);
  // Setup periodic timer
  timer_subscribe(timer_fired, NULL);
  timer_start_repeating(1000);

  tmp006_start_sampling(0x2, temp_callback, NULL);

  return 0;
}

#include <isl29035.h>
#include <stdio.h>
#include <stdbool.h>
#include <timer.h>
#include <tmp006.h>

void print_intensity(int intensity) {
  printf("Intensity: %d\n", intensity);
}

void intensity_cb(int intensity, int unused1, int unused2, void* ud) {
  print_intensity(intensity);
}

void temp_callback(int temp_value, int err, int unused, void* ud) {
  printf("Current Temp (%d) [0x%X]\n", temp_value, err);
}

void timer_fired(int arg0, int arg1, int arg2, void* ud) {
  isl29035_start_intensity_reading();
}

int main() {
  printf("Hello\n");

  isl29035_subscribe(intensity_cb, NULL);
  // Setup periodic timer
  timer_subscribe(timer_fired, NULL);
  timer_start_repeating(1000);

  //tmp006_start_sampling(0x2, temp_callback, NULL);

  return 0;
}

Add isl29035 to Imix board

Add isl29035 to Imix board


#ifndef MYSQL2_EXT
#define MYSQL2_EXT

#include <ruby.h>
#include <fcntl.h>

#ifdef HAVE_MYSQL_H
#include <mysql.h>
#include <mysql_com.h>
#include <errmsg.h>
#include <mysqld_error.h>
#else
#include <mysql/mysql.h>
#include <mysql/mysql_com.h>
#include <mysql/errmsg.h>
#include <mysql/mysqld_error.h>
#endif

#ifdef HAVE_RUBY_ENCODING_H
#include <ruby/encoding.h>
#endif

#if defined(__GNUC__) && (__GNUC__ >= 3)
#define RB_MYSQL_UNUSED __attribute__ ((unused))
#else
#define RB_MYSQL_UNUSED
#endif

#include <client.h>
#include <result.h>

#endif

#ifndef MYSQL2_EXT
#define MYSQL2_EXT

#include <ruby.h>
#include <fcntl.h>

#ifndef HAVE_UINT
#define HAVE_UINT
typedef unsigned short    ushort;
typedef unsigned int    uint;
#endif

#ifdef HAVE_MYSQL_H
#include <mysql.h>
#include <mysql_com.h>
#include <errmsg.h>
#include <mysqld_error.h>
#else
#include <mysql/mysql.h>
#include <mysql/mysql_com.h>
#include <mysql/errmsg.h>
#include <mysql/mysqld_error.h>
#endif

#ifdef HAVE_RUBY_ENCODING_H
#include <ruby/encoding.h>
#endif

#if defined(__GNUC__) && (__GNUC__ >= 3)
#define RB_MYSQL_UNUSED __attribute__ ((unused))
#else
#define RB_MYSQL_UNUSED
#endif

#include <client.h>
#include <result.h>

#endif

Fix to install with MariDB on Windows

Fix to install with MariDB on Windows