hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588 values | lang stringclasses 305 values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2b00b94fb3ea1cd491cfad86d36a83aa1c640ffb | 605 | h | C | AZ3166/src/cores/arduino/system/SystemWiFi.h | duglah/devkit-sdk | 7f016a1b00a25d6133009028c67b75e54495cf93 | [
"MIT"
] | 34 | 2019-05-08T07:36:51.000Z | 2021-11-11T19:40:39.000Z | AZ3166/src/cores/arduino/system/SystemWiFi.h | duglah/devkit-sdk | 7f016a1b00a25d6133009028c67b75e54495cf93 | [
"MIT"
] | 127 | 2018-01-04T10:24:22.000Z | 2019-04-19T15:18:58.000Z | AZ3166/src/cores/arduino/system/SystemWiFi.h | duglah/devkit-sdk | 7f016a1b00a25d6133009028c67b75e54495cf93 | [
"MIT"
] | 30 | 2018-01-15T03:40:57.000Z | 2019-04-18T19:58:19.000Z | // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
#ifndef __SYSTEM_WIFI_H__
#define __SYSTEM_WIFI_H__
#include "mbed.h"
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
bool InitSystemWiFi(void);
bool SystemWiFiConnect(void);
int SystemWiFiRSSI(void);
const char* SystemWiFiSSID(void);
NetworkInterface* WiFiInterface(void);
bool SystemWiFiAPStart(const char *ssid, const char *passphrase);
NetworkInterface* WiFiAPInterface(void);
int WiFiScan(WiFiAccessPoint *res, unsigned count);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __SYSTEM_WIFI_H__
| 20.862069 | 65 | 0.778512 |
9e91941575e6437cefdaf8754c137045d8ad547d | 2,527 | h | C | enhanced/archive/classlib/java6/modules/awt/src/main/native/winfont/windows/winFont.h | qinFamily/freeVM | 9caa0256b4089d74186f84b8fb2afc95a0afc7bc | [
"Apache-2.0"
] | 5 | 2017-03-08T20:32:39.000Z | 2021-07-10T10:12:38.000Z | enhanced/archive/classlib/java6/modules/awt/src/main/native/winfont/windows/winFont.h | qinFamily/freeVM | 9caa0256b4089d74186f84b8fb2afc95a0afc7bc | [
"Apache-2.0"
] | null | null | null | enhanced/archive/classlib/java6/modules/awt/src/main/native/winfont/windows/winFont.h | qinFamily/freeVM | 9caa0256b4089d74186f84b8fb2afc95a0afc7bc | [
"Apache-2.0"
] | 4 | 2015-07-07T07:06:59.000Z | 2018-06-19T22:38:04.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Ilya S. Okomin
* @version $Revision$
*
*/
#ifndef _Included_winFont
#define _Included_winFont
#include <jni.h>
#include <Windows.h>
#include <GdiPlus.h>
#include "gl_GDIPlus.h"
using namespace Gdiplus;
#define FONTLIB_ERROR 0 /* error code */
#define FONTLIB_SUCCESS 1 /* success code */
#define FONT_PLAIN 0 /* The plain style constant. */
#define FONT_BOLD 1 /* The bold style constant. */
#define FONT_ITALIC 2 /* The italicized style constant. */
#define FONT_STR_BOLD "bold" /* The bold style string constant. */
#define FONT_STR_ITALIC "italic" /* The italicized style string constant. */
#define FONT_TYPE_TT 4 /* TrueType */
#define FONT_TYPE_T1 2 /* Type1 */
#define FONT_TYPE_UNDEF 0 /* Undefined type */
typedef char Tag[4]; /* Array of four bytes */
// Font names structure for EnumFontFamEx
typedef struct
{
int *indices; /* Array of font families indices in families array.*/
int *types; /* Type of font */
int *styles; /* Style of font */
TCHAR **faceNames; /* Face name of the font */
int size; /* Size of the array. */
int count; /* The Number of elements in the array. */
} FontRecords;
typedef struct
{
TCHAR names[256][10]; /* Locale name. */
short lcids[256]; /* LCID value. */
int count;
} LCIDS;
#endif // _Included_winFont
| 37.716418 | 86 | 0.593985 |
9eab3039ad2e5397565fa2594457e8e63a166430 | 3,188 | c | C | ALSNP_3rd/src/6.io_interface/sockopt/tcp_cli_reuseaddr.c | nosy0411/Advanced_Linux_System_Network_Programming_for_Finance | d4596adeaa2692584b5011e55f01d6b6a8f24269 | [
"MIT"
] | null | null | null | ALSNP_3rd/src/6.io_interface/sockopt/tcp_cli_reuseaddr.c | nosy0411/Advanced_Linux_System_Network_Programming_for_Finance | d4596adeaa2692584b5011e55f01d6b6a8f24269 | [
"MIT"
] | 3 | 2020-09-04T16:54:13.000Z | 2021-06-02T02:56:55.000Z | ALSNP_3rd/src/6.io_interface/sockopt/tcp_cli_reuseaddr.c | nosy0411/ALSNP_for_Finance | d4596adeaa2692584b5011e55f01d6b6a8f24269 | [
"MIT"
] | null | null | null | /* vim: set ts=4 sw=4: */
/* Filename : tcp_cli_reuseaddr.c
* Description : SO_REUSEADDR on client side
* Author : SunYoung Kim <sunyzero@gmail.com>
* Notes :
* Rel. : 3rd Ed.
*/
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
int fd, rc_gai, flag_once = 0;
struct addrinfo ai_dest, *ai_dest_ret;
if (argc != 4) {
printf("%s <hostname> <port> <0(SO_REUSEADDR off) | 1(SO_REUSEADDR on)>\n", argv[0]);
exit(EXIT_FAILURE);
}
struct sockaddr_storage sae_local;
socklen_t len_sae_local = sizeof(sae_local);
char addrstr[INET6_ADDRSTRLEN], portstr[8];
for (int i=0; ;i++ ) {
memset(&ai_dest, 0, sizeof(ai_dest));
ai_dest.ai_family = AF_UNSPEC;
ai_dest.ai_socktype = SOCK_STREAM;
ai_dest.ai_flags = AI_ADDRCONFIG;
if ((rc_gai = getaddrinfo(argv[1], argv[2], &ai_dest, &ai_dest_ret)) != 0) {
fprintf(stderr, "FAIL: getaddrinfo():%s", gai_strerror(rc_gai));
exit(EXIT_FAILURE);
}
if ((fd = socket(ai_dest_ret->ai_family,
ai_dest_ret->ai_socktype,
ai_dest_ret->ai_protocol)) == -1) {
perror("[Client] : FAIL: socket()");
exit(EXIT_FAILURE);
}
if (argv[3][0] != '0') {
int sockopt = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(sockopt)) == -1) {
exit(EXIT_FAILURE);
}
printf("Socket option = SO_REUSEADDR(on)\n");
} else {
printf("Socket option = SO_REUSEADDR(off)\n");
}
if (flag_once) {
/* explicit binding to the previous address */
if (bind(fd, (struct sockaddr *)&sae_local, len_sae_local) == -1) {
perror("FAIL: bind()");
exit(EXIT_FAILURE);
}
}
if (connect(fd, ai_dest_ret->ai_addr, ai_dest_ret->ai_addrlen) == -1) {
perror("FAIL: connect()");
exit(EXIT_FAILURE);
}
/* if first connection */
if (flag_once == 0) {
if (getsockname(fd, (struct sockaddr *)&sae_local, &len_sae_local) == -1) {
perror("FAIL: getpeername()");
exit(EXIT_FAILURE);
}
if ((rc_gai = getnameinfo((struct sockaddr *)&sae_local, len_sae_local,
addrstr, sizeof(addrstr), portstr, sizeof(portstr),
NI_NUMERICHOST|NI_NUMERICSERV))) {
perror("FAIL: getnameinfo()");
exit(EXIT_FAILURE);
}
}
flag_once = 1;
printf("Connection established\n");
printf("\tLocal(%s:%s) => Destination(%s:%s)\n", addrstr, portstr, argv[1], argv[2]);
printf(">> Press any key to disconnect.");
getchar();
close(fd);
printf(">> Press any key to reconnect.");
getchar();
}
return 0;
}
| 32.20202 | 93 | 0.536073 |
fa06ca847196e2523335db9710e54f6052509e07 | 3,292 | h | C | MakefileBasedBuild/Atmel/sam3x/sam3x-ek/libraries/usb_device/memory/virtual_mem/virtual_mem.h | bhargavkumar040/android-source-browsing.device--google--accessory--adk2012-demo | d1d4908ee7e35973b3215eb04ddcea2022ceebc1 | [
"Apache-2.0"
] | null | null | null | MakefileBasedBuild/Atmel/sam3x/sam3x-ek/libraries/usb_device/memory/virtual_mem/virtual_mem.h | bhargavkumar040/android-source-browsing.device--google--accessory--adk2012-demo | d1d4908ee7e35973b3215eb04ddcea2022ceebc1 | [
"Apache-2.0"
] | null | null | null | MakefileBasedBuild/Atmel/sam3x/sam3x-ek/libraries/usb_device/memory/virtual_mem/virtual_mem.h | bhargavkumar040/android-source-browsing.device--google--accessory--adk2012-demo | d1d4908ee7e35973b3215eb04ddcea2022ceebc1 | [
"Apache-2.0"
] | null | null | null | /*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file ******************************************************************
*
* \brief Management of the virtual memory.
*
* This file manages the virtual memory.
*
* - Compiler: IAR EWAVR32 and GNU GCC for AVR32
* - Supported devices: All AVR32 devices with a USB module can be used.
* - AppNote:
*
* \author Atmel Corporation: http://www.atmel.com \n
* Support and FAQ: http://support.atmel.no/
*
***************************************************************************/
/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an Atmel
* AVR product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*
*/
#ifndef _VIRTUAL_MEM_H_
#define _VIRTUAL_MEM_H_
#include "conf_access.h"
#if VIRTUAL_MEM == ENABLE
#include "ctrl_access.h"
#ifdef __cplusplus
extern "C" {
#endif
//_____ D E F I N I T I O N S ______________________________________________
#define VMEM_SECTOR_SIZE 512
//---- CONTROL FUNCTIONS ----
extern Ctrl_status virtual_test_unit_ready(void);
extern Ctrl_status virtual_read_capacity(U32 *u32_nb_sector);
extern Bool virtual_wr_protect(void);
extern Bool virtual_removal(void);
//---- ACCESS DATA FUNCTIONS ----
// USB interface
#if ACCESS_USB == ENABLED
extern Ctrl_status virtual_usb_read_10 (U32 addr, U16 nb_sector);
extern Ctrl_status virtual_usb_write_10(U32 addr, U16 nb_sector);
#endif
// RAM interface
#if ACCESS_MEM_TO_RAM == ENABLED
extern Ctrl_status virtual_mem_2_ram(U32 addr, void *ram);
extern Ctrl_status virtual_ram_2_mem(U32 addr, const void *ram);
#endif
#ifdef __cplusplus
}
#endif
#endif
#endif // _VIRTUAL_MEM_H_
| 34.291667 | 83 | 0.688943 |
fa2d4a1bae203a0ed5d3dd2f38b972c03f40d7d1 | 20,824 | c | C | src/map/lapack2flamec/f2c/c/dtrsen.c | haampie/libflame | a6b27af9b7ef91ec2724b52c7c09b681379a3470 | [
"BSD-3-Clause"
] | 199 | 2015-02-06T06:05:32.000Z | 2022-03-18T05:20:33.000Z | src/map/lapack2flamec/f2c/c/dtrsen.c | haampie/libflame | a6b27af9b7ef91ec2724b52c7c09b681379a3470 | [
"BSD-3-Clause"
] | 44 | 2015-05-10T18:14:52.000Z | 2022-02-22T08:22:10.000Z | src/map/lapack2flamec/f2c/c/dtrsen.c | haampie/libflame | a6b27af9b7ef91ec2724b52c7c09b681379a3470 | [
"BSD-3-Clause"
] | 70 | 2015-02-07T04:53:03.000Z | 2022-03-18T05:20:36.000Z | /* ../netlib/dtrsen.f -- translated by f2c (version 20100827). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */
#include "FLA_f2c.h" /* Table of constant values */
static integer c_n1 = -1;
/* > \brief \b DTRSEN */
/* =========== DOCUMENTATION =========== */
/* Online html documentation available at */
/* http://www.netlib.org/lapack/explore-html/ */
/* > \htmlonly */
/* > Download DTRSEN + dependencies */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtrsen. f"> */
/* > [TGZ]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtrsen. f"> */
/* > [ZIP]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtrsen. f"> */
/* > [TXT]</a> */
/* > \endhtmlonly */
/* Definition: */
/* =========== */
/* SUBROUTINE DTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, WR, WI, */
/* M, S, SEP, WORK, LWORK, IWORK, LIWORK, INFO ) */
/* .. Scalar Arguments .. */
/* CHARACTER COMPQ, JOB */
/* INTEGER INFO, LDQ, LDT, LIWORK, LWORK, M, N */
/* DOUBLE PRECISION S, SEP */
/* .. */
/* .. Array Arguments .. */
/* LOGICAL SELECT( * ) */
/* INTEGER IWORK( * ) */
/* DOUBLE PRECISION Q( LDQ, * ), T( LDT, * ), WI( * ), WORK( * ), */
/* $ WR( * ) */
/* .. */
/* > \par Purpose: */
/* ============= */
/* > */
/* > \verbatim */
/* > */
/* > DTRSEN reorders the real Schur factorization of a real matrix */
/* > A = Q*T*Q**T, so that a selected cluster of eigenvalues appears in */
/* > the leading diagonal blocks of the upper quasi-triangular matrix T, */
/* > and the leading columns of Q form an orthonormal basis of the */
/* > corresponding right invariant subspace. */
/* > */
/* > Optionally the routine computes the reciprocal condition numbers of */
/* > the cluster of eigenvalues and/or the invariant subspace. */
/* > */
/* > T must be in Schur canonical form (as returned by DHSEQR), that is, */
/* > block upper triangular with 1-by-1 and 2-by-2 diagonal blocks;
each */
/* > 2-by-2 diagonal block has its diagonal elements equal and its */
/* > off-diagonal elements of opposite sign. */
/* > \endverbatim */
/* Arguments: */
/* ========== */
/* > \param[in] JOB */
/* > \verbatim */
/* > JOB is CHARACTER*1 */
/* > Specifies whether condition numbers are required for the */
/* > cluster of eigenvalues (S) or the invariant subspace (SEP): */
/* > = 'N': none;
*/
/* > = 'E': for eigenvalues only (S);
*/
/* > = 'V': for invariant subspace only (SEP);
*/
/* > = 'B': for both eigenvalues and invariant subspace (S and */
/* > SEP). */
/* > \endverbatim */
/* > */
/* > \param[in] COMPQ */
/* > \verbatim */
/* > COMPQ is CHARACTER*1 */
/* > = 'V': update the matrix Q of Schur vectors;
*/
/* > = 'N': do not update Q. */
/* > \endverbatim */
/* > */
/* > \param[in] SELECT */
/* > \verbatim */
/* > SELECT is LOGICAL array, dimension (N) */
/* > SELECT specifies the eigenvalues in the selected cluster. To */
/* > select a real eigenvalue w(j), SELECT(j) must be set to */
/* > .TRUE.. To select a complex conjugate pair of eigenvalues */
/* > w(j) and w(j+1), corresponding to a 2-by-2 diagonal block, */
/* > either SELECT(j) or SELECT(j+1) or both must be set to */
/* > .TRUE.;
a complex conjugate pair of eigenvalues must be */
/* > either both included in the cluster or both excluded. */
/* > \endverbatim */
/* > */
/* > \param[in] N */
/* > \verbatim */
/* > N is INTEGER */
/* > The order of the matrix T. N >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in,out] T */
/* > \verbatim */
/* > T is DOUBLE PRECISION array, dimension (LDT,N) */
/* > On entry, the upper quasi-triangular matrix T, in Schur */
/* > canonical form. */
/* > On exit, T is overwritten by the reordered matrix T, again in */
/* > Schur canonical form, with the selected eigenvalues in the */
/* > leading diagonal blocks. */
/* > \endverbatim */
/* > */
/* > \param[in] LDT */
/* > \verbatim */
/* > LDT is INTEGER */
/* > The leading dimension of the array T. LDT >= max(1,N). */
/* > \endverbatim */
/* > */
/* > \param[in,out] Q */
/* > \verbatim */
/* > Q is DOUBLE PRECISION array, dimension (LDQ,N) */
/* > On entry, if COMPQ = 'V', the matrix Q of Schur vectors. */
/* > On exit, if COMPQ = 'V', Q has been postmultiplied by the */
/* > orthogonal transformation matrix which reorders T;
the */
/* > leading M columns of Q form an orthonormal basis for the */
/* > specified invariant subspace. */
/* > If COMPQ = 'N', Q is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[in] LDQ */
/* > \verbatim */
/* > LDQ is INTEGER */
/* > The leading dimension of the array Q. */
/* > LDQ >= 1;
and if COMPQ = 'V', LDQ >= N. */
/* > \endverbatim */
/* > */
/* > \param[out] WR */
/* > \verbatim */
/* > WR is DOUBLE PRECISION array, dimension (N) */
/* > \endverbatim */
/* > \param[out] WI */
/* > \verbatim */
/* > WI is DOUBLE PRECISION array, dimension (N) */
/* > */
/* > The real and imaginary parts, respectively, of the reordered */
/* > eigenvalues of T. The eigenvalues are stored in the same */
/* > order as on the diagonal of T, with WR(i) = T(i,i) and, if */
/* > T(i:i+1,i:i+1) is a 2-by-2 diagonal block, WI(i) > 0 and */
/* > WI(i+1) = -WI(i). Note that if a complex eigenvalue is */
/* > sufficiently ill-conditioned, then its value may differ */
/* > significantly from its value before reordering. */
/* > \endverbatim */
/* > */
/* > \param[out] M */
/* > \verbatim */
/* > M is INTEGER */
/* > The dimension of the specified invariant subspace. */
/* > 0 < = M <= N. */
/* > \endverbatim */
/* > */
/* > \param[out] S */
/* > \verbatim */
/* > S is DOUBLE PRECISION */
/* > If JOB = 'E' or 'B', S is a lower bound on the reciprocal */
/* > condition number for the selected cluster of eigenvalues. */
/* > S cannot underestimate the true reciprocal condition number */
/* > by more than a factor of sqrt(N). If M = 0 or N, S = 1. */
/* > If JOB = 'N' or 'V', S is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[out] SEP */
/* > \verbatim */
/* > SEP is DOUBLE PRECISION */
/* > If JOB = 'V' or 'B', SEP is the estimated reciprocal */
/* > condition number of the specified invariant subspace. If */
/* > M = 0 or N, SEP = norm(T). */
/* > If JOB = 'N' or 'E', SEP is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[out] WORK */
/* > \verbatim */
/* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
/* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
/* > \endverbatim */
/* > */
/* > \param[in] LWORK */
/* > \verbatim */
/* > LWORK is INTEGER */
/* > The dimension of the array WORK. */
/* > If JOB = 'N', LWORK >= max(1,N);
*/
/* > if JOB = 'E', LWORK >= max(1,M*(N-M));
*/
/* > if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)). */
/* > */
/* > If LWORK = -1, then a workspace query is assumed;
the routine */
/* > only calculates the optimal size of the WORK array, returns */
/* > this value as the first entry of the WORK array, and no error */
/* > message related to LWORK is issued by XERBLA. */
/* > \endverbatim */
/* > */
/* > \param[out] IWORK */
/* > \verbatim */
/* > IWORK is INTEGER array, dimension (MAX(1,LIWORK)) */
/* > On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. */
/* > \endverbatim */
/* > */
/* > \param[in] LIWORK */
/* > \verbatim */
/* > LIWORK is INTEGER */
/* > The dimension of the array IWORK. */
/* > If JOB = 'N' or 'E', LIWORK >= 1;
*/
/* > if JOB = 'V' or 'B', LIWORK >= max(1,M*(N-M)). */
/* > */
/* > If LIWORK = -1, then a workspace query is assumed;
the */
/* > routine only calculates the optimal size of the IWORK array, */
/* > returns this value as the first entry of the IWORK array, and */
/* > no error message related to LIWORK is issued by XERBLA. */
/* > \endverbatim */
/* > */
/* > \param[out] INFO */
/* > \verbatim */
/* > INFO is INTEGER */
/* > = 0: successful exit */
/* > < 0: if INFO = -i, the i-th argument had an illegal value */
/* > = 1: reordering of T failed because some eigenvalues are too */
/* > close to separate (the problem is very ill-conditioned);
*/
/* > T may have been partially reordered, and WR and WI */
/* > contain the eigenvalues in the same order as in T;
S and */
/* > SEP (if requested) are set to zero. */
/* > \endverbatim */
/* Authors: */
/* ======== */
/* > \author Univ. of Tennessee */
/* > \author Univ. of California Berkeley */
/* > \author Univ. of Colorado Denver */
/* > \author NAG Ltd. */
/* > \date April 2012 */
/* > \ingroup doubleOTHERcomputational */
/* > \par Further Details: */
/* ===================== */
/* > */
/* > \verbatim */
/* > */
/* > DTRSEN first collects the selected eigenvalues by computing an */
/* > orthogonal transformation Z to move them to the top left corner of T. */
/* > In other words, the selected eigenvalues are the eigenvalues of T11 */
/* > in: */
/* > */
/* > Z**T * T * Z = ( T11 T12 ) n1 */
/* > ( 0 T22 ) n2 */
/* > n1 n2 */
/* > */
/* > where N = n1+n2 and Z**T means the transpose of Z. The first n1 columns */
/* > of Z span the specified invariant subspace of T. */
/* > */
/* > If T has been obtained from the real Schur factorization of a matrix */
/* > A = Q*T*Q**T, then the reordered real Schur factorization of A is given */
/* > by A = (Q*Z)*(Z**T*T*Z)*(Q*Z)**T, and the first n1 columns of Q*Z span */
/* > the corresponding invariant subspace of A. */
/* > */
/* > The reciprocal condition number of the average of the eigenvalues of */
/* > T11 may be returned in S. S lies between 0 (very badly conditioned) */
/* > and 1 (very well conditioned). It is computed as follows. First we */
/* > compute R so that */
/* > */
/* > P = ( I R ) n1 */
/* > ( 0 0 ) n2 */
/* > n1 n2 */
/* > */
/* > is the projector on the invariant subspace associated with T11. */
/* > R is the solution of the Sylvester equation: */
/* > */
/* > T11*R - R*T22 = T12. */
/* > */
/* > Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote */
/* > the two-norm of M. Then S is computed as the lower bound */
/* > */
/* > (1 + F-norm(R)**2)**(-1/2) */
/* > */
/* > on the reciprocal of 2-norm(P), the true reciprocal condition number. */
/* > S cannot underestimate 1 / 2-norm(P) by more than a factor of */
/* > sqrt(N). */
/* > */
/* > An approximate error bound for the computed average of the */
/* > eigenvalues of T11 is */
/* > */
/* > EPS * norm(T) / S */
/* > */
/* > where EPS is the machine precision. */
/* > */
/* > The reciprocal condition number of the right invariant subspace */
/* > spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP. */
/* > SEP is defined as the separation of T11 and T22: */
/* > */
/* > sep( T11, T22 ) = sigma-min( C ) */
/* > */
/* > where sigma-min(C) is the smallest singular value of the */
/* > n1*n2-by-n1*n2 matrix */
/* > */
/* > C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) ) */
/* > */
/* > I(m) is an m by m identity matrix, and kprod denotes the Kronecker */
/* > product. We estimate sigma-min(C) by the reciprocal of an estimate of */
/* > the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C) */
/* > cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2). */
/* > */
/* > When SEP is small, small changes in T can cause large changes in */
/* > the invariant subspace. An approximate bound on the maximum angular */
/* > error in the computed right invariant subspace is */
/* > */
/* > EPS * norm(T) / SEP */
/* > \endverbatim */
/* > */
/* ===================================================================== */
/* Subroutine */
int dtrsen_(char *job, char *compq, logical *select, integer *n, doublereal *t, integer *ldt, doublereal *q, integer *ldq, doublereal *wr, doublereal *wi, integer *m, doublereal *s, doublereal *sep, doublereal *work, integer *lwork, integer *iwork, integer * liwork, integer *info)
{
/* System generated locals */
integer q_dim1, q_offset, t_dim1, t_offset, i__1, i__2;
doublereal d__1, d__2;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
integer k, n1, n2, kk, nn, ks;
doublereal est;
integer kase;
logical pair;
integer ierr;
logical swap;
doublereal scale;
extern logical lsame_(char *, char *);
integer isave[3], lwmin;
logical wantq, wants;
doublereal rnorm;
extern /* Subroutine */
int dlacn2_(integer *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *);
extern doublereal dlange_(char *, integer *, integer *, doublereal *, integer *, doublereal *);
extern /* Subroutine */
int dlacpy_(char *, integer *, integer *, doublereal *, integer *, doublereal *, integer *), xerbla_(char *, integer *);
logical wantbh;
extern /* Subroutine */
int dtrexc_(char *, integer *, doublereal *, integer *, doublereal *, integer *, integer *, integer *, doublereal *, integer *);
integer liwmin;
logical wantsp, lquery;
extern /* Subroutine */
int dtrsyl_(char *, char *, integer *, integer *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *);
/* -- LAPACK computational routine (version 3.4.1) -- */
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
/* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
/* April 2012 */
/* .. Scalar Arguments .. */
/* .. */
/* .. Array Arguments .. */
/* .. */
/* ===================================================================== */
/* .. Parameters .. */
/* .. */
/* .. Local Scalars .. */
/* .. */
/* .. Local Arrays .. */
/* .. */
/* .. External Functions .. */
/* .. */
/* .. External Subroutines .. */
/* .. */
/* .. Intrinsic Functions .. */
/* .. */
/* .. Executable Statements .. */
/* Decode and test the input parameters */
/* Parameter adjustments */
--select;
t_dim1 = *ldt;
t_offset = 1 + t_dim1;
t -= t_offset;
q_dim1 = *ldq;
q_offset = 1 + q_dim1;
q -= q_offset;
--wr;
--wi;
--work;
--iwork;
/* Function Body */
wantbh = lsame_(job, "B");
wants = lsame_(job, "E") || wantbh;
wantsp = lsame_(job, "V") || wantbh;
wantq = lsame_(compq, "V");
*info = 0;
lquery = *lwork == -1;
if (! lsame_(job, "N") && ! wants && ! wantsp)
{
*info = -1;
}
else if (! lsame_(compq, "N") && ! wantq)
{
*info = -2;
}
else if (*n < 0)
{
*info = -4;
}
else if (*ldt < max(1,*n))
{
*info = -6;
}
else if (*ldq < 1 || wantq && *ldq < *n)
{
*info = -8;
}
else
{
/* Set M to the dimension of the specified invariant subspace, */
/* and test LWORK and LIWORK. */
*m = 0;
pair = FALSE_;
i__1 = *n;
for (k = 1;
k <= i__1;
++k)
{
if (pair)
{
pair = FALSE_;
}
else
{
if (k < *n)
{
if (t[k + 1 + k * t_dim1] == 0.)
{
if (select[k])
{
++(*m);
}
}
else
{
pair = TRUE_;
if (select[k] || select[k + 1])
{
*m += 2;
}
}
}
else
{
if (select[*n])
{
++(*m);
}
}
}
/* L10: */
}
n1 = *m;
n2 = *n - *m;
nn = n1 * n2;
if (wantsp)
{
/* Computing MAX */
i__1 = 1;
i__2 = nn << 1; // , expr subst
lwmin = max(i__1,i__2);
liwmin = max(1,nn);
}
else if (lsame_(job, "N"))
{
lwmin = max(1,*n);
liwmin = 1;
}
else if (lsame_(job, "E"))
{
lwmin = max(1,nn);
liwmin = 1;
}
if (*lwork < lwmin && ! lquery)
{
*info = -15;
}
else if (*liwork < liwmin && ! lquery)
{
*info = -17;
}
}
if (*info == 0)
{
work[1] = (doublereal) lwmin;
iwork[1] = liwmin;
}
if (*info != 0)
{
i__1 = -(*info);
xerbla_("DTRSEN", &i__1);
return 0;
}
else if (lquery)
{
return 0;
}
/* Quick return if possible. */
if (*m == *n || *m == 0)
{
if (wants)
{
*s = 1.;
}
if (wantsp)
{
*sep = dlange_("1", n, n, &t[t_offset], ldt, &work[1]);
}
goto L40;
}
/* Collect the selected blocks at the top-left corner of T. */
ks = 0;
pair = FALSE_;
i__1 = *n;
for (k = 1;
k <= i__1;
++k)
{
if (pair)
{
pair = FALSE_;
}
else
{
swap = select[k];
if (k < *n)
{
if (t[k + 1 + k * t_dim1] != 0.)
{
pair = TRUE_;
swap = swap || select[k + 1];
}
}
if (swap)
{
++ks;
/* Swap the K-th block to position KS. */
ierr = 0;
kk = k;
if (k != ks)
{
dtrexc_(compq, n, &t[t_offset], ldt, &q[q_offset], ldq, & kk, &ks, &work[1], &ierr);
}
if (ierr == 1 || ierr == 2)
{
/* Blocks too close to swap: exit. */
*info = 1;
if (wants)
{
*s = 0.;
}
if (wantsp)
{
*sep = 0.;
}
goto L40;
}
if (pair)
{
++ks;
}
}
}
/* L20: */
}
if (wants)
{
/* Solve Sylvester equation for R: */
/* T11*R - R*T22 = scale*T12 */
dlacpy_("F", &n1, &n2, &t[(n1 + 1) * t_dim1 + 1], ldt, &work[1], &n1);
dtrsyl_("N", "N", &c_n1, &n1, &n2, &t[t_offset], ldt, &t[n1 + 1 + (n1 + 1) * t_dim1], ldt, &work[1], &n1, &scale, &ierr);
/* Estimate the reciprocal of the condition number of the cluster */
/* of eigenvalues. */
rnorm = dlange_("F", &n1, &n2, &work[1], &n1, &work[1]);
if (rnorm == 0.)
{
*s = 1.;
}
else
{
*s = scale / (sqrt(scale * scale / rnorm + rnorm) * sqrt(rnorm));
}
}
if (wantsp)
{
/* Estimate sep(T11,T22). */
est = 0.;
kase = 0;
L30:
dlacn2_(&nn, &work[nn + 1], &work[1], &iwork[1], &est, &kase, isave);
if (kase != 0)
{
if (kase == 1)
{
/* Solve T11*R - R*T22 = scale*X. */
dtrsyl_("N", "N", &c_n1, &n1, &n2, &t[t_offset], ldt, &t[n1 + 1 + (n1 + 1) * t_dim1], ldt, &work[1], &n1, &scale, & ierr);
}
else
{
/* Solve T11**T*R - R*T22**T = scale*X. */
dtrsyl_("T", "T", &c_n1, &n1, &n2, &t[t_offset], ldt, &t[n1 + 1 + (n1 + 1) * t_dim1], ldt, &work[1], &n1, &scale, & ierr);
}
goto L30;
}
*sep = scale / est;
}
L40: /* Store the output eigenvalues in WR and WI. */
i__1 = *n;
for (k = 1;
k <= i__1;
++k)
{
wr[k] = t[k + k * t_dim1];
wi[k] = 0.;
/* L50: */
}
i__1 = *n - 1;
for (k = 1;
k <= i__1;
++k)
{
if (t[k + 1 + k * t_dim1] != 0.)
{
wi[k] = sqrt((d__1 = t[k + (k + 1) * t_dim1], f2c_abs(d__1))) * sqrt(( d__2 = t[k + 1 + k * t_dim1], f2c_abs(d__2)));
wi[k + 1] = -wi[k];
}
/* L60: */
}
work[1] = (doublereal) lwmin;
iwork[1] = liwmin;
return 0;
/* End of DTRSEN */
}
/* dtrsen_ */
| 32.639498 | 292 | 0.496542 |
d27971cb3789bcf7a3947898592ae410421e64f9 | 1,857 | h | C | src/range.h | jl2922/hybrid_parallel_util | 3d9ff157b7d47e85a1d32786401c7f0807d98362 | [
"MIT"
] | 1 | 2018-02-23T18:01:01.000Z | 2018-02-23T18:01:01.000Z | src/range.h | jl2922/hpmr | 3d9ff157b7d47e85a1d32786401c7f0807d98362 | [
"MIT"
] | null | null | null | src/range.h | jl2922/hpmr | 3d9ff157b7d47e85a1d32786401c7f0807d98362 | [
"MIT"
] | null | null | null | #pragma once
#include <functional>
#include "dist_map.h"
namespace hpmr {
template <class T>
class Range {
public:
Range(const T start, const T end, const T step = 1) : start(start), end(end), step(step) {}
template <class K, class V, class H = std::hash<K>>
DistMap<K, V, H> mapreduce(
const std::function<void(const T, const std::function<void(const K&, const V&)>&)>& mapper,
const std::function<void(V&, const V&)>& reducer,
const bool verbose = false);
// TODO: local map reduce to a concurrent map.
private:
T start;
T end;
T step;
};
template <class T>
template <class K, class V, class H>
DistMap<K, V, H> Range<T>::mapreduce(
const std::function<void(const T, const std::function<void(const K&, const V&)>&)>& mapper,
const std::function<void(V&, const V&)>& reducer,
const bool verbose) {
DistMap<K, V, H> res;
int proc_id;
int n_procs;
MPI_Comm_size(MPI_COMM_WORLD, &n_procs);
MPI_Comm_rank(MPI_COMM_WORLD, &proc_id);
double target_progress = 0.1;
const auto& emit = [&](const K& key, const V& value) { res.async_set(key, value, reducer); };
if (verbose && proc_id == 0) {
const int n_threads = omp_get_max_threads();
printf("MapReduce on %d (%dx) node(s):\nMapping: ", n_procs, n_threads);
}
#pragma omp parallel for schedule(dynamic, 3)
for (T i = start + proc_id * step; i < end; i += step * n_procs) {
mapper(i, emit);
const int thread_id = omp_get_thread_num();
if (verbose && proc_id == 0 && thread_id == 0) {
const double current_progress = (i - start) * 100.0 / (end - start);
while (target_progress <= current_progress) {
printf("%.1f%% ", target_progress);
target_progress *= 2;
}
}
}
if (verbose && proc_id == 0) printf("\n");
res.sync(reducer, verbose);
return res;
}
} // namespace hpmr
| 27.716418 | 97 | 0.631125 |
2cd139a68eff5044eb62625ea0470974d6561ee5 | 2,879 | h | C | modules/drivers/lidar/robosense/driver/driver.h | GoJamie/apollo | 1084d778c1be40fdaaf3fcdcf3e01d5dbcc27bda | [
"Apache-2.0"
] | 1 | 2020-11-30T07:07:59.000Z | 2020-11-30T07:07:59.000Z | modules/drivers/lidar/robosense/driver/driver.h | GoJamie/apollo | 1084d778c1be40fdaaf3fcdcf3e01d5dbcc27bda | [
"Apache-2.0"
] | 1 | 2020-07-17T09:10:44.000Z | 2020-07-17T09:10:44.000Z | modules/drivers/lidar/robosense/driver/driver.h | GoJamie/apollo | 1084d778c1be40fdaaf3fcdcf3e01d5dbcc27bda | [
"Apache-2.0"
] | 2 | 2021-12-12T03:33:50.000Z | 2021-12-29T22:29:21.000Z | /******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include "modules/drivers/proto/pointcloud.pb.h"
#include "modules/drivers/lidar/robosense/proto/config.pb.h"
#include "modules/drivers/lidar/robosense/proto/robosense.pb.h"
#include "cyber/cyber.h"
#include "modules/drivers/lidar/robosense/decoder/decoder_16.hpp"
#include "modules/drivers/lidar/robosense/decoder/decoder_factory.hpp"
#include "modules/drivers/lidar/robosense/driver/utility.h"
#include "modules/drivers/lidar/robosense/input/input.h"
#define PKT_DATA_LENGTH 1248
namespace apollo {
namespace drivers {
namespace robosense {
struct alignas(16) LidarPacketMsg {
double timestamp = 0.0;
std::string frame_id = "";
std::array<uint8_t, PKT_DATA_LENGTH> packet{}; ///< lidar single packet
};
class RobosenseDriver {
public:
RobosenseDriver(const std::shared_ptr<cyber::Node> &node, const Config &conf)
: node_(node), conf_(conf) {}
~RobosenseDriver() { stop(); }
bool init();
private:
void getPackets();
void processMsopPackets();
void processDifopPackets();
private:
std::shared_ptr<cyber::Node> node_ = nullptr;
Config conf_;
std::shared_ptr<cyber::Writer<RobosenseScan>> scan_writer_ = nullptr;
std::shared_ptr<cyber::Writer<PointCloud>> pointcloud_writer_ = nullptr;
private:
void prepareLidarScanMsg(std::shared_ptr<RobosenseScan> msg);
void preparePointsMsg(std::shared_ptr<PointCloud> msg);
void stop() {
msop_pkt_queue_.clear();
difop_pkt_queue_.clear();
if (thread_flag_ == true) {
thread_flag_ = false;
lidar_thread_ptr_->join();
}
}
private:
Queue<LidarPacketMsg> msop_pkt_queue_;
Queue<LidarPacketMsg> difop_pkt_queue_;
bool thread_flag_;
std::shared_ptr<std::thread> lidar_thread_ptr_;
std::shared_ptr<DecoderBase<PointXYZIT>> lidar_decoder_ptr_;
std::shared_ptr<Input> lidar_input_ptr_;
uint32_t scan_seq_;
uint32_t points_seq_;
std::shared_ptr<PointCloud> point_cloud_ptr_;
std::shared_ptr<RobosenseScan> scan_ptr_;
};
} // namespace robosense
} // namespace drivers
} // namespace apollo
| 33.476744 | 79 | 0.706148 |
d625366504ad328e9b2e001816e72763c5d22944 | 114 | h | C | project/include/Utils.h | JOELwindows7/haxe-hardware | 6544b119cf55b1711a3fffc07871bc01d698ef86 | [
"MIT"
] | 10 | 2015-04-01T03:34:41.000Z | 2021-07-02T17:47:52.000Z | project/include/Utils.h | JOELwindows7/haxe-hardware | 6544b119cf55b1711a3fffc07871bc01d698ef86 | [
"MIT"
] | 2 | 2015-03-30T12:06:24.000Z | 2021-07-04T01:39:20.000Z | project/include/Utils.h | JOELwindows7/haxe-hardware | 6544b119cf55b1711a3fffc07871bc01d698ef86 | [
"MIT"
] | 4 | 2015-03-30T06:37:05.000Z | 2021-07-03T09:26:29.000Z | #ifndef HARDWARE_H
#define HARDWARE_H
namespace hardware {
int SampleMethod(int inputValue);
}
#endif | 8.142857 | 34 | 0.719298 |
32855cc91772eea14d4178b2be1c84a8f4349987 | 122 | h | C | src/unistd/_POSIX_ASYNCHRONOUS_IO.h | ung-org/lib-c | 55fc64c7ffd7792bc88451a736c2e94e5865282f | [
"MIT"
] | null | null | null | src/unistd/_POSIX_ASYNCHRONOUS_IO.h | ung-org/lib-c | 55fc64c7ffd7792bc88451a736c2e94e5865282f | [
"MIT"
] | null | null | null | src/unistd/_POSIX_ASYNCHRONOUS_IO.h | ung-org/lib-c | 55fc64c7ffd7792bc88451a736c2e94e5865282f | [
"MIT"
] | null | null | null | #include <unistd.h>
#define _POSIX_ASYNCHRONOUS_IO 200809L
/*
POSIX(199309)
*/
| 17.428571 | 80 | 0.491803 |
d0d25d9fba7c0cbee83a37a3037808c1a3d68d42 | 41,563 | h | C | Deps/acl/includes/acl/math/vector4_32.h | niello/deusexmachina | 2f698054fe82d8b40a0a0e58b86d64ffed0de06c | [
"MIT"
] | 15 | 2019-05-07T11:26:13.000Z | 2022-01-12T18:26:45.000Z | Deps/acl/includes/acl/math/vector4_32.h | niello/deusexmachina | 2f698054fe82d8b40a0a0e58b86d64ffed0de06c | [
"MIT"
] | 16 | 2021-10-04T17:15:31.000Z | 2022-03-20T09:34:29.000Z | Deps/acl/includes/acl/math/vector4_32.h | niello/deusexmachina | 2f698054fe82d8b40a0a0e58b86d64ffed0de06c | [
"MIT"
] | 2 | 2019-04-28T23:27:48.000Z | 2019-05-07T11:26:18.000Z | #pragma once
////////////////////////////////////////////////////////////////////////////////
// The MIT License (MIT)
//
// Copyright (c) 2017 Nicholas Frechette & Animation Compression Library contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
////////////////////////////////////////////////////////////////////////////////
#include "acl/core/compiler_utils.h"
#include "acl/core/error.h"
#include "acl/core/memory_utils.h"
#include "acl/math/math.h"
#include "acl/math/scalar_32.h"
ACL_IMPL_FILE_PRAGMA_PUSH
namespace acl
{
//////////////////////////////////////////////////////////////////////////
// Setters, getters, and casts
inline Vector4_32 ACL_SIMD_CALL vector_set(float x, float y, float z, float w)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_set_ps(w, z, y, x);
#elif defined(ACL_NEON_INTRINSICS)
#if 1
float32x2_t V0 = vcreate_f32(((uint64_t)*(const uint32_t*)&x) | ((uint64_t)(*(const uint32_t*)&y) << 32));
float32x2_t V1 = vcreate_f32(((uint64_t)*(const uint32_t*)&z) | ((uint64_t)(*(const uint32_t*)&w) << 32));
return vcombine_f32(V0, V1);
#else
float __attribute__((aligned(16))) data[4] = { x, y, z, w };
return vld1q_f32(data);
#endif
#else
return Vector4_32{ x, y, z, w };
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_set(float x, float y, float z)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_set_ps(0.0F, z, y, x);
#elif defined(ACL_NEON_INTRINSICS)
#if 1
float32x2_t V0 = vcreate_f32(((uint64_t)*(const uint32_t*)&x) | ((uint64_t)(*(const uint32_t*)&y) << 32));
float32x2_t V1 = vcreate_f32((uint64_t)*(const uint32_t*)&z);
return vcombine_f32(V0, V1);
#else
float __attribute__((aligned(16))) data[4] = { x, y, z };
return vld1q_f32(data);
#endif
#else
return Vector4_32{ x, y, z, 0.0f };
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_set(float xyzw)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_set_ps1(xyzw);
#elif defined(ACL_NEON_INTRINSICS)
return vdupq_n_f32(xyzw);
#else
return Vector4_32{ xyzw, xyzw, xyzw, xyzw };
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_unaligned_load(const float* input)
{
return vector_set(input[0], input[1], input[2], input[3]);
}
inline Vector4_32 ACL_SIMD_CALL vector_unaligned_load3(const float* input)
{
return vector_set(input[0], input[1], input[2], 0.0F);
}
inline Vector4_32 ACL_SIMD_CALL vector_unaligned_load_32(const uint8_t* input)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_loadu_ps((const float*)input);
#elif defined(ACL_NEON_INTRINSICS)
return vreinterpretq_f32_u8(vld1q_u8(input));
#else
Vector4_32 result;
std::memcpy(&result, input, sizeof(Vector4_32));
return result;
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_unaligned_load3_32(const uint8_t* input)
{
float input_f[3];
std::memcpy(&input_f[0], input, sizeof(float) * 3);
return vector_set(input_f[0], input_f[1], input_f[2], 0.0F);
}
inline Vector4_32 ACL_SIMD_CALL vector_zero_32()
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_setzero_ps();
#else
return vector_set(0.0F);
#endif
}
inline Vector4_32 ACL_SIMD_CALL quat_to_vector(Quat_32Arg0 input)
{
#if defined(ACL_SSE2_INTRINSICS) || defined(ACL_NEON_INTRINSICS)
return input;
#else
return Vector4_32{ input.x, input.y, input.z, input.w };
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_cast(const Vector4_64& input)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_shuffle_ps(_mm_cvtpd_ps(input.xy), _mm_cvtpd_ps(input.zw), _MM_SHUFFLE(1, 0, 1, 0));
#else
return vector_set(float(input.x), float(input.y), float(input.z), float(input.w));
#endif
}
inline float ACL_SIMD_CALL vector_get_x(Vector4_32Arg0 input)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_cvtss_f32(input);
#elif defined(ACL_NEON_INTRINSICS)
return vgetq_lane_f32(input, 0);
#else
return input.x;
#endif
}
inline float ACL_SIMD_CALL vector_get_y(Vector4_32Arg0 input)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_cvtss_f32(_mm_shuffle_ps(input, input, _MM_SHUFFLE(1, 1, 1, 1)));
#elif defined(ACL_NEON_INTRINSICS)
return vgetq_lane_f32(input, 1);
#else
return input.y;
#endif
}
inline float ACL_SIMD_CALL vector_get_z(Vector4_32Arg0 input)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_cvtss_f32(_mm_shuffle_ps(input, input, _MM_SHUFFLE(2, 2, 2, 2)));
#elif defined(ACL_NEON_INTRINSICS)
return vgetq_lane_f32(input, 2);
#else
return input.z;
#endif
}
inline float ACL_SIMD_CALL vector_get_w(Vector4_32Arg0 input)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_cvtss_f32(_mm_shuffle_ps(input, input, _MM_SHUFFLE(3, 3, 3, 3)));
#elif defined(ACL_NEON_INTRINSICS)
return vgetq_lane_f32(input, 3);
#else
return input.w;
#endif
}
template<VectorMix component_index>
inline float ACL_SIMD_CALL vector_get_component(Vector4_32Arg0 input)
{
switch (component_index)
{
case VectorMix::A:
case VectorMix::X: return vector_get_x(input);
case VectorMix::B:
case VectorMix::Y: return vector_get_y(input);
case VectorMix::C:
case VectorMix::Z: return vector_get_z(input);
case VectorMix::D:
case VectorMix::W: return vector_get_w(input);
default:
ACL_ASSERT(false, "Invalid component index");
return 0.0F;
}
}
inline float ACL_SIMD_CALL vector_get_component(Vector4_32Arg0 input, VectorMix component_index)
{
switch (component_index)
{
case VectorMix::A:
case VectorMix::X: return vector_get_x(input);
case VectorMix::B:
case VectorMix::Y: return vector_get_y(input);
case VectorMix::C:
case VectorMix::Z: return vector_get_z(input);
case VectorMix::D:
case VectorMix::W: return vector_get_w(input);
default:
ACL_ASSERT(false, "Invalid component index");
return 0.0F;
}
}
inline const float* ACL_SIMD_CALL vector_as_float_ptr(const Vector4_32& input)
{
return reinterpret_cast<const float*>(&input);
}
inline void ACL_SIMD_CALL vector_unaligned_write(Vector4_32Arg0 input, float* output)
{
#if defined(ACL_SSE2_INTRINSICS)
_mm_storeu_ps(output, input);
#else
output[0] = vector_get_x(input);
output[1] = vector_get_y(input);
output[2] = vector_get_z(input);
output[3] = vector_get_w(input);
#endif
}
inline void ACL_SIMD_CALL vector_unaligned_write3(Vector4_32Arg0 input, float* output)
{
output[0] = vector_get_x(input);
output[1] = vector_get_y(input);
output[2] = vector_get_z(input);
}
inline void ACL_SIMD_CALL vector_unaligned_write(Vector4_32Arg0 input, uint8_t* output)
{
std::memcpy(output, &input, sizeof(Vector4_32));
}
inline void ACL_SIMD_CALL vector_unaligned_write3(Vector4_32Arg0 input, uint8_t* output)
{
std::memcpy(output, &input, sizeof(float) * 3);
}
//////////////////////////////////////////////////////////////////////////
// Arithmetic
inline Vector4_32 ACL_SIMD_CALL vector_add(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_add_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vaddq_f32(lhs, rhs);
#else
return vector_set(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w);
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_sub(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_sub_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vsubq_f32(lhs, rhs);
#else
return vector_set(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w);
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_mul(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_mul_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vmulq_f32(lhs, rhs);
#else
return vector_set(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w);
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_mul(Vector4_32Arg0 lhs, float rhs)
{
#if defined(ACL_NEON_INTRINSICS)
return vmulq_n_f32(lhs, rhs);
#else
return vector_mul(lhs, vector_set(rhs));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_div(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_div_ps(lhs, rhs);
#elif defined (ACL_NEON64_INTRINSICS)
return vdivq_f32(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
// Perform two passes of Newton-Raphson iteration on the hardware estimate
float32x4_t x0 = vrecpeq_f32(rhs);
// First iteration
float32x4_t x1 = vmulq_f32(x0, vrecpsq_f32(x0, rhs));
// Second iteration
float32x4_t x2 = vmulq_f32(x1, vrecpsq_f32(x1, rhs));
return vmulq_f32(lhs, x2);
#else
return vector_set(lhs.x / rhs.x, lhs.y / rhs.y, lhs.z / rhs.z, lhs.w / rhs.w);
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_max(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_max_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vmaxq_f32(lhs, rhs);
#else
return vector_set(max(lhs.x, rhs.x), max(lhs.y, rhs.y), max(lhs.z, rhs.z), max(lhs.w, rhs.w));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_min(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_min_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vminq_f32(lhs, rhs);
#else
return vector_set(min(lhs.x, rhs.x), min(lhs.y, rhs.y), min(lhs.z, rhs.z), min(lhs.w, rhs.w));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_clamp(Vector4_32Arg0 input, Vector4_32Arg1 min, Vector4_32Arg2 max)
{
return vector_min(max, vector_max(min, input));
}
inline Vector4_32 ACL_SIMD_CALL vector_abs(Vector4_32Arg0 input)
{
#if defined(ACL_SSE2_INTRINSICS)
return vector_max(vector_sub(_mm_setzero_ps(), input), input);
#elif defined(ACL_NEON_INTRINSICS)
return vabsq_f32(input);
#else
return vector_set(abs(input.x), abs(input.y), abs(input.z), abs(input.w));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_neg(Vector4_32Arg0 input)
{
#if defined(ACL_NEON_INTRINSICS)
return vnegq_f32(input);
#else
return vector_mul(input, -1.0F);
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_reciprocal(Vector4_32Arg0 input)
{
#if defined(ACL_SSE2_INTRINSICS)
// Perform two passes of Newton-Raphson iteration on the hardware estimate
__m128 x0 = _mm_rcp_ps(input);
// First iteration
__m128 x1 = _mm_sub_ps(_mm_add_ps(x0, x0), _mm_mul_ps(input, _mm_mul_ps(x0, x0)));
// Second iteration
__m128 x2 = _mm_sub_ps(_mm_add_ps(x1, x1), _mm_mul_ps(input, _mm_mul_ps(x1, x1)));
return x2;
#elif defined(ACL_NEON_INTRINSICS)
// Perform two passes of Newton-Raphson iteration on the hardware estimate
float32x4_t x0 = vrecpeq_f32(input);
// First iteration
float32x4_t x1 = vmulq_f32(x0, vrecpsq_f32(x0, input));
// Second iteration
float32x4_t x2 = vmulq_f32(x1, vrecpsq_f32(x1, input));
return x2;
#else
return vector_div(vector_set(1.0F), input);
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_ceil(Vector4_32Arg0 input)
{
#if defined(ACL_SSE4_INTRINSICS)
return _mm_ceil_ps(input);
#else
return vector_set(ceil(vector_get_x(input)), ceil(vector_get_y(input)), ceil(vector_get_z(input)), ceil(vector_get_w(input)));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_floor(Vector4_32Arg0 input)
{
#if defined(ACL_SSE4_INTRINSICS)
return _mm_floor_ps(input);
#else
return vector_set(floor(vector_get_x(input)), floor(vector_get_y(input)), floor(vector_get_z(input)), floor(vector_get_w(input)));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_cross3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
return vector_set(vector_get_y(lhs) * vector_get_z(rhs) - vector_get_z(lhs) * vector_get_y(rhs),
vector_get_z(lhs) * vector_get_x(rhs) - vector_get_x(lhs) * vector_get_z(rhs),
vector_get_x(lhs) * vector_get_y(rhs) - vector_get_y(lhs) * vector_get_x(rhs));
}
inline float ACL_SIMD_CALL vector_dot(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE4_INTRINSICS) && 0
// SSE4 dot product instruction isn't precise enough
return _mm_cvtss_f32(_mm_dp_ps(lhs, rhs, 0xFF));
#elif defined(ACL_SSE2_INTRINSICS)
__m128 x2_y2_z2_w2 = _mm_mul_ps(lhs, rhs);
__m128 z2_w2_0_0 = _mm_shuffle_ps(x2_y2_z2_w2, x2_y2_z2_w2, _MM_SHUFFLE(0, 0, 3, 2));
__m128 x2z2_y2w2_0_0 = _mm_add_ps(x2_y2_z2_w2, z2_w2_0_0);
__m128 y2w2_0_0_0 = _mm_shuffle_ps(x2z2_y2w2_0_0, x2z2_y2w2_0_0, _MM_SHUFFLE(0, 0, 0, 1));
__m128 x2y2z2w2_0_0_0 = _mm_add_ps(x2z2_y2w2_0_0, y2w2_0_0_0);
return _mm_cvtss_f32(x2y2z2w2_0_0_0);
#elif defined(ACL_NEON_INTRINSICS)
float32x4_t x2_y2_z2_w2 = vmulq_f32(lhs, rhs);
float32x2_t x2_y2 = vget_low_f32(x2_y2_z2_w2);
float32x2_t z2_w2 = vget_high_f32(x2_y2_z2_w2);
float32x2_t x2z2_y2w2 = vadd_f32(x2_y2, z2_w2);
float32x2_t x2y2z2w2 = vpadd_f32(x2z2_y2w2, x2z2_y2w2);
return vget_lane_f32(x2y2z2w2, 0);
#else
return (vector_get_x(lhs) * vector_get_x(rhs)) + (vector_get_y(lhs) * vector_get_y(rhs)) + (vector_get_z(lhs) * vector_get_z(rhs)) + (vector_get_w(lhs) * vector_get_w(rhs));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_vdot(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE4_INTRINSICS) && 0
// SSE4 dot product instruction isn't precise enough
return _mm_dp_ps(lhs, rhs, 0xFF);
#elif defined(ACL_SSE2_INTRINSICS)
__m128 x2_y2_z2_w2 = _mm_mul_ps(lhs, rhs);
__m128 z2_w2_0_0 = _mm_shuffle_ps(x2_y2_z2_w2, x2_y2_z2_w2, _MM_SHUFFLE(0, 0, 3, 2));
__m128 x2z2_y2w2_0_0 = _mm_add_ps(x2_y2_z2_w2, z2_w2_0_0);
__m128 y2w2_0_0_0 = _mm_shuffle_ps(x2z2_y2w2_0_0, x2z2_y2w2_0_0, _MM_SHUFFLE(0, 0, 0, 1));
__m128 x2y2z2w2_0_0_0 = _mm_add_ps(x2z2_y2w2_0_0, y2w2_0_0_0);
return _mm_shuffle_ps(x2y2z2w2_0_0_0, x2y2z2w2_0_0_0, _MM_SHUFFLE(0, 0, 0, 0));
#elif defined(ACL_NEON_INTRINSICS)
float32x4_t x2_y2_z2_w2 = vmulq_f32(lhs, rhs);
float32x2_t x2_y2 = vget_low_f32(x2_y2_z2_w2);
float32x2_t z2_w2 = vget_high_f32(x2_y2_z2_w2);
float32x2_t x2z2_y2w2 = vadd_f32(x2_y2, z2_w2);
float32x2_t x2y2z2w2 = vpadd_f32(x2z2_y2w2, x2z2_y2w2);
return vcombine_f32(x2y2z2w2, x2y2z2w2);
#else
return vector_set(vector_dot(lhs, rhs));
#endif
}
inline float ACL_SIMD_CALL vector_dot3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE4_INTRINSICS) && 0
// SSE4 dot product instruction isn't precise enough
return _mm_cvtss_f32(_mm_dp_ps(lhs, rhs, 0x7F));
#elif defined(ACL_SSE2_INTRINSICS)
__m128 x2_y2_z2_w2 = _mm_mul_ps(lhs, rhs);
__m128 y2_0_0_0 = _mm_shuffle_ps(x2_y2_z2_w2, x2_y2_z2_w2, _MM_SHUFFLE(0, 0, 0, 1));
__m128 x2y2_0_0_0 = _mm_add_ss(x2_y2_z2_w2, y2_0_0_0);
__m128 z2_0_0_0 = _mm_shuffle_ps(x2_y2_z2_w2, x2_y2_z2_w2, _MM_SHUFFLE(0, 0, 0, 2));
__m128 x2y2z2_0_0_0 = _mm_add_ss(x2y2_0_0_0, z2_0_0_0);
return _mm_cvtss_f32(x2y2z2_0_0_0);
#elif defined(ACL_NEON_INTRINSICS)
float32x4_t x2_y2_z2_w2 = vmulq_f32(lhs, rhs);
float32x2_t x2_y2 = vget_low_f32(x2_y2_z2_w2);
float32x2_t z2_w2 = vget_high_f32(x2_y2_z2_w2);
float32x2_t x2y2_x2y2 = vpadd_f32(x2_y2, x2_y2);
float32x2_t z2_z2 = vdup_lane_f32(z2_w2, 0);
float32x2_t x2y2z2_x2y2z2 = vadd_f32(x2y2_x2y2, z2_z2);
return vget_lane_f32(x2y2z2_x2y2z2, 0);
#else
return (vector_get_x(lhs) * vector_get_x(rhs)) + (vector_get_y(lhs) * vector_get_y(rhs)) + (vector_get_z(lhs) * vector_get_z(rhs));
#endif
}
inline float ACL_SIMD_CALL vector_length_squared(Vector4_32Arg0 input)
{
return vector_dot(input, input);
}
inline float ACL_SIMD_CALL vector_length_squared3(Vector4_32Arg0 input)
{
return vector_dot3(input, input);
}
inline float ACL_SIMD_CALL vector_length(Vector4_32Arg0 input)
{
return sqrt(vector_length_squared(input));
}
inline float ACL_SIMD_CALL vector_length3(Vector4_32Arg0 input)
{
return sqrt(vector_length_squared3(input));
}
inline float ACL_SIMD_CALL vector_length_reciprocal(Vector4_32Arg0 input)
{
return sqrt_reciprocal(vector_length_squared(input));
}
inline float ACL_SIMD_CALL vector_length_reciprocal3(Vector4_32Arg0 input)
{
return sqrt_reciprocal(vector_length_squared3(input));
}
inline float ACL_SIMD_CALL vector_distance3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
return vector_length3(vector_sub(rhs, lhs));
}
inline Vector4_32 ACL_SIMD_CALL vector_normalize3(Vector4_32Arg0 input, float threshold = 1.0E-8F)
{
// Reciprocal is more accurate to normalize with
const float len_sq = vector_length_squared3(input);
if (len_sq >= threshold)
return vector_mul(input, sqrt_reciprocal(len_sq));
else
return input;
}
inline Vector4_32 ACL_SIMD_CALL vector_fraction(Vector4_32Arg0 input)
{
return vector_set(fraction(vector_get_x(input)), fraction(vector_get_y(input)), fraction(vector_get_z(input)), fraction(vector_get_w(input)));
}
// output = (input * scale) + offset
inline Vector4_32 ACL_SIMD_CALL vector_mul_add(Vector4_32Arg0 input, Vector4_32Arg1 scale, Vector4_32Arg2 offset)
{
#if defined(ACL_NEON64_INTRINSICS)
return vfmaq_f32(offset, input, scale);
#elif defined(ACL_NEON_INTRINSICS)
return vmlaq_f32(offset, input, scale);
#else
return vector_add(vector_mul(input, scale), offset);
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_mul_add(Vector4_32Arg0 input, float scale, Vector4_32Arg2 offset)
{
#if defined(ACL_NEON64_INTRINSICS)
return vfmaq_n_f32(offset, input, scale);
#elif defined(ACL_NEON_INTRINSICS)
return vmlaq_n_f32(offset, input, scale);
#else
return vector_add(vector_mul(input, scale), offset);
#endif
}
// output = offset - (input * scale)
inline Vector4_32 ACL_SIMD_CALL vector_neg_mul_sub(Vector4_32Arg0 input, Vector4_32Arg1 scale, Vector4_32Arg2 offset)
{
#if defined(ACL_NEON64_INTRINSICS)
return vfmsq_f32(offset, input, scale);
#elif defined(ACL_NEON_INTRINSICS)
return vmlsq_f32(offset, input, scale);
#else
return vector_sub(offset, vector_mul(input, scale));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_neg_mul_sub(Vector4_32Arg0 input, float scale, Vector4_32Arg2 offset)
{
#if defined(ACL_NEON64_INTRINSICS)
return vfmsq_n_f32(offset, input, scale);
#elif defined(ACL_NEON_INTRINSICS)
return vmlsq_n_f32(offset, input, scale);
#else
return vector_sub(offset, vector_mul(input, scale));
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_lerp(Vector4_32Arg0 start, Vector4_32Arg1 end, float alpha)
{
return vector_mul_add(vector_sub(end, start), alpha, start);
}
//////////////////////////////////////////////////////////////////////////
// Comparisons and masking
inline Vector4_32 ACL_SIMD_CALL vector_less_than(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_cmplt_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vcltq_f32(lhs, rhs);
#else
return Vector4_32{ math_impl::get_mask_value(lhs.x < rhs.x), math_impl::get_mask_value(lhs.y < rhs.y), math_impl::get_mask_value(lhs.z < rhs.z), math_impl::get_mask_value(lhs.w < rhs.w) };
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_less_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_cmple_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vcleq_f32(lhs, rhs);
#else
return Vector4_32{ math_impl::get_mask_value(lhs.x <= rhs.x), math_impl::get_mask_value(lhs.y <= rhs.y), math_impl::get_mask_value(lhs.z <= rhs.z), math_impl::get_mask_value(lhs.w <= rhs.w) };
#endif
}
inline Vector4_32 ACL_SIMD_CALL vector_greater_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_cmpge_ps(lhs, rhs);
#elif defined(ACL_NEON_INTRINSICS)
return vcgeq_f32(lhs, rhs);
#else
return Vector4_32{ math_impl::get_mask_value(lhs.x >= rhs.x), math_impl::get_mask_value(lhs.y >= rhs.y), math_impl::get_mask_value(lhs.z >= rhs.z), math_impl::get_mask_value(lhs.w >= rhs.w) };
#endif
}
inline bool ACL_SIMD_CALL vector_all_less_than(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_movemask_ps(_mm_cmplt_ps(lhs, rhs)) == 0xF;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcltq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) == 0xFFFFFFFFU;
#else
return lhs.x < rhs.x && lhs.y < rhs.y && lhs.z < rhs.z && lhs.w < rhs.w;
#endif
}
inline bool ACL_SIMD_CALL vector_all_less_than3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return (_mm_movemask_ps(_mm_cmplt_ps(lhs, rhs)) & 0x7) == 0x7;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcltq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return (vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) & 0x00FFFFFFU) == 0x00FFFFFFU;
#else
return lhs.x < rhs.x && lhs.y < rhs.y && lhs.z < rhs.z;
#endif
}
inline bool ACL_SIMD_CALL vector_any_less_than(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_movemask_ps(_mm_cmplt_ps(lhs, rhs)) != 0;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcltq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) != 0;
#else
return lhs.x < rhs.x || lhs.y < rhs.y || lhs.z < rhs.z || lhs.w < rhs.w;
#endif
}
inline bool ACL_SIMD_CALL vector_any_less_than3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return (_mm_movemask_ps(_mm_cmplt_ps(lhs, rhs)) & 0x7) != 0;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcltq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return (vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) & 0x00FFFFFFU) != 0;
#else
return lhs.x < rhs.x || lhs.y < rhs.y || lhs.z < rhs.z;
#endif
}
inline bool ACL_SIMD_CALL vector_all_less_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_movemask_ps(_mm_cmple_ps(lhs, rhs)) == 0xF;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcleq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) == 0xFFFFFFFFU;
#else
return lhs.x <= rhs.x && lhs.y <= rhs.y && lhs.z <= rhs.z && lhs.w <= rhs.w;
#endif
}
inline bool ACL_SIMD_CALL vector_all_less_equal2(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return (_mm_movemask_ps(_mm_cmple_ps(lhs, rhs)) & 0x3) == 0x3;
#elif defined(ACL_NEON_INTRINSICS)
uint32x2_t mask = vcle_f32(vget_low_f32(lhs), vget_low_f32(rhs));
return vget_lane_u64(mask, 0) == 0xFFFFFFFFFFFFFFFFULL;
#else
return lhs.x <= rhs.x && lhs.y <= rhs.y;
#endif
}
inline bool ACL_SIMD_CALL vector_all_less_equal3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return (_mm_movemask_ps(_mm_cmple_ps(lhs, rhs)) & 0x7) == 0x7;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcleq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return (vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) & 0x00FFFFFFU) == 0x00FFFFFFU;
#else
return lhs.x <= rhs.x && lhs.y <= rhs.y && lhs.z <= rhs.z;
#endif
}
inline bool ACL_SIMD_CALL vector_any_less_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_movemask_ps(_mm_cmple_ps(lhs, rhs)) != 0;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcleq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) != 0;
#else
return lhs.x <= rhs.x || lhs.y <= rhs.y || lhs.z <= rhs.z || lhs.w <= rhs.w;
#endif
}
inline bool ACL_SIMD_CALL vector_any_less_equal3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return (_mm_movemask_ps(_mm_cmple_ps(lhs, rhs)) & 0x7) != 0;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcleq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return (vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) & 0x00FFFFFFU) != 0;
#else
return lhs.x <= rhs.x || lhs.y <= rhs.y || lhs.z <= rhs.z;
#endif
}
inline bool ACL_SIMD_CALL vector_all_greater_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_movemask_ps(_mm_cmpge_ps(lhs, rhs)) == 0xF;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcgeq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) == 0xFFFFFFFFU;
#else
return lhs.x >= rhs.x && lhs.y >= rhs.y && lhs.z >= rhs.z && lhs.w >= rhs.w;
#endif
}
inline bool ACL_SIMD_CALL vector_all_greater_equal3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return (_mm_movemask_ps(_mm_cmpge_ps(lhs, rhs)) & 0x7) == 0x7;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcgeq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return (vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) & 0x00FFFFFFU) == 0x00FFFFFFU;
#else
return lhs.x >= rhs.x && lhs.y >= rhs.y && lhs.z >= rhs.z;
#endif
}
inline bool ACL_SIMD_CALL vector_any_greater_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_movemask_ps(_mm_cmpge_ps(lhs, rhs)) != 0;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcgeq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) != 0;
#else
return lhs.x >= rhs.x || lhs.y >= rhs.y || lhs.z >= rhs.z || lhs.w >= rhs.w;
#endif
}
inline bool ACL_SIMD_CALL vector_any_greater_equal3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs)
{
#if defined(ACL_SSE2_INTRINSICS)
return (_mm_movemask_ps(_mm_cmpge_ps(lhs, rhs)) & 0x7) != 0;
#elif defined(ACL_NEON_INTRINSICS)
uint32x4_t mask = vcgeq_f32(lhs, rhs);
uint8x8x2_t mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15 = vzip_u8(vget_low_u8(mask), vget_high_u8(mask));
uint16x4x2_t mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15 = vzip_u16(mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[0], mask_0_8_1_9_2_10_3_11_4_12_5_13_6_14_7_15.val[1]);
return (vget_lane_u32(mask_0_8_4_12_1_9_5_13_2_10_6_14_3_11_7_15.val[0], 0) & 0x00FFFFFFU) != 0;
#else
return lhs.x >= rhs.x || lhs.y >= rhs.y || lhs.z >= rhs.z;
#endif
}
inline bool ACL_SIMD_CALL vector_all_near_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs, float threshold = 0.00001F)
{
return vector_all_less_equal(vector_abs(vector_sub(lhs, rhs)), vector_set(threshold));
}
inline bool ACL_SIMD_CALL vector_all_near_equal2(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs, float threshold = 0.00001F)
{
return vector_all_less_equal2(vector_abs(vector_sub(lhs, rhs)), vector_set(threshold));
}
inline bool ACL_SIMD_CALL vector_all_near_equal3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs, float threshold = 0.00001F)
{
return vector_all_less_equal3(vector_abs(vector_sub(lhs, rhs)), vector_set(threshold));
}
inline bool ACL_SIMD_CALL vector_any_near_equal(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs, float threshold = 0.00001F)
{
return vector_any_less_equal(vector_abs(vector_sub(lhs, rhs)), vector_set(threshold));
}
inline bool ACL_SIMD_CALL vector_any_near_equal3(Vector4_32Arg0 lhs, Vector4_32Arg1 rhs, float threshold = 0.00001F)
{
return vector_any_less_equal3(vector_abs(vector_sub(lhs, rhs)), vector_set(threshold));
}
inline bool ACL_SIMD_CALL vector_is_finite(Vector4_32Arg0 input)
{
return is_finite(vector_get_x(input)) && is_finite(vector_get_y(input)) && is_finite(vector_get_z(input)) && is_finite(vector_get_w(input));
}
inline bool ACL_SIMD_CALL vector_is_finite3(Vector4_32Arg0 input)
{
return is_finite(vector_get_x(input)) && is_finite(vector_get_y(input)) && is_finite(vector_get_z(input));
}
//////////////////////////////////////////////////////////////////////////
// Swizzling, permutations, and mixing
inline Vector4_32 ACL_SIMD_CALL vector_blend(Vector4_32Arg0 mask, Vector4_32Arg1 if_true, Vector4_32Arg2 if_false)
{
#if defined(ACL_SSE2_INTRINSICS)
return _mm_or_ps(_mm_andnot_ps(mask, if_false), _mm_and_ps(if_true, mask));
#elif defined(ACL_NEON_INTRINSICS)
return vbslq_f32(mask, if_true, if_false);
#else
return Vector4_32{ math_impl::select(mask.x, if_true.x, if_false.x), math_impl::select(mask.y, if_true.y, if_false.y), math_impl::select(mask.z, if_true.z, if_false.z), math_impl::select(mask.w, if_true.w, if_false.w) };
#endif
}
template<VectorMix comp0, VectorMix comp1, VectorMix comp2, VectorMix comp3>
inline Vector4_32 ACL_SIMD_CALL vector_mix(Vector4_32Arg0 input0, Vector4_32Arg1 input1)
{
#if defined(ACL_SSE2_INTRINSICS)
// All four components come from input 0
if (math_impl::is_vector_mix_arg_xyzw(comp0) && math_impl::is_vector_mix_arg_xyzw(comp1) && math_impl::is_vector_mix_arg_xyzw(comp2) && math_impl::is_vector_mix_arg_xyzw(comp3))
return _mm_shuffle_ps(input0, input0, _MM_SHUFFLE(int(comp3) % 4, int(comp2) % 4, int(comp1) % 4, int(comp0) % 4));
// All four components come from input 1
if (math_impl::is_vector_mix_arg_abcd(comp0) && math_impl::is_vector_mix_arg_abcd(comp1) && math_impl::is_vector_mix_arg_abcd(comp2) && math_impl::is_vector_mix_arg_abcd(comp3))
return _mm_shuffle_ps(input1, input1, _MM_SHUFFLE(int(comp3) % 4, int(comp2) % 4, int(comp1) % 4, int(comp0) % 4));
// First two components come from input 0, second two come from input 1
if (math_impl::is_vector_mix_arg_xyzw(comp0) && math_impl::is_vector_mix_arg_xyzw(comp1) && math_impl::is_vector_mix_arg_abcd(comp2) && math_impl::is_vector_mix_arg_abcd(comp3))
return _mm_shuffle_ps(input0, input1, _MM_SHUFFLE(int(comp3) % 4, int(comp2) % 4, int(comp1) % 4, int(comp0) % 4));
// First two components come from input 1, second two come from input 0
if (math_impl::is_vector_mix_arg_abcd(comp0) && math_impl::is_vector_mix_arg_abcd(comp1) && math_impl::is_vector_mix_arg_xyzw(comp2) && math_impl::is_vector_mix_arg_xyzw(comp3))
return _mm_shuffle_ps(input1, input0, _MM_SHUFFLE(int(comp3) % 4, int(comp2) % 4, int(comp1) % 4, int(comp0) % 4));
// Low words from both inputs are interleaved
if (static_condition<comp0 == VectorMix::X && comp1 == VectorMix::A && comp2 == VectorMix::Y && comp3 == VectorMix::B>::test())
return _mm_unpacklo_ps(input0, input1);
// Low words from both inputs are interleaved
if (static_condition<comp0 == VectorMix::A && comp1 == VectorMix::X && comp2 == VectorMix::B && comp3 == VectorMix::Y>::test())
return _mm_unpacklo_ps(input1, input0);
// High words from both inputs are interleaved
if (static_condition<comp0 == VectorMix::Z && comp1 == VectorMix::C && comp2 == VectorMix::W && comp3 == VectorMix::D>::test())
return _mm_unpackhi_ps(input0, input1);
// High words from both inputs are interleaved
if (static_condition<comp0 == VectorMix::C && comp1 == VectorMix::Z && comp2 == VectorMix::D && comp3 == VectorMix::W>::test())
return _mm_unpackhi_ps(input1, input0);
#endif // defined(ACL_SSE2_INTRINSICS)
// Slow code path, not yet optimized or not using intrinsics
const float x = math_impl::is_vector_mix_arg_xyzw(comp0) ? vector_get_component<comp0>(input0) : vector_get_component<comp0>(input1);
const float y = math_impl::is_vector_mix_arg_xyzw(comp1) ? vector_get_component<comp1>(input0) : vector_get_component<comp1>(input1);
const float z = math_impl::is_vector_mix_arg_xyzw(comp2) ? vector_get_component<comp2>(input0) : vector_get_component<comp2>(input1);
const float w = math_impl::is_vector_mix_arg_xyzw(comp3) ? vector_get_component<comp3>(input0) : vector_get_component<comp3>(input1);
return vector_set(x, y, z, w);
}
inline Vector4_32 ACL_SIMD_CALL vector_mix_xxxx(Vector4_32Arg0 input) { return vector_mix<VectorMix::X, VectorMix::X, VectorMix::X, VectorMix::X>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_yyyy(Vector4_32Arg0 input) { return vector_mix<VectorMix::Y, VectorMix::Y, VectorMix::Y, VectorMix::Y>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zzzz(Vector4_32Arg0 input) { return vector_mix<VectorMix::Z, VectorMix::Z, VectorMix::Z, VectorMix::Z>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_wwww(Vector4_32Arg0 input) { return vector_mix<VectorMix::W, VectorMix::W, VectorMix::W, VectorMix::W>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_xxyy(Vector4_32Arg0 input) { return vector_mix<VectorMix::X, VectorMix::X, VectorMix::Y, VectorMix::Y>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_xzyw(Vector4_32Arg0 input) { return vector_mix<VectorMix::X, VectorMix::Z, VectorMix::Y, VectorMix::W>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_yzxy(Vector4_32Arg0 input) { return vector_mix<VectorMix::Y, VectorMix::Z, VectorMix::X, VectorMix::Y>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_ywxz(Vector4_32Arg0 input) { return vector_mix<VectorMix::Y, VectorMix::W, VectorMix::X, VectorMix::Z>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zxyx(Vector4_32Arg0 input) { return vector_mix<VectorMix::Z, VectorMix::X, VectorMix::Y, VectorMix::X>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zwyz(Vector4_32Arg0 input) { return vector_mix<VectorMix::Z, VectorMix::W, VectorMix::Y, VectorMix::Z>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zwzw(Vector4_32Arg0 input) { return vector_mix<VectorMix::Z, VectorMix::W, VectorMix::Z, VectorMix::W>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_wxwx(Vector4_32Arg0 input) { return vector_mix<VectorMix::W, VectorMix::X, VectorMix::W, VectorMix::X>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_wzwy(Vector4_32Arg0 input) { return vector_mix<VectorMix::W, VectorMix::Z, VectorMix::W, VectorMix::Y>(input, input); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_xyab(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::X, VectorMix::Y, VectorMix::A, VectorMix::B>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_xzac(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::X, VectorMix::Z, VectorMix::A, VectorMix::C>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_xbxb(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::X, VectorMix::B, VectorMix::X, VectorMix::B>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_xbzd(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::X, VectorMix::B, VectorMix::Z, VectorMix::D>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_ywbd(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::Y, VectorMix::W, VectorMix::B, VectorMix::D>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zyax(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::Z, VectorMix::Y, VectorMix::A, VectorMix::X>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zycx(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::Z, VectorMix::Y, VectorMix::C, VectorMix::X>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zwcd(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::Z, VectorMix::W, VectorMix::C, VectorMix::D>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zbaz(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::Z, VectorMix::B, VectorMix::A, VectorMix::Z>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_zdcz(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::Z, VectorMix::D, VectorMix::C, VectorMix::Z>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_wxya(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::W, VectorMix::X, VectorMix::Y, VectorMix::A>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_wxyc(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::W, VectorMix::X, VectorMix::Y, VectorMix::C>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_wbyz(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::W, VectorMix::B, VectorMix::Y, VectorMix::Z>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_wdyz(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::W, VectorMix::D, VectorMix::Y, VectorMix::Z>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_bxwa(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::B, VectorMix::X, VectorMix::W, VectorMix::A>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_bywx(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::B, VectorMix::Y, VectorMix::W, VectorMix::X>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_dxwc(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::D, VectorMix::X, VectorMix::W, VectorMix::C>(input0, input1); }
inline Vector4_32 ACL_SIMD_CALL vector_mix_dywx(Vector4_32Arg0 input0, Vector4_32Arg1 input1) { return vector_mix<VectorMix::D, VectorMix::Y, VectorMix::W, VectorMix::X>(input0, input1); }
//////////////////////////////////////////////////////////////////////////
// Misc
inline Vector4_32 ACL_SIMD_CALL vector_sign(Vector4_32Arg0 input)
{
Vector4_32 mask = vector_greater_equal(input, vector_zero_32());
return vector_blend(mask, vector_set(1.0F), vector_set(-1.0F));
}
//////////////////////////////////////////////////////////////////////////
// Returns per component the rounded input using a symmetric algorithm.
// symmetric_round(1.5) = 2.0
// symmetric_round(1.2) = 1.0
// symmetric_round(-1.5) = -2.0
// symmetric_round(-1.2) = -1.0
//////////////////////////////////////////////////////////////////////////
inline Vector4_32 ACL_SIMD_CALL vector_symmetric_round(Vector4_32Arg0 input)
{
const Vector4_32 half = vector_set(0.5F);
const Vector4_32 floored = vector_floor(vector_add(input, half));
const Vector4_32 ceiled = vector_ceil(vector_sub(input, half));
const Vector4_32 is_greater_equal = vector_greater_equal(input, vector_zero_32());
return vector_blend(is_greater_equal, floored, ceiled);
}
}
ACL_IMPL_FILE_PRAGMA_POP
| 42.892673 | 222 | 0.758198 |
1913ae3ba98cc8d56ada0d8835dada8bd52e6914 | 1,667 | c | C | hex_to_dec.c | JoshuaSkootsky/SomeMath | 0c8ae8cd676813df694170f3292bbeb792cbd1a2 | [
"BSL-1.0"
] | null | null | null | hex_to_dec.c | JoshuaSkootsky/SomeMath | 0c8ae8cd676813df694170f3292bbeb792cbd1a2 | [
"BSL-1.0"
] | null | null | null | hex_to_dec.c | JoshuaSkootsky/SomeMath | 0c8ae8cd676813df694170f3292bbeb792cbd1a2 | [
"BSL-1.0"
] | null | null | null | /* Excercise 2-3: K&R :: Convert Hex input into base-10 integer outout
(c) Joshua Skootsky, 2014 */
#include <stdio.h>
#include <math.h>
#define MAXLINE 1000
int main(int argc, char *argv[]) {
char input[MAXLINE];
int i, c, j, sum, val;
/* Read from file to stored 'input' array, skipping newlines */
while ((c = getchar()) != EOF) {
if (c == '\n' || c == '\t') {
; /* do nothing */
}
else {
input[i] = c;
++i;
}
}
input[i] = '\0';
printf("Here is input:\n%s\nIt is %i long\n", input, i);
/* Work around 0x intro to Hex using stateful 'j' variable */
if (input[0] == '0' && (input[1] == 'x' || input[1] == 'X')) {
printf("Hexadecimal supplied.\n");
j = 2;
}
else {
printf("Assuming Hexadecimal\n");
j = 0;
}
sum = 0;
/* Convert from base_16 to base 10 */
while (input[j] != '\0') {
// Handle Hex cases
switch(input[j]) {
case 'A':
val = 10;
break;
case 'B':
val = 11;
break;
case 'C':
val = 12;
break;
case 'D':
val = 13;
break;
case 'E':
val = 14;
break;
case 'F':
val = 15;
break;
default:
val = input[j] - '0';
}
/* Sum based on position in array */
sum = val * pow(16,i-1-j) + sum;
j++;
}
printf("This is the sum:\n%i\n", sum);
return 0;
}
| 23.478873 | 70 | 0.40192 |
1928734c675cb3adb64a4e4db35caf80bc600971 | 6,500 | h | C | src/application/io/encoders/Encoders.h | js-midi/OpenDeck | 72fc7199e3ba484b87086541f27a1ccb20fbc54f | [
"Apache-2.0"
] | null | null | null | src/application/io/encoders/Encoders.h | js-midi/OpenDeck | 72fc7199e3ba484b87086541f27a1ccb20fbc54f | [
"Apache-2.0"
] | null | null | null | src/application/io/encoders/Encoders.h | js-midi/OpenDeck | 72fc7199e3ba484b87086541f27a1ccb20fbc54f | [
"Apache-2.0"
] | null | null | null | /*
Copyright 2015-2021 Igor Petrovic
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 "database/Database.h"
#include "util/messaging/Messaging.h"
#ifndef ENCODERS_SUPPORTED
#include "stub/Encoders.h"
#else
namespace IO
{
class Encoders
{
public:
enum class type_t : uint8_t
{
controlChange7Fh01h,
controlChange3Fh41h,
programChange,
controlChange,
presetChange,
pitchBend,
nrpn7bit,
nrpn14bit,
controlChange14bit,
AMOUNT
};
enum class position_t : uint8_t
{
stopped,
ccw,
cw,
};
enum class acceleration_t : uint8_t
{
disabled,
slow,
medium,
fast,
AMOUNT
};
class HWA
{
public:
//should return true if the value has been refreshed, false otherwise
virtual bool state(size_t index, uint8_t& numberOfReadings, uint32_t& states) = 0;
};
class Filter
{
public:
virtual bool isFiltered(size_t index,
IO::Encoders::position_t position,
IO::Encoders::position_t& filteredPosition,
uint32_t sampleTakenTime) = 0;
virtual void reset(size_t index) = 0;
virtual uint32_t lastMovementTime(size_t index) = 0;
};
Encoders(HWA& hwa,
Filter& filter,
uint32_t timeDiffTimeout,
Database& database,
Util::MessageDispatcher& dispatcher);
void update();
void resetValue(size_t index);
private:
HWA& _hwa;
Filter& _filter;
struct encoderDescriptor_t
{
type_t type = type_t::controlChange7Fh01h;
uint8_t pulsesPerStep = 0;
Util::MessageDispatcher::message_t dispatchMessage;
encoderDescriptor_t() = default;
};
/// Time difference betweeen multiple encoder readouts in milliseconds.
const uint32_t TIME_DIFF_READOUT;
Database& _database;
Util::MessageDispatcher& _dispatcher;
void fillEncoderDescriptor(size_t index, encoderDescriptor_t& descriptor);
position_t read(size_t index, uint8_t pairState);
void processReading(size_t index, uint8_t pairValue, uint32_t sampleTime);
void sendMessage(size_t index, encoderDescriptor_t& descriptor);
void setValue(size_t index, uint16_t value);
/// Time threshold in milliseconds between two encoder steps used to detect fast movement.
static constexpr uint32_t ENCODERS_SPEED_TIMEOUT = 140;
/// Holds current MIDI value for all encoders.
int16_t _midiValue[MAX_NUMBER_OF_ENCODERS] = { 0 };
/// Array holding current speed (in steps) for all encoders.
uint8_t _encoderSpeed[MAX_NUMBER_OF_ENCODERS] = {};
/// Array holding last two readings from encoder pins.
uint8_t _encoderData[MAX_NUMBER_OF_ENCODERS] = {};
/// Array holding current amount of pulses for all encoders.
int8_t _encoderPulses[MAX_NUMBER_OF_ENCODERS] = {};
/// Lookup table used to convert encoder reading to pulses.
const int8_t _encoderLookUpTable[16] = {
0, //0000
1, //0001
-1, //0010
0, //0011
-1, //0100
0, //0101
0, //0110
1, //0111
1, //1000
0, //1001
0, //1010
-1, //1011
0, //1100
-1, //1101
1, //1110
0 //1111
};
/// Used to achieve linear encoder acceleration on fast movement.
/// Every time fast movement is detected, amount of steps is increased by this value.
/// Used only in CC/Pitch bend/NRPN modes. In Pitch bend/NRPN modes, this value is multiplied
/// by 4 due to a larger value range.
const uint8_t _encoderSpeedChange[static_cast<uint8_t>(IO::Encoders::acceleration_t::AMOUNT)] = {
0, //acceleration disabled
1,
2,
3
};
/// Maximum value by which MIDI value is increased during acceleration.
const uint8_t _encoderMaxAccSpeed[static_cast<uint8_t>(IO::Encoders::acceleration_t::AMOUNT)] = {
0, //acceleration disabled
5,
10,
100
};
/// Array used for easier access to current encoder MIDI value in 7Fh01h and 3Fh41h modes.
/// Matched with type_t and position_t
const uint8_t _encValue[2][3] = {
//controlChange7Fh01h
{
0, //stopped
127, //ccw
1 //cw
},
//controlChange3Fh41h
{
0, //stopped
63, //ccw
65 //cw
}
};
const MIDI::messageType_t _internalMsgToMIDIType[static_cast<uint8_t>(type_t::AMOUNT)] = {
MIDI::messageType_t::controlChange,
MIDI::messageType_t::controlChange,
MIDI::messageType_t::programChange,
MIDI::messageType_t::controlChange,
MIDI::messageType_t::invalid,
MIDI::messageType_t::pitchBend,
MIDI::messageType_t::nrpn7bit,
MIDI::messageType_t::nrpn14bit,
MIDI::messageType_t::controlChange14bit,
};
};
} // namespace IO
#endif | 32.178218 | 105 | 0.541077 |
5cb1051b5831330beb681a78e2bc00450ff4f744 | 1,914 | h | C | linux/arch/arm/mach-netx/include/mach/uncompress.h | bradchesney79/illacceptanything | 4594ae4634fdb5e39263a6423dc255ed46c25208 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | linux/arch/arm/mach-netx/include/mach/uncompress.h | bradchesney79/illacceptanything | 4594ae4634fdb5e39263a6423dc255ed46c25208 | [
"MIT"
] | 2 | 2020-11-02T08:01:00.000Z | 2022-03-27T02:59:18.000Z | linux/arch/arm/mach-netx/include/mach/uncompress.h | bradchesney79/illacceptanything | 4594ae4634fdb5e39263a6423dc255ed46c25208 | [
"MIT"
] | 11 | 2020-08-06T03:59:45.000Z | 2022-02-25T02:31:59.000Z | /*
* arch/arm/mach-netx/include/mach/uncompress.h
*
* Copyright (C) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* The following code assumes the serial port has already been
* initialized by the bootloader. We search for the first enabled
* port in the most probable order. If you didn't setup a port in
* your bootloader then nothing will appear (which might be desired).
*
* This does not append a newline
*/
#define REG(x) (*(volatile unsigned long *)(x))
#define UART1_BASE 0x100a00
#define UART2_BASE 0x100a80
#define UART_DR 0x0
#define UART_CR 0x14
#define CR_UART_EN (1<<0)
#define UART_FR 0x18
#define FR_BUSY (1<<3)
#define FR_TXFF (1<<5)
static void putc(char c)
{
unsigned long base;
if (REG(UART1_BASE + UART_CR) & CR_UART_EN)
base = UART1_BASE;
else if (REG(UART2_BASE + UART_CR) & CR_UART_EN)
base = UART2_BASE;
else
return;
while (REG(base + UART_FR) & FR_TXFF);
REG(base + UART_DR) = c;
}
static inline void flush(void)
{
unsigned long base;
if (REG(UART1_BASE + UART_CR) & CR_UART_EN)
base = UART1_BASE;
else if (REG(UART2_BASE + UART_CR) & CR_UART_EN)
base = UART2_BASE;
else
return;
while (REG(base + UART_FR) & FR_BUSY);
}
/*
* nothing to do
*/
#define arch_decomp_setup()
| 25.184211 | 76 | 0.719958 |
6829818d099a77a4f7b1d33c626f5b27ea0f2f0b | 7,835 | h | C | Clocker/Frameworks/SystemConfiguration.framework/Versions/A/Headers/SCNetwork.h | niij/Clocker | a28f6263091038b7d41464106ab9c65125d8daa6 | [
"MIT"
] | 416 | 2016-08-20T03:40:59.000Z | 2022-03-30T14:27:47.000Z | Clocker/Frameworks/SystemConfiguration.framework/Versions/A/Headers/SCNetwork.h | niij/Clocker | a28f6263091038b7d41464106ab9c65125d8daa6 | [
"MIT"
] | 41 | 2016-08-22T14:41:42.000Z | 2022-02-25T11:38:16.000Z | Clocker/Frameworks/SystemConfiguration.framework/Versions/A/Headers/SCNetwork.h | niij/Clocker | a28f6263091038b7d41464106ab9c65125d8daa6 | [
"MIT"
] | 173 | 2016-08-28T15:09:18.000Z | 2022-03-23T15:42:52.000Z | /*
* Copyright (c) 2000, 2001, 2003-2009, 2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _SCNETWORK_H
#define _SCNETWORK_H
#include <Availability.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <CoreFoundation/CoreFoundation.h>
CF_IMPLICIT_BRIDGING_ENABLED
CF_ASSUME_NONNULL_BEGIN
/*!
@header SCNetwork
@discussion The SCNetwork API contains functions an application can
use to determine remote host reachability and notify the
system of configuration changes.
The two SCNetworkCheckReachability functions allow an
application to determine the status of the system's current
network configuration and the reachability of a target host
or address.
"Reachability" reflects whether a data packet, sent by an
application into the network stack, can leave the local
computer. Note that reachability does <i>not</i> guarantee
that the data packet will actually be received by the host.
*/
/*!
@enum SCNetworkConnectionFlags
@discussion Flags that indicate whether the specified network
nodename or address is reachable, whether a connection is
required, and whether some user intervention may be required
when establishing a connection.
Note: the SCNetworkConnection flags have been deprecated
in favor of the newer SCNetworkReachability flags defined
in SCNetworkReachability.h.
@constant kSCNetworkFlagsTransientConnection
This flag indicates that the specified nodename or address can
be reached via a transient connection, such as PPP.
@constant kSCNetworkFlagsReachable
This flag indicates that the specified nodename or address can
be reached using the current network configuration.
@constant kSCNetworkFlagsConnectionRequired
This flag indicates that the specified nodename or address can
be reached using the current network configuration, but a
connection must first be established.
As an example, this status would be returned for a dialup
connection that was not currently active, but could handle
network traffic for the target system.
@constant kSCNetworkFlagsConnectionAutomatic
This flag indicates that the specified nodename or address can
be reached using the current network configuration, but a
connection must first be established. Any traffic directed
to the specified name or address will initiate the connection.
@constant kSCNetworkFlagsInterventionRequired
This flag indicates that the specified nodename or address can
be reached using the current network configuration, but a
connection must first be established. In addition, some
form of user intervention will be required to establish this
connection, such as providing a password, an authentication
token, etc.
Note: At the present time, this flag will only be returned
in the case where you have a dial-on-traffic configuration
(ConnectionAutomatic), where an attempt to connect has
already been made, and where some error (e.g. no dial tone,
no answer, bad password, ...) was encountered during the
automatic connection attempt. In this case the PPP controller
will stop attempting to establish a connection until the user
has intervened.
@constant kSCNetworkFlagsIsLocalAddress
This flag indicates that the specified nodename or address
is one associated with a network interface on the current
system.
@constant kSCNetworkFlagsIsDirect
This flag indicates that network traffic to the specified
nodename or address will not go through a gateway, but is
routed directly to one of the interfaces in the system.
*/
enum {
kSCNetworkFlagsTransientConnection = 1<<0,
kSCNetworkFlagsReachable = 1<<1,
kSCNetworkFlagsConnectionRequired = 1<<2,
kSCNetworkFlagsConnectionAutomatic = 1<<3,
kSCNetworkFlagsInterventionRequired = 1<<4,
kSCNetworkFlagsIsLocalAddress = 1<<16,
kSCNetworkFlagsIsDirect = 1<<17,
};
typedef uint32_t SCNetworkConnectionFlags;
__BEGIN_DECLS
/*!
@function SCNetworkCheckReachabilityByAddress
@discussion Determines if the given network address is
reachable using the current network configuration.
Note: this API has been deprecated but you can
get equivalent results with :
<pre>
SCNetworkReachabiltyRef target;
SCNetworkReachabiltyFlags flags = 0;
Boolean ok;
target = SCNetworkReachabilityCreateWithAddress(NULL, address);
ok = SCNetworkReachabilityGetFlags(target, &flags);
CFRelease(target);
</pre>
@param address The network address of the desired host.
@param addrlen The length, in bytes, of the address.
@param flags A pointer to memory that will be filled with a
set of SCNetworkConnectionFlags detailing the reachability
of the specified address.
@result Returns TRUE if the network connection flags are valid;
FALSE if the status could not be determined.
*/
Boolean
SCNetworkCheckReachabilityByAddress (
const struct sockaddr *address,
socklen_t addrlen,
SCNetworkConnectionFlags *flags
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
/*!
@function SCNetworkCheckReachabilityByName
@discussion Determines if the given network host or node name is
reachable using the current network configuration.
Note: this API has been deprecated but you can
get equivalent results with :
<pre>
SCNetworkReachabilityRef target;
SCNetworkReachabilityFlags flags = 0;
Boolean ok;
target = SCNetworkReachabilityCreateWithName(NULL, name);
ok = SCNetworkReachabilityGetFlags(target, &flags);
CFRelease(target);
</pre>
@param nodename The node name of the desired host. This name would
be the same as that passed to the gethostbyname(3) or
getaddrinfo(3) functions.
@param flags A pointer to memory that will be filled with a
set of SCNetworkConnectionFlags detailing the reachability
of the specified node name.
@result Returns TRUE if the network connection flags are valid;
FALSE if the status could not be determined.
*/
Boolean
SCNetworkCheckReachabilityByName (
const char *nodename,
SCNetworkConnectionFlags *flags
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
/*!
@function SCNetworkInterfaceRefreshConfiguration
@discussion Sends a notification to interested configuration agents
to have them immediately retry their configuration over a
particular network interface.
Note: This function must be invoked by root (uid == 0).
@param ifName The BSD name of the network interface, such as
CFSTR("en0").
@result Returns TRUE if the notification was sent; FALSE otherwise.
@deprecated in version 10.4. Replaced with SCNetworkInterfaceForceConfigurationRefresh.
*/
Boolean
SCNetworkInterfaceRefreshConfiguration (
CFStringRef ifName
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA);
__END_DECLS
CF_ASSUME_NONNULL_END
CF_IMPLICIT_BRIDGING_DISABLED
#endif /* _SCNETWORK_H */
| 38.219512 | 88 | 0.785578 |
658302cfb0ae17a67c59683c0565180dc73ef814 | 562 | c | C | tests/regression/33-constants/03-empty-not-dead-branch.c | TDacik/analyzer | f5a98a0d321f02b6c217cbbb1c0f058315409c42 | [
"MIT"
] | 64 | 2015-02-21T12:09:08.000Z | 2022-03-30T14:38:16.000Z | tests/regression/33-constants/03-empty-not-dead-branch.c | TDacik/analyzer | f5a98a0d321f02b6c217cbbb1c0f058315409c42 | [
"MIT"
] | 507 | 2015-03-17T14:56:21.000Z | 2022-03-31T12:25:20.000Z | tests/regression/33-constants/03-empty-not-dead-branch.c | TDacik/analyzer | f5a98a0d321f02b6c217cbbb1c0f058315409c42 | [
"MIT"
] | 39 | 2015-05-03T19:46:24.000Z | 2022-03-30T14:38:18.000Z | //PARAM: --set ana.activated '["constants"]'
int g;
int main() {
// state: {bot}, because no locals
if (g) {
g = 1; // state: {bot}, because Hoare set add (in PathSensitive2 map) keeps bot, while reduce would remove
}
else {
g = 2; // state: {bot}, because Hoare set add (in PathSensitive2 map) keeps bot, while reduce would remove
}
// old broken state: {}, because reduce is applied after join and that (old broken) removed bot
g = 3; // old broken state: {} and PathSensitive2 map raises Deadcode
return 0;
}
| 33.058824 | 114 | 0.626335 |
04edada669fb6acaeadcf8ce220c94b3ad457333 | 4,687 | c | C | server_customer.c | abhiyadav1323/banking | 10fbc4e34b4782eb32bca84b1ec34123978805a5 | [
"MIT"
] | 1 | 2022-03-04T14:00:01.000Z | 2022-03-04T14:00:01.000Z | server_customer.c | abhiyadav1323/banking | 10fbc4e34b4782eb32bca84b1ec34123978805a5 | [
"MIT"
] | null | null | null | server_customer.c | abhiyadav1323/banking | 10fbc4e34b4782eb32bca84b1ec34123978805a5 | [
"MIT"
] | 1 | 2021-12-05T04:16:59.000Z | 2021-12-05T04:16:59.000Z | #include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/sendfile.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#define MAX 1001
extern void error(char *);
extern char *client_ip;
void available_balance(int sockfd,char *cust_id)
{
int n;
char filename[MAX];
sprintf(filename,"%s",cust_id);
strcat(filename,".txt");
FILE *fp = fopen(filename,"r");
if(fp == NULL)
error("Error in opening user file for balance.");
char *transaction = NULL;
size_t len = 0;
char *balance;
while(getline(&transaction,&len,fp)!=-1)
{
strtok(transaction," ");
strtok(NULL, " ");
balance = strtok(NULL, " ");
}
fprintf(stdout, "Sending balance of customer '%s' to client with ip '%s'. \n", cust_id, client_ip);
// balance
n = write(sockfd,balance,strlen(balance));
if (n < 0)
error("ERROR writing to socket");
free(transaction);
fclose(fp);
}
void mini_statement(int sockfd, char *cust_id)
{
int n;
char filename[MAX];
sprintf(filename,"%s",cust_id);
strcat(filename,".txt");
struct stat file_stat;
char buffer[MAX];
int fd = open(filename, O_RDONLY);
if(fd == -1)
error("Error in opening user file for mini_statement");
// finding stats of file
if (fstat(fd, &file_stat) < 0)
error("Error in getting statistics of file.");
// writing size of file
bzero(buffer,MAX);
sprintf(buffer, "%d", (int)file_stat.st_size);
n = write(sockfd,buffer,strlen(buffer));
if (n < 0)
error("ERROR writing to socket");
// delimeter string
bzero(buffer,MAX);
n = read(sockfd,buffer,MAX-1);
if (n < 0)
error("ERROR reading from socket");
// sending mini statement
fprintf(stdout, "Sending mini statement of customer '%s' to client with ip '%s'. \n", cust_id, client_ip);
while (1)
{
bzero(buffer,MAX);
int bytes_read = read(fd, buffer, sizeof(buffer));
if (bytes_read == 0)
break;
if (bytes_read < 0)
error("ERROR reading from file.");
void *ptr = buffer;
while (bytes_read > 0) {
int bytes_written = write(sockfd, ptr, bytes_read);
if (bytes_written <= 0)
error("ERROR writing to socket");
bytes_read -= bytes_written;
ptr += bytes_written;
}
}
close(fd);
}
void customer(int sockfd,int cust_id)
{
int n;
char buffer[MAX];
char id[MAX];
sprintf(id,"%d",cust_id);
/* Reading flag */
bzero(buffer,MAX);
n = read(sockfd,buffer,MAX-1);
if (n < 0)
error("ERROR reading from socket");
while(buffer[0]=='y')
{
// reading command
bzero(buffer,MAX);
n = read(sockfd,buffer,MAX-1);
if (n < 0)
error("ERROR reading from socket");
buffer[strlen(buffer)-1] = '\0';
if(!strcmp(buffer,"balance"))
{
// sending true
bzero(buffer,MAX);
strcpy(buffer,"true");
n = write(sockfd,buffer,strlen(buffer));
if (n < 0)
error("ERROR writing to socket");
// delimeter string
bzero(buffer,MAX);
n = read(sockfd,buffer,MAX-1);
if (n < 0)
error("ERROR reading from socket");
available_balance(sockfd,id);
}
else if(!strcmp(buffer,"mini_statement"))
{
// sending true
bzero(buffer,MAX);
strcpy(buffer,"true");
n = write(sockfd,buffer,strlen(buffer));
if (n < 0)
error("ERROR writing to socket");
// delimeter string
bzero(buffer,MAX);
n = read(sockfd,buffer,MAX-1);
if (n < 0)
error("ERROR reading from socket");
mini_statement(sockfd,id);
}
else
{
fprintf(stdout, "Request from client with ip '%s' declined. \n", client_ip);
// sending false
bzero(buffer,MAX);
strcpy(buffer,"false");
n = write(sockfd,buffer,strlen(buffer));
if (n < 0)
error("ERROR writing to socket");
}
/* Reading flag */
bzero(buffer,MAX);
n = read(sockfd,buffer,MAX-1);
if (n < 0)
error("ERROR reading from socket");
}
} | 26.630682 | 110 | 0.519735 |
aa2276e8a5bd703a46d35b2129ee3993d8db70a6 | 104 | c | C | 1000/1063.c | Jason-time/codeup | 0a9b803f643b9021bece7959fef919a3355f0803 | [
"MIT"
] | null | null | null | 1000/1063.c | Jason-time/codeup | 0a9b803f643b9021bece7959fef919a3355f0803 | [
"MIT"
] | null | null | null | 1000/1063.c | Jason-time/codeup | 0a9b803f643b9021bece7959fef919a3355f0803 | [
"MIT"
] | null | null | null | #include <stdio.h>
void main ()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d", a>b?a:b);
return 0;
}
| 11.555556 | 23 | 0.509615 |
80371e1349c98a8799649c16526d39e1b5e8b564 | 3,265 | c | C | release/src-rt-6.x.4708/cfe/cfe/arch/mips/board/bcm97115/src/dev_bcm4413_mii.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src-rt-6.x.4708/cfe/cfe/arch/mips/board/bcm97115/src/dev_bcm4413_mii.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src-rt-6.x.4708/cfe/cfe/arch/mips/board/bcm97115/src/dev_bcm4413_mii.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | #include "lib_types.h"
#include "lib_printf.h"
#include "cfe_timer.h"
#include "dev_bcm4413.h"
#include "dev_bcm4413_mii.h"
#define MIITRACE( x )
#define CTL_RESET (1 << 15) /* reset */
#define CTL_SPEED (1 << 13) /* speed selection 0=10, 1=100 */
#define CTL_ANENAB (1 << 12) /* autonegotiation enable */
#define CTL_RESTART (1 << 9) /* restart autonegotiation */
#define CTL_DUPLEX (1 << 8) /* duplex mode 0=half, 1=full */
#define ADV_10FULL (1 << 6) /* autonegotiate advertise 10full capability */
#define ADV_10HALF (1 << 5) /* autonegotiate advertise 10half capability */
#define ADV_100FULL (1 << 8) /* autonegotiate advertise 100full capability */
#define ADV_100HALF (1 << 7) /* autonegotiate advertise 100half capability */
static uint16_t mii_read( bcmenetregs_t * regs , unsigned int reg )
{
uint32_t mdiodata;
MIITRACE( "mii_read entered\n" );
#ifdef DEBUG
if( reg >= 32 ) {
xprintf( "ERROR : invalid register in mii_read (%d)!\n", reg );
return -1;
}
#endif
/* clear mii_int */
W_REG(NULL, ®s->emacintstatus, EI_MII );
mdiodata = MD_SB_START | MD_OP_READ | (1 << MD_PMD_SHIFT)
| (reg << MD_RA_SHIFT) | MD_TA_VALID;
/* issue the read */
W_REG(NULL, ®s->mdiodata, mdiodata );
MIITRACE( "Waiting for hardware...\n" );
/* wait for it to complete */
while( !(R_REG(NULL, ®s->emacintstatus) & EI_MII) ) {
cfe_usleep( 10 );
}
mdiodata = R_REG(NULL, ®s->mdiodata);
MIITRACE( "mii_read exited\n" );
return mdiodata & MD_DATA_MASK;
}
static void mii_write( bcmenetregs_t * regs, unsigned int reg, uint16_t v )
{
uint32_t mdiodata;
MIITRACE( "mii_write entered\n" );
#ifdef DEBUG
if( reg >= 32 ) {
xprintf( "ERROR : invalid register in mii_write (%d)!\n", reg );
return;
}
#endif
/* clear mii_int */
W_REG(NULL, ®s->emacintstatus, EI_MII );
mdiodata = MD_SB_START | MD_OP_WRITE | (1 << MD_PMD_SHIFT)
| (reg << MD_RA_SHIFT) | MD_TA_VALID | v;
/* issue the write */
W_REG(NULL, ®s->mdiodata, mdiodata );
MIITRACE( "Waiting for hardware...\n" );
/* wait for it to complete */
while( !(R_REG(NULL, ®s->emacintstatus) & EI_MII) ) {
cfe_usleep( 10 );
}
MIITRACE( "mii_write exited\n" );
}
static void mii_or( bcmenetregs_t * regs, unsigned int reg, uint16_t v )
{
uint16_t tmp;
tmp = mii_read( regs, reg );
tmp |= v;
mii_write( regs, reg, tmp );
}
static void mii_and( bcmenetregs_t * regs, unsigned int reg, uint16_t v )
{
uint16_t tmp;
tmp = mii_read( regs, reg );
tmp &= v;
mii_write( regs, reg, tmp );
}
void mii_init( bcmenetregs_t * regs )
{
mii_write( regs, 0, CTL_RESET );
cfe_usleep( 10 );
if (mii_read(regs, 0) & CTL_RESET) {
xprintf( "mii_reset: reset not complete\n" );
}
/* enable activity led */
mii_and( regs, 26, 0x7fff );
/* enable traffic meter led mode */
mii_or( regs, 27, (1 << 6) );
}
void mii_setspeed( bcmenetregs_t * regs )
{
uint16_t reg;
/*
* Because of our bcm4413 interface limitations, force 10Mbps.
*/
/* reset our advertised capabilitity bits */
reg = mii_read(regs, 4);
reg &= ~(ADV_100FULL | ADV_100HALF | ADV_10FULL | ADV_10HALF);
reg |= (ADV_10FULL | ADV_10HALF);
mii_write(regs, 4, reg);
/* restart autonegotiation */
mii_or(regs, 0, CTL_RESTART);
}
| 22.060811 | 77 | 0.654824 |
e7323476a43996d4ec405d44f989ae0f373322f6 | 509 | h | C | src/Parsers/New/AST/DescribeQuery.h | evryfs/ClickHouse | a9648af0b9e2506ce783106315814ed8dbd0a952 | [
"Apache-2.0"
] | 18 | 2021-05-29T01:12:33.000Z | 2021-11-18T12:34:48.000Z | src/Parsers/New/AST/DescribeQuery.h | evryfs/ClickHouse | a9648af0b9e2506ce783106315814ed8dbd0a952 | [
"Apache-2.0"
] | 13 | 2019-06-06T09:45:53.000Z | 2020-05-15T12:03:45.000Z | src/Parsers/New/AST/DescribeQuery.h | evryfs/ClickHouse | a9648af0b9e2506ce783106315814ed8dbd0a952 | [
"Apache-2.0"
] | 22 | 2019-06-14T10:31:51.000Z | 2020-10-12T14:57:44.000Z | #pragma once
#include <Parsers/New/AST/Query.h>
namespace DB::AST
{
// TODO: rewrite to
// `SELECT name, type, default_type, default_expression, comment, codec_expression, ttl_expression FROM system.columns
// WHERE database=db AND table=table`
class DescribeQuery : public Query
{
public:
explicit DescribeQuery(PtrTo<TableExpr> expr);
ASTPtr convertToOld() const override;
private:
enum ChildIndex : UInt8
{
EXPR = 0,
};
};
}
| 18.178571 | 124 | 0.638507 |
2e9854884c67399ceaf512064f15e82cd0b87f2b | 1,885 | h | C | src/main/include/trx0xa.h | xiaoma20082008/innodb | 62f1cf0a1e249fbd867fbdc2f09816aa8cef4acd | [
"Apache-2.0"
] | null | null | null | src/main/include/trx0xa.h | xiaoma20082008/innodb | 62f1cf0a1e249fbd867fbdc2f09816aa8cef4acd | [
"Apache-2.0"
] | null | null | null | src/main/include/trx0xa.h | xiaoma20082008/innodb | 62f1cf0a1e249fbd867fbdc2f09816aa8cef4acd | [
"Apache-2.0"
] | null | null | null | /*****************************************************************************
Copyright (c) 1995, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License, version 2.0, as published by the
Free Software Foundation.
This program is also distributed with certain software (including but not
limited to OpenSSL) that is licensed under separate terms, as designated in a
particular file or component or in included license documentation. The authors
of MySQL hereby grant you an additional permission to link the program and
your derivative works with the separately licensed software that they have
included with MySQL.
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, version 2.0,
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
*****************************************************************************/
/*
* Start of xa.h header
*
* Define a symbol to prevent multiple inclusions of this header file
*/
#ifndef XA_H
#define XA_H
#include "sql/xa.h"
/*
* Transaction branch identification: XID and NULLXID:
*/
#ifndef XIDDATASIZE
/** Sizes of transaction identifier */
#define XIDDATASIZE \
128 /*!< maximum size of a transaction \
identifier, in bytes */
#define MAXGTRIDSIZE 64 /*!< maximum size in bytes of gtrid */
#define MAXBQUALSIZE 64 /*!< maximum size in bytes of bqual */
#endif
#endif /* ifndef XA_H */
/*
* End of xa.h header
*/
| 34.272727 | 78 | 0.667905 |
8350b5dbd79819e0058fe76af816f65b2164f4a9 | 2,454 | h | C | oasys_source/io/NetUtils.h | lauramazzuca21/DTNME | c97b598b09a8c8e97c2e4136879d9f0e157c8df7 | [
"Apache-2.0"
] | 7 | 2021-02-11T16:54:24.000Z | 2021-08-20T06:15:30.000Z | io/NetUtils.h | delay-tolerant-networking/oasys | ec3f11d8a1e41c05ecbc275b9f4dfc160d69b420 | [
"Apache-2.0"
] | 3 | 2020-09-18T13:48:53.000Z | 2021-05-27T18:28:14.000Z | oasys_source/io/NetUtils.h | lauramazzuca21/DTNME | c97b598b09a8c8e97c2e4136879d9f0e157c8df7 | [
"Apache-2.0"
] | 10 | 2020-09-26T05:08:40.000Z | 2022-01-25T12:57:55.000Z | /*
* Copyright 2004-2006 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _OASYS_NET_UTILS_H_
#define _OASYS_NET_UTILS_H_
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "../compat/inttypes.h"
/**
* Wrapper macro to give the illusion that intoa() is a function call.
* Which it is, really... or more accurately two inlined calls and one
* function call.
*/
#define intoa(addr) oasys::Intoa(addr).buf()
namespace oasys {
/**
* Faster wrapper around inet_ntoa.
*/
extern const char* _intoa(u_int32_t addr, char* buf, size_t bufsize);
/**
* Class used to allow for safe concurrent calls to _intoa within an
* argument list.
*/
class Intoa {
public:
Intoa(in_addr_t addr) {
str_ = _intoa(addr, buf_, bufsize_);
}
~Intoa() {
buf_[0] = '\0';
}
const char* buf() { return str_; }
static const int bufsize_ = sizeof(".xxx.xxx.xxx.xxx");
protected:
char buf_[bufsize_];
const char* str_;
};
/**
* Utility wrapper around the ::gethostbyname() system call
*/
extern int gethostbyname(const char* name, in_addr_t* addrp);
/*
* Various overrides of {ntoh,hton}{l,s} that take a char buffer,
* which can be used on systems that require alignment for integer
* operations.
*/
inline u_int32_t
safe_ntohl(const char* bp)
{
u_int32_t netval;
memcpy(&netval, bp, sizeof(netval));
return ntohl(netval);
}
inline u_int16_t
safe_ntohs(const char* bp)
{
u_int16_t netval;
memcpy(&netval, bp, sizeof(netval));
return ntohs(netval);
}
inline void
safe_htonl(u_int32_t val, char* bp)
{
val = htonl(val);
memcpy(bp, &val, sizeof(val));
}
inline void
safe_htons(u_int16_t val, char* bp)
{
val = htons(val);
memcpy(bp, &val, sizeof(val));
}
} // namespace oasys
#endif /* _OASYS_NET_UTILS_H_ */
| 22.309091 | 78 | 0.673187 |
d3dce8f6391804af20b38973ce00e005a48446ac | 508 | h | C | libcog/Json/cogjson.h | dcerjan/old-cog-engine | e6aa34989af7ae359f2550f430dba567a0a1c313 | [
"MIT"
] | 1 | 2020-05-14T18:52:22.000Z | 2020-05-14T18:52:22.000Z | libcog/Json/cogjson.h | dcerjan/old-cog-engine | e6aa34989af7ae359f2550f430dba567a0a1c313 | [
"MIT"
] | null | null | null | libcog/Json/cogjson.h | dcerjan/old-cog-engine | e6aa34989af7ae359f2550f430dba567a0a1c313 | [
"MIT"
] | null | null | null | #ifndef _COG_JSON_H_
#define _COG_JSON_H_
#include "CogJsonObject.h"
#include "coggc.h"
struct CogJsonParser {
CogCleanupPool pool;
};
typedef struct CogJsonParser* CogJsonParser;
CogJsonParser
CogJsonParserAlloc(
void
);
CogJsonObject
CogJsonParserParseString(
CogJsonParser parser,
const char* json
);
CogJsonObject
CogJsonParserParseFromFile(
CogJsonParser parser,
const char* filename
);
void
CogJsonParserFree(
CogJsonParser parser
);
#endif | 14.941176 | 44 | 0.728346 |
d3f15e0c97766af434a3f86f949b3bd37dd1d113 | 3,357 | h | C | coast/modules/StringRenderers/RegExpReplaceRenderer.h | zer0infinity/CuteForCoast | 37d933c5fe2e0ce9a801f51b2aa27c7a18098511 | [
"BSD-3-Clause"
] | null | null | null | coast/modules/StringRenderers/RegExpReplaceRenderer.h | zer0infinity/CuteForCoast | 37d933c5fe2e0ce9a801f51b2aa27c7a18098511 | [
"BSD-3-Clause"
] | null | null | null | coast/modules/StringRenderers/RegExpReplaceRenderer.h | zer0infinity/CuteForCoast | 37d933c5fe2e0ce9a801f51b2aa27c7a18098511 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2010, Peter Sommerlad and IFS Institute for Software at HSR Rapperswil, Switzerland
* All rights reserved.
*
* This library/application is free software; you can redistribute and/or modify it under the terms of
* the license that is included with this library/application in the file license.txt.
*/
#ifndef _RegExpReplaceRenderer_H
#define _RegExpReplaceRenderer_H
#include "Renderer.h"
//---- RegExpReplaceRenderer ----------------------------------------------------------
//! Search regular expression within a string and replace match(es).
/*! Search regular expression \c /Pattern or \c /SimplePattern within \c /Text and render the replaced result to the stream.
*
* @section rerr1 Renderer configuration
\code
{
/Text
/Expressions {
{ # optional if only one expression used
/Pattern # either
/SimplePattern # or
/MatchFlags
/Replacement
/ReplaceAll
}
...
}
}
\endcode
* @par \c Text
* Mandatory\n
* Simple String or Renderer specification used to search/replace within
*
* @par \c Expressions
* Mandatory\n
* One expression specification or list of expressions to apply on \c Text in sequence of list
*
* @par \c Pattern
* Mandatory, if \c SimplePattern not specified, this one has precedence\n
* Regular expression pattern used to search within contents of \c Text. Simple String or Renderer specification supported.
*
* @par \c SimplePattern
* Mandatory, if \c Pattern not specified\n
* Simple Regular expression pattern used to search within contents of \c Text. The pattern will be filtered through RE::SimplePatternToFullRegularExpression()
* to create a valid regular expression string. Simple String or Renderer specification supported.
*
* @par \c MatchFlags
* Optional, default 0 (RE::MATCH_NORMAL which is case sensitive matching), check \ref RE::eMatchFlags for valid values
*
* @par \c Replacement
* Mandatory\n
* Simple String or Renderer specification resulting in a string to be used as replacement for the matching regular expression.\n
* \note Group specific replacement strings like \\1 are not supported.
*
* @par \c ReplaceAll
* Optional, default 1 (true)\n
* Default is to replace all regular expression matches within \c Text. Set to 0 if you want to only replace the first occurrence.
*
* @par Example1:
\code
{ /RegExpReplaceRenderer {
/Text "Try to match anything within this string"
/Expressions {
/Pattern "any"
/Replacement "some"
}
} }
\endcode
Renders : "Try to match something within this string"
\par Example2:
\code
/TmpStore {
/blub anything
/replacewith some
}
{ /RegExpReplaceRenderer {
/Text {
"Try to match "
/Lookup blub
" within this string"
}
/Expressions {
{
/Pattern "any"
/Replacement { /Lookup replacewith }
}
}
} }
\endcode
Renders : "Try to match something within this string"
*/
class RegExpReplaceRenderer: public Renderer {
RegExpReplaceRenderer();
public:
/*! @copydoc RegisterableObject::RegisterableObject(const char *) */
RegExpReplaceRenderer(const char *name) :
Renderer(name) {
}
protected:
//! Renders the corresponding result based on the regular expression match and replacement
/*! @copydoc Renderer::RenderAll(std::ostream &, Context &, const ROAnything &) */
virtual void RenderAll(std::ostream &reply, Context &ctx, const ROAnything &config);
};
#endif
| 29.447368 | 159 | 0.722669 |
d907600fea43645f21ae0ad467e7e2877848edc6 | 1,349 | h | C | IoT2/IoT2-mbed-wrappers/IoT2_wrappers/tcp/mbed-sdk/iot2TCP.h | ghsecuritylab/BenchIoT | 4919427d35e578a7ff07ef5e0b4710b6455dd0b9 | [
"Apache-2.0"
] | 22 | 2019-05-03T03:39:09.000Z | 2022-02-26T17:14:15.000Z | IoT2/IoT2-mbed-wrappers/IoT2_wrappers/tcp/mbed-sdk/iot2TCP.h | ghsecuritylab/BenchIoT | 4919427d35e578a7ff07ef5e0b4710b6455dd0b9 | [
"Apache-2.0"
] | 3 | 2019-07-29T19:48:49.000Z | 2022-01-10T07:24:43.000Z | IoT2/IoT2-mbed-wrappers/IoT2_wrappers/tcp/mbed-sdk/iot2TCP.h | ghsecuritylab/BenchIoT | 4919427d35e578a7ff07ef5e0b4710b6455dd0b9 | [
"Apache-2.0"
] | 8 | 2019-05-16T08:02:33.000Z | 2021-08-03T03:41:37.000Z | //=================================================================================================
//
// This file is used to simplify initializig ethernet and resolve non-blocking send/recv
// calls in the main application.
//
//=================================================================================================
#ifndef IOT2_TCP_H
#define IOT2_TCP_H
//=========================================== INCLUDES ==========================================//
// IoT2 configuration and special interface files
#include "IoT2_Config.h"
#include "iot2Debug.h"
// mbed files
#include "mbed.h"
// board specific files
#include "benchmark_target.h"
// Network files
#include "BareMetalEthernet.h"
#include "BareMetalTCP.h"
#include "lwip/timeouts.h"
//======================================== DEFINES & GLOBALS ====================================//
//========================================= FUNCTIONS ===========================================//
/// Initializes ethernet and tcp
void iot2InitTCP(BareMetalEthernet *eth, BareMetalTCP *socket);
nsapi_size_or_error_t iot2send(BareMetalTCP *socket, const void *data, nsapi_size_t size);
nsapi_size_or_error_t iot2recv(BareMetalTCP *socket, void *data, nsapi_size_t size);
bool ethernetInitialized(void);
BareMetalEthernet* getEthernetInterface(void);
#endif // IOT2_TCP_H // | 26.98 | 99 | 0.507784 |
031e866517049d64ecbda1e8eb2005343721796f | 22,898 | c | C | c_code/1_2/compiler_typesrenderer.c | FedericoCeratto/debian-nim | a029bf7b350731aa9b59a9be7d441a6b7e93ce27 | [
"MIT"
] | null | null | null | c_code/1_2/compiler_typesrenderer.c | FedericoCeratto/debian-nim | a029bf7b350731aa9b59a9be7d441a6b7e93ce27 | [
"MIT"
] | null | null | null | c_code/1_2/compiler_typesrenderer.c | FedericoCeratto/debian-nim | a029bf7b350731aa9b59a9be7d441a6b7e93ce27 | [
"MIT"
] | null | null | null | /* Generated by Nim Compiler v0.15.0 */
/* (c) 2016 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Tnode290802 Tnode290802;
typedef struct Ttype290840 Ttype290840;
typedef struct Tlineinfo189336 Tlineinfo189336;
typedef struct Tsym290834 Tsym290834;
typedef struct Tident197010 Tident197010;
typedef struct Tnodeseq290796 Tnodeseq290796;
typedef struct Tidobj197004 Tidobj197004;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct TY134602 TY134602;
typedef struct Ttypeseq290836 Ttypeseq290836;
typedef struct TY290929 TY290929;
typedef struct Tstrtable290806 Tstrtable290806;
typedef struct Tsymseq290804 Tsymseq290804;
typedef struct Tloc290816 Tloc290816;
typedef struct Ropeobj177006 Ropeobj177006;
typedef struct Tlib290820 Tlib290820;
typedef struct Cell46904 Cell46904;
typedef struct Cellseq46920 Cellseq46920;
typedef struct Gcheap49418 Gcheap49418;
typedef struct Gcstack49416 Gcstack49416;
typedef struct Memregion29086 Memregion29086;
typedef struct Smallchunk29040 Smallchunk29040;
typedef struct Llchunk29080 Llchunk29080;
typedef struct Bigchunk29042 Bigchunk29042;
typedef struct Intset29014 Intset29014;
typedef struct Trunk29010 Trunk29010;
typedef struct Avlnode29084 Avlnode29084;
typedef struct Gcstat49414 Gcstat49414;
typedef struct Cellset46916 Cellset46916;
typedef struct Pagedesc46912 Pagedesc46912;
typedef struct TY290960 TY290960;
typedef struct Tinstantiation290824 Tinstantiation290824;
typedef struct Tlistentry147007 Tlistentry147007;
typedef struct Basechunk29038 Basechunk29038;
typedef struct Freecell29030 Freecell29030;
typedef struct TY290961 TY290961;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct Tlineinfo189336 {
NI16 line;
NI16 col;
NI32 fileindex;
};
typedef NU16 Tnodeflag290427Set;
typedef NU8 Tnodekind290020;
struct Tnode290802 {
Ttype290840* typ;
Tlineinfo189336 info;
Tnodeflag290427Set flags;
Tnodekind290020 kind;
union{
struct {NI64 intval;
} S1;
struct {NF floatval;
} S2;
struct {NimStringDesc* strval;
} S3;
struct {Tsym290834* sym;
} S4;
struct {Tident197010* ident;
} S5;
struct {Tnodeseq290796* sons;
} S6;
} kindU;
NimStringDesc* comment;
};
typedef NU8 Tnimkind3403;
typedef NU8 Tnimtypeflag3409Set;
typedef N_NIMCALL_PTR(void, TY3489) (void* p0, NI op0);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p0);
struct TNimType {
NI size;
Tnimkind3403 kind;
Tnimtypeflag3409Set flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 deepcopy;
};
struct TNimObject {
TNimType* m_type;
};
struct Tidobj197004 {
TNimObject Sup;
NI id;
};
struct Tident197010 {
Tidobj197004 Sup;
NimStringDesc* s;
Tident197010* next;
NI h;
};
typedef NU8 Tnimnodekind3405;
struct TNimNode {
Tnimnodekind3405 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef NU8 Tprefereddesc318011;
typedef NU8 Tsymkind290435;
struct Tstrtable290806 {
NI counter;
Tsymseq290804* data;
};
typedef NU16 Tmagic290524;
typedef NU32 Tsymflag290184Set;
typedef NU32 Toption168009Set;
typedef NU8 Tlockind290808;
typedef NU8 Tstorageloc290812;
typedef NU16 Tlocflag290810Set;
struct Tloc290816 {
Tlockind290808 k;
Tstorageloc290812 s;
Tlocflag290810Set flags;
Ttype290840* t;
Ropeobj177006* r;
};
struct Tsym290834 {
Tidobj197004 Sup;
Tsymkind290435 kind;
union{
struct {Ttypeseq290836* typeinstcache;
} S1;
struct {TY290929* procinstcache;
Tsym290834* gcunsafetyreason;
} S2;
struct {TY290929* usedgenerics;
Tstrtable290806 tab;
} S3;
struct {Tsym290834* guard;
NI bitsize;
} S4;
} kindU;
Tmagic290524 magic;
Ttype290840* typ;
Tident197010* name;
Tlineinfo189336 info;
Tsym290834* owner;
Tsymflag290184Set flags;
Tnode290802* ast;
Toption168009Set options;
NI position;
NI offset;
Tloc290816 loc;
Tlib290820* annex;
Tnode290802* constraint;
};
struct Cell46904 {
NI refcount;
TNimType* typ;
};
struct Cellseq46920 {
NI len;
NI cap;
Cell46904** d;
};
typedef Smallchunk29040* TY29101[512];
typedef Trunk29010* Trunkbuckets29012[256];
struct Intset29014 {
Trunkbuckets29012 data;
};
struct Memregion29086 {
NI minlargeobj;
NI maxlargeobj;
TY29101 freesmallchunks;
Llchunk29080* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk29042* freechunkslist;
Intset29014 chunkstarts;
Avlnode29084* root;
Avlnode29084* deleted;
Avlnode29084* last;
Avlnode29084* freeavlnodes;
NIM_BOOL locked;
};
struct Gcstat49414 {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct Cellset46916 {
NI counter;
NI max;
Pagedesc46912* head;
Pagedesc46912** data;
};
struct Gcheap49418 {
Gcstack49416* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq46920 zct;
Cellseq46920 decstack;
Cellseq46920 tempstack;
NI recgclock;
Memregion29086 region;
Gcstat49414 stat;
Cellset46916 marked;
Cellseq46920 additionalroots;
};
typedef NU8 Ttypekind290244;
typedef NU8 Tcallingconvention290002;
typedef NU32 Ttypeflag290431Set;
struct Ttype290840 {
Tidobj197004 Sup;
Ttypekind290244 kind;
Tcallingconvention290002 callconv;
Ttypeflag290431Set flags;
Ttypeseq290836* sons;
Tnode290802* n;
Tsym290834* owner;
Tsym290834* sym;
Tsym290834* destructor;
Tsym290834* deepcopy;
Tsym290834* assignment;
TY290960* methods;
NI64 size;
NI16 align;
NI16 locklevel;
Tloc290816 loc;
};
struct Ropeobj177006 {
TNimObject Sup;
Ropeobj177006* left;
Ropeobj177006* right;
NI length;
NimStringDesc* data;
};
struct Tlistentry147007 {
TNimObject Sup;
Tlistentry147007* prev;
Tlistentry147007* next;
};
typedef NU8 Tlibkind290818;
struct Tlib290820 {
Tlistentry147007 Sup;
Tlibkind290818 kind;
NIM_BOOL generated;
NIM_BOOL isoverriden;
Ropeobj177006* name;
Tnode290802* path;
};
struct Gcstack49416 {
Gcstack49416* prev;
Gcstack49416* next;
void* starts;
void* pos;
NI maxstacksize;
};
struct Basechunk29038 {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct Smallchunk29040 {
Basechunk29038 Sup;
Smallchunk29040* next;
Smallchunk29040* prev;
Freecell29030* freelist;
NI free;
NI acc;
NF data;
};
struct Llchunk29080 {
NI size;
NI acc;
Llchunk29080* next;
};
struct Bigchunk29042 {
Basechunk29038 Sup;
Bigchunk29042* next;
Bigchunk29042* prev;
NI align;
NF data;
};
typedef NI TY29019[8];
struct Trunk29010 {
Trunk29010* next;
NI key;
TY29019 bits;
};
typedef Avlnode29084* TY29091[2];
struct Avlnode29084 {
TY29091 link;
NI key;
NI upperbound;
NI level;
};
struct Pagedesc46912 {
Pagedesc46912* next;
NI key;
TY29019 bits;
};
struct TY290961 {
NI Field0;
Tsym290834* Field1;
};
struct Tinstantiation290824 {
Tsym290834* sym;
Ttypeseq290836* concretetypes;
NI compilesid;
};
struct Freecell29030 {
Freecell29030* next;
NI zerofield;
};
struct TY134602 {
TGenericSeq Sup;
NimStringDesc* data[SEQ_DECL_SIZE];
};
struct Tnodeseq290796 {
TGenericSeq Sup;
Tnode290802* data[SEQ_DECL_SIZE];
};
struct Ttypeseq290836 {
TGenericSeq Sup;
Ttype290840* data[SEQ_DECL_SIZE];
};
struct TY290929 {
TGenericSeq Sup;
Tinstantiation290824* data[SEQ_DECL_SIZE];
};
struct Tsymseq290804 {
TGenericSeq Sup;
Tsym290834* data[SEQ_DECL_SIZE];
};
struct TY290960 {
TGenericSeq Sup;
TY290961 data[SEQ_DECL_SIZE];
};
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src0);
N_NIMCALL(NimStringDesc*, renderplainsymbolname_410003_117375469)(Tnode290802* n0);
static N_INLINE(Tnode290802*, HEX5BHEX5D_291238_850551059)(Tnode290802* n0, NI i0);
static N_INLINE(NI, len_291081_850551059)(Tnode290802* n0);
N_NIMCALL(NimStringDesc*, renderdefinitionname_309113_382274130)(Tsym290834* s0, NIM_BOOL noquotes0);
N_NIMCALL(void, internalerror_194100_155036129)(Tlineinfo189336 info0, NimStringDesc* errmsg0);
static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0);
static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0);
N_NIMCALL(NimStringDesc*, reprEnum)(NI e0, TNimType* typ0);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space0);
N_NIMCALL(void*, newSeq)(TNimType* typ0, NI len0);
N_NIMCALL(void, renderparamtypes_412233_117375469)(TY134602** found0, Tnode290802* n0);
N_NIMCALL(NimStringDesc*, rendertype_410201_117375469)(Tnode290802* n0);
N_NIMCALL(NimStringDesc*, typetostring_318017_3876443242)(Ttype290840* typ0, Tprefereddesc318011 prefer0);
static N_INLINE(void, appendChar)(NimStringDesc* dest0, NIM_CHAR c0);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest0, NI addlen0);
N_NIMCALL(TGenericSeq*, incrSeqV2)(TGenericSeq* seq0, NI elemsize0);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src0);
static N_INLINE(void, nimGCunrefNoCycle)(void* p0);
static N_INLINE(Cell46904*, usrtocell_51040_1689653243)(void* usr0);
static N_INLINE(void, rtladdzct_52201_1689653243)(Cell46904* c0);
N_NOINLINE(void, addzct_51017_1689653243)(Cellseq46920* s0, Cell46904* c0);
N_NIMCALL(NimStringDesc*, nsuJoinSep)(NimStringDesc** a0, NI a0Len0, NimStringDesc* sep0);
STRING_LITERAL(T117375469_2, "", 0);
STRING_LITERAL(T117375469_3, "renderPlainSymbolName() with ", 29);
STRING_LITERAL(T117375469_4, "ref.", 4);
STRING_LITERAL(T117375469_5, "ptr.", 4);
STRING_LITERAL(T117375469_6, "proc(", 5);
STRING_LITERAL(T117375469_7, "tuple[", 6);
STRING_LITERAL(T117375469_8, "renderParamTypes(found,n) with ", 31);
extern TNimType NTI290020; /* TNodeKind */
extern TNimType NTI134602; /* seq[string] */
extern Gcheap49418 gch_49458_1689653243;
static N_INLINE(Tnode290802*, HEX5BHEX5D_291238_850551059)(Tnode290802* n0, NI i0) {
Tnode290802* result0;
result0 = (Tnode290802*)0;
result0 = (*n0).kindU.S6.sons->data[i0];
return result0;
}
static N_INLINE(NI, len_291081_850551059)(Tnode290802* n0) {
NI result0;
result0 = (NI)0;
{
if (!(*n0).kindU.S6.sons == 0) goto LA3;
result0 = ((NI) 0);
}
goto LA1;
LA3: ;
{
result0 = ((*n0).kindU.S6.sons ? (*n0).kindU.S6.sons->Sup.len : 0);
}
LA1: ;
return result0;
}
static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0) {
void* LOC1;
LOC1 = (void*)0;
LOC1 = memcpy(dest0, source0, ((size_t) (size0)));
}
static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0) {
copymem_7485_1689653243(((void*) ((&(*dest0).data[((*dest0).Sup.len)- 0]))), ((void*) ((*src0).data)), ((NI) ((NI)((*src0).Sup.len + ((NI) 1)))));
(*dest0).Sup.len += (*src0).Sup.len;
}
N_NIMCALL(NimStringDesc*, renderplainsymbolname_410003_117375469)(Tnode290802* n0) {
NimStringDesc* result0;
result0 = (NimStringDesc*)0;
result0 = copyString(((NimStringDesc*) &T117375469_2));
switch ((*n0).kind) {
case ((Tnodekind290020) 31):
case ((Tnodekind290020) 53):
{
NI LOC2;
Tnode290802* LOC3;
LOC2 = (NI)0;
LOC2 = len_291081_850551059(n0);
LOC3 = (Tnode290802*)0;
LOC3 = HEX5BHEX5D_291238_850551059(n0, (LOC2 - 1));
result0 = renderplainsymbolname_410003_117375469(LOC3);
}
break;
case ((Tnodekind290020) 2):
{
result0 = copyString((*(*n0).kindU.S5.ident).s);
}
break;
case ((Tnodekind290020) 3):
{
result0 = renderdefinitionname_309113_382274130((*n0).kindU.S4.sym, NIM_TRUE);
}
break;
case ((Tnodekind290020) 43):
{
Tnode290802* LOC7;
LOC7 = (Tnode290802*)0;
LOC7 = HEX5BHEX5D_291238_850551059(n0, ((NI) 0));
result0 = renderplainsymbolname_410003_117375469(LOC7);
}
break;
default:
{
NimStringDesc* LOC9;
LOC9 = (NimStringDesc*)0;
LOC9 = rawNewString(reprEnum((NI)(*n0).kind, (&NTI290020))->Sup.len + 29);
appendString(LOC9, ((NimStringDesc*) &T117375469_3));
appendString(LOC9, reprEnum((NI)(*n0).kind, (&NTI290020)));
internalerror_194100_155036129((*n0).info, LOC9);
}
break;
}
return result0;
}
static N_INLINE(void, appendChar)(NimStringDesc* dest0, NIM_CHAR c0) {
(*dest0).data[((*dest0).Sup.len)- 0] = c0;
(*dest0).data[((NI)((*dest0).Sup.len + ((NI) 1)))- 0] = 0;
(*dest0).Sup.len += ((NI) 1);
}
N_NIMCALL(NimStringDesc*, rendertype_410201_117375469)(Tnode290802* n0) {
NimStringDesc* result0;
result0 = (NimStringDesc*)0;
switch ((*n0).kind) {
case ((Tnodekind290020) 2):
{
result0 = copyString((*(*n0).kindU.S5.ident).s);
}
break;
case ((Tnodekind290020) 3):
{
result0 = typetostring_318017_3876443242((*(*n0).kindU.S4.sym).typ, ((Tprefereddesc318011) 0));
}
break;
case ((Tnodekind290020) 143):
{
Tnode290802* LOC4;
LOC4 = (Tnode290802*)0;
LOC4 = HEX5BHEX5D_291238_850551059(n0, ((NI) 0));
result0 = rendertype_410201_117375469(LOC4);
}
break;
case ((Tnodekind290020) 141):
{
NimStringDesc* LOC6;
Tnode290802* LOC7;
NimStringDesc* LOC8;
LOC6 = (NimStringDesc*)0;
LOC7 = (Tnode290802*)0;
LOC7 = HEX5BHEX5D_291238_850551059(n0, ((NI) 0));
LOC8 = (NimStringDesc*)0;
LOC8 = rendertype_410201_117375469(LOC7);
LOC6 = rawNewString(LOC8->Sup.len + 4);
appendString(LOC6, ((NimStringDesc*) &T117375469_4));
appendString(LOC6, LOC8);
result0 = LOC6;
}
break;
case ((Tnodekind290020) 142):
{
NimStringDesc* LOC10;
Tnode290802* LOC11;
NimStringDesc* LOC12;
LOC10 = (NimStringDesc*)0;
LOC11 = (Tnode290802*)0;
LOC11 = HEX5BHEX5D_291238_850551059(n0, ((NI) 0));
LOC12 = (NimStringDesc*)0;
LOC12 = rendertype_410201_117375469(LOC11);
LOC10 = rawNewString(LOC12->Sup.len + 4);
appendString(LOC10, ((NimStringDesc*) &T117375469_5));
appendString(LOC10, LOC12);
result0 = LOC10;
}
break;
case ((Tnodekind290020) 147):
{
Tnode290802* params0;
params0 = HEX5BHEX5D_291238_850551059(n0, ((NI) 0));
result0 = copyString(((NimStringDesc*) &T117375469_6));
{
NI i_411418_117375469;
NI HEX3Atmp_412202_117375469;
NI LOC15;
NI res_412205_117375469;
i_411418_117375469 = (NI)0;
HEX3Atmp_412202_117375469 = (NI)0;
LOC15 = (NI)0;
LOC15 = len_291081_850551059(params0);
HEX3Atmp_412202_117375469 = (LOC15 - 1);
res_412205_117375469 = ((NI) 1);
{
while (1) {
NimStringDesc* LOC18;
Tnode290802* LOC19;
NimStringDesc* LOC20;
if (!(res_412205_117375469 <= HEX3Atmp_412202_117375469)) goto LA17;
i_411418_117375469 = res_412205_117375469;
LOC18 = (NimStringDesc*)0;
LOC19 = (Tnode290802*)0;
LOC19 = HEX5BHEX5D_291238_850551059(params0, i_411418_117375469);
LOC20 = (NimStringDesc*)0;
LOC20 = rendertype_410201_117375469(LOC19);
LOC18 = rawNewString(LOC20->Sup.len + 1);
appendString(LOC18, LOC20);
appendChar(LOC18, 44);
result0 = resizeString(result0, LOC18->Sup.len + 0);
appendString(result0, LOC18);
res_412205_117375469 += ((NI) 1);
} LA17: ;
}
}
result0->data[((result0 ? result0->Sup.len : 0) - 1)] = 41;
}
break;
case ((Tnodekind290020) 35):
{
NI typepos0;
NI LOC22;
NimStringDesc* typestr0;
Tnode290802* LOC23;
LOC22 = (NI)0;
LOC22 = len_291081_850551059(n0);
typepos0 = (NI)(LOC22 - ((NI) 2));
LOC23 = (Tnode290802*)0;
LOC23 = HEX5BHEX5D_291238_850551059(n0, typepos0);
typestr0 = rendertype_410201_117375469(LOC23);
result0 = copyString(typestr0);
{
NI i_411620_117375469;
NI HEX3Atmp_412210_117375469;
NI res_412213_117375469;
i_411620_117375469 = (NI)0;
HEX3Atmp_412210_117375469 = (NI)0;
HEX3Atmp_412210_117375469 = (typepos0 - 1);
res_412213_117375469 = ((NI) 1);
{
while (1) {
NimStringDesc* LOC27;
if (!(res_412213_117375469 <= HEX3Atmp_412210_117375469)) goto LA26;
i_411620_117375469 = res_412213_117375469;
LOC27 = (NimStringDesc*)0;
LOC27 = rawNewString(typestr0->Sup.len + 1);
appendChar(LOC27, 44);
appendString(LOC27, typestr0);
result0 = resizeString(result0, LOC27->Sup.len + 0);
appendString(result0, LOC27);
res_412213_117375469 += ((NI) 1);
} LA26: ;
}
}
}
break;
case ((Tnodekind290020) 134):
{
result0 = copyString(((NimStringDesc*) &T117375469_7));
{
NI i_411818_117375469;
NI HEX3Atmp_412218_117375469;
NI LOC30;
NI res_412221_117375469;
i_411818_117375469 = (NI)0;
HEX3Atmp_412218_117375469 = (NI)0;
LOC30 = (NI)0;
LOC30 = len_291081_850551059(n0);
HEX3Atmp_412218_117375469 = (LOC30 - 1);
res_412221_117375469 = ((NI) 0);
{
while (1) {
NimStringDesc* LOC33;
Tnode290802* LOC34;
NimStringDesc* LOC35;
if (!(res_412221_117375469 <= HEX3Atmp_412218_117375469)) goto LA32;
i_411818_117375469 = res_412221_117375469;
LOC33 = (NimStringDesc*)0;
LOC34 = (Tnode290802*)0;
LOC34 = HEX5BHEX5D_291238_850551059(n0, i_411818_117375469);
LOC35 = (NimStringDesc*)0;
LOC35 = rendertype_410201_117375469(LOC34);
LOC33 = rawNewString(LOC35->Sup.len + 1);
appendString(LOC33, LOC35);
appendChar(LOC33, 44);
result0 = resizeString(result0, LOC33->Sup.len + 0);
appendString(result0, LOC33);
res_412221_117375469 += ((NI) 1);
} LA32: ;
}
}
result0->data[((result0 ? result0->Sup.len : 0) - 1)] = 93;
}
break;
case ((Tnodekind290020) 42):
{
NimStringDesc* LOC37;
Tnode290802* LOC38;
NimStringDesc* LOC39;
LOC37 = (NimStringDesc*)0;
LOC38 = (Tnode290802*)0;
LOC38 = HEX5BHEX5D_291238_850551059(n0, ((NI) 0));
LOC39 = (NimStringDesc*)0;
LOC39 = rendertype_410201_117375469(LOC38);
LOC37 = rawNewString(LOC39->Sup.len + 1);
appendString(LOC37, LOC39);
appendChar(LOC37, 91);
result0 = LOC37;
{
NI i_412018_117375469;
NI HEX3Atmp_412226_117375469;
NI LOC41;
NI res_412229_117375469;
i_412018_117375469 = (NI)0;
HEX3Atmp_412226_117375469 = (NI)0;
LOC41 = (NI)0;
LOC41 = len_291081_850551059(n0);
HEX3Atmp_412226_117375469 = (LOC41 - 1);
res_412229_117375469 = ((NI) 1);
{
while (1) {
NimStringDesc* LOC44;
Tnode290802* LOC45;
NimStringDesc* LOC46;
if (!(res_412229_117375469 <= HEX3Atmp_412226_117375469)) goto LA43;
i_412018_117375469 = res_412229_117375469;
LOC44 = (NimStringDesc*)0;
LOC45 = (Tnode290802*)0;
LOC45 = HEX5BHEX5D_291238_850551059(n0, i_412018_117375469);
LOC46 = (NimStringDesc*)0;
LOC46 = rendertype_410201_117375469(LOC45);
LOC44 = rawNewString(LOC46->Sup.len + 1);
appendString(LOC44, LOC46);
appendChar(LOC44, 44);
result0 = resizeString(result0, LOC44->Sup.len + 0);
appendString(result0, LOC44);
res_412229_117375469 += ((NI) 1);
} LA43: ;
}
}
result0->data[((result0 ? result0->Sup.len : 0) - 1)] = 93;
}
break;
default:
{
result0 = copyString(((NimStringDesc*) &T117375469_2));
}
break;
}
return result0;
}
static N_INLINE(Cell46904*, usrtocell_51040_1689653243)(void* usr0) {
Cell46904* result0;
result0 = (Cell46904*)0;
result0 = ((Cell46904*) ((NI)((NU64)(((NI) (usr0))) - (NU64)(((NI)sizeof(Cell46904))))));
return result0;
}
static N_INLINE(void, rtladdzct_52201_1689653243)(Cell46904* c0) {
addzct_51017_1689653243((&gch_49458_1689653243.zct), c0);
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p0) {
Cell46904* c0;
c0 = usrtocell_51040_1689653243(p0);
{
(*c0).refcount -= ((NI) 8);
if (!((NU64)((*c0).refcount) < (NU64)(((NI) 8)))) goto LA3;
rtladdzct_52201_1689653243(c0);
}
LA3: ;
}
N_NIMCALL(void, renderparamtypes_412233_117375469)(TY134602** found0, Tnode290802* n0) {
{ switch ((*n0).kind) {
case ((Tnodekind290020) 76):
{
{
NI i_412256_117375469;
NI HEX3Atmp_412456_117375469;
NI LOC3;
NI res_412459_117375469;
i_412256_117375469 = (NI)0;
HEX3Atmp_412456_117375469 = (NI)0;
LOC3 = (NI)0;
LOC3 = len_291081_850551059(n0);
HEX3Atmp_412456_117375469 = (LOC3 - 1);
res_412459_117375469 = ((NI) 1);
{
while (1) {
Tnode290802* LOC6;
if (!(res_412459_117375469 <= HEX3Atmp_412456_117375469)) goto LA5;
i_412256_117375469 = res_412459_117375469;
LOC6 = (Tnode290802*)0;
LOC6 = HEX5BHEX5D_291238_850551059(n0, i_412256_117375469);
renderparamtypes_412233_117375469(found0, LOC6);
res_412459_117375469 += ((NI) 1);
} LA5: ;
}
}
}
break;
case ((Tnodekind290020) 35):
{
NI typepos0;
NI LOC8;
NimStringDesc* typestr0;
Tnode290802* LOC9;
LOC8 = (NI)0;
LOC8 = len_291081_850551059(n0);
typepos0 = (NI)(LOC8 - ((NI) 2));
LOC9 = (Tnode290802*)0;
LOC9 = HEX5BHEX5D_291238_850551059(n0, typepos0);
typestr0 = rendertype_410201_117375469(LOC9);
{
NIM_BOOL LOC12;
Tnode290802* LOC14;
Ttype290840* typ0;
Tnode290802* LOC17;
LOC12 = (NIM_BOOL)0;
LOC12 = ((typestr0 ? typestr0->Sup.len : 0) < ((NI) 1));
if (!(LOC12)) goto LA13;
LOC14 = (Tnode290802*)0;
LOC14 = HEX5BHEX5D_291238_850551059(n0, (NI)(typepos0 + ((NI) 1)));
LOC12 = !(((*LOC14).kind == ((Tnodekind290020) 1)));
LA13: ;
if (!LOC12) goto LA15;
LOC17 = (Tnode290802*)0;
LOC17 = HEX5BHEX5D_291238_850551059(n0, (NI)(typepos0 + ((NI) 1)));
typ0 = (*LOC17).typ;
{
if (!!(typ0 == 0)) goto LA20;
typestr0 = typetostring_318017_3876443242(typ0, ((Tprefereddesc318011) 2));
}
LA20: ;
{
if (!((typestr0 ? typestr0->Sup.len : 0) < ((NI) 1))) goto LA24;
goto BeforeRet;
}
LA24: ;
}
LA15: ;
{
NI i_412437_117375469;
NI HEX3Atmp_412464_117375469;
NI res_412467_117375469;
i_412437_117375469 = (NI)0;
HEX3Atmp_412464_117375469 = (NI)0;
HEX3Atmp_412464_117375469 = (typepos0 - 1);
res_412467_117375469 = ((NI) 0);
{
while (1) {
NimStringDesc* LOC29;
if (!(res_412467_117375469 <= HEX3Atmp_412464_117375469)) goto LA28;
i_412437_117375469 = res_412467_117375469;
(*found0) = (TY134602*) incrSeqV2(&((*found0))->Sup, sizeof(NimStringDesc*));
LOC29 = (NimStringDesc*)0;
LOC29 = (*found0)->data[(*found0)->Sup.len]; (*found0)->data[(*found0)->Sup.len] = copyStringRC1(typestr0);
if (LOC29) nimGCunrefNoCycle(LOC29);
++(*found0)->Sup.len;
res_412467_117375469 += ((NI) 1);
} LA28: ;
}
}
}
break;
default:
{
NimStringDesc* LOC31;
LOC31 = (NimStringDesc*)0;
LOC31 = rawNewString(reprEnum((NI)(*n0).kind, (&NTI290020))->Sup.len + 31);
appendString(LOC31, ((NimStringDesc*) &T117375469_8));
appendString(LOC31, reprEnum((NI)(*n0).kind, (&NTI290020)));
internalerror_194100_155036129((*n0).info, LOC31);
}
break;
}
}BeforeRet: ;
}
N_NIMCALL(NimStringDesc*, renderparamtypes_412471_117375469)(Tnode290802* n0, NimStringDesc* sep0) {
NimStringDesc* result0;
TY134602* found0;
result0 = (NimStringDesc*)0;
result0 = copyString(((NimStringDesc*) &T117375469_2));
found0 = (TY134602*) newSeq((&NTI134602), 0);
renderparamtypes_412233_117375469((&found0), n0);
{
if (!(((NI) 0) < (found0 ? found0->Sup.len : 0))) goto LA3;
result0 = nsuJoinSep(found0->data, found0->Sup.len, sep0);
}
LA3: ;
return result0;
}
NIM_EXTERNC N_NOINLINE(void, compiler_typesrendererInit000)(void) {
}
NIM_EXTERNC N_NOINLINE(void, compiler_typesrendererDatInit000)(void) {
}
| 26.687646 | 147 | 0.723033 |
03dd67410f47b0fafc382aa9953accff532df2b6 | 4,690 | c | C | src/machine/cchip.c | rsn8887/mame2003-plus-libretro | 2d0759df85a6e647a7301fed9eec37b4f4270812 | [
"RSA-MD"
] | null | null | null | src/machine/cchip.c | rsn8887/mame2003-plus-libretro | 2d0759df85a6e647a7301fed9eec37b4f4270812 | [
"RSA-MD"
] | null | null | null | src/machine/cchip.c | rsn8887/mame2003-plus-libretro | 2d0759df85a6e647a7301fed9eec37b4f4270812 | [
"RSA-MD"
] | null | null | null | /***************************************************************************
cchip.c
This file contains routines to interface with the Taito Controller Chip
(or "Command Chip") version 1. It's currently used by Superman and Mega
Blast. [Further cchip emulation is in machine/rainbow.c, machine/volfied.c,
drivers/opwolf.c]
According to Richard Bush, the C-Chip is an encrypted Z80 which communicates
with the main board as a protection feature.
Superman (revised SJ 060601)
--------
In Superman, the C-chip's main purpose is to handle player inputs and
coins and pass commands along to the sound chip.
The 68k queries the c-chip, which passes back $100 bytes of 68k code which
are then executed in RAM. To get around this, we hack in our own code to
communicate with the sound board, since we are familiar with the interface
as it's used in Rastan and Super Space Invaders '91.
It is believed that the NOPs in the 68k code are there to supply the
necessary cycles to the cchip to switch banks.
This code requires that the player & coin inputs be in input ports 4-6.
Mega Blast
----------
C-Chip simply used as RAM, the game doesn't even bother to change banks.
It does read the chip id though. The dump is confirmed to be from an
original board.
***************************************************************************/
#include "driver.h"
#include "state.h"
static int current_bank = 0;
static UINT8 cc_port = 0;
/* This code for sound communication is a hack, it will not be
identical to the code derived from the real c-chip */
static UINT8 superman_code[40] =
{
0x48, 0xe7, 0x80, 0x80, /* MOVEM.L D0/A0,-(A7) ( Preserve Regs ) */
0x20, 0x6d, 0x1c, 0x40, /* MOVEA.L ($1C40,A5),A0 ( Load sound pointer in A0 ) */
0x30, 0x2f, 0x00, 0x0c, /* MOVE.W ($0C,A7),D0 ( Fetch sound number ) */
0x10, 0x80, /* MOVE.B D0,(A0) ( Store it on sound pointer ) */
0x52, 0x88, /* ADDQ.W #1,A0 ( Increment sound pointer ) */
0x20, 0x3c, 0x00, 0xf0, 0x1c, 0x40, /* MOVE.L #$F01C40,D0 ( Load top of buffer in D0 ) */
0xb1, 0xc0, /* CMPA.L D0,A0 ( Are we there yet? ) */
0x66, 0x04, /* BNE.S *+$6 ( No, we arent, skip next line ) */
0x41, 0xed, 0x1c, 0x20, /* LEA ($1C20,A5),A0 ( Point to the start of the buffer ) */
0x2b, 0x48, 0x1c, 0x40, /* MOVE.L A0,($1C40,A5) ( Store new sound pointer ) */
0x4c, 0xdf, 0x01, 0x01, /* MOVEM.L (A7)+, D0/A0 ( Restore Regs ) */
0x4e, 0x75 /* RTS ( Return ) */
};
MACHINE_INIT( cchip1 )
{
state_save_register_int ("cchip1", 0, "current_bank", ¤t_bank);
state_save_register_UINT8("cchip1", 0, "cc_port", &cc_port, 1);
}
WRITE16_HANDLER( cchip1_word_w )
{
if (offset == 0x600)
{
current_bank = data;
}
else if (current_bank == 0 && offset == 0x003)
{
cc_port = data;
coin_lockout_w(1, data & 0x08);
coin_lockout_w(0, data & 0x04);
coin_counter_w(1, data & 0x02);
coin_counter_w(0, data & 0x01);
}
else
{
log_cb(RETRO_LOG_DEBUG, LOGPRE "cchip1_w pc: %06x bank %02x offset %04x: %02x\n",activecpu_get_pc(),current_bank,offset,data);
}
}
READ16_HANDLER( cchip1_word_r )
{
/* C-Chip ID */
if (offset == 0x401)
{
return 0x01;
}
/* Check for input ports */
if (current_bank == 0)
{
switch (offset)
{
case 0x000: return readinputport(4);
case 0x001: return readinputport(5);
case 0x002: return readinputport(6);
case 0x003: return cc_port;
}
}
/* Other non-standard offsets */
if (current_bank == 1 && offset <= 0xff)
{
if (offset < 40) /* our hack code is only 40 bytes long */
return superman_code[offset];
else /* so pad with zeros */
return 0;
}
if (current_bank == 2)
{
switch (offset)
{
case 0x000: return 0x47;
case 0x001: return 0x57;
case 0x002: return 0x4b;
}
}
log_cb(RETRO_LOG_DEBUG, LOGPRE "cchip1_r bank: %02x offset: %04x\n",current_bank,offset);
return 0;
}
/* Mega Blast */
data16_t *cchip_ram;
WRITE16_HANDLER( cchip2_word_w )
{
log_cb(RETRO_LOG_DEBUG, LOGPRE "cchip2_w pc: %06x offset %04x: %02x\n", activecpu_get_pc(), offset, data);
COMBINE_DATA(&cchip_ram[offset]);
}
READ16_HANDLER( cchip2_word_r )
{
/* C-Chip ID */
if (offset == 0x401)
{
return 0x01;
}
log_cb(RETRO_LOG_DEBUG, LOGPRE "cchip2_r offset: %04x\n", offset);
return cchip_ram[offset];
}
| 28.424242 | 127 | 0.592751 |
1e1469b0fdc70d2a8decb364b61dfe398906a6f1 | 3,251 | c | C | dift/splice.c | huhong789/shortcut | bce8a64c4d99b3dca72ffa0a04c9f3485cbab13a | [
"BSD-2-Clause"
] | 47 | 2015-03-10T23:21:52.000Z | 2022-02-17T01:04:14.000Z | dift/splice.c | shortcut-sosp19/shortcut | f0ff3d9170dbc6de38e0d8c200db056aa26b9c48 | [
"BSD-2-Clause"
] | 1 | 2020-06-30T18:01:37.000Z | 2020-06-30T18:01:37.000Z | dift/splice.c | shortcut-sosp19/shortcut | f0ff3d9170dbc6de38e0d8c200db056aa26b9c48 | [
"BSD-2-Clause"
] | 19 | 2015-02-25T19:50:05.000Z | 2021-10-05T14:35:54.000Z | #include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <semaphore.h>
#include <glib-2.0/glib.h>
#include "linkage_common.h"
#include "maputil.h"
#include "taint_interface/taint_creation.h"
#include "taint_interface/taint_interface.h"
extern u_long* pregs;
extern u_long merge_total_count;
#define OUTBUFSIZE 1000000
u_long outbuf[OUTBUFSIZE];
u_long outindex = 0;
static void flush_outbuf(int outfd)
{
long rc = write (outfd, outbuf, outindex*sizeof(u_long));
if (rc != (long) (outindex*sizeof(u_long))) {
fprintf (stderr, "write of segment failed, rc=%ld, errno=%d\n", rc, errno);
exit (rc);
}
outindex = 0;
}
static inline void write_value (u_long value, int outfd)
{
if (outindex == OUTBUFSIZE) flush_outbuf(outfd);
outbuf[outindex++] = value;
}
long splice_after_segment (const char* splice_input_filename, const char* semname, int outfd)
{
struct taint_creation_info tci;
long rc;
u_long bufsize, i, addr, value, idatasize, imapsize;
u_long* ibuf;
int ifd, val = 0;
sem_t* sem;
struct timeval tv;
if (semname) {
// Wait on this semaphore before accessing splice file
sem = sem_open (semname, 0);
if (sem == NULL) {
printf ("splice_after_segment: cannot open semaphore %s, errno=%d\n", semname, errno);
return -1;
}
// This is hideous - but Pin deadlocks if we make a blocking sem_wait here (sigh)
gettimeofday(&tv, NULL);
printf ("Waiting on semaphore %s time %ld.%ld\n", semname, tv.tv_sec, tv.tv_usec);
do {
rc = sem_getvalue (sem, &val);
if (rc < 0) {
fprintf (stderr, "splice_after_segment: waiting on semaphore %s, errno=%d\n", semname, errno);
return -1;
}
if (val < 1) usleep (100);
} while (val < 1);
gettimeofday(&tv, NULL);
printf ("Done waiting on semaphore %s time %ld.%ld\n", semname, tv.tv_sec, tv.tv_usec);
sem_close (sem);
}
//printf ("Merge entries: %lu\n", merge_total_count - 0xe0000000);
rc = map_file (splice_input_filename, &ifd, &idatasize, &imapsize, (char **) &ibuf);
printf ("Open of input file %s returns %ld\n", splice_input_filename, rc);
if (rc < 0) return rc;
tci.type = 0;
tci.rg_id = 0;
tci.record_pid = 0;
tci.syscall_cnt = 0; // We'll use this to indicate address space taints for now - structure is somewhat broken
tci.offset = 0;
tci.fileno = 0;
tci.data = 0;
rc = write(outfd, &tci, sizeof(tci));
if (rc != sizeof(tci)) {
fprintf(stderr, "splice_after_segment: header write returned %ld, errno=%d\n", rc, errno);
return rc;
}
write_value (0, outfd);
bufsize = idatasize / sizeof(u_long);
write_value (bufsize, outfd);
for (i = 0; i < bufsize; i++) {
addr = ibuf[i];
if (addr < NUM_REGS * REG_SIZE) {
value = pregs[addr];
} else {
taint_t* mem_taint = get_mem_taints(addr, 1);
if (mem_taint) {
value = *mem_taint;
} else {
value = 0;
}
}
if (value > 0 && value <= NUM_REGS*REG_SIZE) value--; // Reg taint offset by 1 to allow zero taint
write_value(addr, outfd);
write_value(value, outfd);
}
flush_outbuf (outfd);
return 0;
}
| 27.786325 | 114 | 0.647493 |
14206f41a67ead54d12fa63034b04433fd1ad03e | 1,731 | h | C | src/Ngap_GlobalRANNodeID.h | neonkingfr/oai-libngapcodec | a36b8c44cdd8f9aee88527ad1d3c74d4caf8f9c4 | [
"Apache-2.0"
] | 2 | 2019-12-06T14:24:00.000Z | 2021-02-25T05:55:58.000Z | src/Ngap_GlobalRANNodeID.h | fly-fisher/oai-libngapcodec | d90f648f1a294e707a7506e199867ec786c76941 | [
"Apache-2.0"
] | null | null | null | src/Ngap_GlobalRANNodeID.h | fly-fisher/oai-libngapcodec | d90f648f1a294e707a7506e199867ec786c76941 | [
"Apache-2.0"
] | 6 | 2019-12-06T14:23:59.000Z | 2021-04-08T06:33:21.000Z | /*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "NGAP-IEs"
* found in "asn.1/Information Element Definitions.asn1"
* `asn1c -pdu=all -fcompound-names -fno-include-deps -findirect-choice -gen-PER -D src`
*/
#ifndef _Ngap_GlobalRANNodeID_H_
#define _Ngap_GlobalRANNodeID_H_
#include <asn_application.h>
/* Including external dependencies */
#include <constr_CHOICE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum Ngap_GlobalRANNodeID_PR {
Ngap_GlobalRANNodeID_PR_NOTHING, /* No components present */
Ngap_GlobalRANNodeID_PR_globalGNB_ID,
Ngap_GlobalRANNodeID_PR_globalNgENB_ID,
Ngap_GlobalRANNodeID_PR_globalN3IWF_ID,
Ngap_GlobalRANNodeID_PR_choice_Extensions
} Ngap_GlobalRANNodeID_PR;
/* Forward declarations */
struct Ngap_GlobalGNB_ID;
struct Ngap_GlobalNgENB_ID;
struct Ngap_GlobalN3IWF_ID;
struct Ngap_ProtocolIE_SingleContainer;
/* Ngap_GlobalRANNodeID */
typedef struct Ngap_GlobalRANNodeID {
Ngap_GlobalRANNodeID_PR present;
union Ngap_GlobalRANNodeID_u {
struct Ngap_GlobalGNB_ID *globalGNB_ID;
struct Ngap_GlobalNgENB_ID *globalNgENB_ID;
struct Ngap_GlobalN3IWF_ID *globalN3IWF_ID;
struct Ngap_ProtocolIE_SingleContainer *choice_Extensions;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Ngap_GlobalRANNodeID_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_Ngap_GlobalRANNodeID;
extern asn_CHOICE_specifics_t asn_SPC_Ngap_GlobalRANNodeID_specs_1;
extern asn_TYPE_member_t asn_MBR_Ngap_GlobalRANNodeID_1[4];
extern asn_per_constraints_t asn_PER_type_Ngap_GlobalRANNodeID_constr_1;
#ifdef __cplusplus
}
#endif
#endif /* _Ngap_GlobalRANNodeID_H_ */
#include <asn_internal.h>
| 27.919355 | 89 | 0.822646 |
b32996f8d4542849febefd7795a274b8b5d0d955 | 592 | h | C | components/viz/common/gpu/context_lost_observer.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | components/viz/common/gpu/context_lost_observer.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | components/viz/common/gpu/context_lost_observer.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941 | 2015-01-02T11:32:21.000Z | 2022-03-31T16:35:46.000Z | // Copyright 2017 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 COMPONENTS_VIZ_COMMON_GPU_CONTEXT_LOST_OBSERVER_H_
#define COMPONENTS_VIZ_COMMON_GPU_CONTEXT_LOST_OBSERVER_H_
namespace viz {
// Observers a ContextProvider and is notified when the context is lost.
class ContextLostObserver {
public:
virtual void OnContextLost() = 0;
protected:
virtual ~ContextLostObserver() = default;
};
} // namespace viz
#endif // COMPONENTS_VIZ_COMMON_GPU_CONTEXT_LOST_OBSERVER_H_
| 26.909091 | 73 | 0.795608 |
cad9ad4815fab6fbfd7a85d22ec6ede536923b0d | 1,104 | c | C | libft/ft_strcat.c | vpopovyc/nm_otool | a4b6069efe6c403626676a70b51b1c32286228df | [
"MIT"
] | null | null | null | libft/ft_strcat.c | vpopovyc/nm_otool | a4b6069efe6c403626676a70b51b1c32286228df | [
"MIT"
] | null | null | null | libft/ft_strcat.c | vpopovyc/nm_otool | a4b6069efe6c403626676a70b51b1c32286228df | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vpopovyc <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/22 19:38:58 by vpopovyc #+# #+# */
/* Updated: 2016/12/02 14:43:52 by vpopovyc ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/libft.h"
char *ft_strcat(char *s1, const char *s2)
{
char *beer;
beer = s1;
beer = beer + ft_strlen(s1);
while (*s2)
{
*beer = *s2;
beer++;
s2++;
}
*beer = '\0';
return (s1);
}
| 36.8 | 80 | 0.190217 |
23e5b015d5cd85c6e2f534f632b05bdbe1d833b5 | 2,060 | h | C | Utilities/RIUtility.h | hardcao/scanCode | ddc0e1516e2fd3e15ccafbe19813e2cca4fc2811 | [
"MIT"
] | null | null | null | Utilities/RIUtility.h | hardcao/scanCode | ddc0e1516e2fd3e15ccafbe19813e2cca4fc2811 | [
"MIT"
] | null | null | null | Utilities/RIUtility.h | hardcao/scanCode | ddc0e1516e2fd3e15ccafbe19813e2cca4fc2811 | [
"MIT"
] | null | null | null | //
// RIUtility.h
// studyBase
//
// Created by renren on 14-1-22.
// Copyright (c) 2014年 renren. All rights reserved.
//
#import <AssetsLibrary/AssetsLibrary.h>
extern NSString * const kEmotionPlistName;
@class MPlacePOIInfo, NSFetchRequest, SDImageCache;
@interface RIUtility : NSObject
+ (NSString *)documentDirectory;
+ (NSString *)commonDirectory;
+ (NSString *)emotionDictory;
+ (NSString *)backgroundImageDictory;
+ (NSString *)backgroundThumbnailImageDictory;
+ (NSString *)backgroundOriginalImageDictory;
+ (NSString *)filterSampleImageDirectory;
+ (NSString *)absolutePathForResourcePath:(NSString *)path;
+ (NSString *)relativePathForResourcePath:(NSString *)path;
+ (SDImageCache *)chatImageCache;
+ (NSString *)saveResouceData:(NSData *)data;
+ (NSString *)userDirectoryForUserID:(NSNumber *)userID;
+ (NSString *)signature:(NSDictionary *)parameters secretKey:(NSString*)secretKey;
+ (NSMutableArray *)mergeArray:(NSArray *)aArray intoArray:(NSArray *)bArray uniqueKeyPath:(NSString *)keyPath;
+ (void)cleanCacheWithFetchRequest:(NSFetchRequest *)fetchRequest reservedData:(NSArray *)array;
+ (void)replaceCacheWithManagedObjectArray:(NSArray *)newArray;
+ (NSString *)requestStringForParametersWithSecretKey:(NSDictionary *)parameters;
+ (void)copyEmotionPlistToLocalDiskWhenAppFirstRun;
+ (NSBundle *)emotionBundle;
+ (NSBundle *)defaultBackgroundImageBundle;
+ (NSBundle *)defaultBackgroundThumbnailImageBundle;
+ (NSBundle *)defaultBackgroundOriginalImageBundle;
+ (NSString *)errorStringForCode:(NSString *)errorCode;
+ (NSString *)networkUnreachableString;
//根据userid获取头像url,目前主要用于服务器没下发的原作者头像
+ (NSString *)headURLByUserID:(NSNumber *)userID;
+ (NSString *)headURLByJabberID:(NSString *)jabberID;
+ (id)objectFromPlist:(NSString *)pilstName;
//数据持久化
+ (BOOL)saveToPersistence;
+ (id)insertNewObjectForEntityForName:(NSString *)entityName;
//拼装讨论组头像
+ (void)constructMucGroupHeadImageWithHeadURLs:(NSArray *)headURLs imageView:(UIImageView *)imageView;
//单队列操作数据的删除,解析
+ (dispatch_queue_t)serialManagedObjectOperateQueue;
@end
| 36.140351 | 111 | 0.78835 |
9b1e924402488b8459c73a5db149d9863caf09e7 | 2,857 | h | C | Sources/Elastos/Frameworks/Droid/WebView/Chromium/inc/elastos/droid/webview/chromium/native/ui/ColorPickerMoreButton.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 7 | 2017-07-13T10:34:54.000Z | 2021-04-16T05:40:35.000Z | Sources/Elastos/Frameworks/Droid/WebView/Chromium/inc/elastos/droid/webview/chromium/native/ui/ColorPickerMoreButton.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | null | null | null | Sources/Elastos/Frameworks/Droid/WebView/Chromium/inc/elastos/droid/webview/chromium/native/ui/ColorPickerMoreButton.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 9 | 2017-07-13T12:33:20.000Z | 2021-06-19T02:46:48.000Z | //=========================================================================
// Copyright (C) 2012 The Elastos Open Source Project
//
// 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.
//=========================================================================
// Copyright 2013 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 _ELASTOS_DROID_WEBKIT_WEBVIEW_CHROMIUM_UI_COLORPICKERMOREBUTTON_H_
#define _ELASTOS_DROID_WEBKIT_WEBVIEW_CHROMIUM_UI_COLORPICKERMOREBUTTON_H_
#include "elastos/droid/ext/frameworkext.h"
#include "elastos/droid/widget/Button.h"
#include <elastos/core/Object.h>
// package org.chromium.ui;
// import android.content.Context;
// import android.graphics.Canvas;
// import android.graphics.Color;
// import android.graphics.Paint;
// import android.util.AttributeSet;
// import android.widget.Button;
using Elastos::Droid::Content::IContext;
using Elastos::Droid::Graphics::ICanvas;
using Elastos::Droid::Graphics::IPaint;
using Elastos::Droid::Utility::IAttributeSet;
using Elastos::Droid::Widget::Button;
namespace Elastos {
namespace Droid {
namespace Webkit {
namespace Webview {
namespace Chromium {
namespace Ui {
/**
* Simple class that draws a white border around a button, purely for a UI change.
*/
class ColorPickerMoreButton
: public Button
{
public:
ColorPickerMoreButton(
/* [in] */ IContext* context,
/* [in] */ IAttributeSet* attrs);
ColorPickerMoreButton(
/* [in] */ IContext* context,
/* [in] */ IAttributeSet* attrs,
/* [in] */ Int32 defStyle);
/**
* Sets up the paint to use for drawing the border.
*/
virtual CARAPI Init();
protected:
/**
* Draws the border around the edge of the button.
*
* @param canvas The canvas to draw on.
*/
// @Override
CARAPI_(void) OnDraw(
/* [in] */ ICanvas* canvas);
private:
// A cache for the paint used to draw the border, so it doesn't have to be created in
// every onDraw() call.
AutoPtr<IPaint> mBorderPaint;
};
} // namespace Ui
} // namespace Chromium
} // namespace Webview
} // namespace Webkit
} // namespace Droid
} // namespace Elastos
#endif // _ELASTOS_DROID_WEBKIT_WEBVIEW_CHROMIUM_UI_COLORPICKERMOREBUTTON_H_
| 30.073684 | 89 | 0.674134 |
88cd1b7fa2ead7afc19f83f434b2f39a89a47aa0 | 1,588 | h | C | libc/kernel/arch-arm/asm/smp.h | cfriedt/bionic | d65ab1d9017fe191208974be49aa244688177e26 | [
"BSD-2-Clause"
] | 18 | 2015-06-28T23:08:40.000Z | 2021-11-19T17:55:25.000Z | libc/kernel/arch-arm/asm/smp.h | cfriedt/bionic | d65ab1d9017fe191208974be49aa244688177e26 | [
"BSD-2-Clause"
] | 1 | 2015-12-05T14:20:14.000Z | 2015-12-05T14:20:14.000Z | libc/kernel/arch-arm/asm/smp.h | cfriedt/bionic | d65ab1d9017fe191208974be49aa244688177e26 | [
"BSD-2-Clause"
] | 4 | 2017-12-19T12:22:07.000Z | 2022-01-25T16:07:47.000Z | /****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
*** To edit the content of this header, modify the corresponding
*** source file (e.g. under external/kernel-headers/original/) then
*** run bionic/libc/kernel/tools/update_all.py
***
*** Any manual change here will be lost the next time this script will
*** be run. You've been warned!
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ARM_SMP_H
#define __ASM_ARM_SMP_H
#include <linux/threads.h>
#include <linux/cpumask.h>
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#include <linux/thread_info.h>
#include <asm/arch/smp.h>
#error "<asm-arm/smp.h> included in non-SMP build"
#define raw_smp_processor_id() (current_thread_info()->cpu)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define PROC_CHANGE_PENALTY 15
struct seq_file;
struct secondary_data {
unsigned long pgdir;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
void *stack;
};
#endif
| 42.918919 | 78 | 0.583753 |
f047bd805870e22b89a2398416a4592455bf17eb | 14,742 | c | C | tools/font/build/single_font_files/u8g2_font_osr18_tf.c | Linghhh/u8g2 | ba733c51a607c32c0f041496ba9929f3a9f6eccd | [
"BSD-2-Clause"
] | 4 | 2019-12-31T19:39:21.000Z | 2021-10-17T19:32:18.000Z | tools/font/build/single_font_files/u8g2_font_osr18_tf.c | Linghhh/u8g2 | ba733c51a607c32c0f041496ba9929f3a9f6eccd | [
"BSD-2-Clause"
] | 35 | 2019-10-26T12:44:43.000Z | 2021-10-02T17:40:13.000Z | tools/font/build/single_font_files/u8g2_font_osr18_tf.c | Linghhh/u8g2 | ba733c51a607c32c0f041496ba9929f3a9f6eccd | [
"BSD-2-Clause"
] | 1 | 2020-12-16T10:31:52.000Z | 2020-12-16T10:31:52.000Z | /*
Fontname: -FreeType-Old Standard TT-Medium-R-Normal--26-260-72-72-P-138-ISO10646-1
Copyright: Copyright (C) 2006-2008 Alexey Kryukov <alexios@thessalonica.org.ru>
Glyphs: 191/1456
BBX Build Mode: 0
*/
const uint8_t u8g2_font_osr18_tf[5943] U8G2_FONT_SECTION("u8g2_font_osr18_tf") =
"\277\0\4\3\5\5\4\5\6\34 \377\371\22\372\23\374\3\201\7\336\27\32 \6\0 <\1!\14C"
"*<\341\1EH~t \42\14\246hWA\204\23\211\220\10\0#*N*\224+(\60(\60("
"\60(\60(\346\340(aP`P`P`P\234P\320\301MP`P`P`P`P\24\0$"
"\65\253\352{)$.$\314(\42$\42$\27!Y\204\244\220\10I\241\42$\212\42\314U\310TH"
"DEH\10EH\310H\222\221\24!\22!\21Af!\61\0%\67R*\264e\62(&.HF"
"*JF*JF(LF&NF&\60&\351P<D\220h\214\210`\210P\134\214\220T\220\252"
" EQBBa\62A\201$\0&\61R&\244\213:(V(V(VFv$\232\36@\350\210"
"J,DJ*H(Jh&HL$JnLnl\214&DJb$\306\210\4\0'\11\242h"
"\77\341 \42\0(\24\346.S)\221P\252 \241\250\374J*\225TX\224\2)\27\346&K#,"
"J*J*\225T>\22\212J\24\25\224H\10\0*\31J)vIPHD\204$d$\42Bj"
"\212bB$dHP\10\0+\60\266f\303\67\36,\36,\36,\36,\36,\36,\36,\36,\36"
",\364\340Al<X<X<X<X<X<X<X<X<X(\0,\15\3);A\302"
"$EHD\10\0-\7'\250]\341\0.\10c(<\341@\0/\30\10\253b/Y\134\262\270d"
"bqabq\311\342\222\305%\213K\7\60\34L&|\211.H(,FLD.B\220\77\224\220"
"\13\21\223\11\213\12\22#\2\61\16I.|)\60N\250N\377\217\16\4\62\27J*t\207Hf\42"
"\214n\256\312H$JN\273\300\354\346\16\36\63\34K*|\305H\211\230\304\224\4\221\244B\241ZQ"
"\25bVVd\42QB\66\0\64\34L*|/T\345 a\204\134\210\230\210X\214T\220FQB"
"\7t\242\332\35\10\65\36K*|CJ\344 \306*\64\213\42\65a\42a\223*\304\254\252$\304D"
"\242\204\212\0\66\42K*|\211L&H*DJDJ$R\11\215D\314\304\224\304\224Y\63\11\251"
"\11)\31e\64\0\67\24J.|\341Cu\221\201\221\201\201\352\4\345\310\270\233\1\70 L*\204\307"
"JhDLB\220\260\316,\244&\312J\302D\312\256\220\241\204\230\310\220\224\15\0\71$K*|\207"
"LF\225\304\224\204\134\204\34\263\11\251\211\231\10\31\22I\311\20)\21)\221\260\230\250\250\42\0:\13"
"\203)<\341@\36\346@\0;\21\4*C\341\240\36L\342 &ILH\10\0<\60\264j\303\37"
"F\36B\36B\36B\36B\36b\36`\36`\36B\36B\36D\36J\36J\36h\36h\36h\36"
"H\36J\36J\36J\36*\0=\14\326$\305\341\203x\274>x\20>\61\264j\303A\36J\36J"
"\36J\36J\36h\36h\36h\36H\36J\36H\36B\36B\36b\36`\36`\36B\36B\36B"
"\36B\36$\36\10\0\77\33I*d\245&H\42l\254HBHL\263\70\271\230\240\230\250y\200\261"
"\65\0@\66R&\244\355RN,JB\42(Hd$\221\222\64RA\62SA\62Cj\244\204d"
"\244\242d\204\204\42b\204\204\42bDh\322\314\20\311\203\304\303\310I\236\1A(R*\244\61\36D"
"\36`\36`\36\200\272:D:dVd\66H\66hRh\362@Pl.P.PLp\346A\0"
"B+O&\214\341\240LlHNHPFPFPFNHL\352 NLJNHPFPF"
"PFPFNHl\342\240\6\0C!N*\224\213(FHB$\216BpB\222\224vX\267\21"
"\242\21\242!\221\61rBRrE\0D+Q&\244\341\240PNLPJRHRHTFTF"
"TFTFTFTFTFTFRHRHPJN\346\240\12\0E,O&\224\341A\214\240"
"\214d\214d\214d\214TL\214T\234\220\334A\234\220\234T\234T\234TL\214d\214d\214\240\214\334"
"\301\1\1F%O&\214\341A\214\240\214d\214d\214d\214TL\214T\234\220\334A\234\220\234T\234"
"T\234T\234\264\266w\0G+P*\234\213&LH\42*nHPH\62f\62F\134\331\301\244\214"
"\244\214\244\214\244\220\240\220\334T\134DXTH\134M\14\0H.R&\244\341 \344 FPLP"
"LPLPLPLPLP\354\240LPLPLPLPLPLPLPLP\346 \344 "
"\0I\15H&T\341 FL\377\277\71\10J\25L&t\353NT\377\221\32\32\231!\31)\241 "
"\261*\0K.Q&\234\341 \344FnJ.N,P*R(T&VdT\42BtdRH"
"RhPjNjNlLlLn\344 \342 \0L\30O&\214\341 TZ\377e\214d\214d"
"\214\240\214\240\214\334\301\1\1MCT&\264\301\320fp\214,B\214,B,B,B,b*B"
",b(D,D(D,d&D,d$F,F$F,F$F,\206H,hH,h"
"H,hHJ*J\346$\344 \0N\63R&\234\241\354f\60\214.\214.,b,\311TX\310"
"TX\314PX\220PX\320LX\324HX\230HX\330DX\34Y\340X\340\224\244\214a\14\0O"
"\36O*\224\253PJ\235Pd\214\244\210\244\204,\337JH\212H\312D\6\311I)\254\2P\35O"
"&\214\341\240LlHNHPFPFPFNHL\352@LZ\77=\210\3Q+\317*\223\253"
"PJ\235Pd\214\244\210\244\204,\337JH\212\310\314\310\204\304\204\310H\304P\315\214D\331D\312D"
"N\210\22\213\0R-Q&\234\341\240PLN\231\234\230\234\230\234\230\272\203H)A\251\71\61\71\61"
"\71\61\71\261\221\30\261\221\30\261\221\30\261\212\203 \12\0S&M*\204\207&FH\42DNDN"
"D\60D\60d\266\362\360$\254\42p\42\224\222\262\60\42D*$\250\6\0T\32O*\224\341\301\220"
"\20\225\324\224X\230X\230X\230X\230\264\376\351\201\14\0U+S&\254\341 \350F\64L\64L\64"
"L\64L\64L\64L\64L\64L\64L\64L\64L\64L\64NPN\60R,\330\14\0V+R"
"&\244\341 \346fPj\60N\60nLP,r*r(V(v&v$Z$z\42|\36`"
"\36`\36\42\36$\20\0WBZ&\344\341 \344\315\330\234\230\234\134\234\330\134\334\24\225\334\24U\244"
"P\210T\344L\310\214\344L\310L\254\210\214L\354D\320\204\354D\320D\264D\224D\364\30\365\330<"
"\200\234<@\240<@` \0X)R&\244\343 \342jJpJr(t&xBZ\42|\36"
"B\36b<BZb\70f\64hRj\60N\335\314\203\0Y*Q&\234\341 \306fNj.n"
",P*r(t$v\42\232\134\36@\36@\36@\36@\36@\36@\36@\370@\6\0Z%N"
"*\214\343\300blDN&n&l&NvtVvtV.f.d\60DPb\316n\342\300"
"\2\0[\14\345\356R\341F\377\377\67#\0\134\27\10\253b!.a\134\302\270\204q\31\306%\214K"
"\30\227\60.\0]\12\345\352R\241F\377\377\37^\25+i~+r\60\42.&JF(*&."
"$n\62\0_\7. s\341\1`\12\204h_AdD(\0a\37\213%l\207JF(JF"
"H(H\254fFdHDhbh\202$B\42\202d\2\0b\42K\42l\201R\237\14I\204\310"
"\14\211\14\211H\211H\211H\211H\211H\211\14\211D\304\310\204\220\0c\23\211%\134\207(\211\324\24"
";\315\42\244B\202\202H\0d!L&t\253T\257Fdd\42d\204F\244F\304D\304D\304D"
"\304D\304d\204f\204\246(\10e\26\211%d\207(FD\210\212\352\300NY\204THP\20\11\0"
"f\25I&L\211H&DFD&FN\352HN\377\352\4\0g$L\252z\207dBH\242\350"
"LDLDLdH\63\62\311\330\3\251\203\230\300\210\310\210\310\10\271\240\33\0h\37M&|\201V"
"\237PI\204H\15\11\15\251\22\222\22\222\22\222\22\222\22\222\22\222\22\261\60i\16F&Dcf("
"\36\214H\377\211\1j\21\7\237BK=\202*\375_\321\320\314\210\220\0k\37L&t\201T\337\224"
"\10E\311\204\211\304\211\304I\310M\210\211\210\311H\311\14\11MX\24l\12F&D\201H\377\177b"
"m)\223%\254\201\204fJ\42DBDh\315\42\241\31)\241\31)\241\31)\241\31)\241\31)\241"
"\31)\241\31)\241\11\27\5n\36\215%|\201\204J\42DjHhH\225\220\224\220\224\220\224\220\224"
"\220\224\220\224\210\205\1o\24\212%l\207*HDHB\214\317$\204d\202\204h\0p\42K\246r"
"\201dH\42DfHdHDJDJDJDJDJdHdF\5\221\244\356\254\0q!L"
"\246jg&F&$FhDLDLDLDLDLDLFhFh\212BT\17\15r\24"
"\211%\134\201dD\42$dDd&dLN\257l\0s\26\211%\134\243\42\225DX\204T\4Y"
"\213(\272\61*\221\12\0t\23(&T'.\231\242\33\61\375&D&D\15\5\0u\36\215!t"
"\201\206HJHJHJHJHJHJHJHhHhI\204\24\11\1v\32\215%t\301\244"
"DJH*L(L&P$P$P\42tmp\30\0w+\223%\254\301\302\242DJ*HJ"
"*Jh&L&B&N$B&N$D\42P\42F\42rftH\66J\66*\14\0x\33"
"\214%t\241\204F(j$N$prT\62B.D.F*h\204\304\0y$M\242r\301\244"
"d*J*J(N&N&N$R\42R\42rVmp`L\234L\234H\344 \0z\27\211"
"%d\341\200\210J\42H$fL\331\230P\204T\204\324\301\0{\26\346\356bI&HGC\32\205"
"LIE\11\311\314\10i\25&|\10\1\257:\341\203\1}\27\346\356ZA,JH\315\214\220Va"
"#\62B\32\15i\24#\4~\21\257$\215%\64\342N\306H\354 \42\256\2\0\240\6\0 <\1"
"\241\15C\252:\341@($\277\70\70 \242!In{+\60Y\215D\22\221\20\222\10\232\10\232\30"
"\231\30\231\230\221\24\42I$\22\225\5\246\1\243\34N*\234\261P(L*,J\261\312bCa\35"
"N\304\311\310\311D\234\14\221\0\244\30k\251|!\244$bf$.\42pR\313\210\270\20)\211\220"
"\222\0\245!O\42|\301\306dLJ,l*N(p$T$\224x\360`RZ\362`RZ\323"
"\203 \0\246\12\341\356:\341@\352@\0\247)\352\356\212\207*(\215P\214P\244\344X\304P\314H"
"\324DX\263\210\251\220\231\240\211\70IA!\231 \231\240\230\260!\0\250\11G\350_A\206F\0\251"
"\66s\346\253\257vJPR*j*F(fD$HM\204\214XLD\220X\220Z!Y!Y"
"!Y!\251 \211 \241$\62B\61\62QDQ\261qJ\317\0\252\25'i^c&\211H\320L"
"H\210H\210HDD\205\5\0\253\30Fmd%(F&\42&\42&\42&\42&\42&$&$"
"\6\0\254\11\315\344|\341\300\70\17\255\7'\250]\341\0\256\70s\346\253\257vJPR*\342*F"
"'A\62B\21B\62B\21Q\62RRuR\62aR\62Rj\244\324H\204H\4\311H\204\204H"
"\324L\310DG\305\306)=\3\257\7'\350_\341\0\260\17\347\360~e&E\224\252\210\230\230\21\0"
"\261'V\346\303\67\36,\36,\36,\36,\36,\36,\364\340Al<X<X<X<X<X"
"<X<\226\7\17\2\262\23g\351]\203$h\210F\42FH(*\321\314\201\0\263\24g\355]\203"
"$\210\206F*\204.$\206fH\202\4\0\264\12\204t_E\205D\14\0\265%nj\212ALH"
"LHLHLHLHLHL*L*,#\211\230\3\21\232\211\350ha\305\303\301\0\266\63\313"
"*s\345@\202&\244&\244&\244&\244&\244&\206&,&,&,&,&,&,&,&"
",&,&,&,&,&,&,&\4\0\267\10c\350=\341@\0\270\13\245\354Z#JH"
"\306\2\0\271\13f\355e'H\204H\77\61\272\17'i^e&\205\14\67\22!\62#\7\273\27G"
"ml)&IL&\61!\61!\61\21\61!\61\21\61!\0\274\62R.\274'\62.P\210\60N"
".P.P,RJR*H\233!\241\230\10\21\213\240\10\311\230\20\301\240\20\71\231\30\271\240\203\240"
"H\261H\251@\3\275\63q\356\263;,\62\206\60L.N.N,P,P*dHjdD("
"\42\350 \42DF.FD,N.L.LN*(YP\214\324M\64\0\276\71R.\274\203\60"
"(]\220\214T\250\220XLT\340T\354\210`\214H\220\210\214D\320H\220DL\204\14IP\204\240"
"L\210`P\210\134P\214\134\320AP\244T\250T\240\1\277\33I\246bgl=\300TLPL\234"
"\134\230f\63\22BeT\21B\61%\0\300\60\22+\244K\36B\36D\36&\36\303x\20y\200y"
"\200y\0\352\352\20\351\220Y\221\331 \331\240I)\311\3A\261\271@\271\300)\301\231\7\1\301\62\22"
"+\244\67\36B\36@\36\42\36\42\36U<\210<\300<\300<\0uu\210t\310\254\310l\220l\320"
"\244\320\344\201\240\330\134\240\134\340\224\340\314\203\0\302\63\22+\244\61\36D\36 B:F\66,\36E"
"<\210<\300<\300<\0uu\210t\310\254\310l\220l\320\244\320\344\201\240\330\134\240\134\240\230\340\314"
"\203\0\303-\362*\244m$\66\242\36\207\361 \361\20\363\0\363\0\324\325!\322!\263\42\263A\242B"
"\223B\223\7\202bsqs\201b\202\63\17\2\304,\362&\244KHTH\66(\36+y\10y\10"
"y\0r\362\10\351\220\341\220\341\30\331\240\321(I)\311\203\301\70\335M\15\312<\10\305/\21+\244"
"o:&\70&\70&z\36I<D<\300\370\352\210\341\20\341\20\331\230\321\230I!\311\250\301\3\71"
"\261\261\270\261@)\301\221\7\1\306;X\42\324\363\340 vnvP\64B\62\64B\62\211TLd"
"\210Tp\214\220p\314Al\220R!\251\320(\251\230\250\3\251\230\250\60\311\240\70\311\240\70A\31\71"
"\271\203\231\203\3\307(\16\253\222\213(FHB$\216BpB\222\224vX\267\21\242\21\242\21\222\61"
"rBRb\246\321\323\302\202\61\222T\0\310\60\17'\224+\134{d\7\7\61\202\62\222\61\222\61\222"
"\61R\61\61RqBr\7qBrRqRqR\61\61\222\61\222\61\202\62r\7\7\4\311\62\17"
"'\224UZX\70\36\331\301A\214\240\214\240\214d\214d\214TL\214T\234\220\334A\234\220\234T\234"
"T\234TL\214d\214d\214\240\214\334\301\1\1\312\65\17'\224\61zV\42TF.=\310\301A\214"
"\240\214d\214d\214d\214TL\214T\234\220\334A\234\220\234T\234T\234TL\214d\214d\214\240\214"
"\334\301\1\1\313\64\357&\224KFPF\60*\36\315\301A\214\240\214\240\214d\214d\214TL\214T"
"\234\220\334A\234\220\234T\234T\234TL\214d\214d\214\240\214\334\301\1\1\314\21\10'T#N]"
"`\354A\214\230\376\177s\20\315\21\10'TM\225T<\320A\214\230\376\177s\20\316\25\10'T)"
"LJ\42&(\42,\360 FL\377\277\71\10\317\23\350&TA\210H\42(\36\344 FL\377\277"
"\71\10\320+Q&\234\341\240PNLPJRHRHTFTFT\342NFTFTFTF"
"TFRHRHPJN\346\240\12\0\321\70\22'\234\215$\66\242\36O\312n\6\303\350\302\350\302"
"\42\306\222L\205\205L\205\305\14\205\5\11\205\5\315\204E\215\204\205\211\204\205M\204\305\221\5\216\5N"
"I\312\30\306\0\322%\17k\224gZ\134<\36 \36\270PJ\235Pd\214\244\210\244\204,\337JH"
"\212H\312D\6\311I)\254\2\323#\17k\224sXuz\340B)uB\221\61\222\42\222\22\262|"
"+!)\42)\23\31$'\245\260\12\0\324&\17+\224/zVBRF.=`\241\224:\241\310"
"\30I\21I\11Y\276\225\220\24\221\224\211\14\222\223RX\5\325$\17+\224\211&,\244\36\227\205R"
"\352\204\42c$E$%d\371VBRDR&\62HNJa\25\0\326%\17+\224)\134FP"
"F\36\313B)uB\221\61\222\42\222\22\262|+!)\42)\23\31$'\245\260\12\0\327#\20\362"
"\303\37 \42X$T(P,L\60H\64DxZE\254L\244T\234\134\224d\214l\204t\0\330"
".O*\224\253(Fh\42F\214&pD\216DLB\331\10\231\14\225\20\221\24\215\30\211\134\205\230"
"\10\235\310`\314\234L\304\220LP\25\0\331\63\23g\254M\36d\36&\36(\36\223\203\240\33\321\60"
"\321\60\321\60\321\60\321\60\321\60\321\60\321\60\321\60\321\60\321\60\321\60\321\70A\71\301H\261`\63\0"
"\332\63\23g\254W\36D\36B\36B\36\213\203\240\33\321\60\321\60\321\60\321\60\321\60\321\60\321\60\321"
"\60\321\60\321\60\321\60\321\60\321\70A\71\301H\261`\63\0\333\66\23'\254\63\36d\36@BZ("
"\36(\36\362 \350F\64L\64L\64L\64L\64L\64L\64L\64L\64L\64L\64L\64L\64"
"NPN\60R,\330\14\0\334\60\363f\254MFXF\36\67\7A\67\222b\242a\242a\242a\242"
"a\242a\242a\242a\242a\242a\242a\242a\242q\202r\202\221b\301f\0\335/\21'\234W|"
"\134<\36\355A\214\315\234\324\134\334X\240T\344P\350H\354D\64\271<\200<\200<\200<\200<\200"
"<\200<\200\360\201\14\0\336#O&\214\341 TZ\372 NLJNHPFPFPFnF"
"NHL\352@LZ\323\203\70\0\337+L&t\213LfH\215\224\214\220\242(\211\61\31)\251 "
")\31\251\21\61\21\61\21\61\21\11\31\21\11\221\21\211\30\11\22\22\0\340$K&lCRTi<"
"\24\225\214P\224\214\220P\220X\315\214\310\220\210\320\304\320\4I\204D\4\311\4\0\341#K&lO"
"pN\62=\24\225P*\31!\241 \261\232\31\221!\21)\211\241\11\222\10\211\10\32\11\0\342'K"
"&l)Tp\60$,(\36\204JF(JFH(H\254fFdHDhbh\202$B\42"
"\202d\2\0\343#+&le&\11=J*\31\241(\31!\241 \261\232\31\221!\21\241\211\241\11"
"\222\10\211\10\222\11\0\344$+&lCFHF*(\36\270*H(H\215T\214\34\321\210\314\214"
"\42\221\231\21\212\10\221\210\231\11\0\345&K&lg.&,&,&n\36\246*H(H\215T"
"\214\34\321\210\314\214\42\221\231\21\212\10\221\210\231\11\0\346%\220%\224\207\204H\206F$JHDH"
"JNJ\346\300BHNJNhlh*b$D(\204\250\4\0\347\30I\246Z\207(\211\324\24"
";\15\245B\202\202\310\2%\3\345\204H\0\350\33I&dCnN\62\36\224(FD\210\212\352\300"
"NY\204THP\20\11\0\351\32I&d/N.{\10\242\30\21!*\252\3;e\21R!A"
"A$\0\352\34I&d)Pl,$(\65Q\214\210\20\25\325\201\235\262\10\251\220\240 \22\0\353"
"\33)&dE\215\210`<\34Q\214\210\20\25\325\201\235\262\10\241\230\240 \22\0\354\17G\42DA"
"jJ.\36\206J\377\215\1\355\16F&<+HF(%\221\376\23\3\356\21(\42DGj*$"
"DH\222L\377\221\5\0\357\20'&L+B\206F\36\200J\377M\5\0\360\35J&le&H"
"BL.B*FP\312&HD\250\214\317$\204d\202\204h\0\361#-&|i$,\204\36\61"
"\11\225D\210\324\220\320\220*!)!)!)!)!)!)\21\13\3\362\31J&lCR\62"
"\64=\10U\220\210\220\204\30\237I\10\311\4\11\321\0\363\31J&lOnN.\36\230*HDH"
"B\214\317$\204d\202\204h\0\364\34J&l+Pp,$*(\36\200*HDHB\214\317$"
"\204d\202\204h\0\365\31*&l\205$&\202\36\25U\220\210\220\204\30\237I\10\311\4\11\321\0\366"
"\30*&lEF\303xP\252 \21!\11\61>\223\20\222\11\22\242\1\367\27\26\346\303s\36h\36"
"h\36\37\36<\210\307\317\347\201\346\201F\1\370\35\212%l\207$\221\210T\204TQ\4M\10I\14"
"EP\225\204\220\210\220D\10\15\0\371#M\42t'Xqt<\20\15\221\224\220\224\220\224\220\224\220"
"\224\220\224\220\224\220\320\220\320\222\10)\22\2\372\42M\42tQVT=\12\32\42)!)!)!"
")!)!)!)!\241!\241%\21R$\4\373&M\42t-V\66\42\62&.\36\216\206H"
"JHJHJHJHJHJHJHhHhI\204\24\11\1\374\42-\42tG\231\214<b"
"\242!)!)!)!)!)!)!)!\241!\241%\21R$\4\375(\15\243rStT"
"\64\36\205I\311T\224T\224P\234L\234L\234H\244D\244D\344\254\266\201\61q\62q\42\221\203\0"
"\376%\13\247rE\216Rof$$F$bD\206D\206D\244D\204d\204d\24\311D\211\204\321"
"I\352P\20\0\377*\355\242r)\235\214\230\214<\264\15\215T\224T\224P\234L\234L\334D\244D"
"\244D\344\254\332\340\300\230\270\221\70\221\310A\0\0\0\0\4\377\377\0";
| 75.989691 | 107 | 0.659408 |
bb7113f48cc996ac967e25e7708a6ab194476085 | 230 | c | C | lang/c/ForIdx.c | liuyang1/test | a4560e0c9ffd0bc054d55bbcf12a894ab5b7d417 | [
"MIT"
] | 8 | 2015-06-07T13:25:48.000Z | 2022-03-22T23:14:50.000Z | lang/c/ForIdx.c | liuyang1/test | a4560e0c9ffd0bc054d55bbcf12a894ab5b7d417 | [
"MIT"
] | 30 | 2016-01-29T01:36:41.000Z | 2018-09-19T07:01:22.000Z | lang/c/ForIdx.c | liuyang1/test | a4560e0c9ffd0bc054d55bbcf12a894ab5b7d417 | [
"MIT"
] | null | null | null | #include "stdio.h"
int main()
{
int a[] = {0, 1, 2};
unsigned int i;
for (i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
if (a[i] == 3) {
break;
}
}
printf("%d\n", i);
return 0;
}
| 15.333333 | 52 | 0.378261 |
63f1c34ff86fbd31a2cfc970df083b6d26502a98 | 4,315 | h | C | System/Library/PrivateFrameworks/VideosUI.framework/VUIScorecardView.h | lechium/tvOS130Headers | 6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd | [
"MIT"
] | 11 | 2019-11-06T04:48:48.000Z | 2022-02-09T17:48:15.000Z | System/Library/PrivateFrameworks/VideosUI.framework/VUIScorecardView.h | lechium/tvOS130Headers | 6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd | [
"MIT"
] | 1 | 2020-04-16T01:41:56.000Z | 2020-04-16T04:32:00.000Z | System/Library/PrivateFrameworks/VideosUI.framework/VUIScorecardView.h | lechium/tvOS130Headers | 6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd | [
"MIT"
] | 3 | 2019-12-22T20:17:53.000Z | 2021-01-25T09:47:49.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Tuesday, November 5, 2019 at 2:46:48 AM Mountain Standard Time
* Operating System: Version 13.0 (Build 17J586)
* Image Source: /System/Library/PrivateFrameworks/VideosUI.framework/VideosUI
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <VideosUI/VideosUI-Structs.h>
#import <UIKitCore/UIView.h>
@protocol VUIScorecardViewDelegate;
@class VUIScoreboardLayout, NSArray, UIImage;
@interface VUIScorecardView : UIView {
BOOL _didCalculatedSize;
BOOL _delegateRespondsToBackgroundImageForScorecardViewMaterial;
BOOL _delegateRespondsToBackgroundBlendModeForScoreValueInRowAtIndex;
id<VUIScorecardViewDelegate> _delegate;
VUIScoreboardLayout* _scoreboardLayout;
double _interitemSpacing;
NSArray* _rowScoreValueSizes;
NSArray* _columnWidths;
NSArray* _rowHeights;
UIImage* _darkMaterialImage;
CGSize _scorecardSize;
}
@property (assign,nonatomic) BOOL didCalculatedSize; //@synthesize didCalculatedSize=_didCalculatedSize - In the implementation block
@property (assign,nonatomic) CGSize scorecardSize; //@synthesize scorecardSize=_scorecardSize - In the implementation block
@property (assign,nonatomic) double interitemSpacing; //@synthesize interitemSpacing=_interitemSpacing - In the implementation block
@property (nonatomic,retain) NSArray * rowScoreValueSizes; //@synthesize rowScoreValueSizes=_rowScoreValueSizes - In the implementation block
@property (nonatomic,retain) NSArray * columnWidths; //@synthesize columnWidths=_columnWidths - In the implementation block
@property (nonatomic,retain) NSArray * rowHeights; //@synthesize rowHeights=_rowHeights - In the implementation block
@property (nonatomic,retain) UIImage * darkMaterialImage; //@synthesize darkMaterialImage=_darkMaterialImage - In the implementation block
@property (assign,nonatomic) BOOL delegateRespondsToBackgroundImageForScorecardViewMaterial; //@synthesize delegateRespondsToBackgroundImageForScorecardViewMaterial=_delegateRespondsToBackgroundImageForScorecardViewMaterial - In the implementation block
@property (assign,nonatomic) BOOL delegateRespondsToBackgroundBlendModeForScoreValueInRowAtIndex; //@synthesize delegateRespondsToBackgroundBlendModeForScoreValueInRowAtIndex=_delegateRespondsToBackgroundBlendModeForScoreValueInRowAtIndex - In the implementation block
@property (assign,nonatomic,__weak) id<VUIScorecardViewDelegate> delegate; //@synthesize delegate=_delegate - In the implementation block
@property (nonatomic,retain) VUIScoreboardLayout * scoreboardLayout; //@synthesize scoreboardLayout=_scoreboardLayout - In the implementation block
-(id<VUIScorecardViewDelegate>)delegate;
-(void)setDelegate:(id<VUIScorecardViewDelegate>)arg1 ;
-(CGSize)sizeThatFits:(CGSize)arg1 ;
-(void)drawRect:(CGRect)arg1 ;
-(double)interitemSpacing;
-(void)setInteritemSpacing:(double)arg1 ;
-(void)setColumnWidths:(NSArray *)arg1 ;
-(NSArray *)columnWidths;
-(void)invalidateData;
-(VUIScoreboardLayout *)scoreboardLayout;
-(void)setScoreboardLayout:(VUIScoreboardLayout *)arg1 ;
-(CGSize)_calculateMetricsOfScorecard;
-(void)_calculateColumnSpacing;
-(BOOL)didCalculatedSize;
-(void)setDidCalculatedSize:(BOOL)arg1 ;
-(CGSize)scorecardSize;
-(void)setScorecardSize:(CGSize)arg1 ;
-(NSArray *)rowScoreValueSizes;
-(void)setRowScoreValueSizes:(NSArray *)arg1 ;
-(NSArray *)rowHeights;
-(void)setRowHeights:(NSArray *)arg1 ;
-(UIImage *)darkMaterialImage;
-(void)setDarkMaterialImage:(UIImage *)arg1 ;
-(BOOL)delegateRespondsToBackgroundImageForScorecardViewMaterial;
-(void)setDelegateRespondsToBackgroundImageForScorecardViewMaterial:(BOOL)arg1 ;
-(BOOL)delegateRespondsToBackgroundBlendModeForScoreValueInRowAtIndex;
-(void)setDelegateRespondsToBackgroundBlendModeForScoreValueInRowAtIndex:(BOOL)arg1 ;
@end
| 60.774648 | 281 | 0.736964 |
63f71059df887540e0f9d124e45bc811b699e54e | 756 | h | C | src/isr.h | mjcheetham/tinyos | ac12f176c54f060de419c143e857d1bfa6e91eeb | [
"MIT"
] | 3 | 2018-10-09T16:42:36.000Z | 2020-10-12T10:40:52.000Z | src/isr.h | mjcheetham/tinyos | ac12f176c54f060de419c143e857d1bfa6e91eeb | [
"MIT"
] | 1 | 2021-02-15T11:06:46.000Z | 2021-02-15T11:08:37.000Z | src/isr.h | mjcheetham/tinyos | ac12f176c54f060de419c143e857d1bfa6e91eeb | [
"MIT"
] | 1 | 2019-10-12T10:52:47.000Z | 2019-10-12T10:52:47.000Z | #pragma once
#include "types.h"
#define IRQ0 32
#define IRQ1 33
#define IRQ2 34
#define IRQ3 35
#define IRQ4 36
#define IRQ5 37
#define IRQ6 38
#define IRQ7 39
#define IRQ8 40
#define IRQ9 41
#define IRQ10 42
#define IRQ11 43
#define IRQ12 44
#define IRQ13 45
#define IRQ14 46
#define IRQ15 47
typedef struct
{
uint32_t ds; // data segment selector
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // pushed by pusha
uint32_t int_no, err_code; // interrupt number and error code (if applicable)
uint32_t eip, cs, eflags, useresp, ss; // pushed by the processor automatically (on iret)
} registers_t;
typedef void (*isr_t)(registers_t);
void interrupt_register(uint8_t n, isr_t handler);
void interrupt_enable();
void interrupt_disable();
| 22.235294 | 90 | 0.736772 |
af9e03583b41de5db86949d09ffaec317427aa09 | 650 | c | C | src/C/struct.c | thai-dinh/calculator | 7d7c5da15feda89432ec7aa0ac7e6fd06fdaab60 | [
"BSD-3-Clause"
] | null | null | null | src/C/struct.c | thai-dinh/calculator | 7d7c5da15feda89432ec7aa0ac7e6fd06fdaab60 | [
"BSD-3-Clause"
] | null | null | null | src/C/struct.c | thai-dinh/calculator | 7d7c5da15feda89432ec7aa0ac7e6fd06fdaab60 | [
"BSD-3-Clause"
] | null | null | null | #include <stdlib.h>
#include <string.h>
#include "struct.h"
Dictionary* new_dict(unsigned size) {
Dictionary* dict = (Dictionary*) calloc(size, sizeof(Dictionary));
if (!dict) {
return NULL;
}
return dict;
}
Operator* new_operator(char* name, unsigned char arity, double (*op)(double, double)) {
Operator* operator = (Operator*) malloc(sizeof(Operator));
if (!operator) {
return NULL;
}
size_t len = strlen(name);
operator->name = (char*) malloc(len * sizeof(char));
if (!operator->name) {
free(operator);
return NULL;
}
strncpy(operator->name, name, len);
operator->arity = arity;
operator->op = op;
return operator;
}
| 19.117647 | 87 | 0.672308 |
769f23bc9b4969c56d640c7a07e6b6ab5a63cf4c | 2,297 | h | C | src/excecoes/Pilha.h | Daniel-Souto/Programacao-avancada | 5b05f61de3dd8fef2007c168de1a88f4d3a0c0fc | [
"MIT"
] | null | null | null | src/excecoes/Pilha.h | Daniel-Souto/Programacao-avancada | 5b05f61de3dd8fef2007c168de1a88f4d3a0c0fc | [
"MIT"
] | null | null | null | src/excecoes/Pilha.h | Daniel-Souto/Programacao-avancada | 5b05f61de3dd8fef2007c168de1a88f4d3a0c0fc | [
"MIT"
] | null | null | null | #ifndef _PILHA_H_
#define _PILHA_H_
#include <string>
#include <iostream>
#include <exception>
using namespace std;
class PilhaVaziaException : public exception
{
public:
virtual const char* what() const throw()
{
return "Pilha vazia!";
}
};
class PilhaCheiaException : public exception
{
public:
virtual const char* what() const throw()
{
return "Pilha cheia!";
}
};
class StringVaziaException : public exception
{
public:
virtual const char* what() const throw()
{
return "String vazia!";
}
};
class Pilha
{
public:
Pilha(int tamanho = 100)
{
_topo = -1;
_tamanho = tamanho;
_item = new string[tamanho];
}
virtual ~Pilha()
{
delete[] _item;
}
void empilha(string item)
{
if(item == "")
{
throw StringVaziaException();
}
if(_topo < _tamanho-1)
{
_topo++;
_item[_topo] = item;
}
else
{
throw PilhaCheiaException();
}
}
string desempilha()
{
if(_topo == -1)
{
throw PilhaVaziaException();
return "";
}
string item = _item[_topo];
_topo--;
return item;
}
int tamanho()
{
return _tamanho;
}
void imprime()
{
if(_topo == -1)
{
throw PilhaVaziaException();
}
else
{
cout<<endl;
for(int i = 0; i <= _topo; i++)
{
cout<<i<<" = "<<_item[i]<<" | ";
}
cout<<endl;
}
}
void operator+=(string item)
{
this->empilha(item);
}
string operator--()
{
return this->desempilha();
}
friend istream& operator>>(istream &is, Pilha &p)
{
string item;
is>>item;
p.empilha(item);
return is;
}
friend ostream& operator<<(ostream &os, Pilha &p)
{
os<<p.desempilha();
return os;
}
private:
int _topo;
string* _item;
int _tamanho;
};
#endif // _PILHA_H_
| 17.270677 | 54 | 0.449717 |
18d1a82d5f8f502b43b74165d20b907dd955c9a5 | 965 | h | C | YHPaaS/Classes/CMSPaaS.framework/Headers/CMSMenuControllerHeader.h | p2max34/YHPaaS | 23d3b90a1f446fed7953214809456cd3a1bec9f2 | [
"MIT"
] | null | null | null | YHPaaS/Classes/CMSPaaS.framework/Headers/CMSMenuControllerHeader.h | p2max34/YHPaaS | 23d3b90a1f446fed7953214809456cd3a1bec9f2 | [
"MIT"
] | null | null | null | YHPaaS/Classes/CMSPaaS.framework/Headers/CMSMenuControllerHeader.h | p2max34/YHPaaS | 23d3b90a1f446fed7953214809456cd3a1bec9f2 | [
"MIT"
] | null | null | null | //
// GMenuControllerHeader.h
// GMenuController
//
// Created by GIKI on 2017/10/19.
// Copyright © 2017年 GIKI. All rights reserved.
//
#ifndef GMenuControllerHeader_h
#define GMenuControllerHeader_h
typedef NS_ENUM(NSUInteger, CMSMenuControllerArrowDirection) {
CMSMenuControllerArrowDefault, // up or down based on screen location
CMSMenuControllerArrowUp , // Forced upward. If the screen is not displayed, Will do anchor displacement
CMSMenuControllerArrowDown , // Forced down
};
UIKIT_EXTERN NSNotificationName const CMSMenuControllerWillShowMenuNotification;
UIKIT_EXTERN NSNotificationName const CMSMenuControllerDidShowMenuNotification;
UIKIT_EXTERN NSNotificationName const CMSMenuControllerWillHideMenuNotification;
UIKIT_EXTERN NSNotificationName const CMSMenuControllerDidHideMenuNotification;
UIKIT_EXTERN NSNotificationName const CMSMenuControllerMenuFrameDidChangeNotification;
#endif /* GMenuControllerHeader_h */
| 38.6 | 115 | 0.827979 |
6349c8a92f5a29f2a22db2a1cd6b383dae68695b | 372 | h | C | src/States/Error.h | TamirPerek/worktimer | 63faceb3b89607921eebe546f7796ad6d979d213 | [
"Unlicense"
] | null | null | null | src/States/Error.h | TamirPerek/worktimer | 63faceb3b89607921eebe546f7796ad6d979d213 | [
"Unlicense"
] | null | null | null | src/States/Error.h | TamirPerek/worktimer | 63faceb3b89607921eebe546f7796ad6d979d213 | [
"Unlicense"
] | null | null | null | #pragma once
#include "State_Interface.h"
namespace State
{
class Error : public State_Interface
{
public:
~Error() noexcept final = default;
bool Apply(StateMachine &, Command &&) noexcept final;
std::string Name() const noexcept final { return "Error"; }
std::string GetCommand() const noexcept final { return ""; }
};
} | 24.8 | 68 | 0.63172 |
63b59ee15a71ea657275bf14fca52101fff5b1e4 | 8,399 | h | C | framework/modules/saf_utilities/saf_utility_complex.h | rapolasd/Spatial_Audio_Framework | 24ed0f45918b2893d2c64e3388b5f5405736da3b | [
"Intel",
"ISC"
] | 310 | 2018-05-16T19:20:06.000Z | 2022-03-30T08:52:26.000Z | framework/modules/saf_utilities/saf_utility_complex.h | rapolasd/Spatial_Audio_Framework | 24ed0f45918b2893d2c64e3388b5f5405736da3b | [
"Intel",
"ISC"
] | 20 | 2019-03-21T10:37:45.000Z | 2022-03-10T20:39:45.000Z | framework/modules/saf_utilities/saf_utility_complex.h | rapolasd/Spatial_Audio_Framework | 24ed0f45918b2893d2c64e3388b5f5405736da3b | [
"Intel",
"ISC"
] | 55 | 2018-05-18T08:59:30.000Z | 2022-03-22T18:59:33.000Z | /*
* Copyright 2016-2018 Leo McCormack
*
* 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.
*/
/**
*@addtogroup Utilities
*@{
* @file saf_utility_complex.h
* @brief Contains wrappers for handling complex numbers across both
* C99-compliant compilers and Microsoft Visual Compiler (MSVC)
* @author Leo McCormack
* @date 11.07.2016
* @license ISC
*/
#ifndef SAF_COMPLEX_H_INCLUDED
#define SAF_COMPLEX_H_INCLUDED
#if defined(__cplusplus)
# include <complex>
typedef std::complex<float> float_complex;
typedef std::complex<double> double_complex;
/*
Single-Precision Complex Operations
*/
inline float_complex cmplxf(float re, float im) {return float_complex(re, im); }
inline float_complex ccaddf(float_complex x, float_complex y) { return x + y; }
inline float_complex craddf(float_complex x, float y) { return x + y; }
inline float_complex ccsubf(float_complex x, float_complex y) { return x - y; }
inline float_complex crsubf(float_complex x, float y) { return x - y; }
inline float_complex ccmulf(float_complex x, float_complex y) { return x * y; }
inline float_complex cccmulf(float_complex x, float_complex y, float_complex z) { return x * y * z; }
inline float_complex crmulf(float_complex x, float y) { return x * y; }
inline float_complex ccdivf(float_complex x, float_complex y) { return x / y; }
inline float_complex crdivf(float_complex x, float y) { return x / y; }
/*
Double-Precision Complex Operations
*/
inline double_complex cmplx(double re, double im) {return double_complex(re, im);}
inline double_complex ccadd(double_complex x, double_complex y) { return x + y; }
inline double_complex cradd(double_complex x, double y) { return x + y; }
inline double_complex ccsub(double_complex x, double_complex y) { return x - y; }
inline double_complex crsub(double_complex x, double y) { return x - y; }
inline double_complex ccmul(double_complex x, double_complex y) { return x * y; }
inline double_complex cccmul(double_complex x, double_complex y, double_complex z) { return x * y * z; }
inline double_complex crmul(double_complex x, double y) { return x * y; }
inline double_complex ccdiv(double_complex x, double_complex y) { return x / y; }
inline double_complex crdiv(double_complex x, double y) { return x / y; }
#elif __STDC_VERSION__ >= 199901L
/* for fully C99+/C++11 compliant compilers */
# include <complex.h>
typedef float _Complex float_complex;
typedef double _Complex double_complex;
/*
Single-Precision Complex Operations
*/
float_complex cmplxf(float re, float im);
float_complex ccaddf(float_complex x, float_complex y);
float_complex craddf(float_complex x, float y);
float_complex ccsubf(float_complex x, float_complex y);
float_complex crsubf(float_complex x, float y);
float_complex ccmulf(float_complex x, float_complex y);
float_complex cccmulf(float_complex x, float_complex y, float_complex z);
float_complex crmulf(float_complex x, float y);
float_complex ccdivf(float_complex x, float_complex y);
float_complex crdivf(float_complex x, float y);
/*
Double-Precision Complex Operations
*/
double_complex cmplx(double re, double im);
double_complex ccadd(double_complex x, double_complex y);
double_complex cradd(double_complex x, double y);
double_complex ccsub(double_complex x, double_complex y);
double_complex crsub(double_complex x, double y);
double_complex ccmul(double_complex x, double_complex y);
double_complex cccmul(double_complex x, double_complex y, double_complex z);
double_complex crmul(double_complex x, double y);
double_complex ccdiv(double_complex x, double_complex y);
double_complex crdiv(double_complex x, double y);
#elif _MSC_VER >= 1900
/* for Microsoft's ancient C compiler (MS VC++ 14.0 _MSC_VER = 1900, Visual
* Studio 2015) */
# include <complex.h>
typedef _Fcomplex float_complex;
typedef _Dcomplex double_complex;
/*
Single-Precision Complex Operations
*/
inline float_complex cmplxf(float re, float im) {
float_complex z;
z._Val[0] = re; z._Val[1] = im;
return z;
}
inline float_complex ccaddf(float_complex x, float_complex y) {
float_complex z;
z._Val[0] = x._Val[0] + y._Val[0]; z._Val[1] = x._Val[1] + y._Val[1];
return z;
}
inline float_complex craddf(float_complex x, float y) {
float_complex z;
z._Val[0] = x._Val[0] + y; z._Val[1] = x._Val[1];
return z;
}
inline float_complex ccsubf(float_complex x, float_complex y) {
float_complex z;
z._Val[0] = x._Val[0] - y._Val[0]; z._Val[1] = x._Val[1] - y._Val[1];
return z;
}
inline float_complex crsubf(float_complex x, float y) {
float_complex z;
z._Val[0] = x._Val[0] - y; z._Val[1] = x._Val[1];
return z;
}
inline float_complex ccmulf(float_complex x, float_complex y) {
return _FCmulcc(x, y);
}
inline float_complex cccmulf(float_complex x, float_complex y, float_complex z) {
return _FCmulcc(_FCmulcc(x, y), z);
}
inline float_complex crmulf(float_complex x, float y) {
return _FCmulcr(x, y);
}
inline float_complex ccdivf(float_complex x, float_complex y) {
float_complex z;
z._Val[0] = (x._Val[0] * y._Val[0] + x._Val[1] * y._Val[1]) / (y._Val[0] * y._Val[0] + y._Val[1] * y._Val[1] );
z._Val[1] = (x._Val[1] * y._Val[0] - x._Val[0] * y._Val[1]) / (y._Val[0] * y._Val[0] + y._Val[1] * y._Val[1] );
return z;
}
inline float_complex crdivf(float_complex x, float y) {
float_complex z;
z._Val[0] = x._Val[0] / y;
z._Val[1] = x._Val[1] / y;
return z;
}
/*
Double-Precision Complex Operations
*/
inline double_complex cmplx(double re, double im) {
double_complex z;
z._Val[0] = re; z._Val[1] = im;
return z;
}
inline double_complex ccadd(double_complex x, double_complex y) {
double_complex z;
z._Val[0] = x._Val[0] + y._Val[0]; z._Val[1] = x._Val[1] + y._Val[1];
return z;
}
inline double_complex cradd(double_complex x, double y) {
double_complex z;
z._Val[0] = x._Val[0] + y; z._Val[1] = x._Val[1];
return z;
}
inline double_complex ccsub(double_complex x, double_complex y) {
double_complex z;
z._Val[0] = x._Val[0] - y._Val[0]; z._Val[1] = x._Val[1] - y._Val[1];
return z;
}
inline double_complex crsub(double_complex x, double y) {
double_complex z;
z._Val[0] = x._Val[0] - y; z._Val[1] = x._Val[1];
return z;
}
inline double_complex ccmul(double_complex x, double_complex y) {
return _Cmulcc(x, y);
}
inline double_complex cccmul(double_complex x, double_complex y, double_complex z) {
return _Cmulcc(_Cmulcc(x, y), z);
}
inline double_complex crmul(double_complex x, double y) {
return _Cmulcr(x, y);
}
inline double_complex ccdiv(double_complex x, double_complex y) {
double_complex z;
z._Val[0] = (x._Val[0] * y._Val[0] + x._Val[1] * y._Val[1]) / (y._Val[0] * y._Val[0] + y._Val[1] * y._Val[1]);
z._Val[1] = (x._Val[1] * y._Val[0] - x._Val[0] * y._Val[1]) / (y._Val[0] * y._Val[0] + y._Val[1] * y._Val[1]);
return z;
}
inline double_complex crdiv(double_complex x, double y) {
double_complex z;
z._Val[0] = x._Val[0] / y;
z._Val[1] = x._Val[1] / y;
return z;
}
#else
# error "SAF requires a compiler that supports the C99 standard, or MSVC version 1900 or newer"
#endif
#endif /* SAF_COMPLEX_H_INCLUDED */
/**@} */ /* doxygen addtogroup Utilities */
| 35.588983 | 116 | 0.673771 |
0ae22fb4106efa550d210ae4413732a97c5374c4 | 50,925 | h | C | cpp/platform/impl/windows/generated/winrt/impl/Windows.UI.Notifications.1.h | edwinwutw/nearby-connections | 56b7daf88dc3e36360818a2ea78875b4a2e63fec | [
"Apache-2.0"
] | null | null | null | cpp/platform/impl/windows/generated/winrt/impl/Windows.UI.Notifications.1.h | edwinwutw/nearby-connections | 56b7daf88dc3e36360818a2ea78875b4a2e63fec | [
"Apache-2.0"
] | null | null | null | cpp/platform/impl/windows/generated/winrt/impl/Windows.UI.Notifications.1.h | edwinwutw/nearby-connections | 56b7daf88dc3e36360818a2ea78875b4a2e63fec | [
"Apache-2.0"
] | null | null | null | // WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.210505.3
#ifndef WINRT_Windows_UI_Notifications_1_H
#define WINRT_Windows_UI_Notifications_1_H
#include "winrt/impl/Windows.UI.Notifications.0.h"
WINRT_EXPORT namespace winrt::Windows::UI::Notifications
{
struct __declspec(empty_bases) IAdaptiveNotificationContent :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IAdaptiveNotificationContent>
{
IAdaptiveNotificationContent(std::nullptr_t = nullptr) noexcept {}
IAdaptiveNotificationContent(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IAdaptiveNotificationContent(IAdaptiveNotificationContent const&) noexcept = default;
IAdaptiveNotificationContent(IAdaptiveNotificationContent&&) noexcept = default;
IAdaptiveNotificationContent& operator=(IAdaptiveNotificationContent const&) & noexcept = default;
IAdaptiveNotificationContent& operator=(IAdaptiveNotificationContent&&) & noexcept = default;
};
struct __declspec(empty_bases) IAdaptiveNotificationText :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IAdaptiveNotificationText>
{
IAdaptiveNotificationText(std::nullptr_t = nullptr) noexcept {}
IAdaptiveNotificationText(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IAdaptiveNotificationText(IAdaptiveNotificationText const&) noexcept = default;
IAdaptiveNotificationText(IAdaptiveNotificationText&&) noexcept = default;
IAdaptiveNotificationText& operator=(IAdaptiveNotificationText const&) & noexcept = default;
IAdaptiveNotificationText& operator=(IAdaptiveNotificationText&&) & noexcept = default;
};
struct __declspec(empty_bases) IBadgeNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBadgeNotification>
{
IBadgeNotification(std::nullptr_t = nullptr) noexcept {}
IBadgeNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IBadgeNotification(IBadgeNotification const&) noexcept = default;
IBadgeNotification(IBadgeNotification&&) noexcept = default;
IBadgeNotification& operator=(IBadgeNotification const&) & noexcept = default;
IBadgeNotification& operator=(IBadgeNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) IBadgeNotificationFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBadgeNotificationFactory>
{
IBadgeNotificationFactory(std::nullptr_t = nullptr) noexcept {}
IBadgeNotificationFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IBadgeNotificationFactory(IBadgeNotificationFactory const&) noexcept = default;
IBadgeNotificationFactory(IBadgeNotificationFactory&&) noexcept = default;
IBadgeNotificationFactory& operator=(IBadgeNotificationFactory const&) & noexcept = default;
IBadgeNotificationFactory& operator=(IBadgeNotificationFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) IBadgeUpdateManagerForUser :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBadgeUpdateManagerForUser>
{
IBadgeUpdateManagerForUser(std::nullptr_t = nullptr) noexcept {}
IBadgeUpdateManagerForUser(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IBadgeUpdateManagerForUser(IBadgeUpdateManagerForUser const&) noexcept = default;
IBadgeUpdateManagerForUser(IBadgeUpdateManagerForUser&&) noexcept = default;
IBadgeUpdateManagerForUser& operator=(IBadgeUpdateManagerForUser const&) & noexcept = default;
IBadgeUpdateManagerForUser& operator=(IBadgeUpdateManagerForUser&&) & noexcept = default;
};
struct __declspec(empty_bases) IBadgeUpdateManagerStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBadgeUpdateManagerStatics>
{
IBadgeUpdateManagerStatics(std::nullptr_t = nullptr) noexcept {}
IBadgeUpdateManagerStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IBadgeUpdateManagerStatics(IBadgeUpdateManagerStatics const&) noexcept = default;
IBadgeUpdateManagerStatics(IBadgeUpdateManagerStatics&&) noexcept = default;
IBadgeUpdateManagerStatics& operator=(IBadgeUpdateManagerStatics const&) & noexcept = default;
IBadgeUpdateManagerStatics& operator=(IBadgeUpdateManagerStatics&&) & noexcept = default;
};
struct __declspec(empty_bases) IBadgeUpdateManagerStatics2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBadgeUpdateManagerStatics2>
{
IBadgeUpdateManagerStatics2(std::nullptr_t = nullptr) noexcept {}
IBadgeUpdateManagerStatics2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IBadgeUpdateManagerStatics2(IBadgeUpdateManagerStatics2 const&) noexcept = default;
IBadgeUpdateManagerStatics2(IBadgeUpdateManagerStatics2&&) noexcept = default;
IBadgeUpdateManagerStatics2& operator=(IBadgeUpdateManagerStatics2 const&) & noexcept = default;
IBadgeUpdateManagerStatics2& operator=(IBadgeUpdateManagerStatics2&&) & noexcept = default;
};
struct __declspec(empty_bases) IBadgeUpdater :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBadgeUpdater>
{
IBadgeUpdater(std::nullptr_t = nullptr) noexcept {}
IBadgeUpdater(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IBadgeUpdater(IBadgeUpdater const&) noexcept = default;
IBadgeUpdater(IBadgeUpdater&&) noexcept = default;
IBadgeUpdater& operator=(IBadgeUpdater const&) & noexcept = default;
IBadgeUpdater& operator=(IBadgeUpdater&&) & noexcept = default;
};
struct __declspec(empty_bases) IKnownAdaptiveNotificationHintsStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IKnownAdaptiveNotificationHintsStatics>
{
IKnownAdaptiveNotificationHintsStatics(std::nullptr_t = nullptr) noexcept {}
IKnownAdaptiveNotificationHintsStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IKnownAdaptiveNotificationHintsStatics(IKnownAdaptiveNotificationHintsStatics const&) noexcept = default;
IKnownAdaptiveNotificationHintsStatics(IKnownAdaptiveNotificationHintsStatics&&) noexcept = default;
IKnownAdaptiveNotificationHintsStatics& operator=(IKnownAdaptiveNotificationHintsStatics const&) & noexcept = default;
IKnownAdaptiveNotificationHintsStatics& operator=(IKnownAdaptiveNotificationHintsStatics&&) & noexcept = default;
};
struct __declspec(empty_bases) IKnownAdaptiveNotificationTextStylesStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IKnownAdaptiveNotificationTextStylesStatics>
{
IKnownAdaptiveNotificationTextStylesStatics(std::nullptr_t = nullptr) noexcept {}
IKnownAdaptiveNotificationTextStylesStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IKnownAdaptiveNotificationTextStylesStatics(IKnownAdaptiveNotificationTextStylesStatics const&) noexcept = default;
IKnownAdaptiveNotificationTextStylesStatics(IKnownAdaptiveNotificationTextStylesStatics&&) noexcept = default;
IKnownAdaptiveNotificationTextStylesStatics& operator=(IKnownAdaptiveNotificationTextStylesStatics const&) & noexcept = default;
IKnownAdaptiveNotificationTextStylesStatics& operator=(IKnownAdaptiveNotificationTextStylesStatics&&) & noexcept = default;
};
struct __declspec(empty_bases) IKnownNotificationBindingsStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IKnownNotificationBindingsStatics>
{
IKnownNotificationBindingsStatics(std::nullptr_t = nullptr) noexcept {}
IKnownNotificationBindingsStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IKnownNotificationBindingsStatics(IKnownNotificationBindingsStatics const&) noexcept = default;
IKnownNotificationBindingsStatics(IKnownNotificationBindingsStatics&&) noexcept = default;
IKnownNotificationBindingsStatics& operator=(IKnownNotificationBindingsStatics const&) & noexcept = default;
IKnownNotificationBindingsStatics& operator=(IKnownNotificationBindingsStatics&&) & noexcept = default;
};
struct __declspec(empty_bases) INotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<INotification>
{
INotification(std::nullptr_t = nullptr) noexcept {}
INotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
INotification(INotification const&) noexcept = default;
INotification(INotification&&) noexcept = default;
INotification& operator=(INotification const&) & noexcept = default;
INotification& operator=(INotification&&) & noexcept = default;
};
struct __declspec(empty_bases) INotificationBinding :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<INotificationBinding>
{
INotificationBinding(std::nullptr_t = nullptr) noexcept {}
INotificationBinding(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
INotificationBinding(INotificationBinding const&) noexcept = default;
INotificationBinding(INotificationBinding&&) noexcept = default;
INotificationBinding& operator=(INotificationBinding const&) & noexcept = default;
INotificationBinding& operator=(INotificationBinding&&) & noexcept = default;
};
struct __declspec(empty_bases) INotificationData :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<INotificationData>
{
INotificationData(std::nullptr_t = nullptr) noexcept {}
INotificationData(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
INotificationData(INotificationData const&) noexcept = default;
INotificationData(INotificationData&&) noexcept = default;
INotificationData& operator=(INotificationData const&) & noexcept = default;
INotificationData& operator=(INotificationData&&) & noexcept = default;
};
struct __declspec(empty_bases) INotificationDataFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<INotificationDataFactory>
{
INotificationDataFactory(std::nullptr_t = nullptr) noexcept {}
INotificationDataFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
INotificationDataFactory(INotificationDataFactory const&) noexcept = default;
INotificationDataFactory(INotificationDataFactory&&) noexcept = default;
INotificationDataFactory& operator=(INotificationDataFactory const&) & noexcept = default;
INotificationDataFactory& operator=(INotificationDataFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) INotificationVisual :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<INotificationVisual>
{
INotificationVisual(std::nullptr_t = nullptr) noexcept {}
INotificationVisual(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
INotificationVisual(INotificationVisual const&) noexcept = default;
INotificationVisual(INotificationVisual&&) noexcept = default;
INotificationVisual& operator=(INotificationVisual const&) & noexcept = default;
INotificationVisual& operator=(INotificationVisual&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledTileNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledTileNotification>
{
IScheduledTileNotification(std::nullptr_t = nullptr) noexcept {}
IScheduledTileNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledTileNotification(IScheduledTileNotification const&) noexcept = default;
IScheduledTileNotification(IScheduledTileNotification&&) noexcept = default;
IScheduledTileNotification& operator=(IScheduledTileNotification const&) & noexcept = default;
IScheduledTileNotification& operator=(IScheduledTileNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledTileNotificationFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledTileNotificationFactory>
{
IScheduledTileNotificationFactory(std::nullptr_t = nullptr) noexcept {}
IScheduledTileNotificationFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledTileNotificationFactory(IScheduledTileNotificationFactory const&) noexcept = default;
IScheduledTileNotificationFactory(IScheduledTileNotificationFactory&&) noexcept = default;
IScheduledTileNotificationFactory& operator=(IScheduledTileNotificationFactory const&) & noexcept = default;
IScheduledTileNotificationFactory& operator=(IScheduledTileNotificationFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledToastNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledToastNotification>
{
IScheduledToastNotification(std::nullptr_t = nullptr) noexcept {}
IScheduledToastNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledToastNotification(IScheduledToastNotification const&) noexcept = default;
IScheduledToastNotification(IScheduledToastNotification&&) noexcept = default;
IScheduledToastNotification& operator=(IScheduledToastNotification const&) & noexcept = default;
IScheduledToastNotification& operator=(IScheduledToastNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledToastNotification2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledToastNotification2>
{
IScheduledToastNotification2(std::nullptr_t = nullptr) noexcept {}
IScheduledToastNotification2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledToastNotification2(IScheduledToastNotification2 const&) noexcept = default;
IScheduledToastNotification2(IScheduledToastNotification2&&) noexcept = default;
IScheduledToastNotification2& operator=(IScheduledToastNotification2 const&) & noexcept = default;
IScheduledToastNotification2& operator=(IScheduledToastNotification2&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledToastNotification3 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledToastNotification3>
{
IScheduledToastNotification3(std::nullptr_t = nullptr) noexcept {}
IScheduledToastNotification3(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledToastNotification3(IScheduledToastNotification3 const&) noexcept = default;
IScheduledToastNotification3(IScheduledToastNotification3&&) noexcept = default;
IScheduledToastNotification3& operator=(IScheduledToastNotification3 const&) & noexcept = default;
IScheduledToastNotification3& operator=(IScheduledToastNotification3&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledToastNotification4 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledToastNotification4>
{
IScheduledToastNotification4(std::nullptr_t = nullptr) noexcept {}
IScheduledToastNotification4(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledToastNotification4(IScheduledToastNotification4 const&) noexcept = default;
IScheduledToastNotification4(IScheduledToastNotification4&&) noexcept = default;
IScheduledToastNotification4& operator=(IScheduledToastNotification4 const&) & noexcept = default;
IScheduledToastNotification4& operator=(IScheduledToastNotification4&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledToastNotificationFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledToastNotificationFactory>
{
IScheduledToastNotificationFactory(std::nullptr_t = nullptr) noexcept {}
IScheduledToastNotificationFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledToastNotificationFactory(IScheduledToastNotificationFactory const&) noexcept = default;
IScheduledToastNotificationFactory(IScheduledToastNotificationFactory&&) noexcept = default;
IScheduledToastNotificationFactory& operator=(IScheduledToastNotificationFactory const&) & noexcept = default;
IScheduledToastNotificationFactory& operator=(IScheduledToastNotificationFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) IScheduledToastNotificationShowingEventArgs :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IScheduledToastNotificationShowingEventArgs>
{
IScheduledToastNotificationShowingEventArgs(std::nullptr_t = nullptr) noexcept {}
IScheduledToastNotificationShowingEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IScheduledToastNotificationShowingEventArgs(IScheduledToastNotificationShowingEventArgs const&) noexcept = default;
IScheduledToastNotificationShowingEventArgs(IScheduledToastNotificationShowingEventArgs&&) noexcept = default;
IScheduledToastNotificationShowingEventArgs& operator=(IScheduledToastNotificationShowingEventArgs const&) & noexcept = default;
IScheduledToastNotificationShowingEventArgs& operator=(IScheduledToastNotificationShowingEventArgs&&) & noexcept = default;
};
struct __declspec(empty_bases) IShownTileNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IShownTileNotification>
{
IShownTileNotification(std::nullptr_t = nullptr) noexcept {}
IShownTileNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IShownTileNotification(IShownTileNotification const&) noexcept = default;
IShownTileNotification(IShownTileNotification&&) noexcept = default;
IShownTileNotification& operator=(IShownTileNotification const&) & noexcept = default;
IShownTileNotification& operator=(IShownTileNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileFlyoutNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileFlyoutNotification>
{
ITileFlyoutNotification(std::nullptr_t = nullptr) noexcept {}
ITileFlyoutNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileFlyoutNotification(ITileFlyoutNotification const&) noexcept = default;
ITileFlyoutNotification(ITileFlyoutNotification&&) noexcept = default;
ITileFlyoutNotification& operator=(ITileFlyoutNotification const&) & noexcept = default;
ITileFlyoutNotification& operator=(ITileFlyoutNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileFlyoutNotificationFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileFlyoutNotificationFactory>
{
ITileFlyoutNotificationFactory(std::nullptr_t = nullptr) noexcept {}
ITileFlyoutNotificationFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileFlyoutNotificationFactory(ITileFlyoutNotificationFactory const&) noexcept = default;
ITileFlyoutNotificationFactory(ITileFlyoutNotificationFactory&&) noexcept = default;
ITileFlyoutNotificationFactory& operator=(ITileFlyoutNotificationFactory const&) & noexcept = default;
ITileFlyoutNotificationFactory& operator=(ITileFlyoutNotificationFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileFlyoutUpdateManagerStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileFlyoutUpdateManagerStatics>
{
ITileFlyoutUpdateManagerStatics(std::nullptr_t = nullptr) noexcept {}
ITileFlyoutUpdateManagerStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileFlyoutUpdateManagerStatics(ITileFlyoutUpdateManagerStatics const&) noexcept = default;
ITileFlyoutUpdateManagerStatics(ITileFlyoutUpdateManagerStatics&&) noexcept = default;
ITileFlyoutUpdateManagerStatics& operator=(ITileFlyoutUpdateManagerStatics const&) & noexcept = default;
ITileFlyoutUpdateManagerStatics& operator=(ITileFlyoutUpdateManagerStatics&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileFlyoutUpdater :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileFlyoutUpdater>
{
ITileFlyoutUpdater(std::nullptr_t = nullptr) noexcept {}
ITileFlyoutUpdater(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileFlyoutUpdater(ITileFlyoutUpdater const&) noexcept = default;
ITileFlyoutUpdater(ITileFlyoutUpdater&&) noexcept = default;
ITileFlyoutUpdater& operator=(ITileFlyoutUpdater const&) & noexcept = default;
ITileFlyoutUpdater& operator=(ITileFlyoutUpdater&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileNotification>
{
ITileNotification(std::nullptr_t = nullptr) noexcept {}
ITileNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileNotification(ITileNotification const&) noexcept = default;
ITileNotification(ITileNotification&&) noexcept = default;
ITileNotification& operator=(ITileNotification const&) & noexcept = default;
ITileNotification& operator=(ITileNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileNotificationFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileNotificationFactory>
{
ITileNotificationFactory(std::nullptr_t = nullptr) noexcept {}
ITileNotificationFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileNotificationFactory(ITileNotificationFactory const&) noexcept = default;
ITileNotificationFactory(ITileNotificationFactory&&) noexcept = default;
ITileNotificationFactory& operator=(ITileNotificationFactory const&) & noexcept = default;
ITileNotificationFactory& operator=(ITileNotificationFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileUpdateManagerForUser :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileUpdateManagerForUser>
{
ITileUpdateManagerForUser(std::nullptr_t = nullptr) noexcept {}
ITileUpdateManagerForUser(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileUpdateManagerForUser(ITileUpdateManagerForUser const&) noexcept = default;
ITileUpdateManagerForUser(ITileUpdateManagerForUser&&) noexcept = default;
ITileUpdateManagerForUser& operator=(ITileUpdateManagerForUser const&) & noexcept = default;
ITileUpdateManagerForUser& operator=(ITileUpdateManagerForUser&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileUpdateManagerStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileUpdateManagerStatics>
{
ITileUpdateManagerStatics(std::nullptr_t = nullptr) noexcept {}
ITileUpdateManagerStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileUpdateManagerStatics(ITileUpdateManagerStatics const&) noexcept = default;
ITileUpdateManagerStatics(ITileUpdateManagerStatics&&) noexcept = default;
ITileUpdateManagerStatics& operator=(ITileUpdateManagerStatics const&) & noexcept = default;
ITileUpdateManagerStatics& operator=(ITileUpdateManagerStatics&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileUpdateManagerStatics2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileUpdateManagerStatics2>
{
ITileUpdateManagerStatics2(std::nullptr_t = nullptr) noexcept {}
ITileUpdateManagerStatics2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileUpdateManagerStatics2(ITileUpdateManagerStatics2 const&) noexcept = default;
ITileUpdateManagerStatics2(ITileUpdateManagerStatics2&&) noexcept = default;
ITileUpdateManagerStatics2& operator=(ITileUpdateManagerStatics2 const&) & noexcept = default;
ITileUpdateManagerStatics2& operator=(ITileUpdateManagerStatics2&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileUpdater :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileUpdater>
{
ITileUpdater(std::nullptr_t = nullptr) noexcept {}
ITileUpdater(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileUpdater(ITileUpdater const&) noexcept = default;
ITileUpdater(ITileUpdater&&) noexcept = default;
ITileUpdater& operator=(ITileUpdater const&) & noexcept = default;
ITileUpdater& operator=(ITileUpdater&&) & noexcept = default;
};
struct __declspec(empty_bases) ITileUpdater2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ITileUpdater2>
{
ITileUpdater2(std::nullptr_t = nullptr) noexcept {}
ITileUpdater2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
ITileUpdater2(ITileUpdater2 const&) noexcept = default;
ITileUpdater2(ITileUpdater2&&) noexcept = default;
ITileUpdater2& operator=(ITileUpdater2 const&) & noexcept = default;
ITileUpdater2& operator=(ITileUpdater2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastActivatedEventArgs :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastActivatedEventArgs>
{
IToastActivatedEventArgs(std::nullptr_t = nullptr) noexcept {}
IToastActivatedEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastActivatedEventArgs(IToastActivatedEventArgs const&) noexcept = default;
IToastActivatedEventArgs(IToastActivatedEventArgs&&) noexcept = default;
IToastActivatedEventArgs& operator=(IToastActivatedEventArgs const&) & noexcept = default;
IToastActivatedEventArgs& operator=(IToastActivatedEventArgs&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastActivatedEventArgs2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastActivatedEventArgs2>
{
IToastActivatedEventArgs2(std::nullptr_t = nullptr) noexcept {}
IToastActivatedEventArgs2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastActivatedEventArgs2(IToastActivatedEventArgs2 const&) noexcept = default;
IToastActivatedEventArgs2(IToastActivatedEventArgs2&&) noexcept = default;
IToastActivatedEventArgs2& operator=(IToastActivatedEventArgs2 const&) & noexcept = default;
IToastActivatedEventArgs2& operator=(IToastActivatedEventArgs2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastCollection :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastCollection>
{
IToastCollection(std::nullptr_t = nullptr) noexcept {}
IToastCollection(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastCollection(IToastCollection const&) noexcept = default;
IToastCollection(IToastCollection&&) noexcept = default;
IToastCollection& operator=(IToastCollection const&) & noexcept = default;
IToastCollection& operator=(IToastCollection&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastCollectionFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastCollectionFactory>
{
IToastCollectionFactory(std::nullptr_t = nullptr) noexcept {}
IToastCollectionFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastCollectionFactory(IToastCollectionFactory const&) noexcept = default;
IToastCollectionFactory(IToastCollectionFactory&&) noexcept = default;
IToastCollectionFactory& operator=(IToastCollectionFactory const&) & noexcept = default;
IToastCollectionFactory& operator=(IToastCollectionFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastCollectionManager :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastCollectionManager>
{
IToastCollectionManager(std::nullptr_t = nullptr) noexcept {}
IToastCollectionManager(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastCollectionManager(IToastCollectionManager const&) noexcept = default;
IToastCollectionManager(IToastCollectionManager&&) noexcept = default;
IToastCollectionManager& operator=(IToastCollectionManager const&) & noexcept = default;
IToastCollectionManager& operator=(IToastCollectionManager&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastDismissedEventArgs :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastDismissedEventArgs>
{
IToastDismissedEventArgs(std::nullptr_t = nullptr) noexcept {}
IToastDismissedEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastDismissedEventArgs(IToastDismissedEventArgs const&) noexcept = default;
IToastDismissedEventArgs(IToastDismissedEventArgs&&) noexcept = default;
IToastDismissedEventArgs& operator=(IToastDismissedEventArgs const&) & noexcept = default;
IToastDismissedEventArgs& operator=(IToastDismissedEventArgs&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastFailedEventArgs :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastFailedEventArgs>
{
IToastFailedEventArgs(std::nullptr_t = nullptr) noexcept {}
IToastFailedEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastFailedEventArgs(IToastFailedEventArgs const&) noexcept = default;
IToastFailedEventArgs(IToastFailedEventArgs&&) noexcept = default;
IToastFailedEventArgs& operator=(IToastFailedEventArgs const&) & noexcept = default;
IToastFailedEventArgs& operator=(IToastFailedEventArgs&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotification>
{
IToastNotification(std::nullptr_t = nullptr) noexcept {}
IToastNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotification(IToastNotification const&) noexcept = default;
IToastNotification(IToastNotification&&) noexcept = default;
IToastNotification& operator=(IToastNotification const&) & noexcept = default;
IToastNotification& operator=(IToastNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotification2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotification2>
{
IToastNotification2(std::nullptr_t = nullptr) noexcept {}
IToastNotification2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotification2(IToastNotification2 const&) noexcept = default;
IToastNotification2(IToastNotification2&&) noexcept = default;
IToastNotification2& operator=(IToastNotification2 const&) & noexcept = default;
IToastNotification2& operator=(IToastNotification2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotification3 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotification3>
{
IToastNotification3(std::nullptr_t = nullptr) noexcept {}
IToastNotification3(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotification3(IToastNotification3 const&) noexcept = default;
IToastNotification3(IToastNotification3&&) noexcept = default;
IToastNotification3& operator=(IToastNotification3 const&) & noexcept = default;
IToastNotification3& operator=(IToastNotification3&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotification4 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotification4>
{
IToastNotification4(std::nullptr_t = nullptr) noexcept {}
IToastNotification4(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotification4(IToastNotification4 const&) noexcept = default;
IToastNotification4(IToastNotification4&&) noexcept = default;
IToastNotification4& operator=(IToastNotification4 const&) & noexcept = default;
IToastNotification4& operator=(IToastNotification4&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotification6 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotification6>
{
IToastNotification6(std::nullptr_t = nullptr) noexcept {}
IToastNotification6(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotification6(IToastNotification6 const&) noexcept = default;
IToastNotification6(IToastNotification6&&) noexcept = default;
IToastNotification6& operator=(IToastNotification6 const&) & noexcept = default;
IToastNotification6& operator=(IToastNotification6&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationActionTriggerDetail :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationActionTriggerDetail>
{
IToastNotificationActionTriggerDetail(std::nullptr_t = nullptr) noexcept {}
IToastNotificationActionTriggerDetail(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationActionTriggerDetail(IToastNotificationActionTriggerDetail const&) noexcept = default;
IToastNotificationActionTriggerDetail(IToastNotificationActionTriggerDetail&&) noexcept = default;
IToastNotificationActionTriggerDetail& operator=(IToastNotificationActionTriggerDetail const&) & noexcept = default;
IToastNotificationActionTriggerDetail& operator=(IToastNotificationActionTriggerDetail&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationFactory>
{
IToastNotificationFactory(std::nullptr_t = nullptr) noexcept {}
IToastNotificationFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationFactory(IToastNotificationFactory const&) noexcept = default;
IToastNotificationFactory(IToastNotificationFactory&&) noexcept = default;
IToastNotificationFactory& operator=(IToastNotificationFactory const&) & noexcept = default;
IToastNotificationFactory& operator=(IToastNotificationFactory&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationHistory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationHistory>
{
IToastNotificationHistory(std::nullptr_t = nullptr) noexcept {}
IToastNotificationHistory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationHistory(IToastNotificationHistory const&) noexcept = default;
IToastNotificationHistory(IToastNotificationHistory&&) noexcept = default;
IToastNotificationHistory& operator=(IToastNotificationHistory const&) & noexcept = default;
IToastNotificationHistory& operator=(IToastNotificationHistory&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationHistory2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationHistory2>
{
IToastNotificationHistory2(std::nullptr_t = nullptr) noexcept {}
IToastNotificationHistory2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationHistory2(IToastNotificationHistory2 const&) noexcept = default;
IToastNotificationHistory2(IToastNotificationHistory2&&) noexcept = default;
IToastNotificationHistory2& operator=(IToastNotificationHistory2 const&) & noexcept = default;
IToastNotificationHistory2& operator=(IToastNotificationHistory2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationHistoryChangedTriggerDetail :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationHistoryChangedTriggerDetail>
{
IToastNotificationHistoryChangedTriggerDetail(std::nullptr_t = nullptr) noexcept {}
IToastNotificationHistoryChangedTriggerDetail(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationHistoryChangedTriggerDetail(IToastNotificationHistoryChangedTriggerDetail const&) noexcept = default;
IToastNotificationHistoryChangedTriggerDetail(IToastNotificationHistoryChangedTriggerDetail&&) noexcept = default;
IToastNotificationHistoryChangedTriggerDetail& operator=(IToastNotificationHistoryChangedTriggerDetail const&) & noexcept = default;
IToastNotificationHistoryChangedTriggerDetail& operator=(IToastNotificationHistoryChangedTriggerDetail&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationHistoryChangedTriggerDetail2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationHistoryChangedTriggerDetail2>
{
IToastNotificationHistoryChangedTriggerDetail2(std::nullptr_t = nullptr) noexcept {}
IToastNotificationHistoryChangedTriggerDetail2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationHistoryChangedTriggerDetail2(IToastNotificationHistoryChangedTriggerDetail2 const&) noexcept = default;
IToastNotificationHistoryChangedTriggerDetail2(IToastNotificationHistoryChangedTriggerDetail2&&) noexcept = default;
IToastNotificationHistoryChangedTriggerDetail2& operator=(IToastNotificationHistoryChangedTriggerDetail2 const&) & noexcept = default;
IToastNotificationHistoryChangedTriggerDetail2& operator=(IToastNotificationHistoryChangedTriggerDetail2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationManagerForUser :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationManagerForUser>
{
IToastNotificationManagerForUser(std::nullptr_t = nullptr) noexcept {}
IToastNotificationManagerForUser(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationManagerForUser(IToastNotificationManagerForUser const&) noexcept = default;
IToastNotificationManagerForUser(IToastNotificationManagerForUser&&) noexcept = default;
IToastNotificationManagerForUser& operator=(IToastNotificationManagerForUser const&) & noexcept = default;
IToastNotificationManagerForUser& operator=(IToastNotificationManagerForUser&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationManagerForUser2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationManagerForUser2>
{
IToastNotificationManagerForUser2(std::nullptr_t = nullptr) noexcept {}
IToastNotificationManagerForUser2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationManagerForUser2(IToastNotificationManagerForUser2 const&) noexcept = default;
IToastNotificationManagerForUser2(IToastNotificationManagerForUser2&&) noexcept = default;
IToastNotificationManagerForUser2& operator=(IToastNotificationManagerForUser2 const&) & noexcept = default;
IToastNotificationManagerForUser2& operator=(IToastNotificationManagerForUser2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationManagerStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationManagerStatics>
{
IToastNotificationManagerStatics(std::nullptr_t = nullptr) noexcept {}
IToastNotificationManagerStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationManagerStatics(IToastNotificationManagerStatics const&) noexcept = default;
IToastNotificationManagerStatics(IToastNotificationManagerStatics&&) noexcept = default;
IToastNotificationManagerStatics& operator=(IToastNotificationManagerStatics const&) & noexcept = default;
IToastNotificationManagerStatics& operator=(IToastNotificationManagerStatics&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationManagerStatics2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationManagerStatics2>
{
IToastNotificationManagerStatics2(std::nullptr_t = nullptr) noexcept {}
IToastNotificationManagerStatics2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationManagerStatics2(IToastNotificationManagerStatics2 const&) noexcept = default;
IToastNotificationManagerStatics2(IToastNotificationManagerStatics2&&) noexcept = default;
IToastNotificationManagerStatics2& operator=(IToastNotificationManagerStatics2 const&) & noexcept = default;
IToastNotificationManagerStatics2& operator=(IToastNotificationManagerStatics2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationManagerStatics4 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationManagerStatics4>
{
IToastNotificationManagerStatics4(std::nullptr_t = nullptr) noexcept {}
IToastNotificationManagerStatics4(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationManagerStatics4(IToastNotificationManagerStatics4 const&) noexcept = default;
IToastNotificationManagerStatics4(IToastNotificationManagerStatics4&&) noexcept = default;
IToastNotificationManagerStatics4& operator=(IToastNotificationManagerStatics4 const&) & noexcept = default;
IToastNotificationManagerStatics4& operator=(IToastNotificationManagerStatics4&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotificationManagerStatics5 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotificationManagerStatics5>
{
IToastNotificationManagerStatics5(std::nullptr_t = nullptr) noexcept {}
IToastNotificationManagerStatics5(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotificationManagerStatics5(IToastNotificationManagerStatics5 const&) noexcept = default;
IToastNotificationManagerStatics5(IToastNotificationManagerStatics5&&) noexcept = default;
IToastNotificationManagerStatics5& operator=(IToastNotificationManagerStatics5 const&) & noexcept = default;
IToastNotificationManagerStatics5& operator=(IToastNotificationManagerStatics5&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotifier :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotifier>
{
IToastNotifier(std::nullptr_t = nullptr) noexcept {}
IToastNotifier(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotifier(IToastNotifier const&) noexcept = default;
IToastNotifier(IToastNotifier&&) noexcept = default;
IToastNotifier& operator=(IToastNotifier const&) & noexcept = default;
IToastNotifier& operator=(IToastNotifier&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotifier2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotifier2>
{
IToastNotifier2(std::nullptr_t = nullptr) noexcept {}
IToastNotifier2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotifier2(IToastNotifier2 const&) noexcept = default;
IToastNotifier2(IToastNotifier2&&) noexcept = default;
IToastNotifier2& operator=(IToastNotifier2 const&) & noexcept = default;
IToastNotifier2& operator=(IToastNotifier2&&) & noexcept = default;
};
struct __declspec(empty_bases) IToastNotifier3 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IToastNotifier3>
{
IToastNotifier3(std::nullptr_t = nullptr) noexcept {}
IToastNotifier3(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IToastNotifier3(IToastNotifier3 const&) noexcept = default;
IToastNotifier3(IToastNotifier3&&) noexcept = default;
IToastNotifier3& operator=(IToastNotifier3 const&) & noexcept = default;
IToastNotifier3& operator=(IToastNotifier3&&) & noexcept = default;
};
struct __declspec(empty_bases) IUserNotification :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IUserNotification>
{
IUserNotification(std::nullptr_t = nullptr) noexcept {}
IUserNotification(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IUserNotification(IUserNotification const&) noexcept = default;
IUserNotification(IUserNotification&&) noexcept = default;
IUserNotification& operator=(IUserNotification const&) & noexcept = default;
IUserNotification& operator=(IUserNotification&&) & noexcept = default;
};
struct __declspec(empty_bases) IUserNotificationChangedEventArgs :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IUserNotificationChangedEventArgs>
{
IUserNotificationChangedEventArgs(std::nullptr_t = nullptr) noexcept {}
IUserNotificationChangedEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
IUserNotificationChangedEventArgs(IUserNotificationChangedEventArgs const&) noexcept = default;
IUserNotificationChangedEventArgs(IUserNotificationChangedEventArgs&&) noexcept = default;
IUserNotificationChangedEventArgs& operator=(IUserNotificationChangedEventArgs const&) & noexcept = default;
IUserNotificationChangedEventArgs& operator=(IUserNotificationChangedEventArgs&&) & noexcept = default;
};
}
#endif
| 70.241379 | 177 | 0.760196 |
8d07855a22d011ef05556fed4498239a5f6311b2 | 319 | h | C | Artsy_WatchKit_Extension/App/ARWatchMenuActionController.h | TribeMedia/eigen | 8a48e793bee2acb76e49af2a9e0f5134782bd684 | [
"MIT"
] | null | null | null | Artsy_WatchKit_Extension/App/ARWatchMenuActionController.h | TribeMedia/eigen | 8a48e793bee2acb76e49af2a9e0f5134782bd684 | [
"MIT"
] | 3 | 2021-05-21T00:41:23.000Z | 2022-02-26T10:51:08.000Z | Artsy_WatchKit_Extension/App/ARWatchMenuActionController.h | TribeMedia/eigen | 8a48e793bee2acb76e49af2a9e0f5134782bd684 | [
"MIT"
] | null | null | null | #import <Foundation/Foundation.h>
#import "WatchArtwork.h"
@interface ARWatchMenuActionController : NSObject
- (void)heartArtwork:(WatchArtwork *)artwork;
- (void)unheartArtwork:(WatchArtwork *)artwork;
- (void)heartArtworkArtist:(WatchArtwork *)artwork;
- (void)unheartArtworkArtist:(WatchArtwork *)artwork;
@end
| 22.785714 | 53 | 0.780564 |
8d9200c90fde62dccd46f29a49956cdd0cfb756a | 632 | c | C | gmdtools/reuse/c/StrMemDrv.c | pahihu/SPOC | 45264b6648f644a184c5c6b4fb97707e0fa3ef51 | [
"BSD-4-Clause-UC"
] | 1 | 2020-06-13T13:55:23.000Z | 2020-06-13T13:55:23.000Z | gmdtools/reuse/c/StrMemDrv.c | pahihu/SPOC | 45264b6648f644a184c5c6b4fb97707e0fa3ef51 | [
"BSD-4-Clause-UC"
] | 1 | 2020-06-13T16:57:18.000Z | 2020-06-14T13:42:33.000Z | gmdtools/reuse/c/StrMemDrv.c | pahihu/SPOC | 45264b6648f644a184c5c6b4fb97707e0fa3ef51 | [
"BSD-4-Clause-UC"
] | null | null | null | static char rcsid [] = "$Id: StrMemDrv.c,v 1.3 1992/05/05 13:19:05 grosch rel $";
# include <stdio.h>
# include "StringMem.h"
extern int strlen ();
static void loop ()
{
char string [256];
tStringRef stringref;
(void) printf ("enter strings, one per line, - terminates\n");
do {
(void) scanf ("%s", string);
stringref = PutString (string, strlen (string));
WriteString (stdout, stringref);
(void) printf ("\n");
} while (string [0] != '-' || string [1] != '\0');
(void) printf ("\n");
WriteStringMemory ();
}
main ()
{
loop ();
InitStringMemory ();
loop ();
return 0;
}
| 20.387097 | 81 | 0.571203 |
e4622114c42692e373e8228d5e064e8227f2d48b | 5,579 | c | C | trunk/chuffed/vars/int-var-ll.c | gkgange/chuffed-cert | 3065c9cf4edd2b624ccfb2bbaf842944d020be2f | [
"MIT"
] | null | null | null | trunk/chuffed/vars/int-var-ll.c | gkgange/chuffed-cert | 3065c9cf4edd2b624ccfb2bbaf842944d020be2f | [
"MIT"
] | null | null | null | trunk/chuffed/vars/int-var-ll.c | gkgange/chuffed-cert | 3065c9cf4edd2b624ccfb2bbaf842944d020be2f | [
"MIT"
] | null | null | null | #include <chuffed/vars/int-var.h>
#include <chuffed/core/sat.h>
#include <chuffed/core/propagator.h>
// val -> (val-1)/2
IntVarLL::IntVarLL(const IntVar& other) : IntVar(other), ld(2), li(0), hi(1) {
ld[0].var = 0; ld[0].val = min-1; ld[0].prev = -1; ld[0].next = 1;
ld[1].var = 1; ld[1].val = max; ld[1].prev = 0; ld[1].next = -1;
valLit = Lit(sat.nVars(), 1);
int v = sat.newVar(1, ChannelInfo(var_id, 1, 0, 0));
sat.flags[v].setDecidable(false);
sat.flags[v].setUIPable(false);
sat.flags[v].setLearnable(false);
if (isFixed()) sat.cEnqueue(valLit, NULL);
}
DecInfo* IntVarLL::branch() {
switch (preferred_val) {
case PV_MIN: return new DecInfo(this, min, 3);
case PV_MAX: return new DecInfo(this, max-1, 2);
case PV_SPLIT_MIN: return new DecInfo(this, (max+min-1)/2, 3);
case PV_SPLIT_MAX: return new DecInfo(this, (max+min)/2, 2);
default: NEVER;
}
}
inline int IntVarLL::getLitNode() {
int i = -1;
if (freelist.size()) {
i = freelist.last(); freelist.pop();
} else {
i = ld.size(); ld.push();
}
return i;
}
void IntVarLL::freeLazyVar(int val) {
int ni;
if (val < min) {
ni = li;
while (ld[ni].val > val) { ni = ld[ni].prev; assert(0 <= ni && ni < ld.size()); }
} else if (val >= max) {
ni = hi;
while (ld[ni].val < val) { ni = ld[ni].next; assert(0 <= ni && ni < ld.size()); }
} else NEVER;
assert(ld[ni].val == val);
ld[ld[ni].prev].next = ld[ni].next;
ld[ld[ni].next].prev = ld[ni].prev;
freelist.push(ni);
}
inline Lit IntVarLL::getGELit(int v) {
if (v > max) return getMaxLit();
assert(v >= min);
int ni = li;
while (ld[ni].val < v-1) { ni = ld[ni].next; assert(0 <= ni && ni < ld.size()); }
if (ld[ni].val == v-1) return Lit(ld[ni].var, 1);
// overshot, create new var and insert before ni
int mi = getLitNode();
ld[mi].var = sat.getLazyVar(ChannelInfo(var_id, 1, 1, v-1));
ld[mi].val = v-1;
ld[mi].next = ni;
ld[mi].prev = ld[ni].prev;
ld[ni].prev = mi;
ld[ld[mi].prev].next = mi;
return Lit(ld[mi].var, 1);
}
inline Lit IntVarLL::getLELit(int v) {
if (v < min) return getMinLit();
assert(v <= max);
int ni = hi;
while (ld[ni].val > v) { ni = ld[ni].prev; assert(0 <= ni && ni < ld.size()); }
if (ld[ni].val == v) return Lit(ld[ni].var, 0);
// overshot, create new var and insert before ni
int mi = getLitNode();
ld[mi].var = sat.getLazyVar(ChannelInfo(var_id, 1, 1, v));
ld[mi].val = v;
ld[mi].prev = ni;
ld[mi].next = ld[ni].next;
ld[ni].next = mi;
ld[ld[mi].next].prev = mi;
return Lit(ld[mi].var, 0);
}
Lit IntVarLL::getLit(int64_t v, int t) {
assert(engine.decisionLevel() == 0);
if (v < min) return toLit(1^(t&1)); // _, _, 1, 0
if (v > max) return toLit(t&1); // _, _, 0, 1
switch (t) {
case 2: return getGELit(v);
case 3: return getLELit(v);
default: NEVER;
}
}
// Use when you've just set [x >= v]
inline void IntVarLL::channelMin(int v, Lit p) {
Reason r(mk_reason(~p));
int ni;
for (ni = ld[li].next; ld[ni].val < v-1; ni = ld[ni].next) {
sat.cEnqueue(Lit(ld[ni].var, 1), r);
}
assert(ld[ni].val == v-1);
li = ni;
}
// Use when you've just set [x <= v]
inline void IntVarLL::channelMax(int v, Lit p) {
Reason r(mk_reason(~p));
int ni;
for (ni = ld[hi].prev; ld[ni].val > v; ni = ld[ni].prev) {
sat.cEnqueue(Lit(ld[ni].var, 0), r);
}
assert(ld[ni].val == v);
hi = ni;
}
inline void IntVarLL::updateFixed() {
if (isFixed()) {
Reason r(mk_reason(getMinLit(), getMaxLit()));
sat.cEnqueue(valLit, r);
changes |= EVENT_F;
}
}
bool IntVarLL::setMin(int64_t v, Reason r, bool channel) {
assert(setMinNotR(v));
Lit p = getGELit(v);
if (channel) sat.cEnqueue(p, r);
if (v > max) { assert(sat.confl); return false; }
channelMin(v, p);
min = v; changes |= EVENT_C | EVENT_L;
updateFixed();
pushInQueue();
return true;
}
bool IntVarLL::setMax(int64_t v, Reason r, bool channel) {
assert(setMaxNotR(v));
Lit p = getLELit(v);
if (channel) sat.cEnqueue(p, r);
if (v < min) { assert(sat.confl); return false; }
channelMax(v, p);
max = v; changes |= EVENT_C | EVENT_U;
updateFixed();
pushInQueue();
return true;
}
bool IntVarLL::setVal(int64_t v, Reason r, bool channel) {
assert(setValNotR(v));
assert(channel);
if (setMinNotR(v)) if (!setMin(v,r,channel)) return false;
if (setMaxNotR(v)) if (!setMax(v,r,channel)) return false;
return true;
}
bool IntVarLL::remVal(int64_t v, Reason r, bool channel) {
assert(channel);
if (!engine.finished_init) NEVER;
return true;
}
Lit IntVarLL::createLit(int _v) {
int v = _v >> 2;
int s = 1 - _v%2;
int ni = 1;
while (ld[ni].val > v) { ni = ld[ni].prev; assert(0 <= ni && ni < ld.size()); }
if (ld[ni].val == v) return Lit(ld[ni].var, s);
// overshot, create new var and insert before ni
int mi = getLitNode();
ld[mi].var = sat.getLazyVar(ChannelInfo(var_id, 1, 1, v));
ld[mi].val = v;
ld[mi].prev = ni;
ld[mi].next = ld[ni].next;
ld[ni].next = mi;
ld[ld[mi].next].prev = mi;
Lit p = Lit(ld[ld[mi].next].var, 1);
Lit q = Lit(ld[ld[mi].prev].var, 0);
// printf("created var %d, ", ld[mi].var);
if (sat.value(p) == l_True) {
Clause* r = (Clause*) malloc(sizeof(Clause) + 2 * sizeof(Lit));
r->clearFlags(); r->temp_expl = 1; r->sz = 2; (*r)[1] = ~p;
int l = sat.getLevel(var(p));
sat.rtrail[l].push(r);
sat.aEnqueue(Lit(ld[mi].var, 1), r, l);
}
if (sat.value(q) == l_True) {
Clause* r = (Clause*) malloc(sizeof(Clause) + 2 * sizeof(Lit));
r->clearFlags(); r->temp_expl = 1; r->sz = 2; (*r)[1] = ~q;
int l = sat.getLevel(var(q));
sat.rtrail[l].push(r);
sat.aEnqueue(Lit(ld[mi].var, 0), r, l);
}
return Lit(ld[mi].var, s);
}
| 27.482759 | 83 | 0.602258 |
777c2b72809655c352cfaf26d60c14d0e1c0630c | 169 | h | C | engine/graphics/ImGuiWrapper.h | Shidacea/Shidacea-CPP | 19b9c4101c84384acfa4e6987911588ff58be01d | [
"MIT"
] | 1 | 2019-06-16T06:17:30.000Z | 2019-06-16T06:17:30.000Z | engine/graphics/ImGuiWrapper.h | Shidacea/Shidacea-CPP | 19b9c4101c84384acfa4e6987911588ff58be01d | [
"MIT"
] | 1 | 2020-05-02T20:17:17.000Z | 2020-05-02T20:17:17.000Z | engine/graphics/ImGuiWrapper.h | Hadeweka/Shidacea | 7cff14587dc3a203efc71cdcce7a8cd5ee770881 | [
"MIT"
] | null | null | null | #pragma once
#include "MrbWrap.h"
#include <SFML/Graphics.hpp>
#include "imgui.h"
#include "imgui-SFML.h"
void setup_ruby_imgui(mrb_state* mrb, RClass* ruby_module); | 16.9 | 59 | 0.745562 |
c4cd04cd311439a506cf1632aed886b2d3cb67fd | 2,778 | h | C | Pod/Sources/Common/TrampolineMacros.h | sanekgusev/SGVSuperMessagingProxy | 7fa2a39cf5af906d50d832ac791d5d9da1dbc916 | [
"MIT"
] | 19 | 2015-02-22T22:23:01.000Z | 2020-06-12T21:38:40.000Z | Pod/Sources/Common/TrampolineMacros.h | sanekgusev/SGVSuperMessagingProxy | 7fa2a39cf5af906d50d832ac791d5d9da1dbc916 | [
"MIT"
] | null | null | null | Pod/Sources/Common/TrampolineMacros.h | sanekgusev/SGVSuperMessagingProxy | 7fa2a39cf5af906d50d832ac791d5d9da1dbc916 | [
"MIT"
] | 1 | 2018-03-21T07:55:11.000Z | 2018-03-21T07:55:11.000Z | //
// TrampolineMacros.h
// Pods
//
// Created by Aleksandr Gusev on 29/05/16.
//
//
#pragma once
#import <sys/types.h>
// Generate function declarations for header files
#define _SGVDeclareTrampolineFuction(trampolineFunction) \
void trampolineFunction(void);
#define SGVDeclareTrampolineFuction(trampolineFunction) \
_SGVDeclareTrampolineFuction(trampolineFunction)
// Generate function definitions for implementation files
#if defined(__arm64__)
#define SGVSelfLocation x0
#define SGVSelfLocationStret x1
#define SGVIvarOffsetObjc 8
#define SGVIvarOffsetSwift 16
#define _SGVDefineTrampolineFuction(trampolineFunction, msgSendSuperFunction, selfLocation, offset) \
__attribute__((__naked__)) \
void trampolineFunction(void) { \
asm volatile ("add " #selfLocation ", " #selfLocation ", #" #offset "\n\t" \
"b " #msgSendSuperFunction "\n\t" \
: : : "x0", "x1"); \
}
#elif defined(__arm__)
#define SGVSelfLocation r0
#define SGVSelfLocationStret r1
#define SGVIvarOffsetObjc 4
#define SGVIvarOffsetSwift 8
#define _SGVDefineTrampolineFuction(trampolineFunction, msgSendSuperFunction, selfLocation, offset) \
__attribute__((__naked__)) \
void trampolineFunction(void) { \
asm volatile ("add " #selfLocation ", #" #offset "\n\t" \
"b " #msgSendSuperFunction "\n\t" \
: : : "r0", "r1"); \
}
#elif defined(__x86_64__)
#define SGVSelfLocation %%rdi
#define SGVSelfLocationStret %%rsi
#define SGVIvarOffsetObjc 8
#define SGVIvarOffsetSwift 16
#define _SGVDefineTrampolineFuction(trampolineFunction, msgSendSuperFunction, selfLocation, offset) \
__attribute__((__naked__)) \
void trampolineFunction(void) { \
asm volatile ("addq $" #offset ", " #selfLocation "\n\t" \
"jmp " #msgSendSuperFunction "\n\t" \
: : : "rsi", "rdi"); \
}
#elif defined(__i386__)
#define SGVSelfLocation 0x4(%%esp)
#define SGVSelfLocationStret 0x8(%%esp)
#define SGVIvarOffsetObjc 4
#define SGVIvarOffsetSwift 8
#define _SGVDefineTrampolineFuction(trampolineFunction, msgSendSuperFunction, selfLocation, offset) \
__attribute__((__naked__)) \
void trampolineFunction(void) { \
asm volatile ("addl $" #offset ", " #selfLocation "\n\t" \
"jmp " #msgSendSuperFunction "\n\t" \
: : : "memory"); \
}
#else
#error - Unknown arhitecture
#endif
#define SGVDefineTrampolineFuction(trampolineFunction, msgSendSuperFunction, selfLocation, offset) \
_SGVDefineTrampolineFuction(trampolineFunction, msgSendSuperFunction, selfLocation, offset)
#define _SGVDefineAddressOfTrampolineFunctionFunction(addressOfFunction, trampolineFunction) \
uintptr_t addressOfFunction(void) { \
return (uintptr_t)&trampolineFunction; \
}
#define SGVDefineAddressOfTrampolineFunctionFunction(addressOfFunction, trampolineFunction) \
_SGVDefineAddressOfTrampolineFunctionFunction(addressOfFunction, trampolineFunction)
| 28.639175 | 101 | 0.778258 |
4fbb1407b94036a36e7cc418cf0da89f4fde8314 | 765 | h | C | StarJewel/Component.h | zhonghualangcai/StarJewel | ff5823df48968dd1af29ec0707ee61a0dd03d8be | [
"Unlicense"
] | 1 | 2016-01-28T09:24:09.000Z | 2016-01-28T09:24:09.000Z | StarJewel/Component.h | zhonghualangcai/StarJewel | ff5823df48968dd1af29ec0707ee61a0dd03d8be | [
"Unlicense"
] | null | null | null | StarJewel/Component.h | zhonghualangcai/StarJewel | ff5823df48968dd1af29ec0707ee61a0dd03d8be | [
"Unlicense"
] | null | null | null | //
// Component.h
// StarJewel
//
// Created by Eric Lanz on 11/25/12.
// Copyright (c) 2012 200 Monkeys. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#define componenttype_hull 1
#define componenttype_shield 2
#define componenttype_weapon 3
@interface Component : NSObject
@property (nonatomic, readwrite) int type;
@property (nonatomic, readwrite) int hp;
@property (nonatomic, readwrite) int attack;
@property (nonatomic, readwrite) int recovery;
@property (nonatomic, readwrite) int color1;
@property (nonatomic, readwrite) int color2;
@property (nonatomic, retain) CCSprite * sprite;
- (id) initWithType:(int)type hp:(int)hp attack:(int)attack color1:(int)color1 color2:(int)color2 filename:(NSString*)filename;
@end
| 26.37931 | 127 | 0.750327 |
16105cf64cc931dd050954f9fb8edae5c6e5622e | 2,712 | h | C | src/common/sfinae_helpers.h | yuanxcoin/gyuanx-core | 4b5e0afb14d4590d5d3857001ab86ef2be2a07e2 | [
"BSD-3-Clause"
] | null | null | null | src/common/sfinae_helpers.h | yuanxcoin/gyuanx-core | 4b5e0afb14d4590d5d3857001ab86ef2be2a07e2 | [
"BSD-3-Clause"
] | null | null | null | src/common/sfinae_helpers.h | yuanxcoin/gyuanx-core | 4b5e0afb14d4590d5d3857001ab86ef2be2a07e2 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2018-2020, The Gyuanx Project
// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
// the loose definitions of types in this file are, well, loose.
//
// these helpers aren't here for absolute type certainty at compile-time,
// but rather to help with templated functions telling types apart.
namespace sfinae
{
template <typename T, typename = void>
constexpr bool is_container_like = false;
// Container-like: has a begin(), end(), and a ::value_type.
template <typename T>
constexpr bool is_container_like<T, std::void_t<
decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end()),
typename T::value_type>> = true;
template <typename T, typename = void>
constexpr bool is_map_like = false;
// Map-like: looks like a container plus has a ::key_type and ::mapped_type
template <typename T>
constexpr bool is_map_like<T, std::enable_if_t<is_container_like<T>, std::void_t<
typename T::key_type,
typename T::mapped_type>>> = true;
// List-like: looks like a container but *doesn't* look like a map
template <typename T>
constexpr bool is_list_like = is_container_like<T> && !is_map_like<T>;
} // namespace sfinae
| 42.375 | 90 | 0.75295 |
275ce4e990065f8c7f8c0f02a4f4782c45b4eb54 | 32,082 | c | C | TuneDinia/tunedinia/opencl/b+tree/kernel/kernel_gpu_opencl_wrapper_2.c | benvanwerkhoven/TuneDinia | 2817f4d0932b062c9849f163ec280ddee01d82ba | [
"BSD-3-Clause"
] | 1 | 2021-10-04T08:37:42.000Z | 2021-10-04T08:37:42.000Z | TuneDinia/tunedinia/opencl/b+tree/kernel/kernel_gpu_opencl_wrapper_2.c | benvanwerkhoven/TuneDinia | 2817f4d0932b062c9849f163ec280ddee01d82ba | [
"BSD-3-Clause"
] | null | null | null | TuneDinia/tunedinia/opencl/b+tree/kernel/kernel_gpu_opencl_wrapper_2.c | benvanwerkhoven/TuneDinia | 2817f4d0932b062c9849f163ec280ddee01d82ba | [
"BSD-3-Clause"
] | 1 | 2021-07-22T07:45:05.000Z | 2021-07-22T07:45:05.000Z | // #ifdef __cplusplus
// extern "C" {
// #endif
//========================================================================================================================================================================================================200
// INCLUDE
//========================================================================================================================================================================================================200
//======================================================================================================================================================150
// LIBRARIES
//======================================================================================================================================================150
#include <CL/cl.h> // (in directory provided to compiler) needed by OpenCL types and functions
#include <string.h> // (in directory known to compiler) needed by memset
#include <stdio.h> // (in directory known to compiler) needed by printf, stderr
//======================================================================================================================================================150
// COMMON
//======================================================================================================================================================150
#include "../common.h" // (in directory provided here)
//======================================================================================================================================================150
// UTILITIES
//======================================================================================================================================================150
#include "../util/timer/timer.h" // (in directory provided here)
#include "../util/opencl/opencl.h"
#ifdef TIMING
#include "../../util/timing.h"
#endif
//======================================================================================================================================================150
// HEADER
//======================================================================================================================================================150
#include "./kernel_gpu_opencl_wrapper_2.h" // (in directory provided here)
//========================================================================================================================================================================================================200
// FUNCTION
//========================================================================================================================================================================================================200
void
kernel_gpu_opencl_wrapper_2(knode *knodes,
long knodes_elem,
long knodes_mem,
int order,
long maxheight,
int count,
long *currKnode,
long *offset,
long *lastKnode,
long *offset_2,
int *start,
int *end,
int *recstart,
int *reclength)
{
//======================================================================================================================================================150
// CPU VARIABLES
//======================================================================================================================================================150
//Primitives for timing
#ifdef TIMING
struct timeval tv;
struct timeval tv_total_start, tv_total_end;
struct timeval tv_init_end;
struct timeval tv_h2d_start, tv_h2d_end;
struct timeval tv_d2h_start, tv_d2h_end;
struct timeval tv_kernel_start, tv_kernel_end;
struct timeval tv_mem_alloc_start, tv_mem_alloc_end;
struct timeval tv_close_start, tv_close_end;
float init_time = 0, mem_alloc_time = 0, h2d_time = 0, kernel_time= 0,
d2h_time = 0, close_time = 0, total_time = 0;
#endif
#ifdef TIMING
gettimeofday(&tv_total_start, NULL);
#endif
//======================================================================================================================================================150
// GPU SETUP
//======================================================================================================================================================150
//====================================================================================================100
// INITIAL DRIVER OVERHEAD
//====================================================================================================100
// cudaThreadSynchronize();
//====================================================================================================100
// COMMON VARIABLES
//====================================================================================================100
// common variables
cl_int error;
//====================================================================================================100
// GET PLATFORMS (Intel, AMD, NVIDIA, based on provided library), SELECT ONE
//====================================================================================================100
// Get the number of available platforms
cl_uint num_platforms;
error = clGetPlatformIDs( 0,
NULL,
&num_platforms);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
// Get the list of available platforms
cl_platform_id *platforms = (cl_platform_id *)malloc(sizeof(cl_platform_id) * num_platforms);
error = clGetPlatformIDs( num_platforms,
platforms,
NULL);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
// Select the 1st platform
cl_platform_id platform = platforms[platform_id_inuse];
// Get the name of the selected platform and print it (if there are multiple platforms, choose the first one)
char pbuf[100];
error = clGetPlatformInfo( platform,
CL_PLATFORM_VENDOR,
sizeof(pbuf),
pbuf,
NULL);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
printf("Platform: %s\n", pbuf);
//====================================================================================================100
// GET DEVICE INFORMATION
//====================================================================================================100
cl_uint devices_size;
error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 0, NULL, &devices_size);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
if (devices_size == 0) {
printf("There are no devices for Platform %d\n", platform_id_inuse);
exit(0);
}
printf("Device num: %u\n", devices_size);
// Get the list of devices (previousely selected for the context)
cl_device_id *devices = (cl_device_id *) malloc(devices_size);
error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, devices_size,
devices, NULL);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
// Select the device
cl_device_id device;
device = devices[device_id_inuse];
// Check device type
error = clGetDeviceInfo(device, CL_DEVICE_TYPE,
sizeof(device_type), (void *)&device_type, NULL);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
if(device_type == CL_DEVICE_TYPE_GPU)
printf("Creating GPU Context\n");
else if (device_type == CL_DEVICE_TYPE_CPU)
printf("Creating CPU Context\n");
else
printf("This Context Type Not Supported\n");
// Get the name of the selected device
error = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(pbuf),
pbuf, NULL);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
printf("Device: %s\n", pbuf);
//====================================================================================================100
// CREATE CONTEXT FOR THE PLATFORM
//====================================================================================================100
// Create context properties for selected platform
cl_context_properties context_properties[3] = { CL_CONTEXT_PLATFORM,
(cl_context_properties) platform,
0};
// Create context for selected platform being GPU
cl_context context;
context = clCreateContextFromType( context_properties,
device_type,
NULL,
NULL,
&error);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//====================================================================================================100
// CREATE COMMAND QUEUE FOR THE DEVICE
//====================================================================================================100
// Create a command queue
cl_command_queue command_queue;
#ifdef TIMING
command_queue = clCreateCommandQueue(context, device,
CL_QUEUE_PROFILING_ENABLE, &error);
#else
command_queue = clCreateCommandQueue(context, device, 0, &error);
#endif
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//====================================================================================================100
// CREATE PROGRAM, COMPILE IT
//====================================================================================================100
// Load kernel source code from file
const char *source = load_kernel_source("./kernel/kernel_gpu_opencl_2.cl");
size_t sourceSize = strlen(source);
// Create the program
cl_program program = clCreateProgramWithSource( context,
1,
&source,
&sourceSize,
&error);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
char clOptions[110];
// sprintf(clOptions,"-I../../src");
sprintf(clOptions,"-I./../");
#ifdef DEFAULT_ORDER_2
sprintf(clOptions + strlen(clOptions), " -DDEFAULT_ORDER_2=%d", DEFAULT_ORDER_2);
#endif
// Compile the program
error = clBuildProgram( program,
1,
&device,
clOptions,
NULL,
NULL);
// Print warnings and errors from compilation
static char log[65536];
memset(log, 0, sizeof(log));
clGetProgramBuildInfo( program,
device,
CL_PROGRAM_BUILD_LOG,
sizeof(log)-1,
log,
NULL);
printf("-----OpenCL Compiler Output-----\n");
if (strstr(log,"warning:") || strstr(log, "error:"))
printf("<<<<\n%s\n>>>>\n", log);
printf("--------------------------------\n");
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
// Create kernel
cl_kernel kernel;
kernel = clCreateKernel(program,
"findRangeK",
&error);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
gettimeofday(&tv_init_end, NULL);
tvsub(&tv_init_end, &tv_total_start, &tv);
init_time = tv.tv_sec * 1000.0 + (float) tv.tv_usec / 1000.0;
#endif
//====================================================================================================100
// END
//====================================================================================================100
//======================================================================================================================================================150
// GPU MEMORY MALLOC
//======================================================================================================================================================150
//====================================================================================================100
// DEVICE IN
//====================================================================================================100
//==================================================50
// knodesD
//==================================================50
cl_mem knodesD;
knodesD = clCreateBuffer( context,
CL_MEM_READ_WRITE,
knodes_mem,
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// currKnodeD
//==================================================50
cl_mem currKnodeD;
currKnodeD = clCreateBuffer(context,
CL_MEM_READ_WRITE,
count*sizeof(long),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// offsetD
//==================================================50
cl_mem offsetD;
offsetD = clCreateBuffer( context,
CL_MEM_READ_WRITE,
count*sizeof(long),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// lastKnodeD
//==================================================50
cl_mem lastKnodeD;
lastKnodeD = clCreateBuffer(context,
CL_MEM_READ_WRITE,
count*sizeof(long),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// offset_2D
//==================================================50
cl_mem offset_2D;
offset_2D = clCreateBuffer(context,
CL_MEM_READ_WRITE,
count*sizeof(long),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// startD
//==================================================50
cl_mem startD;
startD = clCreateBuffer(context,
CL_MEM_READ_WRITE,
count*sizeof(int),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// endD
//==================================================50
cl_mem endD;
endD = clCreateBuffer( context,
CL_MEM_READ_WRITE,
count*sizeof(int),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// END
//==================================================50
//====================================================================================================100
// DEVICE IN/OUT
//====================================================================================================100
//==================================================50
// ansDStart
//==================================================50
cl_mem ansDStart;
ansDStart = clCreateBuffer( context,
CL_MEM_READ_WRITE,
count*sizeof(int),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
//==================================================50
// ansDLength
//==================================================50
cl_mem ansDLength;
ansDLength = clCreateBuffer( context,
CL_MEM_READ_WRITE,
count*sizeof(int),
NULL,
&error );
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
gettimeofday(&tv_mem_alloc_end, NULL);
tvsub(&tv_mem_alloc_end, &tv_init_end, &tv);
mem_alloc_time = tv.tv_sec * 1000.0 + (float) tv.tv_usec / 1000.0;
#endif
//==================================================50
// END
//==================================================50
//====================================================================================================100
// END
//====================================================================================================100
//======================================================================================================================================================150
// GPU MEMORY COPY
//======================================================================================================================================================150
//====================================================================================================100
// DEVICE IN
//====================================================================================================100
//==================================================50
// knodesD
//==================================================50
cl_event event;
error = clEnqueueWriteBuffer( command_queue, // command queue
knodesD, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
knodes_mem, // size to be copied
knodes, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// currKnodeD
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
currKnodeD, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(long), // size to be copied
currKnode, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// offsetD
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
offsetD, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(long), // size to be copied
offset, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// lastKnodeD
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
lastKnodeD, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(long), // size to be copied
lastKnode, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// offset_2D
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
offset_2D, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(long), // size to be copied
offset_2, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// startD
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
startD, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(int), // size to be copied
start, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// endD
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
endD, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(int), // size to be copied
end, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// END
//==================================================50
//====================================================================================================100
// DEVICE IN/OUT
//====================================================================================================100
//==================================================50
// ansDStart
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
endD, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(int), // size to be copied
end, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// ansDLength
//==================================================50
error = clEnqueueWriteBuffer( command_queue, // command queue
ansDLength, // destination
1, // block the source from access until this copy operation complates (1=yes, 0=no)
0, // offset in destination to write to
count*sizeof(int), // size to be copied
reclength, // source
0, // # of events in the list of events to wait for
NULL, // list of events to wait for
&event); // ID of this operation to be used by waiting operations
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
h2d_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// END
//==================================================50
//======================================================================================================================================================150
// KERNEL
//======================================================================================================================================================150
//====================================================================================================100
// Execution Parameters
//====================================================================================================100
size_t local_work_size[1];
local_work_size[0] = order < 1024 ? order : 1024;
size_t global_work_size[1];
global_work_size[0] = count * local_work_size[0];
printf("# of blocks = %d, # of threads/block = %d (ensure that device can handle)\n", (int)(global_work_size[0]/local_work_size[0]), (int)local_work_size[0]);
//====================================================================================================100
// Kernel Arguments
//====================================================================================================100
clSetKernelArg( kernel,
0,
sizeof(long),
(void *) &maxheight);
clSetKernelArg( kernel,
1,
sizeof(cl_mem),
(void *) &knodesD);
clSetKernelArg( kernel,
2,
sizeof(long),
(void *) &knodes_elem);
clSetKernelArg( kernel,
3,
sizeof(cl_mem),
(void *) &currKnodeD);
clSetKernelArg( kernel,
4,
sizeof(cl_mem),
(void *) &offsetD);
clSetKernelArg( kernel,
5,
sizeof(cl_mem),
(void *) &lastKnodeD);
clSetKernelArg( kernel,
6,
sizeof(cl_mem),
(void *) &offset_2D);
clSetKernelArg( kernel,
7,
sizeof(cl_mem),
(void *) &startD);
clSetKernelArg( kernel,
8,
sizeof(cl_mem),
(void *) &endD);
clSetKernelArg( kernel,
9,
sizeof(cl_mem),
(void *) &ansDStart);
clSetKernelArg( kernel,
10,
sizeof(cl_mem),
(void *) &ansDLength);
//====================================================================================================100
// Kernel
//====================================================================================================100
error = clEnqueueNDRangeKernel( command_queue,
kernel,
1,
NULL,
global_work_size,
local_work_size,
0,
NULL,
&event);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
// Wait for all operations to finish NOT SURE WHERE THIS SHOULD GO
#ifdef TIMING
kernel_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//====================================================================================================100
// END
//====================================================================================================100
//======================================================================================================================================================150
// GPU MEMORY COPY (CONTD.)
//======================================================================================================================================================150
//====================================================================================================100
// DEVICE IN/OUT
//====================================================================================================100
//==================================================50
// ansDStart
//==================================================50
error = clEnqueueReadBuffer(command_queue, // The command queue.
ansDStart, // The image on the device.
CL_TRUE, // Blocking? (ie. Wait at this line until read has finished?)
0, // Offset. None in this case.
count*sizeof(int), // Size to copy.
recstart, // The pointer to the image on the host.
0, // Number of events in wait list. Not used.
NULL, // Event wait list. Not used.
&event); // Event object for determining status. Not used.
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
d2h_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// ansDLength
//==================================================50
error = clEnqueueReadBuffer(command_queue, // The command queue.
ansDLength, // The image on the device.
CL_TRUE, // Blocking? (ie. Wait at this line until read has finished?)
0, // Offset. None in this case.
count*sizeof(int), // Size to copy.
reclength, // The pointer to the image on the host.
0, // Number of events in wait list. Not used.
NULL, // Event wait list. Not used.
&event); // Event object for determining status. Not used.
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
#ifdef TIMING
d2h_time += probe_event_time(event, command_queue);
#endif
clReleaseEvent(event);
//==================================================50
// END
//==================================================50
//====================================================================================================100
// END
//====================================================================================================100
//======================================================================================================================================================150
// GPU MEMORY DEALLOCATION
//======================================================================================================================================================150
#ifdef TIMING
gettimeofday(&tv_close_start, NULL);
#endif
// Release kernels...
clReleaseKernel(kernel);
// Now the program...
clReleaseProgram(program);
// Clean up the device memory...
clReleaseMemObject(knodesD);
clReleaseMemObject(currKnodeD);
clReleaseMemObject(offsetD);
clReleaseMemObject(lastKnodeD);
clReleaseMemObject(offset_2D);
clReleaseMemObject(startD);
clReleaseMemObject(endD);
clReleaseMemObject(ansDStart);
clReleaseMemObject(ansDLength);
// Flush the queue
error = clFlush(command_queue);
if (error != CL_SUCCESS)
fatal_CL(error, __LINE__);
// ...and finally, the queue and context.
clReleaseCommandQueue(command_queue);
// ???
clReleaseContext(context);
#ifdef TIMING
gettimeofday(&tv_close_end, NULL);
tvsub(&tv_close_end, &tv_close_start, &tv);
close_time += tv.tv_sec * 1000.0 + (float) tv.tv_usec / 1000.0;
tvsub(&tv_close_end, &tv_total_start, &tv);
total_time = tv.tv_sec * 1000.0 + (float) tv.tv_usec / 1000.0;
#endif
//======================================================================================================================================================150
// DISPLAY TIMING
//======================================================================================================================================================150
#ifdef TIMING
printf("Time spent in different stages of GPU_CUDA KERNEL:\n");
printf("Init: %f\n", init_time);
printf("MemAlloc: %f\n", mem_alloc_time);
printf("HtoD: %f\n", h2d_time);
printf("Exec: %f\n", kernel_time);
printf("DtoH: %f\n", d2h_time);
printf("Close: %f\n", close_time);
printf("Total: %f\n", total_time);
#endif
//======================================================================================================================================================150
// END
//======================================================================================================================================================150
}
//========================================================================================================================================================================================================200
// END
//========================================================================================================================================================================================================200
// #ifdef __cplusplus
// }
// #endif
| 37.966864 | 205 | 0.401378 |
5fe73e74f970d976e346b42bc4173a29e9a03830 | 1,075 | h | C | Source/UnrealExtendedFramework/AI/BTTask/Strafe/EFBTTaskStrafe.h | ElderDeveloper/UnrealExtendedFramework | 9eda70583773159f80e8bc4406a85c476d0c80e5 | [
"MIT"
] | 1 | 2022-01-13T07:21:19.000Z | 2022-01-13T07:21:19.000Z | Source/UnrealExtendedFramework/AI/BTTask/Strafe/EFBTTaskStrafe.h | ElderDeveloper/UnrealExtendedFramework | 9eda70583773159f80e8bc4406a85c476d0c80e5 | [
"MIT"
] | null | null | null | Source/UnrealExtendedFramework/AI/BTTask/Strafe/EFBTTaskStrafe.h | ElderDeveloper/UnrealExtendedFramework | 9eda70583773159f80e8bc4406a85c476d0c80e5 | [
"MIT"
] | null | null | null | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTTaskNode.h"
#include "UObject/Object.h"
#include "EFBTTaskStrafe.generated.h"
/**
*
*/
UCLASS()
class UNREALEXTENDEDFRAMEWORK_API UEFBTTaskStrafe : public UBTTaskNode
{
GENERATED_BODY()
UEFBTTaskStrafe();
public:
UPROPERTY(EditAnywhere,BlueprintReadWrite)
FBlackboardKeySelector StrafeBlackboardKey;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
float StrafeTimeMin = 1;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
float StrafeTimeMax = 2;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
bool SetOrientRotationToMovementAtFinish = true;
protected:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory);
virtual void TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override;
void FinishThisTask();
bool TaskFinished = false;
float StrafeValue = 0;
FTimerHandle TaskFinishHandle;
UPROPERTY()
UBehaviorTreeComponent* TaskOwnerComp;
};
| 23.369565 | 106 | 0.804651 |
55b6ce8b6b276179613ff2a21a7a8c1f880e807a | 1,695 | h | C | plugins/moldyn/src/io/AbstractSimpleParticleDataSource.h | xge/megamol | 1e298dd3d8b153d7468ed446f6b2ed3ac49f0d5b | [
"BSD-3-Clause"
] | null | null | null | plugins/moldyn/src/io/AbstractSimpleParticleDataSource.h | xge/megamol | 1e298dd3d8b153d7468ed446f6b2ed3ac49f0d5b | [
"BSD-3-Clause"
] | null | null | null | plugins/moldyn/src/io/AbstractSimpleParticleDataSource.h | xge/megamol | 1e298dd3d8b153d7468ed446f6b2ed3ac49f0d5b | [
"BSD-3-Clause"
] | null | null | null | /*
* AbstractSimpleParticleDataSource.h
*
* Copyright (C) 2012 by TU Dresden (CGV)
* Alle Rechte vorbehalten.
*/
#pragma once
#include "geometry_calls/MultiParticleDataCall.h"
#include "mmcore/CalleeSlot.h"
#include "mmcore/Module.h"
#include "mmcore/param/ParamSlot.h"
namespace megamol::datatools::io {
/**
* Abstract base class for simple particle loaders (single time step = no animation)
*/
class AbstractSimpleParticleDataSource : public core::Module {
public:
protected:
/** Ctor. */
AbstractSimpleParticleDataSource(void);
/** Dtor. */
virtual ~AbstractSimpleParticleDataSource(void);
/**
* Gets the data from the source.
*
* @param call The calling call.
*
* @return 'true' on success, 'false' on failure.
*/
virtual bool getData(geocalls::MultiParticleDataCall& call) = 0;
/**
* Gets the data from the source.
*
* @param call The calling call.
*
* @return 'true' on success, 'false' on failure.
*/
virtual bool getExtent(geocalls::MultiParticleDataCall& call) = 0;
/** The file name */
core::param::ParamSlot filenameSlot;
private:
/**
* Gets the data from the source.
*
* @param caller The calling call.
*
* @return 'true' on success, 'false' on failure.
*/
bool getDataCallback(core::Call& caller);
/**
* Gets the data from the source.
*
* @param caller The calling call.
*
* @return 'true' on success, 'false' on failure.
*/
bool getExtentCallback(core::Call& caller);
/** The slot for requesting data */
core::CalleeSlot getDataSlot;
};
} // namespace megamol::datatools::io
| 22.012987 | 84 | 0.635398 |
b1f95370574d3f168908a7efb74012a4edd1c0b4 | 5,452 | c | C | secure-device-access-client/secure-device-access/source/sda_nonce_mgr.c | laides/mbed-cloud-client | a90cdc723466ff50c08eebdd62fff4456c49e524 | [
"Apache-2.0"
] | null | null | null | secure-device-access-client/secure-device-access/source/sda_nonce_mgr.c | laides/mbed-cloud-client | a90cdc723466ff50c08eebdd62fff4456c49e524 | [
"Apache-2.0"
] | 1 | 2020-08-01T01:28:39.000Z | 2020-08-01T01:28:39.000Z | secure-device-access-client/secure-device-access/source/sda_nonce_mgr.c | laides/mbed-cloud-client | a90cdc723466ff50c08eebdd62fff4456c49e524 | [
"Apache-2.0"
] | 1 | 2020-07-31T18:55:20.000Z | 2020-07-31T18:55:20.000Z | // ----------------------------------------------------------------------------
// Copyright 2017-2019 ARM Ltd.
//
// 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.
// ----------------------------------------------------------------------------
#include <stdbool.h>
#include <stdint.h>
#include "sda_status.h"
#include "sda_error_handling.h"
#include "sda_nonce_mgr.h"
#include "sda_macros.h"
#include "pal.h"
/** Self describing nonce structure
* value - the nonce value
* age - the age of the nonce ranged [0 .. SDA_CYCLIC_BUFFER_MAX_SIZE] in the insertion
* time, 0 means the oldest nonce while SDA_CYCLIC_BUFFER_MAX_SIZE is the youngeset one.
*/
typedef struct {
uint64_t value;
uint8_t age;
} nonce_s;
static nonce_s g_nonce_array[SDA_CYCLIC_BUFFER_MAX_SIZE];
#define SDA_NONCE_AGE_YOUNGEST (SDA_ARRAY_LENGTH(g_nonce_array) - 1)
#define SDA_NONCE_AGE_OLDEST (0)
/** Evacuates an entry in the array.
*/
static void circ_buf_nonce_clear(nonce_s *element)
{
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
element->value = 0;
element->age = 0;
SDA_LOG_TRACE_FUNC_EXIT_NO_ARGS();
}
/** Gets oldest nonce's index in the array.
*
* - Worth case run-time - O(n)
*/
static nonce_s *circ_buf_get_oldest()
{
int i = 0;
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
while (g_nonce_array[i++].age != SDA_NONCE_AGE_OLDEST);
SDA_LOG_TRACE_FUNC_EXIT_NO_ARGS();
return &(g_nonce_array[i - 1]);
}
/** Updates the target index with the new nonce element.
*
* - The new element insert is the youngest one.
* - It updates all the nonce ages in the array due to
* the new element insertion.
* - Worth case run-time - O(n)
*/
static void circ_buf_update_ages(nonce_s *new, uint64_t nonce_new_value)
{
uint32_t i;
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
// traverse array and update age individually (if necessary)
for (i = 0; i < SDA_ARRAY_LENGTH(g_nonce_array); i++) {
if (g_nonce_array[i].age > new->age) {
g_nonce_array[i].age--;
}
}
// update array with the new one (value, age)
new->value = nonce_new_value;
new->age = SDA_NONCE_AGE_YOUNGEST;
SDA_LOG_TRACE_FUNC_EXIT_NO_ARGS();
}
void circ_buf_insert(uint64_t nonce_value)
{
nonce_s *nonce_new_p = NULL;
// traverse the circular buffer perhaps
// someone request his nonce value and
// free up some space
uint32_t i;
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
for (i = 0; i < SDA_ARRAY_LENGTH(g_nonce_array); i++) {
if (g_nonce_array[i].value == 0) {
nonce_new_p = &g_nonce_array[i];
break;
}
}
if (nonce_new_p == NULL) {
// no.. buffer is still full, we have no option
// but dropping the oldest nonce from the array.
nonce_new_p = circ_buf_get_oldest();
}
circ_buf_update_ages(nonce_new_p, nonce_value);
SDA_LOG_TRACE_FUNC_EXIT_NO_ARGS();
}
static bool circ_buf_delete(uint64_t nonce)
{
uint32_t i;
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
for (i = 0; i < SDA_ARRAY_LENGTH(g_nonce_array); i++) {
if (g_nonce_array[i].value == nonce) {
// found it, remove from array
circ_buf_nonce_clear(&(g_nonce_array[i]));
return true;
}
}
SDA_LOG_TRACE_FUNC_EXIT("status=false");
// failed to find the target nonce value
return false;
}
sda_status_internal_e sda_nonce_init(void)
{
uint32_t i;
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
for (i = 0; i < SDA_ARRAY_LENGTH(g_nonce_array); i++) {
g_nonce_array[i].value = 0;
g_nonce_array[i].age = SDA_NONCE_AGE_OLDEST;
}
SDA_LOG_TRACE_FUNC_EXIT_NO_ARGS();
return SDA_STATUS_INTERNAL_SUCCESS;
}
sda_status_internal_e sda_nonce_fini(void)
{
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
SDA_LOG_TRACE_FUNC_EXIT_NO_ARGS();
return sda_nonce_init();
}
sda_status_internal_e sda_nonce_get(uint64_t *nonce_out)
{
palStatus_t pal_status = PAL_SUCCESS;
uint64_t nonce = 0;
SDA_LOG_TRACE_FUNC_ENTER_NO_ARGS();
SDA_ERR_RECOVERABLE_RETURN_IF((nonce_out == NULL), SDA_STATUS_INTERNAL_INVALID_PARAMETER, "Got NULL for nonce_out");
// generate a fresh nonce values
pal_status = pal_osRandomBuffer((uint8_t *)&nonce, sizeof(nonce));
SDA_ERR_RECOVERABLE_RETURN_IF((pal_status != PAL_SUCCESS), SDA_STATUS_INTERNAL_NONCE_GENERATION_ERROR, "Failed to generate random nonce");
SDA_ERR_RECOVERABLE_RETURN_IF((nonce == 0), SDA_STATUS_INTERNAL_NONCE_GENERATION_ERROR, "Got zero for random nonce");
// push to circular buffer
circ_buf_insert(nonce);
*nonce_out = nonce;
SDA_LOG_TRACE_FUNC_EXIT("nonce=%" PRIu64 "status=SDA_STATUS_INTERNAL_SUCCESS", nonce);
return SDA_STATUS_INTERNAL_SUCCESS;
}
bool sda_nonce_verify_and_delete(uint64_t nonce)
{
SDA_LOG_TRACE_FUNC_ENTER("nonce=%" PRIu64, nonce);
SDA_LOG_INFO_FUNC_EXIT_NO_ARGS();
return circ_buf_delete(nonce);
}
| 27.396985 | 142 | 0.681034 |
cedb5fb784e6a412054956436ce39a6dfea5df80 | 1,347 | c | C | src/chalkboard/main.c | aquefir/oamas | 95165a98eb8fcf0f98ca661842f3147e74b4d70f | [
"BSD-2-Clause"
] | null | null | null | src/chalkboard/main.c | aquefir/oamas | 95165a98eb8fcf0f98ca661842f3147e74b4d70f | [
"BSD-2-Clause"
] | null | null | null | src/chalkboard/main.c | aquefir/oamas | 95165a98eb8fcf0f98ca661842f3147e74b4d70f | [
"BSD-2-Clause"
] | null | null | null | /****************************************************************************\
* OAMAS™ *
* *
* Copyright © 2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/
#include <uni/log.h>
#include <stdio.h>
#include <oam/display.h>
#include <oam/eventer.h>
static void promenade( void )
{
struct oam_display * disp = NULL;
struct oam_events * evs = NULL;
uni_err_t e = 0;
struct oam_display_initopts disp_initopts;
disp_initopts.canvas_sz.val.x = 1280;
disp_initopts.canvas_sz.val.y = 720;
disp_initopts.canvas_sz.is = 1;
disp_initopts.colspace.is = 0;
disp_initopts.title = "OAM Chalkboard";
e = oam_display_init( disp_initopts, &disp );
if( e )
{
uni_perror( "ERROR::\nDESCRIPTION: %s\nMODULE: %s\nLEVEL: %s",
uni_err_desc_tostr( e ),
uni_err_mod_tostr( e ),
uni_err_lvl_tostr( e ) );
return;
}
evs = NULL;
while( !oam_mainloop( disp, evs ) )
;
}
int main( int ac, char * av[] )
{
uni_print( "Good morning, Vietnam!" );
promenade( );
printf( "\n\n" );
return 0;
}
| 25.415094 | 78 | 0.454343 |
385076006e1aac140b23ec441a91046b620e9cd9 | 494 | h | C | include/SimpleFormatFactory.h | oz-hernandez/mips-disassembler | e84b254e27b027435a13db95d6dd172098a098c9 | [
"MIT"
] | null | null | null | include/SimpleFormatFactory.h | oz-hernandez/mips-disassembler | e84b254e27b027435a13db95d6dd172098a098c9 | [
"MIT"
] | null | null | null | include/SimpleFormatFactory.h | oz-hernandez/mips-disassembler | e84b254e27b027435a13db95d6dd172098a098c9 | [
"MIT"
] | null | null | null | //
// Copyright © 2017 OsmaniHernandez. All rights reserved.
//
#ifndef SIMPLEFORMATFACTORY_H
#define SIMPLEFORMATFACTORY_H
class Format;
class FormatFactory
{
public:
Format *returnFormat(const unsigned int&);
enum
{
OP_MASK = 0xFC000000,
RS_MASK = 0x03E00000,
RT_MASK = 0x001F0000,
RD_MASK = 0x0000F800,
FUNC_MASK = 0x0000003F,
OFFSET_MASK = 0x0000FFFF
};
private:
unsigned int opcode;
};
#endif
| 17.034483 | 58 | 0.625506 |
e0649a8cfac27e662cecf079c5b538f07a2cf341 | 923 | h | C | src/ledger/bin/encryption/fake/fake_encryption_service_factory.h | zhangpf/fuchsia-rs | 903568f28ddf45f09157ead36d61b50322c9cf49 | [
"BSD-3-Clause"
] | 3 | 2020-08-02T04:46:18.000Z | 2020-08-07T10:10:53.000Z | src/ledger/bin/encryption/fake/fake_encryption_service_factory.h | zhangpf/fuchsia-rs | 903568f28ddf45f09157ead36d61b50322c9cf49 | [
"BSD-3-Clause"
] | 16 | 2020-09-04T19:01:11.000Z | 2021-05-28T03:23:09.000Z | src/ledger/bin/encryption/fake/fake_encryption_service_factory.h | ZVNexus/fuchsia | c5610ad15208208c98693618a79c705af935270c | [
"BSD-3-Clause"
] | 1 | 2020-08-07T10:11:49.000Z | 2020-08-07T10:11:49.000Z | // Copyright 2018 The Fuchsia 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 SRC_LEDGER_BIN_ENCRYPTION_FAKE_FAKE_ENCRYPTION_SERVICE_FACTORY_H_
#define SRC_LEDGER_BIN_ENCRYPTION_FAKE_FAKE_ENCRYPTION_SERVICE_FACTORY_H_
#include <lib/async/dispatcher.h>
#include "src/ledger/bin/encryption/public/encryption_service_factory.h"
namespace encryption {
class FakeEncryptionServiceFactory : public EncryptionServiceFactory {
public:
explicit FakeEncryptionServiceFactory(async_dispatcher_t* dispatcher);
~FakeEncryptionServiceFactory() override;
// EncryptionServiceFactory
std::unique_ptr<EncryptionService> MakeEncryptionService(std::string namespace_id) override;
private:
async_dispatcher_t* dispatcher_;
};
} // namespace encryption
#endif // SRC_LEDGER_BIN_ENCRYPTION_FAKE_FAKE_ENCRYPTION_SERVICE_FACTORY_H_
| 34.185185 | 94 | 0.83532 |
ed224317a62b20968829e2224b0c45b9c917af92 | 140 | h | C | purenum/purenum.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | purenum/purenum.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | purenum/purenum.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z | // ------------------
// Purenum 0.4e alpha
// ------------------
// purenum.h
// ------------------
#include "int.h"
#include "array.h"
| 12.727273 | 21 | 0.335714 |
c307c7e110db017705ab7363000c1fff773ccf2d | 42,880 | c | C | ext/open_rpg/audiofx.c | ForeverZer0/open_rpg | 989419a754d9561a4498018bab38ac7e18eeaa7d | [
"MIT"
] | 1 | 2020-08-03T07:51:37.000Z | 2020-08-03T07:51:37.000Z | ext/open_rpg/audiofx.c | ForeverZer0/open_rpg | 989419a754d9561a4498018bab38ac7e18eeaa7d | [
"MIT"
] | null | null | null | ext/open_rpg/audiofx.c | ForeverZer0/open_rpg | 989419a754d9561a4498018bab38ac7e18eeaa7d | [
"MIT"
] | null | null | null | #include "./audio.h"
#include "./internal.h"
#include <AL/efx-presets.h>
VALUE rb_cReverbPreset;
/* Effect object functions */
static LPALGENEFFECTS alGenEffects;
static LPALDELETEEFFECTS alDeleteEffects;
static LPALISEFFECT alIsEffect;
static LPALEFFECTI alEffecti;
static LPALEFFECTIV alEffectiv;
static LPALEFFECTF alEffectf;
static LPALEFFECTFV alEffectfv;
static LPALGETEFFECTI alGetEffecti;
static LPALGETEFFECTIV alGetEffectiv;
static LPALGETEFFECTF alGetEffectf;
static LPALGETEFFECTFV alGetEffectfv;
static void rpg_audiofx_refresh_channels(RPGeffect *e) {
for (int i = 0; i < MAX_CHANNELS; i++) {
RPGchannel *c = rpgCHANNELS[i];
if (c) {
for (int j = 0; j < c->num_slots; j++) {
RPGslot slot = c->slots[j];
if (slot.effect == e->effect) {
alAuxiliaryEffectSloti(slot.slot, AL_EFFECTSLOT_EFFECT, e->effect);
}
}
}
}
}
#define RPG_AUDIOFX_DEF_INIT(klass, name) \
VALUE klass = rb_define_class_under(effects, name, effect); \
rb_define_method(klass, "initialize", rpg_##klass##_initialize, 0)
#define RPG_AUDIOFX_DEF_ATTR(type, name) \
rb_define_method(type, #name, rpg_##type##_##name##_get, 0); \
rb_define_method(type, #name "=", rpg_##type##_##name##_set, 1)
#define RPG_AUDIOFX_INIT_FUNC(klass, type) \
static VALUE rpg_##klass##_initialize(VALUE self) { \
VALUE t = INT2NUM(type); \
rb_call_super(1, &t); \
return Qnil; \
}
#define RPG_AUDIOFX_ATTR_F(func, param, minv, maxv) \
static VALUE func##_get(VALUE self) { \
RPGeffect *e = DATA_PTR(self); \
ALfloat v; \
alGetEffectf(e->effect, param, &v); \
return DBL2NUM(v); \
} \
static VALUE func##_set(VALUE self, VALUE value) { \
RPGeffect *e = DATA_PTR(self); \
alEffectf(e->effect, param, clampf(NUM2FLT(value), minv, maxv)); \
rpg_audiofx_refresh_channels(e); \
return value; \
}
#define RPG_AUDIOFX_ATTR_VEC(func, param) \
static VALUE func##_get(VALUE self) { \
RPGeffect *e = DATA_PTR(self); \
RPGvec3 *v = ALLOC(RPGvec3); \
alGetEffectfv(e->effect, param, (ALfloat*) v); \
return Data_Wrap_Struct(rb_cVec3, NULL, RUBY_DEFAULT_FREE, v); \
} \
static VALUE func##_set(VALUE self, VALUE value) { \
RPGeffect *e = DATA_PTR(self); \
ALfloat *v = DATA_PTR(value); \
alEffectfv(e->effect, param, v); \
rpg_audiofx_refresh_channels(e); \
return value; \
}
#define RPG_AUDIOFX_ATTR_I(func, param, minv, maxv) \
static VALUE func##_get(VALUE self) { \
RPGeffect *e = DATA_PTR(self); \
ALint v; \
alGetEffecti(e->effect, param, &v); \
return INT2NUM(v); \
} \
static VALUE func##_set(VALUE self, VALUE value) { \
RPGeffect *e = DATA_PTR(self); \
alEffecti(e->effect, param, clampi(NUM2INT(value), minv, maxv)); \
rpg_audiofx_refresh_channels(e); \
return value; \
}
#define RPG_AUDIOFX_ATTR_BOOL(func, param) \
static VALUE func##_get(VALUE self) { \
RPGeffect *e = DATA_PTR(self); \
ALint v; \
alGetEffecti(e->effect, param, &v); \
return RB_BOOL(v); \
} \
static VALUE func##_set(VALUE self, VALUE value) { \
RPGeffect *e = DATA_PTR(self); \
alEffecti(e->effect, param, RTEST(value)); \
rpg_audiofx_refresh_channels(e); \
return value; \
}
#define RPG_REVERB_PRESET(name) \
do { \
EFXEAXREVERBPROPERTIES v = EFX_REVERB_PRESET_##name; \
EFXEAXREVERBPROPERTIES *rv = ALLOC(EFXEAXREVERBPROPERTIES); \
memcpy(rv, &v, sizeof(EFXEAXREVERBPROPERTIES)); \
VALUE preset = Data_Wrap_Struct(rb_cReverbPreset, NULL, RUBY_DEFAULT_FREE, rv); \
rb_obj_freeze(preset); \
rb_define_const(rb_cReverbPreset, #name, preset); \
} while (0)
#define RPG_DEF_REVERB_ATTR(name) \
rb_define_method(rb_cReverbPreset, #name, rpg_preset_get_##name, 0); \
rb_define_method(rb_cReverbPreset, #name "=", rpg_preset_set_##name, 1)
#define RPG_REVERB_ATTR(name, field, RUBY_MACRO, C_MACRO) \
ATTR_READER(rpg_preset_get_##name, EFXEAXREVERBPROPERTIES, field, RUBY_MACRO) \
static VALUE rpg_preset_set_##name(VALUE self, VALUE value) { \
if (RB_OBJ_FROZEN(self)) { \
rb_raise(rb_eFrozenError, "cannot modifiy frozen %s", RPG_OBJ_CLASS_NAME(self)); \
} \
EFXEAXREVERBPROPERTIES *r = DATA_PTR(self); \
r->field = C_MACRO(value); \
}
static void rpg_audiofx_free(void *data) {
rb_p(Qtrue);
if (data) {
RPGeffect *e = data;
alDeleteEffects(1, &e->effect);
RPG_FREE(data);
}
}
static VALUE rpg_audiofx_alloc(VALUE klass) {
RPGeffect *e = ALLOC(RPGeffect);
memset(e, 0, sizeof(RPGeffect));
return Data_Wrap_Struct(klass, NULL, rpg_audiofx_free, e);
}
static VALUE rpg_audiofx_initialize(VALUE self, VALUE type) {
RPGeffect *e = DATA_PTR(self);
e->type = NUM2INT(type);
alGenEffects(1, &e->effect);
alEffecti(e->effect, AL_EFFECT_TYPE, e->type);
ALenum error = alGetError();
if (error != AL_NO_ERROR) {
alDeleteEffects(1, &e->effect);
rb_raise(rb_eRPGError, "failed to create audio effect - %08X", error);
}
}
static VALUE rpg_audiofx_valid_p(VALUE self) {
RPGeffect *e = DATA_PTR(self);
return RB_BOOL(alIsEffect(e->effect));
}
static VALUE rpg_audiofx_setf(VALUE self, VALUE param, VALUE value) {
RPGeffect *e = DATA_PTR(self);
ALenum p = NUM2INT(param);
if (RB_TYPE_P(value, T_ARRAY)) {
long n = rb_array_len(value);
ALfloat args[n];
for (long i = 0; i < n; i++) {
args[i] = NUM2FLT(rb_ary_entry(value, i));
}
alEffectfv(e->effect, p, args);
} else {
alEffectf(e->effect, p, NUM2FLT(value));
}
CHECK_AL_ERROR("error setting parameter, ensure param is correct value is within valid range")
rpg_audiofx_refresh_channels(e);
return value;
}
static VALUE rpg_audiofx_seti(VALUE self, VALUE param, VALUE value) {
RPGeffect *e = DATA_PTR(self);
ALenum p = NUM2INT(param);
if (RB_TYPE_P(value, T_ARRAY)) {
long n = rb_array_len(value);
ALint args[n];
for (long i = 0; i < n; i++) {
args[i] = NUM2INT(rb_ary_entry(value, i));
}
alEffectiv(e->effect, p, args);
} else {
alEffecti(e->effect, p, NUM2INT(value));
}
CHECK_AL_ERROR("error setting parameter, ensure param is correct value is within valid range")
rpg_audiofx_refresh_channels(e);
return value;
}
static VALUE rpg_audiofx_getf(VALUE self, VALUE param, VALUE count) {
RPGeffect *e = DATA_PTR(self);
ALenum p = NUM2INT(param);
int n = NUM2INT(count);
if (n > 1) {
ALfloat buffer[n];
alGetEffectfv(e->effect, p, buffer);
VALUE ary = rb_ary_new_capa(n);
for (int i = 0; i < n; i++) {
rb_ary_store(ary, i, DBL2NUM(buffer[i]));
}
return ary;
} else {
ALfloat v;
alGetEffectf(e->effect, p, &v);
return DBL2NUM(v);
}
}
static VALUE rpg_audiofx_geti(VALUE self, VALUE param, VALUE count) {
RPGeffect *e = DATA_PTR(self);
ALenum p = NUM2INT(param);
int n = NUM2INT(count);
if (n > 1) {
ALint buffer[n];
alGetEffectiv(e->effect, p, buffer);
VALUE ary = rb_ary_new_capa(n);
for (int i = 0; i < n; i++) {
rb_ary_store(ary, i, INT2NUM(buffer[i]));
}
return ary;
} else {
ALint v;
alGetEffecti(e->effect, p, &v);
return INT2NUM(v);
}
}
// Reverb
static void rpg_reverb_set_internal(RPGeffect *e, EFXEAXREVERBPROPERTIES *preset) {
if (e->type == AL_EFFECT_EAXREVERB) {
// EAX Reverb is only in OpenAL-Soft implementations
alEffectf(e->effect, AL_EAXREVERB_DENSITY, preset->flDensity);
alEffectf(e->effect, AL_EAXREVERB_DIFFUSION, preset->flDiffusion);
alEffectf(e->effect, AL_EAXREVERB_GAIN, preset->flGain);
alEffectf(e->effect, AL_EAXREVERB_GAINHF, preset->flGainHF);
alEffectf(e->effect, AL_EAXREVERB_GAINLF, preset->flGainLF);
alEffectf(e->effect, AL_EAXREVERB_DECAY_TIME, preset->flDecayTime);
alEffectf(e->effect, AL_EAXREVERB_DECAY_HFRATIO, preset->flDecayHFRatio);
alEffectf(e->effect, AL_EAXREVERB_DECAY_LFRATIO, preset->flDecayLFRatio);
alEffectf(e->effect, AL_EAXREVERB_REFLECTIONS_GAIN, preset->flReflectionsGain);
alEffectf(e->effect, AL_EAXREVERB_REFLECTIONS_DELAY, preset->flReflectionsDelay);
alEffectfv(e->effect, AL_EAXREVERB_REFLECTIONS_PAN, preset->flReflectionsPan);
alEffectf(e->effect, AL_EAXREVERB_LATE_REVERB_GAIN, preset->flLateReverbGain);
alEffectf(e->effect, AL_EAXREVERB_LATE_REVERB_DELAY, preset->flLateReverbDelay);
alEffectfv(e->effect, AL_EAXREVERB_LATE_REVERB_PAN, preset->flLateReverbPan);
alEffectf(e->effect, AL_EAXREVERB_ECHO_TIME, preset->flEchoTime);
alEffectf(e->effect, AL_EAXREVERB_ECHO_DEPTH, preset->flEchoDepth);
alEffectf(e->effect, AL_EAXREVERB_MODULATION_TIME, preset->flModulationTime);
alEffectf(e->effect, AL_EAXREVERB_MODULATION_DEPTH, preset->flModulationDepth);
alEffectf(e->effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, preset->flAirAbsorptionGainHF);
alEffectf(e->effect, AL_EAXREVERB_HFREFERENCE, preset->flHFReference);
alEffectf(e->effect, AL_EAXREVERB_LFREFERENCE, preset->flLFReference);
alEffectf(e->effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, preset->flRoomRolloffFactor);
alEffecti(e->effect, AL_EAXREVERB_DECAY_HFLIMIT, preset->iDecayHFLimit);
} else {
// EAX Reverb not present, use standard reverb
alEffectf(e->effect, AL_REVERB_DENSITY, preset->flDensity);
alEffectf(e->effect, AL_REVERB_DIFFUSION, preset->flDiffusion);
alEffectf(e->effect, AL_REVERB_GAIN, preset->flGain);
alEffectf(e->effect, AL_REVERB_GAINHF, preset->flGainHF);
alEffectf(e->effect, AL_REVERB_DECAY_TIME, preset->flDecayTime);
alEffectf(e->effect, AL_REVERB_DECAY_HFRATIO, preset->flDecayHFRatio);
alEffectf(e->effect, AL_REVERB_REFLECTIONS_GAIN, preset->flReflectionsGain);
alEffectf(e->effect, AL_REVERB_REFLECTIONS_DELAY, preset->flReflectionsDelay);
alEffectf(e->effect, AL_REVERB_LATE_REVERB_GAIN, preset->flLateReverbGain);
alEffectf(e->effect, AL_REVERB_LATE_REVERB_DELAY, preset->flLateReverbDelay);
alEffectf(e->effect, AL_REVERB_AIR_ABSORPTION_GAINHF, preset->flAirAbsorptionGainHF);
alEffectf(e->effect, AL_REVERB_ROOM_ROLLOFF_FACTOR, preset->flRoomRolloffFactor);
alEffecti(e->effect, AL_REVERB_DECAY_HFLIMIT, preset->iDecayHFLimit);
}
}
static VALUE rpg_reverb_set(VALUE self, VALUE preset) {
RPGeffect *e = DATA_PTR(self);
EFXEAXREVERBPROPERTIES *p = DATA_PTR(preset);
rpg_reverb_set_internal(e, p);
rpg_reverb_refresh_channels(e);
return self;
}
static VALUE rpg_reverb_initialize(int argc, VALUE *argv, VALUE self) {
VALUE arg;
rb_scan_args(argc, argv, "01", &arg);
VALUE type = INT2NUM((alGetEnumValue("AL_EFFECT_EAXREVERB") != 0) ? AL_EFFECT_EAXREVERB : AL_EFFECT_REVERB);
rb_call_super(1, &type);
if (RTEST(arg)) {
RPGeffect *e = DATA_PTR(self);
EFXEAXREVERBPROPERTIES *preset = DATA_PTR(arg);
rpg_reverb_set_internal(e, preset);
}
}
// RPG_AUDIOFX_INIT_FUNC(reverb, AL_EFFECT_EAXREVERB)
RPG_AUDIOFX_ATTR_F(rpg_reverb_density, AL_EAXREVERB_DENSITY, AL_EAXREVERB_MIN_DENSITY, AL_EAXREVERB_MAX_DENSITY)
RPG_AUDIOFX_ATTR_F(rpg_reverb_diffusion, AL_EAXREVERB_DIFFUSION, AL_EAXREVERB_MIN_DIFFUSION, AL_EAXREVERB_MAX_DIFFUSION)
RPG_AUDIOFX_ATTR_F(rpg_reverb_gain, AL_EAXREVERB_GAIN, AL_EAXREVERB_MIN_GAIN, AL_EAXREVERB_MAX_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_reverb_gain_hf, AL_EAXREVERB_GAINHF, AL_EAXREVERB_MIN_GAINHF, AL_EAXREVERB_MAX_GAINHF)
RPG_AUDIOFX_ATTR_F(rpg_reverb_gain_lf, AL_EAXREVERB_GAINLF, AL_EAXREVERB_MIN_GAINLF, AL_EAXREVERB_MAX_GAINLF)
RPG_AUDIOFX_ATTR_F(rpg_reverb_decay_time, AL_EAXREVERB_DECAY_TIME, AL_EAXREVERB_MIN_DECAY_TIME, AL_EAXREVERB_MAX_DECAY_TIME)
RPG_AUDIOFX_ATTR_F(rpg_reverb_hf_ratio, AL_EAXREVERB_DECAY_HFRATIO, AL_EAXREVERB_MIN_DECAY_HFRATIO, AL_EAXREVERB_MAX_DECAY_HFRATIO)
RPG_AUDIOFX_ATTR_F(rpg_reverb_lf_ratio, AL_EAXREVERB_DECAY_LFRATIO, AL_EAXREVERB_MIN_DECAY_LFRATIO, AL_EAXREVERB_MAX_DECAY_LFRATIO)
RPG_AUDIOFX_ATTR_F(rpg_reverb_reflections_gain, AL_EAXREVERB_REFLECTIONS_GAIN, AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_reverb_reflections_delay, AL_EAXREVERB_REFLECTIONS_DELAY, AL_EAXREVERB_MIN_REFLECTIONS_DELAY, AL_EAXREVERB_MAX_REFLECTIONS_DELAY)
RPG_AUDIOFX_ATTR_F(rpg_reverb_late_gain, AL_EAXREVERB_LATE_REVERB_GAIN, AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_reverb_late_delay, AL_EAXREVERB_LATE_REVERB_DELAY, AL_EAXREVERB_MIN_LATE_REVERB_DELAY, AL_EAXREVERB_MAX_LATE_REVERB_DELAY)
RPG_AUDIOFX_ATTR_F(rpg_reverb_echo_time, AL_EAXREVERB_ECHO_TIME, AL_EAXREVERB_MIN_ECHO_TIME, AL_EAXREVERB_MAX_ECHO_TIME)
RPG_AUDIOFX_ATTR_F(rpg_reverb_echo_depth, AL_EAXREVERB_ECHO_DEPTH, AL_EAXREVERB_MIN_ECHO_DEPTH, AL_EAXREVERB_MAX_ECHO_DEPTH)
RPG_AUDIOFX_ATTR_F(rpg_reverb_modulation_time, AL_EAXREVERB_MODULATION_TIME, AL_EAXREVERB_MIN_MODULATION_TIME, AL_EAXREVERB_MAX_MODULATION_TIME)
RPG_AUDIOFX_ATTR_F(rpg_reverb_modulation_depth, AL_EAXREVERB_MODULATION_DEPTH, AL_EAXREVERB_MIN_MODULATION_DEPTH, AL_EAXREVERB_MAX_MODULATION_DEPTH)
RPG_AUDIOFX_ATTR_F(rpg_reverb_air_absorption, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)
RPG_AUDIOFX_ATTR_F(rpg_reverb_hf_reference, AL_EAXREVERB_HFREFERENCE, AL_EAXREVERB_MIN_HFREFERENCE, AL_EAXREVERB_MAX_HFREFERENCE)
RPG_AUDIOFX_ATTR_F(rpg_reverb_lf_reference, AL_EAXREVERB_LFREFERENCE, AL_EAXREVERB_MIN_LFREFERENCE, AL_EAXREVERB_MAX_LFREFERENCE)
RPG_AUDIOFX_ATTR_F(rpg_reverb_room_rolloff, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR, AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR)
RPG_AUDIOFX_ATTR_BOOL(rpg_reverb_decay_limit, AL_EAXREVERB_DECAY_HFLIMIT)
RPG_AUDIOFX_ATTR_VEC(rpg_reverb_reflections_pan, AL_EAXREVERB_REFLECTIONS_PAN)
RPG_AUDIOFX_ATTR_VEC(rpg_reverb_late_pan, AL_EAXREVERB_LATE_REVERB_PAN)
// CHorus
RPG_AUDIOFX_INIT_FUNC(chorus, AL_EFFECT_CHORUS)
RPG_AUDIOFX_ATTR_I(rpg_chorus_waveform, AL_CHORUS_WAVEFORM, AL_CHORUS_MIN_WAVEFORM, AL_CHORUS_MAX_WAVEFORM)
RPG_AUDIOFX_ATTR_I(rpg_chorus_phase, AL_CHORUS_PHASE, AL_CHORUS_MIN_PHASE, AL_CHORUS_MAX_PHASE)
RPG_AUDIOFX_ATTR_F(rpg_chorus_rate, AL_CHORUS_RATE, AL_CHORUS_MIN_RATE, AL_CHORUS_MAX_RATE)
RPG_AUDIOFX_ATTR_F(rpg_chorus_depth, AL_CHORUS_DEPTH, AL_CHORUS_MIN_DEPTH, AL_CHORUS_MAX_DEPTH)
RPG_AUDIOFX_ATTR_F(rpg_chorus_feedback, AL_CHORUS_FEEDBACK, AL_CHORUS_MIN_FEEDBACK, AL_CHORUS_MAX_FEEDBACK)
RPG_AUDIOFX_ATTR_F(rpg_chorus_delay, AL_CHORUS_DELAY, AL_CHORUS_MIN_DELAY, AL_CHORUS_MAX_DELAY)
// Distortion
RPG_AUDIOFX_INIT_FUNC(distortion, AL_EFFECT_DISTORTION)
RPG_AUDIOFX_ATTR_F(rpg_distortion_edge, AL_DISTORTION_EDGE, AL_DISTORTION_MIN_EDGE, AL_DISTORTION_MAX_EDGE)
RPG_AUDIOFX_ATTR_F(rpg_distortion_gain, AL_DISTORTION_GAIN, AL_DISTORTION_MIN_GAIN, AL_DISTORTION_MAX_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_distortion_lowpass_cutoff, AL_DISTORTION_LOWPASS_CUTOFF, AL_DISTORTION_MIN_LOWPASS_CUTOFF, AL_DISTORTION_MAX_LOWPASS_CUTOFF)
RPG_AUDIOFX_ATTR_F(rpg_distortion_eq_center, AL_DISTORTION_EQCENTER, AL_DISTORTION_MIN_EQCENTER, AL_DISTORTION_MAX_EQCENTER)
RPG_AUDIOFX_ATTR_F(rpg_distortion_eq_bandwidth, AL_DISTORTION_EQBANDWIDTH, AL_DISTORTION_MIN_EQBANDWIDTH, AL_DISTORTION_MAX_EQBANDWIDTH)
// Echo
RPG_AUDIOFX_INIT_FUNC(echo, AL_EFFECT_ECHO)
RPG_AUDIOFX_ATTR_F(rpg_echo_delay, AL_ECHO_DELAY, AL_ECHO_MIN_DELAY, AL_ECHO_MAX_DELAY)
RPG_AUDIOFX_ATTR_F(rpg_echo_lr_delay, AL_ECHO_LRDELAY, AL_ECHO_MIN_LRDELAY, AL_ECHO_MAX_LRDELAY)
RPG_AUDIOFX_ATTR_F(rpg_echo_damping, AL_ECHO_DAMPING, AL_ECHO_MIN_DAMPING, AL_ECHO_MAX_DAMPING)
RPG_AUDIOFX_ATTR_F(rpg_echo_feedback, AL_ECHO_FEEDBACK, AL_ECHO_MIN_FEEDBACK, AL_ECHO_MAX_FEEDBACK)
RPG_AUDIOFX_ATTR_F(rpg_echo_spread, AL_ECHO_SPREAD, AL_ECHO_MIN_SPREAD, AL_ECHO_MAX_SPREAD)
// Flanger
RPG_AUDIOFX_INIT_FUNC(flanger, AL_EFFECT_FLANGER)
RPG_AUDIOFX_ATTR_I(rpg_flanger_waveform, AL_FLANGER_WAVEFORM, AL_FLANGER_MIN_WAVEFORM, AL_FLANGER_MAX_WAVEFORM)
RPG_AUDIOFX_ATTR_I(rpg_flanger_phase, AL_FLANGER_PHASE, AL_FLANGER_MIN_PHASE, AL_FLANGER_MAX_PHASE)
RPG_AUDIOFX_ATTR_F(rpg_flanger_rate, AL_FLANGER_RATE, AL_FLANGER_MIN_RATE, AL_FLANGER_MAX_RATE)
RPG_AUDIOFX_ATTR_F(rpg_flanger_depth, AL_FLANGER_DEPTH, AL_FLANGER_MIN_DEPTH, AL_FLANGER_MAX_DEPTH)
RPG_AUDIOFX_ATTR_F(rpg_flanger_feedback, AL_FLANGER_FEEDBACK, AL_FLANGER_MIN_FEEDBACK, AL_FLANGER_MAX_FEEDBACK)
RPG_AUDIOFX_ATTR_F(rpg_flanger_delay, AL_FLANGER_DELAY, AL_FLANGER_MIN_DELAY, AL_FLANGER_MAX_DELAY)
// FrequencyShifter
RPG_AUDIOFX_INIT_FUNC(shifter, AL_EFFECT_FREQUENCY_SHIFTER)
RPG_AUDIOFX_ATTR_F(rpg_shifter_freq, AL_FREQUENCY_SHIFTER_FREQUENCY, AL_FREQUENCY_SHIFTER_MIN_FREQUENCY, AL_FREQUENCY_SHIFTER_MAX_FREQUENCY)
RPG_AUDIOFX_ATTR_I(rpg_shifter_left_dir, AL_FREQUENCY_SHIFTER_LEFT_DIRECTION, AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION, AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION)
RPG_AUDIOFX_ATTR_I(rpg_shifter_right_dir, AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION, AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION, AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION)
// Vocal Morpher
RPG_AUDIOFX_INIT_FUNC(vmorph, AL_EFFECT_VOCAL_MORPHER)
RPG_AUDIOFX_ATTR_I(rpg_vmorph_phoneme_a, AL_VOCAL_MORPHER_PHONEMEA, AL_VOCAL_MORPHER_MIN_PHONEMEA, AL_VOCAL_MORPHER_MAX_PHONEMEA)
RPG_AUDIOFX_ATTR_I(rpg_vmorph_phoneme_b, AL_VOCAL_MORPHER_PHONEMEB, AL_VOCAL_MORPHER_MIN_PHONEMEB, AL_VOCAL_MORPHER_MAX_PHONEMEB)
RPG_AUDIOFX_ATTR_I(rpg_vmorph_coarse_a, AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING, AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING, AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING)
RPG_AUDIOFX_ATTR_I(rpg_vmorph_coarse_b, AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING, AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING, AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING)
RPG_AUDIOFX_ATTR_I(rpg_vmorph_waveform, AL_VOCAL_MORPHER_WAVEFORM, AL_VOCAL_MORPHER_MIN_WAVEFORM, AL_VOCAL_MORPHER_MAX_WAVEFORM)
RPG_AUDIOFX_ATTR_F(rpg_vmorph_rate, AL_VOCAL_MORPHER_RATE, AL_VOCAL_MORPHER_MIN_RATE, AL_VOCAL_MORPHER_MAX_RATE)
// PitchShifter
RPG_AUDIOFX_INIT_FUNC(pitch, AL_EFFECT_PITCH_SHIFTER)
RPG_AUDIOFX_ATTR_I(rpg_pitch_coarse, AL_PITCH_SHIFTER_COARSE_TUNE, AL_PITCH_SHIFTER_MIN_COARSE_TUNE, AL_PITCH_SHIFTER_MAX_COARSE_TUNE)
RPG_AUDIOFX_ATTR_I(rpg_pitch_fine, AL_PITCH_SHIFTER_FINE_TUNE, AL_PITCH_SHIFTER_MIN_FINE_TUNE, AL_PITCH_SHIFTER_MAX_FINE_TUNE)
// RingModulator
RPG_AUDIOFX_INIT_FUNC(ringmod, AL_EFFECT_RING_MODULATOR)
RPG_AUDIOFX_ATTR_F(rpg_ringmod_freq, AL_RING_MODULATOR_FREQUENCY, AL_RING_MODULATOR_MIN_FREQUENCY, AL_RING_MODULATOR_MAX_FREQUENCY)
RPG_AUDIOFX_ATTR_F(rpg_ringmod_cutoff, AL_RING_MODULATOR_HIGHPASS_CUTOFF, AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF,AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
RPG_AUDIOFX_ATTR_I(rpg_ringmod_waveform, AL_RING_MODULATOR_WAVEFORM, AL_RING_MODULATOR_MIN_WAVEFORM, AL_RING_MODULATOR_MAX_WAVEFORM)
// AutoWah
RPG_AUDIOFX_INIT_FUNC(autowah, AL_EFFECT_AUTOWAH)
RPG_AUDIOFX_ATTR_F(rpg_autowah_attack, AL_AUTOWAH_ATTACK_TIME, AL_AUTOWAH_MIN_ATTACK_TIME, AL_AUTOWAH_MAX_ATTACK_TIME)
RPG_AUDIOFX_ATTR_F(rpg_autowah_release, AL_AUTOWAH_RELEASE_TIME, AL_AUTOWAH_MIN_RELEASE_TIME, AL_AUTOWAH_MAX_RELEASE_TIME)
RPG_AUDIOFX_ATTR_F(rpg_autowah_resonance, AL_AUTOWAH_RESONANCE, AL_AUTOWAH_MIN_RESONANCE, AL_AUTOWAH_MAX_RESONANCE)
RPG_AUDIOFX_ATTR_F(rpg_autowah_peak_gain, AL_AUTOWAH_PEAK_GAIN, AL_AUTOWAH_MIN_PEAK_GAIN, AL_AUTOWAH_MAX_PEAK_GAIN)
// Compressor
RPG_AUDIOFX_INIT_FUNC(compressor, AL_EFFECT_COMPRESSOR)
RPG_AUDIOFX_ATTR_BOOL(rpg_compressor_enabled, AL_COMPRESSOR_ONOFF)
// Equalizer
RPG_AUDIOFX_INIT_FUNC(eq, AL_EFFECT_EQUALIZER)
RPG_AUDIOFX_ATTR_F(rpg_eq_low_gain, AL_EQUALIZER_LOW_GAIN, AL_EQUALIZER_MIN_LOW_GAIN, AL_EQUALIZER_MAX_LOW_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_eq_low_cutoff, AL_EQUALIZER_LOW_CUTOFF, AL_EQUALIZER_MIN_LOW_CUTOFF, AL_EQUALIZER_MAX_LOW_CUTOFF)
RPG_AUDIOFX_ATTR_F(rpg_eq_mid1_gain, AL_EQUALIZER_MID1_GAIN, AL_EQUALIZER_MIN_MID1_GAIN, AL_EQUALIZER_MAX_MID1_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_eq_mid1_center, AL_EQUALIZER_MID1_CENTER, AL_EQUALIZER_MIN_MID1_CENTER, AL_EQUALIZER_MAX_MID1_CENTER)
RPG_AUDIOFX_ATTR_F(rpg_eq_mid1_width, AL_EQUALIZER_MID1_WIDTH, AL_EQUALIZER_MIN_MID1_WIDTH, AL_EQUALIZER_MAX_MID1_WIDTH)
RPG_AUDIOFX_ATTR_F(rpg_eq_mid2_gain, AL_EQUALIZER_MID2_GAIN, AL_EQUALIZER_MIN_MID2_GAIN, AL_EQUALIZER_MAX_MID2_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_eq_mid2_center, AL_EQUALIZER_MID2_CENTER, AL_EQUALIZER_MIN_MID2_CENTER, AL_EQUALIZER_MAX_MID2_CENTER)
RPG_AUDIOFX_ATTR_F(rpg_eq_mid2_width, AL_EQUALIZER_MID2_WIDTH, AL_EQUALIZER_MIN_MID2_WIDTH, AL_EQUALIZER_MAX_MID2_WIDTH)
RPG_AUDIOFX_ATTR_F(rpg_eq_high_gain, AL_EQUALIZER_HIGH_GAIN, AL_EQUALIZER_MIN_HIGH_GAIN, AL_EQUALIZER_MAX_HIGH_GAIN)
RPG_AUDIOFX_ATTR_F(rpg_eq_high_cutoff, AL_EQUALIZER_HIGH_CUTOFF, AL_EQUALIZER_MIN_HIGH_CUTOFF, AL_EQUALIZER_MAX_HIGH_CUTOFF)
// ReverbPreset
ALLOC_FUNC(rpg_preset_alloc, EFXEAXREVERBPROPERTIES);
DUP_FUNC(rpg_preset_dup, EFXEAXREVERBPROPERTIES)
DUMP_FUNC(rpg_preset_dump, EFXEAXREVERBPROPERTIES)
LOAD_FUNC(rpg_preset_load, EFXEAXREVERBPROPERTIES)
RPG_REVERB_ATTR(density, flDensity, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(diffusion, flDiffusion, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(gain, flGain, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(gain_hf, flGainHF, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(gain_lf, flGainLF, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(decay_time, flDecayTime, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(decay_hf_ratio, flDecayHFRatio, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(decay_lf_ratio, flDecayLFRatio, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(reflections_gain, flReflectionsGain, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(reflections_delay, flReflectionsDelay, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(late_reverb_gain, flLateReverbGain, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(late_reverb_delay, flLateReverbDelay, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(echo_time, flEchoTime, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(echo_depth, flEchoDepth, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(modulation_time, flModulationTime, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(modulation_depth, flModulationDepth, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(hf_reference, flHFReference, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(lf_reference, flLFReference, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(rolloff, flRoomRolloffFactor, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(air_absorption, flAirAbsorptionGainHF, DBL2NUM, NUM2FLT)
RPG_REVERB_ATTR(decay_limit, iDecayHFLimit, RTEST, RB_BOOL)
static VALUE rpg_preset_get_reflections_pan(VALUE self) {
EFXEAXREVERBPROPERTIES *r = DATA_PTR(self);
RPGvec3 *v = ALLOC(RPGvec3);
memcpy(v, &r->flReflectionsPan[0], sizeof(RPGvec3));
return Data_Wrap_Struct(rb_cVec3, NULL, RUBY_DEFAULT_FREE, v);
}
static VALUE rpg_preset_set_reflections_pan(VALUE self, VALUE value) {
if (RB_OBJ_FROZEN(self)) {
rb_raise(rb_eFrozenError, "cannot modifiy frozen %s", RPG_OBJ_CLASS_NAME(self));
}
EFXEAXREVERBPROPERTIES *r = DATA_PTR(self);
RPGvec3 *v = DATA_PTR(value);
memcpy(&r->flReflectionsPan[0], v, sizeof(RPGvec3));
return value;
}
static VALUE rpg_preset_get_late_reverb_pan(VALUE self) {
EFXEAXREVERBPROPERTIES *r = DATA_PTR(self);
RPGvec3 *v = ALLOC(RPGvec3);
memcpy(v, &r->flLateReverbPan[0], sizeof(RPGvec3));
return Data_Wrap_Struct(rb_cVec3, NULL, RUBY_DEFAULT_FREE, v);
}
static VALUE rpg_preset_set_late_reverb_pan(VALUE self, VALUE value) {
if (RB_OBJ_FROZEN(self)) {
rb_raise(rb_eFrozenError, "cannot modifiy frozen %s", RPG_OBJ_CLASS_NAME(self));
}
EFXEAXREVERBPROPERTIES *r = DATA_PTR(self);
RPGvec3 *v = DATA_PTR(value);
memcpy(&r->flLateReverbPan[0], v, sizeof(RPGvec3));
return value;
}
void rpg_audiofx_init(VALUE parent) {
AL_LOAD_PROC(alGenEffects, LPALGENEFFECTS);
AL_LOAD_PROC(alDeleteEffects, LPALDELETEEFFECTS);
AL_LOAD_PROC(alIsEffect, LPALISEFFECT);
AL_LOAD_PROC(alEffecti, LPALEFFECTI);
AL_LOAD_PROC(alEffectiv, LPALEFFECTIV);
AL_LOAD_PROC(alEffectf, LPALEFFECTF);
AL_LOAD_PROC(alEffectfv, LPALEFFECTFV);
AL_LOAD_PROC(alGetEffecti, LPALGETEFFECTI);
AL_LOAD_PROC(alGetEffectiv, LPALGETEFFECTIV);
AL_LOAD_PROC(alGetEffectf, LPALGETEFFECTF);
AL_LOAD_PROC(alGetEffectfv, LPALGETEFFECTFV);
VALUE effects = rb_define_module_under(parent, "Effects");
VALUE effect = rb_define_class_under(effects, "Effect", rb_cObject);
rb_define_alloc_func(effect, rpg_audiofx_alloc);
rb_define_method(effect, "initialize", rpg_audiofx_initialize, 1);
rb_define_method(effect, "valid?", rpg_audiofx_valid_p, 0);
rb_define_method(effect, "setf", rpg_audiofx_setf, 2);
rb_define_method(effect, "seti", rpg_audiofx_seti, 2);
rb_define_method(effect, "getf", rpg_audiofx_getf, 2);
rb_define_method(effect, "geti", rpg_audiofx_geti, 2);
// Reverb
VALUE reverb = rb_define_class_under(effects, "Reverb", effect);
rb_define_method(reverb, "initialize", rpg_reverb_initialize, -1);
rb_define_method(reverb, "set", rpg_reverb_set, 1);
RPG_AUDIOFX_DEF_ATTR(reverb, density);
RPG_AUDIOFX_DEF_ATTR(reverb, diffusion);
RPG_AUDIOFX_DEF_ATTR(reverb, gain);
RPG_AUDIOFX_DEF_ATTR(reverb, gain_hf);
RPG_AUDIOFX_DEF_ATTR(reverb, gain_lf);
RPG_AUDIOFX_DEF_ATTR(reverb, decay_time);
RPG_AUDIOFX_DEF_ATTR(reverb, hf_ratio);
RPG_AUDIOFX_DEF_ATTR(reverb, lf_ratio);
RPG_AUDIOFX_DEF_ATTR(reverb, reflections_gain);
RPG_AUDIOFX_DEF_ATTR(reverb, reflections_delay);
RPG_AUDIOFX_DEF_ATTR(reverb, late_gain);
RPG_AUDIOFX_DEF_ATTR(reverb, late_delay);
RPG_AUDIOFX_DEF_ATTR(reverb, echo_time);
RPG_AUDIOFX_DEF_ATTR(reverb, echo_depth);
RPG_AUDIOFX_DEF_ATTR(reverb, modulation_time);
RPG_AUDIOFX_DEF_ATTR(reverb, modulation_depth);
RPG_AUDIOFX_DEF_ATTR(reverb, air_absorption);
RPG_AUDIOFX_DEF_ATTR(reverb, hf_reference);
RPG_AUDIOFX_DEF_ATTR(reverb, lf_reference);
RPG_AUDIOFX_DEF_ATTR(reverb, room_rolloff);
RPG_AUDIOFX_DEF_ATTR(reverb, decay_limit);
RPG_AUDIOFX_DEF_ATTR(reverb, reflections_pan);
RPG_AUDIOFX_DEF_ATTR(reverb, late_pan);
// Chorus
RPG_AUDIOFX_DEF_INIT(chorus, "Chorus");
RPG_AUDIOFX_DEF_ATTR(chorus, waveform);
RPG_AUDIOFX_DEF_ATTR(chorus, phase);
RPG_AUDIOFX_DEF_ATTR(chorus, rate);
RPG_AUDIOFX_DEF_ATTR(chorus, depth);
RPG_AUDIOFX_DEF_ATTR(chorus, feedback);
RPG_AUDIOFX_DEF_ATTR(chorus, delay);
// Distortion
RPG_AUDIOFX_DEF_INIT(distortion, "Distortion");
RPG_AUDIOFX_DEF_ATTR(distortion, edge);
RPG_AUDIOFX_DEF_ATTR(distortion, gain);
RPG_AUDIOFX_DEF_ATTR(distortion, lowpass_cutoff);
RPG_AUDIOFX_DEF_ATTR(distortion, eq_center);
RPG_AUDIOFX_DEF_ATTR(distortion, eq_bandwidth);
// Echo
RPG_AUDIOFX_DEF_INIT(echo, "Echo");
RPG_AUDIOFX_DEF_ATTR(echo, delay);
RPG_AUDIOFX_DEF_ATTR(echo, lr_delay);
RPG_AUDIOFX_DEF_ATTR(echo, damping);
RPG_AUDIOFX_DEF_ATTR(echo, feedback);
RPG_AUDIOFX_DEF_ATTR(echo, spread);
// Flanger
RPG_AUDIOFX_DEF_INIT(flanger, "Flanger");
RPG_AUDIOFX_DEF_ATTR(flanger, waveform);
RPG_AUDIOFX_DEF_ATTR(flanger, phase);
RPG_AUDIOFX_DEF_ATTR(flanger, rate);
RPG_AUDIOFX_DEF_ATTR(flanger, depth);
RPG_AUDIOFX_DEF_ATTR(flanger, feedback);
RPG_AUDIOFX_DEF_ATTR(flanger, delay);
// FrequencyShifter
RPG_AUDIOFX_DEF_INIT(shifter, "FrequencyShifter");
RPG_AUDIOFX_DEF_ATTR(shifter, freq);
RPG_AUDIOFX_DEF_ATTR(shifter, left_dir);
RPG_AUDIOFX_DEF_ATTR(shifter, right_dir);
// Vocal Morpher
RPG_AUDIOFX_DEF_INIT(vmorph, "VocalMorpher");
RPG_AUDIOFX_DEF_ATTR(vmorph, phoneme_a);
RPG_AUDIOFX_DEF_ATTR(vmorph, phoneme_b);
RPG_AUDIOFX_DEF_ATTR(vmorph, coarse_a);
RPG_AUDIOFX_DEF_ATTR(vmorph, coarse_b);
RPG_AUDIOFX_DEF_ATTR(vmorph, waveform);
RPG_AUDIOFX_DEF_ATTR(vmorph, rate);
// PitchShifer
RPG_AUDIOFX_DEF_INIT(pitch, "PitchShifter");
RPG_AUDIOFX_DEF_ATTR(pitch, coarse);
RPG_AUDIOFX_DEF_ATTR(pitch, fine);
// RingModulator
RPG_AUDIOFX_DEF_INIT(ringmod, "RingModulator");
RPG_AUDIOFX_DEF_ATTR(ringmod, freq);
RPG_AUDIOFX_DEF_ATTR(ringmod, cutoff);
RPG_AUDIOFX_DEF_ATTR(ringmod, waveform);
// AutoWah
RPG_AUDIOFX_DEF_INIT(autowah, "AutoWah");
RPG_AUDIOFX_DEF_ATTR(autowah, attack);
RPG_AUDIOFX_DEF_ATTR(autowah, release);
RPG_AUDIOFX_DEF_ATTR(autowah, resonance);
RPG_AUDIOFX_DEF_ATTR(autowah, peak_gain);
// Compressor
RPG_AUDIOFX_DEF_INIT(compressor, "Compressor");
RPG_AUDIOFX_DEF_ATTR(compressor, enabled);
// Equalizer
RPG_AUDIOFX_DEF_INIT(eq, "Equalizer");
RPG_AUDIOFX_DEF_ATTR(eq, low_gain);
RPG_AUDIOFX_DEF_ATTR(eq, low_cutoff);
RPG_AUDIOFX_DEF_ATTR(eq, mid1_gain);
RPG_AUDIOFX_DEF_ATTR(eq, mid1_center);
RPG_AUDIOFX_DEF_ATTR(eq, mid1_width);
RPG_AUDIOFX_DEF_ATTR(eq, mid2_gain);
RPG_AUDIOFX_DEF_ATTR(eq, mid2_center);
RPG_AUDIOFX_DEF_ATTR(eq, mid2_width);
RPG_AUDIOFX_DEF_ATTR(eq, high_gain);
RPG_AUDIOFX_DEF_ATTR(eq, high_cutoff);
// ReverbPreset
rb_cReverbPreset = rb_define_class_under(effects, "ReverbPreset", rb_cObject);
rb_define_alloc_func(rb_cReverbPreset, rpg_preset_alloc);
rb_define_method(rb_cReverbPreset, "dup", rpg_preset_dup, 0);
rb_define_method(rb_cReverbPreset, "_dump", rpg_preset_dump, -1);
rb_define_method(rb_cReverbPreset, "_load", rpg_preset_load, 1);
RPG_DEF_REVERB_ATTR(density);
RPG_DEF_REVERB_ATTR(diffusion);
RPG_DEF_REVERB_ATTR(gain);
RPG_DEF_REVERB_ATTR(gain_hf);
RPG_DEF_REVERB_ATTR(gain_lf);
RPG_DEF_REVERB_ATTR(decay_time);
RPG_DEF_REVERB_ATTR(decay_hf_ratio);
RPG_DEF_REVERB_ATTR(decay_lf_ratio);
RPG_DEF_REVERB_ATTR(reflections_gain);
RPG_DEF_REVERB_ATTR(reflections_delay);
RPG_DEF_REVERB_ATTR(late_reverb_gain);
RPG_DEF_REVERB_ATTR(late_reverb_delay);
RPG_DEF_REVERB_ATTR(echo_time);
RPG_DEF_REVERB_ATTR(echo_depth);
RPG_DEF_REVERB_ATTR(modulation_time);
RPG_DEF_REVERB_ATTR(modulation_depth);
RPG_DEF_REVERB_ATTR(hf_reference);
RPG_DEF_REVERB_ATTR(lf_reference);
RPG_DEF_REVERB_ATTR(rolloff);
RPG_DEF_REVERB_ATTR(air_absorption);
RPG_DEF_REVERB_ATTR(decay_limit);
RPG_DEF_REVERB_ATTR(reflections_pan);
RPG_DEF_REVERB_ATTR(late_reverb_pan);
// General
RPG_REVERB_PRESET(GENERIC);
RPG_REVERB_PRESET(PADDEDCELL);
RPG_REVERB_PRESET(ROOM);
RPG_REVERB_PRESET(BATHROOM);
RPG_REVERB_PRESET(LIVINGROOM);
RPG_REVERB_PRESET(STONEROOM);
RPG_REVERB_PRESET(AUDITORIUM);
RPG_REVERB_PRESET(CONCERTHALL);
RPG_REVERB_PRESET(CAVE);
RPG_REVERB_PRESET(ARENA);
RPG_REVERB_PRESET(HANGAR);
RPG_REVERB_PRESET(CARPETEDHALLWAY);
RPG_REVERB_PRESET(HALLWAY);
RPG_REVERB_PRESET(STONECORRIDOR);
RPG_REVERB_PRESET(ALLEY);
RPG_REVERB_PRESET(FOREST);
RPG_REVERB_PRESET(CITY);
RPG_REVERB_PRESET(MOUNTAINS);
RPG_REVERB_PRESET(QUARRY);
RPG_REVERB_PRESET(PLAIN);
RPG_REVERB_PRESET(PARKINGLOT);
RPG_REVERB_PRESET(SEWERPIPE);
RPG_REVERB_PRESET(UNDERWATER);
RPG_REVERB_PRESET(DRUGGED);
RPG_REVERB_PRESET(DIZZY);
RPG_REVERB_PRESET(PSYCHOTIC);
/* Castle Presets */
RPG_REVERB_PRESET(CASTLE_SMALLROOM);
RPG_REVERB_PRESET(CASTLE_SHORTPASSAGE);
RPG_REVERB_PRESET(CASTLE_MEDIUMROOM);
RPG_REVERB_PRESET(CASTLE_LARGEROOM);
RPG_REVERB_PRESET(CASTLE_LONGPASSAGE);
RPG_REVERB_PRESET(CASTLE_HALL);
RPG_REVERB_PRESET(CASTLE_CUPBOARD);
RPG_REVERB_PRESET(CASTLE_COURTYARD);
RPG_REVERB_PRESET(CASTLE_ALCOVE);
/* Factory Presets */
RPG_REVERB_PRESET(FACTORY_SMALLROOM);
RPG_REVERB_PRESET(FACTORY_SHORTPASSAGE);
RPG_REVERB_PRESET(FACTORY_MEDIUMROOM);
RPG_REVERB_PRESET(FACTORY_LARGEROOM);
RPG_REVERB_PRESET(FACTORY_LONGPASSAGE);
RPG_REVERB_PRESET(FACTORY_HALL);
RPG_REVERB_PRESET(FACTORY_CUPBOARD);
RPG_REVERB_PRESET(FACTORY_COURTYARD);
RPG_REVERB_PRESET(FACTORY_ALCOVE);
/* Ice Palace Presets */
RPG_REVERB_PRESET(ICEPALACE_SMALLROOM);
RPG_REVERB_PRESET(ICEPALACE_SHORTPASSAGE);
RPG_REVERB_PRESET(ICEPALACE_MEDIUMROOM);
RPG_REVERB_PRESET(ICEPALACE_LARGEROOM);
RPG_REVERB_PRESET(ICEPALACE_LONGPASSAGE);
RPG_REVERB_PRESET(ICEPALACE_HALL);
RPG_REVERB_PRESET(ICEPALACE_CUPBOARD);
RPG_REVERB_PRESET(ICEPALACE_COURTYARD);
RPG_REVERB_PRESET(ICEPALACE_ALCOVE);
/* Space Station Presets */
RPG_REVERB_PRESET(SPACESTATION_SMALLROOM);
RPG_REVERB_PRESET(SPACESTATION_SHORTPASSAGE);
RPG_REVERB_PRESET(SPACESTATION_MEDIUMROOM);
RPG_REVERB_PRESET(SPACESTATION_LARGEROOM);
RPG_REVERB_PRESET(SPACESTATION_LONGPASSAGE);
RPG_REVERB_PRESET(SPACESTATION_HALL);
RPG_REVERB_PRESET(SPACESTATION_CUPBOARD);
RPG_REVERB_PRESET(SPACESTATION_ALCOVE);
/* Wooden Galleon Presets */
RPG_REVERB_PRESET(WOODEN_SMALLROOM);
RPG_REVERB_PRESET(WOODEN_SHORTPASSAGE);
RPG_REVERB_PRESET(WOODEN_MEDIUMROOM);
RPG_REVERB_PRESET(WOODEN_LARGEROOM);
RPG_REVERB_PRESET(WOODEN_LONGPASSAGE);
RPG_REVERB_PRESET(WOODEN_HALL);
RPG_REVERB_PRESET(WOODEN_CUPBOARD);
RPG_REVERB_PRESET(WOODEN_COURTYARD);
RPG_REVERB_PRESET(WOODEN_ALCOVE);
/* Sports Presets */
RPG_REVERB_PRESET(SPORT_EMPTYSTADIUM);
RPG_REVERB_PRESET(SPORT_SQUASHCOURT);
RPG_REVERB_PRESET(SPORT_SMALLSWIMMINGPOOL);
RPG_REVERB_PRESET(SPORT_LARGESWIMMINGPOOL);
RPG_REVERB_PRESET(SPORT_GYMNASIUM);
RPG_REVERB_PRESET(SPORT_FULLSTADIUM);
RPG_REVERB_PRESET(SPORT_STADIUMTANNOY);
/* Prefab Presets */
RPG_REVERB_PRESET(PREFAB_WORKSHOP);
RPG_REVERB_PRESET(PREFAB_SCHOOLROOM);
RPG_REVERB_PRESET(PREFAB_PRACTISEROOM);
RPG_REVERB_PRESET(PREFAB_OUTHOUSE);
RPG_REVERB_PRESET(PREFAB_CARAVAN);
/* Dome and Pipe Presets */
RPG_REVERB_PRESET(DOME_TOMB);
RPG_REVERB_PRESET(PIPE_SMALL);
RPG_REVERB_PRESET(DOME_SAINTPAULS);
RPG_REVERB_PRESET(PIPE_LONGTHIN);
RPG_REVERB_PRESET(PIPE_LARGE);
RPG_REVERB_PRESET(PIPE_RESONANT);
/* Outdoors Presets */
RPG_REVERB_PRESET(OUTDOORS_BACKYARD);
RPG_REVERB_PRESET(OUTDOORS_ROLLINGPLAINS);
RPG_REVERB_PRESET(OUTDOORS_DEEPCANYON);
RPG_REVERB_PRESET(OUTDOORS_CREEK);
RPG_REVERB_PRESET(OUTDOORS_VALLEY);
/* Mood Presets */
RPG_REVERB_PRESET(MOOD_HEAVEN);
RPG_REVERB_PRESET(MOOD_HELL);
RPG_REVERB_PRESET(MOOD_MEMORY);
/* Driving Presets */
RPG_REVERB_PRESET(DRIVING_COMMENTATOR);
RPG_REVERB_PRESET(DRIVING_PITGARAGE);
RPG_REVERB_PRESET(DRIVING_INCAR_RACER);
RPG_REVERB_PRESET(DRIVING_INCAR_SPORTS);
RPG_REVERB_PRESET(DRIVING_INCAR_LUXURY);
RPG_REVERB_PRESET(DRIVING_FULLGRANDSTAND);
RPG_REVERB_PRESET(DRIVING_EMPTYGRANDSTAND);
RPG_REVERB_PRESET(DRIVING_TUNNEL);
/* City Presets */
RPG_REVERB_PRESET(CITY_STREETS);
RPG_REVERB_PRESET(CITY_SUBWAY);
RPG_REVERB_PRESET(CITY_MUSEUM);
RPG_REVERB_PRESET(CITY_LIBRARY);
RPG_REVERB_PRESET(CITY_UNDERPASS);
RPG_REVERB_PRESET(CITY_ABANDONED);
/* Misc. Presets */
RPG_REVERB_PRESET(DUSTYROOM);
RPG_REVERB_PRESET(CHAPEL);
RPG_REVERB_PRESET(SMALLWATERROOM);
}
| 54.693878 | 170 | 0.642397 |
e4ceb193284fe5be92de3d311c1b25f6028a891b | 3,353 | c | C | _more/case/c4rv/rv5/rv/cpu.c | al2698/sp | fceabadef49ffe6ed25dfef38e3dc418f309e128 | [
"MIT"
] | null | null | null | _more/case/c4rv/rv5/rv/cpu.c | al2698/sp | fceabadef49ffe6ed25dfef38e3dc418f309e128 | [
"MIT"
] | null | null | null | _more/case/c4rv/rv5/rv/cpu.c | al2698/sp | fceabadef49ffe6ed25dfef38e3dc418f309e128 | [
"MIT"
] | null | null | null | #include "cpu.h"
enum Id id;
uint32_t pc, ir, op, f3, f7, rd, rs1, rs2, csr, mTop;
int32_t imm;
char type;
const char *name;
uint32_t x[32];
float f[32];
uint8_t m[MMAX];
uint32_t csrs[4096];
void decode(uint32_t ir) {
id=None;
op=BITS(ir, 0, 6);
f3=BITS(ir, 12, 14);
f7=BITS(ir, 25, 31);
rd=BITS(ir, 7, 11);
rs1=BITS(ir, 15, 19);
rs2=BITS(ir, 20, 24);
csr=0;
imm=0;
switch (op) {
case 0x03:
switch (f3) {
case 0: id = Lb; break;
case 1: id = Lh; break;
case 2: id = Lw; break;
case 4: id = Lbu; break;
case 5: id = Lhu; break;
}
break;
case 0x0F:
switch (f3) {
case 0: id = Fence; break;
case 1: id = Fencei; break;
}
break;
case 0x13:
switch (f3) {
case 0: id = Addi; break;
case 1: id = Slli; break;
case 2: id = Slti; break;
case 3: id = Sltiu; break;
case 4: id = Xori; break;
case 5: id = (f7==0)? Srli : Srai; break;
case 6: id = Ori; break;
case 7: id = Andi; break;
}
break;
case 0x17:
id = Auipc;
break;
case 0x23:
switch (f3) {
case 0: id = Sb; break;
case 1: id = Sh; break;
case 2: id = Sw; break;
}
break;
case 0x33:
switch (f3) {
case 0: id = (f7==0)? Add : Sub; break;
case 1: id = Sll; break;
case 2: id = Slt; break;
case 3: id = Sltu; break;
case 4: id = Xor; break;
case 5: id = (f7==0)? Srl : Sra; break;
case 6: id = Or; break;
case 7: id = And; break;
}
break;
case 0x37: // lui
id = Lui;
break;
case 0x63:
switch (f3) {
case 0: id = Beq; break;
case 1: id = Bne; break;
case 4: id = Blt; break;
case 5: id = Bge; break;
case 6: id = Bltu; break;
case 7: id = Bgeu; break;
}
break;
case 0x67: id = Jalr; break;
case 0x6F: id = Jal; break;
case 0x73:
switch (f3) {
case 0:
if (ir == 0x00000073) id = Ecall;
if (ir == 0x00100073) id = Ebreak;
break;
case 1: id = Csrrw; break;
case 2: id = Csrrs; break;
case 3: id = Csrrc; break;
case 5: id = Csrrwi; break;
case 6: id = Csrrsi; break;
case 7: id = Csrrci; break;
}
break;
}
if (id != None) {
Op *o = &opList[id];
name = o->name;
type = o->type;
// printf("csrrw=%d\n", Csrrw);
// printf("op=%2X id=%d name=%s type=%c\n", op, id, name, type);
uint32_t t;
switch (type) {
case 'R': break;
case 'I':
if (op == 0x73) { // ex: csrrw, csrrwi
csr=BITS(ir, 20, 31);
imm=rs1=BITS(ir, 15, 19);
} else {
t=BITS(ir, 20, 31);
imm = SGN(t, 11);
}
break;
case 'S': t=BITS(ir, 25, 31)<<5|BITS(ir, 7, 11); imm=SGN(t,11); break;
case 'B': t=BITS(ir, 31, 31)<<12|BITS(ir,7,7)<<11|BITS(ir,25,30)<<5|BITS(ir,8,11)<<1; imm=SGN(t, 12); break;
case 'U': imm=(int32_t)(BITS(ir, 12, 31)<<12); break;
case 'J': t=BITS(ir, 31, 31)<<20|BITS(ir,21,30)<<1|BITS(ir,20,20)<<11|BITS(ir,12,19)<<12; imm=SGN(t,20); break;
default: printf("Instruction error !"); exit(1);
}
} else {
type = '?';
}
}
| 25.59542 | 117 | 0.471816 |
8ea725726d5e44c78f7520e1d9ea01b27202a12d | 381 | h | C | SkyWay-iOS-Sample/frameworks/SkyWay.framework/Versions/A/Headers/SKWCallOption.h | sikmi/ios_ika_test | 75d9be8010a3a67871e4a79237adb5c091db47fc | [
"MIT"
] | null | null | null | SkyWay-iOS-Sample/frameworks/SkyWay.framework/Versions/A/Headers/SKWCallOption.h | sikmi/ios_ika_test | 75d9be8010a3a67871e4a79237adb5c091db47fc | [
"MIT"
] | null | null | null | SkyWay-iOS-Sample/frameworks/SkyWay.framework/Versions/A/Headers/SKWCallOption.h | sikmi/ios_ika_test | 75d9be8010a3a67871e4a79237adb5c091db47fc | [
"MIT"
] | null | null | null | //
// SKWCallOption.h
// SKWPeer
//
#ifndef SKWPeer_SKWCallOption_h
#define SKWPeer_SKWCallOption_h
#import <Foundation/Foundation.h>
/**
SKWPeer call options
*/
@interface SKWCallOption : NSObject < NSCopying >
/// Any type of metadata associated with the connection, passed in by whoever initiated the connection.
@property (nonatomic) NSString* metadata;
@end
#endif | 16.565217 | 103 | 0.753281 |
fc8b218b6e0ec412796d9f59e617fe1853113b22 | 14,866 | h | C | proxygen/httpserver/samples/hq/HQServer.h | lucyge/proxygen | d272e1455831991076663919bd9e8a2671791f1f | [
"BSD-3-Clause"
] | null | null | null | proxygen/httpserver/samples/hq/HQServer.h | lucyge/proxygen | d272e1455831991076663919bd9e8a2671791f1f | [
"BSD-3-Clause"
] | null | null | null | proxygen/httpserver/samples/hq/HQServer.h | lucyge/proxygen | d272e1455831991076663919bd9e8a2671791f1f | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2019-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <iostream>
#include <string>
#include <proxygen/httpserver/samples/hq/SampleHandlers.h>
#include <fizz/server/AeadTicketCipher.h>
#include <fizz/server/CertManager.h>
#include <fizz/server/TicketCodec.h>
#include <folly/FileUtil.h>
#include <folly/io/async/EventBaseManager.h>
#include <proxygen/lib/http/session/HQDownstreamSession.h>
#include <proxygen/lib/http/session/HTTPSessionController.h>
#include <proxygen/lib/utils/WheelTimerInstance.h>
#include <quic/congestion_control/CongestionControllerFactory.h>
#include <quic/server/QuicServer.h>
#include <quic/server/QuicServerTransport.h>
#include <quic/server/QuicSharedUDPSocketFactory.h>
namespace quic { namespace samples {
const std::string kDefaultCertData = R"(
-----BEGIN CERTIFICATE-----
MIIGGzCCBAOgAwIBAgIJAPowD79hiDyZMA0GCSqGSIb3DQEBCwUAMIGjMQswCQYD
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTETMBEGA1UEBwwKTWVubG8gUGFy
azERMA8GA1UECgwIUHJveHlnZW4xETAPBgNVBAsMCFByb3h5Z2VuMREwDwYDVQQD
DAhQcm94eWdlbjExMC8GCSqGSIb3DQEJARYiZmFjZWJvb2stcHJveHlnZW5AZ29v
Z2xlZ3JvdXBzLmNvbTAeFw0xOTA1MDgwNjU5MDBaFw0yOTA1MDUwNjU5MDBaMIGj
MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTETMBEGA1UEBwwKTWVu
bG8gUGFyazERMA8GA1UECgwIUHJveHlnZW4xETAPBgNVBAsMCFByb3h5Z2VuMREw
DwYDVQQDDAhQcm94eWdlbjExMC8GCSqGSIb3DQEJARYiZmFjZWJvb2stcHJveHln
ZW5AZ29vZ2xlZ3JvdXBzLmNvbTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
ggIBALXZs4+YnCE8aMAL5gWNjLRm2EZiFHWoKpt42on8y+SZdb1xdSZ0rx6/jl4w
8V5aiLLNmboa1ULNWLS40mEUoqRPEUiBiN3T/3HomzMCLZ52xaaKS1sW9+ZPsSlT
omwV4HupJWKQaxpu+inY98mxGaZjzHie3AoydovD+rWWLj4mSX9DchWbC8DYq7xu
4qKedgHMJlsP3luYgnRSsZ+vlTEe/K41Czt+GGhViRNL8Nm3wZrxAGYqTx/zrqsT
R8qA3gwfPPqJJH5UprtvHXDS99yiy6MYyWBr/BbZ37A5X9pWCL09aLEIrQGQWtVu
CnBNCrQgYDgD7Y4+Q4Lfouap7I3YpuJM5cP1NO1x0Voyv2km1tmZpjUavnKyYT/v
XUCkGrWxeuMkqm68eOnadA7A8BM9b++f6NIgaexb9+Rq8QK74MpMm7/+XMWiAS9z
62hgKBd4mtUulJH1YxoQBIkfRa8pkB45nGiTrL2zzpIOoOirNe3/7FVI9LqPphPN
64ojfqZsTiGrC50R/86/p2jBs0fwrXy8opWM7Kmp1h2oNPqtgOC0Zj7IcmvEp2xa
wI6jN4XxbhDQpo3Iz/KRDxXFT4kAjdLDibWH41PccwSbHvg8zjmAGCxW6sC6bmp6
lywMzonS1VWkp1iNQ2u4bdMeDGnsaN0hOBemBLr/p3L1ee/RAgMBAAGjUDBOMB0G
A1UdDgQWBBSHFEM/GlCxZgg9qpi9REqm/RDkZDAfBgNVHSMEGDAWgBSHFEM/GlCx
Zgg9qpi9REqm/RDkZDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQBG
AtowRS0Wsr9cVRKVxEM/7ZxCDcrTg7gUBD/S8RYnS2bJp5ut/3SgO0FZsQKG4k8O
CXE/dQgwIaBqxSioE3L/l+m/+gedZgqaXg7l6EJLr20sUB5PVrJoQznMIwr/FuYZ
LG4nKK/K7eKf2m1Gn54kpeWz+BtgIRU4YPkZHGtQW3ER+wnmlPQfGDiN0JymqR80
TTXlgg03L6jCFQpYGKCLbKpql+cBixmI6TeUtArosCsqZokUXNM7j5u7m1IhY1EL
pNpSaUMU7LmHOmfnxIHzmNzages+mxKOHJLKBbuQx0u87uGy3HInwbNK7hDHXWLF
mXPXDhrWjBbm1RPnq8cX9nFuPS6Cd+hROEr+VB7m+Sij5QyV5pRBS0x/54tiiEv3
8eIFl6aYqTBcCMrtlxVn8sHcA/iGrysIuidWVxQfs4wmM/apR5YgSjTvN/OAB5Mo
/5RWdxBg3jNPGk/GzPDk6FcN5kp7yRLLyAOAnPDUQRC8CkSkyOwriOMe310CnTL4
KCWp7UpoF/qZJEGhYffH85SORpxj09284tZUnLSthnRmIdYB2kWg9AARu3Vhugx8
E9HGSZzTGAsPEBikDbpUimN0zWLw8VJKL+KJURl4dX4tDRe+R2u5cWm8x3HOcDUI
j9aXkPagbL/an2g05K0hIhyANbER7HAZlJ21pJdCIQ==
-----END CERTIFICATE-----
)";
const std::string kDefaultKeyData = R"(
-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEAtdmzj5icITxowAvmBY2MtGbYRmIUdagqm3jaifzL5Jl1vXF1
JnSvHr+OXjDxXlqIss2ZuhrVQs1YtLjSYRSipE8RSIGI3dP/ceibMwItnnbFpopL
Wxb35k+xKVOibBXge6klYpBrGm76Kdj3ybEZpmPMeJ7cCjJ2i8P6tZYuPiZJf0Ny
FZsLwNirvG7iop52AcwmWw/eW5iCdFKxn6+VMR78rjULO34YaFWJE0vw2bfBmvEA
ZipPH/OuqxNHyoDeDB88+okkflSmu28dcNL33KLLoxjJYGv8FtnfsDlf2lYIvT1o
sQitAZBa1W4KcE0KtCBgOAPtjj5Dgt+i5qnsjdim4kzlw/U07XHRWjK/aSbW2Zmm
NRq+crJhP+9dQKQatbF64ySqbrx46dp0DsDwEz1v75/o0iBp7Fv35GrxArvgykyb
v/5cxaIBL3PraGAoF3ia1S6UkfVjGhAEiR9FrymQHjmcaJOsvbPOkg6g6Ks17f/s
VUj0uo+mE83riiN+pmxOIasLnRH/zr+naMGzR/CtfLyilYzsqanWHag0+q2A4LRm
Pshya8SnbFrAjqM3hfFuENCmjcjP8pEPFcVPiQCN0sOJtYfjU9xzBJse+DzOOYAY
LFbqwLpuanqXLAzOidLVVaSnWI1Da7ht0x4Maexo3SE4F6YEuv+ncvV579ECAwEA
AQKCAgBg5/5UC1NIMtTvYmfVlbThfdzKxQF6IX9zElgDKH/O9ihUJ93x/ERF8nZ/
oz08tqoZ/o5pKltzGdKnm8YgjcqOHMRtCvpQm+SIYxgxenus8kYplZDKndbFGLqj
9zmat53EyEJv393zXChbnI+PH503mf8gWCeSF4osuOclVT6XR/fqpZpqARGmVtBN
vhlv51mjY5Mc+7vWu9LpAhg9rGeooYatnv65WVzQXKSLb/CNVOsLElrQFsPLlyQB
bmjXdQzfENaB/AtCdwHS6EecFBCZtvclltPZWjIgS0J0ul5mD2rgzZS4opLvPmnp
SpateaC2lHox34X8Qxne6CX7HZo8phw1g3Lt5378cAcSOxQGyjCw3k7CS28Uwze6
4t7VSn9VxWviYiIV+sgj0EbEyJ/K2YcRKDTG1+jY3AuuTR7lcTO35MCroaQIpk14
4ywTKT1HSTkPV5bNYB3tD4fHAB24Q9rs7GvZgeGWWv3RQTWVTZXnx3zuy5Uh8quy
0Nu8OAEZcKNo+Qq2iTTMf4m9F7OMkWq3aGzdeTBsiKnkaYKyYrNiSNQHgepO5jBT
jRGgJaA7LUakenb0yCexpz5u06zWWeCHu2f7STaVELFWAzvu5WfFcIZbPIY5zGDR
gwcrOQJGAc6CKZI6QCd/h0ruwux8z0E9UAnrxHYK/oaov2Oj8QKCAQEA6FphCswr
7ZwB+EXLIZ0eIfDEg3ms1+bEjhMxq4if7FUVS8OOJBqhn0Q1Tj+goCuGtZdwmNqA
nTjh2A0MDYkBmqpyY+BiJRA/87qVYESPNObMs39Sk6CwKk0esHiquyiMavj1pqYw
Sje5cEdcB551MncyxL+IjC2GGojAJnolgV1doLh08Y6pHa6OkrwjmQxJc7jDBQEv
6h/m3J9Fp1cjdkiM8A3MWW/LomZUEqQerjnW7d0YxbgKk4peGq+kymgZIESuaeaI
36fPy9Md53XAs+eHES/YLbdM54pAQR93fta0GoxkGCc0lEr/z917ybyj5AljYwRq
BiPDEVpyqPHeEwKCAQEAyFuMm5z4crMiE843w1vOiTo17uqG1m7x4qbpY7+TA+nd
d491CPkt7M+eDjlCplHhDYjXWOBKrPnaijemA+GMubOJBJyitNsIq0T+wnwU20PA
THqm7dOuQVeBW9EEmMxLoq7YEFx6CnQMHhWP0JlCRwXTB4ksQsZX6GRUtJ5dAwaQ
ALUuydJ0nVtTFb07WudK654xlkpq5gxB1zljBInHV8hQgsRnXY0SijtGzbenHWvs
jBmXTiOeOBVGehENNxolrLB07JhsXM4/9UAtn+nxESosM0zBGJC79pW3yVb+/7FL
0tEFi4e040ock0BlxVlOBkayAA/hAaaBvAhlUs2nCwKCAQEAosSdcojwxPUi1B9g
W13LfA9EOq4EDQLV8okzpGyDS3WXA4ositI1InMPvI8KIOoc5hz+fbWjn3/3hfgt
11WA0C5TD/BiEIC/rCeq+NNOVsrP33Z0DILmpdt8gjclsxKGu3FH9MQ60+MRfrwe
lh/FDeM+p2FdcIV7ih7+LHYoy+Tx7+MH2SgNBIQB0H0HmvFmizCFPX5FaIeMnETe
8Ik0iGnugUPJQWX1iwCQKLbb30UZcWwPLILutciaf6tHj5s47sfuPrWGcNcH1EtC
iaCNq/mnPrz7fZsIvrK0rGo0taAGbwqmG91rEe8wIReQ3hPN47NH8ldnRoHK5t8r
r3owDQKCAQBWw/avSRn6qgKe6xYQ/wgBO3kxvtSntiIAEmJN9R+YeUWUSkbXnPk7
bWm4JSns1taMQu9nKLKOGCGA67p0Qc/sd4hlu+NmSNiHOvjMhmmNzthPBmqV4a67
00ZM2caQ2SAEEo21ACdFsZ2xxYqjPkuKcEZEJC5LuJNHK3PXSCFldwkTlWLuuboQ
jwT7DBjRNAqo4Lf+qrmCaFp29v4fb/8oz7G1/5H33Gjj/emamua/AgbNYSO6Dgit
puD/abT8YNFh6ISqFRQQWK0v6xwW/XuNAGNlz95rYfpUPd/6TDdfyYrZf/VTyHAY
Yfbf+epYvWThqOnaxwWc7luOb2BZrH+jAoIBAEODPVTsGYwqh5D5wqV1QikczGz4
/37CgGNIWkHvH/dadLDiAQ6DGuMDiJ6pvRQaZCoALdovjzFHH4JDJR6fCkZzKkQs
eaF+jB9pzq3GEXylU9JPIPs58jozC0S9HVsBN3v80jGRTfm5tRvQ6fNJhmYmuxNk
TA+w548kYHiRLAQVGgAqDsIZ1Enx55TaKj60Dquo7d6Bt6xCb+aE4UFtEZNOfEa5
IN+p06Nnnm2ZVTRebTx/WnnG+lTXSOuBuGAGpuOSa3yi84kFfYxBFgGcgUQt4i1M
CzoemuHOSmcvQpU604U+J20FO2gaiYJFxz1h1v+Z/9edY9R9NCwmyFa3LfI=
-----END RSA PRIVATE KEY-----
)";
static std::atomic<bool> shouldPassHealthChecks{true};
class HQSessionController : public proxygen::HTTPSessionController {
public:
using StreamData = std::pair<folly::IOBufQueue, bool>;
HQSessionController(const std::string& version) : version_(version) {
}
~HQSessionController() override = default;
proxygen::HQSession* createSession(
const std::chrono::milliseconds txnTimeout) {
wangle::TransportInfo tinfo;
session_ = new proxygen::HQDownstreamSession(txnTimeout,
this,
tinfo,
nullptr); // InfoCallback
return session_;
}
void startSession(std::shared_ptr<quic::QuicSocket> sock) {
CHECK(session_);
session_->setSocket(std::move(sock));
session_->startNow();
}
proxygen::HTTPTransactionHandler* getRequestHandler(
proxygen::HTTPTransaction& /*txn*/, proxygen::HTTPMessage* msg) override {
DCHECK(msg);
const std::string& path = msg->getPath();
if (path == "/" || path == "/echo") {
return new EchoHandler(version_);
}
if (path == "/continue") {
return new ContinueHandler(version_);
}
if (path.size() > 1 && path[0] == '/' && std::isdigit(path[1])) {
return new RandBytesGenHandler(version_);
}
if (path == "/status") {
return new HealthCheckHandler(shouldPassHealthChecks, version_);
}
if (path == "/status_ok") {
shouldPassHealthChecks = true;
return new HealthCheckHandler(true, version_);
}
if (path == "/status_fail") {
shouldPassHealthChecks = false;
return new HealthCheckHandler(true, version_);
}
if (path == "/wait" || path == "/release") {
return new WaitReleaseHandler(
folly::EventBaseManager::get()->getEventBase(), version_);
}
return new DummyHandler;
}
proxygen::HTTPTransactionHandler* getParseErrorHandler(
proxygen::HTTPTransaction* /*txn*/,
const proxygen::HTTPException& /*error*/,
const folly::SocketAddress& /*localAddress*/) override {
return nullptr;
}
proxygen::HTTPTransactionHandler* getTransactionTimeoutHandler(
proxygen::HTTPTransaction* /*txn*/,
const folly::SocketAddress& /*localAddress*/) override {
return nullptr;
}
void attachSession(proxygen::HTTPSessionBase* /*session*/) override {
}
void detachSession(const proxygen::HTTPSessionBase* /*session*/) override {
delete this;
}
private:
proxygen::HQSession* session_{nullptr};
std::string version_;
};
class HQServerTransportFactory : public quic::QuicServerTransportFactory {
public:
~HQServerTransportFactory() override {
}
HQServerTransportFactory(folly::SocketAddress localAddr,
const std::string& version,
const std::chrono::milliseconds txnTimeout)
: localAddr_(std::move(localAddr)),
txnTimeout_(txnTimeout),
version_(version) {
}
quic::QuicServerTransport::Ptr make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
const folly::SocketAddress& /* peerAddr */,
std::shared_ptr<const fizz::server::FizzServerContext>
ctx) noexcept override {
// Session controller is self owning
auto hqSessionController = new HQSessionController(version_);
auto session = hqSessionController->createSession(txnTimeout_);
CHECK(evb == socket->getEventBase());
auto transport =
quic::QuicServerTransport::make(evb, std::move(socket), *session, ctx);
hqSessionController->startSession(transport);
return transport;
}
private:
folly::SocketAddress localAddr_;
std::chrono::milliseconds txnTimeout_;
std::string version_;
};
class HQServer {
public:
explicit HQServer(
const std::string& host,
uint16_t port,
const std::string& version,
const std::chrono::milliseconds txnTimeout,
quic::TransportSettings transportSettings = quic::TransportSettings(),
folly::Optional<quic::QuicVersion> draftVersion = folly::none,
bool useDraftFirst = true)
: host_(host),
port_(port),
txnTimeout_(txnTimeout),
server_(quic::QuicServer::createQuicServer()) {
localAddr_.setFromHostPort(host_, port_);
server_->setCongestionControllerFactory(
std::make_shared<DefaultCongestionControllerFactory>());
server_->setTransportSettings(transportSettings);
server_->setQuicServerTransportFactory(
std::make_unique<HQServerTransportFactory>(
localAddr_, version, txnTimeout_));
server_->setQuicUDPSocketFactory(
std::make_unique<QuicSharedUDPSocketFactory>());
server_->setHealthCheckToken("health");
std::vector<QuicVersion> versions;
if (useDraftFirst && draftVersion) {
versions.push_back(*draftVersion);
}
versions.push_back(QuicVersion::MVFST);
if (!useDraftFirst && draftVersion) {
versions.push_back(*draftVersion);
}
server_->setSupportedVersion(std::move(versions));
}
static std::shared_ptr<const fizz::server::FizzServerContext>
createFizzContext(const std::string& certfile,
const std::string& keyfile,
fizz::server::ClientAuthMode clientAuth =
fizz::server::ClientAuthMode::None) {
std::string certData = kDefaultCertData;
if (!certfile.empty()) {
folly::readFile(certfile.c_str(), certData);
}
std::string keyData = kDefaultKeyData;
if (!keyfile.empty()) {
folly::readFile(keyfile.c_str(), keyData);
}
auto cert = fizz::CertUtils::makeSelfCert(certData, keyData);
auto certManager = std::make_unique<fizz::server::CertManager>();
certManager->addCert(std::move(cert), true);
auto serverCtx = std::make_shared<fizz::server::FizzServerContext>();
serverCtx->setCertManager(std::move(certManager));
auto ticketCipher = std::make_shared<fizz::server::AeadTicketCipher<
fizz::OpenSSLEVPCipher<fizz::AESGCM128>,
fizz::server::TicketCodec<fizz::server::CertificateStorage::X509>,
fizz::HkdfImpl<fizz::Sha256>>>();
std::array<uint8_t, 32> ticketSeed;
folly::Random::secureRandom(ticketSeed.data(), ticketSeed.size());
ticketCipher->setTicketSecrets({{folly::range(ticketSeed)}});
serverCtx->setTicketCipher(ticketCipher);
serverCtx->setClientAuthMode(clientAuth);
serverCtx->setSupportedAlpns({"h1q-fb",
"h1q-fb-v2",
proxygen::kH3FBCurrentDraft,
proxygen::kH3CurrentDraft,
proxygen::kHQCurrentDraft});
serverCtx->setSendNewSessionTicket(false);
serverCtx->setEarlyDataFbOnly(false);
serverCtx->setVersionFallbackEnabled(false);
fizz::server::ClockSkewTolerance tolerance;
tolerance.before = std::chrono::minutes(-5);
tolerance.after = std::chrono::minutes(5);
std::shared_ptr<fizz::server::ReplayCache> replayCache =
std::make_shared<fizz::server::AllowAllReplayReplayCache>();
serverCtx->setEarlyDataSettings(true, tolerance, std::move(replayCache));
return serverCtx;
}
void setTlsSettings(const std::string& certfile,
const std::string& keyfile,
fizz::server::ClientAuthMode clientAuth) {
server_->setFizzContext(createFizzContext(certfile, keyfile, clientAuth));
}
void start() {
server_->start(localAddr_, std::thread::hardware_concurrency());
}
void run() {
eventbase_.loopForever();
}
const folly::SocketAddress getAddress() const {
server_->waitUntilInitialized();
auto boundAddr = server_->getAddress();
LOG(INFO) << "HQ server started at: " << boundAddr.describe();
return boundAddr;
}
void stop() {
server_->shutdown();
eventbase_.terminateLoopSoon();
}
void rejectNewConnections(bool reject) {
server_->rejectNewConnections(reject);
}
private:
std::string host_;
uint16_t port_;
folly::SocketAddress localAddr_;
std::chrono::milliseconds txnTimeout_;
folly::EventBase eventbase_;
std::shared_ptr<quic::QuicServer> server_;
folly::Baton<> cv_;
};
}} // namespace quic::samples
| 40.070081 | 80 | 0.771492 |
d35ed5ebabf591ee7847585a6d54c1ca792eb33b | 42,343 | c | C | third_party/silabs/gecko_sdk_suite/v1.0/protocol/thread_2.2/app/thread/plugin/zcl/zcl-core/zcl-core-attribute.c | syin2/openthread | a9f42768ec221380f42bfd311bc68e784b2163a6 | [
"BSD-3-Clause"
] | 1 | 2018-12-31T08:12:49.000Z | 2018-12-31T08:12:49.000Z | third_party/silabs/gecko_sdk_suite/v1.0/protocol/thread_2.2/app/thread/plugin/zcl/zcl-core/zcl-core-attribute.c | syin2/openthread | a9f42768ec221380f42bfd311bc68e784b2163a6 | [
"BSD-3-Clause"
] | null | null | null | third_party/silabs/gecko_sdk_suite/v1.0/protocol/thread_2.2/app/thread/plugin/zcl/zcl-core/zcl-core-attribute.c | syin2/openthread | a9f42768ec221380f42bfd311bc68e784b2163a6 | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2015 Silicon Laboratories, Inc.
#include PLATFORM_HEADER
#include CONFIGURATION_HEADER
#include "thread-bookkeeping.h"
#include "thread-callbacks.h"
#include "zcl-core.h"
typedef struct {
EmberZclAttributeContext_t context;
EmberZclReadAttributeResponseHandler readHandler;
EmberZclWriteAttributeResponseHandler writeHandler;
} Response;
typedef struct {
uint16_t count;
uint16_t usedCounts;
} FilterState;
static size_t attributeSize(const EmZclAttributeEntry_t *attribute,
const void *data);
static void *attributeDataLocation(EmberZclEndpointIndex_t endpointIndex,
const EmZclAttributeEntry_t *attribute);
static const void *attributeDefaultMinMaxLocation(const EmZclAttributeEntry_t *attribute,
EmZclAttributeMask_t dataBit);
static bool isValueLocIndirect(const EmZclAttributeEntry_t *attribute);
static bool isLessThan(const uint8_t *dataA,
size_t dataALength,
const uint8_t *dataB,
size_t dataBLength);
static bool getAttributeIdsHandler(const EmZclContext_t *context,
CborState *state,
void *data);
static bool getAttributeHandler(const EmZclContext_t *context,
CborState *state,
void *data);
static bool updateAttributeHandler(const EmZclContext_t *context,
CborState *state,
void *data);
static bool filterAttribute(const EmZclContext_t *context,
FilterState *state,
const EmZclAttributeEntry_t *attribute);
static void readWriteResponseHandler(EmberZclMessageStatus_t status,
EmberCoapCode code,
const uint8_t *payload,
size_t payloadLength,
const void *applicationData,
uint16_t applicationDataLength);
static void handleRead(EmberZclMessageStatus_t status,
const Response *response);
static void handleWrite(EmberZclMessageStatus_t status,
const Response *response);
static EmberZclStatus_t writeAttribute(EmberZclEndpointIndex_t index,
EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
const void *data,
size_t dataLength);
static void callPostAttributeChange(EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
const void *data,
size_t dataLength);
static bool callPreAttributeChange(EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
const void *data,
size_t dataLength);
static size_t tokenize(const EmZclContext_t *context,
void *skipData,
uint8_t depth,
const uint8_t **tokens,
size_t *tokenLengths);
#define oneBitSet(mask) ((mask) != 0 && (mask) == ((mask) & -(mask)))
#define attributeDefaultLocation(a) \
attributeDefaultMinMaxLocation((a), EM_ZCL_ATTRIBUTE_DATA_DEFAULT)
#define attributeMinimumLocation(a) \
attributeDefaultMinMaxLocation((a), EM_ZCL_ATTRIBUTE_DATA_MINIMUM)
#define attributeMaximumLocation(a) \
attributeDefaultMinMaxLocation((a), EM_ZCL_ATTRIBUTE_DATA_MAXIMUM)
// This limit is copied from MAX_ENCODED_URI in coap.c.
#define MAX_ATTRIBUTE_URI_LENGTH 64
void emberZclResetAttributes(EmberZclEndpointId_t endpointId)
{
// TODO: Handle tokens.
for (size_t i = 0; i < EM_ZCL_ATTRIBUTE_COUNT; i++) {
const EmZclAttributeEntry_t *attribute = emZclAttributeTable + i;
EmberZclEndpointIndex_t index
= emberZclEndpointIdToIndex(endpointId, attribute->clusterSpec);
if (index != EMBER_ZCL_ENDPOINT_INDEX_NULL
&& emZclIsAttributeLocal(attribute)) {
const void *dephault = attributeDefaultLocation(attribute);
writeAttribute(index, endpointId, attribute, dephault, attribute->size);
callPostAttributeChange(endpointId, attribute, dephault, attribute->size);
}
}
}
EmberZclStatus_t emberZclReadAttribute(EmberZclEndpointId_t endpointId,
const EmberZclClusterSpec_t *clusterSpec,
EmberZclAttributeId_t attributeId,
void *buffer,
size_t bufferLength)
{
return emZclReadAttributeEntry(endpointId,
emZclFindAttribute(clusterSpec,
attributeId,
false), // exclude remote
buffer,
bufferLength);
}
EmberZclStatus_t emberZclWriteAttribute(EmberZclEndpointId_t endpointId,
const EmberZclClusterSpec_t *clusterSpec,
EmberZclAttributeId_t attributeId,
const void *buffer,
size_t bufferLength)
{
return emZclWriteAttributeEntry(endpointId,
emZclFindAttribute(clusterSpec,
attributeId,
false), // exclude remote
buffer,
bufferLength);
}
EmberZclStatus_t emberZclExternalAttributeChanged(EmberZclEndpointId_t endpointId,
const EmberZclClusterSpec_t *clusterSpec,
EmberZclAttributeId_t attributeId,
const void *buffer,
size_t bufferLength)
{
if (!emZclEndpointHasCluster(endpointId, clusterSpec)) {
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
const EmZclAttributeEntry_t *attribute
= emZclFindAttribute(clusterSpec, attributeId, false); // exclude remote
if (attribute == NULL) {
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
if (!emZclIsAttributeExternal(attribute)) {
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
callPostAttributeChange(endpointId, attribute, buffer, bufferLength);
return EMBER_ZCL_STATUS_SUCCESS;
}
const EmZclAttributeEntry_t *emZclFindAttribute(const EmberZclClusterSpec_t *clusterSpec,
EmberZclAttributeId_t attributeId,
bool includeRemote)
{
for (size_t i = 0; i < EM_ZCL_ATTRIBUTE_COUNT; i++) {
if (emberZclCompareClusterSpec(clusterSpec,
emZclAttributeTable[i].clusterSpec)
&& attributeId == emZclAttributeTable[i].attributeId
&& (includeRemote || emZclIsAttributeLocal(&emZclAttributeTable[i]))) {
return &emZclAttributeTable[i];
}
}
return NULL;
}
EmberZclStatus_t emZclReadAttributeEntry(EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
void *buffer,
size_t bufferLength)
{
if (attribute == NULL || emZclIsAttributeRemote(attribute)) {
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
EmberZclEndpointIndex_t index
= emberZclEndpointIdToIndex(endpointId, attribute->clusterSpec);
if (index == EMBER_ZCL_ENDPOINT_INDEX_NULL) {
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
if (emZclIsAttributeExternal(attribute)) {
return emberZclReadExternalAttributeCallback(endpointId,
attribute->clusterSpec,
attribute->attributeId,
buffer,
bufferLength);
}
// For variable-length attributes, we are a little flexible for buffer sizes.
// As long as there is enough space in the buffer to store the current value
// of the attribute, we permit the read, even if the buffer is smaller than
// the maximum possible size of the attribute.
void *data = attributeDataLocation(index, attribute);
size_t size = attributeSize(attribute, data);
if (bufferLength < size) {
return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE;
}
MEMCOPY(buffer, data, size);
return EMBER_ZCL_STATUS_SUCCESS;
}
EmberZclStatus_t emZclWriteAttributeEntry(EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
const void *buffer,
size_t bufferLength)
{
if (attribute == NULL || emZclIsAttributeRemote(attribute)) {
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
EmberZclEndpointIndex_t index
= emberZclEndpointIdToIndex(endpointId, attribute->clusterSpec);
if (index == EMBER_ZCL_ENDPOINT_INDEX_NULL) {
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
// For variable-length attributes, we are a little flexible for buffer sizes.
// As long as there is enough space in the table to store the new value of
// the attribute, we permit the write, even if the actual length of buffer
// containing the new value is larger than what we have space for.
size_t size = attributeSize(attribute, buffer);
if (attribute->size < size) {
return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE;
}
if (bufferLength == 0
|| bufferLength > EMBER_ZCL_ATTRIBUTE_MAX_SIZE
|| (emZclIsAttributeBounded(attribute)
&& (isLessThan(buffer,
bufferLength,
attributeMinimumLocation(attribute),
attribute->size)
|| isLessThan(attributeMaximumLocation(attribute),
attribute->size,
buffer,
bufferLength)))) {
return EMBER_ZCL_STATUS_INVALID_VALUE;
}
if (!callPreAttributeChange(endpointId, attribute, buffer, size)) {
return EMBER_ZCL_STATUS_FAILURE;
}
EmberZclStatus_t status = writeAttribute(index,
endpointId,
attribute,
buffer,
size);
if (status == EMBER_ZCL_STATUS_SUCCESS) {
callPostAttributeChange(endpointId, attribute, buffer, size);
}
return status;
}
bool emZclReadEncodeAttributeKeyValue(CborState *state,
EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
void *buffer,
size_t bufferLength)
{
if (attribute == NULL) {
return true;
} else {
return ((emZclReadAttributeEntry(endpointId,
attribute,
buffer,
attribute->size)
== EMBER_ZCL_STATUS_SUCCESS)
&& emCborEncodeMapEntry(state,
attribute->attributeId,
attribute->type,
attribute->size,
(isValueLocIndirect(attribute)
? (const uint8_t *)&buffer
: buffer)));
}
}
static size_t attributeSize(const EmZclAttributeEntry_t *attribute,
const void *data)
{
if (attribute->type == EMBER_ZCLIP_TYPE_UINT8_LENGTH_STRING) {
return emberZclStringSize(data);
} else if (attribute->type == EMBER_ZCLIP_TYPE_UINT16_LENGTH_STRING) {
return emberZclLongStringSize(data);
} else {
return attribute->size;
}
}
static void *attributeDataLocation(EmberZclEndpointIndex_t endpointIndex,
const EmZclAttributeEntry_t *attribute)
{
// AppBuilder generates the maximum size for all of the attribute data, so
// that the app can create a buffer to hold all of the runtime attribute
// values. This maximum size factors in attributes that need multiple data
// instances since they exist on multiple endpoints and are not singleton.
// When an attribute has multiple data instances, the values are stored
// sequentially in the buffer. AppBuilder also generates the per-attribute
// offset into the buffer so that it is easy to go from attribute to value.
static uint8_t attributeData[EM_ZCL_ATTRIBUTE_DATA_SIZE] = EM_ZCL_ATTRIBUTE_DEFAULTS;
return (attributeData
+ attribute->dataOffset
+ (attribute->size
* (emZclIsAttributeSingleton(attribute)
? 0
: endpointIndex)));
}
const void *attributeDefaultMinMaxLocation(const EmZclAttributeEntry_t *attribute,
EmZclAttributeMask_t dataBit)
{
// AppBuilder generates a table of attribute "constants" that are all possible
// values of defaults, minimums, and maximums that the user has configured
// their app to use. We don't generate attribute constants that are zero. We
// always assume that if an attribute doesn't have a bit set for a
// default/min/max value in its mask, then the value is all zeros.
//
// Each attribute uses an index into a lookup table to figure out where each
// of their default/min/max constants are located in the constant table. The
// lookup table stores up to 3 indices per attribute (always in this order):
// a default value index, a minimum value index, and a maximum value index.
// However, all of these indices are optional. If an attribute does not have
// a default/min/max value, or the value is all 0's, or the app was
// configured not to include that constant through AppBuilder (in the case of
// min/max values), then an index will not be generated.
assert(READBITS(dataBit, EM_ZCL_ATTRIBUTE_DATA_MASK) && oneBitSet(dataBit));
if (!READBITS(attribute->mask, dataBit)) {
const static uint8_t zeros[EMBER_ZCL_ATTRIBUTE_MAX_SIZE] = {0};
return zeros;
}
const size_t *lookupLocation = (emZclAttributeDefaultMinMaxLookupTable
+ attribute->defaultMinMaxLookupOffset);
for (EmZclAttributeMask_t mask = EM_ZCL_ATTRIBUTE_DATA_DEFAULT;
mask < dataBit;
mask <<= 1) {
if (READBITS(attribute->mask, mask)) {
lookupLocation ++;
}
}
return emZclAttributeDefaultMinMaxData + *lookupLocation;
}
static bool isValueLocIndirect(const EmZclAttributeEntry_t *attribute)
{
// For the CBOR encoder and decoder, in most cases, valueLoc is a pointer to
// some data. For strings, valueLoc is a pointer to a pointer to some data.
// For commands, this is handled automatically by the structs and specs. For
// attributes, it must be done manually.
switch (attribute->type) {
case EMBER_ZCLIP_TYPE_UINT8_LENGTH_STRING:
case EMBER_ZCLIP_TYPE_UINT16_LENGTH_STRING:
return true;
default:
return false;
}
}
static bool isLessThan(const uint8_t *dataA,
size_t dataALength,
const uint8_t *dataB,
size_t dataBLength)
{
// This function assumes a few things.
// - The data* arrays follow the native machine endianness.
// - The data* arrays represent the same (ZCL) data types.
// - The data* arrays represent numeric data types.
// - The data*Length values are not 0.
// - The data*Length values are no greater than EMBER_ZCL_ATTRIBUTE_MAX_SIZE.
uint8_t dataABigEndian[EMBER_ZCL_ATTRIBUTE_MAX_SIZE] = {0};
uint8_t dataBBigEndian[EMBER_ZCL_ATTRIBUTE_MAX_SIZE] = {0};
size_t dataAOffset = EMBER_ZCL_ATTRIBUTE_MAX_SIZE - dataALength;
size_t dataBOffset = EMBER_ZCL_ATTRIBUTE_MAX_SIZE - dataBLength;
#if BIGENDIAN_CPU
MEMMOVE(dataABigEndian + dataAOffset, dataA, dataALength);
MEMMOVE(dataBBigEndian + dataBOffset, dataB, dataBLength);
#else
emberReverseMemCopy(dataABigEndian + dataAOffset, dataA, dataALength);
emberReverseMemCopy(dataBBigEndian + dataBOffset, dataB, dataBLength);
#endif
return (MEMCOMPARE(dataABigEndian,
dataBBigEndian,
EMBER_ZCL_ATTRIBUTE_MAX_SIZE)
< 0);
}
static bool getAttributeIdsHandler(const EmZclContext_t *context,
CborState *state,
void *data)
{
// If there are no queries, then we return an array of attribute ids.
// Otherwise, we return a map from the filtered attribute ids to
// their values.
const EmZclAttributeQuery_t *query = &context->attributeQuery;
bool array = (query->filterCount == 0);
if (array) {
emCborEncodeIndefiniteArray(state);
} else {
emCborEncodeIndefiniteMap(state);
}
// TODO: Handle unreadable attributes.
FilterState filterState = {0};
for (size_t i = 0; i < EM_ZCL_ATTRIBUTE_COUNT; i++) {
const EmZclAttributeEntry_t *attribute = emZclAttributeTable + i;
uint8_t buffer[EMBER_ZCL_ATTRIBUTE_MAX_SIZE];
if (emberZclCompareClusterSpec(&context->clusterSpec,
attribute->clusterSpec)
&& emZclIsAttributeLocal(attribute)
&& filterAttribute(context, &filterState, attribute)
&& !(array
? emCborEncodeValue(state,
EMBER_ZCLIP_TYPE_UNSIGNED_INTEGER,
sizeof(attribute->attributeId),
(const uint8_t *)&attribute->attributeId)
: emZclReadEncodeAttributeKeyValue(state,
context->endpoint->endpointId,
attribute,
buffer,
sizeof(buffer)))) {
return false;
}
}
return emCborEncodeBreak(state);
}
static bool getAttributeHandler(const EmZclContext_t *context,
CborState *state,
void *data)
{
// TODO: Handle unreadable attributes.
uint8_t buffer[EMBER_ZCL_ATTRIBUTE_MAX_SIZE];
return (emCborEncodeIndefiniteMap(state)
&& emZclReadEncodeAttributeKeyValue(state,
context->endpoint->endpointId,
context->attribute,
buffer,
sizeof(buffer))
&& emCborEncodeBreak(state));
}
static bool updateAttributeHandler(const EmZclContext_t *context,
CborState *state,
void *data)
{
// TODO: support undivided write.
CborState inState;
emCborDecodeStart(&inState, context->payload, context->payloadLength);
emCborEncodeIndefiniteMap(state);
if (emCborDecodeMap(&inState)) {
EmberZclAttributeId_t attributeId;
while (emCborDecodeValue(&inState,
EMBER_ZCLIP_TYPE_UNSIGNED_INTEGER,
sizeof(attributeId),
(uint8_t *)&attributeId)) {
if (context->attribute == NULL
|| context->attribute->attributeId == attributeId) {
const EmZclAttributeEntry_t *attribute
= (context->attribute == NULL
? emZclFindAttribute(&context->clusterSpec,
attributeId,
false) // exclude remote
: context->attribute);
// TODO: The CBOR decoder doesn't permit skipping over values. If we
// don't have the attribute, we don't know what it's encoding is, so we
// can't read and ignore it either.
if (attribute == NULL) {
return false;
}
uint8_t buffer[EMBER_ZCL_ATTRIBUTE_MAX_SIZE], *p = buffer;
if (!emCborDecodeValue(&inState,
attribute->type,
attribute->size,
buffer)) {
return false;
}
EmberZclStatus_t status = EMBER_ZCL_STATUS_READ_ONLY;
if (emZclIsAttributeWritable(attribute)) {
status = emZclWriteAttributeEntry(context->endpoint->endpointId,
attribute,
(isValueLocIndirect(attribute)
? *((uint8_t **)p)
: p),
attribute->size);
}
if (!emCborEncodeMapEntry(state,
attribute->attributeId,
EMBER_ZCLIP_TYPE_UNSIGNED_INTEGER,
sizeof(status),
&status)) {
return false;
}
}
}
}
return emCborEncodeBreak(state);
}
static bool filterAttribute(const EmZclContext_t *context,
FilterState *state,
const EmZclAttributeEntry_t *attribute)
{
EmberZclAttributeId_t attributeId = attribute->attributeId;
for (size_t i = 0; i < context->attributeQuery.filterCount; i ++) {
const EmZclAttributeQueryFilter_t *filter = &context->attributeQuery.filters[i];
switch (filter->type) {
case EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_ID:
if (attributeId == filter->data.attributeId) {
return true;
}
break;
case EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_COUNT:
if (attributeId >= filter->data.countData.start) {
if (filter->data.countData.count > state->count
&& !READBIT(state->usedCounts, i)) {
state->count = filter->data.countData.count;
}
SETBIT(state->usedCounts, i);
}
break;
case EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_RANGE:
if (attributeId >= filter->data.rangeData.start
&& attributeId <= filter->data.rangeData.end) {
return true;
}
break;
case EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_WILDCARD:
return true;
default:
assert(false);
}
}
bool ret = (context->attributeQuery.filterCount == 0 || state->count > 0);
if (state->count > 0) {
state->count --;
}
return ret;
}
EmberStatus emberZclSendAttributeRead(const EmberZclDestination_t *destination,
const EmberZclClusterSpec_t *clusterSpec,
const EmberZclAttributeId_t *attributeIds,
size_t attributeIdsCount,
const EmberZclReadAttributeResponseHandler handler)
{
// The size of this array is the maximum number of filter range data
// structures that could possibly be encoded into a URI string of length 64
// that has been optimized with range formatting. This helps us protect from
// writing off the end of the filterRangeData array in the second for loop
// below.
EmZclAttributeQueryFilterRangeData_t filterRangeData[19];
EmZclAttributeQueryFilterRangeData_t *filterRangeDatum = filterRangeData;
for (size_t i = 0; i < COUNTOF(filterRangeData); i++) {
filterRangeData[i].start = filterRangeData[i].end = EMBER_ZCL_ATTRIBUTE_NULL;
}
for (size_t i = 0; i < attributeIdsCount; i++) {
EmberZclAttributeId_t attributeId = attributeIds[i];
if (attributeId == filterRangeDatum->end + 1) {
filterRangeDatum->end = attributeId;
} else {
if (filterRangeDatum->start != EMBER_ZCL_ATTRIBUTE_NULL) {
filterRangeDatum ++;
if (filterRangeDatum - filterRangeData > sizeof(filterRangeData)) {
return EMBER_BAD_ARGUMENT;
}
}
filterRangeDatum->start = filterRangeDatum->end = attributeId;
}
}
size_t filterRangeDataCount = filterRangeDatum - filterRangeData + 1;
uint8_t uri[MAX_ATTRIBUTE_URI_LENGTH];
uint8_t *uriFinger = uri;
uriFinger += emZclAttributeToUriPath(&destination->application,
clusterSpec,
uriFinger);
*uriFinger++ = '?';
*uriFinger++ = 'f';
*uriFinger++ = '=';
for (size_t i = 0; i < filterRangeDataCount; i ++) {
uint8_t buffer[10];
uint8_t *bufferFinger = buffer;
if (i != 0) {
*bufferFinger++ = ',';
}
bufferFinger += emZclIntToHexString(filterRangeData[i].start,
sizeof(EmberZclAttributeId_t),
bufferFinger);
if (filterRangeData[i].start != filterRangeData[i].end) {
*bufferFinger++ = '-';
bufferFinger += emZclIntToHexString(filterRangeData[i].end,
sizeof(EmberZclAttributeId_t),
bufferFinger);
}
size_t bufferLength = bufferFinger - buffer;
MEMMOVE(uriFinger, buffer, bufferLength);
uriFinger += bufferLength;
if (uriFinger - uri > sizeof(uri)) {
return EMBER_BAD_ARGUMENT;
}
*uriFinger = '\0';
}
Response response = {
.context = {
.code = EMBER_COAP_CODE_EMPTY, // filled in when the response arrives
.groupId
= ((destination->application.type
== EMBER_ZCL_APPLICATION_DESTINATION_TYPE_GROUP)
? destination->application.data.groupId
: EMBER_ZCL_GROUP_NULL),
.endpointId
= ((destination->application.type
== EMBER_ZCL_APPLICATION_DESTINATION_TYPE_ENDPOINT)
? destination->application.data.endpointId
: EMBER_ZCL_ENDPOINT_NULL),
.clusterSpec = clusterSpec,
.attributeId = EMBER_ZCL_ATTRIBUTE_NULL, // filled in when the response arrives
.state = NULL, // filled in when the response arrives
},
.readHandler = handler,
.writeHandler = NULL, // unused
};
return emZclSend(&destination->network,
EMBER_COAP_CODE_GET,
uri,
NULL, // payload
0, // payload length
(handler == NULL ? NULL : readWriteResponseHandler),
&response,
sizeof(Response));
}
EmberStatus emberZclSendAttributeWrite(const EmberZclDestination_t *destination,
const EmberZclClusterSpec_t *clusterSpec,
const EmberZclAttributeWriteData_t *attributeWriteData,
size_t attributeWriteDataCount,
const EmberZclWriteAttributeResponseHandler handler)
{
CborState state;
uint8_t buffer[128];
emCborEncodeIndefiniteMapStart(&state, buffer, sizeof(buffer));
for (size_t i = 0; i < attributeWriteDataCount; i++) {
const EmZclAttributeEntry_t *attribute
= emZclFindAttribute(clusterSpec,
attributeWriteData[i].attributeId,
true); // include remote
if (attribute == NULL) {
return EMBER_BAD_ARGUMENT;
} else if (!emCborEncodeMapEntry(&state,
attribute->attributeId,
attribute->type,
attribute->size,
(isValueLocIndirect(attribute)
? (const uint8_t *)&attributeWriteData[i].buffer
: attributeWriteData[i].buffer))) {
return EMBER_ERR_FATAL;
}
}
emCborEncodeBreak(&state);
uint8_t uriPath[EMBER_ZCL_URI_PATH_MAX_LENGTH];
emZclAttributeToUriPath(&destination->application, clusterSpec, uriPath);
Response response = {
.context = {
.code = EMBER_COAP_CODE_EMPTY, // filled in when the response arrives
.groupId
= ((destination->application.type
== EMBER_ZCL_APPLICATION_DESTINATION_TYPE_GROUP)
? destination->application.data.groupId
: EMBER_ZCL_GROUP_NULL),
.endpointId
= ((destination->application.type
== EMBER_ZCL_APPLICATION_DESTINATION_TYPE_ENDPOINT)
? destination->application.data.endpointId
: EMBER_ZCL_ENDPOINT_NULL),
.clusterSpec = clusterSpec,
.attributeId = EMBER_ZCL_ATTRIBUTE_NULL, // filled in when the response arrives
.state = NULL, // filled in when the response arrives
},
.readHandler = NULL, // unused
.writeHandler = handler,
};
return emZclSend(&destination->network,
EMBER_COAP_CODE_POST,
uriPath,
buffer,
emCborEncodeSize(&state),
(handler == NULL ? NULL : readWriteResponseHandler),
&response,
sizeof(Response));
}
static void readWriteResponseHandler(EmberZclMessageStatus_t status,
EmberCoapCode code,
const uint8_t *payload,
size_t payloadLength,
const void *applicationData,
uint16_t applicationDataLength)
{
// We should only be here if the application specified a handler.
assert(applicationDataLength == sizeof(Response));
const Response *response = applicationData;
bool isRead = (*response->readHandler != NULL);
bool isWrite = (*response->writeHandler != NULL);
assert(isRead != isWrite);
((Response *)response)->context.code = code;
// TODO: What should happen for failures?
// TODO: What should happen if the overall payload is missing or malformed?
// Note that this is a separate issue from how missing or malformed responses
// from the individual endpoints should be handled.
if (status == EMBER_ZCL_MESSAGE_STATUS_COAP_RESPONSE
&& emberCoapIsSuccessResponse(code)) {
CborState state;
((Response *)response)->context.state = &state;
emCborDecodeStart(&state, payload, payloadLength);
if (response->context.groupId == EMBER_ZCL_GROUP_NULL) {
(isRead ? handleRead : handleWrite)(status, response);
return;
} else if (emCborDecodeMap(&state)) {
while (emCborDecodeValue(&state,
EMBER_ZCLIP_TYPE_UNSIGNED_INTEGER,
sizeof(response->context.endpointId),
(uint8_t *)&response->context.endpointId)) {
(isRead ? handleRead : handleWrite)(status, response);
}
return;
}
}
if (isRead) {
(*response->readHandler)(status, &response->context, NULL, 0);
} else {
(*response->writeHandler)(status,
&response->context,
EMBER_ZCL_STATUS_NULL);
}
}
static void handleRead(EmberZclMessageStatus_t status,
const Response *response)
{
// TODO: If we expect an attribute but it is missing, or it is present but
// malformed, would should we do?
if (emCborDecodeMap(response->context.state)) {
while (emCborDecodeValue(response->context.state,
EMBER_ZCLIP_TYPE_UNSIGNED_INTEGER,
sizeof(response->context.attributeId),
(uint8_t *)&response->context.attributeId)) {
const EmZclAttributeEntry_t *attribute
= emZclFindAttribute(response->context.clusterSpec,
response->context.attributeId,
true); // include remote
if (attribute == NULL) {
emCborDecodeSkipValue(response->context.state);
} else {
uint8_t buffer[EMBER_ZCL_ATTRIBUTE_MAX_SIZE];
if (emCborDecodeValue(response->context.state,
attribute->type,
attribute->size,
buffer)) {
(*response->readHandler)(status,
&response->context,
buffer,
attribute->size);
}
}
}
}
(*response->readHandler)(status, &response->context, NULL, 0);
}
static void handleWrite(EmberZclMessageStatus_t status,
const Response *response)
{
// TODO: If we expect an attribute but it is missing, or it is present but
// malformed, would should we do?
if (emCborDecodeMap(response->context.state)) {
while (emCborDecodeValue(response->context.state,
EMBER_ZCLIP_TYPE_UNSIGNED_INTEGER,
sizeof(response->context.attributeId),
(uint8_t *)&response->context.attributeId)) {
EmberZclStatus_t result;
if (!emCborDecodeValue(response->context.state,
EMBER_ZCLIP_TYPE_UNSIGNED_INTEGER,
sizeof(result),
(uint8_t *)&result)) {
break;
}
(*response->writeHandler)(status, &response->context, result);
}
return;
}
(*response->writeHandler)(status, &response->context, EMBER_ZCL_STATUS_NULL);
}
static EmberZclStatus_t writeAttribute(EmberZclEndpointIndex_t index,
EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
const void *data,
size_t dataLength)
{
EmberZclStatus_t status = EMBER_ZCL_STATUS_SUCCESS;
EmZclAttributeMask_t storageType
= READBITS(attribute->mask, EM_ZCL_ATTRIBUTE_STORAGE_TYPE_MASK);
assert(emZclIsAttributeLocal(attribute));
switch (storageType) {
case EM_ZCL_ATTRIBUTE_STORAGE_TYPE_EXTERNAL:
status = emberZclWriteExternalAttributeCallback(endpointId,
attribute->clusterSpec,
attribute->attributeId,
data,
dataLength);
break;
case EM_ZCL_ATTRIBUTE_STORAGE_TYPE_RAM:
MEMMOVE(attributeDataLocation(index, attribute), data, attribute->size);
break;
default:
assert(false);
}
return status;
}
static void callPostAttributeChange(EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
const void *data,
size_t dataLength)
{
if (emZclIsAttributeSingleton(attribute)) {
for (size_t i = 0; i < emZclEndpointCount; i++) {
if (emZclEndpointHasCluster(emZclEndpointTable[i].endpointId,
attribute->clusterSpec)) {
emZclPostAttributeChange(emZclEndpointTable[i].endpointId,
attribute->clusterSpec,
attribute->attributeId,
data,
dataLength);
}
}
} else {
emZclPostAttributeChange(endpointId,
attribute->clusterSpec,
attribute->attributeId,
data,
dataLength);
}
}
static bool callPreAttributeChange(EmberZclEndpointId_t endpointId,
const EmZclAttributeEntry_t *attribute,
const void *data,
size_t dataLength)
{
if (emZclIsAttributeSingleton(attribute)) {
for (size_t i = 0; i < emZclEndpointCount; i++) {
if (emZclEndpointHasCluster(emZclEndpointTable[i].endpointId,
attribute->clusterSpec)
&& !emZclPreAttributeChange(emZclEndpointTable[i].endpointId,
attribute->clusterSpec,
attribute->attributeId,
data,
dataLength)) {
return false;
}
}
return true;
} else {
return emZclPreAttributeChange(endpointId,
attribute->clusterSpec,
attribute->attributeId,
data,
dataLength);
}
}
static size_t tokenize(const EmZclContext_t *context,
void *skipData,
uint8_t depth,
const uint8_t **tokens,
size_t *tokenLengths)
{
uint8_t skipLength = strlen((const char *)skipData);
const uint8_t *bytes = context->uriQuery[depth] + skipLength;
size_t bytesLength = context->uriQueryLength[depth] - skipLength;
size_t count = 0;
const uint8_t *next = NULL, *end = bytes + bytesLength;
for (; bytes < end; bytes = next + 1) {
next = memchr(bytes, ',', end - bytes);
if (next == NULL) {
next = end;
} else if (next == bytes || next == end - 1) {
return 0; // 0 length strings are no good.
}
tokens[count] = bytes;
tokenLengths[count] = next - bytes;
count ++;
}
return count;
}
// .../a?f=
bool emZclAttributeUriQueryFilterParse(EmZclContext_t *context,
void *data,
uint8_t depth)
{
const uint8_t *tokens[MAX_URI_QUERY_SEGMENTS];
size_t tokenLengths[MAX_URI_QUERY_SEGMENTS];
size_t tokenCount = tokenize(context, data, depth, tokens, tokenLengths);
if (tokenCount == 0) {
return false;
}
for (size_t i = 0; i < tokenCount; i ++) {
EmZclAttributeQueryFilter_t *filter
= &context->attributeQuery.filters[context->attributeQuery.filterCount++];
if (tokenLengths[i] == 1 && tokens[i][0] == '*') {
// f=*
filter->type = EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_WILDCARD;
} else {
const uint8_t *operator = NULL;
const uint8_t *now = tokens[i];
const uint8_t *next = now + tokenLengths[i];
uintmax_t first, second, length;
if (((operator = memchr(now, '-', tokenLengths[i])) != NULL
|| (operator = memchr(now, '+', tokenLengths[i])) != NULL)
&& (length = operator - now) > 0
&& length <= sizeof(EmberZclAttributeId_t) * 2 // nibbles
&& emZclHexStringToInt(now, length, &first)
&& (length = next - operator - 1) > 0
&& length <= sizeof(EmberZclAttributeId_t) * 2 // nibbles
&& emZclHexStringToInt(operator + 1, length , &second)) {
// f=1-2
// f=3+4
if (*operator == '-') {
filter->type = EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_RANGE;
filter->data.rangeData.start = first;
filter->data.rangeData.end = second;
if (filter->data.rangeData.end <= filter->data.rangeData.start) {
return false;
}
} else {
filter->type = EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_COUNT;
filter->data.countData.start = first;
filter->data.countData.count = second;
}
} else if (tokenLengths[i] <= sizeof(EmberZclAttributeId_t) * 2
&& emZclHexStringToInt(now, tokenLengths[i], &first)) {
// f=5
filter->type = EM_ZCL_ATTRIBUTE_QUERY_FILTER_TYPE_ID;
filter->data.attributeId = first;
} else {
return false;
}
}
}
return true;
}
// ...a/?u
bool emZclAttributeUriQueryUndividedParse(EmZclContext_t *context,
void *data,
uint8_t depth)
{
// Only accept 'u'.
return (context->attributeQuery.undivided
= (context->uriQueryLength[depth] == 1));
}
// zcl/[eg]/XX/<cluster>/a:
// GET:
// w/ query: read multiple attributes.
// w/o query: list attributes in cluster.
// POST:
// w/ query: update attributes undivided.
// w/o query: write multiple attributes.
// OTHER: not allowed.
void emZclUriClusterAttributeHandler(EmZclContext_t *context)
{
CborState state;
uint8_t buffer[128];
emCborEncodeStart(&state, buffer, sizeof(buffer));
if (context->code == EMBER_COAP_CODE_GET) {
if (emZclMultiEndpointDispatch(context, getAttributeIdsHandler, &state, NULL)) {
emZclRespond205ContentCborState(&state);
} else {
emZclRespond500InternalServerError();
}
} else if (context->code == EMBER_COAP_CODE_POST) {
if (emZclMultiEndpointDispatch(context, updateAttributeHandler, &state, NULL)) {
emZclRespond204ChangedCborState(&state);
} else {
emZclRespond500InternalServerError();
}
} else {
assert(false);
}
}
// zcl/[eg]/XX/<cluster>/a/XXXX:
// GET: read one attribute.
// PUT: write one attribute.
// OTHER: not allowed.
void emZclUriClusterAttributeIdHandler(EmZclContext_t *context)
{
CborState state;
uint8_t buffer[128];
emCborEncodeStart(&state, buffer, sizeof(buffer));
if (context->code == EMBER_COAP_CODE_GET) {
if (emZclMultiEndpointDispatch(context, getAttributeHandler, &state, NULL)) {
emZclRespond205ContentCborState(&state);
} else {
emZclRespond500InternalServerError();
}
} else if (context->code == EMBER_COAP_CODE_PUT) {
if (emZclMultiEndpointDispatch(context, updateAttributeHandler, &state, NULL)) {
emZclRespond204ChangedCborState(&state);
} else {
emZclRespond500InternalServerError();
}
} else {
assert(false);
}
}
| 39.870998 | 94 | 0.580804 |
d362988100e048d7740d937fe84a159279b324d0 | 153 | h | C | examples/IntelliKeys/keymouse.h | gdsports/IntelliKeys_t36 | 407297cc131aa3f6e7e336973e08bbfc41a08ad6 | [
"MIT"
] | 1 | 2019-07-17T02:20:55.000Z | 2019-07-17T02:20:55.000Z | examples/IntelliKeys/keymouse.h | gdsports/IntelliKeys_t36 | 407297cc131aa3f6e7e336973e08bbfc41a08ad6 | [
"MIT"
] | 1 | 2019-07-17T02:22:13.000Z | 2019-07-17T02:22:13.000Z | examples/IntelliKeys/keymouse.h | gdsports/IntelliKeys_t36 | 407297cc131aa3f6e7e336973e08bbfc41a08ad6 | [
"MIT"
] | null | null | null | void process_membrane_release(IntelliKeys &ikey, int x, int y);
void process_membrane_press(IntelliKeys &ikey, int x, int y);
void clear_membrane(void);
| 38.25 | 63 | 0.797386 |
dd7a1b4f576f897bf11797cd695c88e7c77d3c9b | 203 | h | C | Example/WPEnvCenter/WPViewController.h | wpim/WPEnvCenter | 7919afa558338e8686daaee2c2dab3a45b8bdcad | [
"MIT"
] | null | null | null | Example/WPEnvCenter/WPViewController.h | wpim/WPEnvCenter | 7919afa558338e8686daaee2c2dab3a45b8bdcad | [
"MIT"
] | null | null | null | Example/WPEnvCenter/WPViewController.h | wpim/WPEnvCenter | 7919afa558338e8686daaee2c2dab3a45b8bdcad | [
"MIT"
] | null | null | null | //
// WPViewController.h
// WPEnvCenter
//
// Created by gwpp on 05/26/2018.
// Copyright (c) 2018 gwpp. All rights reserved.
//
@import UIKit;
@interface WPViewController : UIViewController
@end
| 14.5 | 49 | 0.694581 |
25b52f77c7806d6e7202731671178a62a7caca15 | 7,413 | h | C | rcgen/cpp/inverse_dynamics.h | kmarkus/ublx-ur5_sim | 51efa12446a7ef9ab5e3e783ce2a6409a3db390f | [
"BSD-3-Clause"
] | 1 | 2020-11-07T11:39:31.000Z | 2020-11-07T11:39:31.000Z | rcgen/cpp/inverse_dynamics.h | kmarkus/ublx-ur5_sim | 51efa12446a7ef9ab5e3e783ce2a6409a3db390f | [
"BSD-3-Clause"
] | 1 | 2020-11-10T16:03:37.000Z | 2020-11-10T16:03:37.000Z | rcgen/cpp/inverse_dynamics.h | kmarkus/ublx-ur5_sim | 51efa12446a7ef9ab5e3e783ce2a6409a3db390f | [
"BSD-3-Clause"
] | 1 | 2020-11-07T10:57:43.000Z | 2020-11-07T10:57:43.000Z | #ifndef RCG_UR5_INVERSE_DYNAMICS_H_
#define RCG_UR5_INVERSE_DYNAMICS_H_
#include <iit/rbd/rbd.h>
#include <iit/rbd/InertiaMatrix.h>
#include <iit/rbd/utils.h>
#include "declarations.h"
#include "inertia_properties.h"
#include "transforms.h"
#include "link_data_map.h"
namespace ur5 {
namespace rcg {
/**
* The Inverse Dynamics routine for the robot ur5.
*
* In addition to the full Newton-Euler algorithm, specialized versions to compute
* only certain terms are provided.
* The parameters common to most of the methods are the joint status vector \c q, the
* joint velocity vector \c qd and the acceleration vector \c qdd.
*
* Additional overloaded methods are provided without the \c q parameter. These
* methods use the current configuration of the robot; they are provided for the
* sake of efficiency, in case the motion transforms of the robot have already
* been updated elsewhere with the most recent configuration (eg by a call to
* setJointStatus()), so that it is useless to compute them again.
*
* Whenever present, the external forces parameter is a set of external
* wrenches acting on the robot links. Each wrench must be expressed in
* the reference frame of the link it is excerted on.
*/
class InverseDynamics {
public:
typedef LinkDataMap<Force> ExtForces;
/**
* Default constructor
* \param in the inertia properties of the links
* \param tr the container of all the spatial motion transforms of
* the robot ur5, which will be used by this instance
* to compute inverse-dynamics.
*/
InverseDynamics(InertiaProperties& in, MotionTransforms& tr);
/** \name Inverse dynamics
* The full Newton-Euler algorithm for the inverse dynamics of this robot.
*
* \param[out] jForces the joint force vector required to achieve the desired accelerations
* \param[in] q the joint position vector
* \param[in] qd the joint velocity vector
* \param[in] qdd the desired joint acceleration vector
* \param[in] fext the external forces acting on the links; this parameters
* defaults to zero
*/
///@{
void id(
JointState& jForces,
const JointState& q, const JointState& qd, const JointState& qdd,
const ExtForces& fext = zeroExtForces);
void id(
JointState& jForces,
const JointState& qd, const JointState& qdd,
const ExtForces& fext = zeroExtForces);
///@}
/** \name Gravity terms
* The joint forces (linear or rotational) required to compensate
* for the effect of gravity, in a specific configuration.
*/
///@{
void G_terms(JointState& jForces, const JointState& q);
void G_terms(JointState& jForces);
///@}
/** \name Centrifugal and Coriolis terms
* The forces (linear or rotational) acting on the joints due to centrifugal and
* Coriolis effects, for a specific configuration.
*/
///@{
void C_terms(JointState& jForces, const JointState& q, const JointState& qd);
void C_terms(JointState& jForces, const JointState& qd);
///@}
/** Updates all the kinematics transforms used by the inverse dynamics routine. */
void setJointStatus(const JointState& q) const;
public:
/** \name Getters
* These functions return various spatial quantities used internally
* by the inverse dynamics routines, like the spatial acceleration
* of the links.
*
* The getters can be useful to retrieve the additional data that is not
* returned explicitly by the inverse dynamics routines even though it
* is computed. For example, after a call to the inverse dynamics,
* the spatial velocity of all the links has been determined and
* can be accessed.
*
* However, beware that certain routines might not use some of the
* spatial quantities, which therefore would retain their last value
* without being updated nor reset (for example, the spatial velocity
* of the links is unaffected by the computation of the gravity terms).
*/
///@{
const Velocity& getVelocity_shoulder() const { return shoulder_v; }
const Acceleration& getAcceleration_shoulder() const { return shoulder_a; }
const Force& getForce_shoulder() const { return shoulder_f; }
const Velocity& getVelocity_upper_arm() const { return upper_arm_v; }
const Acceleration& getAcceleration_upper_arm() const { return upper_arm_a; }
const Force& getForce_upper_arm() const { return upper_arm_f; }
const Velocity& getVelocity_forearm() const { return forearm_v; }
const Acceleration& getAcceleration_forearm() const { return forearm_a; }
const Force& getForce_forearm() const { return forearm_f; }
const Velocity& getVelocity_wrist_1() const { return wrist_1_v; }
const Acceleration& getAcceleration_wrist_1() const { return wrist_1_a; }
const Force& getForce_wrist_1() const { return wrist_1_f; }
const Velocity& getVelocity_wrist_2() const { return wrist_2_v; }
const Acceleration& getAcceleration_wrist_2() const { return wrist_2_a; }
const Force& getForce_wrist_2() const { return wrist_2_f; }
const Velocity& getVelocity_wrist_3() const { return wrist_3_v; }
const Acceleration& getAcceleration_wrist_3() const { return wrist_3_a; }
const Force& getForce_wrist_3() const { return wrist_3_f; }
///@}
protected:
void firstPass(const JointState& qd, const JointState& qdd, const ExtForces& fext);
void secondPass(JointState& jForces);
private:
InertiaProperties* inertiaProps;
MotionTransforms* xm;
private:
Matrix66 vcross; // support variable
// Link 'shoulder' :
const InertiaMatrix& shoulder_I;
Velocity shoulder_v;
Acceleration shoulder_a;
Force shoulder_f;
// Link 'upper_arm' :
const InertiaMatrix& upper_arm_I;
Velocity upper_arm_v;
Acceleration upper_arm_a;
Force upper_arm_f;
// Link 'forearm' :
const InertiaMatrix& forearm_I;
Velocity forearm_v;
Acceleration forearm_a;
Force forearm_f;
// Link 'wrist_1' :
const InertiaMatrix& wrist_1_I;
Velocity wrist_1_v;
Acceleration wrist_1_a;
Force wrist_1_f;
// Link 'wrist_2' :
const InertiaMatrix& wrist_2_I;
Velocity wrist_2_v;
Acceleration wrist_2_a;
Force wrist_2_f;
// Link 'wrist_3' :
const InertiaMatrix& wrist_3_I;
Velocity wrist_3_v;
Acceleration wrist_3_a;
Force wrist_3_f;
private:
static const ExtForces zeroExtForces;
};
inline void InverseDynamics::setJointStatus(const JointState& q) const
{
(xm->fr_shoulder_X_fr_base)(q);
(xm->fr_upper_arm_X_fr_shoulder)(q);
(xm->fr_forearm_X_fr_upper_arm)(q);
(xm->fr_wrist_1_X_fr_forearm)(q);
(xm->fr_wrist_2_X_fr_wrist_1)(q);
(xm->fr_wrist_3_X_fr_wrist_2)(q);
}
inline void InverseDynamics::G_terms(JointState& jForces, const JointState& q)
{
setJointStatus(q);
G_terms(jForces);
}
inline void InverseDynamics::C_terms(JointState& jForces, const JointState& q, const JointState& qd)
{
setJointStatus(q);
C_terms(jForces, qd);
}
inline void InverseDynamics::id(
JointState& jForces,
const JointState& q, const JointState& qd, const JointState& qdd,
const ExtForces& fext)
{
setJointStatus(q);
id(jForces, qd, qdd, fext);
}
}
}
#endif
| 36.160976 | 100 | 0.700121 |
50f050baa0d9dd5b5a76c76250d5757c10eace5a | 1,338 | h | C | System/Library/PrivateFrameworks/StoreKitUI.framework/SKUIIPadChartsColumnView.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/StoreKitUI.framework/SKUIIPadChartsColumnView.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/StoreKitUI.framework/SKUIIPadChartsColumnView.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 11:44:36 AM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/StoreKitUI.framework/StoreKitUI
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <StoreKitUI/StoreKitUI-Structs.h>
#import <UIKitCore/UIView.h>
@class NSArray, UIViewController;
@interface SKUIIPadChartsColumnView : UIView {
UIEdgeInsets _contentInset;
NSArray* _contentViewControllers;
long long _selectedViewControllerIndex;
}
@property (assign,nonatomic) UIEdgeInsets contentInset; //@synthesize contentInset=_contentInset - In the implementation block
@property (nonatomic,copy) NSArray * contentViewControllers; //@synthesize contentViewControllers=_contentViewControllers - In the implementation block
@property (nonatomic,readonly) UIViewController * selectedViewController;
-(void)setContentInset:(UIEdgeInsets)arg1 ;
-(UIEdgeInsets)contentInset;
-(void)layoutSubviews;
-(UIViewController *)selectedViewController;
-(void)setContentViewControllers:(NSArray *)arg1 ;
-(NSArray *)contentViewControllers;
-(void)setSelectedViewControllerIndex:(long long)arg1 ;
-(void)_addSelectedViewController;
@end
| 38.228571 | 177 | 0.77429 |
1c9c3cc7ccb8ab417d38487471a3cf6561668399 | 2,668 | c | C | src/base/hash.c | luaman/twilight | b4853f3e0c828a5aaff23e44c17d70410f7781c1 | [
"MIT"
] | 3 | 2018-01-14T10:43:27.000Z | 2020-03-02T08:38:23.000Z | src/base/hash.c | luaman/twilight | b4853f3e0c828a5aaff23e44c17d70410f7781c1 | [
"MIT"
] | null | null | null | src/base/hash.c | luaman/twilight | b4853f3e0c828a5aaff23e44c17d70410f7781c1 | [
"MIT"
] | null | null | null | /*
$RCSfile$
Copyright (C) 2001 Zephaniah E. Hull.
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:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
static const char rcsid[] =
"$Id$";
#include <stdlib.h>
#include "twiconfig.h"
#include "hash.h"
hash_t *
hash_create (int bits, do_compare_t *do_compare, do_index_t *do_index,
do_free_t *do_free, memzone_t *zone)
{
hash_t *hash;
hash = (hash_t *) Zone_Alloc(zone, sizeof(hash_t));
hash->bits = bits;
hash->length = 1 << bits;
hash->do_compare = do_compare;
hash->do_index = do_index;
hash->do_free = do_free;
hash->n_values = 0;
hash->values = (hash_value_t **) Zone_Alloc(zone, hash->length * sizeof(hash_value_t *));
hash->zone = zone;
return hash;
}
void
hash_destroy (hash_t *hash)
{
hash_value_t *val, *next;
int i;
for (i = 0; i < hash->length; i++) {
val = hash->values[i];
while (val) {
next = val->next;
hash->do_free (hash, val->data);
hash->n_values--;
free (val);
val = next;
}
}
Zone_Free (hash->values);
Zone_Free (hash);
}
void *
hash_get (hash_t *hash, void *data)
{
hash_value_t *value;
int i;
i = hash->do_index(hash, data);
for (value = hash->values[i]; value; value = value->next) {
if (!hash->do_compare(hash, value->data, data)) {
return value->data;
}
}
return NULL;
}
qboolean
hash_add (hash_t *hash, void *data)
{
hash_value_t *val;
int which;
which = hash->do_index(hash, data);
val = (hash_value_t *) Zone_Alloc(hash->zone, sizeof(hash_value_t));
val->data = data;
val->next = hash->values[which];
hash->values[which] = val;
hash->n_values++;
return true;
}
qboolean
hash_del (hash_t *hash, void *data)
{
hash_value_t *val, *pval;
int i;
i = hash->do_index(hash, data);
pval = NULL;
for (val = hash->values[i]; val; pval = val, val = val->next) {
if (val->data == data) {
if (!pval) {
hash->values[i] = val->next;
} else {
pval->next = val->next;
}
hash->do_free(hash, val->data);
hash->n_values--;
Zone_Free (val);
return true;
}
}
return false;
}
| 20.366412 | 90 | 0.660045 |
ea64f0b277a39eace983f8642b0fd299c31b8cf2 | 489 | h | C | owSocket/AuthProof_S.h | adan830/OpenWow | 9b6e9c248bd185b1677fe616d2a3a81a35ca8894 | [
"Apache-2.0"
] | null | null | null | owSocket/AuthProof_S.h | adan830/OpenWow | 9b6e9c248bd185b1677fe616d2a3a81a35ca8894 | [
"Apache-2.0"
] | null | null | null | owSocket/AuthProof_S.h | adan830/OpenWow | 9b6e9c248bd185b1677fe616d2a3a81a35ca8894 | [
"Apache-2.0"
] | 1 | 2020-05-11T13:32:49.000Z | 2020-05-11T13:32:49.000Z | #pragma once
#include "AuthCodes.h"
struct AuthProof_S
{
AuthProof_S(ByteBuffer& reader)
{
cmd = AUTH_LOGON_PROOF;
reader.readBytes(&error);
if (error != AuthResult::WOW_SUCCESS)
{
uint16 t;
reader.readBytes(&t, 2);
return;
}
reader.readBytes(M2, 20);
reader.readBytes(&AccountFlags, 4);
reader.readBytes(&SurveyId, 4);
reader.readBytes(&unk3, 2);
}
uint8 cmd;
uint8 error;
uint8 M2[20];
uint32 AccountFlags;
uint32 SurveyId;
uint16 unk3;
}; | 16.862069 | 39 | 0.670757 |
ee2ba01e0b3e76d4a92094531eb0be988491ab10 | 1,249 | h | C | practicas/complejos/src/complejos.h | ULL-ESIT-IB-2020-2021/ib-practica11-oop-cmake-FernandoMarreoHernandez | d0b5f02ea918b7c081751eca00463f95bada90e6 | [
"MIT"
] | null | null | null | practicas/complejos/src/complejos.h | ULL-ESIT-IB-2020-2021/ib-practica11-oop-cmake-FernandoMarreoHernandez | d0b5f02ea918b7c081751eca00463f95bada90e6 | [
"MIT"
] | null | null | null | practicas/complejos/src/complejos.h | ULL-ESIT-IB-2020-2021/ib-practica11-oop-cmake-FernandoMarreoHernandez | d0b5f02ea918b7c081751eca00463f95bada90e6 | [
"MIT"
] | null | null | null | #include <iostream>
#pragma once
#ifndef COMPLEJOS_H
#define COMPLEJOS_H
using namespace std;
class complejo{
private:
int real1;
int imaginaria1;
int real2;
int imaginaria2;
int sumareal;
int sumaimaginaria;
int restareal;
int restaimaginaria;
public:
complejo(int,int,int,int);
void mostrarnumeros();
void suma();
void resta();
};
complejo::complejo(int real1_, int imaginaria1_,int real2_,int imaginaria2_){
real1 = real1_;
imaginaria1 = imaginaria1_;
real2 = real2_;
imaginaria2 = imaginaria2_;
}
void complejo::mostrarnumeros(){
cout<<"su primero numero complejo es: "<<real1<<"+"<<imaginaria1<<"i"<<endl;
cout<<"su segundo numero complejo es: "<<real2<<"+"<<imaginaria2<<"i"<<endl;
}
void complejo::suma(){
sumareal = real1 + real2;
sumaimaginaria = imaginaria1 + imaginaria2;
cout << "la suma de operar los numeos complejos es: " << sumareal<< "+"<<sumaimaginaria<<"i"<<endl;
}
void complejo::resta(){
restareal = real1 - real2;
restaimaginaria = imaginaria1 - imaginaria2;
cout << "la resta de operar sus numeros complejos es: " << restareal<< "+"<<restaimaginaria<<"i"<<endl;
}
#endif | 27.755556 | 107 | 0.639712 |
eedca9b5a923e282c3c7d56ccad12bcf2b372958 | 2,859 | h | C | src/common/buffer.h | weibreeze/breeze-cpp | ccabb502bb3833c3ee3745b12c3f84b531e9ad45 | [
"Apache-2.0"
] | 2 | 2019-05-24T01:31:46.000Z | 2019-06-06T07:13:25.000Z | src/common/buffer.h | weibreeze/breeze-cpp | ccabb502bb3833c3ee3745b12c3f84b531e9ad45 | [
"Apache-2.0"
] | null | null | null | src/common/buffer.h | weibreeze/breeze-cpp | ccabb502bb3833c3ee3745b12c3f84b531e9ad45 | [
"Apache-2.0"
] | 2 | 2019-05-24T11:40:31.000Z | 2020-06-29T06:45:16.000Z | //
// Created by zhachen on 2019-05-23.
//
#ifndef BREEZE_CPP_BUFFER_H
#define BREEZE_CPP_BUFFER_H
#include <cstdio>
#include <cstdint>
#include <cstdarg>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iostream>
#define MOTAN_OK 0
#define E_MOTAN_BUFFER_NOT_ENOUGH (-1)
#define E_MOTAN_OVERFLOW (-2)
#define E_MOTAN_UNSUPPORTED_TYPE (-3)
#define E_MOTAN_MEMORY_NOT_ENOUGH (-4)
#define E_MOTAN_WRONG_SIZE (-5)
#define E_MOTAN_MISMATCH_TYPE (-6)
enum ByteOrder {
kBigEndian,
kLittleEndian
};
class BytesBuffer {
public:
uint8_t *buffer_;
ByteOrder order_;
uint32_t write_pos_;
uint32_t read_pos_;
size_t capacity_;
uint8_t read_only_;
void dump();
void free_bytes_buffer();
void grow_buffer(const size_t &n);
void write_bytes(const uint8_t *bytes, const int &len);
void write_byte(const uint8_t &u);
void write_uint16(const uint16_t &u);
void write_uint32(const uint32_t &u);
void write_uint64(const uint64_t &u);
int write_varint(uint64_t u);
void set_write_pos(const uint32_t &pos);
void set_read_pos(const uint32_t &pos);
int length();
int remain();
int next(const int &n, BytesBuffer &ret);
void reset();
int read_bytes(uint8_t *bs, const int &len);
int read_byte(uint8_t &u);
int read_uint16(uint16_t &u);
int read_uint32(uint32_t &u);
int read_uint64(uint64_t &u);
int read_varint(uint64_t &u);
int write_zigzag32(const uint32_t &v);
int write_zigzag64(const uint64_t &v);
int read_zigzag32(uint64_t &v);
int read_zigzag64(uint64_t &v);
};
void die_bytes_buffer(const char *fmt, ...);
void dump_bytes_buffer(const uint8_t *bs, const int &len);
BytesBuffer *new_bytes_buffer(const size_t &capacity, const ByteOrder &order = kBigEndian);
BytesBuffer *new_bytes_buffer_from_bytes(const uint8_t *raw_bytes, const size_t &len,
const ByteOrder &order = kBigEndian, const uint8_t &read_only = 0);
uint64_t zigzag_encode(int64_t u);
int64_t zigzag_decode(uint64_t n);
// 高位低址
void big_endian_write_uint16(uint8_t *buffer, uint16_t n);
void big_endian_write_uint32(uint8_t *buffer, uint32_t n);
void big_endian_write_uint64(uint8_t *buffer, uint64_t n);
uint16_t big_endian_read_uint16(const uint8_t *buffer);
uint32_t big_endian_read_uint32(const uint8_t *buffer);
uint64_t big_endian_read_uint64(const uint8_t *buffer);
// 高位高址
void little_endian_write_uint16(uint8_t *buffer, uint16_t n);
void little_endian_write_uint32(uint8_t *buffer, uint32_t n);
void little_endian_write_uint64(uint8_t *buffer, uint64_t n);
uint16_t little_endian_read_uint16(const uint8_t *buffer);
uint32_t little_endian_read_uint32(const uint8_t *buffer);
uint64_t little_endian_read_uint64(const uint8_t *buffer);
#endif //BREEZE_CPP_BUFFER_H
| 22.162791 | 108 | 0.734523 |
7cb0c9b58b422f38742393f8509cf08a27762bbd | 2,043 | h | C | weex_core/Source/android/jsengine/dependence/bmalloc/bmalloc/BumpAllocator.h | sunshl/incubator-weex | 40ae49e40c3dd725d6c546451075bd6e90001c9d | [
"Apache-2.0"
] | 2 | 2017-10-18T01:36:31.000Z | 2018-05-07T23:00:21.000Z | weex_core/Source/android/jsengine/dependence/bmalloc/bmalloc/BumpAllocator.h | sunshl/incubator-weex | 40ae49e40c3dd725d6c546451075bd6e90001c9d | [
"Apache-2.0"
] | null | null | null | weex_core/Source/android/jsengine/dependence/bmalloc/bmalloc/BumpAllocator.h | sunshl/incubator-weex | 40ae49e40c3dd725d6c546451075bd6e90001c9d | [
"Apache-2.0"
] | 5 | 2019-05-28T11:48:42.000Z | 2020-05-15T07:31:55.000Z | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef BumpAllocator_h
#define BumpAllocator_h
#include "BAssert.h"
#include "BumpRange.h"
#include "ObjectType.h"
namespace bmalloc {
// Helper object for allocating small objects.
class BumpAllocator {
public:
BumpAllocator();
void init(size_t);
size_t size() { return m_size; }
bool isNull() { return !m_ptr; }
void clear();
bool canAllocate() { return !!m_remaining; }
void* allocate();
void refill(const BumpRange&);
private:
char* m_ptr;
unsigned m_size;
unsigned m_remaining;
};
inline BumpAllocator::BumpAllocator()
: m_ptr()
, m_size()
, m_remaining()
{
}
inline void BumpAllocator::init(size_t size)
{
m_ptr = nullptr;
m_size = size;
m_remaining = 0;
}
inline void* BumpAllocator::allocate()
{
BASSERT(m_remaining);
--m_remaining;
char* result = m_ptr;
m_ptr += m_size;
return result;
}
inline void BumpAllocator::refill(const BumpRange& bumpRange)
{
BASSERT(!canAllocate());
m_ptr = bumpRange.begin;
m_remaining = bumpRange.objectCount;
BASSERT(canAllocate());
}
inline void BumpAllocator::clear()
{
m_ptr = nullptr;
m_remaining = 0;
}
} // namespace bmalloc
#endif // BumpAllocator_h
| 22.206522 | 63 | 0.695546 |
672c6ed9399b65332bccca2d933947d15b537c27 | 11,743 | c | C | sdk/sdk/share/itu/itu_video.c | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | 1 | 2021-10-09T08:05:50.000Z | 2021-10-09T08:05:50.000Z | sdk/sdk/share/itu/itu_video.c | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | null | null | null | sdk/sdk/share/itu/itu_video.c | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | null | null | null | #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "ite/itu.h"
#include "itu_cfg.h"
#include "itu_private.h"
#ifdef CFG_VIDEO_ENABLE
#include "castor3player.h"
#include "ite/itv.h"
#include "ite/ith_video.h"
#endif // CFG_VIDEO_ENABLE
bool isOtherVideoPlaying = false;
static pthread_t tid;
static const char videoName[] = "ITUVideo";
static bool videoPlayerIsFileEOF = false;
static bool videoloopIsPlaying = false;
static bool isVideoWidgetStartPlaying = false;
#ifdef CFG_VIDEO_ENABLE
static bool videoPlayerSetWindow = false;
static MTAL_SPEC mtal_spec = {0};
extern bool audioKeySoundPaused;
#endif
#ifdef CFG_VIDEO_ENABLE
static void ItuEnterVideoState(void)
{
#ifndef DISABLE_SWITCH_VIDEO_STATE
ituFrameFuncInit();
#endif
}
static void ItuLeaveVideoState(void)
{
#ifndef DISABLE_SWITCH_VIDEO_STATE
ituFrameFuncExit();
#ifdef CFG_LCD_ENABLE
ituLcdInit();
#endif
#ifdef CFG_M2D_ENABLE
ituM2dInit();
#else
ituSWInit();
#endif
#endif
}
static void EventHandler(PLAYER_EVENT nEventID, void *arg)
{
switch(nEventID)
{
case PLAYER_EVENT_EOF:
printf("File EOF\n");
videoPlayerIsFileEOF = true;
break;
case PLAYER_EVENT_OPEN_FILE_FAIL:
printf("Open file fail\n");
videoPlayerIsFileEOF = true;
break;
case PLAYER_EVENT_UNSUPPORT_FILE:
printf("File not support\n");
videoPlayerIsFileEOF = true;
break;
default:
break;
}
}
static void *polling_video_widget_status(void *arg)
{
ITUVideo* video = (ITUVideo*)arg;
while(videoloopIsPlaying)
{
if(videoPlayerIsFileEOF)
{
videoPlayerIsFileEOF = false;
mtal_pb_seekto(0);
}
usleep(2000);
}
pthread_exit(NULL);
}
#endif
static void VideoOnStop(ITUVideo* video)
{
// DO NOTHING
}
void ituVideoExit(ITUWidget* widget)
{
ITUVideo* video = (ITUVideo*) widget;
assert(widget);
ITU_ASSERT_THREAD();
#ifdef CFG_VIDEO_ENABLE
mtal_pb_stop();
mtal_pb_exit();
videoloopIsPlaying = false;
ItuLeaveVideoState();
if (video->repeat)
{
#ifndef WIN32
if(tid)
#endif
{
pthread_join(tid, NULL);
#ifndef WIN32
tid = 0;
#endif
}
}
#endif // CFG_VIDEO_ENABLE
ituVideoOnStop(video);
ituWidgetExitImpl(widget);
}
bool ituVideoUpdate(ITUWidget* widget, ITUEvent ev, int arg1, int arg2, int arg3)
{
ITUVideo* video = (ITUVideo*) widget;
bool result = false;
assert(video);
if (ev == ITU_EVENT_TIMER)
{
if(!isOtherVideoPlaying && !isVideoWidgetStartPlaying)
{
#ifdef CFG_VIDEO_ENABLE
if (video->playing && video->filePath[0] != '\0')
{
ItuEnterVideoState();
videoPlayerSetWindow = true;
mtal_pb_init(EventHandler);
strcpy(mtal_spec.srcname, video->filePath);
if(video->volume)
mtal_spec.vol_level = video->volume;
mtal_pb_select_file(&mtal_spec);
if (video->repeat)
{
mtal_pb_play_videoloop();
videoloopIsPlaying = true;
pthread_create(&tid, NULL, polling_video_widget_status, (void *)video);
}
else
{
mtal_pb_play();
}
isVideoWidgetStartPlaying = true;
}
#endif
}
if (video->playing)
{
if(videoPlayerIsFileEOF)
{
if (!video->repeat)
{
videoPlayerIsFileEOF = false;
#ifdef CFG_VIDEO_ENABLE
mtal_pb_stop();
#endif
video->playing = false;
ituVideoOnStop(video);
}
}
result = widget->dirty = true;
}
}
else if (ev == ITU_EVENT_LOAD)
{
isVideoWidgetStartPlaying = false;
if(!isOtherVideoPlaying)
{
#ifdef CFG_VIDEO_ENABLE
if (video->playing && video->filePath[0] != '\0')
{
ItuEnterVideoState();
videoPlayerSetWindow = true;
mtal_pb_init(EventHandler);
strcpy(mtal_spec.srcname, video->filePath);
if(video->volume)
mtal_spec.vol_level = video->volume;
mtal_pb_select_file(&mtal_spec);
if (video->repeat)
{
mtal_pb_play_videoloop();
videoloopIsPlaying = true;
pthread_create(&tid, NULL, polling_video_widget_status, (void *)video);
}
else
{
mtal_pb_play();
}
isVideoWidgetStartPlaying = true;
}
#endif
}
}
else if (ev == ITU_EVENT_RELEASE)
{
#ifdef CFG_VIDEO_ENABLE
mtal_pb_stop();
mtal_pb_exit();
videoloopIsPlaying = false;
ItuLeaveVideoState();
if (video->repeat)
{
#ifndef WIN32
if(tid)
#endif
{
pthread_join(tid, NULL);
#ifndef WIN32
tid = 0;
#endif
}
}
#endif
}
else if (ev == ITU_EVENT_LAYOUT)
{
#ifdef CFG_VIDEO_ENABLE
videoPlayerSetWindow = true;
#endif
result = widget->dirty = true;
}
result |= ituWidgetUpdateImpl(widget, ev, arg1, arg2, arg3);
return widget->visible ? result : false;
}
void ituVideoDraw(ITUWidget* widget, ITUSurface* dest, int x, int y, uint8_t alpha)
{
int destx, desty;
ITURectangle prevClip;
ITUVideo* video = (ITUVideo*) widget;
ITURectangle* rect = (ITURectangle*) &widget->rect;
assert(video);
assert(dest);
destx = rect->x + x;
desty = rect->y + y;
#ifdef CFG_VIDEO_ENABLE
if (videoPlayerSetWindow)
{
itv_set_video_window(destx, desty, rect->width, rect->height);
videoPlayerSetWindow = false;
}
#endif
ituWidgetSetClipping(widget, dest, x, y, &prevClip);
#if (CFG_CHIP_FAMILY == 9850) && (CFG_VIDEO_ENABLE)
ituDrawVideoSurface(dest, destx, desty, rect->width, rect->height);
#else
ituColorFill(dest, destx, desty, rect->width, rect->height, &widget->color);
#endif
ituSurfaceSetClipping(dest, prevClip.x, prevClip.y, prevClip.width, prevClip.height);
ituWidgetDrawImpl(widget, dest, x, y, alpha);
}
void ituVideoOnAction(ITUWidget* widget, ITUActionType action, char* param)
{
assert(widget);
switch (action)
{
case ITU_ACTION_PLAY:
if (param[0] != '\0')
ituVideoPlay((ITUVideo*)widget, atoi(param));
break;
case ITU_ACTION_STOP:
ituVideoStop((ITUVideo*)widget);
break;
case ITU_ACTION_GOTO:
if (param[0] != '\0')
ituVideoGoto((ITUVideo*)widget, atoi(param));
break;
default:
ituWidgetOnActionImpl(widget, action, param);
break;
}
}
void ituVideoInit(ITUVideo* video)
{
assert(video);
ITU_ASSERT_THREAD();
memset(video, 0, sizeof (ITUVideo));
ituWidgetInit(&video->widget);
ituWidgetSetType(video, ITU_VIDEO);
ituWidgetSetName(video, videoName);
ituWidgetSetExit(video, ituVideoExit);
ituWidgetSetUpdate(video, ituVideoUpdate);
ituWidgetSetDraw(video, ituVideoDraw);
ituWidgetSetOnAction(video, ituVideoOnAction);
ituVideoSetOnStop(video, VideoOnStop);
}
void ituVideoLoad(ITUVideo* video, uint32_t base)
{
assert(video);
ituWidgetLoad((ITUWidget*)video, base);
ituWidgetSetExit(video, ituVideoExit);
ituWidgetSetUpdate(video, ituVideoUpdate);
ituWidgetSetDraw(video, ituVideoDraw);
ituWidgetSetOnAction(video, ituVideoOnAction);
ituVideoSetOnStop(video, VideoOnStop);
}
void ituVideoPlay(ITUVideo* video, int percentage)
{
assert(video);
ITU_ASSERT_THREAD();
if (video->filePath[0] != '\0')
{
#ifdef CFG_VIDEO_ENABLE
if(!video->playing)
{
audioKeySoundPaused = true;
#ifdef CFG_BUILD_AUDIO_MGR
smtkAudioMgrQuickStop();
#endif
ItuEnterVideoState();
videoPlayerSetWindow = true;
mtal_pb_init(EventHandler);
strcpy(mtal_spec.srcname, video->filePath);
if(video->volume)
mtal_spec.vol_level = video->volume;
mtal_pb_select_file(&mtal_spec);
if (video->repeat)
{
mtal_pb_play_videoloop();
videoloopIsPlaying = true;
pthread_create(&tid, NULL, polling_video_widget_status, (void *)video);
}
else
{
mtal_pb_play();
}
isVideoWidgetStartPlaying = true;
}
else if(video->paused)
{
mtal_pb_pause();
video->paused = false;
}
#endif // CFG_VIDEO_ENABLE
}
if (percentage > 0)
ituVideoGoto(video, percentage);
video->playing = true;
video->widget.dirty = true;
}
void ituVideoStop(ITUVideo* video)
{
assert(video);
ITU_ASSERT_THREAD();
if (video->playing)
{
#ifdef CFG_VIDEO_ENABLE
mtal_pb_stop();
mtal_pb_exit();
videoloopIsPlaying = false;
ItuLeaveVideoState();
if (video->repeat)
{
#ifndef WIN32
if(tid)
#endif
{
pthread_join(tid, NULL);
#ifndef WIN32
tid = 0;
#endif
}
}
audioKeySoundPaused = false;
#endif // CFG_VIDEO_ENABLE
video->playing = false;
video->paused = false;
video->widget.dirty = true;
}
}
void ituVideoPause(ITUVideo* video)
{
assert(video);
ITU_ASSERT_THREAD();
if (video->playing && !video->paused)
{
#ifdef CFG_VIDEO_ENABLE
mtal_pb_pause();
#endif // CFG_VIDEO_ENABLE
video->paused = true;
}
}
void ituVideoGoto(ITUVideo* video, int percentage)
{
assert(video);
ITU_ASSERT_THREAD();
if (video->playing && percentage >= 0)
{
#ifdef CFG_VIDEO_ENABLE
int pos;
int totaltime = 0;
mtal_pb_get_total_duration(&totaltime);
if(totaltime > 0)
pos = percentage*totaltime/100;
else
pos = 0;
mtal_pb_seekto(pos);
#endif // CFG_VIDEO_ENABLE
video->widget.dirty = true;
}
}
int ituVideoGetPlayingPercentage(ITUVideo* video)
{
assert(video);
ITU_ASSERT_THREAD();
if (video->playing)
{
int percentage_value;
int totaltime = 0;
int currenttime = 0;
#ifdef CFG_VIDEO_ENABLE
int ret = mtal_pb_get_total_duration(&totaltime);
if(ret < 0)
return -1;
ret = mtal_pb_get_current_time(¤ttime);
if(ret < 0)
return -1;
#endif
if(totaltime > 0)
{
percentage_value = currenttime*100/totaltime;
if(percentage_value > 100)
percentage_value = 100;
}
else
percentage_value = 0;
return percentage_value;
}
return -1;
}
void ituVideoSpeedUpDown(ITUVideo* video, float speed)
{
assert(video);
ITU_ASSERT_THREAD();
if (video->playing)
{
#ifdef CFG_VIDEO_ENABLE
mtal_pb_slow_fast_play(speed);
#endif // CFG_VIDEO_ENABLE
}
}
| 24.162551 | 91 | 0.56919 |
6b1fcf755c095516ed54ea568fc052d95769381d | 3,991 | h | C | WaveSim/WaveSim/WaveSolver.h | willamm/WaveSimulator | 75f9dd1760af67663eeae3aba406d9ce9df334e0 | [
"MIT"
] | 1 | 2021-08-03T08:25:31.000Z | 2021-08-03T08:25:31.000Z | WaveSim/WaveSim/WaveSolver.h | willamm/WaveSimulator | 75f9dd1760af67663eeae3aba406d9ce9df334e0 | [
"MIT"
] | 29 | 2017-09-28T18:47:32.000Z | 2017-12-11T01:34:19.000Z | WaveSim/WaveSim/WaveSolver.h | willamm/WaveSimulator | 75f9dd1760af67663eeae3aba406d9ce9df334e0 | [
"MIT"
] | null | null | null | #ifndef WAVESOLVER_H_
#define WAVESOLVER_H_
#include "FieldArray.h"
#include <iostream>
#include <iomanip>
template<typename T>
class WaveSolver {
public:
WaveSolver(int numCellsX, int numCellsY) :
mCenterX(numCellsX / 44),
mCenterY(numCellsY / 4),
mFieldPrev(numCellsX, numCellsY, 0),
mField(numCellsX, numCellsY, 0),
mFieldNext(numCellsX, numCellsY, 0),
mVelocity(numCellsX, numCellsY, defaultVelocity)
{
mField(mCenterX, mCenterY) = 1.0;
}
WaveSolver(int numCellsX, int numCellsY, int centerX, int centerY) :
mCenterX(centerX),
mCenterY(centerY),
mFieldPrev(numCellsX, numCellsY, 0),
mField(numCellsX, numCellsY, 0),
mFieldNext(numCellsX, numCellsY, 0),
mVelocity(numCellsX, numCellsY, defaultVelocity)
{
// Add a single (source) peak in the middle of the current field
mField(mCenterX, mCenterY) = 1.0;
}
FieldArray<T>& getField() { return mField; }
FieldArray<T> const& getField() const { return mField; }
FieldArray<T>& getVelocity() { return mVelocity; }
FieldArray<T> const& getVelocity() const { return mVelocity; }
void addRectangle(int minX, int minY, int maxX, int maxY, T value = 0.5) {
assert(minX <= maxX);
assert(minY <= maxY);
for (int curX = minX; curX <= maxX; ++curX) {
for (int curY = minY; curY <= maxY; ++curY) {
mVelocity(curX, curY) = value;
}
}
}
void addCircle(int centerX, int centerY, int radius, T value = 0.5) {
assert(radius >= 0);
/// This is a very primitive implementation
const int minX = centerX - radius;
const int maxX = centerX + radius;
const int minY = centerY - radius;
const int maxY = centerY + radius;
const int radius2 = radius * radius;
for (int curX = minX; curX <= maxX; ++curX) {
for (int curY = minY; curY <= maxY; ++curY) {
const double r2 = (curX - centerX)*(curX - centerX) + (curY - centerY)*(curY - centerY);
if (r2 <= radius2) {
mVelocity(curX, curY) = value;
}
}
}
}
void resetMaterials()
{
getVelocity().setToValue(defaultVelocity);
}
void resetField()
{
mFieldPrev.setToValue(0);
mField.setToValue(0);
mFieldNext.setToValue(0);
mField(mCenterX, mCenterY) = 1.0;
}
void clearField()
{
mFieldPrev.setToValue(0);
mField.setToValue(0);
mFieldNext.setToValue(0);
}
void doTimestep()
{
const T dx2 = 1;
const T dy2 = 1;
const T dt2 =1./2.;
const int minX = 1;
const int minY = 1;
const int maxX = mField.numCellsX() - 1;
const int maxY = mField.numCellsY() - 1;
for (int curX = minX; curX < maxX; ++curX) {
for (int curY = minY; curY < maxY; ++curY) {
const auto xDerivative = (mField(curX + 1, curY) - 2 * mField(curX, curY) + mField(curX - 1, curY)) / dx2;
const auto yDerivative = (mField(curX, curY + 1) - 2 * mField(curX, curY) + mField(curX, curY - 1)) / dy2;
const auto curVelocity2 = mVelocity(curX, curY)*mVelocity(curX, curY);
mFieldNext(curX, curY) = 2 * mField(curX, curY) - mFieldPrev(curX, curY) + dt2*curVelocity2*(xDerivative + yDerivative);
}
}
/// To avoid re-allocation, we simply rotate the pointer around
swapData(mFieldPrev, mField);
swapData(mField, mFieldNext);
}
void setNewSource(int x, int y)
{
clearField();
mField(x, y) = 1.0;
}
private:
int mCenterX;
int mCenterY;
const T defaultVelocity = 1.0;
FieldArray<T> mFieldPrev; ///< Field at previous time-step
FieldArray<T> mField; ///< Field at current time-step
FieldArray<T> mFieldNext; ///< Field at next time-step
FieldArray<T> mVelocity;
};
#endif // WAVESOLVER_H_
| 28.92029 | 136 | 0.585317 |
408eb45bf7e3dc988f5e872909ae807fa04657cb | 157 | h | C | tests/cpp/default/keywords/Error_sizeof.h | zaimoni/Z.C- | 7ca97ec0af14d092c87a25e07d7ed486c7912266 | [
"BSL-1.0"
] | null | null | null | tests/cpp/default/keywords/Error_sizeof.h | zaimoni/Z.C- | 7ca97ec0af14d092c87a25e07d7ed486c7912266 | [
"BSL-1.0"
] | 4 | 2019-12-07T08:08:29.000Z | 2021-01-22T00:19:10.000Z | tests/cpp/default/keywords/Error_sizeof.h | zaimoni/Z.C- | 7ca97ec0af14d092c87a25e07d7ed486c7912266 | [
"BSL-1.0"
] | null | null | null | // default\keywords\Error_sizeof.h
// check that #define of sizeof errors// (C)2009 Kenneth Boyd, license: MIT.txt
#define sizeof 1
#include <stdbool.h>
| 31.4 | 80 | 0.726115 |
0b58601c35a553928ad059d8068fb4b1a42f8f98 | 535 | h | C | Solutions/Kamikoto66/GameShop4/Item.h | pravin1237/ProgrammingPractice | bc15181d5c692ae99b64fdae0ef284b948b20c80 | [
"MIT"
] | 32 | 2017-05-17T04:05:31.000Z | 2021-02-16T07:40:22.000Z | Solutions/Kamikoto66/GameShop4/Item.h | pravin1237/ProgrammingPractice | bc15181d5c692ae99b64fdae0ef284b948b20c80 | [
"MIT"
] | 17 | 2017-05-21T13:35:45.000Z | 2017-06-20T00:20:39.000Z | Solutions/Kamikoto66/GameShop4/Item.h | pravin1237/ProgrammingPractice | bc15181d5c692ae99b64fdae0ef284b948b20c80 | [
"MIT"
] | 35 | 2017-05-25T06:26:47.000Z | 2020-10-02T13:49:02.000Z | #pragma once
#include <string>
using namespace std;
enum class ItemIndex
{
eName = 1,
eDescription,
eWeight,
eValue
};
class Item
{
protected:
string _name;
string _description;
int _weight;
int _value;
public:
Item();
Item(string name, string description, int weight, int value);
virtual ~Item();
virtual void Describe();
void SetName(string name) { _name = name; }
void SetDes(string des) { _description = des; }
void SetWeight(int weight) { _weight = weight; }
void SetValue(int value) { _value = value; }
};
| 15.285714 | 62 | 0.697196 |
4ca56d2625fe09f462a37163c75f8c8bf4fcb161 | 23,217 | c | C | ccx_prool/CalculiX/ccx_2.19/src/crackpropagation.c | alleindrach/calculix-desktop | 2cb2c434b536eb668ff88bdf82538d22f4f0f711 | [
"MIT"
] | null | null | null | ccx_prool/CalculiX/ccx_2.19/src/crackpropagation.c | alleindrach/calculix-desktop | 2cb2c434b536eb668ff88bdf82538d22f4f0f711 | [
"MIT"
] | null | null | null | ccx_prool/CalculiX/ccx_2.19/src/crackpropagation.c | alleindrach/calculix-desktop | 2cb2c434b536eb668ff88bdf82538d22f4f0f711 | [
"MIT"
] | null | null | null | /* CalculiX - A 3-dimensional finite element program */
/* Copyright (C) 1998-2021 Guido Dhondt */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation(version 2); */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "CalculiX.h"
#define max(a,b) ((a) >= (b) ? (a) : (b))
void crackpropagation(ITG **ipkonp,ITG **konp,char **lakonp,ITG *ne,ITG *nk,
char *jobnamec,ITG *nboun,ITG *iamboun,double *xboun,
ITG *nload,char *sideload,ITG *iamload,ITG *nforc,
ITG *iamforc,double *xforc,ITG *ithermal,double *t1,
ITG *iamt1,double **cop,ITG *nkon,ITG *mi,ITG **ielmatp,
char *matname,char *output,ITG *nmat,char *set,ITG *nset,
ITG *istartset,ITG *iendset,ITG *ialset,ITG *jmax,
double *timepar,ITG *nelcon,double *elcon,ITG *ncmat_,
ITG *ntmat_,ITG *istep,char *filab,ITG *nmethod,
ITG *mei){
char *lakon=NULL,description[13]=" ",
*param=NULL;
ITG *kontri=NULL,ntri,*iedg=NULL,*ipoed=NULL,*ieled=NULL,nedg,
*ibounedg=NULL,nbounedg,*ibounnod=NULL,nbounnod,*iedno=NULL,
*integerglob=NULL,iglob,*ifront=NULL,nfront,*ifrontrel=NULL,
*ifront2=NULL,*ifrontrel2=NULL,*istartfront=NULL,*iendfront=NULL,
nnfront,*istartcrackfro=NULL,*iendcrackfro=NULL,ncrack,i,j,
*ibounnod2=NULL,*istartcrackbou=NULL,*iendcrackbou=NULL,imat,
*isubsurffront=NULL,*iedno2=NULL,nkold,*ipkon=NULL,*kon=NULL,
*iresort=NULL,*inum=NULL,kode=1,nstate_=0,iinc,ier=0,nstepf,
mode=-1,noddiam=-1,*inotr=NULL,ntrans,*ielorien=NULL,norien,*ipneigh=NULL,
*neigh=NULL,ngraph=1,mortar=0,*ielprop=NULL,*ielmat=NULL,icritic=0,
*ifrontprop=NULL,*ifronteq=NULL,*istartfronteq=NULL,*iendfronteq=NULL,
nfronteq,ncyc,*idist=NULL,ncrconst,nstep,nproc,ncrtem,law,nstepf2,
*iincglob=NULL,nparam,ncyctot=0,ieqspace,*integerglobf=NULL,lcf;
double *doubleglob=NULL,*stress=NULL,*xt=NULL,*xn=NULL,*xa=NULL,
*acrack=NULL,*xk1=NULL,*xk2=NULL,*xk3=NULL,*doubleglobf=NULL,
*xkeq=NULL,*phi=NULL,*psi=NULL,*co=NULL,*da=NULL,*stress2=NULL,*v=NULL,
*stn=NULL,*een=NULL,*fn=NULL,time=0.,*epn=NULL,*enern=NULL,*sti=NULL,
*xstaten=NULL,*qfn=NULL,*trab=NULL,*orab=NULL,*vr=NULL,*vi=NULL,
*stnr=NULL,*stni=NULL,*vmax=NULL,*stnmax=NULL,*veold=NULL,*ener=NULL,
*cs=NULL,*eenmax=NULL,*fnr=NULL,*fni=NULL,*emn=NULL,*thicke=NULL,*qfx=NULL,
*cdn=NULL,*cdnr=NULL,*cdni=NULL,*prop=NULL,*costruc=NULL,*costruc2=NULL,
*dadn=NULL,*wk1glob=NULL,*wk2glob=NULL,*wk3glob=NULL,*dkeqglob=NULL,
*phiglob=NULL,*dadnglob=NULL,*dnglob=NULL,*charlen,damax,*crcon=NULL,
*angle=NULL,*posfront=NULL,*dist=NULL,*tempf=NULL,*stressf=NULL,
*a=NULL,*amin=NULL,*shape=NULL,*dk=NULL,*p=NULL,*temp=NULL,*temp2=NULL,
*crconloc=NULL,datarget,phimax,*acrackglob=NULL,scaling,*hcfstress=NULL,
*wk1=NULL,*wk2=NULL,*wk3=NULL,*xkeqmin=NULL,*xkeqmax=NULL,*domstep=NULL,
*dkeq=NULL,*domphi=NULL,*xkeqminglob=NULL,*xkeqmaxglob=NULL,
*domstepglob=NULL,*hcftemp=NULL,*xk1f=NULL,*xk2f=NULL,*xk3f=NULL,
*xkeqf=NULL,*phif=NULL,*psif=NULL,*rglob=NULL,*r=NULL;
co=*cop;lakon=*lakonp;ipkon=*ipkonp;kon=*konp;ielmat=*ielmatp;
damax=timepar[0];
phimax=timepar[1]*atan(1.)/45.;
imat=(ITG)(floor(timepar[2]));
nproc=(ITG)(floor(timepar[3]));
scaling=timepar[4];
/* storing the crack propagation data in crcon */
crackpropdata(jobnamec,nelcon,elcon,&crcon,&ncrconst,&ncrtem,&imat,
matname,ntmat_,ncmat_,¶m,&nparam,&law);
/* reading the LCF master file
iglob>0: static results */
nstep=0;
iglob=1;
getuncrackedresults(&jobnamec[396],&integerglob,&doubleglob,
&iglob,&nstep);
/* reading the HCF master file
iglob<0: frequency results */
if(mei[0]>0){
nstepf=0;
iglob=-1;
getuncrackedresults(&jobnamec[528],&integerglobf,&doubleglobf,
&iglob,&nstepf);
}
NNEW(wk1glob,double,3**nk);
NNEW(wk2glob,double,3**nk);
NNEW(wk3glob,double,3**nk);
NNEW(xkeqminglob,double,3**nk);
NNEW(xkeqmaxglob,double,3**nk);
NNEW(dkeqglob,double,3**nk);
NNEW(rglob,double,3**nk);
NNEW(phiglob,double,3**nk);
NNEW(dadnglob,double,3**nk);
NNEW(dnglob,double,3**nk);
NNEW(acrackglob,double,3**nk);
NNEW(iincglob,ITG,3**nk);
NNEW(domstepglob,double,3**nk);
/* loop over crack propagation increments */
for(iinc=0;iinc<jmax[0];iinc++){
printf("Increment %d\n\n",iinc+1);
/* catalogue all triangles belonging to the crack(s)
they are supposed to be of type S3 */
NNEW(kontri,ITG,3**ne);
FORTRAN(cattri,(ne,lakon,ipkon,kon,kontri,&ntri));
RENEW(kontri,ITG,3*ntri);
/* catalogue all edges of the crack(s) */
NNEW(ipoed,ITG,*nk);
NNEW(iedg,ITG,9*ntri+3);
NNEW(ieled,ITG,6*ntri);
FORTRAN(catedges_crackprop,(ipoed,iedg,&ntri,ieled,kontri,&nedg,&ier));
if(ier==1) break;
RENEW(iedg,ITG,3*nedg);
RENEW(ieled,ITG,2*nedg);
/* check for the boundary edges and boundary nodes of the
shell mesh (= crack shape(s)) */
NNEW(ibounedg,ITG,nedg);
NNEW(ibounnod,ITG,nedg);
NNEW(iedno,ITG,2*nedg);
FORTRAN(extern_crackprop,(ieled,&nedg,ibounedg,&nbounedg,ibounnod,
&nbounnod,iedg,iedno));
RENEW(ibounedg,ITG,nbounedg);
RENEW(ibounnod,ITG,nbounnod);
RENEW(iedno,ITG,2*nbounnod);
/* interpolating the stress in all boundary nodes
determining the boundary crack nodes inside the structure */
NNEW(temp,double,nstep*nbounnod);
NNEW(stress,double,6*nstep*nbounnod);
NNEW(ifront,ITG,nbounnod);
NNEW(ifrontrel,ITG,nbounnod);
NNEW(costruc,double,3*nbounnod);
FORTRAN(interpolextnodes,(ibounnod,&nbounnod,co,doubleglob,integerglob,
stress,ifront,&nfront,ifrontrel,costruc,
temp,&nstep));
RENEW(ifront,ITG,nfront);
RENEW(ifrontrel,ITG,nfront);
/* interpolating the hcf stress in all boundary nodes */
if(mei[0]>0){
NNEW(hcftemp,double,nbounnod);
NNEW(hcfstress,double,6*nbounnod);
FORTRAN(interpolextnodesf,(ibounnod,&nbounnod,co,doubleglobf,integerglobf,
hcfstress,hcftemp,&nstepf,&mei[0]));
/* scaling the hcf stress */
for(i=0;i<6*nbounnod;i++){hcfstress[i]*=scaling;}
SFREE(hcftemp);
}
/* determining the internal boundary nodes
sorting them according to adjacency
add the nodes immediately outside the structure */
NNEW(ifront2,ITG,3*nfront);
NNEW(ifrontrel2,ITG,3*nfront);
NNEW(istartfront,ITG,nfront);
NNEW(iendfront,ITG,nfront);
RENEW(ifront,ITG,3*nfront);
RENEW(ifrontrel,ITG,3*nfront);
NNEW(istartcrackfro,ITG,nfront);
NNEW(iendcrackfro,ITG,nfront);
NNEW(ibounnod2,ITG,nbounnod);
NNEW(iresort,ITG,nbounnod);
NNEW(istartcrackbou,ITG,nfront);
NNEW(iendcrackbou,ITG,nfront);
NNEW(isubsurffront,ITG,nfront);
NNEW(iedno2,ITG,2*nbounnod);
NNEW(temp2,double,nstep*6*nbounnod);
NNEW(stress2,double,nstep*6*nbounnod);
NNEW(costruc2,double,3*nbounnod);
/* determine the order of the nodes along the crack front(s) */
FORTRAN(adjacentbounodes,(ifront,ifrontrel,&nfront,iedno,iedg,&nnfront,
ifront2,ifrontrel2,ibounnod,&nbounnod,istartfront,
iendfront,ibounedg,istartcrackfro,iendcrackfro,
&ncrack,ibounnod2,istartcrackbou,iendcrackbou,
isubsurffront,iedno2,stress,stress2,iresort,
ieled,kontri,costruc,costruc2,temp,temp2,&nstep,
&ier));
if(ier==1) break;
SFREE(iresort);
RENEW(ifront,ITG,nfront);
RENEW(ifrontrel,ITG,nfront);
RENEW(istartfront,ITG,nnfront);
RENEW(iendfront,ITG,nnfront);
if(iinc==0) NNEW(charlen,double,ncrack);
RENEW(istartcrackfro,ITG,ncrack);
RENEW(iendcrackfro,ITG,ncrack);
RENEW(istartcrackbou,ITG,ncrack);
RENEW(iendcrackbou,ITG,ncrack);
RENEW(isubsurffront,ITG,nfront);
SFREE(ifront2);SFREE(ifrontrel2);SFREE(ibounnod2);SFREE(iedno2);
SFREE(stress2);SFREE(temp2);SFREE(costruc2);
NNEW(xt,double,3*nfront);
NNEW(xn,double,3*nfront);
NNEW(xa,double,3*nfront);
NNEW(angle,double,nnfront);
/* determine a local coordinate system in each front node based on
the local stress tensor */
FORTRAN(createlocalsys,(&nnfront,istartfront,iendfront,ifront,co,xt,xn,xa,
&nfront,ifrontrel,stress,iedno,ibounedg,ieled,
kontri,isubsurffront,istartcrackfro,iendcrackfro,
&ncrack,angle,&nstep,&ier));
if(ier==1) break;
/* determine a crack length for each front node*/
NNEW(acrack,double,nfront);
NNEW(posfront,double,nfront);
FORTRAN(cracklength,(&ncrack,istartcrackfro,iendcrackfro,co,istartcrackbou,
iendcrackbou,costruc,ibounnod,xt,acrack,istartfront,
iendfront,&nnfront,isubsurffront,ifrontrel,
ifront,posfront,doubleglob,integerglob,
&nproc,&iinc,acrackglob,&ier));
if(ier==1) break;
NNEW(dist,double,nfront);
NNEW(idist,ITG,nfront);
NNEW(a,double,nfront);
// NNEW(amin,double,ncrack);
FORTRAN(cracklength_smoothing,(&nnfront,isubsurffront,istartfront,
iendfront,ifrontrel,costruc,dist,a,
istartcrackfro,iendcrackfro,acrack,amin,
&nfront,&ncrack,idist,&nstep));
SFREE(dist);SFREE(idist);SFREE(a);
/* calculating the shape factors F=K/(sigma*sqrt(pi*a)) */
NNEW(shape,double,3*nfront);
FORTRAN(crackshape,(&nnfront,ifront,istartfront,iendfront,isubsurffront,
angle,posfront,shape));
SFREE(angle);SFREE(posfront);
/* calculating the stress intensity factors (LCF) */
NNEW(xk1,double,nstep*nfront);
NNEW(xk2,double,nstep*nfront);
NNEW(xk3,double,nstep*nfront);
NNEW(xkeq,double,nstep*nfront);
NNEW(phi,double,nstep*nfront);
NNEW(psi,double,nstep*nfront);
FORTRAN(stressintensity,(&nfront,ifrontrel,stress,xt,xn,xa,xk1,xk2,
xk3,xkeq,phi,psi,acrack,shape,&nstep));
SFREE(psi);
/* calculating the stress intensity factors (HCF) */
if(mei[0]>0){
if(mei[1]>nstep){
printf("*ERROR in crackpropagation.c: HCF mission step %d\n",mei[1]);
printf(" exceeds the number of LCF steps %d\n\n",nstep);
FORTRAN(stop,());
}
/* creating LCF+HCF and LCF-HCF */
NNEW(tempf,double,2*nbounnod);
NNEW(stressf,double,6*2*nbounnod);
FORTRAN(combilcfhcf,(tempf,stressf,stress,hcfstress,temp,&nbounnod,
mei,&nstep));
SFREE(hcfstress);
NNEW(xk1f,double,2*nfront);
NNEW(xk2f,double,2*nfront);
NNEW(xk3f,double,2*nfront);
NNEW(xkeqf,double,2*nfront);
NNEW(phif,double,2*nfront);
NNEW(psif,double,2*nfront);
nstepf2=2;
FORTRAN(stressintensity,(&nfront,ifrontrel,stressf,xt,xn,xa,xk1f,xk2f,
xk3f,xkeqf,phif,psif,acrack,shape,&nstepf2));
SFREE(psif);
}
SFREE(shape);
/* smoothing the equivalent k-factors and deflection angles */
NNEW(dist,double,nfront);
NNEW(idist,ITG,nfront);
NNEW(dk,double,nstep*nfront);
NNEW(p,double,nstep*nfront);
FORTRAN(stressintensity_smoothing,(&nnfront,isubsurffront,istartfront,
iendfront,ifrontrel,costruc,dist,
istartcrackfro,iendcrackfro,xkeq,phi,
&nfront,&ncrack,dk,p,idist,&phimax,
&nstep));
SFREE(dist);SFREE(idist);SFREE(dk);SFREE(p);
/* smoothing the HCF equivalent k-factors and deflection angles */
if(mei[0]>0){
NNEW(dist,double,nfront);
NNEW(idist,ITG,nfront);
NNEW(dk,double,2*nfront);
NNEW(p,double,2*nfront);
FORTRAN(stressintensity_smoothing,(&nnfront,isubsurffront,istartfront,
iendfront,ifrontrel,costruc,dist,
istartcrackfro,iendcrackfro,xkeqf,phif,
&nfront,&ncrack,dk,p,idist,&phimax,
&nstepf2));
SFREE(dist);SFREE(idist);SFREE(dk);SFREE(p);
}
/* determine the target crack propagation increment */
FORTRAN(calcdatarget,(ifront,co,&nnfront,istartfront,iendfront,
isubsurffront,&damax,&datarget,acrack,&nstep));
/* propagate the nodes at the crack front(s)
(generate new nodes) */
lcf=1;
if(mei[0]>0){
/* check whether propagation due to hcf */
NNEW(dadn,double,nfront);
NNEW(wk1,double,nfront);
NNEW(wk2,double,nfront);
NNEW(wk3,double,nfront);
NNEW(xkeqmin,double,nfront);
NNEW(xkeqmax,double,nfront);
NNEW(dkeq,double,nfront);
NNEW(r,double,nfront);
NNEW(domstep,double,nfront);
NNEW(domphi,double,nfront);
NNEW(crconloc,double,ncrconst);
FORTRAN(crackrate,(&nfront,ifrontrel,xkeqf,phif,ifront,dadn,&ncyc,
&icritic,&datarget,crcon,tempf,
&ncrtem,crconloc,&ncrconst,xk1f,xk2f,xk3f,&nstepf2,
acrack,wk1,wk2,wk3,xkeqmin,xkeqmax,
dkeq,domstep,domphi,param,&nparam,&law,&ier,r));
if((icritic>0)||(ier==1)){
if(icritic>0){
printf("WARNING: Exit because a critical value for Keq is reached along the crack front due to the modal loading \n");
}else{
printf("WARNING: Exit because an error occurred in crackrate.f \n");
}
printf("Number of iteration= %d\n\n" ,(iinc+1));
SFREE(xkeq);SFREE(phi);SFREE(xk1);SFREE(xk2);SFREE(xk3);
SFREE(xkeqf);SFREE(phif);SFREE(xk1f);SFREE(xk2f);SFREE(xk3f);
SFREE(crconloc);
SFREE(kontri);SFREE(ipoed);SFREE(iedg);SFREE(ieled);SFREE(ibounedg);
SFREE(ibounnod);SFREE(iedno);SFREE(stress);SFREE(ifront);
SFREE(ifrontrel);SFREE(istartfront);SFREE(iendfront);SFREE(xt);
SFREE(stressf);SFREE(tempf);
SFREE(istartcrackfro);SFREE(iendcrackfro);SFREE(temp);
SFREE(istartcrackbou);SFREE(iendcrackbou);SFREE(r);
SFREE(isubsurffront);SFREE(acrack);SFREE(dkeq);SFREE(costruc);
SFREE(dadn);SFREE(wk1);SFREE(wk2);SFREE(wk3);SFREE(xkeqmin);
SFREE(xkeqmax);SFREE(domstep);SFREE(domphi);
break;
}
if(icritic<0){
/* no crack propagation due to hcf: replace step mei[1]
of xkeq by the first step of xkeqf (=lcf+hcf) */
for(i=0;i<nfront;i++){
xkeq[nstep*i+mei[1]-1]=xkeqf[2*i];
}
SFREE(xkeqf);SFREE(phif);SFREE(xk1f);SFREE(xk2f);SFREE(xk3f);
SFREE(dadn);SFREE(wk1);SFREE(wk2);SFREE(wk3);SFREE(xkeqmin);
SFREE(xkeqmax);SFREE(dkeq);SFREE(domstep);SFREE(domphi);SFREE(r);
SFREE(crconloc);
}else{
/* crack propagation due to hcf:
if not allowed: stop
else: accumulate hcf cycles */
/* a negative dominant step points to HCF crack propagation */
for(i=0;i<nfront;i++){
domstep[i]*=-1;
}
SFREE(xkeq);SFREE(phi);SFREE(xk1);SFREE(xk2);SFREE(xk3);
SFREE(xkeqf);SFREE(phif);SFREE(xk1f);SFREE(xk2f);SFREE(xk3f);
SFREE(crconloc);
if(mei[2]==0){
printf("HCF crack propagation takes place; the program stops!\n\n");
icritic=1;
}else{
printf("HCF crack propagation takes place!\n\n");
ncyctot+=ncyc;
}
lcf=0;
}
}
if(lcf==1){
/* reset icritic to the default */
icritic=0;
NNEW(dadn,double,nfront);
NNEW(wk1,double,nfront);
NNEW(wk2,double,nfront);
NNEW(wk3,double,nfront);
NNEW(xkeqmin,double,nfront);
NNEW(xkeqmax,double,nfront);
NNEW(dkeq,double,nfront);
NNEW(r,double,nfront);
NNEW(domstep,double,nfront);
NNEW(domphi,double,nfront);
NNEW(crconloc,double,ncrconst);
FORTRAN(crackrate,(&nfront,ifrontrel,xkeq,phi,ifront,dadn,&ncyc,
&icritic,&datarget,crcon,temp,
&ncrtem,crconloc,&ncrconst,xk1,xk2,xk3,&nstep,
acrack,wk1,wk2,wk3,xkeqmin,xkeqmax,
dkeq,domstep,domphi,param,&nparam,&law,&ier,r));
if((icritic>0)||(ier==1)){
if(icritic>0){
printf("WARNING: Exit because a critical value for Keq is reached along the crack front due to the static loading \n");
}else{
printf("WARNING: Exit because an error occurred in crackrate.f \n");
}
printf("Number of iteration= %d\n\n" ,(iinc+1));
SFREE(xkeq);SFREE(phi);SFREE(xk1);SFREE(xk2);SFREE(xk3);
SFREE(crconloc);
SFREE(kontri);SFREE(ipoed);SFREE(iedg);SFREE(ieled);SFREE(ibounedg);
SFREE(ibounnod);SFREE(iedno);SFREE(stress);SFREE(ifront);
SFREE(ifrontrel);SFREE(istartfront);SFREE(iendfront);SFREE(xt);
SFREE(stressf);SFREE(tempf);
SFREE(istartcrackfro);SFREE(iendcrackfro);SFREE(temp);
SFREE(istartcrackbou);SFREE(iendcrackbou);SFREE(r);
SFREE(isubsurffront);SFREE(acrack);SFREE(dkeq);SFREE(costruc);
SFREE(dadn);SFREE(wk1);SFREE(wk2);SFREE(wk3);SFREE(xkeqmin);
SFREE(xkeqmax);SFREE(domstep);SFREE(domphi);
break;
}
ncyctot+=ncyc;
SFREE(xkeq);SFREE(phi);SFREE(xk1);SFREE(xk2);SFREE(xk3);
SFREE(crconloc);
}
nkold=*nk;
NNEW(da,double,nfront);
RENEW(co,double,3*(*nk+nfront));
NNEW(ifrontprop,ITG,nfront);
FORTRAN(crackprop,(ifrontrel,ibounnod,domphi,da,co,costruc,nk,xa,
xn,&nnfront,istartfront,iendfront,doubleglob,
integerglob,isubsurffront,dadn,&ncyc,
ifrontprop,&nstep,acrack,acrackglob,&datarget,
&ieqspace,iincglob,&iinc));
SFREE(xn);SFREE(xa);
/* calculate the mesh characteristic length for each front
and the new equally spread nodes on the propagated front(s) */
NNEW(ifronteq,ITG,2*nfront);
NNEW(istartfronteq,ITG,nnfront);
NNEW(iendfronteq,ITG,nnfront);
/* the assumption is made, that no more than 2*nfront equally
spaced nodes are necessary for the propagated front */
RENEW(co,double,3*(*nk+2*nfront));
RENEW(acrackglob,double,*nk+2*nfront);
RENEW(iincglob,ITG,*nk+2*nfront);
if(iinc==0){
FORTRAN(characteristiclength,(co,istartcrackfro,iendcrackfro,&ncrack,
ifront,charlen,&datarget));
}
/* next lines of no equal spacing is desired */
if(ieqspace==0){
RENEW(ifronteq,ITG,nfront);
memcpy(&ifronteq[0],&ifrontprop[0],sizeof(ITG)*nfront);
memcpy(&istartfronteq[0],&istartfront[0],sizeof(ITG)*nnfront);
memcpy(&iendfronteq[0],&iendfront[0],sizeof(ITG)*nnfront);
nfronteq=nfront;
}else{
/* next lines of equal spacing is desired */
FORTRAN(eqspacednodes,(co,istartfront,iendfront,&nnfront,
ifrontprop,nk,&nfront,ifronteq,charlen,
istartfronteq,iendfronteq,&nfronteq,
acrackglob,&ier,iendcrackfro,iincglob,
&iinc,dnglob,&ncyctot));
if(ier==1) break;
}
RENEW(acrackglob,double,3*(*nk+nfront));
RENEW(iincglob,ITG,3*(*nk+nfront));
RENEW(ifronteq,ITG,nfronteq);
/* update the crack mesh topology (generate new crack elements) */
RENEW(lakon,char,8*(*ne+(nfronteq+nfront)));
RENEW(ipkon,ITG,*ne+(nfronteq+nfront));
RENEW(ielmat,ITG,mi[2]*(*ne+(nfronteq+nfront)));
for(i=mi[2]**ne;i<mi[2]*(*ne+(nfronteq+nfront));i++){ielmat[i]=0.;}
RENEW(kon,ITG,*nkon+9*(*ne+(nfronteq+nfront)));
FORTRAN(extendmesh,(&nnfront,istartfront,iendfront,ifront,&nkold,ne,
nkon,lakon,ipkon,kon,isubsurffront,co,ifronteq,
istartfronteq,iendfronteq,&nfront,&nfronteq));
RENEW(lakon,char,8**ne);
RENEW(ipkon,ITG,*ne);
RENEW(ielmat,ITG,mi[2]**ne);
RENEW(kon,ITG,*nkon);
/* storing the local crack results into global nodal fields */
RENEW(wk1glob,double,3*(*nk+nfront));
RENEW(wk2glob,double,3*(*nk+nfront));
RENEW(wk3glob,double,3*(*nk+nfront));
RENEW(xkeqminglob,double,3*(*nk+nfront));
RENEW(xkeqmaxglob,double,3*(*nk+nfront));
RENEW(dkeqglob,double,3*(*nk+nfront));
RENEW(rglob,double,3*(*nk+nfront));
RENEW(phiglob,double,3*(*nk+nfront));
RENEW(dadnglob,double,3*(*nk+nfront));
RENEW(dnglob,double,3*(*nk+nfront));
RENEW(iincglob,ITG,3*(*nk+nfront));
RENEW(domstepglob,double,3*(*nk+nfront));
FORTRAN(globalcrackresults,(&nfront,ifront,wk1,wk2,wk3,dkeq,domphi,dadn,
&ncyctot,wk1glob,wk2glob,wk3glob,dkeqglob,
phiglob,dadnglob,dnglob,acrack,acrackglob,
&nstep,xkeqmin,xkeqmax,xkeqminglob,xkeqmaxglob,
&iinc,iincglob,domstep,domstepglob,r,rglob));
SFREE(kontri);SFREE(ipoed);SFREE(iedg);SFREE(ieled);SFREE(ibounedg);
SFREE(ibounnod);SFREE(iedno);SFREE(stress);SFREE(ifront);SFREE(ifrontrel);
SFREE(istartfront);SFREE(iendfront);SFREE(xt);SFREE(stressf);SFREE(tempf);
SFREE(istartcrackfro);SFREE(iendcrackfro);SFREE(temp);
SFREE(istartcrackbou);SFREE(iendcrackbou);
SFREE(isubsurffront);SFREE(acrack);
SFREE(dkeq);SFREE(da);SFREE(costruc);SFREE(r);
SFREE(dadn);SFREE(ifrontprop);SFREE(ifronteq);SFREE(istartfronteq);
SFREE(iendfronteq);SFREE(wk1);SFREE(wk2);SFREE(wk3);SFREE(xkeqmin);
SFREE(xkeqmax);SFREE(domstep);SFREE(domphi);
if(icritic>0){
printf("WARNING: Exit because crack propagation occurred due to the modal loading \n");
printf("Number of iteration= %d\n\n" ,(iinc+1));
break;
}else if(icritic<0){
printf("WARNING: Exit because no crack propagation anywhere along the crack front \n");
printf("Number of iteration= %d\n\n" ,(iinc+1));
break;
}
}
SFREE(crcon);SFREE(integerglob);SFREE(doubleglob);
if(mei[0]>0){SFREE(integerglobf);SFREE(doubleglobf);}
for(j=0;j<*ne;j++){
if(strcmp1(&lakon[8*j+6],"L")==0) lakon[8*j+6]='A';
}
NNEW(inum,ITG,*nk);
for(j=0;j<*nk;j++){
inum[j]=1;
}
/* storing the global mesh and the triangulation of the crack(s):
shells must be stored as 2D-triangles */
filab[4]='I';
frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,
&kode,filab,een,t1,fn,&time,epn,ielmat,matname,enern,xstaten,
&nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr,
&ntrans,orab,ielorien,&norien,description,ipneigh,neigh,
mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne,
cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn,
thicke,jobnamec,output,qfx,cdn,&mortar,cdnr,cdni,nmat,
ielprop,prop,sti);
/* storing the crack propagation fields in frd-format */
if(strcmp1(&filab[4611],"KEQ ")==0){
crackfrd(nk,&ngraph,&noddiam,cs,&kode,inum,nmethod,&time,istep,&iinc,&mode,
description,set,nset,istartset,iendset,ialset,jobnamec,output,
dkeqglob,wk1glob,wk2glob,wk3glob,phiglob,dadnglob,dnglob,
acrackglob,xkeqminglob,xkeqmaxglob,iincglob,domstepglob,
rglob);
}
SFREE(wk1glob);SFREE(wk2glob);SFREE(wk3glob);SFREE(dkeqglob);
SFREE(phiglob);SFREE(dadnglob);SFREE(dnglob);SFREE(xkeqminglob);
SFREE(inum);SFREE(charlen);SFREE(acrackglob);SFREE(xkeqmaxglob);
SFREE(iincglob);SFREE(domstepglob);SFREE(rglob);
*cop=co;*lakonp=lakon;*ipkonp=ipkon;*konp=kon;*ielmatp=ielmat;
return;
}
| 33.992679 | 122 | 0.666624 |
4cafbfb5fda16d7e6647d508c6d9a010efa3783a | 2,820 | c | C | src/timer/timer.c | recp/tm | 99c42dca60722a5cc2b16746d65ad27775b8bc06 | [
"MIT"
] | 34 | 2018-07-31T15:13:05.000Z | 2022-01-28T18:06:27.000Z | src/timer/timer.c | recp/tm | 99c42dca60722a5cc2b16746d65ad27775b8bc06 | [
"MIT"
] | null | null | null | src/timer/timer.c | recp/tm | 99c42dca60722a5cc2b16746d65ad27775b8bc06 | [
"MIT"
] | 3 | 2020-03-17T05:37:33.000Z | 2022-01-28T18:06:29.000Z | /*
* Copyright (c), Recep Aslantas.
* MIT License (MIT), http://opensource.org/licenses/MIT
*/
#include "../common.h"
#include "runloop.h"
#include "timer.h"
#include <time.h>
#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach_time.h>
#endif
double tm__time2sec = 1.0;
TM_EXPORT
tm_timer*
tm_alloc(tm_func cb, tm_interval interval) {
tm_allocator *alc;
tm_timer *tmr;
alc = tm_get_allocator();
tmr = alc->calloc(1, sizeof(*tmr));
tmr->cb = cb;
tmr->interval = interval;
return tmr;
}
TM_HIDE
tm_timer*
tm_alloc2(tm_vfunc cb, void *arg, tm_interval interval) {
tm_allocator *alc;
tm_timer *tmr;
alc = tm_get_allocator();
tmr = alc->calloc(1, sizeof(*tmr));
tmr->cb2 = cb;
tmr->arg = arg;
tmr->interval = interval;
return tmr;
}
TM_EXPORT
tm_timer*
tm_schedule(tm_func cb, tm_interval interval, tm_interval delay) {
tm_timer *timer;
timer = tm_alloc(cb, interval);
timer->start_at = tm_time() + delay;
tm_start(timer);
return timer;
}
TM_EXPORT
void
tm_settimeout(tm_vfunc cb, void *arg, tm_interval delay) {
tm_timer *timer;
timer = tm_alloc2(cb, arg, 0);
timer->maxtick = 1;
timer->istimeout = true;
tm_start_at(timer, delay);
}
TM_EXPORT
void
tm_free(tm_timer *timer) {
timer->status = TM_TIMER_WAITING_TO_STOP | TM_TIMER_WAITING_TO_FREE;
}
TM_EXPORT
void
tm_start(tm_timer *timer) {
tm_runloop *loop;
if (timer->status != TM_TIMER_STOPPED)
return;
loop = tm_def_runloop();
thread_wrlock(&loop->rwlock);
if (loop->timers)
loop->timers->prev = timer;
timer->next = loop->timers;
loop->timers = timer;
timer->status = TM_TIMER_SCHEDULED;
loop->timercount++;
thread_rwunlock(&loop->rwlock);
thread_cond_signal(&loop->cond);
}
TM_EXPORT
void
tm_start_at(tm_timer *timer, tm_interval delay) {
timer->start_at = tm_time() + delay;
tm_start(timer);
}
TM_EXPORT
void
tm_stop(tm_timer *timer) {
timer->status = TM_TIMER_WAITING_TO_STOP;
}
TM_EXPORT
tm_interval
tm_time() {
#ifdef __MACH__
uint64_t abstime;
abstime = mach_absolute_time();
return abstime * tm__time2sec;
#elif defined(_WIN32) || defined(_MSC_VER)
uint64_t abstime;
QueryPerformanceCounter((LARGE_INTEGER *)&abstime);
return abstime * tm__time2sec;
#else
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (tm_interval)ts.tv_sec + ts.tv_nsec * 1e-9;
#endif
}
TM_HIDE
void
tm__time_init() {
#ifdef __MACH__
mach_timebase_info_data_t info;
mach_timebase_info(&info);
tm__time2sec = (double)info.numer / (info.denom * NSEC_PER_SEC);
#elif defined(_WIN32) || defined(_MSC_VER)
uint64_t frequency;
QueryPerformanceFrequency((LARGE_INTEGER *)&frequency);
tm__time2sec = 1.0 / (double)frequency;
#endif
}
| 19.183673 | 70 | 0.685816 |
215611eb347d2a4243d7fd389cd208bc4070a65c | 5,059 | c | C | apps/pkeyparam.c | redshodan/mosh-openssl | af170194a88d6127d447bea826845c23ca192727 | [
"OpenSSL"
] | 6 | 2015-10-07T06:12:10.000Z | 2018-04-16T12:55:40.000Z | extern/openssl.orig/apps/pkeyparam.c | vbloodv/blood | 1c6f6c54e937e8d7064f72f32cbbcc8fdaa2677d | [
"MIT"
] | null | null | null | extern/openssl.orig/apps/pkeyparam.c | vbloodv/blood | 1c6f6c54e937e8d7064f72f32cbbcc8fdaa2677d | [
"MIT"
] | 2 | 2017-08-05T18:31:01.000Z | 2021-11-07T16:23:34.000Z | /*
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2006
*/
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. 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. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``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 OpenSSL PROJECT 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 product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
#include <stdio.h>
#include <string.h>
#include "apps.h"
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/evp.h>
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_IN, OPT_OUT, OPT_TEXT, OPT_NOOUT, OPT_ENGINE
} OPTION_CHOICE;
OPTIONS pkeyparam_options[] = {
{"help", OPT_HELP, '-', "Display this summary"},
{"in", OPT_IN, '<', "Input file"},
{"out", OPT_OUT, '>', "Output file"},
{"text", OPT_TEXT, '-', "Print parameters as text"},
{"noout", OPT_NOOUT, '-', "Don't output encoded parameters"},
#ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
#endif
{NULL}
};
int pkeyparam_main(int argc, char **argv)
{
BIO *in = NULL, *out = NULL;
EVP_PKEY *pkey = NULL;
int text = 0, noout = 0, ret = 1;
OPTION_CHOICE o;
char *infile = NULL, *outfile = NULL, *prog;
prog = opt_init(argc, argv, pkeyparam_options);
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_EOF:
case OPT_ERR:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
goto end;
case OPT_HELP:
opt_help(pkeyparam_options);
ret = 0;
goto end;
case OPT_IN:
infile = opt_arg();
break;
case OPT_OUT:
outfile = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
break;
case OPT_TEXT:
text = 1;
break;
case OPT_NOOUT:
noout = 1;
break;
}
}
argc = opt_num_rest();
argv = opt_rest();
if (!app_load_modules(NULL))
goto end;
in = bio_open_default(infile, 'r', FORMAT_PEM);
if (in == NULL)
goto end;
out = bio_open_default(outfile, 'w', FORMAT_PEM);
if (out == NULL)
goto end;
pkey = PEM_read_bio_Parameters(in, NULL);
if (!pkey) {
BIO_printf(bio_err, "Error reading parameters\n");
ERR_print_errors(bio_err);
goto end;
}
if (!noout)
PEM_write_bio_Parameters(out, pkey);
if (text)
EVP_PKEY_print_params(out, pkey, 0, NULL);
ret = 0;
end:
EVP_PKEY_free(pkey);
BIO_free_all(out);
BIO_free(in);
return ret;
}
| 33.282895 | 77 | 0.636489 |
34e892e2c50eaa1947083d535726b605fae191ff | 1,478 | h | C | include/game/Player/PlayerFormSensorCollisionArranger.h | CraftyBoss/Starlight-SMO-LayoutEditing | d777e11fb073242ce44b3cc4d616d356a513fceb | [
"MIT"
] | 8 | 2021-11-06T02:11:04.000Z | 2022-03-03T05:21:19.000Z | include/game/Player/PlayerFormSensorCollisionArranger.h | Sanae6/Starlight-SMO-LayoutEditing | e79e3e1edeb67bac450cbb2dde38594ec6957714 | [
"MIT"
] | 1 | 2021-12-14T00:29:17.000Z | 2021-12-21T15:04:21.000Z | include/game/Player/PlayerFormSensorCollisionArranger.h | Sanae6/Starlight-SMO-LayoutEditing | e79e3e1edeb67bac450cbb2dde38594ec6957714 | [
"MIT"
] | 6 | 2021-10-31T11:42:06.000Z | 2021-12-21T00:17:52.000Z | #pragma once
#include "sead/math/seadVector.h"
#include "al/LiveActor/LiveActor.h"
#include "PlayerColliderHakoniwa.h"
#include "PlayerHackKeeper.h"
class IPlayerModelChanger;
class PlayerFormSensorCollisionArranger {
public:
PlayerFormSensorCollisionArranger(al::LiveActor *, PlayerColliderHakoniwa *, IPlayerModelChanger const*, PlayerHackKeeper const*);
void setFormModel3D(void);
void setFormModel2D(void);
void setFormActionSquat(void);
void setFormActionStandup(void);
void setFormActionWallGrab(sead::Vector3f const&);
void setFormActionGrabCeil(sead::Vector3f const&);
void setFormActionPoleClimb(sead::Vector3f const&);
void setFormActionSwim(void);
void setFormActionHack(void);
void setFormActionBind(bool);
void setFormActionRecovery(void);
void setFormActionAbyss(sead::Vector3f const&);
void setFormActionDead(void);
void setFormAttackSensorNone(void);
void setFormAttackSensorSpin(void);
void setFormAttackSensorTornado(void);
void setCollisionShapeOffsetGround(float);
const char *getHeadSensorName(void) const;
sead::Vector3f *getHeadPos(void) const;
float getHeadRadius(void) const;
sead::Vector3f *getBodyPos(void) const;
bool isEnableSafetyPointForm(void) const;
void update(void);
void syncForm(void);
void validateAttackSensor(void);
}; | 37.897436 | 138 | 0.705007 |
56ca12b6592ffd69ee176d37d89d00565fd2d5d4 | 726 | c | C | src/main.c | NoeMurr/ncurses_pong | b1fa3cfa7e0e07b684958e1d18dd10e2c4043fe6 | [
"BSD-3-Clause"
] | null | null | null | src/main.c | NoeMurr/ncurses_pong | b1fa3cfa7e0e07b684958e1d18dd10e2c4043fe6 | [
"BSD-3-Clause"
] | null | null | null | src/main.c | NoeMurr/ncurses_pong | b1fa3cfa7e0e07b684958e1d18dd10e2c4043fe6 | [
"BSD-3-Clause"
] | null | null | null | /*******************************************************************************
PONG
File: main.c
*******************************************************************************/
#include <stdio.h>
#include "screen/screen.h"
#include "game/game.h"
int main(int argc, char const *argv[]) {
init_screen(30,75);
init_game();
pthread_t screen_updater;
pthread_t ball_worker;
pthread_t racket_controller;
pthread_create(&racket_controller,NULL,&move_racket,NULL);
pthread_create(&ball_worker,NULL,&move_ball,NULL);
pthread_create(&screen_updater,NULL,&update_screen,NULL);
pthread_join(racket_controller, (void *)10);
endwin();
return 0;
}
| 31.565217 | 80 | 0.511019 |
16f498e6862e2934638a2efdc0a0cd99a06628c1 | 3,424 | h | C | lib/app/include/app.h | robinlavallee/chicken-little | 4605bdc07a5a8ea7df9fb2b574241fa15a1d2dc3 | [
"MIT"
] | 1 | 2020-09-14T22:16:15.000Z | 2020-09-14T22:16:15.000Z | lib/app/include/app.h | robinlavallee/chicken-little | 4605bdc07a5a8ea7df9fb2b574241fa15a1d2dc3 | [
"MIT"
] | null | null | null | lib/app/include/app.h | robinlavallee/chicken-little | 4605bdc07a5a8ea7df9fb2b574241fa15a1d2dc3 | [
"MIT"
] | 1 | 2020-09-14T22:16:21.000Z | 2020-09-14T22:16:21.000Z | /*
*/
#ifndef _app_h
#define _app_h_
//#include <windows.h>
#include "mmio.h"
typedef void FUNCV(void);
typedef FUNCV * LPFUNCV;
// we use memset instead of Windows-specific ZeroMemory because it is more
// cross-platform friendly.
#define CLEAR_STRUCT(s) memset(&s,0,sizeof(s))
#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
/* =====================================================================================
Message map
======================================================================================== */
#define WMWL uint uMsg, uint wParam, uint lParam
typedef uint FUNCWMWL(WMWL);
typedef FUNCWMWL * LPFUNCWMWL;
typedef struct
{
uint uMsg;
uint wParam;
LPFUNCWMWL MsgHandlerFunc;
} APPMSGMAP;
extern uint App_OnPaint(WMWL);
extern uint App_OnDestroy(WMWL);
extern uint App_OnSize(WMWL);
#define BEGIN_MESSAGE_MAP(s) APPMSGMAP s[] = {
#define ON_COMMAND(id,func) {WM_COMMAND,id,func},
#define ON_PAINT(func) {WM_PAINT,0,func},
#define ON_DISPLAYCHANGE(func) {WM_DISPLAYCHANGE,0,func},
#define ON_CREATE(func) {WM_CREATE,0,func},
#define ON_DESTROY(func) {WM_DESTROY,0,func},
#define ON_SIZE(func) {WM_SIZE,0,func},
#define END_MESSAGE_MAP() {0,0,NULL} };
/* ===============================================================================================
Window creation
=============================================================================================== */
typedef struct
{
CHAR *WindowName; // "<program name>"
CHAR *IconName; // MAKEINTRESOURCE(IDI_APPICON)
CHAR *IconSmName; // MAKEINTRESOURCE(IDI_APPICON)
DWORD Style; // APPWS_NORMAL || APPWS_FULLSCREEN
int Width; // width of client area
int Height; // height of client area
const CHAR *MenuName; // menu name (NULL for none)
APPMSGMAP *MessageMap; // message map structure
} APPWND;
#define APPWS_NORMAL 0 // WS_OVERLAPPEDWINDOW
#define APPWS_FULLSCREEN 1 // WS_POPUP
/* ===============================================================================================
Function declarations
=============================================================================================== */
extern bool App_CreateWindow(APPWND *wnd);
extern bool App_AdjustWindow(uint dwStyle, int x, int y, int Width, int Height, BOOL bMenu);
extern void App_Close(void);
extern char *App_GetCommandLine(void);
//HWND App_GetWindowHandle(void);
extern void App_Run(void);
extern void App_SetState(LPFUNCV renderfunc, LPFUNCV logicfunc);
extern void App_SetRenderer(LPFUNCV renderfunc);
extern void App_Paint(void);
extern ulong App_GetTime(void);
extern BOOL App_IsMinimized(void);
extern DWORD App_GetDXVersion(void);
extern int App_MessageBox(const CHAR *title, const CHAR *text, int style);
extern int App_DialogBox(uint res);
// ==============
// Timer Jazz
// ==============
volatile ulong systemtime, // don't modify this. only read it.
timer; // set this to 0 for easy wait-loops.
extern BOOL AppTimer_Init(LPFUNCV timerfunc, int hz);
extern void AppTimer_Exit(void);
extern BOOL AppTimer_SetEvent(uint framedelay, void (*proc)(uint message, void *data), uint message, void *data);
#define _app_h
#endif
| 32.301887 | 116 | 0.56104 |
22cacce0246b19c19bed44024e4ad341b9e774cb | 893 | c | C | uhk/acm3853.c | Hyyyyyyyyyy/acm | d7101755b2c2868d51bb056f094e024d0333b56f | [
"MIT"
] | null | null | null | uhk/acm3853.c | Hyyyyyyyyyy/acm | d7101755b2c2868d51bb056f094e024d0333b56f | [
"MIT"
] | null | null | null | uhk/acm3853.c | Hyyyyyyyyyy/acm | d7101755b2c2868d51bb056f094e024d0333b56f | [
"MIT"
] | null | null | null | #include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
int i, j, k, u, n, m;
double a, b, c, ar[1002][1002][3], bag[1002][1002];
while (scanf("%d %d", &n, &m) != EOF)
{
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
{
scanf("%lf %lf %lf", &ar[i][j][0], &ar[i][j][1], &ar[i][j][2]);
}
}
memset(bag, 0, sizeof(bag));
for (i = n; i > 0; i--)
{
for (j = m; j > 0; j--)
{
if (i == n && j == m)
continue;
if (fabs(1 - ar[i][j][0]) < 1e-8)
continue;
bag[i][j] = (bag[i + 1][j] * ar[i][j][2] + bag[i][j + 1] * ar[i][j][1] + 2.0) / (1.0 - ar[i][j][0]);
}
}
printf("%.3lf\n", bag[1][1]);
}
return 0;
} | 27.060606 | 116 | 0.326988 |
edf4b5bc34e8e46dc57f6ffa0094463c281e3e04 | 1,839 | h | C | PrivateFrameworks/PhotoImaging/PICompositionExporter.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/PhotoImaging/PICompositionExporter.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/PhotoImaging/PICompositionExporter.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@interface PICompositionExporter : NSObject
{
}
+ (id)resetImageProperties:(id)arg1 preserveRegions:(BOOL)arg2;
+ (id)metadataConverter;
+ (void)setMetadataConverter:(id)arg1;
- (void)_exportVideoToURLFull:(id)arg1 composition:(id)arg2 options:(id)arg3 metadata:(id)arg4 progress:(id)arg5 completion:(CDUnknownBlockType)arg6;
- (void)_exportVideoToURL:(id)arg1 composition:(id)arg2 options:(id)arg3 metadata:(id)arg4 progress:(id)arg5 completion:(CDUnknownBlockType)arg6;
- (BOOL)shouldTryVideoRotationFastPath:(id)arg1 options:(id)arg2;
- (id)addVideoProperties:(id)arg1 composition:(id)arg2 options:(id)arg3 error:(id *)arg4;
- (void)_prepareToExportVideo:(id)arg1 options:(id)arg2 completion:(CDUnknownBlockType)arg3;
- (id)addImageProperties:(id)arg1 composition:(id)arg2 options:(id)arg3 error:(id *)arg4;
- (void)prepareAuxiliaryImagesFetchProperties:(id)arg1 options:(id)arg2 completion:(CDUnknownBlockType)arg3;
- (void)prepareImageExportRequest:(id)arg1 options:(id)arg2 completion:(CDUnknownBlockType)arg3;
- (id)variationForFlavor:(id)arg1;
- (id)exportComposition:(id)arg1 options:(id)arg2 completionQueue:(id)arg3 completion:(CDUnknownBlockType)arg4;
- (id)exportComposition:(id)arg1 toPrimaryURL:(id)arg2 videoComplementURL:(id)arg3 videoPosterFrameURL:(id)arg4 completionQueue:(id)arg5 completion:(CDUnknownBlockType)arg6;
- (id)exportVideoToURL:(id)arg1 composition:(id)arg2 options:(id)arg3 completion:(CDUnknownBlockType)arg4;
- (void)exportImageToDataWithComposition:(id)arg1 options:(id)arg2 completion:(CDUnknownBlockType)arg3;
- (void)exportImageToURL:(id)arg1 composition:(id)arg2 options:(id)arg3 completion:(CDUnknownBlockType)arg4;
- (id)init;
@end
| 54.088235 | 173 | 0.784666 |
e84dcb3d76b5934764f20e395bacb67f3535bbb2 | 262 | h | C | tools/snex_playground/function_const_ref.h | romsom/HISE | 73e0e299493ce9236e6fafa7938d3477fcc36a4a | [
"Intel"
] | null | null | null | tools/snex_playground/function_const_ref.h | romsom/HISE | 73e0e299493ce9236e6fafa7938d3477fcc36a4a | [
"Intel"
] | null | null | null | tools/snex_playground/function_const_ref.h | romsom/HISE | 73e0e299493ce9236e6fafa7938d3477fcc36a4a | [
"Intel"
] | null | null | null | /*
BEGIN_TEST_DATA
f: main
ret: int
args: int
input: 12
output: 24
error: ""
filename: "basic/function_const_ref"
END_TEST_DATA
*/
int other(const int& input)
{
return input * 2;
}
int main(int input)
{
int x = other(input);
return x;
}
| 10.48 | 38 | 0.633588 |
1974bbc8c0af80aa4b446eebd9f16b9805a00566 | 3,570 | h | C | 02Segundo/Estructura_de_Datos_ED/EjerciciosED/include/menu.h | elsudano/Facultad | 8ff2c5904f0a38a3a0682e040da4439f2bc872f2 | [
"MIT"
] | 2 | 2017-02-20T09:26:42.000Z | 2021-11-21T21:56:35.000Z | 02Segundo/Estructura_de_Datos_ED/EjerciciosED/include/menu.h | elsudano/Facultad | 8ff2c5904f0a38a3a0682e040da4439f2bc872f2 | [
"MIT"
] | 1 | 2016-10-06T16:59:39.000Z | 2017-09-21T08:04:51.000Z | 02Segundo/Estructura_de_Datos_ED/EjerciciosED/include/menu.h | elsudano/Facultad | 8ff2c5904f0a38a3a0682e040da4439f2bc872f2 | [
"MIT"
] | 4 | 2016-10-06T16:41:01.000Z | 2019-11-21T12:37:20.000Z | /*
* menu.h
*
* Created on: 17/11/2013
* Author: Carlos de la Torre
*/
#ifndef MENU_H_
#define MENU_H_
#include "default.h"
#include <vector>
#include <map>
using namespace std;
typedef string nombreItem;
typedef unsigned valorItem;
typedef pair<nombreItem,valorItem> Item;
typedef vector<Item> listaItems;
class itemMenu{
private:
listaItems miListaOpciones;
nombreItem miNombre;
valorItem miValor;
public:
/**
* @brief Constructor primitivo
*/
itemMenu(nombreItem pNombre, valorItem pValor);
/**
* @brief Muestra el nombre del Menú
*/
nombreItem getNombre();
/**
* @brief Muestra el valor que devuelve el menu al seleccionarlo.
*/
valorItem getValor();
/**
* @brief Deveulve el valor de la Opción del Menú
* @return tipoitemOpcion es un pair con el nombre de la opcion y el valor de la misma.
*/
valorItem getOpcion(const nombreItem pCual);
/**
* @brief Deveulve todas las opciones de un menu
* @return listaItems es un map con todos los items que tiene el menu.
*/
listaItems getOpciones();
/**
* @brief Adigna el nombre de la Opción
*/
void setNombre(nombreItem &pNombre);
/**
* @brief Asigna el valor que devolvera el menu al seleccionarlo.
*/
void setValor(valorItem &pValor);
/**
* @brief Asigna el valor de la Opción
*/
void setOpcion(Item &pOpcion);
};
typedef vector<itemMenu> BarraMenu;
class menuTexto{
private:
BarraMenu miBarraMenu;
// vector<itemMenu>::iterator it;
/*
* @brief Muestra el menu por pantalla.
*/
void mostrarMenus();
/*
* @brief Muesta todos los submenu de un menu dado.
*/
void mostrarSubMenus(itemMenu &pMenu);
public:
/*
* @brief constructor primitivo.
*/
menuTexto();
/*
* @brief constructor primitivo.
* @param[in] nula representa a la entrada nula para el diccionario
* @post define la entrada nula
*/
menuTexto(itemMenu &pMenu);
/*
* @brief constructor de copia
* @param[in] menu, menu a copiar
*/
menuTexto(const menuTexto &pValor);
/*
* @brief Añade un menu a la Barra de Menus.
* @param[in] pMenu es el nombre del Menu.
* @param[in] pValor es el valor que devolvera el menu al seleccionarlo.
* @post Se añade solo el menu con un submenu vacio.
*/
void addMenu(nombreItem pMenu, valorItem pValor);
/*
* @brief Añade un Submenu al Menu.
* @param[in] pMenu es el nombre del menu al que vamos a añadir el submenu.
* @param[in] pSubMenu es el nombre del submenu que añadiremos.
* @param[in] pValor es el valor unsigned que devolvera el submenu al seleccionarla.
*/
void addSubMenu(nombreItem pMenu, nombreItem pSubMenu, valorItem pValor);
/**
* @brief Muestra el menu y espera la elección del usuario.
*/
int seleccionar();
// /*
// * @brief Consulta/Inserta una opcion completa con valor incluido al menu que elijamos.
// * @param[in] pMenu este es el nombre del menu al que queremos asignar la opcion.
// * @return[in/out] una referencia a la opcion que queremos crear/consultar.
// */
// valorItem &operator[](const nombreItem &pMenu);
//
// /*
// * @brief Consulta un menu.
// */
// const valorItem &operator[](const nombreItem &pMenu) const;
//
// /*
// * @brief operador de asignación
// */
// tipoItemMenu &operator=( const tipoItemMenu &pValor);
/*
* @brief numero de menus
* @post No se modifica el menuTexto.
*/
int size() const ;
/*
* @brief vacia
* Chequea si el menu esta vacío.
*/
bool empty() const;
};
#endif /* MENU_H_ */
| 22.173913 | 91 | 0.663585 |
e5fa3c72c65a3c5fb25241e4c59c4202571b417e | 1,260 | h | C | src/eth.h | 1computerguy/mercury | 193bf6432e4f53f1253965f5ca8634bd6ca69136 | [
"BSD-2-Clause"
] | null | null | null | src/eth.h | 1computerguy/mercury | 193bf6432e4f53f1253965f5ca8634bd6ca69136 | [
"BSD-2-Clause"
] | null | null | null | src/eth.h | 1computerguy/mercury | 193bf6432e4f53f1253965f5ca8634bd6ca69136 | [
"BSD-2-Clause"
] | null | null | null | /*
* eth.h
*
* Copyright (c) 2019 Cisco Systems, Inc. All rights reserved.
* License at https://github.com/cisco/mercury/blob/master/LICENSE
*/
#ifndef ETH_H
#define ETH_H
#include <stdint.h>
#define ETH_ADDR_LEN 6
struct eth_hdr {
uint8_t dhost[ETH_ADDR_LEN];
uint8_t shost[ETH_ADDR_LEN];
uint16_t ether_type;
} __attribute__ ((__packed__));
struct eth_dot1q_tag {
uint16_t tci;
uint16_t ether_type;
} __attribute__ ((__packed__));
struct eth_dot1ad_tag {
uint16_t inner_tci;
uint16_t ether_type;
} __attribute__ ((__packed__));
#define MPLS_HDR_LEN 4
#define MPLS_BOTTOM_OF_STACK 0x100
/*
* big-endian ETHERTYPE definitions
*/
#define ETH_TYPE_NONE 0x0000
#define ETH_TYPE_PUP 0x0200
#define ETH_TYPE_SPRITE 0x0500
#define ETH_TYPE_IP 0x0800
#define ETH_TYPE_ARP 0x0806
#define ETH_TYPE_REVARP 0x8035
#define ETH_TYPE_AT 0x809B
#define ETH_TYPE_AARP 0x80F3
#define ETH_TYPE_VLAN 0x8100
#define ETH_TYPE_IPX 0x8137
#define ETH_TYPE_IPV6 0x86dd
#define ETH_TYPE_1AD 0x88a8
#define ETH_TYPE_LOOPBACK 0x9000
#define ETH_TYPE_TRAIL 0x1000
#define ETH_TYPE_MPLS 0x8847
#endif /* ETH_H */
| 22.909091 | 66 | 0.692857 |
c372d6cdb8f492905c6843ff32e7eea88fd71e1f | 950 | h | C | QtScrcpy/device/decoder/decoder.h | 13383754499/QtScrcpy | be5aa5d337093ba3f4f24bfded25b1c61fc3e5a9 | [
"Apache-2.0"
] | null | null | null | QtScrcpy/device/decoder/decoder.h | 13383754499/QtScrcpy | be5aa5d337093ba3f4f24bfded25b1c61fc3e5a9 | [
"Apache-2.0"
] | null | null | null | QtScrcpy/device/decoder/decoder.h | 13383754499/QtScrcpy | be5aa5d337093ba3f4f24bfded25b1c61fc3e5a9 | [
"Apache-2.0"
] | null | null | null | #ifndef DECODER_H
#define DECODER_H
#include <QObject>
extern "C"
{
#include "libavcodec/avcodec.h"
}
class VideoBuffer;
class Decoder : public QObject
{
Q_OBJECT
public:
Decoder(std::function<void(int width, int height, uint8_t* dataY, uint8_t* dataU, uint8_t* dataV, int linesizeY, int linesizeU, int linesizeV)> onFrame, QObject *parent = Q_NULLPTR);
virtual ~Decoder();
bool open();
void close();
bool push(const AVPacket *packet);
void peekFrame(std::function<void(int width, int height, uint8_t* dataRGB32)> onFrame);
signals:
void updateFPS(quint32 fps);
private slots:
void onNewFrame();
signals:
void newFrame();
private:
void pushFrame();
private:
VideoBuffer *m_vb = Q_NULLPTR;
AVCodecContext *m_codecCtx = Q_NULLPTR;
bool m_isCodecCtxOpen = false;
std::function<void(int, int, uint8_t*, uint8_t*, uint8_t*, int, int, int)> m_onFrame = Q_NULLPTR;
};
#endif // DECODER_H
| 22.093023 | 186 | 0.698947 |
d76ff88ade603ad9dbb336a91f3ab52680059c4f | 2,586 | h | C | stdlib/network/net_interfaces.h | colding/MercuryFIX | 435b77e546d7764dc8c40bc41900e5bf852fa72d | [
"BSD-3-Clause"
] | 1 | 2017-10-06T16:56:58.000Z | 2017-10-06T16:56:58.000Z | stdlib/network/net_interfaces.h | colding/MercuryFIX | 435b77e546d7764dc8c40bc41900e5bf852fa72d | [
"BSD-3-Clause"
] | null | null | null | stdlib/network/net_interfaces.h | colding/MercuryFIX | 435b77e546d7764dc8c40bc41900e5bf852fa72d | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (C) 2013, Jules Colding <jcolding@gmail.com>.
*
* All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* (1) Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of
* its contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#pragma once
#ifdef HAVE_CONFIG_H
#include "ac_config.h"
#endif
#include "stdlib/network/net_types.h"
/*
* Will try to deduce the first assigned IP address on the specified
* NIC.
*/
extern char*
get_ip_from_ifname(const int inet_family,
const char * const ifname);
/*
* Will open and initialize a socket. Returns socket on success, -1
* otherwise.
*/
extern int
create_listening_socket(const char * const interface,
const uint16_t port,
const int pf_family,
const int socket_type,
const bool keep_alive);
/*
* Will return a connected socket to host:port or (sock ==
* -1) in case of error.
*/
extern int
connect_to_listening_socket(const char * const interface,
const uint16_t port,
const int pf_family,
const int socket_type,
const timeout_t timeout);
| 34.026316 | 70 | 0.689869 |
bf1393d32845b3daf3dd02e49cd2e08902718822 | 1,715 | h | C | rotate_align/rotate_align.h | Eberty/LowCost3DReconstruction | 2d2f2247385ade510f04163ca12287640b7a5cf5 | [
"MIT"
] | 13 | 2020-07-25T16:47:22.000Z | 2022-03-31T18:54:06.000Z | rotate_align/rotate_align.h | pathi/LowCost3DReconstruction | 78e26468c5a5fefa13711f7ba86a0e4a5a34901c | [
"MIT"
] | 1 | 2020-03-23T13:59:44.000Z | 2020-03-23T13:59:44.000Z | rotate_align/rotate_align.h | pathi/LowCost3DReconstruction | 78e26468c5a5fefa13711f7ba86a0e4a5a34901c | [
"MIT"
] | 2 | 2020-10-11T12:29:26.000Z | 2021-01-25T18:32:40.000Z | /*
* Copyright (c) 2019, Eberty Alves
*/
#ifndef ROTATE_ALIGN_H_
#define ROTATE_ALIGN_H_
// C++ standard library
#include <bits/stdc++.h>
// Qt
#include <QMainWindow>
// Point Cloud Library
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>
// Visualization Toolkit (VTK)
#include <vtkRenderWindow.h>
// UI file
#include "ui_rotate_align.h"
// Typedef to short code
typedef pcl::PointXYZRGBNormal PointT;
typedef pcl::PointCloud<PointT> PointC;
typedef pcl::visualization::PointCloudColorHandlerRGBField<PointT> PointCloudColorHandler;
class RotateAlign : public QMainWindow {
Q_OBJECT
public:
RotateAlign(int argc, char *argv[], QWidget *parent = 0);
~RotateAlign();
bool userInterface();
public Q_SLOTS:
void saveFiles();
void distanceXSliderValueChanged(int value);
void distanceYSliderValueChanged(int value);
void distanceZSliderValueChanged(int value);
protected:
pcl::visualization::PCLVisualizer::Ptr viewer;
std::vector<PointC::Ptr> point_clouds;
std::vector<PointC::Ptr> transformed_point_clouds;
private:
bool parserProgramOptions(int argc, char *argv[]);
void performOperationWithoutGui();
void printAttributes();
void readPointClouds();
void updatePointClouds();
void transformPointCloud(size_t index);
void addPointCloudToViewer(std::string point_cloud_name, int index);
// Declaration of variables
bool user_interface;
bool b_accumulated_file;
std::string accumulated_file_name;
std::string capture_name;
uint capture_step;
uint num_captures;
double distance_x;
double distance_y;
double distance_z;
// Interface
Ui::RotateAlign *ui;
};
#endif // ROTATE_ALIGN_H_
| 22.565789 | 90 | 0.756851 |
0fbc06077f2122565cabc6cba22930bdb98fa25f | 329 | h | C | include/common/binary_file.h | allie/superdendy | 156e1a78750578b465ed7720e09dd6199fc6f15f | [
"MIT"
] | null | null | null | include/common/binary_file.h | allie/superdendy | 156e1a78750578b465ed7720e09dd6199fc6f15f | [
"MIT"
] | null | null | null | include/common/binary_file.h | allie/superdendy | 156e1a78750578b465ed7720e09dd6199fc6f15f | [
"MIT"
] | null | null | null | #pragma once
#include "common/data.h"
#include <string>
#include <vector>
#include <time.h>
namespace SuperDendy {
class BinaryFile {
private:
long int size;
std::string path;
public:
BinaryFile(const char* file);
~BinaryFile();
long int get_size();
std::string get_path();
std::vector<Byte> buffer;
};
};
| 13.708333 | 31 | 0.671733 |
8431d144bf64d11feddc435908d7141278ccbb48 | 330 | h | C | components/network/ble/blecontroller/ip/ble/ll/src/lld/lld_pdu.h | shyba/bl602-re | bf242368cbcfc1391eb37a4542b76440202a8d5f | [
"Apache-2.0"
] | 1 | 2021-01-05T03:41:42.000Z | 2021-01-05T03:41:42.000Z | components/network/ble/blecontroller/ip/ble/ll/src/lld/lld_pdu.h | shyba/bl602-re | bf242368cbcfc1391eb37a4542b76440202a8d5f | [
"Apache-2.0"
] | null | null | null | components/network/ble/blecontroller/ip/ble/ll/src/lld/lld_pdu.h | shyba/bl602-re | bf242368cbcfc1391eb37a4542b76440202a8d5f | [
"Apache-2.0"
] | null | null | null | /**
* @file lld_pdu.h
* Header file for BL602
*/
#ifndef __LLD_PDU_H__
#define __LLD_PDU_H__
struct lld_pdu_data_tx_tag {
struct co_list_hdr hdr; // +0
uint16_t idx; // +4
uint16_t conhdl; // +6
uint16_t length; // +8
uint8_t pb_bc_flag; // +10
struct em_buf_node *buf; // +12
};
#endif // __LLD_PDU_H__
| 18.333333 | 35 | 0.651515 |
b917c12c7c61cec721bf9b910fb33bc848d63946 | 753 | h | C | APPS/iperf-1.7.0/confdefs.h | shkir/sctp-refimpl | 76d37a9a01919b1ba43eaa8b18229ff49c70a8f7 | [
"BSD-2-Clause"
] | 8 | 2015-07-20T19:33:58.000Z | 2019-10-27T10:02:23.000Z | APPS/iperf-1.7.0/confdefs.h | shkir/sctp-refimpl | 76d37a9a01919b1ba43eaa8b18229ff49c70a8f7 | [
"BSD-2-Clause"
] | 2 | 2015-07-19T13:27:57.000Z | 2015-07-22T10:46:12.000Z | APPS/iperf-1.7.0/confdefs.h | shkir/sctp-refimpl | 76d37a9a01919b1ba43eaa8b18229ff49c70a8f7 | [
"BSD-2-Clause"
] | 6 | 2015-07-19T12:20:24.000Z | 2019-11-30T23:56:41.000Z |
#define HAVE_LIBPTHREAD 1
#define HAVE_POSIX_THREAD 1
#define _REENTRANT 1
#define HAVE_STRINGS_H 1
#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_UNSIGNED_SHORT 2
#define SIZEOF_UNSIGNED_INT 4
#define SIZEOF_UNSIGNED_LONG 4
#define SIZEOF_UNSIGNED_LONG_LONG 8
#define int16_t short
#define int32_t int
#define int64_t long long
#define u_int16_t unsigned short
#define u_int32_t unsigned int
#define u_int64_t unsigned long long
#define IP_TOS_TYPE char
#define Socklen_t int
#define size_t unsigned int
#define ssize_t int
#define HAVE_SNPRINTF 1
#define HAVE_INET_PTON 1
#define HAVE_INET_NTOP 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_PTHREAD_CANCEL 1
#define HAVE_USLEEP 1
| 17.928571 | 36 | 0.826029 |
02be57c02fbe4be4263305a333039e508f5a9ed2 | 347 | h | C | ben.h | thisguyistotallyben/ben | 6b79e79048b97d8a0dcec175fd271323a10ab9a7 | [
"MIT"
] | null | null | null | ben.h | thisguyistotallyben/ben | 6b79e79048b97d8a0dcec175fd271323a10ab9a7 | [
"MIT"
] | 1 | 2019-07-19T03:47:32.000Z | 2019-08-02T05:08:21.000Z | ben.h | thisguyistotallyben/ben | 6b79e79048b97d8a0dcec175fd271323a10ab9a7 | [
"MIT"
] | null | null | null | #pragma once
#include <queue>
#include <map>
#include "ben_common.h"
#include "ben_server.h"
class Ben {
public:
void start();
void stop();
BenWidget* createWidget(std::string lookup, BenWidgetType, int sizex, int sizey, int posx, int posy);
BenWidget* widget(std::string lookup);
void hideCursor();
int maxHeight();
int maxWidth();
}; | 17.35 | 102 | 0.706052 |
f324bab013c15d47d1fa393f50640fe0e9cb348b | 1,669 | h | C | security/tee/csky/ck802t/src/tw/drv/crypto/trng/csky_ch2201/trng.h | ruoranluomu/AliOS-Things | d0f3431bcacac5b61645e9beb231a0a53be8078b | [
"Apache-2.0"
] | 6 | 2019-06-24T08:30:42.000Z | 2021-12-26T21:15:27.000Z | security/tee/csky/ck802t/src/tw/drv/crypto/trng/csky_ch2201/trng.h | ewfweftwer/AliOS-Things | 26a5c1a2d6b1771590f5d302f0b2e7fe2fcf843e | [
"Apache-2.0"
] | 1 | 2019-04-02T10:03:10.000Z | 2019-04-02T10:03:10.000Z | security/tee/csky/ck802t/src/tw/drv/crypto/trng/csky_ch2201/trng.h | ewfweftwer/AliOS-Things | 26a5c1a2d6b1771590f5d302f0b2e7fe2fcf843e | [
"Apache-2.0"
] | 9 | 2019-07-12T02:50:10.000Z | 2021-08-20T17:24:36.000Z | /* ****************************************************************************
* *
* C-Sky Microsystems Confidential *
* ------------------------------- *
* This file and all its contents are properties of C-Sky Microsystems. The *
* information contained herein is confidential and proprietary and is not *
* to be disclosed outside of C-Sky Microsystems except under a *
* Non-Disclosured Agreement (NDA). *
* *
****************************************************************************/
/**
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
**/
#ifndef TRNG_H
#define TRNG_H
#include "tee_types.h"
#define TRNG_BASEADDR 0x40009000
#define TRNG_TCR 0x0
#define TRNG_TDR 0x4
#define TRNG_EN 2
#define TRNG_LOWPER_MODE 4
static inline void trng_enable(void)
{
*(volatile uint32_t *)(TRNG_BASEADDR + TRNG_TCR) |= TRNG_EN;
}
static inline void trng_disable(void)
{
*(volatile uint32_t *)(TRNG_BASEADDR + TRNG_TCR) &= ~TRNG_EN;
}
static inline void trng_lowpermode_enable(void)
{
*(volatile uint32_t *)(TRNG_BASEADDR + TRNG_TCR) |= TRNG_LOWPER_MODE;
}
static inline void trng_lowpermode_disable(void)
{
*(volatile uint32_t *)(TRNG_BASEADDR + TRNG_TCR) &= ~TRNG_LOWPER_MODE;
}
static inline uint32_t trng_data_ready_status(void)
{
return (*(volatile uint32_t *)(TRNG_BASEADDR + TRNG_TCR) & 0x1);
}
int32_t trng_random_get(void *arg);
#endif
| 30.345455 | 79 | 0.526064 |
7e79622073f1b120a217794e5ccefb6ea807080c | 39,469 | h | C | usr/src/lib/libpthread/uthread/pthread_private.h | sizeofvoid/ifconfigd | bdff4b2cec6d572c1450cb44f32c0bdab1b49e5f | [
"BSD-2-Clause"
] | 2 | 2020-04-15T13:39:01.000Z | 2020-08-28T01:27:00.000Z | usr/src/lib/libpthread/uthread/pthread_private.h | sizeofvoid/ifconfigd | bdff4b2cec6d572c1450cb44f32c0bdab1b49e5f | [
"BSD-2-Clause"
] | null | null | null | usr/src/lib/libpthread/uthread/pthread_private.h | sizeofvoid/ifconfigd | bdff4b2cec6d572c1450cb44f32c0bdab1b49e5f | [
"BSD-2-Clause"
] | 1 | 2020-08-28T01:25:41.000Z | 2020-08-28T01:25:41.000Z | /* $OpenBSD: pthread_private.h,v 1.76 2010/10/28 15:02:41 millert Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by John Birrell.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Private thread definitions for the uthread kernel.
*
* $FreeBSD: pthread_private.h,v 1.27 1999/09/29 15:18:38 marcel Exp $
*/
#ifndef _PTHREAD_PRIVATE_H
#define _PTHREAD_PRIVATE_H
/*
* Evaluate the storage class specifier.
*/
#ifdef GLOBAL_PTHREAD_PRIVATE
#define SCLASS
#else
#define SCLASS extern
#endif
/*
* Include files.
*/
#include <signal.h>
#include <stdio.h>
#include <sys/poll.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sched.h>
#include <spinlock.h>
#include <pthread_np.h>
#include "thread_private.h"
#include "uthread_machdep.h"
/*
* Kernel fatal error handler macro.
*/
#define PANIC(string) _thread_exit(__FILE__,__LINE__,string)
/* Output debug messages like this: */
#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x));
#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x));
/*
* Priority queue manipulation macros (using pqe link):
*/
#define PTHREAD_PRIOQ_INSERT_HEAD(thrd) _pq_insert_head(&_readyq,thrd)
#define PTHREAD_PRIOQ_INSERT_TAIL(thrd) _pq_insert_tail(&_readyq,thrd)
#define PTHREAD_PRIOQ_REMOVE(thrd) _pq_remove(&_readyq,thrd)
#define PTHREAD_PRIOQ_FIRST() _pq_first(&_readyq)
/*
* Waiting queue manipulation macros (using pqe link):
*/
#define PTHREAD_WAITQ_REMOVE(thrd) _waitq_remove(thrd)
#define PTHREAD_WAITQ_INSERT(thrd) _waitq_insert(thrd)
#if defined(_PTHREADS_INVARIANTS)
#define PTHREAD_WAITQ_CLEARACTIVE() _waitq_clearactive()
#define PTHREAD_WAITQ_SETACTIVE() _waitq_setactive()
#else
#define PTHREAD_WAITQ_CLEARACTIVE()
#define PTHREAD_WAITQ_SETACTIVE()
#endif
/*
* Work queue manipulation macros (using qe link):
*/
#define PTHREAD_WORKQ_INSERT(thrd) do { \
TAILQ_INSERT_TAIL(&_workq,thrd,qe); \
(thrd)->flags |= PTHREAD_FLAGS_IN_WORKQ; \
} while (0)
#define PTHREAD_WORKQ_REMOVE(thrd) do { \
TAILQ_REMOVE(&_workq,thrd,qe); \
(thrd)->flags &= ~PTHREAD_FLAGS_IN_WORKQ; \
} while (0)
/*
* State change macro without scheduling queue change:
*/
#define PTHREAD_SET_STATE(thrd, newstate) do { \
(thrd)->state = newstate; \
(thrd)->fname = __FILE__; \
(thrd)->lineno = __LINE__; \
} while (0)
/*
* State change macro with scheduling queue change - This must be
* called with preemption deferred (see thread_kern_sched_[un]defer).
*/
#if defined(_PTHREADS_INVARIANTS)
#include <assert.h>
#define PTHREAD_ASSERT(cond, msg) do { \
if (!(cond)) \
PANIC(msg); \
} while (0)
#define PTHREAD_ASSERT_NOT_IN_SYNCQ(thrd) \
PTHREAD_ASSERT((((thrd)->flags & PTHREAD_FLAGS_IN_SYNCQ) == 0), \
"Illegal call from signal handler");
#define PTHREAD_NEW_STATE(thrd, newstate) do { \
if (_thread_kern_new_state != 0) \
PANIC("Recursive PTHREAD_NEW_STATE"); \
_thread_kern_new_state = 1; \
if ((thrd)->state != newstate) { \
if ((thrd)->state == PS_RUNNING) { \
PTHREAD_PRIOQ_REMOVE(thrd); \
PTHREAD_WAITQ_INSERT(thrd); \
} else if (newstate == PS_RUNNING) { \
PTHREAD_WAITQ_REMOVE(thrd); \
PTHREAD_PRIOQ_INSERT_TAIL(thrd); \
} \
} \
_thread_kern_new_state = 0; \
PTHREAD_SET_STATE(thrd, newstate); \
} while (0)
#else
#define PTHREAD_ASSERT(cond, msg)
#define PTHREAD_ASSERT_NOT_IN_SYNCQ(thrd)
#define PTHREAD_NEW_STATE(thrd, newstate) do { \
if ((thrd)->state != newstate) { \
if ((thrd)->state == PS_RUNNING) { \
PTHREAD_PRIOQ_REMOVE(thrd); \
PTHREAD_WAITQ_INSERT(thrd); \
} else if (newstate == PS_RUNNING) { \
PTHREAD_WAITQ_REMOVE(thrd); \
PTHREAD_PRIOQ_INSERT_TAIL(thrd); \
} \
} \
PTHREAD_SET_STATE(thrd, newstate); \
} while (0)
#endif
/*
* Define the signals to be used for scheduling.
*/
#if defined(_PTHREADS_COMPAT_SCHED) || defined(PROF)
#define _ITIMER_SCHED_TIMER ITIMER_VIRTUAL
#define _SCHED_SIGNAL SIGVTALRM
#else
#define _ITIMER_SCHED_TIMER ITIMER_PROF
#define _SCHED_SIGNAL SIGPROF
#endif
/* Lists with volatile elements */
#define V_TAILQ_HEAD(name, type) \
volatile struct name { \
struct type * tqh_first; \
struct type * volatile * tqh_last; \
}
#define V_TAILQ_ENTRY(type) \
volatile struct { \
struct type * tqe_next; \
struct type * volatile * tqe_prev; \
}
/* List of all threads: */
typedef V_TAILQ_HEAD(, pthread) _thread_list_t;
/*
* Priority queues.
*
* XXX It'd be nice if these were contained in uthread_priority_queue.[ch].
*/
typedef struct pq_list {
_thread_list_t pl_head; /* list of threads at this priority */
TAILQ_ENTRY(pq_list) pl_link; /* link for queue of priority lists */
int pl_prio; /* the priority of this list */
int pl_queued; /* is this in the priority queue */
} pq_list_t;
typedef struct pq_queue {
TAILQ_HEAD(, pq_list) pq_queue; /* queue of priority lists */
pq_list_t *pq_lists; /* array of all priority lists */
int pq_size; /* number of priority lists */
} pq_queue_t;
/*
* TailQ initialization values.
*/
#define TAILQ_INITIALIZER { NULL, NULL }
/*
* Mutex definitions.
*/
union pthread_mutex_data {
void *m_ptr;
int m_count;
};
struct pthread_mutex {
enum pthread_mutextype m_type;
int m_protocol;
V_TAILQ_HEAD(mutex_head, pthread) m_queue;
struct pthread *m_owner;
union pthread_mutex_data m_data;
long m_flags;
int m_refcount;
/*
* Used for priority inheritence and protection.
*
* m_prio - For priority inheritence, the highest active
* priority (threads locking the mutex inherit
* this priority). For priority protection, the
* ceiling priority of this mutex.
* m_saved_prio - mutex owners inherited priority before
* taking the mutex, restored when the owner
* unlocks the mutex.
*/
int m_prio;
int m_saved_prio;
/*
* Link for list of all mutexes a thread currently owns.
*/
V_TAILQ_ENTRY(pthread_mutex volatile) m_qe;
/*
* Lock for accesses to this structure.
*/
spinlock_t lock;
};
/*
* Flags for mutexes.
*/
#define MUTEX_FLAGS_PRIVATE 0x01
#define MUTEX_FLAGS_INITED 0x02
#define MUTEX_FLAGS_BUSY 0x04
/*
* Static mutex initialization values.
*/
#define PTHREAD_MUTEX_STATIC_INITIALIZER \
{ PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \
NULL, { NULL }, MUTEX_FLAGS_PRIVATE, 0, 0, 0, TAILQ_INITIALIZER, \
_SPINLOCK_INITIALIZER }
struct pthread_mutex_attr {
enum pthread_mutextype m_type;
int m_protocol;
int m_ceiling;
long m_flags;
};
#define PTHREAD_MUTEXATTR_STATIC_INITIALIZER \
{ PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, MUTEX_FLAGS_PRIVATE }
/*
* Condition variable definitions.
*/
enum pthread_cond_type {
COND_TYPE_FAST,
COND_TYPE_MAX
};
struct pthread_cond {
enum pthread_cond_type c_type;
V_TAILQ_HEAD(cond_head, pthread) c_queue;
pthread_mutex_t c_mutex;
long c_flags;
int c_seqno;
/*
* Lock for accesses to this structure.
*/
spinlock_t lock;
};
struct pthread_cond_attr {
enum pthread_cond_type c_type;
long c_flags;
};
/*
* Flags for condition variables.
*/
#define COND_FLAGS_PRIVATE 0x01
#define COND_FLAGS_INITED 0x02
#define COND_FLAGS_BUSY 0x04
/*
* Static cond initialization values.
*/
#define PTHREAD_COND_STATIC_INITIALIZER \
{ COND_TYPE_FAST, TAILQ_INITIALIZER, NULL, NULL, \
0, 0, _SPINLOCK_INITIALIZER }
/*
* Semaphore definitions.
*/
struct sem {
#define SEM_MAGIC ((u_int32_t) 0x09fa4012)
u_int32_t magic;
pthread_mutex_t lock;
pthread_cond_t gtzero;
u_int32_t count;
u_int32_t nwaiters;
};
/*
* Cleanup definitions.
*/
struct pthread_cleanup {
struct pthread_cleanup *next;
void (*routine)(void*);
void *routine_arg;
};
struct pthread_atfork {
TAILQ_ENTRY(pthread_atfork) qe;
void (*prepare)(void);
void (*parent)(void);
void (*child)(void);
};
struct pthread_attr {
int sched_policy;
int sched_inherit;
int sched_interval;
int prio;
int suspend;
int flags;
void *arg_attr;
void (*cleanup_attr)(void*);
void *stackaddr_attr;
size_t stacksize_attr;
size_t guardsize_attr;
};
/*
* Thread creation state attributes.
*/
#define PTHREAD_CREATE_RUNNING 0
#define PTHREAD_CREATE_SUSPENDED 1
/*
* Additional state for a thread suspended with pthread_suspend_np().
*/
enum pthread_susp {
SUSP_NO, /* Not suspended. */
SUSP_YES, /* Suspended. */
SUSP_JOIN, /* Suspended, joining. */
SUSP_NOWAIT, /* Suspended, was in a mutex or condition queue. */
SUSP_MUTEX_WAIT,/* Suspended, still in a mutex queue. */
SUSP_COND_WAIT /* Suspended, still in a condition queue. */
};
/*
* Miscellaneous definitions.
*/
#ifdef __LP64__
#define PTHREAD_STACK_DEFAULT (512 * 1024)
#else
#define PTHREAD_STACK_DEFAULT (256 * 1024)
#endif
/*
* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since many applications are likely to run
* almost entirely on this stack.
*/
#define PTHREAD_STACK_INITIAL 0x100000
/*
* Define the different priority ranges. All applications have thread
* priorities constrained within 0-31. The threads library raises the
* priority when delivering signals in order to ensure that signal
* delivery happens (from the POSIX spec) "as soon as possible".
* In the future, the threads library will also be able to map specific
* threads into real-time (cooperating) processes or kernel threads.
* The RT and SIGNAL priorities will be used internally and added to
* thread base priorities so that the scheduling queue can handle both
* normal and RT priority threads with and without signal handling.
*
* The approach taken is that, within each class, signal delivery
* always has priority over thread execution.
*/
#define PTHREAD_DEFAULT_PRIORITY 15
#define PTHREAD_MIN_PRIORITY 0
#define PTHREAD_MAX_PRIORITY 31 /* 0x1F */
#define PTHREAD_SIGNAL_PRIORITY 32 /* 0x20 */
#define PTHREAD_RT_PRIORITY 64 /* 0x40 */
#define PTHREAD_FIRST_PRIORITY PTHREAD_MIN_PRIORITY
#define PTHREAD_LAST_PRIORITY \
(PTHREAD_MAX_PRIORITY + PTHREAD_SIGNAL_PRIORITY + PTHREAD_RT_PRIORITY)
#define PTHREAD_BASE_PRIORITY(prio) ((prio) & PTHREAD_MAX_PRIORITY)
/*
* Clock resolution in microseconds.
*/
#define CLOCK_RES_USEC 10000
#define CLOCK_RES_USEC_MIN 1000
/*
* Time slice period in microseconds.
*/
#define TIMESLICE_USEC 20000
/*
* Define a thread-safe macro to get the current time of day
* which is updated at regular intervals by the scheduling signal
* handler.
*/
#define GET_CURRENT_TOD(tv) \
do { \
tv.tv_sec = _sched_tod.tv_sec; \
tv.tv_usec = _sched_tod.tv_usec; \
} while (tv.tv_sec != _sched_tod.tv_sec)
struct pthread_key {
spinlock_t lock;
volatile int allocated;
volatile int count;
void (*destructor)(void*);
};
struct pthread_rwlockattr {
int pshared;
};
struct pthread_rwlock {
pthread_mutex_t lock; /* monitor lock */
int state; /* 0 = idle >0 = # of readers -1 = writer */
pthread_cond_t read_signal;
pthread_cond_t write_signal;
int blocked_writers;
};
/*
* Thread states.
*/
enum pthread_state {
PS_RUNNING,
PS_SIGTHREAD,
PS_MUTEX_WAIT,
PS_COND_WAIT,
PS_FDLR_WAIT,
PS_FDLW_WAIT,
PS_FDR_WAIT,
PS_FDW_WAIT,
PS_FILE_WAIT,
PS_POLL_WAIT,
PS_SELECT_WAIT,
PS_SLEEP_WAIT,
PS_WAIT_WAIT,
PS_SIGSUSPEND,
PS_SIGWAIT,
PS_SPINBLOCK,
PS_JOIN,
PS_SUSPENDED,
PS_DEAD,
PS_DEADLOCK,
PS_STATE_MAX
};
/*
* File descriptor locking definitions.
*/
#define FD_READ 0x1
#define FD_WRITE 0x2
#define FD_RDWR (FD_READ | FD_WRITE)
#define FD_RDWR_CLOSE (FD_RDWR | 0x4)
#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock(_fd, _type, _ts)
#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock(_fd, _type)
/* Get a suitable argument for _thread_kern_set_timeout(), given an fd */
#define _FD_RCVTIMEO(_fd) _thread_fd_timeout((_fd), 0)
#define _FD_SNDTIMEO(_fd) _thread_fd_timeout((_fd), 1)
/*
* File status flags structure - shared for dup'ed fd's
*/
struct fs_flags {
int flags;
#define _FD_NOTSOCK O_EXCL /* Not a socket. */
int refcnt;
SLIST_ENTRY(fs_flags) fe; /* free list entry. */
};
/*
* fd_table_entry states
*/
enum fd_entry_state {
FD_ENTRY_OPEN,
FD_ENTRY_CLOSING,
FD_ENTRY_CLOSED
};
/*
* Defines for _thread_fd_table_init init_mode
*/
enum fd_entry_mode {
FD_INIT_UNKNOWN, /* inherited or not created by pthreads wrapper */
FD_INIT_NEW, /* new fd opened by pthreads */
FD_INIT_BLOCKING, /* new user blocking fd opened by pthreads */
FD_INIT_DUP, /* new fd with passed flags */
FD_INIT_DUP2, /* replace status_flags and open */
};
/*
* File descriptor table structure.
*/
struct fd_table_entry {
_thread_list_t r_queue; /* Read queue. */
_thread_list_t w_queue; /* Write queue. */
struct pthread *r_owner; /* thread owning read lock. */
struct pthread *w_owner; /* thread owning write lock. */
const char *r_fname; /* read lock source file name */
int r_lineno; /* Read lock source line no. */
const char *w_fname; /* write lock src file name */
int w_lineno; /* Write lock src line no. */
int r_lockcount; /* Count for FILE read locks. */
int w_lockcount; /* Count for FILE write locks.*/
struct fs_flags *status_flags; /* Shared file status flags. */
enum fd_entry_state state; /* Open, closing, or closed. */
enum fd_entry_mode init_mode; /* The mode used for init. */
SLIST_ENTRY(fd_table_entry) fe; /* Free list entry. */
};
struct pthread_poll_data {
nfds_t nfds;
struct pollfd *fds;
};
union pthread_wait_data {
pthread_mutex_t mutex;
pthread_cond_t cond;
const sigset_t *sigwait; /* Waiting on a signal in sigwait */
struct {
int fd; /* Used when thread waiting on fd */
int branch; /* Line number, for debugging. */
const char *fname; /* Source file name for debugging.*/
} fd;
FILE *fp;
struct pthread_poll_data *poll_data;
spinlock_t *spinlock;
struct pthread *thread;
};
/* Spare thread stack. */
struct stack {
SLIST_ENTRY(stack) qe; /* Queue entry for this stack. */
void *base; /* Bottom of useful stack */
size_t size; /* Size of useful stack */
size_t guardsize; /* Size of red zone */
void *redzone; /* Red zone location */
void *storage; /* allocated storage */
};
/*
* Define a continuation routine that can be used to perform a
* transfer of control:
*/
typedef void (*thread_continuation_t) (struct pthread *);
typedef V_TAILQ_ENTRY(pthread) pthread_entry_t;
struct join_status {
struct pthread *thread;
void *ret;
int error;
};
/*
* Thread structure.
*/
struct pthread {
/*
* Magic value to help recognize a valid thread structure
* from an invalid one:
*/
#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
u_int32_t magic;
char *name;
/*
* Lock for accesses to this thread structure.
*/
spinlock_t lock;
/* Queue entry for list of all threads: */
pthread_entry_t tle;
/* Queue entry for list of dead threads: */
pthread_entry_t dle;
/*
* Thread start routine, argument, stack pointer and thread
* attributes.
*/
void *(*start_routine)(void *);
void *arg;
struct stack *stack;
struct pthread_attr attr;
/*
* Saved signal context used in call to sigreturn by
* _thread_kern_sched if sig_saved is TRUE.
*/
struct sigcontext saved_sigcontext;
/*
* Machine-dependent context, valid if sig_saved is FALSE.
*/
struct _machdep_state _machdep;
/*
* TRUE if the last state saved was a signal context. FALSE if the
* last state saved was a jump buffer.
*/
int sig_saved;
/*
* Cancelability flags - the lower 2 bits are used by cancel
* definitions in pthread.h
*/
#define PTHREAD_AT_CANCEL_POINT 0x0004
#define PTHREAD_CANCELLING 0x0008
#define PTHREAD_CANCEL_NEEDED 0x0010
int cancelflags;
enum pthread_susp suspended;
thread_continuation_t continuation;
/*
* Current signal mask and pending signals.
*/
sigset_t sigmask;
sigset_t sigpend;
/* Thread state: */
enum pthread_state state;
/* Scheduling clock when this thread was last made active. */
long last_active;
/* Scheduling clock when this thread was last made inactive. */
long last_inactive;
/*
* Number of microseconds accumulated by this thread when
* time slicing is active.
*/
long slice_usec;
/*
* Time to wake up thread. This is used for sleeping threads and
* for any operation which may time out (such as select).
*/
struct timespec wakeup_time;
/* TRUE if operation has timed out. */
int timeout;
/*
* Error variable used instead of errno. The function __error()
* returns a pointer to this.
*/
int error;
/*
* The joiner is the thread that is joining to this thread. The
* join status keeps track of a join operation to another thread.
*/
struct pthread *joiner;
struct join_status join_status;
/*
* The current thread can belong to only one scheduling queue at
* a time (ready or waiting queue). It can also belong to:
*
* o A queue of threads waiting for a mutex
* o A queue of threads waiting for a condition variable
* o A queue of threads waiting for a file descriptor lock
* o A queue of threads needing work done by the kernel thread
* (waiting for a spinlock or file I/O)
*
* A thread can also be joining a thread (the joiner field above).
*
* It must not be possible for a thread to belong to any of the
* above queues while it is handling a signal. Signal handlers
* may longjmp back to previous stack frames circumventing normal
* control flow. This could corrupt queue integrity if the thread
* retains membership in the queue. Therefore, if a thread is a
* member of one of these queues when a signal handler is invoked,
* it must remove itself from the queue before calling the signal
* handler and reinsert itself after normal return of the handler.
*
* Use pqe for the scheduling queue link (both ready and waiting),
* sqe for synchronization (mutex and condition variable) queue
* links, and qe for all other links.
*/
pthread_entry_t pqe; /* priority queue link */
pthread_entry_t sqe; /* synchronization queue link */
pthread_entry_t qe; /* all other queues link */
/* Wait data. */
union pthread_wait_data data;
/*
* Allocated for converting select into poll.
*/
struct pthread_poll_data poll_data;
/*
* Set to TRUE if a blocking operation was
* interrupted by a signal:
*/
int interrupted;
/*
* Set to TRUE if a blocking operation was
* interrupted by a closing file descriptor.
*/
int closing_fd;
/* Signal number when in state PS_SIGWAIT: */
int signo;
/*
* Set to non-zero when this thread has deferred signals.
* We allow for recursive deferral.
*/
int sig_defer_count;
/*
* Set to TRUE if this thread should yield after undeferring
* signals.
*/
int yield_on_sig_undefer;
/* Miscellaneous flags; only set with signals deferred. */
int flags;
#define PTHREAD_FLAGS_PRIVATE 0x0001
#define PTHREAD_EXITING 0x0002
#define PTHREAD_FLAGS_IN_WAITQ 0x0004 /* in waiting queue using pqe link */
#define PTHREAD_FLAGS_IN_PRIOQ 0x0008 /* in priority queue using pqe link */
#define PTHREAD_FLAGS_IN_WORKQ 0x0010 /* in work queue using qe link */
#define PTHREAD_FLAGS_IN_FILEQ 0x0020 /* in file lock queue using qe link */
#define PTHREAD_FLAGS_IN_FDQ 0x0040 /* in fd lock queue using qe link */
#define PTHREAD_FLAGS_IN_CONDQ 0x0080 /* in condition queue using sqe link */
#define PTHREAD_FLAGS_IN_MUTEXQ 0x0100 /* in mutex queue using sqe link */
#define PTHREAD_FLAGS_TRACE 0x0200 /* for debugging purposes */
#define PTHREAD_FLAGS_IN_SYNCQ \
(PTHREAD_FLAGS_IN_CONDQ | PTHREAD_FLAGS_IN_MUTEXQ)
/*
* Base priority is the user setable and retrievable priority
* of the thread. It is only affected by explicit calls to
* set thread priority and upon thread creation via a thread
* attribute or default priority.
*/
int base_priority;
/*
* Inherited priority is the priority a thread inherits by
* taking a priority inheritence or protection mutex. It
* is not affected by base priority changes. Inherited
* priority defaults to and remains 0 until a mutex is taken
* that is being waited on by any other thread whose priority
* is non-zero.
*/
int inherited_priority;
/*
* Active priority is always the maximum of the threads base
* priority and inherited priority. When there is a change
* in either the base or inherited priority, the active
* priority must be recalculated.
*/
int active_priority;
/* Number of priority ceiling or protection mutexes owned. */
int priority_mutex_count;
/* Number rwlocks rdlocks held. */
int rdlock_count;
/*
* Queue of currently owned mutexes.
*/
V_TAILQ_HEAD(, pthread_mutex volatile) mutexq;
void *ret;
const void **specific_data;
int specific_data_count;
/* Cleanup handlers Link List */
struct pthread_cleanup *cleanup;
const char *fname; /* Ptr to source file name */
int lineno; /* Source line number. */
};
/*
* Flags and prototypes for the machine dependent layer
*/
void _thread_machdep_switch(struct _machdep_state *newstate,
struct _machdep_state *savestate);
void _thread_machdep_init(struct _machdep_state *state, void *stackbase,
int stacksize, void (*entry)(void));
void _thread_machdep_save_float_state(struct _machdep_state* statep);
void _thread_machdep_restore_float_state(struct _machdep_state* statep);
/*
* Global variables for the uthread kernel.
*/
/* Kernel thread structure used when there are no running threads: */
SCLASS struct pthread _thread_kern_thread;
/* Ptr to the thread structure for the running thread: */
SCLASS struct pthread * volatile _thread_run
#ifdef GLOBAL_PTHREAD_PRIVATE
= &_thread_kern_thread;
#else
;
#endif
/* Ptr to the thread structure for the last user thread to run: */
SCLASS struct pthread * volatile _last_user_thread
#ifdef GLOBAL_PTHREAD_PRIVATE
= &_thread_kern_thread;
#else
;
#endif
/*
* Ptr to the thread running in single-threaded mode or NULL if
* running multi-threaded (default POSIX behaviour).
*/
SCLASS struct pthread * volatile _thread_single
#ifdef GLOBAL_PTHREAD_PRIVATE
= NULL;
#else
;
#endif
SCLASS _thread_list_t _thread_list
#ifdef GLOBAL_PTHREAD_PRIVATE
= TAILQ_HEAD_INITIALIZER(_thread_list);
#else
;
#endif
/*
* Array of kernel pipe file descriptors that are used to ensure that
* no signals are missed in calls to _select.
*/
SCLASS int _thread_kern_pipe[2]
#ifdef GLOBAL_PTHREAD_PRIVATE
= {
-1,
-1
};
#else
;
#endif
SCLASS int volatile _queue_signals
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
SCLASS int volatile _thread_kern_in_sched
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
SCLASS int _sig_in_handler
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
/* Time of day at last scheduling timer signal: */
SCLASS struct timeval volatile _sched_tod
#ifdef GLOBAL_PTHREAD_PRIVATE
= { 0, 0 };
#else
;
#endif
/*
* Current scheduling timer ticks; used as resource usage.
*/
SCLASS unsigned int volatile _sched_ticks
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
/* Dead threads: */
SCLASS _thread_list_t _dead_list
#ifdef GLOBAL_PTHREAD_PRIVATE
= TAILQ_HEAD_INITIALIZER(_dead_list);
#else
;
#endif
/* Initial thread: */
SCLASS struct pthread *_thread_initial
#ifdef GLOBAL_PTHREAD_PRIVATE
= NULL;
#else
;
#endif
SCLASS TAILQ_HEAD(atfork_head, pthread_atfork) _atfork_list;
SCLASS pthread_mutex_t _atfork_mutex;
/* Default thread attributes: */
SCLASS struct pthread_attr pthread_attr_default
#ifdef GLOBAL_PTHREAD_PRIVATE
= { SCHED_RR, 0, TIMESLICE_USEC, PTHREAD_DEFAULT_PRIORITY,
PTHREAD_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL,
PTHREAD_STACK_DEFAULT, 0 /* set in _thread_init() */ };
#else
;
#endif
/* Default mutex attributes: */
SCLASS struct pthread_mutex_attr pthread_mutexattr_default
#ifdef GLOBAL_PTHREAD_PRIVATE
= { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, 0 };
#else
;
#endif
/* Default condition variable attributes: */
SCLASS struct pthread_cond_attr pthread_condattr_default
#ifdef GLOBAL_PTHREAD_PRIVATE
= { COND_TYPE_FAST, 0 };
#else
;
#endif
/* File table information: */
SCLASS struct fd_table_entry **_thread_fd_table
#ifdef GLOBAL_PTHREAD_PRIVATE
= NULL;
#else
;
#endif
/* Table for polling file descriptors: */
SCLASS struct pollfd *_thread_pfd_table
#ifdef GLOBAL_PTHREAD_PRIVATE
= NULL;
#else
;
#endif
SCLASS int _thread_init_fdtsize /* Initial fd/pfd table size. */
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
SCLASS int _thread_max_fdtsize /* Max fd table size. */
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
SCLASS nfds_t _thread_max_pfdtsize /* Max pfd table size. */
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
SCLASS int _clock_res_usec /* Clock resolution in usec. */
#ifdef GLOBAL_PTHREAD_PRIVATE
= CLOCK_RES_USEC;
#else
;
#endif
/* Garbage collector mutex and condition variable. */
SCLASS pthread_mutex_t _gc_mutex
#ifdef GLOBAL_PTHREAD_PRIVATE
= NULL
#endif
;
SCLASS pthread_cond_t _gc_cond
#ifdef GLOBAL_PTHREAD_PRIVATE
= NULL
#endif
;
/*
* Array of signal actions for this process.
*/
SCLASS struct sigaction _thread_sigact[NSIG];
/*
* Array of counts of dummy handlers for SIG_DFL signals. This is used to
* assure that there is always a dummy signal handler installed while there is a
* thread sigwait()ing on the corresponding signal.
*/
SCLASS int _thread_dfl_count[NSIG];
/*
* Pending signals and mask for this process:
*/
SCLASS sigset_t _process_sigpending;
SCLASS sigset_t _process_sigmask
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0
#endif
;
/*
* Scheduling queues:
*/
SCLASS pq_queue_t _readyq;
SCLASS _thread_list_t _waitingq;
/*
* Work queue:
*/
SCLASS _thread_list_t _workq;
/* Tracks the number of threads blocked while waiting for a spinlock. */
SCLASS volatile int _spinblock_count
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0
#endif
;
/* Used to maintain pending and active signals: */
struct sigstatus {
spinlock_t lock; /* structure access lock */
int pending; /* Is this a pending signal? */
siginfo_t siginfo; /* arg 2 to signal handler */
};
SCLASS struct sigstatus _thread_sigq[NSIG];
/* Indicates that the signal queue needs to be checked. */
SCLASS volatile int _sigq_check_reqd
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0
#endif
;
/* The signal stack. */
SCLASS struct sigaltstack _thread_sigstack;
/* Thread switch hook. */
SCLASS pthread_switch_routine_t _sched_switch_hook
#ifdef GLOBAL_PTHREAD_PRIVATE
= NULL
#endif
;
/*
* Spare stack queue. Stacks of default size are cached in order to reduce
* thread creation time. Spare stacks are used in LIFO order to increase cache
* locality.
*/
typedef SLIST_HEAD(, stack) _stack_list_t;
extern _stack_list_t _stackq;
/* Used for _PTHREADS_INVARIANTS checking. */
SCLASS int _thread_kern_new_state
#ifdef GLOBAL_PTHREAD_PRIVATE
= 0;
#else
;
#endif
/* Undefine the storage class specifier: */
#undef SCLASS
/*
* Function prototype definitions.
*/
__BEGIN_DECLS
int *__error(void);
int _find_thread(pthread_t);
struct pthread *_get_curthread(void);
void _set_curthread(struct pthread *);
int _thread_create(pthread_t *, const pthread_attr_t *,
void *(*start_routine)(void *), void *,pthread_t);
void _dispatch_signal(int, struct sigcontext *);
void _dispatch_signals(struct sigcontext *);
void _thread_signal(pthread_t, int);
void _thread_nonblock_fds(void);
int _mutex_cv_lock(pthread_mutex_t *);
int _mutex_cv_unlock(pthread_mutex_t *);
int _mutex_reinit(pthread_mutex_t *);
void _mutex_notify_priochange(struct pthread *);
int _cond_reinit(pthread_cond_t *);
int _pq_alloc(struct pq_queue *, int, int);
int _pq_init(struct pq_queue *);
void _pq_remove(struct pq_queue *pq, struct pthread *);
void _pq_insert_head(struct pq_queue *pq, struct pthread *);
void _pq_insert_tail(struct pq_queue *pq, struct pthread *);
struct pthread *_pq_first(struct pq_queue *pq);
void _waitq_insert(pthread_t pthread);
void _waitq_remove(pthread_t pthread);
#if defined(_PTHREADS_INVARIANTS)
void _waitq_setactive(void);
void _waitq_clearactive(void);
#endif
__dead void _thread_exit(const char *, int, const char *) __attribute__((__noreturn__));
void *_thread_cleanup(pthread_t);
void _thread_cleanupspecific(void);
void _thread_clear_pending(int, pthread_t);
void _thread_dump_data(const void *, int);
void _thread_dump_info(void);
int _thread_fd_lock(int, int, struct timespec *);
void _thread_fd_unlock(int, int);
struct timespec *_thread_fd_timeout(int, int);
void _thread_init(void);
void _thread_kern_lock(int);
void _thread_kern_sched(struct sigcontext *);
void _thread_kern_sched_state(enum pthread_state, const char *, int);
void _thread_kern_sched_state_unlock(enum pthread_state, spinlock_t *,
const char *, int);
void _thread_kern_set_timeout(const struct timespec *);
void _thread_kern_sig_defer(void);
void _thread_kern_sig_undefer(void);
void _thread_key_init(void);
void _thread_kill_siginfo(int);
void _thread_sig_handler(int, siginfo_t *, struct sigcontext *);
int _thread_sig_handle(int, struct sigcontext *);
void _thread_sig_init(void);
void _thread_start(void);
void _thread_start_sig_handler(void);
void _thread_seterrno(pthread_t,int);
void _thread_fs_flags_replace(int, struct fs_flags *);
int _thread_fd_init_mem(void);
void _thread_fd_init(void);
int _thread_fd_table_init(int, enum fd_entry_mode, struct fs_flags *);
void _thread_fd_entry_close(int);
pthread_addr_t _thread_gc(pthread_addr_t);
void _thread_enter_cancellation_point(void);
void _thread_leave_cancellation_point(void);
void _thread_cancellation_point(void);
int _thread_slow_atomic_lock(volatile _spinlock_lock_t *);
int _thread_slow_atomic_is_locked(volatile _spinlock_lock_t *);
struct stack * _thread_stack_alloc(void *, size_t, size_t);
void _thread_stack_free(struct stack *);
/* #include <signal.h> */
#ifdef _USER_SIGNAL_H
int _thread_sys_kill(pid_t, int);
int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *);
int _thread_sys_sigblock(int);
int _thread_sys_sigsetmask(int);
int _thread_sys_sigpending(sigset_t *);
int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *);
int _thread_sys_sigsuspend(const sigset_t *);
int _thread_sys_siginterrupt(int, int);
int _thread_sys_sigpause(int);
int _thread_sys_sigreturn(struct sigcontext *);
int _thread_sys_sigaltstack(const struct sigaltstack *, struct sigaltstack *);
int _thread_sys_sigvec(int, struct sigvec *, struct sigvec *);
void _thread_sys_psignal(unsigned int, const char *);
void (*_thread_sys_signal(int, void (*)(int)))(int);
#endif
/* #include <sys/stat.h> */
#ifdef _SYS_STAT_H_
int _thread_sys_fchmod(int, mode_t);
int _thread_sys_fstat(int, struct stat *);
int _thread_sys_fchflags(int, unsigned int);
#endif
/* #include <sys/mount.h> */
#ifdef _SYS_MOUNT_H_
int _thread_sys_fstatfs(int, struct statfs *);
#endif
int _thread_sys_pipe(int *);
/* #include <sys/socket.h> */
#ifdef _SYS_SOCKET_H_
int _thread_sys_accept(int, struct sockaddr *, socklen_t *);
int _thread_sys_bind(int, const struct sockaddr *, socklen_t);
int _thread_sys_connect(int, const struct sockaddr *, socklen_t);
int _thread_sys_getpeername(int, struct sockaddr *, socklen_t *);
int _thread_sys_getsockname(int, struct sockaddr *, socklen_t *);
int _thread_sys_getsockopt(int, int, int, void *, socklen_t *);
int _thread_sys_listen(int, int);
int _thread_sys_setsockopt(int, int, int, const void *, socklen_t);
int _thread_sys_shutdown(int, int);
int _thread_sys_socket(int, int, int);
int _thread_sys_socketpair(int, int, int, int *);
ssize_t _thread_sys_recv(int, void *, size_t, int);
ssize_t _thread_sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
ssize_t _thread_sys_recvmsg(int, struct msghdr *, int);
ssize_t _thread_sys_send(int, const void *, size_t, int);
ssize_t _thread_sys_sendmsg(int, const struct msghdr *, int);
ssize_t _thread_sys_sendto(int, const void *,size_t, int, const struct sockaddr *, socklen_t);
#endif
/* #include <stdio.h> */
#ifdef _STDIO_H_
FILE *_thread_sys_fdopen(int, const char *);
FILE *_thread_sys_fopen(const char *, const char *);
FILE *_thread_sys_freopen(const char *, const char *, FILE *);
FILE *_thread_sys_popen(const char *, const char *);
FILE *_thread_sys_tmpfile(void);
char *_thread_sys_ctermid(char *);
char *_thread_sys_cuserid(char *);
char *_thread_sys_fgetln(FILE *, size_t *);
char *_thread_sys_fgets(char *, int, FILE *);
char *_thread_sys_gets(char *);
char *_thread_sys_tempnam(const char *, const char *);
char *_thread_sys_tmpnam(char *);
int _thread_sys_fclose(FILE *);
int _thread_sys_feof(FILE *);
int _thread_sys_ferror(FILE *);
int _thread_sys_fflush(FILE *);
int _thread_sys_fgetc(FILE *);
int _thread_sys_fgetpos(FILE *, fpos_t *);
int _thread_sys_fileno(FILE *);
int _thread_sys_fprintf(FILE *, const char *, ...);
int _thread_sys_fpurge(FILE *);
int _thread_sys_fputc(int, FILE *);
int _thread_sys_fputs(const char *, FILE *);
int _thread_sys_fscanf(FILE *, const char *, ...);
int _thread_sys_fseek(FILE *, long, int);
int _thread_sys_fsetpos(FILE *, const fpos_t *);
int _thread_sys_getc(FILE *);
int _thread_sys_getchar(void);
int _thread_sys_getw(FILE *);
int _thread_sys_pclose(FILE *);
int _thread_sys_printf(const char *, ...);
int _thread_sys_putc(int, FILE *);
int _thread_sys_putchar(int);
int _thread_sys_puts(const char *);
int _thread_sys_putw(int, FILE *);
int _thread_sys_remove(const char *);
int _thread_sys_rename (const char *, const char *);
int _thread_sys_scanf(const char *, ...);
int _thread_sys_setlinebuf(FILE *);
int _thread_sys_setvbuf(FILE *, char *, int, size_t);
int _thread_sys_snprintf(char *, size_t, const char *, ...);
int _thread_sys_sprintf(char *, const char *, ...);
int _thread_sys_sscanf(const char *, const char *, ...);
int _thread_sys_ungetc(int, FILE *);
int _thread_sys_vfprintf(FILE *, const char *, __va_list);
int _thread_sys_vprintf(const char *, __va_list);
int _thread_sys_vscanf(const char *, __va_list);
int _thread_sys_vsnprintf(char *, size_t, const char *, __va_list);
int _thread_sys_vsprintf(char *, const char *, __va_list);
int _thread_sys_vsscanf(const char *, const char *, __va_list);
long _thread_sys_ftell(FILE *);
size_t _thread_sys_fread(void *, size_t, size_t, FILE *);
size_t _thread_sys_fwrite(const void *, size_t, size_t, FILE *);
void _thread_sys_clearerr(FILE *);
void _thread_sys_perror(const char *);
void _thread_sys_rewind(FILE *);
void _thread_sys_setbuf(FILE *, char *);
void _thread_sys_setbuffer(FILE *, char *, int);
#endif
/* #include <unistd.h> */
#ifdef _UNISTD_H_
char *_thread_sys_ttyname(int);
int _thread_sys_close(int);
int _thread_sys_closefrom(int);
int _thread_sys_dup(int);
int _thread_sys_dup2(int, int);
int _thread_sys_exect(const char *, char * const *, char * const *);
int _thread_sys_execve(const char *, char * const *, char * const *);
int _thread_sys_fchdir(int);
int _thread_sys_fchown(int, uid_t, gid_t);
int _thread_sys_fsync(int);
int _thread_sys_ftruncate(int, off_t);
long _thread_sys_fpathconf(int, int);
pid_t _thread_sys_getpid(void);
int _thread_sys_pipe(int *);
int _thread_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
off_t _thread_sys_lseek(int, off_t, int);
pid_t _thread_sys_fork(void);
pid_t _thread_sys_vfork(void);
pid_t _thread_sys_tcgetpgrp(int);
ssize_t _thread_sys_read(int, void *, size_t);
ssize_t _thread_sys_write(int, const void *, size_t);
__dead void _thread_sys__exit(int) __attribute__((__noreturn__));
#endif
/* #include <fcntl.h> */
#ifdef _SYS_FCNTL_H_
int _thread_sys_creat(const char *, mode_t);
int _thread_sys_fcntl(int, int, ...);
int _thread_sys_flock(int, int);
int _thread_sys_open(const char *, int, ...);
#endif
/* #include <sys/ioctl.h> */
#ifdef _SYS_IOCTL_H_
int _thread_sys_ioctl(int, unsigned long, ...);
#endif
/* #include <dirent.h> */
#ifdef _DIRENT_H_
DIR *___thread_sys_opendir2(const char *, int);
DIR *_thread_sys_opendir(const char *);
int _thread_sys_alphasort(const void *, const void *);
int _thread_sys_scandir(const char *, struct dirent ***,
int (*)(struct dirent *), int (*)(const void *, const void *));
int _thread_sys_closedir(DIR *);
int _thread_sys_getdirentries(int, char *, int, off_t *);
long _thread_sys_telldir(const DIR *);
struct dirent *_thread_sys_readdir(DIR *);
void _thread_sys_rewinddir(DIR *);
void _thread_sys_seekdir(DIR *, long);
#endif
/* #include <sys/uio.h> */
#ifdef _SYS_UIO_H_
ssize_t _thread_sys_readv(int, const struct iovec *, int);
ssize_t _thread_sys_writev(int, const struct iovec *, int);
#endif
/* #include <sys/wait.h> */
#ifdef _SYS_WAIT_H_
pid_t _thread_sys_wait(int *);
pid_t _thread_sys_waitpid(pid_t, int *, int);
pid_t _thread_sys_wait3(int *, int, struct rusage *);
pid_t _thread_sys_wait4(pid_t, int *, int, struct rusage *);
#endif
/* #include <poll.h> */
#ifdef _SYS_POLL_H_
int _thread_sys_poll(struct pollfd *, unsigned, int);
#endif
/* #include <sys/event.h> */
#ifdef _SYS_EVENT_H_
int _thread_sys_kqueue(void);
int _thread_sys_kevent(int, const struct kevent *, int, struct kevent *,
int, const struct timespec *);
#endif
/* #include <sys/mman.h> */
int _thread_sys_msync(void *, size_t, int);
__END_DECLS
#endif /* !_PTHREAD_PRIVATE_H */
| 28.313486 | 94 | 0.729281 |
a8fab4218d35fa0eff47cf16e7237a9b447baa8a | 1,269 | h | C | Support/Fuego/Mechanism/Models/dodecane_lu/mechanism.h | JiangAngus/PelePhysics | 21b84a978db789ed8e8275d97b0592cceeee7b82 | [
"BSD-3-Clause-LBNL"
] | null | null | null | Support/Fuego/Mechanism/Models/dodecane_lu/mechanism.h | JiangAngus/PelePhysics | 21b84a978db789ed8e8275d97b0592cceeee7b82 | [
"BSD-3-Clause-LBNL"
] | null | null | null | Support/Fuego/Mechanism/Models/dodecane_lu/mechanism.h | JiangAngus/PelePhysics | 21b84a978db789ed8e8275d97b0592cceeee7b82 | [
"BSD-3-Clause-LBNL"
] | null | null | null | #ifndef MECHANISM_h
#define MECHANISM_h
#if 0
/* Elements
0 O
1 H
2 C
3 N
*/
#endif
/* Species */
#define NC12H26_ID 0
#define H_ID 1
#define O_ID 2
#define OH_ID 3
#define HO2_ID 4
#define H2_ID 5
#define H2O_ID 6
#define H2O2_ID 7
#define O2_ID 8
#define CH2_ID 9
#define CH2D_ID 10
#define CH3_ID 11
#define CH4_ID 12
#define HCO_ID 13
#define CH2O_ID 14
#define CH3O_ID 15
#define CO_ID 16
#define CO2_ID 17
#define C2H2_ID 18
#define C2H3_ID 19
#define C2H4_ID 20
#define C2H5_ID 21
#define C2H6_ID 22
#define CH2CHO_ID 23
#define aC3H5_ID 24
#define C3H6_ID 25
#define nC3H7_ID 26
#define C2H3CHO_ID 27
#define C4H7_ID 28
#define C4H81_ID 29
#define pC4H9_ID 30
#define C5H9_ID 31
#define C5H10_ID 32
#define PXC5H11_ID 33
#define C6H12_ID 34
#define PXC6H13_ID 35
#define C7H14_ID 36
#define PXC7H15_ID 37
#define C8H16_ID 38
#define PXC8H17_ID 39
#define C9H18_ID 40
#define PXC9H19_ID 41
#define C10H20_ID 42
#define PXC10H21_ID 43
#define PXC12H25_ID 44
#define SXC12H25_ID 45
#define S3XC12H25_ID 46
#define C12H24_ID 47
#define C12H25O2_ID 48
#define C12OOH_ID 49
#define O2C12H24OOH_ID 50
#define OC12H23OOH_ID 51
#define N2_ID 52
#define NUM_ELEMENTS 4
#define NUM_SPECIES 53
#define NUM_REACTIONS 268
#define NUM_FIT 4
#endif
/* End of file */
| 16.697368 | 25 | 0.777778 |
a4c3f82d869ce8076bad10a9bc30fd3cf5f224e5 | 1,022 | h | C | usr/libexec/PineBoard/_PBPIPInsetsTuple.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | 5 | 2021-04-29T04:31:43.000Z | 2021-08-19T18:59:58.000Z | usr/libexec/PineBoard/_PBPIPInsetsTuple.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | null | null | null | usr/libexec/PineBoard/_PBPIPInsetsTuple.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | 1 | 2022-03-19T11:16:23.000Z | 2022-03-19T11:16:23.000Z | //
// Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <objc/NSObject.h>
@class BKSAnimationFenceHandle, BSAnimationSettings, NSValue;
@interface _PBPIPInsetsTuple : NSObject
{
NSValue *_value; // 8 = 0x8
BSAnimationSettings *_animationSettings; // 16 = 0x10
BKSAnimationFenceHandle *_animationFence; // 24 = 0x18
}
- (void).cxx_destruct; // IMP=0x0000000100066dc0
@property(readonly, nonatomic) BKSAnimationFenceHandle *animationFence; // @synthesize animationFence=_animationFence;
@property(readonly, nonatomic) BSAnimationSettings *animationSettings; // @synthesize animationSettings=_animationSettings;
@property(readonly, nonatomic) NSValue *value; // @synthesize value=_value;
- (void)dropFence; // IMP=0x0000000100066d24
- (id)initWithValue:(id)arg1 animationSettings:(id)arg2 animationFence:(id)arg3; // IMP=0x0000000100066bdc
- (id)init; // IMP=0x0000000100066aec
@end
| 36.5 | 123 | 0.761252 |
788722e01910bf05cff1fadbdd575b0e8bfc3265 | 1,045 | h | C | source/include/Shader.h | chromaScript/chroma.io | c484354df6f3c84a049ffadfe37c677c0ccb6390 | [
"MIT"
] | null | null | null | source/include/Shader.h | chromaScript/chroma.io | c484354df6f3c84a049ffadfe37c677c0ccb6390 | [
"MIT"
] | null | null | null | source/include/Shader.h | chromaScript/chroma.io | c484354df6f3c84a049ffadfe37c677c0ccb6390 | [
"MIT"
] | null | null | null | #ifndef SHADER_H
#define SHADER_H
#include <glm.hpp>
#include <iostream>
class Shader
{
private:
std::string name;
void checkCompileErrors(unsigned int shader, std::string type);
std::string loadShaderFile(const char* shaderPath);
protected:
public:
unsigned int ID;
Shader(const char* vertexPath, const char* fragmentPath, std::string n);
Shader(const char* geoPath, const char* vertexPath, const char* fragmentPath, std::string n);
void use();
void setBool(const std::string &name, bool value) const;
void setInt(const std::string &name, int value) const;
void setIntArray(const std::string& name, int size, int* arr) const;
void setFloatArray(const std::string& name, int size, float* arr) const;
void setFloat(const std::string &name, float value) const;
void setVec2(const std::string &name, glm::vec2 &value) const;
void setVec3(const std::string &name, glm::vec3 &value) const;
void setVec4(const std::string &name, glm::vec4 &value) const;
void setMat4(const std::string &name, const glm::mat4 &mat) const;
};
#endif | 32.65625 | 94 | 0.737799 |
93f2de9ce9b42ee4149a73ced1f53464b5feee15 | 7,083 | c | C | trees/src/tree.c | Khaaz/SP_Clang | 9585f9307bcf997e7c225acb1a48a2d5a4b415a6 | [
"MIT"
] | 1 | 2020-02-07T12:39:23.000Z | 2020-02-07T12:39:23.000Z | trees/src/tree.c | Khaaz/SP_Clang | 9585f9307bcf997e7c225acb1a48a2d5a4b415a6 | [
"MIT"
] | null | null | null | trees/src/tree.c | Khaaz/SP_Clang | 9585f9307bcf997e7c225acb1a48a2d5a4b415a6 | [
"MIT"
] | null | null | null | #include "tree.h"
#include "queue/queue.h"
#include "stack/stack.h"
/**
* @brief Cree un node (un noeud de notre arbre)
*
* @param value char - La valeur du noeud
* @return node_t* - le moeud nouvellement cree
*/
node_t * createNode(char value)
{
node_t * node = NULL;
node = malloc(sizeof(*node));
if(node != NULL)
{
node->value = value;
node->son = NULL;
node->brother = NULL;
}
else
{
printf("ERROR: Allocation Node\n");
}
return node;
}
/**
* @brief Cree un arbre a partir d'une notation algebrique
*
* @param treeString char* - la notation algebrique
* @return node_t* - l'arbre nouvellement cree
*/
node_t * createTree(char * treeString)
{
int i = 0;
char e, c;
stack_t * stack = NULL;
stack = createStack(50);
node_t * tree = NULL;
tree = createNode(treeString[i++]);
node_t * element = NULL;
node_t * cur = tree;
while(treeString[i] != '\0' && cur != NULL)
{
e = treeString[i];
if(e == ')') // )
{
cur = peek(stack);
pop(stack);
}
else // +, *, (
{
++i;
c = treeString[i];
if(e == '+') // +
{
element = createNode(c);
insertBrother(cur, element);
cur = element;
}
else // *
{
if(c == '(') // (
{
++i;
element = createNode(treeString[i]);
insertSon(cur, element);
push(stack, cur);
cur = element;
}
else // char
{
element = createNode(c);
insertSon(cur, element);
if(treeString[i + 1] == '*')
{
cur = element;
}
}
}
}
++i;
}
freeStack(stack);
return tree;
}
/**
* @brief Libere l'arbre (free tous les noeuds de note arbre)
*
* @param tree node_t* L'arbre a liberer
*/
void freeTree(node_t * tree)
{
stack_t * stack = createStack(50);
node_t * cour = tree;
node_t * tmp = NULL;
while(cour != NULL)
{
if(cour->son != NULL)
{
tmp = cour->son;
cour->son = NULL;
push(stack, cour);
cour = tmp;
}
else
{
if(cour->brother != NULL)
{
tmp = cour->brother;
cour->brother = NULL;
free(cour);
cour = tmp;
}
else
{
free(cour);
if(isEmptyStack(stack) == 0)
{
cour = peek(stack);
pop(stack);
}
else
{
cour = NULL;
}
}
}
}
freeStack(stack);
}
/**
* @brief Insert un frere sur un noeud donne.
*
* @param node node_t* - Le noeud dans lequel inserer un frere
* @param element node_t* - Le frere a inserer
*/
void insertBrother(node_t * node, node_t * element)
{
node->brother = element;
}
/**
* @brief Insert un file sur un noeud donne.
*
* @param node node_t* - Le noeud dans lequel inserer un fils
* @param element node_t* - Le fils a inserer
*/
void insertSon(node_t * node, node_t * element)
{
node->son = element;
}
/**
* @brief Donne la representation post fix de l'arbre. Donne cette
* representation dans une list contigue de char donnee en parametre.
*
* @param node ndoe_t* - L'arbre duquel on veut obtenir la representation
* postfix
* @param list char* - la liste contigue contenant la representation postfix
* @param size int* - la taille logique de note liste
*/
void getPostfix(node_t * node, char * list, int * size)
{
node_t * cour = node;
stack_t * stack = createStack(50);
while(cour != NULL)
{
while(cour->son)
{
push(stack, cour);
cour = cour->son;
}
list[*size] = cour->value;
++(*size);
cour = cour->brother;
while(cour == NULL && isEmptyStack(stack) == 0)
{
cour = peek(stack);
pop(stack);
list[*size] = cour->value;
++(*size);
cour = cour->brother;
}
}
freeStack(stack);
}
/**
* @brief Affiche la notation postfix d'un arbre: Affiche le contenu d'une liste
* contigue contenant la representation postfix d'un arbre
*
* @param list char* - la liste contigue contenant la representation postfix
* @param taille int - la taille de la liste
*/
void displayPostfix(char * list, int taille)
{
int i;
printf("Ordre postfix:\n");
for(i = 0; i < taille; i++)
{
printf("%c", list[i]);
}
printf("\n");
}
/**
* @brief Cherche dans l'arbre le premier noeud de valeur donne.
* La recherche est une recherche par parcours de premier ordre par niveau.
* (parcours en largeur de premier ordre par niveau) On utilise une file.
*
* @param node node_t* - l'arbre dans lequel rechercher
* @param value char - la valeur a recherche dans l'arbre
* @return node_t* - le neoud trouve apres la recherche
*/
node_t * search(node_t * node, char value)
{
node_t * cour = node;
queue_t * queue = createQueue(50);
while(cour != NULL && cour->value != value)
{
if(cour->son != NULL)
{
pushBack(queue, cour->son);
}
if(cour->brother != NULL)
{
cour = cour->brother;
}
else
{
cour = front(queue);
popFront(queue);
}
}
freeQueue(queue);
return cour;
}
/**
* @brief Creer et insert un noeud de valeur donnee dans l'arbre. Insert dans
* les fils du noeud donne en parametre. Le noeud donne en parametre est donne
* sous format de char, et est donc trouve en utilisant search. L'insertion dans
* les fils se fait en suivant l'ordre alphabetique.
*
* @param node node_t* - l'arbre dans lequel inserer
* @param noeud char - la valeur du noeud a trouver et dans lequel inserer
* @param value char - la valeur du noeud a creer et inserer
* @return int - Si la fonction a marche correctement
*/
int insertion(node_t * node, char noeud, char value)
{
int code = 1;
node_t * cour = search(node, noeud);
node_t ** prec = NULL;
node_t * newnode = NULL;
if(cour != NULL)
{
prec = &(cour->son);
newnode = createNode(value);
while(*prec != NULL && (*prec)->value < value)
{
prec = &((*prec)->brother);
}
newnode->brother = *prec;
*prec = newnode;
}
else
{
code = 0;
printf("ERROR: Insertion dans un noeud inexistant\n");
}
return code;
} | 24.940141 | 80 | 0.501906 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.