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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8f27c0cb67d02005906fe0b3273ba29081c707c3 | 1,969 | h | C | incl/cs_eip202_global_ext.h | paldier/eip97 | ce4edaca76d0e253c98eb1611a7a6b6f45fadb17 | [
"BSD-2-Clause"
] | null | null | null | incl/cs_eip202_global_ext.h | paldier/eip97 | ce4edaca76d0e253c98eb1611a7a6b6f45fadb17 | [
"BSD-2-Clause"
] | null | null | null | incl/cs_eip202_global_ext.h | paldier/eip97 | ce4edaca76d0e253c98eb1611a7a6b6f45fadb17 | [
"BSD-2-Clause"
] | null | null | null | /* cs_eip202_global_ext.h
*
* Top-level EIP-202 Driver Library Global Control configuration extensions
*/
/*****************************************************************************
* Copyright (c) 2012-2013 INSIDE Secure B.V. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef CS_EIP202_GLOBAL_EXT_H_
#define CS_EIP202_GLOBAL_EXT_H_
/*----------------------------------------------------------------------------
* This module uses (requires) the following interface(s):
*/
/*----------------------------------------------------------------------------
* Definitions and macros
*/
// Read/Write register constants
/*****************************************************************************
* Byte offsets of the EIP-202 HIA registers
*****************************************************************************/
// HIA DFE all threads
#define EIP202_DFE_BASE 0x0F000
// HIA DFE thread n (n - number of the DFE thread)
#define EIP202_DFE_TRD_BASE 0x0F200
// HIA DSE all threads
#define EIP202_DSE_BASE 0x0F400
// HIA DSE thread n (n - number of the DSE thread)
#define EIP202_DSE_TRD_BASE 0x0F600
// HIA Global
#define EIP202_G_BASE 0x0FFF4
#endif /* CS_EIP202_GLOBAL_EXT_H_ */
/* end of file cs_eip202_global_ext.h */
| 31.758065 | 79 | 0.559675 |
5c3f28e8db9c08d014dded995ce2f087b5bbb35b | 398 | h | C | Fireworks/Tracks/interface/estimate_field.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 3 | 2018-08-24T19:10:26.000Z | 2019-02-19T11:45:32.000Z | Fireworks/Tracks/interface/estimate_field.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 3 | 2018-08-23T13:40:24.000Z | 2019-12-05T21:16:03.000Z | Fireworks/Tracks/interface/estimate_field.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 5 | 2018-08-21T16:37:52.000Z | 2020-01-09T13:33:17.000Z | #ifndef Fireworks_Tracks_estimate_field_h
#define Fireworks_Tracks_estimate_field_h
// -*- C++ -*-
//
// Package: Tracks
// Class : estimate_field
//
namespace reco {
class Track;
}
namespace fw {
double estimate_field( const reco::Track& track, bool highQuality = false );
double estimate_field( double vx1, double vy1, double vx2, double vy2, double px, double py );
}
#endif
| 22.111111 | 97 | 0.70603 |
b14d07d14f5105929ceb079f39fc0eaf080ebe85 | 1,183 | h | C | src/grid/MessageSection.h | fmidev/smartmet-library-grid-files | c68d271e12e3404cd805a423fe6c5b6c467f00e6 | [
"MIT"
] | null | null | null | src/grid/MessageSection.h | fmidev/smartmet-library-grid-files | c68d271e12e3404cd805a423fe6c5b6c467f00e6 | [
"MIT"
] | null | null | null | src/grid/MessageSection.h | fmidev/smartmet-library-grid-files | c68d271e12e3404cd805a423fe6c5b6c467f00e6 | [
"MIT"
] | null | null | null | #pragma once
#include "Typedefs.h"
#include "../common/AttributeList.h"
namespace SmartMet
{
namespace GRID
{
// ====================================================================================
/*!
\brief This class is a parent class for all message sections in different grid files.
It defines the basic methods that all its child classes should implement.
*/
// ====================================================================================
class MessageSection
{
public:
MessageSection();
//MessageSection(const MessageSection& other);
virtual ~MessageSection();
// ### Common methods for all message sections
virtual void getAttributeList(const std::string& prefix,T::AttributeList& attributeList) const;
virtual T::FilePosition getFilePosition() const;
virtual std::uint32_t getSectionLength() const;
virtual std::string getSectionName() const;
virtual std::uint8_t getSectionNumber() const;
virtual void print(std::ostream& stream,uint level,uint optionFlags) const;
};
} // namespace GRID
} // namespace SmartMet
| 29.575 | 110 | 0.563821 |
c08aac94da0ef6860ef21402f58ea5805c7abbe7 | 3,320 | c | C | src/spice3/src/lib/dev/mos1/mos1conv.c | yrrapt/cacd | 696f5a22cb71b83eabbb9de199f1972d458fa9e9 | [
"ISC"
] | 11 | 2019-10-16T11:03:49.000Z | 2021-09-28T19:46:12.000Z | src/spice3/src/lib/dev/mos1/mos1conv.c | yrrapt/cacd | 696f5a22cb71b83eabbb9de199f1972d458fa9e9 | [
"ISC"
] | null | null | null | src/spice3/src/lib/dev/mos1/mos1conv.c | yrrapt/cacd | 696f5a22cb71b83eabbb9de199f1972d458fa9e9 | [
"ISC"
] | 1 | 2021-09-29T18:15:17.000Z | 2021-09-29T18:15:17.000Z | /**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
**********/
#include "spice.h"
#include <stdio.h>
#include "cktdefs.h"
#include "mos1defs.h"
#include "sperror.h"
#include "util.h"
int
MOS1convTest(inModel,ckt)
GENmodel *inModel;
register CKTcircuit *ckt;
{
register MOS1model *model = (MOS1model*)inModel;
register MOS1instance *here;
double delvbs;
double delvbd;
double delvgs;
double delvds;
double delvgd;
double cbhat;
double cdhat;
double vbs;
double vbd;
double vgs;
double vds;
double vgd;
double vgdo;
double tol;
for( ; model != NULL; model = model->MOS1nextModel) {
for(here = model->MOS1instances; here!= NULL;
here = here->MOS1nextInstance) {
vbs = model->MOS1type * (
*(ckt->CKTrhs+here->MOS1bNode) -
*(ckt->CKTrhs+here->MOS1sNodePrime));
vgs = model->MOS1type * (
*(ckt->CKTrhs+here->MOS1gNode) -
*(ckt->CKTrhs+here->MOS1sNodePrime));
vds = model->MOS1type * (
*(ckt->CKTrhs+here->MOS1dNodePrime) -
*(ckt->CKTrhs+here->MOS1sNodePrime));
vbd=vbs-vds;
vgd=vgs-vds;
vgdo = *(ckt->CKTstate0 + here->MOS1vgs) -
*(ckt->CKTstate0 + here->MOS1vds);
delvbs = vbs - *(ckt->CKTstate0 + here->MOS1vbs);
delvbd = vbd - *(ckt->CKTstate0 + here->MOS1vbd);
delvgs = vgs - *(ckt->CKTstate0 + here->MOS1vgs);
delvds = vds - *(ckt->CKTstate0 + here->MOS1vds);
delvgd = vgd-vgdo;
/* these are needed for convergence testing */
if (here->MOS1mode >= 0) {
cdhat=
here->MOS1cd-
here->MOS1gbd * delvbd +
here->MOS1gmbs * delvbs +
here->MOS1gm * delvgs +
here->MOS1gds * delvds ;
} else {
cdhat=
here->MOS1cd -
( here->MOS1gbd -
here->MOS1gmbs) * delvbd -
here->MOS1gm * delvgd +
here->MOS1gds * delvds ;
}
cbhat=
here->MOS1cbs +
here->MOS1cbd +
here->MOS1gbd * delvbd +
here->MOS1gbs * delvbs ;
/*
* check convergence
*/
tol=ckt->CKTreltol*MAX(FABS(cdhat),FABS(here->MOS1cd))+
ckt->CKTabstol;
if (FABS(cdhat-here->MOS1cd) >= tol) {
ckt->CKTnoncon++;
ckt->CKTtroubleElt = (GENinstance *) here;
return(OK); /* no reason to continue, we haven't converged */
} else {
tol=ckt->CKTreltol*
MAX(FABS(cbhat),FABS(here->MOS1cbs+here->MOS1cbd))+
ckt->CKTabstol;
if (FABS(cbhat-(here->MOS1cbs+here->MOS1cbd)) > tol) {
ckt->CKTnoncon++;
ckt->CKTtroubleElt = (GENinstance *) here;
return(OK); /* no reason to continue, we haven't converged*/
}
}
}
}
return(OK);
}
| 32.23301 | 80 | 0.480422 |
69f383bbd924813b792fc0ac68f6c4b4495440be | 1,431 | h | C | toolboxes/fft/gpu/cuFFTCachedPlan.h | roopchansinghv/gadgetron | fb6c56b643911152c27834a754a7b6ee2dd912da | [
"MIT"
] | 1 | 2022-02-22T21:06:36.000Z | 2022-02-22T21:06:36.000Z | toolboxes/fft/gpu/cuFFTCachedPlan.h | apd47/gadgetron | 073e84dabe77d2dae3b3dd9aa4bf9edbf1f890f2 | [
"MIT"
] | null | null | null | toolboxes/fft/gpu/cuFFTCachedPlan.h | apd47/gadgetron | 073e84dabe77d2dae3b3dd9aa4bf9edbf1f890f2 | [
"MIT"
] | null | null | null | #pragma once
#include "cuFFTPlan.h"
#include <map>
namespace Gadgetron {
template <class ComplexType> class cuFFTCachedPlan {
public:
cuFFTCachedPlan() = default;
void fft1(cuNDArray<ComplexType>& in_out, bool scale=true);
void fft2(cuNDArray<ComplexType>& in_out, bool scale=true);
void fft3(cuNDArray<ComplexType>& in_out, bool scale=true);
void ifft1(cuNDArray<ComplexType>& in_out, bool scale=true);
void ifft2(cuNDArray<ComplexType>& in_out, bool scale=true);
void ifft3(cuNDArray<ComplexType>& in_out, bool scale=true);
void fft1c(cuNDArray<ComplexType>& in_out, bool scale=true);
void fft2c(cuNDArray<ComplexType>& in_out, bool scale=true);
void fft3c(cuNDArray<ComplexType>& in_out, bool scale=true);
void ifft1c(cuNDArray<ComplexType>& in_out, bool scale=true);
void ifft2c(cuNDArray<ComplexType>& in_out, bool scale=true);
void ifft3c(cuNDArray<ComplexType>& in_out, bool scale=true);
void fft(cuNDArray<ComplexType>& in_out, unsigned int rank, bool scale=true);
void ifft(cuNDArray<ComplexType>& in_out, unsigned int rank, bool scale=true);
void fftc(cuNDArray<ComplexType>& in_out, unsigned int rank, bool scale=true);
void ifftc(cuNDArray<ComplexType>& in_out, unsigned int rank, bool scale=true);
private:
std::map<std::vector<size_t>, cuFFTPlan<ComplexType, void >> plans;
};
} // namespace Gadgetron
#include "cuFFTCachedPlan.hpp" | 38.675676 | 83 | 0.734451 |
0762e6cae138c1e156423a05bbf34bde239f9c3d | 451 | h | C | tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.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 | tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.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 | tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.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 2014 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 PART_OBJECT_TO_GC_DERIVED_CLASS_H_
#define PART_OBJECT_TO_GC_DERIVED_CLASS_H_
#include "heap/stubs.h"
namespace blink {
class A : public GarbageCollected<A> { };
class B : public GarbageCollected<B> {
public:
void Trace(Visitor*) const;
private:
A m_a;
};
}
#endif
| 18.04 | 73 | 0.747228 |
0d61edecc32ab5bca087bdf481b738c5622edfe5 | 23,253 | c | C | applications/c-toxcore/testing/av_test.c | gaohangaohan/qkd-net | 90f52104412b5c5c82668362dbd3e4791261f332 | [
"MIT"
] | 17 | 2019-04-21T14:10:57.000Z | 2022-03-26T09:32:53.000Z | applications/c-toxcore/testing/av_test.c | gaohangaohan/qkd-net | 90f52104412b5c5c82668362dbd3e4791261f332 | [
"MIT"
] | 22 | 2019-01-11T19:13:44.000Z | 2022-02-26T17:58:32.000Z | applications/c-toxcore/testing/av_test.c | gaohangaohan/qkd-net | 90f52104412b5c5c82668362dbd3e4791261f332 | [
"MIT"
] | 17 | 2019-03-06T17:29:29.000Z | 2021-08-10T10:17:09.000Z | /*
* Compile with (Linux only; in newly created directory toxcore/dir_name):
* gcc -o av_test ../toxav/av_test.c ../build/.libs/libtox*.a -lopencv_core \
* -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio
*/
/*
* Copyright © 2016-2017 The TokTok team.
* Copyright © 2013-2015 Tox project.
*
* This file is part of Tox, the free peer to peer instant messenger.
*
* Tox is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tox 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 Tox. If not, see <http://www.gnu.org/licenses/>.
*/
#define _XOPEN_SOURCE 600
#ifdef __cplusplus
extern "C" {
#endif
// XXX: Hack because toxav doesn't really expose ring_buffer, but this av test
// uses it. Not all of these functions are used, but when linking statically,
// not renaming them will cause multiple definition errors, so we need to rename
// all of them.
#define RingBuffer TestRingBuffer
#define rb_full test_rb_full
#define rb_empty test_rb_empty
#define rb_write test_rb_write
#define rb_read test_rb_read
#define rb_new test_rb_new
#define rb_kill test_rb_kill
#define rb_size test_rb_size
#define rb_data test_rb_data
#include "../toxav/ring_buffer.c"
#include "../toxav/toxav.h"
#include "../toxcore/network.h" /* current_time_monotonic() */
#include "../toxcore/tox.h"
#include "../toxcore/util.h"
#ifdef __cplusplus
}
#endif
/* Playing audio data */
#include <portaudio.h>
/* Reading audio */
#include <sndfile.h>
/* Reading and Displaying video data */
#include <opencv/cv.h>
#include <opencv/cvwimage.h>
#include <opencv/highgui.h>
#include <assert.h>
#include <errno.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*(x))
#define CLIP(X) ((X) > 255 ? 255 : (X) < 0 ? 0 : X)
// RGB -> YUV
#define RGB2Y(R, G, B) CLIP((( 66 * (R) + 129 * (G) + 25 * (B) + 128) >> 8) + 16)
#define RGB2U(R, G, B) CLIP(((-38 * (R) - 74 * (G) + 112 * (B) + 128) >> 8) + 128)
#define RGB2V(R, G, B) CLIP(((112 * (R) - 94 * (G) - 18 * (B) + 128) >> 8) + 128)
// YUV -> RGB
#define C(Y) ((Y) - 16 )
#define D(U) ((U) - 128 )
#define E(V) ((V) - 128 )
#define YUV2R(Y, U, V) CLIP((298 * C(Y) + 409 * E(V) + 128) >> 8)
#define YUV2G(Y, U, V) CLIP((298 * C(Y) - 100 * D(U) - 208 * E(V) + 128) >> 8)
#define YUV2B(Y, U, V) CLIP((298 * C(Y) + 516 * D(U) + 128) >> 8)
#define TEST_TRANSFER_A 0
#define TEST_TRANSFER_V 1
typedef struct {
bool incoming;
uint32_t state;
pthread_mutex_t arb_mutex[1];
RingBuffer *arb; /* Audio ring buffer */
} CallControl;
struct toxav_thread_data {
ToxAV *AliceAV;
ToxAV *BobAV;
int32_t sig;
};
static const char *vdout = "AV Test"; /* Video output */
static PaStream *adout = nullptr; /* Audio output */
typedef struct {
uint16_t size;
int16_t data[];
} frame;
static void *pa_write_thread(void *d)
{
/* The purpose of this thread is to make sure Pa_WriteStream will not block
* toxav_iterate thread
*/
CallControl *cc = (CallControl *)d;
while (Pa_IsStreamActive(adout)) {
frame *f;
pthread_mutex_lock(cc->arb_mutex);
if (rb_read(cc->arb, (void **)&f)) {
pthread_mutex_unlock(cc->arb_mutex);
Pa_WriteStream(adout, f->data, f->size);
free(f);
} else {
pthread_mutex_unlock(cc->arb_mutex);
c_sleep(10);
}
}
return nullptr;
}
/**
* Callbacks
*/
static void t_toxav_call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data)
{
printf("Handling CALL callback\n");
((CallControl *)user_data)->incoming = true;
}
static void t_toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data)
{
printf("Handling CALL STATE callback: %d\n", state);
((CallControl *)user_data)->state = state;
}
static void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
uint16_t width, uint16_t height,
uint8_t const *y, uint8_t const *u, uint8_t const *v,
int32_t ystride, int32_t ustride, int32_t vstride,
void *user_data)
{
ystride = abs(ystride);
ustride = abs(ustride);
vstride = abs(vstride);
uint16_t *img_data = (uint16_t *)malloc(height * width * 6);
unsigned long int i, j;
for (i = 0; i < height; ++i) {
for (j = 0; j < width; ++j) {
uint8_t *point = (uint8_t *) img_data + 3 * ((i * width) + j);
int yx = y[(i * ystride) + j];
int ux = u[((i / 2) * ustride) + (j / 2)];
int vx = v[((i / 2) * vstride) + (j / 2)];
point[0] = YUV2R(yx, ux, vx);
point[1] = YUV2G(yx, ux, vx);
point[2] = YUV2B(yx, ux, vx);
}
}
CvMat mat = cvMat(height, width, CV_8UC3, img_data);
CvSize sz;
sz.height = height;
sz.width = width;
IplImage *header = cvCreateImageHeader(sz, 1, 3);
IplImage *img = cvGetImage(&mat, header);
cvShowImage(vdout, img);
free(img_data);
}
static void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
int16_t const *pcm,
size_t sample_count,
uint8_t channels,
uint32_t sampling_rate,
void *user_data)
{
CallControl *cc = (CallControl *)user_data;
frame *f = (frame *)malloc(sizeof(uint16_t) + sample_count * sizeof(int16_t) * channels);
memcpy(f->data, pcm, sample_count * sizeof(int16_t) * channels);
f->size = sample_count;
pthread_mutex_lock(cc->arb_mutex);
free(rb_write(cc->arb, f));
pthread_mutex_unlock(cc->arb_mutex);
}
static void t_toxav_audio_bit_rate_cb(ToxAV *av, uint32_t friend_number,
uint32_t audio_bit_rate, void *user_data)
{
printf("Suggested bit rate: audio: %d\n", audio_bit_rate);
}
static void t_toxav_video_bit_rate_cb(ToxAV *av, uint32_t friend_number,
uint32_t video_bit_rate, void *user_data)
{
printf("Suggested bit rate: video: %d\n", video_bit_rate);
}
static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length,
void *userdata)
{
if (length == 7 && memcmp("gentoo", data, 7) == 0) {
assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0);
}
}
/**
*/
static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceCC, ToxAV **BobAV, CallControl *BobCC)
{
Tox *Alice;
Tox *Bob;
struct Tox_Options *opts = tox_options_new(nullptr);
assert(opts != nullptr);
tox_options_set_end_port(opts, 0);
tox_options_set_ipv6_enabled(opts, false);
{
TOX_ERR_NEW error;
tox_options_set_start_port(opts, 33445);
*bootstrap = tox_new(opts, &error);
assert(error == TOX_ERR_NEW_OK);
tox_options_set_start_port(opts, 33455);
Alice = tox_new(opts, &error);
assert(error == TOX_ERR_NEW_OK);
tox_options_set_start_port(opts, 33465);
Bob = tox_new(opts, &error);
assert(error == TOX_ERR_NEW_OK);
}
tox_options_free(opts);
printf("Created 3 instances of Tox\n");
printf("Preparing network...\n");
long long unsigned int cur_time = time(nullptr);
uint32_t to_compare = 974536;
uint8_t address[TOX_ADDRESS_SIZE];
tox_callback_friend_request(Alice, t_accept_friend_request_cb);
tox_self_get_address(Alice, address);
assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0);
uint8_t off = 1;
while (1) {
tox_iterate(*bootstrap, &to_compare);
tox_iterate(Alice, &to_compare);
tox_iterate(Bob, &to_compare);
if (tox_self_get_connection_status(*bootstrap) &&
tox_self_get_connection_status(Alice) &&
tox_self_get_connection_status(Bob) && off) {
printf("Toxes are online, took %llu seconds\n", time(nullptr) - cur_time);
off = 0;
}
if (tox_friend_get_connection_status(Alice, 0, nullptr) == TOX_CONNECTION_UDP &&
tox_friend_get_connection_status(Bob, 0, nullptr) == TOX_CONNECTION_UDP) {
break;
}
c_sleep(20);
}
TOXAV_ERR_NEW rc;
*AliceAV = toxav_new(Alice, &rc);
assert(rc == TOXAV_ERR_NEW_OK);
*BobAV = toxav_new(Bob, &rc);
assert(rc == TOXAV_ERR_NEW_OK);
/* Alice */
toxav_callback_call(*AliceAV, t_toxav_call_cb, AliceCC);
toxav_callback_call_state(*AliceAV, t_toxav_call_state_cb, AliceCC);
toxav_callback_audio_bit_rate(*AliceAV, t_toxav_audio_bit_rate_cb, AliceCC);
toxav_callback_video_bit_rate(*AliceAV, t_toxav_video_bit_rate_cb, AliceCC);
toxav_callback_video_receive_frame(*AliceAV, t_toxav_receive_video_frame_cb, AliceCC);
toxav_callback_audio_receive_frame(*AliceAV, t_toxav_receive_audio_frame_cb, AliceCC);
/* Bob */
toxav_callback_call(*BobAV, t_toxav_call_cb, BobCC);
toxav_callback_call_state(*BobAV, t_toxav_call_state_cb, BobCC);
toxav_callback_audio_bit_rate(*BobAV, t_toxav_audio_bit_rate_cb, BobCC);
toxav_callback_video_bit_rate(*BobAV, t_toxav_video_bit_rate_cb, BobCC);
toxav_callback_video_receive_frame(*BobAV, t_toxav_receive_video_frame_cb, BobCC);
toxav_callback_audio_receive_frame(*BobAV, t_toxav_receive_audio_frame_cb, BobCC);
printf("Created 2 instances of ToxAV\n");
printf("All set after %llu seconds!\n", time(nullptr) - cur_time);
}
static int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV, void *userdata)
{
tox_iterate(bootstrap, userdata);
tox_iterate(toxav_get_tox(AliceAV), userdata);
tox_iterate(toxav_get_tox(BobAV), userdata);
return MIN(tox_iteration_interval(toxav_get_tox(AliceAV)), tox_iteration_interval(toxav_get_tox(BobAV)));
}
static void *iterate_toxav(void *data)
{
struct toxav_thread_data *data_cast = (struct toxav_thread_data *)data;
#if defined TEST_TRANSFER_V && TEST_TRANSFER_V == 1
cvNamedWindow(vdout, CV_WINDOW_AUTOSIZE);
#endif
while (data_cast->sig == 0) {
toxav_iterate(data_cast->AliceAV);
toxav_iterate(data_cast->BobAV);
int rc = MIN(toxav_iteration_interval(data_cast->AliceAV), toxav_iteration_interval(data_cast->BobAV));
printf("\rIteration interval: %d ", rc);
fflush(stdout);
#if defined TEST_TRANSFER_V && TEST_TRANSFER_V == 1
if (!rc) {
rc = 1;
}
cvWaitKey(rc);
#else
c_sleep(rc);
#endif
}
data_cast->sig = 1;
#if defined TEST_TRANSFER_V && TEST_TRANSFER_V == 1
cvDestroyWindow(vdout);
#endif
pthread_exit(nullptr);
}
static int send_opencv_img(ToxAV *av, uint32_t friend_number, const IplImage *img)
{
int32_t strides[3] = { img->width, img->width / 2, img->width / 2 };
uint8_t *planes[3] = {
(uint8_t *)malloc(img->height * img->width),
(uint8_t *)malloc(img->height * img->width / 4),
(uint8_t *)malloc(img->height * img->width / 4),
};
int x_chroma_shift = 1;
int y_chroma_shift = 1;
int x, y;
for (y = 0; y < img->height; ++y) {
for (x = 0; x < img->width; ++x) {
uint8_t r = img->imageData[(x + y * img->width) * 3 + 0];
uint8_t g = img->imageData[(x + y * img->width) * 3 + 1];
uint8_t b = img->imageData[(x + y * img->width) * 3 + 2];
planes[0][x + y * strides[0]] = RGB2Y(r, g, b);
if (!(x % (1 << x_chroma_shift)) && !(y % (1 << y_chroma_shift))) {
const int i = x / (1 << x_chroma_shift);
const int j = y / (1 << y_chroma_shift);
planes[1][i + j * strides[1]] = RGB2U(r, g, b);
planes[2][i + j * strides[2]] = RGB2V(r, g, b);
}
}
}
int rc = toxav_video_send_frame(av, friend_number, img->width, img->height,
planes[0], planes[1], planes[2], nullptr);
free(planes[0]);
free(planes[1]);
free(planes[2]);
return rc;
}
static int print_audio_devices(void)
{
int i = 0;
for (i = 0; i < Pa_GetDeviceCount(); ++i) {
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
if (info) {
printf("%d) %s\n", i, info->name);
}
}
return 0;
}
static int print_help(const char *name)
{
printf("Usage: %s -[a:v:o:dh]\n"
"-a <path> audio input file\n"
"-b <ms> audio frame duration\n"
"-v <path> video input file\n"
"-x <ms> video frame duration\n"
"-o <idx> output audio device index\n"
"-d print output audio devices\n"
"-h print this help\n", name);
return 0;
}
int main(int argc, char **argv)
{
freopen("/dev/zero", "w", stderr);
Pa_Initialize();
struct stat st;
/* AV files for testing */
const char *af_name = nullptr;
const char *vf_name = nullptr;
long audio_out_dev_idx = -1;
int32_t audio_frame_duration = 20;
#if 0
// TODO(mannol): Put this to use.
int32_t video_frame_duration = 10;
#endif
/* Parse settings */
CHECK_ARG:
switch (getopt(argc, argv, "a:b:v:x:o:dh")) {
case 'a':
af_name = optarg;
goto CHECK_ARG;
case 'b': {
char *d;
audio_frame_duration = strtol(optarg, &d, 10);
if (*d) {
printf("Invalid value for argument: 'b'");
exit(1);
}
goto CHECK_ARG;
}
case 'v':
vf_name = optarg;
goto CHECK_ARG;
#if 0
case 'x': {
char *d;
video_frame_duration = strtol(optarg, &d, 10);
if (*d) {
printf("Invalid value for argument: 'x'");
exit(1);
}
goto CHECK_ARG;
}
#endif
case 'o': {
char *d;
audio_out_dev_idx = strtol(optarg, &d, 10);
if (*d) {
printf("Invalid value for argument: 'o'");
exit(1);
}
goto CHECK_ARG;
}
case 'd':
return print_audio_devices();
case 'h':
return print_help(argv[0]);
case '?':
exit(1);
case -1:
;
}
{ /* Check files */
if (!af_name) {
printf("Required audio input file!\n");
exit(1);
}
if (!vf_name) {
printf("Required video input file!\n");
exit(1);
}
/* Check for files */
if (stat(af_name, &st) != 0 || !S_ISREG(st.st_mode)) {
printf("%s doesn't seem to be a regular file!\n", af_name);
exit(1);
}
if (stat(vf_name, &st) != 0 || !S_ISREG(st.st_mode)) {
printf("%s doesn't seem to be a regular file!\n", vf_name);
exit(1);
}
}
if (audio_out_dev_idx < 0) {
audio_out_dev_idx = Pa_GetDefaultOutputDevice();
}
const PaDeviceInfo *audio_dev = Pa_GetDeviceInfo(audio_out_dev_idx);
if (!audio_dev) {
fprintf(stderr, "Device under index: %ld invalid", audio_out_dev_idx);
return 1;
}
printf("Using audio device: %s\n", audio_dev->name);
printf("Using audio file: %s\n", af_name);
printf("Using video file: %s\n", vf_name);
/* START TOX NETWORK */
Tox *bootstrap;
ToxAV *AliceAV;
ToxAV *BobAV;
CallControl AliceCC;
CallControl BobCC;
initialize_tox(&bootstrap, &AliceAV, &AliceCC, &BobAV, &BobCC);
if (TEST_TRANSFER_A) {
SNDFILE *af_handle;
SF_INFO af_info;
printf("\nTrying audio enc/dec...\n");
memset(&AliceCC, 0, sizeof(CallControl));
memset(&BobCC, 0, sizeof(CallControl));
pthread_mutex_init(AliceCC.arb_mutex, nullptr);
pthread_mutex_init(BobCC.arb_mutex, nullptr);
AliceCC.arb = rb_new(16);
BobCC.arb = rb_new(16);
{ /* Call */
TOXAV_ERR_CALL rc;
toxav_call(AliceAV, 0, 48, 0, &rc);
if (rc != TOXAV_ERR_CALL_OK) {
printf("toxav_call failed: %d\n", rc);
exit(1);
}
}
while (!BobCC.incoming) {
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
}
{ /* Answer */
TOXAV_ERR_ANSWER rc;
toxav_answer(BobAV, 0, 48, 0, &rc);
if (rc != TOXAV_ERR_ANSWER_OK) {
printf("toxav_answer failed: %d\n", rc);
exit(1);
}
}
while (AliceCC.state == 0) {
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
}
/* Open audio file */
af_handle = sf_open(af_name, SFM_READ, &af_info);
if (af_handle == nullptr) {
printf("Failed to open the file.\n");
exit(1);
}
int16_t PCM[5760];
time_t start_time = time(nullptr);
time_t expected_time = af_info.frames / af_info.samplerate + 2;
/* Start decode thread */
struct toxav_thread_data data = {
AliceAV,
BobAV,
0,
};
pthread_t dect;
pthread_create(&dect, nullptr, iterate_toxav, &data);
pthread_detach(dect);
int frame_size = (af_info.samplerate * audio_frame_duration / 1000) * af_info.channels;
struct PaStreamParameters output;
output.device = audio_out_dev_idx;
output.channelCount = af_info.channels;
output.sampleFormat = paInt16;
output.suggestedLatency = audio_dev->defaultHighOutputLatency;
output.hostApiSpecificStreamInfo = nullptr;
PaError err = Pa_OpenStream(&adout, nullptr, &output, af_info.samplerate, frame_size, paNoFlag, nullptr, nullptr);
assert(err == paNoError);
err = Pa_StartStream(adout);
assert(err == paNoError);
// toxav_audio_bit_rate_set(AliceAV, 0, 64, false, nullptr);
/* Start write thread */
pthread_t t;
pthread_create(&t, nullptr, pa_write_thread, &BobCC);
pthread_detach(t);
printf("Sample rate %d\n", af_info.samplerate);
while (start_time + expected_time > time(nullptr)) {
uint64_t enc_start_time = current_time_monotonic();
int64_t count = sf_read_short(af_handle, PCM, frame_size);
if (count > 0) {
TOXAV_ERR_SEND_FRAME rc;
if (toxav_audio_send_frame(AliceAV, 0, PCM, count / af_info.channels, af_info.channels, af_info.samplerate,
&rc) == false) {
printf("Error sending frame of size %ld: %d\n", (long)count, rc);
}
}
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
c_sleep((audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1));
}
printf("Played file in: %lu; stopping stream...\n", time(nullptr) - start_time);
Pa_StopStream(adout);
sf_close(af_handle);
{ /* Hangup */
TOXAV_ERR_CALL_CONTROL rc;
toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
if (rc != TOXAV_ERR_CALL_CONTROL_OK) {
printf("toxav_call_control failed: %d\n", rc);
exit(1);
}
}
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED);
/* Stop decode thread */
data.sig = -1;
while (data.sig != 1) {
sched_yield();
}
pthread_mutex_destroy(AliceCC.arb_mutex);
pthread_mutex_destroy(BobCC.arb_mutex);
void *f = nullptr;
while (rb_read(AliceCC.arb, &f)) {
free(f);
}
while (rb_read(BobCC.arb, &f)) {
free(f);
}
printf("Success!");
}
if (TEST_TRANSFER_V) {
printf("\nTrying video enc/dec...\n");
memset(&AliceCC, 0, sizeof(CallControl));
memset(&BobCC, 0, sizeof(CallControl));
{ /* Call */
TOXAV_ERR_CALL rc;
toxav_call(AliceAV, 0, 0, 2000, &rc);
if (rc != TOXAV_ERR_CALL_OK) {
printf("toxav_call failed: %d\n", rc);
exit(1);
}
}
while (!BobCC.incoming) {
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
}
{ /* Answer */
TOXAV_ERR_ANSWER rc;
toxav_answer(BobAV, 0, 0, 5000, &rc);
if (rc != TOXAV_ERR_ANSWER_OK) {
printf("toxav_answer failed: %d\n", rc);
exit(1);
}
}
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
/* Start decode thread */
struct toxav_thread_data data = {
AliceAV,
BobAV,
0,
};
pthread_t dect;
pthread_create(&dect, nullptr, iterate_toxav, &data);
pthread_detach(dect);
CvCapture *capture = cvCreateFileCapture(vf_name);
if (!capture) {
printf("Failed to open video file: %s\n", vf_name);
exit(1);
}
#if 0
toxav_video_bit_rate_set(AliceAV, 0, 5000, false, nullptr);
#endif
time_t start_time = time(nullptr);
while (start_time + 90 > time(nullptr)) {
IplImage *frame = cvQueryFrame(capture);
if (!frame) {
break;
}
send_opencv_img(AliceAV, 0, frame);
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
c_sleep(10);
}
cvReleaseCapture(&capture);
{ /* Hangup */
TOXAV_ERR_CALL_CONTROL rc;
toxav_call_control(AliceAV, 0, TOXAV_CALL_CONTROL_CANCEL, &rc);
if (rc != TOXAV_ERR_CALL_CONTROL_OK) {
printf("toxav_call_control failed: %d\n", rc);
exit(1);
}
}
iterate_tox(bootstrap, AliceAV, BobAV, nullptr);
assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED);
/* Stop decode thread */
printf("Stopping decode thread\n");
data.sig = -1;
while (data.sig != 1) {
sched_yield();
}
printf("Success!");
}
Tox *Alice = toxav_get_tox(AliceAV);
Tox *Bob = toxav_get_tox(BobAV);
toxav_kill(BobAV);
toxav_kill(AliceAV);
tox_kill(Bob);
tox_kill(Alice);
tox_kill(bootstrap);
printf("\nTest successful!\n");
Pa_Terminate();
return 0;
}
| 28.151332 | 123 | 0.583538 |
a666892e85da2ab2f3221b4c1a63d5703581abf6 | 2,826 | c | C | src/oneShot/hacTreeTest/hacTreeTest.c | andypohl/kent | af7a004c8f3fa909cd8c2cfc2e5bea60e3421cd1 | [
"MIT"
] | 171 | 2015-04-22T15:16:02.000Z | 2022-03-18T20:21:53.000Z | src/oneShot/hacTreeTest/hacTreeTest.c | andypohl/kent | af7a004c8f3fa909cd8c2cfc2e5bea60e3421cd1 | [
"MIT"
] | 60 | 2016-10-03T15:15:06.000Z | 2022-03-30T15:21:52.000Z | src/oneShot/hacTreeTest/hacTreeTest.c | andypohl/kent | af7a004c8f3fa909cd8c2cfc2e5bea60e3421cd1 | [
"MIT"
] | 80 | 2015-04-16T10:39:48.000Z | 2022-03-29T16:36:30.000Z | /* hacTreeTest - Test out various hacTree code. */
#include "common.h"
#include "linefile.h"
#include "hash.h"
#include "options.h"
#include "hacTree.h"
#include "pthreadDoList.h"
char* clHacTree = "fromItems";
int clThreads = 10;
void usage()
/* Explain usage and exit. */
{
errAbort(
"hacTreeTest - Test out various hacTree code\n"
"usage:\n"
" hacTreeTest XXX\n"
"options:\n"
" -hacTree = Dictates how the tree is generated; multiThreads or fromItems. fromItems is default \n"
" -threads - number of threads to use for multiThread default %d\n"
, clThreads
);
}
/* Command line validation table. */
static struct optionSpec options[] = {
{"threads", OPTION_INT},
{"hacTree", OPTION_STRING},
{NULL, 0},
};
void rDump(struct hacTree *ht, int level, FILE *f)
/* Help dump out results */
{
spaceOut(f, level*2);
struct slDouble *el = (struct slDouble *)ht->itemOrCluster;
if (ht->left || ht->right)
{
fprintf(f, "(%g %g)\n", el->val, ht->childDistance);
rDump(ht->left, level+1, f);
rDump(ht->right, level+1, f);
}
else
fprintf(f, "%g\n", el->val);
}
double dblDistance(const struct slList *item1, const struct slList *item2, void *extraData)
{
struct slDouble *i1 = (struct slDouble *)item1;
struct slDouble *i2 = (struct slDouble *)item2;
double d = fabs(i1->val - i2->val);
verbose(2, "dblDistance %g %g = %g\n", i1->val, i2->val, d);
return d;
}
struct slList *dblMerge(const struct slList *item1, const struct slList *item2,
void *extraData)
{
struct slDouble *i1 = (struct slDouble *)item1;
struct slDouble *i2 = (struct slDouble *)item2;
double d = 0.5 * (i1->val + i2->val);
verbose(2, "dblMerge %g %g = %g\n", i1->val, i2->val, d);
return (struct slList *)slDoubleNew(d);
}
void hacTreeTest(char *output)
/* hacTreeTest - Test out various hacTree code. */
{
FILE *f = mustOpen(output, "w");
int i;
/* Make up list of random numbers */
struct slDouble *list = NULL;
double data[] = {1,2, 4,5, 6,7, 11,15, 22,24};
for (i=0; i<10; ++i)
{
struct slDouble *el = slDoubleNew(data[i]);
slAddHead(&list, el);
}
struct lm *lm = lmInit(0);
struct hacTree *ht = NULL;
if (sameString(clHacTree, "multiThreads"))
{
ht = hacTreeMultiThread(clThreads, (struct slList *)list, lm, dblDistance, dblMerge,
NULL, NULL);
}
else if (sameString(clHacTree, "fromItems"))
{
ht = hacTreeFromItems((struct slList *)list, lm, dblDistance, dblMerge, NULL, NULL);
}
else
{
uglyAbort("Unrecognized input option: %s", clHacTree);
}
rDump(ht, 0, f);
carefulClose(&f);
}
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
if (argc != 2)
usage();
clHacTree = optionVal("hacTree", clHacTree);
clThreads = optionInt("threads", clThreads);
hacTreeTest(argv[1]);
return 0;
}
| 24.573913 | 105 | 0.650743 |
32bf2208a1dfa060cd63f8905d324857c7290d01 | 1,007 | c | C | user/biscuit/c/fstest.c | pdeantihuman/rcore-fork | c27736422f5c6dbb1d2224b8b0e2261988d6e650 | [
"MIT"
] | null | null | null | user/biscuit/c/fstest.c | pdeantihuman/rcore-fork | c27736422f5c6dbb1d2224b8b0e2261988d6e650 | [
"MIT"
] | null | null | null | user/biscuit/c/fstest.c | pdeantihuman/rcore-fork | c27736422f5c6dbb1d2224b8b0e2261988d6e650 | [
"MIT"
] | null | null | null | #include <common.h>
static char buf[1024];
void readprint(int fd)
{
long ret;
if ((ret = read(fd, &buf, sizeof(buf))) < 0) {
err(ret, "read");
exit(-1);
}
printf("FD %d read %ld bytes\n", fd, ret);
if (ret == sizeof(buf))
ret = sizeof(buf) - 1;
buf[ret] = '\0';
printf("FD %d returned: %s\n", fd, buf);
}
int main(int argc, char **argv)
{
int ret;
if ((ret = open("/etc/passwd", O_RDONLY, 0)) >= 0) {
errx(-1, "open should fail");
return -1;
}
if ((ret = open("/hi.txt", O_RDONLY, 0)) < 0) {
err(ret, "open");
return -1;
}
int fd1 = ret;
if ((ret = open("/boot/uefi/readme.txt", O_RDONLY, 0)) < 0) {
err(ret, "open");
return -1;
}
int fd2 = ret;
if ((ret = open("/clouseau.txt", O_RDONLY, 0)) < 0) {
err(ret, "open");
return -1;
}
int fd3 = ret;
if ((ret = open("/boot/bsd", O_RDONLY, 0)) < 0) {
err(ret, "open");
return -1;
}
int fd4 = ret;
readprint(fd1);
readprint(fd2);
readprint(fd3);
readprint(fd4);
printf("FS TESTS PASSED!\n");
return 0;
}
| 18.309091 | 62 | 0.552135 |
8ed3923a85bd1d1650081bc55f0a00e04e1997fb | 378 | h | C | lua_addon/lua_screen.h | reverendhomer/OpenGTA | addd5e219314c32ecd7103a66f5dc4f5a6324182 | [
"MIT"
] | null | null | null | lua_addon/lua_screen.h | reverendhomer/OpenGTA | addd5e219314c32ecd7103a66f5dc4f5a6324182 | [
"MIT"
] | null | null | null | lua_addon/lua_screen.h | reverendhomer/OpenGTA | addd5e219314c32ecd7103a66f5dc4f5a6324182 | [
"MIT"
] | null | null | null | #ifndef LUA_OGTA_SCREEN_H
#define LUA_OGTA_SCREEN_H
#include "gl_screen.h"
#include "lua.hpp"
namespace OpenGTA {
namespace Script {
class Screen {
public:
static int getFullscreen(lua_State *L);
static int setFullscreen(lua_State *L);
static int makeScreenShot(lua_State *L);
static const luaL_Reg methods[];
};
}
}
#endif
| 18 | 48 | 0.666667 |
508e388348d664e23e2ab4eaef93f55344eb3c4f | 769 | h | C | product/tc0/include/tc0_core.h | iwishguo/SCP-firmware | 85d038227bb3553965703ee19d7328cf7e157e81 | [
"BSD-3-Clause"
] | null | null | null | product/tc0/include/tc0_core.h | iwishguo/SCP-firmware | 85d038227bb3553965703ee19d7328cf7e157e81 | [
"BSD-3-Clause"
] | null | null | null | product/tc0/include/tc0_core.h | iwishguo/SCP-firmware | 85d038227bb3553965703ee19d7328cf7e157e81 | [
"BSD-3-Clause"
] | 1 | 2020-11-04T04:36:51.000Z | 2020-11-04T04:36:51.000Z | /*
* Arm SCP/MCP Software
* Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef TC0_CORE_H
#define TC0_CORE_H
#include <fwk_assert.h>
#define TC0_CORE_PER_CLUSTER_MAX 4
#define CORES_PER_CLUSTER 4
#define NUMBER_OF_CLUSTERS 1
static inline unsigned int tc0_core_get_cluster_count(void)
{
return NUMBER_OF_CLUSTERS;
}
static inline unsigned int tc0_core_get_core_per_cluster_count(
unsigned int cluster)
{
fwk_assert(cluster < tc0_core_get_cluster_count());
return CORES_PER_CLUSTER;
}
static inline unsigned int tc0_core_get_core_count(void)
{
return tc0_core_get_core_per_cluster_count(0) *
tc0_core_get_cluster_count();
}
#endif /* TC0_CORE_H */
| 20.236842 | 73 | 0.762029 |
742237332849854bbb987054fa8982a60cbbdc56 | 11,827 | h | C | include/_antic.h | karrika/cc65 | 2314cddb5a846fb526032525950058e086e9000c | [
"Zlib"
] | null | null | null | include/_antic.h | karrika/cc65 | 2314cddb5a846fb526032525950058e086e9000c | [
"Zlib"
] | null | null | null | include/_antic.h | karrika/cc65 | 2314cddb5a846fb526032525950058e086e9000c | [
"Zlib"
] | null | null | null | /*****************************************************************************/
/* */
/* _antic.h */
/* */
/* Internal include file, do not use directly */
/* */
/* */
/* "ANTIC, Alphanumeric Television Interface Controller, is responsible for */
/* the generation of playfield graphics which is delivered as a datastream */
/* to the related CTIA/GTIA chip. The CTIA/GTIA provides the coloring of the */
/* playfield graphics, and is responsible for adding overlaid sprite */
/* (referred to as "Player/Missile graphics" by Atari). Atari advertised it */
/* as a true microprocessor, in that it has an instruction set to run */
/* programs (called display lists) to process data. ANTIC has no capacity */
/* for writing back computed values to memory, it merely reads data from */
/* memory and processes it for output to the screen, therefore it is not */
/* Turing complete." - Wikipedia article on "ANTIC" (with edits) */
/* */
/* (C) 2000 Freddy Offenga <taf_offenga@yahoo.com> */
/* 24-Jan-2011: Christian Krueger: Added defines for Antic instruction set */
/* 2019-01-16: Bill Kendrick <nbs@sonic.net>: More defines for registers */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#ifndef __ANTIC_H
#define __ANTIC_H
/*****************************************************************************/
/* Define a structure with the ANTIC coprocessor's register offsets */
/*****************************************************************************/
struct __antic {
unsigned char dmactl; /* (W) direct memory access control */
unsigned char chactl; /* (W) character mode control */
unsigned char dlistl; /* display list pointer low-byte */
unsigned char dlisth; /* display list pointer high-byte */
unsigned char hscrol; /* (W) horizontal scroll enable */
unsigned char vscrol; /* (W) vertical scroll enable */
unsigned char unuse0; /* unused */
unsigned char pmbase; /* (W) msb of p/m base address (for when DMACTL has player and/or missile DMA enabled) */
unsigned char unuse1; /* unused */
unsigned char chbase; /* (W) msb of character set base address */
unsigned char wsync; /* (W) wait for horizontal synchronization */
unsigned char vcount; /* (R) vertical line counter */
unsigned char penh; /* (R) light pen horizontal position */
unsigned char penv; /* (R) light pen vertical position */
unsigned char nmien; /* (W) non-maskable interrupt enable */
union {
/* (W) ("NMIRES") nmi reset -- clears the interrupt request register;
** resets all of the NMI status together
*/
unsigned char nmires;
/* (R) ("NMIST") nmi status -- holds cause for the NMI interrupt */
unsigned char nmist;
};
};
/*****************************************************************************/
/* DMACTL register options */
/*****************************************************************************/
/* Initialized to 0x22: DMA fetch, normal playfield, no PMG DMA, double-line PMGs */
/* Playfield modes: */
#define DMACTL_PLAYFIELD_NONE 0x00
#define DMACTL_PLAYFIELD_NARROW 0x01 /* e.g., 32 bytes per scanline with thick borders */
#define DMACTL_PLAYFIELD_NORMAL 0x02 /* e.g., 40 bytes per scanline with normal borders */
#define DMACTL_PLAYFIELD_WIDE 0x03 /* e.g., 48 bytes per scanline with no borders (overscan) */
/* Other options: */
/* If not set, GTIA's GRAFP0 thru GRAFP3, and/or GRAFM registers are used for
** player & missile shapes, respectively. (Modify the registers during the horizontal blank
** (Display List Interrupt), a la "racing the beam" on an Atari VCS/2600, )
** if set, ANTIC's PMBASE will be used to fetch shapes from memory via DMA.
*/
#define DMACTL_DMA_MISSILES 0x04
#define DMACTL_DMA_PLAYERS 0x08
/* Unless set, PMGs (as fetched via DMA) will be double-scanline resolution */
#define DMACTL_PMG_SINGLELINE 0x10
/* Unless set, ANTIC operation is disabled, since it cannot fetch
** Display List instructions
*/
#define DMACTL_DMA_FETCH 0x20
/*****************************************************************************/
/* CHACTL register options */
/*****************************************************************************/
/* Initialized to 2 (CHACTL_CHAR_NORMAL | CHACTL_INV_PRESENT) */
/* Inverted (upside-down) characters */
#define CHACTL_CHAR_NORMAL 0x00
#define CHACTL_CHAR_INVERTED 0x04
/* Inverse (reverse-video) characters */
#define CHACTL_INV_TRANS 0x00 /* chars with high-bit shown */
#define CHACTL_INV_OPAQUE 0x01 /* chars with high-bit appear as space */
#define CHACTL_INV_PRESENT 0x02 /* chars with high-bit are reverse-video */
/*****************************************************************************/
/* Values for NMIEN (enabling interrupts) & NMIST (cause for the interrupt) */
/*****************************************************************************/
/* Display List Interrupts
** Called on a modeline when "DL_DLI" bit is set the ANTIC instruction,
** and jumps through VDSLST vector.
*/
#define NMIEN_DLI 0x80
/* Vertical Blank Interrupt
** Called during every vertical blank; see SYSVBV, VVBLKI, CRITIC, and VVBLKD,
** as well as the SETVBV routine.
*/
#define NMIEN_VBI 0x40
/* [Reset] key pressed */
#define NMIEN_RESET 0x20
/*****************************************************************************/
/* ANTIC instruction set */
/*****************************************************************************/
/* Absolute instructions (non mode lines) */
#define DL_JMP ((unsigned char) 1)
#define DL_JVB ((unsigned char) 65)
#define DL_BLK1 ((unsigned char) 0) /* 1 blank scanline */
#define DL_BLK2 ((unsigned char) 16) /* 2 blank scanlines */
#define DL_BLK3 ((unsigned char) 32) /* ...etc. */
#define DL_BLK4 ((unsigned char) 48)
#define DL_BLK5 ((unsigned char) 64)
#define DL_BLK6 ((unsigned char) 80)
#define DL_BLK7 ((unsigned char) 96)
#define DL_BLK8 ((unsigned char) 112)
/* Absolute instructions (mode lines) */
/* Note: Actual width varies (e.g., 40 vs 32 vs 48) depending on
** normal vs narrow vs wide (overscan) playfield setting; see DMACTL
*/
/* Character modes (text, tile graphics, etc.) */
/* monochrome, 40 character & 8 scanlines per mode line (aka Atari BASIC GRAPHICS 0 via OS's CIO routines) */
#define DL_CHR40x8x1 ((unsigned char) 2)
/* monochrome, 40 character & 10 scanlines per mode line (like GR. 0, with descenders) */
#define DL_CHR40x10x1 ((unsigned char) 3)
/* colour, 40 character & 8 scanlines per mode line (GR. 12) */
#define DL_CHR40x8x4 ((unsigned char) 4)
/* colour, 40 character & 16 scanlines per mode line (GR. 13) */
#define DL_CHR40x16x4 ((unsigned char) 5)
/* colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) */
#define DL_CHR20x8x2 ((unsigned char) 6)
/* colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) */
#define DL_CHR20x16x2 ((unsigned char) 7)
/* Bitmap modes */
/* colour, 40 pixel & 8 scanlines per mode line (GR. 3) */
#define DL_MAP40x8x4 ((unsigned char) 8)
/* 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) */
#define DL_MAP80x4x2 ((unsigned char) 9)
/* colour, 80 pixel & 4 scanlines per mode line (GR.5) */
#define DL_MAP80x4x4 ((unsigned char) 10)
/* 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) */
#define DL_MAP160x2x2 ((unsigned char) 11)
/* 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) */
#define DL_MAP160x1x2 ((unsigned char) 12)
/* 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) */
#define DL_MAP160x2x4 ((unsigned char) 13)
/* 4 colours, 160 pixel & 1 scanline per mode line (GR.15) */
#define DL_MAP160x1x4 ((unsigned char) 14)
/* monochrome, 320 pixel & 1 scanline per mode line (GR.8) */
#define DL_MAP320x1x1 ((unsigned char) 15)
/* Equivalents, for people familiar with Atari 8-bit OS */
#define DL_GRAPHICS0 DL_CHR40x8x1
#define DL_GRAPHICS1 DL_CHR20x8x2
#define DL_GRAPHICS2 DL_CHR20x16x2
#define DL_GRAPHICS3 DL_MAP40x8x4
#define DL_GRAPHICS4 DL_MAP80x4x2
#define DL_GRAPHICS5 DL_MAP80x4x4
#define DL_GRAPHICS6 DL_MAP160x2x2
#define DL_GRAPHICS7 DL_MAP160x2x4
#define DL_GRAPHICS8 DL_MAP320x1x1
#define DL_GRAPHICS9 DL_MAP320x1x1 /* N.B.: GRAPHICS 9, 10, and 11 also involve GTIA's PRIOR register */
#define DL_GRAPHICS10 DL_MAP320x1x1
#define DL_GRAPHICS11 DL_MAP320x1x1
#define DL_GRAPHICS12 DL_CHR40x8x4 /* N.B.: Atari 400/800 OS didn't have GRAPHICS 12 or 13 */
#define DL_GRAPHICS13 DL_CHR40x16x4
#define DL_GRAPHICS14 DL_MAP160x1x2
#define DL_GRAPHICS15 DL_MAP160x1x4
/* Atari 400/800 OS didn't have GRAPHICS 14 or 15, so they were known by "6+" and "7+" */
#define DL_GRAPHICS6PLUS DL_GRAPHICS14
#define DL_GRAPHICS7PLUS DL_GRAPHICS15
/* Neither Atari 400/800 nor XL OS supported 10-scanline (descenders) text mode via CIO */
#define DL_GRAPHICS0_DESCENDERS DL_CHR40x10x1
/* Modifiers to mode lines */
#define DL_HSCROL(x) ((unsigned char)((x) | 16)) /* enable smooth horizontal scrolling on this line; see HSCROL */
#define DL_VSCROL(x) ((unsigned char)((x) | 32)) /* enable smooth vertical scrolling on this line; see VSCROL */
#define DL_LMS(x) ((unsigned char)((x) | 64)) /* Load Memory Scan (next two bytes must be the LSB/MSB of the data to load) */
/* General modifier */
#define DL_DLI(x) ((unsigned char)((x) | 128)) /* enable Display List Interrupt on this mode line */
/* End of _antic.h */
#endif /* #ifndef __ANTIC_H */
| 46.380392 | 131 | 0.567938 |
1f866d6caa779b4d31aaf65715c0dc00a702fcd1 | 5,425 | c | C | dev_scripts/wokni/init_wokni.c | Sandeep-Sarma/ngic-rtc | d65e86595d03c4786ce9e6380f2e0d64c6f1db33 | [
"Apache-2.0"
] | null | null | null | dev_scripts/wokni/init_wokni.c | Sandeep-Sarma/ngic-rtc | d65e86595d03c4786ce9e6380f2e0d64c6f1db33 | [
"Apache-2.0"
] | null | null | null | dev_scripts/wokni/init_wokni.c | Sandeep-Sarma/ngic-rtc | d65e86595d03c4786ce9e6380f2e0d64c6f1db33 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2017 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <rte_lcore.h>
#include <rte_per_lcore.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include "main.h"
/**
* RX_NUM_DESC < 1024:
* Increased sensivity kernel packet processing core sched jitters
*/
#define RX_NUM_DESC 2048
/**
* macro to config tx ring size.
*/
#define TX_NUM_DESC (RX_NUM_DESC*1) /* TX_NUM_DESC = 2048 */
/**
* DPDK default value optimial.
*/
#define MBUF_CACHE_SIZE 512
/**
* NUM_MBUFS >= 2x RX_NUM_DESC::
* Else rte_eth_dev_start(...) { FAIL; ...}
* NUM_MBUFS >= 1.5x MBUF_CACHE_SIZE::
* Else rte_pktmbuf_pool_create(...) { FAIL; ...}
*/
/*#define NUM_MBUFS (TX_NUM_DESC*2) */ /* 2048, (TX_NUM_DESC*2) */ /* NUM_MBUFS = 4096 */
#define NUM_MBUFS (TX_NUM_DESC*2) > (1.5 * MBUF_CACHE_SIZE) ? \
(TX_NUM_DESC*2) : (2 * MBUF_CACHE_SIZE)
/**
* default port config structure .
*/
const struct rte_eth_conf port_conf_default = {
.rxmode = {
.max_rx_pkt_len = ETHER_MAX_LEN,
.offloads =
DEV_RX_OFFLOAD_IPV4_CKSUM |
DEV_RX_OFFLOAD_UDP_CKSUM |
DEV_RX_OFFLOAD_TCP_CKSUM |
DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
DEV_RX_OFFLOAD_CRC_STRIP,
/* Enable hw_crc_strip for PF/VF drivers */
.hw_strip_crc = 1}
};
/**
* Function to Initialize a given port using global settings and with the rx
* buffers coming from the mbuf_pool passed as parameter
* @param port
* port number.
* @param mbuf_pool
* memory pool pointer.
*
* @return
* - 0 on success
* - -1 on failure
*/
static inline int port_init(uint8_t port, struct rte_mempool *mbuf_pool)
{
struct rte_eth_conf port_conf = port_conf_default;
// const uint16_t rx_rings = 1, tx_rings = 1; //tx_rings = rte_lcore_count() - 1;
/* ASR- TST_Probe: tx_rings = 2 */
const uint16_t rx_rings = 1, tx_rings = 2; //tx_rings = rte_lcore_count() - 1;
int retval;
uint16_t q;
if (port >= rte_eth_dev_count())
return -1;
/* TODO: use q 1 for arp */
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
return retval;
/* Allocate and set up RX queue per Ethernet port. */
for (q = 0; q < rx_rings; q++) {
retval = rte_eth_rx_queue_setup(port, q, RX_NUM_DESC,
rte_eth_dev_socket_id(port),
NULL, mbuf_pool);
if (retval < 0)
return retval;
}
/* Allocate and set up TX queue per Ethernet port. */
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, TX_NUM_DESC,
rte_eth_dev_socket_id(port),
NULL);
if (retval < 0)
return retval;
}
/* Start the Ethernet port. */
retval = rte_eth_dev_start(port);
if (retval < 0)
return retval;
/* Display the port MAC address. */
rte_eth_macaddr_get(port, &ports_eth_addr[port]);
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
(unsigned)port,
ports_eth_addr[port].addr_bytes[0],
ports_eth_addr[port].addr_bytes[1],
ports_eth_addr[port].addr_bytes[2],
ports_eth_addr[port].addr_bytes[3],
ports_eth_addr[port].addr_bytes[4],
ports_eth_addr[port].addr_bytes[5]);
/* Enable RX in promiscuous mode for the Ethernet device. */
/* rte_eth_promiscuous_enable(port); */
rte_eth_promiscuous_disable(port);
return 0;
}
void dp_port_init(void)
{
struct rte_mempool *s1u_mempool;
struct rte_mempool *sgi_mempool;
uint32_t nb_ports;
enum {
S1U_PORT = 0,
SGI_PORT = 1
};
nb_ports = rte_eth_dev_count();
if (nb_ports < 2 || (nb_ports & 1))
rte_exit(EXIT_FAILURE, "Error: number of ports must be two\n");
printf("ASR Trace:%s::"
"\n\tRX_NUM_DESC= %d; TX_NUM_DESC= %d;"
"\n\tNUM_MBUFS=%d; MBUF_CACHE_SIZE=%d;"
"\n\tRTE_MBUF_DEFAULT_BUF_SIZE=%d\n",
__func__,
RX_NUM_DESC, TX_NUM_DESC,
NUM_MBUFS, MBUF_CACHE_SIZE,
RTE_MBUF_DEFAULT_BUF_SIZE);
/* Create S1U mempool to hold the mbufs. */
s1u_mempool = rte_pktmbuf_pool_create("S1U_MPOOL", NUM_MBUFS,
MBUF_CACHE_SIZE, 0,
RTE_MBUF_DEFAULT_BUF_SIZE,
rte_socket_id());
if (s1u_mempool == NULL)
rte_exit(EXIT_FAILURE, "Cannot create s1u_mempool !!!\n");
/* Create SGi mempool to hold the mbufs. */
sgi_mempool = rte_pktmbuf_pool_create("SGI_MPOOL", NUM_MBUFS,
MBUF_CACHE_SIZE, 0,
RTE_MBUF_DEFAULT_BUF_SIZE,
rte_socket_id());
if (sgi_mempool == NULL)
rte_exit(EXIT_FAILURE, "Cannot create sgi_mempool !!!\n");
/* Initialize S1U & SGi ports. */
if (port_init(S1U_PORT, s1u_mempool) != 0)
rte_exit(EXIT_FAILURE, "Cannot init s1u port %" PRIu8 "\n",
S1U_PORT);
if (port_init(SGI_PORT, sgi_mempool) != 0)
rte_exit(EXIT_FAILURE, "Cannot init s1u port %" PRIu8 "\n",
SGI_PORT);
printf("DP Port initialization completed.\n");
}
| 28.108808 | 90 | 0.686083 |
1f89cfc0e110849974fac9eb9b283f0f468b7aa9 | 2,241 | c | C | driver/misc/drv_fan.c | derek-yi/xdaemon | 38f6e26c03215f221dfffdade7bb92651c6122f4 | [
"MIT"
] | null | null | null | driver/misc/drv_fan.c | derek-yi/xdaemon | 38f6e26c03215f221dfffdade7bb92651c6122f4 | [
"MIT"
] | null | null | null | driver/misc/drv_fan.c | derek-yi/xdaemon | 38f6e26c03215f221dfffdade7bb92651c6122f4 | [
"MIT"
] | null | null | null |
#include "daemon_pub.h"
#include "drv_main.h"
#include "drv_cpu.h"
#include "drv_fpga.h"
uint32 FAN_PWM_CTRL=0x43c30258;
uint32 FAN_T_BDRY=0x43c3025c;
uint32 FAN_T_CTRL=0x43c30260;
uint32 FAN_T_THRESHOLD=0x43c30264;
uint32 FAN_TEMPRATURE=0x43c30268;
uint32 FAN_RPS=0x43c3026c;
uint32 FAN_RPS1=0x43c30270;
uint32 FAN_RPS2=0x43c30274;
uint32 FAN_RT_TR=0x43c30278;
uint32 FAN_FW_TEMP=0x43c30280;
//uint32 SYS_STATE_BASE=0x43c30240;
uint32 pwm_max=125;
uint32 pwm_min=15;
uint32 pwm_step=11;
uint32 pwm_n_step=10;
uint32 t_max=358; //#80 `echo "scale=0; (80+273.15)*4096/503.975/8" | bc`
uint32 t_min=338; //#60 `echo "scale=0; (60+273.15)*4096/503.975/8" | bc`
uint32 t_step=2;
uint32 t_tolerance=2;
uint32 t_thr_up=3;
uint32 t_thr_down=3;
//function FAN_PWM_SET()
//function FAN_T_SET()
int drv_fan_init(void)
{
uint32 tmp;
//tmp=$((${pwm_n_step} | (${pwm_step}<<8) | (${pwm_min}<<16) | (${pwm_max}<<24)))
//devmem $FAN_PWM_CTRL 32 $tmp
tmp = pwm_n_step | (pwm_step << 8) | (pwm_min << 16) | (pwm_max << 24);
fpga_write(FAN_PWM_CTRL, tmp);
//tmp=$(((${t_max}<<16) | ${t_min}))
//devmem $FAN_T_BDRY 32 $tmp
tmp = (t_max << 16) | t_min;
fpga_write(FAN_T_BDRY, tmp);
//tmp=$(((${t_step}<<16) | ${t_tolerance}))
//devmem $FAN_T_CTRL 32 $tmp
tmp = (t_step << 16) | t_tolerance;
fpga_write(FAN_T_CTRL, tmp);
//tmp=$(((${t_thr_up}<<16) | ${t_thr_down}))
//devmem $FAN_T_THRESHOLD 32 $tmp
tmp = (t_thr_up << 16) | t_thr_down;
fpga_write(FAN_T_THRESHOLD, tmp);
return VOS_OK;
}
/* fan.sh
tmp=`devmem $FAN_RPS 32` //0x43c3026c
fan1=$(( ($tmp & 0xffff) ))
fan2=$(( ($tmp>>16) ))
fan1=`echo "scale=0; ($fan1*100)/320" | bc`
fan2=`echo "scale=0; ($fan2*100)/320" | bc`
*/
int drv_fan_get_speed(int fan_id, int *ret_value)
{
int reg_val;
int speed;
if (fan_id < 0 || fan_id >= SYS_MAX_FAN_ID) return VOS_ERR;
if (ret_value == NULL) return VOS_ERR;
reg_val = (int)fpga_read(FAN_RPS);
if (fan_id == 0) speed = reg_val & 0xffff;
else speed = reg_val >> 16;
speed = (speed*100)/320;
*ret_value = speed;
return VOS_OK;
}
| 26.05814 | 86 | 0.622044 |
941dbaac7f761753fb0da6d7db1073cfaf611f1f | 693 | h | C | Pods/AerisWeather/AerisWeatherSDK/Aeris.framework/Versions/A/Headers/AWFPrecipitationPeriod.h | spacedrabbit/CatAerisWeatherDemo | 7d6563a9dd0d33f1f8583b44abac01ca53b84517 | [
"MIT"
] | null | null | null | Pods/AerisWeather/AerisWeatherSDK/Aeris.framework/Versions/A/Headers/AWFPrecipitationPeriod.h | spacedrabbit/CatAerisWeatherDemo | 7d6563a9dd0d33f1f8583b44abac01ca53b84517 | [
"MIT"
] | null | null | null | Pods/AerisWeather/AerisWeatherSDK/Aeris.framework/Versions/A/Headers/AWFPrecipitationPeriod.h | spacedrabbit/CatAerisWeatherDemo | 7d6563a9dd0d33f1f8583b44abac01ca53b84517 | [
"MIT"
] | null | null | null | //
// AWFPrecipitationPeriod.h
// Aeris
//
// Created by Nicholas Shipes on 4/5/16.
// Copyright © 2016 Aeris Weather, LLC. All rights reserved.
//
#import <Aeris/AWFGeographicObject.h>
@interface AWFPrecipitationPeriod : AWFGeographicObject
/**
* Date the period is for.
*/
@property (strong, nonatomic) NSDate *timestamp;
@property (strong, nonatomic) NSTimeZone *timeZone;
@property (strong, nonatomic) NSNumber *dailyIN;
@property (strong, nonatomic) NSNumber *dailyMM;
@property (strong, nonatomic) NSNumber *monthlyIN;
@property (strong, nonatomic) NSNumber *monthlyMM;
@property (strong, nonatomic) NSNumber *yearlyIN;
@property (strong, nonatomic) NSNumber *yearlyMM;
@end
| 25.666667 | 61 | 0.746032 |
e3b35cf21eab6dad15ddb8eb9d359b0821e8426b | 4,371 | h | C | third-party/webscalesqlclient/mysql-5.6/storage/rocksdb/properties_collector.h | hkirsman/hhvm_centos7_builds | 2a1fd6de0d2d289c1575f43f10018f3bec23bb13 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | third-party/webscalesqlclient/mysql-5.6/storage/rocksdb/properties_collector.h | hkirsman/hhvm_centos7_builds | 2a1fd6de0d2d289c1575f43f10018f3bec23bb13 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | third-party/webscalesqlclient/mysql-5.6/storage/rocksdb/properties_collector.h | hkirsman/hhvm_centos7_builds | 2a1fd6de0d2d289c1575f43f10018f3bec23bb13 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | /*
Copyright (c) 2015, Facebook, Inc.
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 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef PROPERTIES_COLLECTOR_H
#define PROPERTIES_COLLECTOR_H
/* C++ system header files */
#include <map>
#include <memory>
#include <unordered_set>
#include <vector>
/* RocksDB header files */
#include "rocksdb/db.h"
/* MyRocks header files */
#include "./ha_rocksdb.h"
class Table_ddl_manager;
class RDBSE_KEYDEF;
extern uint64_t rocksdb_num_sst_entry_put;
extern uint64_t rocksdb_num_sst_entry_delete;
extern uint64_t rocksdb_num_sst_entry_singledelete;
extern uint64_t rocksdb_num_sst_entry_merge;
extern uint64_t rocksdb_num_sst_entry_other;
struct CompactionParams {
uint64_t deletes_, window_, file_size_;
};
class MyRocksTablePropertiesCollector
: public rocksdb::TablePropertiesCollector {
public:
struct IndexStats {
enum {
INDEX_STATS_VERSION= 1,
};
GL_INDEX_ID gl_index_id;
int64_t data_size, rows, approximate_size;
std::vector<int64_t> distinct_keys_per_prefix;
std::string name; // name is not persisted
static std::string materialize(std::vector<IndexStats>);
static int unmaterialize(const std::string& s, std::vector<IndexStats>&);
IndexStats() : IndexStats({0, 0}) {}
explicit IndexStats(GL_INDEX_ID _gl_index_id) :
gl_index_id(_gl_index_id),
data_size(0),
rows(0),
approximate_size(0) {}
void merge(const IndexStats& s);
};
MyRocksTablePropertiesCollector(
Table_ddl_manager* ddl_manager,
CompactionParams params,
uint32_t cf_id
);
virtual rocksdb::Status AddUserKey(
const rocksdb::Slice& key, const rocksdb::Slice& value,
rocksdb::EntryType type, rocksdb::SequenceNumber seq,
uint64_t file_size);
virtual rocksdb::Status Finish(rocksdb::UserCollectedProperties* properties) override;
virtual const char* Name() const override {
return "MyRocksTablePropertiesCollector";
}
static std::string
GetReadableStats(const MyRocksTablePropertiesCollector::IndexStats& it);
rocksdb::UserCollectedProperties GetReadableProperties() const override;
static std::vector<IndexStats> GetStatsFromTableProperties(
const std::shared_ptr<const rocksdb::TableProperties>& table_props
);
static void GetStats(
const rocksdb::TablePropertiesCollection& collection,
const std::unordered_set<GL_INDEX_ID>& index_numbers,
std::map<GL_INDEX_ID, MyRocksTablePropertiesCollector::IndexStats>& stats
);
bool NeedCompact() const;
uint64_t GetMaxDeletedRows() const {
return max_deleted_rows_;
}
private:
uint32_t cf_id_;
std::unique_ptr<RDBSE_KEYDEF> keydef_;
Table_ddl_manager* ddl_manager_;
std::vector<IndexStats> stats_;
static const char* INDEXSTATS_KEY;
// last added key
std::string last_key_;
// floating window to count deleted rows
std::vector<bool> deleted_rows_window_;
uint64_t rows_, deleted_rows_, max_deleted_rows_;
uint64_t file_size_;
CompactionParams params_;
};
class MyRocksTablePropertiesCollectorFactory
: public rocksdb::TablePropertiesCollectorFactory {
public:
explicit MyRocksTablePropertiesCollectorFactory(
Table_ddl_manager* ddl_manager
) : ddl_manager_(ddl_manager) {
}
virtual rocksdb::TablePropertiesCollector* CreateTablePropertiesCollector(
rocksdb::TablePropertiesCollectorFactory::Context context) override {
return new MyRocksTablePropertiesCollector(
ddl_manager_, params_, context.column_family_id);
}
virtual const char* Name() const override {
return "MyRocksTablePropertiesCollectorFactory";
}
void SetCompactionParams(const CompactionParams& params) {
params_ = params;
}
private:
Table_ddl_manager* ddl_manager_;
CompactionParams params_;
};
#endif
| 29.533784 | 88 | 0.75795 |
e3fd4382c9b327d2ec97283bf989651059f20f5e | 1,560 | h | C | examples/complex/complex.h | anuragiitg/nixysa | e34b79b8c2bafafbdbdee21580ef9765d51b6c75 | [
"Apache-2.0"
] | 9 | 2015-03-23T17:34:49.000Z | 2021-10-16T22:54:16.000Z | examples/complex/complex.h | anuragiitg/nixysa | e34b79b8c2bafafbdbdee21580ef9765d51b6c75 | [
"Apache-2.0"
] | 1 | 2019-11-27T05:09:49.000Z | 2019-11-27T16:47:58.000Z | examples/complex/complex.h | anuragiitg/nixysa | e34b79b8c2bafafbdbdee21580ef9765d51b6c75 | [
"Apache-2.0"
] | 9 | 2015-12-06T20:42:16.000Z | 2022-03-31T09:27:55.000Z | // Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _NIXYSA_EXAMPLES_SIMPLE_COMPLEX_H_
#define _NIXYSA_EXAMPLES_SIMPLE_COMPLEX_H_
#include <math.h>
class Complex {
public:
Complex() : real_(0.f), imaginary_(0.f) { }
Complex(float real, float imaginary) : real_(real), imaginary_(imaginary) {}
float real() const { return real_; }
void set_real(float value) { real_ = value; }
float imaginary() const { return imaginary_; }
void set_imaginary(float value) { imaginary_ = value; }
float norm2() const { return real_*real_ + imaginary_*imaginary_; }
float norm() const { return sqrtf(norm2()); }
Complex add(const Complex &other) {
return Complex(real_ + other.real_, imaginary_ + other.imaginary_);
}
Complex mul(const Complex &other) {
return Complex(real_ * other.real_ - imaginary_ * other.imaginary_,
real_ * other.imaginary_ + imaginary_ * other.real_);
}
private:
float real_;
float imaginary_;
};
#endif // _NIXYSA_EXAMPLES_SIMPLE_COMPLEX_H_
| 31.836735 | 78 | 0.716667 |
2d9303481b613bdffeed8988bc74f46cc30972e8 | 1,321 | h | C | Core/SoarKernel/src/shared/triples.h | Bryan-Stearns/Soar | 969f4fec676293b459ed552ad096549519800534 | [
"BSD-2-Clause"
] | 1 | 2021-03-03T23:20:23.000Z | 2021-03-03T23:20:23.000Z | Core/SoarKernel/src/shared/triples.h | Bryan-Stearns/Soar | 969f4fec676293b459ed552ad096549519800534 | [
"BSD-2-Clause"
] | null | null | null | Core/SoarKernel/src/shared/triples.h | Bryan-Stearns/Soar | 969f4fec676293b459ed552ad096549519800534 | [
"BSD-2-Clause"
] | 1 | 2021-03-03T23:20:25.000Z | 2021-03-03T23:20:25.000Z | #ifndef CORE_SOARKERNEL_SRC_SHARED_TRIPLES_H_
#define CORE_SOARKERNEL_SRC_SHARED_TRIPLES_H_
#include "kernel.h"
typedef struct symbol_triple_struct
{
Symbol* id;
Symbol* attr;
Symbol* value;
symbol_triple_struct(Symbol* new_id = NULL, Symbol* new_attr = NULL, Symbol* new_value = NULL): id(new_id), attr(new_attr), value(new_value) {}
} symbol_triple;
typedef struct test_triple_struct
{
test id;
test attr;
test value;
test_triple_struct(test new_id = NULL, test new_attr = NULL, test new_value = NULL): id(new_id), attr(new_attr), value(new_value) {}
} test_triple;
typedef struct identity_triple_struct
{
uint64_t id;
uint64_t attr;
uint64_t value;
uint64_t referent;
identity_triple_struct(uint64_t new_id = 0, uint64_t new_attr = 0, uint64_t new_value = 0, uint64_t new_referent = 0): id(new_id), attr(new_attr), value(new_value), referent(new_referent) {}
} identity_triple;
typedef struct rhs_triple_struct
{
rhs_value id;
rhs_value attr;
rhs_value value;
rhs_triple_struct(rhs_value new_id = NULL, rhs_value new_attr = NULL, rhs_value new_value = NULL): id(new_id), attr(new_attr), value(new_value) {}
} rhs_triple;
#endif /* CORE_SOARKERNEL_SRC_SHARED_TRIPLES_H_ */
| 30.022727 | 198 | 0.701741 |
e17dac3fd69c338cb96e3f68f892c58f5ae9e7fd | 7,463 | h | C | cmd/CmdManager.h | dbonates/cmd | 30e8f2e3da0de47c9de3d15c652d87b8e27e38bd | [
"Unlicense",
"MIT"
] | 5 | 2017-11-21T15:57:26.000Z | 2017-12-03T03:45:05.000Z | cmd/CmdManager.h | dbonates/cmd | 30e8f2e3da0de47c9de3d15c652d87b8e27e38bd | [
"Unlicense",
"MIT"
] | null | null | null | cmd/CmdManager.h | dbonates/cmd | 30e8f2e3da0de47c9de3d15c652d87b8e27e38bd | [
"Unlicense",
"MIT"
] | null | null | null | //
// CmdManager.h
// cmd
//
// Created by Daniel Bonates on 10/11/17.
// Copyright © 2017 Daniel Bonates. All rights reserved.
//
#ifndef CmdManager_h
#define CmdManager_h
#endif /* CmdManager_h */
#import "Logger.h"
@interface CmdManager: NSObject
- (void)createDbFileIfNeeded;
@property (nonatomic, retain) NSString *dbFile;
@property (nonatomic, retain) NSString *aliasFile;
@property (nonatomic, retain) NSMutableDictionary *allCmds;
@end
@implementation CmdManager
@synthesize dbFile;
@synthesize allCmds;
- (NSString *)dbFile {
NSString *homeDir = NSHomeDirectory();
return [homeDir stringByAppendingString:@"/.cmd_db.plist"];
}
- (NSString *)aliasFile {
NSString *homeDir = NSHomeDirectory();
return [homeDir stringByAppendingString:@"/.db_cmd_alias"];
}
- (NSString *)bashProfileFile {
NSString *homeDir = NSHomeDirectory();
return [homeDir stringByAppendingString:@"/.bash_profile"];
}
- (NSString *)bashProfileFileForBackup {
NSString *homeDir = NSHomeDirectory();
NSString *bashfile_bkp = [NSString stringWithFormat: @"/.bash_profile_%@", [[NSProcessInfo processInfo] globallyUniqueString]];
return [homeDir stringByAppendingString:bashfile_bkp];
}
- (NSString *)injectString {
return @"source ~/.db_cmd_alias";
}
- (void)createDbFileIfNeeded {
NSFileManager *fm = [[NSFileManager alloc] init];
if(![fm fileExistsAtPath: self.dbFile]) {
NSDictionary *plist = [NSDictionary new];
BOOL success = [plist writeToFile:self.dbFile atomically:YES];
if (success) {
printf("db file created!");
} else {
printf("error creating plist");
}
}
if (self.allCmds == nil) {
NSMutableDictionary *cmds = [[NSMutableDictionary alloc] initWithContentsOfFile: self.dbFile];
self.allCmds = cmds != nil ? cmds : [NSMutableDictionary dictionary];
}
}
- (void)createAliasFileIfNeeded {
NSFileManager *fm = [[NSFileManager alloc] init];
if(![fm fileExistsAtPath: self.aliasFile]) {
NSError *error;
BOOL success = [@"" writeToFile:self.dbFile atomically:YES encoding:NSUTF8StringEncoding error: &error];
if (success) {
printf("alias file created!");
} else {
printf("error creating alias file");
}
}
}
- (int)saveCommandWithAlias:(NSString *)alias for:(NSString *)requestedCommand shouldOverride:(BOOL)shouldOverride {
if (![self validAlias: alias shouldExist: NO shouldOverride: shouldOverride]) {
return 1;
}
[Logger log:[NSString stringWithFormat: @"\nadding %s%@%s for %@...", KYEL, alias, KWHT, requestedCommand]];
// add new cmd
[self.allCmds setValue:requestedCommand forKey:alias];
if ([self updateShell] != 0) {
[Logger log: @"\nShell not updated. Try it running `cmd -u` at end.\n\n"];
}
return [self saveUpdatedCmds];
}
- (int)deleteCmdWithAlias: (NSString *)alias {
if (![self validAlias: alias shouldExist: YES shouldOverride:NO]) {
return 1;
}
[Logger log:[NSString stringWithFormat: @"\nremoving %s%@ %s...", KYEL, alias, KWHT]];
[self.allCmds removeObjectForKey: alias];
if ([self updateShell] != 0) {
[Logger log: @"\nShell not updated. Try it running `cmd -u` at end.\n\n"];
}
return [self saveUpdatedCmds];
}
- (int)updateShell {
__block NSString *cmdList = @"";
[allCmds enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL * stop) {
NSString *cmdInfo = [NSString stringWithFormat: @"alias %@='%@'\n", key, obj];
cmdList = [cmdList stringByAppendingString: cmdInfo];
}];
[self createAliasFileIfNeeded];
[self updateBashProfileIfNeeded];
NSError *error;
BOOL success = [cmdList writeToFile: self.aliasFile atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!success) {
[Logger log: @"\ncouldn't save alias file, exiting...\n"];
return 1;
}
[Logger log: @"\nalias file updated.\n\n"];
system("source ~/.bash_profile");
return 0;
}
- (void)updateBashProfileIfNeeded {
NSError *error;
NSString *bashProfileContents = [NSString stringWithContentsOfFile: [self bashProfileFile] encoding:NSUTF8StringEncoding error: &error];
if (error != nil) {
[Logger log: @"\nerror getting .bash_profile\n"];
return;
}
NSString *injectString = [self injectString];
if ([bashProfileContents rangeOfString:injectString].location == NSNotFound) {
BOOL success = [bashProfileContents writeToFile: [self bashProfileFileForBackup] atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!success) {
[Logger log: @"\ncouldn't backup .bash_profile file, too dangerous to continue, exiting...\n"];
return;
}
bashProfileContents = [bashProfileContents stringByAppendingString:[NSString stringWithFormat:@"\n%@\n", injectString]];
success = [bashProfileContents writeToFile:[self bashProfileFile] atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!success) {
[Logger log: @"\ncouldn't save .bash_profile file, too dangerous to continue, exiting...\n"];
return;
}
[Logger log: @"\n.bash_profile updated\n"];
}
}
- (int)saveUpdatedCmds {
BOOL success = [self.allCmds writeToFile: self.dbFile atomically:YES];
if (success) {
printf("\n%sdone!%s\n\n", KGRN, KWHT);
return 0;
} else {
printf("\n%serror updating plist%s\n\n", KGRN, KWHT);
return 1;
}
}
- (BOOL)validAlias: (NSString *)alias shouldExist:(BOOL)shouldExist shouldOverride:(BOOL)shouldOverride {
if (alias == Nil || alias.length < 1) {
[Logger printWrongParameters];
return NO;
}
BOOL aliasInUse = [[self.allCmds allKeys] containsObject: alias];
if (aliasInUse) {
if (shouldOverride) {
[self deleteCmdWithAlias:alias];
return YES;
}
if(shouldExist) { //should exist to proceed
return YES;
} else { // alias in use cannot do save operation
[Logger log: [NSString stringWithFormat:@"\nthe alias %s%@%s is already in use, please choose another.\n\n", KYEL, alias, KWHT]];
return NO;
}
} else {
if(shouldExist) { //should exist to proceed
[Logger log: [NSString stringWithFormat:@"\nthis alias %s%@%s doesn't exists.\n\n", KYEL, alias, KWHT]];
return NO;
}
}
// cmd already saved?
NSString *currentCommand = [[NSFileManager defaultManager] currentDirectoryPath];
if ([[self.allCmds allValues] containsObject: currentCommand]) {
NSString *keyForCmd = [[self.allCmds allKeysForObject: currentCommand] lastObject];
[Logger log: [NSString stringWithFormat: @"\nthis cmd was alread saved using alias %s%@%s.\n\n", KYEL, keyForCmd, KWHT]];
return NO;
}
return YES;
}
@end
| 27.039855 | 146 | 0.607262 |
4bfdaab6064b882535eb7f67871b18f2a3891e34 | 884 | c | C | 1-echo_shell.c | MarcoANT9/Shell_Backup | fe557e0f3e762f54e4a424701c541dd8d15c1a48 | [
"MIT"
] | null | null | null | 1-echo_shell.c | MarcoANT9/Shell_Backup | fe557e0f3e762f54e4a424701c541dd8d15c1a48 | [
"MIT"
] | null | null | null | 1-echo_shell.c | MarcoANT9/Shell_Backup | fe557e0f3e762f54e4a424701c541dd8d15c1a48 | [
"MIT"
] | null | null | null | #include "dragola.h"
/**
* _echo_shell - Emulates a simple shell.
*
* @argenv: Environment variables.
*
* Description - This program emulates a simple shell with its prompt which
* waits for the user to input a command.
*
* Return: Nothing (Void).
*
*/
void _echo_shell(char *argenv[])
{
int rdl;
char *buff, **name;
size_t bytes_read = 512;
buff = malloc(sizeof(char) * (512)); /** To store input */
if (buff == NULL)
return;
rdl = getline(&buff, &bytes_read, stdin);
if (rdl == -1)
{
write(STDOUT_FILENO, "\n", 1);
return;
}
name = _interpreter(buff);
if (name == NULL)
{
write(STDOUT_FILENO, "\n", 1);
free(buff);
return;
}
if (access(name[0], F_OK) == -1) /** If the PATH exits or not */
exe_path(name, 1, argenv);
else /** Execute if command with PATH is found */
exe_path(name, 0, argenv);
free(buff);
free(name);
}
| 19.217391 | 75 | 0.614253 |
ef0b6fdd5ca55f901a0fc4a33a84a6bb098504e1 | 23,292 | c | C | lib/dpdk-20.08/app/test/test_flow_classify.c | jhyunleehi/poseidonos | 1d90e4320855d61742ff37af8c0148da579d95d4 | [
"BSD-3-Clause"
] | null | null | null | lib/dpdk-20.08/app/test/test_flow_classify.c | jhyunleehi/poseidonos | 1d90e4320855d61742ff37af8c0148da579d95d4 | [
"BSD-3-Clause"
] | null | null | null | lib/dpdk-20.08/app/test/test_flow_classify.c | jhyunleehi/poseidonos | 1d90e4320855d61742ff37af8c0148da579d95d4 | [
"BSD-3-Clause"
] | null | null | null | /* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2017 Intel Corporation
*/
#include <string.h>
#include <errno.h>
#include "test.h"
#include <rte_string_fns.h>
#include <rte_mbuf.h>
#include <rte_byteorder.h>
#include <rte_ip.h>
#include <rte_acl.h>
#include <rte_common.h>
#include <rte_table_acl.h>
#include <rte_flow.h>
#include <rte_flow_classify.h>
#include "packet_burst_generator.h"
#include "test_flow_classify.h"
#define FLOW_CLASSIFY_MAX_RULE_NUM 100
#define MAX_PKT_BURST 32
#define NB_SOCKETS 4
#define MEMPOOL_CACHE_SIZE 256
#define MBUF_SIZE 512
#define NB_MBUF 512
/* test UDP, TCP and SCTP packets */
static struct rte_mempool *mbufpool[NB_SOCKETS];
static struct rte_mbuf *bufs[MAX_PKT_BURST];
static struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = {
/* first input field - always one byte long. */
{
.type = RTE_ACL_FIELD_TYPE_BITMASK,
.size = sizeof(uint8_t),
.field_index = PROTO_FIELD_IPV4,
.input_index = PROTO_INPUT_IPV4,
.offset = sizeof(struct rte_ether_hdr) +
offsetof(struct rte_ipv4_hdr, next_proto_id),
},
/* next input field (IPv4 source address) - 4 consecutive bytes. */
{
/* rte_flow uses a bit mask for IPv4 addresses */
.type = RTE_ACL_FIELD_TYPE_BITMASK,
.size = sizeof(uint32_t),
.field_index = SRC_FIELD_IPV4,
.input_index = SRC_INPUT_IPV4,
.offset = sizeof(struct rte_ether_hdr) +
offsetof(struct rte_ipv4_hdr, src_addr),
},
/* next input field (IPv4 destination address) - 4 consecutive bytes. */
{
/* rte_flow uses a bit mask for IPv4 addresses */
.type = RTE_ACL_FIELD_TYPE_BITMASK,
.size = sizeof(uint32_t),
.field_index = DST_FIELD_IPV4,
.input_index = DST_INPUT_IPV4,
.offset = sizeof(struct rte_ether_hdr) +
offsetof(struct rte_ipv4_hdr, dst_addr),
},
/*
* Next 2 fields (src & dst ports) form 4 consecutive bytes.
* They share the same input index.
*/
{
/* rte_flow uses a bit mask for protocol ports */
.type = RTE_ACL_FIELD_TYPE_BITMASK,
.size = sizeof(uint16_t),
.field_index = SRCP_FIELD_IPV4,
.input_index = SRCP_DESTP_INPUT_IPV4,
.offset = sizeof(struct rte_ether_hdr) +
sizeof(struct rte_ipv4_hdr) +
offsetof(struct rte_tcp_hdr, src_port),
},
{
/* rte_flow uses a bit mask for protocol ports */
.type = RTE_ACL_FIELD_TYPE_BITMASK,
.size = sizeof(uint16_t),
.field_index = DSTP_FIELD_IPV4,
.input_index = SRCP_DESTP_INPUT_IPV4,
.offset = sizeof(struct rte_ether_hdr) +
sizeof(struct rte_ipv4_hdr) +
offsetof(struct rte_tcp_hdr, dst_port),
},
};
/* parameters for rte_flow_classify_validate and rte_flow_classify_create */
/* test UDP pattern:
* "eth / ipv4 src spec 2.2.2.3 src mask 255.255.255.00 dst spec 2.2.2.7
* dst mask 255.255.255.00 / udp src is 32 dst is 33 / end"
*/
static struct rte_flow_item_ipv4 ipv4_udp_spec_1 = {
{ 0, 0, 0, 0, 0, 0, IPPROTO_UDP, 0,
RTE_IPV4(2, 2, 2, 3), RTE_IPV4(2, 2, 2, 7)}
};
static const struct rte_flow_item_ipv4 ipv4_mask_24 = {
.hdr = {
.next_proto_id = 0xff,
.src_addr = 0xffffff00,
.dst_addr = 0xffffff00,
},
};
static struct rte_flow_item_udp udp_spec_1 = {
{ 32, 33, 0, 0 }
};
static struct rte_flow_item eth_item = { RTE_FLOW_ITEM_TYPE_ETH,
0, 0, 0 };
static struct rte_flow_item eth_item_bad = { -1, 0, 0, 0 };
static struct rte_flow_item ipv4_udp_item_1 = { RTE_FLOW_ITEM_TYPE_IPV4,
&ipv4_udp_spec_1, 0, &ipv4_mask_24};
static struct rte_flow_item ipv4_udp_item_bad = { RTE_FLOW_ITEM_TYPE_IPV4,
NULL, 0, NULL};
static struct rte_flow_item udp_item_1 = { RTE_FLOW_ITEM_TYPE_UDP,
&udp_spec_1, 0, &rte_flow_item_udp_mask};
static struct rte_flow_item udp_item_bad = { RTE_FLOW_ITEM_TYPE_UDP,
NULL, 0, NULL};
static struct rte_flow_item end_item = { RTE_FLOW_ITEM_TYPE_END,
0, 0, 0 };
/* test TCP pattern:
* "eth / ipv4 src spec 1.2.3.4 src mask 255.255.255.00 dst spec 5.6.7.8
* dst mask 255.255.255.00 / tcp src is 16 dst is 17 / end"
*/
static struct rte_flow_item_ipv4 ipv4_tcp_spec_1 = {
{ 0, 0, 0, 0, 0, 0, IPPROTO_TCP, 0,
RTE_IPV4(1, 2, 3, 4), RTE_IPV4(5, 6, 7, 8)}
};
static struct rte_flow_item_tcp tcp_spec_1 = {
{ 16, 17, 0, 0, 0, 0, 0, 0, 0}
};
static struct rte_flow_item ipv4_tcp_item_1 = { RTE_FLOW_ITEM_TYPE_IPV4,
&ipv4_tcp_spec_1, 0, &ipv4_mask_24};
static struct rte_flow_item tcp_item_1 = { RTE_FLOW_ITEM_TYPE_TCP,
&tcp_spec_1, 0, &rte_flow_item_tcp_mask};
/* test SCTP pattern:
* "eth / ipv4 src spec 1.2.3.4 src mask 255.255.255.00 dst spec 5.6.7.8
* dst mask 255.255.255.00 / sctp src is 16 dst is 17/ end"
*/
static struct rte_flow_item_ipv4 ipv4_sctp_spec_1 = {
{ 0, 0, 0, 0, 0, 0, IPPROTO_SCTP, 0, RTE_IPV4(11, 12, 13, 14),
RTE_IPV4(15, 16, 17, 18)}
};
static struct rte_flow_item_sctp sctp_spec_1 = {
{ 10, 11, 0, 0}
};
static struct rte_flow_item ipv4_sctp_item_1 = { RTE_FLOW_ITEM_TYPE_IPV4,
&ipv4_sctp_spec_1, 0, &ipv4_mask_24};
static struct rte_flow_item sctp_item_1 = { RTE_FLOW_ITEM_TYPE_SCTP,
&sctp_spec_1, 0, &rte_flow_item_sctp_mask};
/* test actions:
* "actions count / end"
*/
static struct rte_flow_query_count count = {
.reset = 1,
.hits_set = 1,
.bytes_set = 1,
.hits = 0,
.bytes = 0,
};
static struct rte_flow_action count_action = { RTE_FLOW_ACTION_TYPE_COUNT,
&count};
static struct rte_flow_action count_action_bad = { -1, 0};
static struct rte_flow_action end_action = { RTE_FLOW_ACTION_TYPE_END, 0};
static struct rte_flow_action actions[2];
/* test attributes */
static struct rte_flow_attr attr;
/* test error */
static struct rte_flow_error error;
/* test pattern */
static struct rte_flow_item pattern[4];
/* flow classify data for UDP burst */
static struct rte_flow_classify_ipv4_5tuple_stats udp_ntuple_stats;
static struct rte_flow_classify_stats udp_classify_stats = {
.stats = (void *)&udp_ntuple_stats
};
/* flow classify data for TCP burst */
static struct rte_flow_classify_ipv4_5tuple_stats tcp_ntuple_stats;
static struct rte_flow_classify_stats tcp_classify_stats = {
.stats = (void *)&tcp_ntuple_stats
};
/* flow classify data for SCTP burst */
static struct rte_flow_classify_ipv4_5tuple_stats sctp_ntuple_stats;
static struct rte_flow_classify_stats sctp_classify_stats = {
.stats = (void *)&sctp_ntuple_stats
};
struct flow_classifier_acl *cls;
struct flow_classifier_acl {
struct rte_flow_classifier *cls;
} __rte_cache_aligned;
/*
* test functions by passing invalid or
* non-workable parameters.
*/
static int
test_invalid_parameters(void)
{
struct rte_flow_classify_rule *rule;
int ret;
ret = rte_flow_classify_validate(NULL, NULL, NULL, NULL, NULL);
if (!ret) {
printf("Line %i: rte_flow_classify_validate",
__LINE__);
printf(" with NULL param should have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(NULL, NULL, NULL, NULL,
NULL, NULL);
if (rule) {
printf("Line %i: flow_classifier_table_entry_add", __LINE__);
printf(" with NULL param should have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(NULL, NULL);
if (!ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" with NULL param should have failed!\n");
return -1;
}
ret = rte_flow_classifier_query(NULL, NULL, 0, NULL, NULL);
if (!ret) {
printf("Line %i: flow_classifier_query", __LINE__);
printf(" with NULL param should have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(NULL, NULL, NULL, NULL,
NULL, &error);
if (rule) {
printf("Line %i: flow_classify_table_entry_add ", __LINE__);
printf("with NULL param should have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(NULL, NULL);
if (!ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf("with NULL param should have failed!\n");
return -1;
}
ret = rte_flow_classifier_query(NULL, NULL, 0, NULL, NULL);
if (!ret) {
printf("Line %i: flow_classifier_query", __LINE__);
printf(" with NULL param should have failed!\n");
return -1;
}
return 0;
}
static int
test_valid_parameters(void)
{
struct rte_flow_classify_rule *rule;
int ret;
int key_found;
/*
* set up parameters for rte_flow_classify_validate,
* rte_flow_classify_table_entry_add and
* rte_flow_classify_table_entry_delete
*/
attr.ingress = 1;
attr.priority = 1;
pattern[0] = eth_item;
pattern[1] = ipv4_udp_item_1;
pattern[2] = udp_item_1;
pattern[3] = end_item;
actions[0] = count_action;
actions[1] = end_action;
ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
actions, &error);
if (ret) {
printf("Line %i: rte_flow_classify_validate",
__LINE__);
printf(" should not have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
actions, &key_found, &error);
if (!rule) {
printf("Line %i: flow_classify_table_entry_add", __LINE__);
printf(" should not have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
if (ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" should not have failed!\n");
return -1;
}
return 0;
}
static int
test_invalid_patterns(void)
{
struct rte_flow_classify_rule *rule;
int ret;
int key_found;
/*
* set up parameters for rte_flow_classify_validate,
* rte_flow_classify_table_entry_add and
* rte_flow_classify_table_entry_delete
*/
attr.ingress = 1;
attr.priority = 1;
pattern[0] = eth_item_bad;
pattern[1] = ipv4_udp_item_1;
pattern[2] = udp_item_1;
pattern[3] = end_item;
actions[0] = count_action;
actions[1] = end_action;
pattern[0] = eth_item;
pattern[1] = ipv4_udp_item_bad;
ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
actions, &error);
if (!ret) {
printf("Line %i: rte_flow_classify_validate", __LINE__);
printf(" should have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
actions, &key_found, &error);
if (rule) {
printf("Line %i: flow_classify_table_entry_add", __LINE__);
printf(" should have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
if (!ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" should have failed!\n");
return -1;
}
pattern[1] = ipv4_udp_item_1;
pattern[2] = udp_item_bad;
pattern[3] = end_item;
ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
actions, &error);
if (!ret) {
printf("Line %i: rte_flow_classify_validate", __LINE__);
printf(" should have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
actions, &key_found, &error);
if (rule) {
printf("Line %i: flow_classify_table_entry_add", __LINE__);
printf(" should have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
if (!ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" should have failed!\n");
return -1;
}
return 0;
}
static int
test_invalid_actions(void)
{
struct rte_flow_classify_rule *rule;
int ret;
int key_found;
/*
* set up parameters for rte_flow_classify_validate,
* rte_flow_classify_table_entry_add and
* rte_flow_classify_table_entry_delete
*/
attr.ingress = 1;
attr.priority = 1;
pattern[0] = eth_item;
pattern[1] = ipv4_udp_item_1;
pattern[2] = udp_item_1;
pattern[3] = end_item;
actions[0] = count_action_bad;
actions[1] = end_action;
ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
actions, &error);
if (!ret) {
printf("Line %i: rte_flow_classify_validate", __LINE__);
printf(" should have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
actions, &key_found, &error);
if (rule) {
printf("Line %i: flow_classify_table_entry_add", __LINE__);
printf(" should have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
if (!ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" should have failed!\n");
return -1;
}
return 0;
}
static int
init_ipv4_udp_traffic(struct rte_mempool *mp,
struct rte_mbuf **pkts_burst, uint32_t burst_size)
{
struct rte_ether_hdr pkt_eth_hdr;
struct rte_ipv4_hdr pkt_ipv4_hdr;
struct rte_udp_hdr pkt_udp_hdr;
uint32_t src_addr = IPV4_ADDR(2, 2, 2, 3);
uint32_t dst_addr = IPV4_ADDR(2, 2, 2, 7);
uint16_t src_port = 32;
uint16_t dst_port = 33;
uint16_t pktlen;
static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
printf("Set up IPv4 UDP traffic\n");
initialize_eth_header(&pkt_eth_hdr,
(struct rte_ether_addr *)src_mac,
(struct rte_ether_addr *)dst_mac, RTE_ETHER_TYPE_IPV4, 0, 0);
pktlen = (uint16_t)(sizeof(struct rte_ether_hdr));
printf("ETH pktlen %u\n", pktlen);
pktlen = initialize_ipv4_header(&pkt_ipv4_hdr, src_addr, dst_addr,
pktlen);
printf("ETH + IPv4 pktlen %u\n", pktlen);
pktlen = initialize_udp_header(&pkt_udp_hdr, src_port, dst_port,
pktlen);
printf("ETH + IPv4 + UDP pktlen %u\n\n", pktlen);
return generate_packet_burst(mp, pkts_burst, &pkt_eth_hdr,
0, &pkt_ipv4_hdr, 1,
&pkt_udp_hdr, burst_size,
PACKET_BURST_GEN_PKT_LEN, 1);
}
static int
init_ipv4_tcp_traffic(struct rte_mempool *mp,
struct rte_mbuf **pkts_burst, uint32_t burst_size)
{
struct rte_ether_hdr pkt_eth_hdr;
struct rte_ipv4_hdr pkt_ipv4_hdr;
struct rte_tcp_hdr pkt_tcp_hdr;
uint32_t src_addr = IPV4_ADDR(1, 2, 3, 4);
uint32_t dst_addr = IPV4_ADDR(5, 6, 7, 8);
uint16_t src_port = 16;
uint16_t dst_port = 17;
uint16_t pktlen;
static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
printf("Set up IPv4 TCP traffic\n");
initialize_eth_header(&pkt_eth_hdr,
(struct rte_ether_addr *)src_mac,
(struct rte_ether_addr *)dst_mac, RTE_ETHER_TYPE_IPV4, 0, 0);
pktlen = (uint16_t)(sizeof(struct rte_ether_hdr));
printf("ETH pktlen %u\n", pktlen);
pktlen = initialize_ipv4_header_proto(&pkt_ipv4_hdr, src_addr,
dst_addr, pktlen, IPPROTO_TCP);
printf("ETH + IPv4 pktlen %u\n", pktlen);
pktlen = initialize_tcp_header(&pkt_tcp_hdr, src_port, dst_port,
pktlen);
printf("ETH + IPv4 + TCP pktlen %u\n\n", pktlen);
return generate_packet_burst_proto(mp, pkts_burst, &pkt_eth_hdr,
0, &pkt_ipv4_hdr, 1, IPPROTO_TCP,
&pkt_tcp_hdr, burst_size,
PACKET_BURST_GEN_PKT_LEN, 1);
}
static int
init_ipv4_sctp_traffic(struct rte_mempool *mp,
struct rte_mbuf **pkts_burst, uint32_t burst_size)
{
struct rte_ether_hdr pkt_eth_hdr;
struct rte_ipv4_hdr pkt_ipv4_hdr;
struct rte_sctp_hdr pkt_sctp_hdr;
uint32_t src_addr = IPV4_ADDR(11, 12, 13, 14);
uint32_t dst_addr = IPV4_ADDR(15, 16, 17, 18);
uint16_t src_port = 10;
uint16_t dst_port = 11;
uint16_t pktlen;
static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
printf("Set up IPv4 SCTP traffic\n");
initialize_eth_header(&pkt_eth_hdr,
(struct rte_ether_addr *)src_mac,
(struct rte_ether_addr *)dst_mac, RTE_ETHER_TYPE_IPV4, 0, 0);
pktlen = (uint16_t)(sizeof(struct rte_ether_hdr));
printf("ETH pktlen %u\n", pktlen);
pktlen = initialize_ipv4_header_proto(&pkt_ipv4_hdr, src_addr,
dst_addr, pktlen, IPPROTO_SCTP);
printf("ETH + IPv4 pktlen %u\n", pktlen);
pktlen = initialize_sctp_header(&pkt_sctp_hdr, src_port, dst_port,
pktlen);
printf("ETH + IPv4 + SCTP pktlen %u\n\n", pktlen);
return generate_packet_burst_proto(mp, pkts_burst, &pkt_eth_hdr,
0, &pkt_ipv4_hdr, 1, IPPROTO_SCTP,
&pkt_sctp_hdr, burst_size,
PACKET_BURST_GEN_PKT_LEN, 1);
}
static int
init_mbufpool(void)
{
int socketid;
int ret = 0;
unsigned int lcore_id;
char s[64];
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
if (rte_lcore_is_enabled(lcore_id) == 0)
continue;
socketid = rte_lcore_to_socket_id(lcore_id);
if (socketid >= NB_SOCKETS) {
printf(
"Socket %d of lcore %u is out of range %d\n",
socketid, lcore_id, NB_SOCKETS);
ret = -1;
break;
}
if (mbufpool[socketid] == NULL) {
snprintf(s, sizeof(s), "mbuf_pool_%d", socketid);
mbufpool[socketid] =
rte_pktmbuf_pool_create(s, NB_MBUF,
MEMPOOL_CACHE_SIZE, 0, MBUF_SIZE,
socketid);
if (mbufpool[socketid]) {
printf("Allocated mbuf pool on socket %d\n",
socketid);
} else {
printf("Cannot init mbuf pool on socket %d\n",
socketid);
ret = -ENOMEM;
break;
}
}
}
return ret;
}
static int
test_query_udp(void)
{
struct rte_flow_error error;
struct rte_flow_classify_rule *rule;
int ret;
int i;
int key_found;
ret = init_ipv4_udp_traffic(mbufpool[0], bufs, MAX_PKT_BURST);
if (ret != MAX_PKT_BURST) {
printf("Line %i: init_udp_ipv4_traffic has failed!\n",
__LINE__);
return -1;
}
for (i = 0; i < MAX_PKT_BURST; i++)
bufs[i]->packet_type = RTE_PTYPE_L3_IPV4;
/*
* set up parameters for rte_flow_classify_validate,
* rte_flow_classify_table_entry_add and
* rte_flow_classify_table_entry_delete
*/
attr.ingress = 1;
attr.priority = 1;
pattern[0] = eth_item;
pattern[1] = ipv4_udp_item_1;
pattern[2] = udp_item_1;
pattern[3] = end_item;
actions[0] = count_action;
actions[1] = end_action;
ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
actions, &error);
if (ret) {
printf("Line %i: rte_flow_classify_validate", __LINE__);
printf(" should not have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
actions, &key_found, &error);
if (!rule) {
printf("Line %i: flow_classify_table_entry_add", __LINE__);
printf(" should not have failed!\n");
return -1;
}
ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST,
rule, &udp_classify_stats);
if (ret) {
printf("Line %i: flow_classifier_query", __LINE__);
printf(" should not have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
if (ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" should not have failed!\n");
return -1;
}
return 0;
}
static int
test_query_tcp(void)
{
struct rte_flow_classify_rule *rule;
int ret;
int i;
int key_found;
ret = init_ipv4_tcp_traffic(mbufpool[0], bufs, MAX_PKT_BURST);
if (ret != MAX_PKT_BURST) {
printf("Line %i: init_ipv4_tcp_traffic has failed!\n",
__LINE__);
return -1;
}
for (i = 0; i < MAX_PKT_BURST; i++)
bufs[i]->packet_type = RTE_PTYPE_L3_IPV4;
/*
* set up parameters for rte_flow_classify_validate,
* rte_flow_classify_table_entry_add and
* rte_flow_classify_table_entry_delete
*/
attr.ingress = 1;
attr.priority = 1;
pattern[0] = eth_item;
pattern[1] = ipv4_tcp_item_1;
pattern[2] = tcp_item_1;
pattern[3] = end_item;
actions[0] = count_action;
actions[1] = end_action;
ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
actions, &error);
if (ret) {
printf("Line %i: flow_classifier_query", __LINE__);
printf(" should not have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
actions, &key_found, &error);
if (!rule) {
printf("Line %i: flow_classify_table_entry_add", __LINE__);
printf(" should not have failed!\n");
return -1;
}
ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST,
rule, &tcp_classify_stats);
if (ret) {
printf("Line %i: flow_classifier_query", __LINE__);
printf(" should not have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
if (ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" should not have failed!\n");
return -1;
}
return 0;
}
static int
test_query_sctp(void)
{
struct rte_flow_classify_rule *rule;
int ret;
int i;
int key_found;
ret = init_ipv4_sctp_traffic(mbufpool[0], bufs, MAX_PKT_BURST);
if (ret != MAX_PKT_BURST) {
printf("Line %i: init_ipv4_tcp_traffic has failed!\n",
__LINE__);
return -1;
}
for (i = 0; i < MAX_PKT_BURST; i++)
bufs[i]->packet_type = RTE_PTYPE_L3_IPV4;
/*
* set up parameters rte_flow_classify_validate,
* rte_flow_classify_table_entry_add and
* rte_flow_classify_table_entry_delete
*/
attr.ingress = 1;
attr.priority = 1;
pattern[0] = eth_item;
pattern[1] = ipv4_sctp_item_1;
pattern[2] = sctp_item_1;
pattern[3] = end_item;
actions[0] = count_action;
actions[1] = end_action;
ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
actions, &error);
if (ret) {
printf("Line %i: flow_classifier_query", __LINE__);
printf(" should not have failed!\n");
return -1;
}
rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
actions, &key_found, &error);
if (!rule) {
printf("Line %i: flow_classify_table_entry_add", __LINE__);
printf(" should not have failed!\n");
return -1;
}
ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST,
rule, &sctp_classify_stats);
if (ret) {
printf("Line %i: flow_classifier_query", __LINE__);
printf(" should not have failed!\n");
return -1;
}
ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
if (ret) {
printf("Line %i: rte_flow_classify_table_entry_delete",
__LINE__);
printf(" should not have failed!\n");
return -1;
}
return 0;
}
static int
test_flow_classify(void)
{
struct rte_table_acl_params table_acl_params;
struct rte_flow_classify_table_params cls_table_params;
struct rte_flow_classifier_params cls_params;
int ret;
uint32_t size;
/* Memory allocation */
size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct flow_classifier_acl));
cls = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
cls_params.name = "flow_classifier";
cls_params.socket_id = 0;
cls->cls = rte_flow_classifier_create(&cls_params);
/* initialise ACL table params */
table_acl_params.n_rule_fields = RTE_DIM(ipv4_defs);
table_acl_params.name = "table_acl_ipv4_5tuple";
table_acl_params.n_rules = FLOW_CLASSIFY_MAX_RULE_NUM;
memcpy(table_acl_params.field_format, ipv4_defs, sizeof(ipv4_defs));
/* initialise table create params */
cls_table_params.ops = &rte_table_acl_ops;
cls_table_params.arg_create = &table_acl_params;
cls_table_params.type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE;
ret = rte_flow_classify_table_create(cls->cls, &cls_table_params);
if (ret) {
printf("Line %i: f_create has failed!\n", __LINE__);
rte_flow_classifier_free(cls->cls);
rte_free(cls);
return TEST_FAILED;
}
printf("Created table_acl for for IPv4 five tuple packets\n");
ret = init_mbufpool();
if (ret) {
printf("Line %i: init_mbufpool has failed!\n", __LINE__);
return TEST_FAILED;
}
if (test_invalid_parameters() < 0)
return TEST_FAILED;
if (test_valid_parameters() < 0)
return TEST_FAILED;
if (test_invalid_patterns() < 0)
return TEST_FAILED;
if (test_invalid_actions() < 0)
return TEST_FAILED;
if (test_query_udp() < 0)
return TEST_FAILED;
if (test_query_tcp() < 0)
return TEST_FAILED;
if (test_query_sctp() < 0)
return TEST_FAILED;
return TEST_SUCCESS;
}
REGISTER_TEST_COMMAND(flow_classify_autotest, test_flow_classify);
| 26.558723 | 76 | 0.714408 |
dca198dfc6d70464ab8ce35d85eaeff3b4342bb6 | 1,630 | h | C | EstimoteFleetManagementSDK/EstimoteFleetManagementSDK.framework/Versions/A/Headers/ESTSimulatedBeaconManager.h | SmartSoftAsia/iOS-Fleet-Management-SDK | 5dfc845366c44be6de1414aca17e9e05ba0ef3fc | [
"MIT"
] | null | null | null | EstimoteFleetManagementSDK/EstimoteFleetManagementSDK.framework/Versions/A/Headers/ESTSimulatedBeaconManager.h | SmartSoftAsia/iOS-Fleet-Management-SDK | 5dfc845366c44be6de1414aca17e9e05ba0ef3fc | [
"MIT"
] | null | null | null | EstimoteFleetManagementSDK/EstimoteFleetManagementSDK.framework/Versions/A/Headers/ESTSimulatedBeaconManager.h | SmartSoftAsia/iOS-Fleet-Management-SDK | 5dfc845366c44be6de1414aca17e9e05ba0ef3fc | [
"MIT"
] | null | null | null | // Estimote Fleet Management SDK
// Copyright (c) 2015 Estimote. All rights reserved.
#import <CoreLocation/CoreLocation.h>
/**
* Use this class to simulate beacons.
*/
DEPRECATED_MSG_ATTRIBUTE("Deprecated since 4.31.0.")
@interface ESTSimulatedBeaconManager : CLLocationManager <CLLocationManagerDelegate>
/**
* Array with simulated CLBeacon objects.
*/
@property (nonatomic, readonly) NSArray *simulatedBeacons;
/**
* Use this initializer if you don't want to specify beacons in JSON.
* You will receive empty array in locationManager:didRangeBeacons:inRegion delegate method.
*
* @param delegate Set delegate for CLLocationManagerDelegate updates.
*
* @return Instance of this object.
*/
- (instancetype)initWithDelegate:(id <CLLocationManagerDelegate>)delegate;
/**
* Use this initializer if you want to specify beacons in JSON.
* Providing only filename is sufficient, but remember that your file
* should be *.json type and accessible from MainBundle.
* By default, order of beacons in the list will be reflected in simulatedBeacons array,
* which means, this class do not provide simulation of fluctuating RSSI or proximity.
* However, you can set those values in JSON file, they will be parsed into CLBeacon object.
*
* @param path Path for json file with description of beacons you want to simulate.
* @param delegate Set delegate for CLLocationManagerDelegate updates.
*
* @return Instance of this object.
*/
- (instancetype)initWithDelegate:(id <CLLocationManagerDelegate>)delegate
pathForJSON:(NSString *)path NS_DESIGNATED_INITIALIZER;
@end
| 37.045455 | 95 | 0.752147 |
c2e1b6a331b222f4af43a1e404d03b964a64c1fc | 999 | h | C | Pods/Headers/Private/ZXLUpload/ZXLUploadFmdb.h | ZXLBoaConstrictor/ZXLBaseLibrary | b2b950dbba4a5182b2f636cbc7087829efe43f07 | [
"MIT"
] | 9 | 2019-03-30T14:23:33.000Z | 2021-04-01T08:11:50.000Z | Pods/Headers/Public/ZXLUpload/ZXLUploadFmdb.h | ZXLBoaConstrictor/ZXLBaseLibrary | b2b950dbba4a5182b2f636cbc7087829efe43f07 | [
"MIT"
] | null | null | null | Pods/Headers/Public/ZXLUpload/ZXLUploadFmdb.h | ZXLBoaConstrictor/ZXLBaseLibrary | b2b950dbba4a5182b2f636cbc7087829efe43f07 | [
"MIT"
] | 4 | 2019-04-17T03:09:35.000Z | 2021-12-09T06:09:13.000Z | //
// ZXLUploadFmdb.h
// ZXLUpload
// 上传信息本地数据库存储代码
// Created by 张小龙 on 2018/4/20.
// Copyright © 2018年 张小龙. All rights reserved.
//
#import <Foundation/Foundation.h>
@class ZXLTaskInfoModel;
@class ZXLFileInfoModel;
@interface ZXLUploadFmdb : NSObject
+(ZXLUploadFmdb*)manager;
//增
-(void)insertUploadTaskInfo:(ZXLTaskInfoModel *)taskModel;
-(void)insertUploadSuccessFileResultInfo:(ZXLFileInfoModel *)fileModel;
-(void)insertCompressFileInfo:(ZXLFileInfoModel *)fileModel;
//删
-(void)deleteUploadTaskInfo:(ZXLTaskInfoModel *)taskModel;
-(void)deleteUploadSuccessFileResultInfo:(ZXLFileInfoModel *)fileModel;
-(void)deleteCompressFileInfo:(ZXLFileInfoModel *)fileModel;
-(void)clearUploadTaskInfo;
-(void)clearUploadSuccessFileResultInfo;
-(void)clearCompressFileInfo;
//查(全部)
-(NSMutableArray<ZXLTaskInfoModel *> *)selectAllUploadTaskInfo;
-(NSMutableArray<ZXLFileInfoModel *> *)selectAllUploadSuccessFileResultInfo;
-(NSMutableArray<ZXLFileInfoModel *> *)selectAllCompressFileInfo;
@end
| 31.21875 | 76 | 0.800801 |
897c97a162587c6f50b04c4bc8904e266ebbe9a0 | 6,198 | h | C | include/utils/param.h | kaiping/RNNLM_PARAM_SHARING | 7d39f8813d057565224402e230afacb98c8c366b | [
"Apache-2.0"
] | null | null | null | include/utils/param.h | kaiping/RNNLM_PARAM_SHARING | 7d39f8813d057565224402e230afacb98c8c366b | [
"Apache-2.0"
] | null | null | null | include/utils/param.h | kaiping/RNNLM_PARAM_SHARING | 7d39f8813d057565224402e230afacb98c8c366b | [
"Apache-2.0"
] | null | null | null | #ifndef INCLUDE_UTILS_PARAM_H_
#define INCLUDE_UTILS_PARAM_H_
#include <vector>
#include <string>
#include <map>
#include <functional>
#include "proto/model.pb.h"
#include "utils/blob.h"
#include "communication/msg.h"
// Base paramter class.
namespace singa {
class Param {
public:
Param();
virtual ~Param(){ }
/**
* Generate the message for a get request, i.e., get parameters from a server
*
* This function is called at worker/stub side.
* @param copy decides whether to copy the parameter values from the server.
* @param slice_idx index of the slice from which the message is generated.
* @return generated message without setting src, dst, target fields.
*/
virtual Msg* GenGetMsg(bool copy, int slice_idx);
/**
* Generate the message for a put request, i.e., put parameters to a server.
* \copydetails GenGetMsg(bool, int);
*/
virtual Msg* GenPutMsg(bool copy, int slice_idx);
/**
* Generate the message for a update request, i.e., pass info to server for
* parameter update.
* \copydetails GenGetMsg(bool, int);
*/
virtual Msg* GenUpdateMsg(bool copy, int slice_idx);
/**
* Generate the message for a synchronization request between server groups.
*
* This function is called at server side where the Param is actually a slice
* of an original Param object.
* */
virtual Msg* GenSyncMsg();
/**
* Generate the message to response the update request.
*
* This function is called at the server side, where the Param is actually a slice
* of an original Param object.
* @param copy if true copy the parameter value into the message, otherwise
* only transfer the pointer of the parameter values.
* @return response message pointer
*/
virtual Msg* GenUpdateResponseMsg(bool copy);
/**
* Server handling function for get request.
*
* @param msg request message
* @return resposne message
*/
virtual Msg* HandleGetMsg(Msg** msg);
/**
* Server handling function for put request.
*
* \copydetails HandleGetMsg(Msg**)
*/
virtual Msg* HandlePutMsg(Msg** msg);
/**
* Server handling function for synchronization message
*
* \copydetails HandleGetMsg(Msg**)
*/
virtual Msg* HandleSyncMsg(Msg** msg);
/**
* Server parses update request message.
*
* @param msg
* @return 1 for copy, 0 for no copy
*/
virtual int ParseUpdateMsg(Msg** msg);
/**
* Worker/Stub parsing function for get response.
*
* @param msg
* @param slice_idx index for the slice
*/
virtual int ParseGetResponseMsg(Msg** msg, int slice_idx);
/**
* Worker/Server parsing function for update response
*
* \copydetails ParseGetResponseMsg(Msg**, int);
*/
virtual int ParseUpdateResponseMsg(Msg** msg, int slice_idx);
/**
* Server parsing function for synchronization response.
*
* \copydetails ParseGetResponseMsg(Msg** , int);
*/
virtual int ParseSyncResponseMsg(Msg** msg, int slice_idx);
/**
* Setup param object
*
* @param proto includes learning rate/weight decay multipliers
* @param shape
*/
virtual void Setup(const ParamProto& proto, const std::vector<int>& shape);
/*
* Fill the values according to initmethod, e.g., gaussian distribution
*
* @param version initial version
*/
virtual void InitValues(int version=0);
/**
* Share the data blob from other Param objects.
*
* @param other the Param object whose owner owns the data blob
*/
void ShareData(shared_ptr<Param> other){
proto_.set_owner(other->owner());
if(data_!=nullptr)
CHECK(std::equal(data_->shape().begin(), data_->shape().end(),
other->data_->shape().begin()));
data_=other->data_;
}
float learning_rate_multiplier() {
return proto_.learning_rate_multiplier();
}
float weight_decay_multiplier() {
return proto_.weight_decay_multiplier();
}
const std::string& name() {
return proto_.name();
}
/**
* if the Param shares data with others, then owner is the id of that param.
* otherwise it is itself's id.
*/
const int owner() const{
return proto_.owner();
}
int id() const{
return proto_.id();
}
void set_id(int id){
proto_.set_id(id);
proto_.set_owner(id);
}
/**
* return the version of the parameter value shared by multiple workers
*/
int version() const {
return data_->version();
}
void set_version(int v) {
data_->set_version(v); // TODO read version from data blob
}
/**
* return the version of the parameter value local to a worker
*/
int local_version() const {
return local_version_;
}
void set_local_version(int v){
local_version_=v;
}
/**
* @return num of floats.
*/
int size() const {
return data_->count();
}
/**
* Return const mem address for the content of this parameter
*/
const Blob<float> &data() {
return *data_;
}
Blob<float> *mutable_data() {
return data_.get();
}
/**
* Return gradient of this parameter
*/
const Blob<float> &grad() {
return grad_;
}
Blob<float> *mutable_grad() {
return &grad_;
}
const Blob<float> &history() {
return history_;
}
Blob<float> *mutable_history() {
return &history_;
}
float* mutable_cpu_data(){
return data_->mutable_cpu_data();
}
float* mutable_cpu_grad(){
return grad_.mutable_cpu_data();
}
float* mutable_cpu_history(){
return history_.mutable_cpu_data();
}
int slice_start() const {
return slice_start_;
}
int num_slices() const {
return num_slices_;
}
void AddSlice(int slice_id, int size);
protected:
void ParseResponseMsg(Msg** msg, int slice_idx);
protected:
/**
* name of the parameter used to share wights between neuralnets
*/
std::string name_;
shared_ptr<Blob<float>> data_;
int slice_start_, num_slices_;
vector<int> slice_offset_, slice_size_;
vector<bool> pending_put_,pending_get_, pending_update_;
int num_pending_requests_;
//! gradient, history gradient of this parameter
Blob<float> grad_, history_;
ParamProto proto_;
int local_version_;
};
} // namespace singa
#endif // INCLUDE_UTILS_PARAM_H_
| 25.297959 | 84 | 0.66828 |
899523a4809c70b72713a4f88c7bf09d45c83e70 | 192 | c | C | test/hpmove_spmd.c | lecpie/bsponmpi | 95e1539fdad2c7c4777784673278b15dafefe56e | [
"MIT"
] | 8 | 2019-02-16T19:19:01.000Z | 2021-11-15T09:41:03.000Z | test/hpmove_spmd.c | lecpie/bsponmpi | 95e1539fdad2c7c4777784673278b15dafefe56e | [
"MIT"
] | 1 | 2019-02-25T18:56:45.000Z | 2019-02-25T18:56:45.000Z | test/hpmove_spmd.c | lecpie/bsponmpi | 95e1539fdad2c7c4777784673278b15dafefe56e | [
"MIT"
] | 1 | 2019-03-01T14:40:54.000Z | 2019-03-01T14:40:54.000Z | #include <bsp.h>
#include "test.h"
TEST( hpmove_spmd, abort("bsp_hpmove: can only be called within SPMD section") )
{
void * tag;
void * payload;
bsp_hpmove( &tag, &payload );
}
| 17.454545 | 80 | 0.640625 |
fc7203a9d6ed1f2d745406f9c4ed5268a5f9bf91 | 1,074 | h | C | xo/shape/cylinder.h | tgeijten/xo | b60cbf2e19a4c4df0dc588cf53640f863676aff3 | [
"MIT"
] | 10 | 2019-11-08T06:09:59.000Z | 2022-01-04T08:51:23.000Z | xo/shape/cylinder.h | tgeijten/xo | b60cbf2e19a4c4df0dc588cf53640f863676aff3 | [
"MIT"
] | 16 | 2019-04-19T07:52:30.000Z | 2021-06-08T11:04:07.000Z | xo/shape/cylinder.h | tgeijten/xo | b60cbf2e19a4c4df0dc588cf53640f863676aff3 | [
"MIT"
] | 7 | 2018-01-23T19:41:08.000Z | 2020-06-25T12:36:50.000Z | #pragma once
#include "xo/system/assert.h"
#include <cmath>
namespace xo
{
/// cylinder shape, y-up
struct cylinder
{
cylinder() : radius_(), height_() {}
explicit cylinder( float radius, float height ) : radius_( radius ), height_( height ) {}
float radius_;
float height_;
};
inline float volume( const cylinder& s ) {
return constantsf::pi() * squared( s.radius_ ) * s.height_;
}
inline aabbf aabb( const cylinder& s, const transformf& t ) {
XO_NOT_IMPLEMENTED;
}
inline vec3f dim( const cylinder& s ) {
return vec3f( 2.0f * s.radius_, s.height_, 2.0f * s.radius_ );
}
inline vec3f inertia( const cylinder& s, float density ) {
vec3f r;
auto m = density * volume( s );
r.x = r.z = m / 12.0f * ( 3 * squared( s.radius_ ) + squared( s.height_ ) );
r.y = 0.5f * m * squared( s.radius_ ); // cylinder along y axis
return r;
}
inline void scale( cylinder& s, float f ) {
s.radius_ *= f;
s.height_ *= f;
}
inline void scale( cylinder& s, const vec3f& sv ) {
s.radius_ *= std::sqrt( sv.x * sv.z );
s.height_ *= sv.y;
}
}
| 22.375 | 91 | 0.623836 |
0a5a177c10aebef85fcf537fdf36ea7c4d20d28e | 330 | h | C | src/glossary/include/GlossaryFactory.h | michalovsky/Glossary | a5623d474d7b8a839ef27571adfe5f2151a5fb79 | [
"MIT"
] | 6 | 2020-01-14T05:11:38.000Z | 2021-06-14T09:35:42.000Z | src/glossary/include/GlossaryFactory.h | michalovsky/Glossary | a5623d474d7b8a839ef27571adfe5f2151a5fb79 | [
"MIT"
] | null | null | null | src/glossary/include/GlossaryFactory.h | michalovsky/Glossary | a5623d474d7b8a839ef27571adfe5f2151a5fb79 | [
"MIT"
] | null | null | null | #pragma once
#include <memory>
#include "Glossary.h"
#include "GlossaryApi.h"
namespace glossary
{
class GLOSSARY_API GlossaryFactory
{
public:
virtual ~GlossaryFactory() = default;
virtual std::unique_ptr<Glossary> createGlossary() const = 0;
static std::unique_ptr<GlossaryFactory> createGlossaryFactory();
};
} | 17.368421 | 68 | 0.742424 |
50044d87ca3a0968e58fd79a2d41da479f60ddca | 2,477 | c | C | kernel/arch/i386/idt.c | cptaffe/os_v2 | b23706f6b88388aeb54c80fcd87f516ac4e3af5a | [
"MIT"
] | null | null | null | kernel/arch/i386/idt.c | cptaffe/os_v2 | b23706f6b88388aeb54c80fcd87f516ac4e3af5a | [
"MIT"
] | null | null | null | kernel/arch/i386/idt.c | cptaffe/os_v2 | b23706f6b88388aeb54c80fcd87f516ac4e3af5a | [
"MIT"
] | null | null | null |
// Copyright (c) 2015 Connor Taffe <cpaynetaffe@gmail.com>
#include <kernel/idt.h>
#include <kernel/pic.h>
#include <kernel/int.h>
#include <kernel/syscall.h>
#include <sys/io.h>
static idt_state idt_local = {
.entry = {{0}},
.ptr = {0},
.pic_base = 32,
.pic_masks = {0xfe, 0xff}
};
static void *int_handlers[] = {
// reserved (Intel)
(void *) &int_handler_0,
(void *) &int_handler_1,
(void *) &int_handler_2,
(void *) &int_handler_3,
(void *) &int_handler_4,
(void *) &int_handler_5,
(void *) &int_handler_6,
(void *) &int_handler_7,
(void *) &int_handler_8,
(void *) &int_handler_9,
(void *) &int_handler_10,
(void *) &int_handler_11,
(void *) &int_handler_12,
(void *) &int_handler_13,
(void *) &int_handler_14,
(void *) &int_handler_15,
(void *) &int_handler_16,
(void *) &int_handler_17,
(void *) &int_handler_18,
(void *) &int_handler_19,
(void *) &int_handler_20,
(void *) &int_handler_21,
(void *) &int_handler_22,
(void *) &int_handler_23,
(void *) &int_handler_24,
(void *) &int_handler_25,
(void *) &int_handler_26,
(void *) &int_handler_27,
(void *) &int_handler_28,
(void *) &int_handler_29,
(void *) &int_handler_30,
(void *) &int_handler_31,
// pic
(void *) &int_handler_32,
(void *) &int_handler_33,
(void *) &int_handler_34,
(void *) &int_handler_35,
(void *) &int_handler_36,
(void *) &int_handler_37,
(void *) &int_handler_38,
(void *) &int_handler_39,
(void *) &int_handler_40,
};
// set up handler
void idt_set(idt_state *idts, uint8_t num, void *handle, uint16_t sel, uint8_t flags) {
uint32_t base = (uint32_t) handle;
idts->entry[num].sel = sel;
idts->entry[num].flags = flags;
idts->entry[num].base_hi = (base >> 16) & 0xffff;
idts->entry[num].base_lo = (base & 0xffff);
}
idt_state *idt_init() {
idt_state *idt = &idt_local;
idt->ptr.limit = (uint16_t) sizeof(idt->entry) - 1;
idt->ptr.base = (uint32_t) &(idt->entry);
for (uint32_t i = 0; i < 255; i++) {
idt_set(idt, i, (void *) int_handler_undef, 0x08, 0x8E);
}
// set up kbrd interrupt at irq 1
for (uint32_t i = 0; i < (sizeof(int_handlers) / sizeof(void *)); i++) {
idt_set(idt, i, int_handlers[i], 0x08, 0x8E);
}
// set int 0x80
idt_set(idt, syscall_num, (void *) int_handler_syscall, 0x08, 0x8E);
// set up pic after 0-31 (reserved)
pic_init(idt->pic_base, idt->pic_base + 8);
pic_mask(idt->pic_masks[0], idt->pic_masks[1]);
idt_ptr *ptr = &(idt->ptr);
asm("lidt (%0)"::"r"(ptr));
asm("sti");
return idt;
}
| 24.77 | 87 | 0.64998 |
fb7d81cb0fb2bce79d5894dfe6febae060028cac | 3,752 | h | C | src/utpdf.h | ftns/utpdf | a2693ae8e9e27eb42ce75b2a8b76f635d8fe397a | [
"Apache-2.0"
] | 2 | 2021-01-18T01:51:47.000Z | 2021-03-21T22:06:41.000Z | src/utpdf.h | ftns/utpdf | a2693ae8e9e27eb42ce75b2a8b76f635d8fe397a | [
"Apache-2.0"
] | null | null | null | src/utpdf.h | ftns/utpdf | a2693ae8e9e27eb42ce75b2a8b76f635d8fe397a | [
"Apache-2.0"
] | null | null | null | /*
utpdf/utps
margin-aware converter from utf-8 text to PDF/PostScript
Copyright (c) 2021 by Akihiro SHIMIZU
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 __UTPDF_H__
#define __UTPDF_H__
#include <cairo.h>
#include <cairo-pdf.h>
#include <cairo-ps.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <string.h>
#include <getopt.h>
#include <locale.h>
#define VERSION "0.8.3"
#define S_LEN 256 // short buffer length
#define UC_LEN 8 // UTF-8 Character length
#define PI 3.14159265358979
#define MKPDFNAME "utpdf"
#define NAMELEN 16 // compare length of MKPDFNAME
// unit: point.
// 1inch = 72pt.
// 1mm = 1/25.4inch = 2.835pt.
#define BINDING 72.00 // binding: 1 inch(25.4mm)
#define PLEFT 36.00 // paper left: 0.5 inch(12.7mm)
#define PRIGHT 36.00 // paper right: 0.5 inch(12.7mm)
#define PTOP 36.00 // paper top: 0.5 inch(12.7mm)
#define PBOTTOM 36.00 // paper bottom: 0.5 inch(12.7mm)
#define DIVIDE 18.00 // divide: 0.25 inch(6.35mm)
#define DEFAULT_FONT "IPAGothic"
#define FONTSIZE 9.8 // default fontsize for onecol
#define FONTSIZE_TWOCOLS 6.6 // default fontsize for twocols
#define BETWEEN_L 1.0 // space between lines
#define HEADER_FONT "sans-serif"
#define HFONT_LARGE 16.0 // default fontsize for header
#define HFONT_TWOCOLS_LARGE 9.0 // default fontsize for twocols header
#define HFONT_M_RATE 0.66 // header medium font/large font
#define WATERMARK_FONT "sans-serif"
#define ARROW_WIDTH 1.0 // width of folding arrow
#define TAB 8
#define BUFLEN 1024
// punch mark size
#define MARK_H 4.0
#define MARK_W 2.0
// color
// R G B
#define C_BASEL 0.6, 0.6, 1 // baseline
#define C_NUMBER 0.4, 0.4, 0.4 // line number
#define C_NUMVL 1, 0.6, 0.6 // vertical line along with left of line number
#define C_ARROW 0.6, 0.6, 1 // folding arrow
#define C_BORDER 0.2, 0.2, 0.2 // border
#define C_WHITE 1, 1, 1 // (white)
#define C_RED 1, 0, 0 // (red)
#define C_GREEN 0, 1, 0 // (green)
#define C_BLUE 0, 0, 1 // (blue)
#define C_BLACK 0, 0, 0 // (black)
// watermark default color
#define WMARK_R 0.9
#define WMARK_G 0.9
#define WMARK_B 1.0
// User Interface's WaterMark default color
#define UIWM_R 230 // 230/255=0.9019
#define UIWM_G 230 // 230/255=0.9019
#define UIWM_B 255 // 255/255=1
// line width
#define LW_THIN_BASELINE 0.1
#define LW_THICK_BASELINE 1
#define LW_VLINE 0.4
#define LW_BORDER 1
// header date format -- strftime()
// #define DATE_FORMAT "%m/%d/%y %H:%M"
#define DATE_FORMAT "%D %R"
enum direction { d_down=-2, d_right=-1, d_none=0, d_left=1, d_up=2 };
typedef struct main_coordinates {
double head_top, mbottom, mleft, mright, body_left, body_right, bwidth;
enum direction markdir;
} mcoord_t;
typedef struct sub_coordinates {
double text_left, num_right, body_inset;
double body_top, oneline_h, bottombase;
int lineperpage;
} scoord_t;
extern int makepdf;
extern char *prog_name;
extern char *path2cmd(char *p);
extern cairo_status_t write_func
(void *closure, const unsigned char *data, unsigned int length);
#endif
// end of utpdf.h
| 28 | 79 | 0.698028 |
f7462625a99dcb25b676bd44037c7565025ab4ab | 343 | h | C | YWNetWorking/Classes/YWNetworking/NetWork/Categories/NSURLRequest+YWNetParams.h | flyOfYW/YWNetworking | 95cc464e42b28bbd6ff576b1b889f7b5984982e1 | [
"MIT"
] | 5 | 2017-01-26T06:24:51.000Z | 2021-06-24T09:09:24.000Z | YWNetWorking/Classes/YWNetworking/NetWork/Categories/NSURLRequest+YWNetParams.h | flyOfYW/YWNetworking | 95cc464e42b28bbd6ff576b1b889f7b5984982e1 | [
"MIT"
] | null | null | null | YWNetWorking/Classes/YWNetworking/NetWork/Categories/NSURLRequest+YWNetParams.h | flyOfYW/YWNetworking | 95cc464e42b28bbd6ff576b1b889f7b5984982e1 | [
"MIT"
] | null | null | null | //
// NSURLRequest+YWNetParams.h
// YWNetworkingExamples
//
// Created by Mr.Yao on 2019/9/12.
// Copyright © 2019 姚威. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSURLRequest (YWNetParams)
@property (nonatomic, copy) NSDictionary * _Nullable requestParams;
@end
NS_ASSUME_NONNULL_END
| 18.052632 | 67 | 0.758017 |
7472bb6e070b5a26fdbc4c5cf69dfd135b2f857c | 719 | h | C | ex3/fighter.h | sugartastic81/MCI_DiBSE21_MSE2 | 5565cbe7996402d70483bb5e63dfc0dc9389f0d7 | [
"Unlicense"
] | null | null | null | ex3/fighter.h | sugartastic81/MCI_DiBSE21_MSE2 | 5565cbe7996402d70483bb5e63dfc0dc9389f0d7 | [
"Unlicense"
] | null | null | null | ex3/fighter.h | sugartastic81/MCI_DiBSE21_MSE2 | 5565cbe7996402d70483bb5e63dfc0dc9389f0d7 | [
"Unlicense"
] | null | null | null | //
// Created by juerg on 26.03.2022.
//
#ifndef PROTOTYP_FIGHTER_H
#define PROTOTYP_FIGHTER_H
#include <string>
#include <iostream>
#include "item.h"
#include "character.h"
#include "npc.h"
using namespace std;
class Fighter : public NPC {
protected:
int muscle_strength;
public:
using NPC::NPC;
// override attac function from character class
virtual void attack(Character* enemy) override;
// private variable health getter & setter
int get_muscle_strength() const {
return muscle_strength;
}
void set_muscle_strength(int var_muscle_strength) {
this->muscle_strength = var_muscle_strength;
}
};
#endif //PROTOTYP_FIGHTER_H
| 20.542857 | 56 | 0.67733 |
74bf2415f34fb23b0a3e36ba6f07fac8ae7d9414 | 250 | c | C | test/cases/cpp/optimize.c | bocke/ucc | d95c0014dfc555c3eb6e9fdf909e0460bf2a0060 | [
"MIT"
] | 55 | 2015-02-07T12:31:13.000Z | 2022-02-19T15:25:02.000Z | test/cases/cpp/optimize.c | bocke/ucc | d95c0014dfc555c3eb6e9fdf909e0460bf2a0060 | [
"MIT"
] | null | null | null | test/cases/cpp/optimize.c | bocke/ucc | d95c0014dfc555c3eb6e9fdf909e0460bf2a0060 | [
"MIT"
] | 9 | 2015-08-06T21:26:33.000Z | 2022-01-14T03:44:40.000Z | // RUN: ! %ucc -dM -E -xc /dev/null | grep __OPTIMIZE__
// RUN: %ucc -O -dM -E -xc /dev/null | grep __OPTIMIZE__
// RUN: ! %ucc -O -dM -E -xc /dev/null | grep __OPTIMIZE_SIZE__
// RUN: %ucc -Os -dM -E -xc /dev/null | grep __OPTIMIZE_SIZE__
| 50 | 64 | 0.6 |
dd72d8cebb29a2ee8751e1d74372b7f3e5ab4c57 | 975 | h | C | src/Kontroller/firstblood/buttons.h | christoferjh/dustwars | 9ad050bbca3e07a91e150d7397a8839a8f017511 | [
"MIT"
] | null | null | null | src/Kontroller/firstblood/buttons.h | christoferjh/dustwars | 9ad050bbca3e07a91e150d7397a8839a8f017511 | [
"MIT"
] | null | null | null | src/Kontroller/firstblood/buttons.h | christoferjh/dustwars | 9ad050bbca3e07a91e150d7397a8839a8f017511 | [
"MIT"
] | null | null | null | #ifndef Oo_BUTTONS_H_oO
#define Oo_BUTTONS_H_oO
#include "lcd_engine.h"
//This only uses one port for gamecontroller
//The other port can easly be added. But sice I've only made one controller this was not necessary at the time.
//Init buttons
void button_init(void);
//Debugging
void test_buttons(LCD_engine *lcd);
unsigned char A_isPressed();
unsigned char START_isPressed();
unsigned char B_isPressed();
unsigned char DOWN_isPressed();
unsigned char LEFT_isPressed();
unsigned char RIGHT_isPressed();
unsigned char UP_isPressed();
unsigned char only_combo_isPressed(unsigned char combo);
unsigned char combo_isPressed(unsigned char combo);
unsigned char any_isPressed();
unsigned char RIGHT_isPressedAndRel();
unsigned char LEFT_isPressedAndRel();
unsigned char UP_isPressedAndRel();
unsigned char DOWN_isPressedAndRel();
unsigned char A_isPressedAndRel();
unsigned char B_isPressedAndRel();
unsigned char START_isPressedAndRel();
#endif
| 31.451613 | 113 | 0.786667 |
5a54053386c83253430b3f18b764fe3cb89bef30 | 6,461 | c | C | release/src-rt/linux/linux-2.6/net/core/dev_mcast.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src-rt/linux/linux-2.6/net/core/dev_mcast.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src-rt/linux/linux-2.6/net/core/dev_mcast.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | /*
* Linux NET3: Multicast List maintenance.
*
* Authors:
* Tim Kordas <tjk@nostromo.eeap.cwru.edu>
* Richard Underwood <richard@wuzz.demon.co.uk>
*
* Stir fried together from the IP multicast and CAP patches above
* Alan Cox <Alan.Cox@linux.org>
*
* Fixes:
* Alan Cox : Update the device on a real delete
* rather than any time but...
* Alan Cox : IFF_ALLMULTI support.
* Alan Cox : New format set_multicast_list() calls.
* Gleb Natapov : Remove dev_mc_lock.
*
* 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.
*/
#include <linux/module.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/bitops.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/in.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/if_ether.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/init.h>
#include <net/ip.h>
#include <net/route.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/arp.h>
/*
* Device multicast list maintenance.
*
* This is used both by IP and by the user level maintenance functions.
* Unlike BSD we maintain a usage count on a given multicast address so
* that a casual user application can add/delete multicasts used by
* protocols without doing damage to the protocols when it deletes the
* entries. It also helps IP as it tracks overlapping maps.
*
* Device mc lists are changed by bh at least if IPv6 is enabled,
* so that it must be bh protected.
*
* We block accesses to device mc filters with netif_tx_lock.
*/
/*
* Update the multicast list into the physical NIC controller.
*/
static void __dev_mc_upload(struct net_device *dev)
{
/* Don't do anything till we up the interface
* [dev_open will call this function so the list will
* stay sane]
*/
if (!(dev->flags&IFF_UP))
return;
/*
* Devices with no set multicast or which have been
* detached don't get set.
*/
if (dev->set_multicast_list == NULL ||
!netif_device_present(dev))
return;
dev->set_multicast_list(dev);
}
void dev_mc_upload(struct net_device *dev)
{
netif_tx_lock_bh(dev);
__dev_mc_upload(dev);
netif_tx_unlock_bh(dev);
}
/*
* Delete a device level multicast
*/
int dev_mc_delete(struct net_device *dev, void *addr, int alen, int glbl)
{
int err = 0;
struct dev_mc_list *dmi, **dmip;
netif_tx_lock_bh(dev);
for (dmip = &dev->mc_list; (dmi = *dmip) != NULL; dmip = &dmi->next) {
/*
* Find the entry we want to delete. The device could
* have variable length entries so check these too.
*/
if (memcmp(dmi->dmi_addr, addr, dmi->dmi_addrlen) == 0 &&
alen == dmi->dmi_addrlen) {
if (glbl) {
int old_glbl = dmi->dmi_gusers;
dmi->dmi_gusers = 0;
if (old_glbl == 0)
break;
}
if (--dmi->dmi_users)
goto done;
/*
* Last user. So delete the entry.
*/
*dmip = dmi->next;
dev->mc_count--;
kfree(dmi);
/*
* We have altered the list, so the card
* loaded filter is now wrong. Fix it
*/
__dev_mc_upload(dev);
netif_tx_unlock_bh(dev);
return 0;
}
}
err = -ENOENT;
done:
netif_tx_unlock_bh(dev);
return err;
}
/*
* Add a device level multicast
*/
int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
{
int err = 0;
struct dev_mc_list *dmi, *dmi1;
dmi1 = kmalloc(sizeof(*dmi), GFP_ATOMIC);
netif_tx_lock_bh(dev);
for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) {
if (memcmp(dmi->dmi_addr, addr, dmi->dmi_addrlen) == 0 &&
dmi->dmi_addrlen == alen) {
if (glbl) {
int old_glbl = dmi->dmi_gusers;
dmi->dmi_gusers = 1;
if (old_glbl)
goto done;
}
dmi->dmi_users++;
goto done;
}
}
if ((dmi = dmi1) == NULL) {
netif_tx_unlock_bh(dev);
return -ENOMEM;
}
memcpy(dmi->dmi_addr, addr, alen);
dmi->dmi_addrlen = alen;
dmi->next = dev->mc_list;
dmi->dmi_users = 1;
dmi->dmi_gusers = glbl ? 1 : 0;
dev->mc_list = dmi;
dev->mc_count++;
__dev_mc_upload(dev);
netif_tx_unlock_bh(dev);
return 0;
done:
netif_tx_unlock_bh(dev);
kfree(dmi1);
return err;
}
/*
* Discard multicast list when a device is downed
*/
void dev_mc_discard(struct net_device *dev)
{
netif_tx_lock_bh(dev);
while (dev->mc_list != NULL) {
struct dev_mc_list *tmp = dev->mc_list;
dev->mc_list = tmp->next;
if (tmp->dmi_users > tmp->dmi_gusers)
printk("dev_mc_discard: multicast leakage! dmi_users=%d\n", tmp->dmi_users);
kfree(tmp);
}
dev->mc_count = 0;
netif_tx_unlock_bh(dev);
}
#ifdef CONFIG_PROC_FS
static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
{
struct net_device *dev;
loff_t off = 0;
read_lock(&dev_base_lock);
for_each_netdev(dev) {
if (off++ == *pos)
return dev;
}
return NULL;
}
static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
++*pos;
return next_net_device((struct net_device *)v);
}
static void dev_mc_seq_stop(struct seq_file *seq, void *v)
{
read_unlock(&dev_base_lock);
}
static int dev_mc_seq_show(struct seq_file *seq, void *v)
{
struct dev_mc_list *m;
struct net_device *dev = v;
netif_tx_lock_bh(dev);
for (m = dev->mc_list; m; m = m->next) {
int i;
seq_printf(seq, "%-4d %-15s %-5d %-5d ", dev->ifindex,
dev->name, m->dmi_users, m->dmi_gusers);
for (i = 0; i < m->dmi_addrlen; i++)
seq_printf(seq, "%02x", m->dmi_addr[i]);
seq_putc(seq, '\n');
}
netif_tx_unlock_bh(dev);
return 0;
}
static const struct seq_operations dev_mc_seq_ops = {
.start = dev_mc_seq_start,
.next = dev_mc_seq_next,
.stop = dev_mc_seq_stop,
.show = dev_mc_seq_show,
};
static int dev_mc_seq_open(struct inode *inode, struct file *file)
{
return seq_open(file, &dev_mc_seq_ops);
}
static const struct file_operations dev_mc_seq_fops = {
.owner = THIS_MODULE,
.open = dev_mc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif
void __init dev_mcast_init(void)
{
proc_net_fops_create("dev_mcast", 0, &dev_mc_seq_fops);
}
EXPORT_SYMBOL(dev_mc_add);
EXPORT_SYMBOL(dev_mc_delete);
EXPORT_SYMBOL(dev_mc_upload);
| 21.827703 | 79 | 0.679461 |
eeebaadfd16e5125e6fc32f9f2fc6287dfcf2acb | 1,466 | h | C | ios/web_view/internal/web_view_web_state_policy_decider.h | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 575 | 2015-06-18T23:58:20.000Z | 2022-03-23T09:32:39.000Z | ios/web_view/internal/web_view_web_state_policy_decider.h | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | ios/web_view/internal/web_view_web_state_policy_decider.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 52 | 2015-07-14T10:40:50.000Z | 2022-03-15T01:11:49.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 IOS_WEB_VIEW_INTERNAL_WEB_VIEW_WEB_STATE_POLICY_DECIDER_H_
#define IOS_WEB_VIEW_INTERNAL_WEB_VIEW_WEB_STATE_POLICY_DECIDER_H_
#import <Foundation/Foundation.h>
#import "ios/web/public/navigation/web_state_policy_decider.h"
namespace web {
class WebState;
}
@class CWVWebView;
namespace ios_web_view {
// An implementation of web::WebStatePolicyDecider which delegates to:
// [web_view.navigationDelegate webView:shouldStartLoadWithRequest:]
// [web_view.navigationDelegate webView:shouldContinueLoadWithResponse:]
class WebViewWebStatePolicyDecider : public web::WebStatePolicyDecider {
public:
WebViewWebStatePolicyDecider(web::WebState* web_state, CWVWebView* web_view);
// web::WebStatePolicyDecider overrides:
web::WebStatePolicyDecider::PolicyDecision ShouldAllowRequest(
NSURLRequest* request,
const web::WebStatePolicyDecider::RequestInfo& request_info) override;
void ShouldAllowResponse(
NSURLResponse* response,
bool for_main_frame,
base::OnceCallback<void(WebStatePolicyDecider::PolicyDecision)> callback)
override;
private:
// Delegates to |delegate| property of this web view.
__weak CWVWebView* web_view_ = nil;
};
} // namespace ios_web_view
#endif // IOS_WEB_VIEW_INTERNAL_WEB_VIEW_WEB_STATE_POLICY_DECIDER_H_
| 32.577778 | 79 | 0.797408 |
f68dd05d0ef0e0f951203c1d434f67d2932547dd | 2,100 | c | C | src/queue.c | UrekMazinoTOG/os-simulation | fa2ef796c593c8fc2a36d3ba128b759528dfd79d | [
"MIT"
] | 1 | 2020-05-26T16:47:00.000Z | 2020-05-26T16:47:00.000Z | src/queue.c | UrekMazinoTOG/os-simulation | fa2ef796c593c8fc2a36d3ba128b759528dfd79d | [
"MIT"
] | null | null | null | src/queue.c | UrekMazinoTOG/os-simulation | fa2ef796c593c8fc2a36d3ba128b759528dfd79d | [
"MIT"
] | null | null | null | #include "../include/queue.h"
#include <stddef.h> // macro : NULL(0)
#include <stdint.h> // type : int8_t
#include <stdbool.h> // type : bool
#include <assert.h> // macro : assert()
#define swap(X,Y) { __typeof__(X) _T = X; X = Y; Y = _T; }
// Utility function
int8_t parent(int8_t i) {return (i&1)?(i-1)>>1:(i-2)>>1;}
int8_t left (int8_t i) {return (i<<1) + 1;}
int8_t right (int8_t i) {return (i<<1) + 2;}
static void heapifyUp (struct queue_t * q, int8_t i);
static void heapifyDown(struct queue_t * q, int8_t i);
bool empty(struct queue_t * q) {
assert(q != NULL);
return q->size == 0;
}
bool full(struct queue_t * q) {
assert(q != NULL);
return q->size == MAX_QUEUE_SIZE;
}
void enqueue(struct queue_t * q, struct pcb_t * proc) {
assert(q != NULL && proc != NULL);
// If queue is full, stop program
if(full(q)) return;
// 1. Insert new process at end of queue
q->proc[q->size] = proc;
q->size = q->size + 1;
// 2. Heapify up new process in queue
heapifyUp(q, q->size - 1);
}
struct pcb_t * dequeue(struct queue_t * q) {
assert(q != NULL);
// If queue is empty, stop program
if(empty(q)) return NULL;
// 1 Save process with highest priority(HP)
struct pcb_t * proc = q->proc[0];
// 2 Remove HP process from queue
q->proc[0] = q->proc[q->size - 1];
q->size = q->size - 1;
// 3 Heapify down first process in queue
heapifyDown(q, 0);
return proc;
}
static void heapifyUp (struct queue_t * q, int8_t i) {
assert(q != NULL && i >= 0);
int8_t p = parent(i);
if(p >= 0 && q->proc[i]->priority > q->proc[p]->priority) {
swap(q->proc[i], q->proc[p]); // parent is smaller
heapifyUp(q, p); // continue
}
}
static void heapifyDown(struct queue_t * q, int8_t i) {
int8_t l = left(i), r = right(i), biggest = i;
if(l < q->size && q->proc[l]->priority > q->proc[biggest]->priority)
biggest = l; // left child priority is bigger
if(r < q->size && q->proc[r]->priority > q->proc[biggest]->priority)
biggest = r; // right child priority is bigger
if(biggest != i) {
swap(q->proc[i], q->proc[biggest]);
heapifyDown(q, biggest); // continue
}
}
| 28 | 69 | 0.62 |
6e55a99d90290f7584eb88233ab811bfcb5c74b3 | 10,589 | c | C | labs/16-esp8266/libesp/esp-commands.c | Ouyancheng/RPi-WLAN-driver | f8650faa33ce47c6591285dbec09e0247e3343da | [
"MIT"
] | 23 | 2022-01-05T00:06:04.000Z | 2022-03-29T06:14:31.000Z | labs/16-esp8266/libesp/esp-commands.c | Ouyancheng/RPi-WLAN-driver | f8650faa33ce47c6591285dbec09e0247e3343da | [
"MIT"
] | null | null | null | labs/16-esp8266/libesp/esp-commands.c | Ouyancheng/RPi-WLAN-driver | f8650faa33ce47c6591285dbec09e0247e3343da | [
"MIT"
] | 11 | 2022-01-05T03:01:50.000Z | 2022-03-20T16:29:05.000Z | /*
* engler, cs140e: routines to use the ESP. put all your code here
* and in its header (esp-commands.h). do not modify anything else
* in case we need to push bug fixes. sorry.
*
* big issue was the right strategy for handling messages we didn't expect.
* i think everything but message data has a newline carriage return?
*/
#include <stdarg.h>
#include "libesp.h"
// connect, disconnect. print wth messages.
// change the debugging.
static int is_connect(esp_t *e, unsigned *ch) {
// blocks until input: should check if its there?
if(!match_line(e->l, "%u, CONNECT", ch))
return 0;
assert(*ch < ESP_MAX_CONN);
return 1;
}
static int is_disconnect(esp_t *e, unsigned *ch) {
// blocks until input: should check if its there?
if(!match_line(e->l, "%u, DISCONNECT", ch))
return 0;
assert(*ch < ESP_MAX_CONN);
return 1;
}
// wait: what is the other stuff?
int wait_for_conn(esp_t *e, unsigned *ch) {
return is_connect(e,ch);
// wait: what: this isn't right.
if(is_connect(e,ch))
while(!esp_has_data_timeout(e->l,10000)) {
output("no connection\n");
;
}
while(!is_connect(e, ch))
;
return 1;
}
/*
* default out-of-order message handler: ignore everything
* before the connection is active.
*
* we should not be called after, so just panic if so.
*/
int default_handle_out_of_order_msg(esp_t *e) {
if(!e->active_p)
cmd_echo_line(e, "booting up: ignoring:");
else
lex_panic(e->l, "unexpected out of order message\n");
return 1;
}
void handle_connect(esp_t *e, unsigned ch) {
output("got a connect for %d\n", ch);
e->open_conn[ch].active_p = 1;
e->open_conn[ch].client_p = 0;
e->open_conn[ch].type = ESP_TCP;
}
void handle_disconnect(esp_t *e, unsigned ch) {
output("got a disconnect for %d\n", ch);
e->open_conn[ch].active_p = 0;
}
// if you are running in server mode, will have to change this
// since you can receive connect and disconnect messages.
// cleaner to use a function pointer, but we use flags since
// lab is short.
static int handle_ooo_server(esp_t *e) {
unsigned ch;
lex_panic(e->l, "in handle ooo server\n");
if(is_connect(e,&ch)) {
handle_connect(e,ch);
} else if(is_disconnect(e, &ch)) {
output("got a disconnect for %d\n", ch);
handle_disconnect(e,ch);
} else
lex_panic(e->l, "unimplemented: you should handle other messages.\n");
return 1;
}
static int handle_ooo_client(esp_t *e) {
lex_panic(e->l, "client: AFAIK: should never receive unexpected messages.\n");
return 1;
}
/********************************************************************
* crude esp management.
*/
// is it up at all?
int esp_is_up(esp_t *e) {
at_cmd(e, "AT", "OK");
return 1;
}
// drain random data that appears after a reset. not sure a better way.
int at_drain(esp_t *e) {
while(1) {
if(match_line(e->l, "ready"))
break;
cmd_echo_line(e, "reset:");
}
// i seems like we have to wait awhile for the esp.
esp_usleep(1000 * 1000);
return 1;
}
// esp has various race conditions: we use delays to try to
// allow it to finish what it is doing.
int at_delay(void) {
esp_usleep(400*1000);
return 1;
}
// this is our attempt to do a hard reset so that you don't have to
// pull the esp in and out your computer.
//
// NOTE: this is *NOT* guaranteed. i experminted with this and that
// (hence the seemingly contradictory actions and random delays).
// there is likely a better way. so just use this as a starting point.
int esp_hard_reset(esp_t *e) {
// we wait until no characters for 1ms. otherwise we can get
// random stuff from previous connections. note: this
// is still a race condition (we can always get old stuff from a
// non-reset esp), so strictly speaking i think we need to
// sit here in a tight loop issuing resets until things work ok.
while(esp_has_data_timeout(e->l, 1000))
lex_getc(e->l);
debug("drained everything i think\n");
if(!at_cmd_extra(e, "AT+RST", "OK") || !at_drain(e))
panic("cannot reset??\n");
// for these two, we can get random extraneous stuff during.
return at_cmd_extra(e, "AT+RESTORE", "OK")
&& at_delay()
&& at_drain(e)
// i think restore implies redone.
&& at_cmd_extra(e, "AT+RST", "OK")
&& at_drain(e)
;
}
/*********************************************************************
* wifi connection routines.
*/
// AP server.
int esp_setup_wifi(esp_t *e) {
assert(e->wifi && e->password);
assert(!e->active_p);
output("setup_wifie: on my esp this prints out: +CIFSR:APIP,\"%s\"\n", ESP_SERVER_IP);
output("\tso 192.168.4.1 is the device's address\n");
assert(strlen(e->password) >= 8);
return
at_cmdv(e, "AT+CWSAP=\"%s\",\"%s\",5,3", e->wifi, e->password)
&& at_cmd(e, "AT+CWMODE=3", "OK")
&& at_cmd_extra(e, "AT+CIFSR", "OK")
;
}
int esp_connect_to_wifi(esp_t *e) {
assert(e->wifi && e->password);
// set mode client.
return at_cmd_ok(e, "AT+CWMODE=1")
// && at_cmd_rep_v(e, "WIFI CONNECTED", "AT+CWJAP=\"%s\",\"%s\"", e->wifi, e->password)
// && at_cmdv(e, "AT+CWJAP=\"%s\",\"%s\"", e->wifi, e->password)
&& at_cmd_extrav(e, "AT+CWJAP=\"%s\",\"%s\"", e->wifi, e->password)
;
}
// you want to get a response, and then get an ok --- the way the code is
// setup now, you can bail if you just get an ok without filling anything
// in. is it better to not bundle everything together?
static unsigned
issue_tcp_connect(esp_t *e, unsigned *ch, const char *server_ip, unsigned portn) {
char cmd[1024];
snprintf(cmd, sizeof cmd, "AT+CIPSTART=0,\"TCP\",\"192.168.4.1\",4444");
// returns a uint.
// make a run_cmd_uint
cmd_puts(e, cmd);
if(!cmd_ack(e, cmd, 0))
panic("error issuing <%s>\n", cmd);
// can't do this: need to do command_response
if(!cmd_responsef(e, 0, 0, "%u, CONNECT", ch))
cmd_reject_line(e, "expecting <<uint>, CONNECT>\n");
if(!cmd_response(e, "OK", 0, 0))
cmd_reject_line(e, "did not receive ok!\n");
debug("have a connect! channel=%d\n", *ch);
return 1;
}
/*********************************************************************
* tcp routines.
*/
int esp_start_tcp_client(esp_t *e, const char *server_ip, unsigned portn) {
assert(!e->active_p);
// first we just do channel 0.
unsigned ch = 0;
// we are only connecting on a single channel.
int result =
// enable multiple connections.
at_cmd_ok(e,"AT+CIPMUX=1")
// connect using the given port.
// we can get a 0,CONNECT --i don't remember seeing this before.
// we need to extract the channel from this.
#if 0
&& at_cmd_extrav(e,"AT+CIPSTART=0,\"TCP\",\"192.168.4.1\",4444");
#else
&& issue_tcp_connect(e, &ch, server_ip, portn)
#endif
// && at_cmdv(e,"AT+CIPSTART=0,\"TCP\",\"%s\",%u", server_ip, portn)
;
if(!result)
return 0;
assert(!ch);
esp_conn_t *c = &e->open_conn[ch];
assert(!c->active_p);
c->client_p = 1;
c->active_p = 1;
c->type = ESP_TCP;
c->server_ip = server_ip;
c->portn = portn;
e->handle_ooo_msg = handle_ooo_client;
e->active_p = 1;
return 1;
}
int esp_start_tcp_server(esp_t *e, unsigned portnum) {
assert(!e->active_p);
// output("connect using: <netcat 192.168.4.1 %d>\n", portnum);
int result = at_cmd(e,"AT+CWMODE=3", "OK") // dual mode
&& at_cmd(e,"AT+CIPMUX=1", "OK")
// start a tcp server.
// run using: netcat 192.168.4.1 <portnum>
&& at_cmdv(e,"AT+CIPSERVER=1,%u", portnum)
// set timeout.
&& at_cmd_extra(e, "AT+CIPSTO?", "OK")
&& at_cmd_extra(e, "AT+CIPSTO=7200", "OK")
&& at_cmd_extra(e, "AT+CIPSTO?", "OK")
&& at_cmd_extra(e, "AT+CIFSR", "OK")
&& at_cmd_extra(e, "AT+GMR", "OK")
;
if(!result)
return 0;
e->handle_ooo_msg = handle_ooo_server;
e->active_p = 1;
return 1;
}
#if 0
int esp_send(esp_t *e, unsigned ch, const void *data, unsigned n) {
assert(n < ESP_MAX_PKT);
char cmd[512];
snprintf(cmd, sizeof cmd, "AT+CIPSEND=%u,%u", ch, n);
char ack[512];
snprintf(ack, sizeof ack, "Recv %d bytes", n);
// doc seems to indicate you do both? or do you wait for an ack?
cmd_puts(e, cmd);
if(!esp_write_exact(e->l, data, n))
panic("write exact failed\n");
if(!cmd_ack(e, cmd, 1))
lex_panic(e->l, "no ack for command: <%s>", cmd);
if(!cmd_response(e, ack, 0, 0))
lex_panic(e->l, "could not get command");
if(!cmd_response(e, "SEND OK", 0, 0))
lex_panic(e->l, "expected SEND OK");
#if 0
if(!at_cmdv(fd, "AT+CIPSEND=%u,%u", ch, n))
panic("send failed\n");
if(!esp_write_exact(e, data, n))
panic("write exact failed\n");
if(!cmd_response(e, "SEND OK"
#endif
return n;
}
#endif
// usually these will be received spontaneously: have a queue of data?
int esp_is_recv(esp_t *e, unsigned *ch, void *data, unsigned maxbytes) {
unsigned nbytes;
if(!match(e->l, "+IPD,%u,%u:", ch, &nbytes))
cmd_reject_line(e, "expected receive, have something else\n");
esp_debug("got a recv: ch=%d, nbytes=%d, max=%d\n", *ch, nbytes,maxbytes);
assert(nbytes>0);
if(nbytes > maxbytes)
lex_panic(e->l, "message is %d bytes long, we have %d space avail\n", nbytes, maxbytes);
// this should be timeout based.
uint8_t *m = data;
int i;
// DO NOT 0 terminate data! will corrupt non-strings.
for(i = 0; i < nbytes; i++)
m[i] = lex_getc(e->l);
esp_debug("received %d bytes, message=<%s>\n", nbytes, m);
return nbytes;
}
int esp_send(esp_t *e, unsigned ch, const void *data, unsigned n) {
assert(n>0);
at_cmdv(e, "AT+CIPSEND=%u,%u", ch, n);
// wait for a >, no EOL
if(!match_tok(e->l, ">"))
cmd_reject_line(e, "didn't match '>'");
esp_debug("got an ack\n");
// return error
if(!esp_write_exact(e->l, data, n))
panic("write failed\n");
unsigned nsent;
cmd_responsef(e, 0, 0, "Recv %u bytes", &nsent);
if(n != nsent)
panic("wanted to send %d bytes, sent: %d\n", n, nsent);
cmd_response(e, "SEND OK", 0, 0);
return n;
}
| 30.87172 | 96 | 0.585891 |
dc0d04a6a67609454db119ac02f1f4a4f948bd47 | 2,020 | h | C | Portable/zoolib/ChanRPos_XX_ChanR.h | ElectricMagic/zoolib_cxx | cb3ccfde931b3989cd420fa093153204a7899805 | [
"MIT"
] | 13 | 2015-01-28T21:05:09.000Z | 2021-11-03T22:21:11.000Z | Portable/zoolib/ChanRPos_XX_ChanR.h | ElectricMagic/zoolib_cxx | cb3ccfde931b3989cd420fa093153204a7899805 | [
"MIT"
] | null | null | null | Portable/zoolib/ChanRPos_XX_ChanR.h | ElectricMagic/zoolib_cxx | cb3ccfde931b3989cd420fa093153204a7899805 | [
"MIT"
] | 4 | 2018-11-16T08:33:33.000Z | 2021-12-11T19:40:46.000Z | // Copyright (c) 2021 Andrew Green. MIT License. http://www.zoolib.org
#ifndef __ZooLib_ChanRPos_XX_ChanR_h__
#define __ZooLib_ChanRPos_XX_ChanR_h__ 1
#include "zconfig.h"
#include "zoolib/ChanR.h"
#include "zoolib/Util_Chan.h" // For sECopyAll, sCopyFully.
namespace ZooLib {
// =================================================================================================
#pragma mark - ChanRPos_XX_ChanR
template <class EE>
class ChanRPos_XX_ChanR
: public ChanRPos<EE>
{
public:
ChanRPos_XX_ChanR(const ChanR<EE>& iSource, const ChanRWPos<EE>& iBuffer)
: fSource(iSource)
, fBuffer(iBuffer)
{}
// From ChanPos
virtual uint64 Pos()
{ return sPos(fBuffer); }
// From ChanPosSet
virtual void PosSet(uint64 iPos)
{ sPosSet(fBuffer, iPos); }
// From ChanR
virtual size_t Read(EE* oDest, size_t iCount)
{
const uint64 theBufferPos = sPos(fBuffer);
const uint64 theBufferSize = sSize(fBuffer);
if (theBufferPos >= theBufferSize)
{
sPosSet(fBuffer, theBufferSize);
std::pair<uint64,uint64> result =
sCopyFully(fSource, fBuffer, theBufferPos - theBufferSize + iCount);
sPosSet(fBuffer, theBufferPos);
if (result.first != result.second)
sThrow_ExhaustedW();
}
return sRead(fBuffer, oDest, iCount);
}
virtual size_t Readable()
{
if (size_t theReadable = sReadable(fBuffer))
return theReadable;
return sReadable(fSource);
}
// From ChanSize
virtual uint64 Size()
{
// In order to know how much data is available we have
// to suck it all in from fSource. Another reason to avoid
// using Size if at all possible.
uint64 curPosition = sPos(fBuffer);
sPosSet(fBuffer, sSize(fBuffer));
sECopyAll(fSource, fBuffer);
sPosSet(fBuffer, curPosition);
return sSize(fBuffer);
}
// From ChanU
virtual size_t Unread(const EE* iSource, size_t iCount)
{ return sUnread(fBuffer, iSource, iCount); }
protected:
const ChanR<EE>& fSource;
const ChanRWPos<EE>& fBuffer;
};
} // namespace ZooLib
#endif // __ZooLib_ChanRPos_XX_ChanR_h__
| 23.764706 | 100 | 0.683663 |
4925f22dff0af0a009196cb5eb5d473fbc9add0e | 1,546 | h | C | drivers/net/wwan/iosm/iosm_ipc_wwan.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | null | null | null | drivers/net/wwan/iosm/iosm_ipc_wwan.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 1 | 2021-01-27T01:29:47.000Z | 2021-01-27T01:29:47.000Z | drivers/net/wwan/iosm/iosm_ipc_wwan.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | null | null | null | /* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (C) 2020-21 Intel Corporation.
*/
#ifndef IOSM_IPC_WWAN_H
#define IOSM_IPC_WWAN_H
/**
* ipc_wwan_init - Allocate, Init and register WWAN device
* @ipc_imem: Pointer to imem data-struct
* @dev: Pointer to device structure
*
* Returns: Pointer to instance on success else NULL
*/
struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev);
/**
* ipc_wwan_deinit - Unregister and free WWAN device, clear pointer
* @ipc_wwan: Pointer to wwan instance data
*/
void ipc_wwan_deinit(struct iosm_wwan *ipc_wwan);
/**
* ipc_wwan_receive - Receive a downlink packet from CP.
* @ipc_wwan: Pointer to wwan instance
* @skb_arg: Pointer to struct sk_buff
* @dss: Set to true if interafce id is from 257 to 261,
* else false
* @if_id: Interface ID
*
* Return: 0 on success and failure value on error
*/
int ipc_wwan_receive(struct iosm_wwan *ipc_wwan, struct sk_buff *skb_arg,
bool dss, int if_id);
/**
* ipc_wwan_tx_flowctrl - Enable/Disable TX flow control
* @ipc_wwan: Pointer to wwan instance
* @id: Ipc mux channel session id
* @on: if true then flow ctrl would be enabled else disable
*
*/
void ipc_wwan_tx_flowctrl(struct iosm_wwan *ipc_wwan, int id, bool on);
/**
* ipc_wwan_is_tx_stopped - Checks if Tx stopped for a Interface id.
* @ipc_wwan: Pointer to wwan instance
* @id: Ipc mux channel session id
*
* Return: true if stopped, false otherwise
*/
bool ipc_wwan_is_tx_stopped(struct iosm_wwan *ipc_wwan, int id);
#endif
| 27.607143 | 80 | 0.728331 |
563274dab2afd5909e4389a9da3b1f4e98bb216a | 5,512 | h | C | dnn_project/dnn/util/gammatone_fb.h | alexeyche/dnn_old | 58305cf486187575312cef0a753c86a8c7792196 | [
"MIT"
] | null | null | null | dnn_project/dnn/util/gammatone_fb.h | alexeyche/dnn_old | 58305cf486187575312cef0a753c86a8c7792196 | [
"MIT"
] | null | null | null | dnn_project/dnn/util/gammatone_fb.h | alexeyche/dnn_old | 58305cf486187575312cef0a753c86a8c7792196 | [
"MIT"
] | null | null | null | #pragma once
#define BW_CORRECTION 1.0190
#define VERY_SMALL_NUMBER 1e-200
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/*=======================
* Utility functions
*=======================
*/
#define myMax(x,y) ( ( x ) > ( y ) ? ( x ) : ( y ) )
#define myMod(x,y) ( ( x ) - ( y ) * floor ( ( x ) / ( y ) ) )
#define erb(x) ( 24.7 * ( 4.37e-3 * ( x ) + 1.0 ) )
#include <dnn/core.h>
class GammatoneFilter {
public:
enum class Options { OnlyMembrane, Full };
GammatoneFilter(GammatoneFilter::Options _o) : o(_o) { }
void calc(const vector<double> &x, int fs, double cf, int hrect) {
int i, j, t, nsamples;
double a, tpt, tptbw, gain;
double p0r, p1r, p2r, p3r, p4r, p0i, p1i, p2i, p3i, p4i;
double a1, a2, a3, a4, a5, u0r, u0i; /*, u1r, u1i;*/
double qcos, qsin, oldcs, coscf, sincf, oldphase, dp, dps;
nsamples = x.size();
membrane.resize(nsamples);
if(o == Options::Full) {
hilbert_envelope.resize(nsamples);
inst_freq.resize(nsamples);
inst_phase.resize(nsamples);
}
oldphase = 0.0;
tpt = ( M_PI + M_PI ) / fs;
tptbw = tpt * erb ( cf ) * BW_CORRECTION;
a = exp ( -tptbw );
/* based on integral of impulse response */
gain = ( tptbw*tptbw*tptbw*tptbw ) / 3;
/* Update filter coefficients */
a1 = 4.0*a; a2 = -6.0*a*a; a3 = 4.0*a*a*a; a4 = -a*a*a*a; a5 = a*a;
p0r = 0.0; p1r = 0.0; p2r = 0.0; p3r = 0.0; p4r = 0.0;
p0i = 0.0; p1i = 0.0; p2i = 0.0; p3i = 0.0; p4i = 0.0;
/*===========================================================
* exp(a+i*b) = exp(a)*(cos(b)+i*sin(b))
* q = exp(-i*tpt*cf*t) = cos(tpt*cf*t) + i*(-sin(tpt*cf*t))
* qcos = cos(tpt*cf*t)
* qsin = -sin(tpt*cf*t)
*===========================================================
*/
coscf = cos ( tpt * cf );
sincf = sin ( tpt * cf );
qcos = 1; qsin = 0; /* t=0 & q = exp(-i*tpt*t*cf)*/
for ( t=0; t<nsamples; t++ )
{
/* Filter part 1 & shift down to d.c. */
p0r = qcos*x[t] + a1*p1r + a2*p2r + a3*p3r + a4*p4r;
p0i = qsin*x[t] + a1*p1i + a2*p2i + a3*p3i + a4*p4i;
/* Clip coefficients to stop them from becoming too close to zero */
if (fabs(p0r) < VERY_SMALL_NUMBER)
p0r = 0.0F;
if (fabs(p0i) < VERY_SMALL_NUMBER)
p0i = 0.0F;
/* Filter part 2 */
u0r = p0r + a1*p1r + a5*p2r;
u0i = p0i + a1*p1i + a5*p2i;
/* Update filter results */
p4r = p3r; p3r = p2r; p2r = p1r; p1r = p0r;
p4i = p3i; p3i = p2i; p2i = p1i; p1i = p0i;
/*==========================================
* Basilar membrane response
* 1/ shift up in frequency first: (u0r+i*u0i) * exp(i*tpt*cf*t) = (u0r+i*u0i) * (qcos + i*(-qsin))
* 2/ take the real part only: membrane = real(exp(j*wcf*kT).*u) * gain;
*==========================================
*/
membrane[t] = ( u0r * qcos + u0i * qsin ) * gain;
if ( 1 == hrect && membrane[t] < 0 ) {
membrane[t] = 0; /* half-wave rectifying */
}
/*==========================================
* Instantaneous Hilbert envelope
* env = abs(u) * gain;
*==========================================
*/
if (o == Options::Full) {
hilbert_envelope[t] = sqrt ( u0r * u0r + u0i * u0i ) * gain;
}
/*==========================================
* Instantaneous phase
* instp = unwrap(angle(u));
*==========================================
*/
if (o == Options::Full) {
inst_phase[t] = atan2 ( u0i, u0r );
/* unwrap it */
dp = inst_phase[t] - oldphase;
if ( std::abs ( dp ) > M_PI ) {
dps = myMod ( dp + M_PI, 2 * M_PI) - M_PI;
if ( dps == -M_PI && dp > 0 ) {
dps = M_PI;
}
inst_phase[t] = inst_phase[t] + dps - dp;
}
oldphase = inst_phase[t];
}
/*==========================================
* Instantaneous frequency
* instf = cf + [diff(inst_phase) 0]./tpt;
*==========================================
*/
if ( o == Options::Full && t > 0 ) {
inst_freq[t-1] = cf + ( inst_phase[t] - inst_phase[t-1] ) / tpt;
}
/*====================================================
* The basic idea of saving computational load:
* cos(a+b) = cos(a)*cos(b) - sin(a)*sin(b)
* sin(a+b) = sin(a)*cos(b) + cos(a)*sin(b)
* qcos = cos(tpt*cf*t) = cos(tpt*cf + tpt*cf*(t-1))
* qsin = -sin(tpt*cf*t) = -sin(tpt*cf + tpt*cf*(t-1))
*====================================================
*/
qcos = coscf * ( oldcs = qcos ) + sincf * qsin;
qsin = coscf * qsin - sincf * oldcs;
}
if ( o == Options::Full ) {
inst_freq[nsamples-1] = cf;
}
}
Options o;
vector<double> membrane;
vector<double> hilbert_envelope;
vector<double> inst_phase;
vector<double> inst_freq;
};
| 36.263158 | 109 | 0.396589 |
c683b923af7b2f926f97ac9fc87b6241e3af7de4 | 199 | c | C | c02/ex08/ft_strlowcase.c | luanldcarvalho/42Basecamp | 2d5ba76eac254ecb5c7d768e880fcc34f4acdc1e | [
"MIT"
] | null | null | null | c02/ex08/ft_strlowcase.c | luanldcarvalho/42Basecamp | 2d5ba76eac254ecb5c7d768e880fcc34f4acdc1e | [
"MIT"
] | null | null | null | c02/ex08/ft_strlowcase.c | luanldcarvalho/42Basecamp | 2d5ba76eac254ecb5c7d768e880fcc34f4acdc1e | [
"MIT"
] | null | null | null | char *ft_strlowcase(char *str)
{
int index;
index = 0;
while (str[index] != '\0')
{
if (str[index] >= 'A' && str[index] <= 'Z')
str[index] = str[index] + 32;
index++;
}
return (str);
}
| 14.214286 | 45 | 0.522613 |
566a55ec6d656d3643b926f69186845335d448ed | 322 | h | C | MyGE/src/MyGE/EntryPoint.h | tomasmartinsantos/MyGE | 30f8d9ef6c101fae6c01cc8907dc01c35bbed33a | [
"Apache-2.0"
] | null | null | null | MyGE/src/MyGE/EntryPoint.h | tomasmartinsantos/MyGE | 30f8d9ef6c101fae6c01cc8907dc01c35bbed33a | [
"Apache-2.0"
] | null | null | null | MyGE/src/MyGE/EntryPoint.h | tomasmartinsantos/MyGE | 30f8d9ef6c101fae6c01cc8907dc01c35bbed33a | [
"Apache-2.0"
] | null | null | null | #pragma once
#ifdef MG_PLATFORM_WINDOWS
extern MyGE::Application* MyGE::CreateApplication();
int main(int argc, char** argv)
{
MyGE::Log::Init();
MG_CORE_WARN("Initialized Log");
int a = 5;
MG_INFO("Hello Var={0}", a);
auto App = MyGE::CreateApplication();
App->Run();
delete App;
}
#endif | 16.947368 | 52 | 0.636646 |
b6aa007072839336e35ac90fbb6d3933bc5c8c32 | 4,415 | c | C | src/kernel/proc/process.c | zhengruohuang/toddler | 0d7bde9aaf1fab8fed5f37973eeda9eaa100bd7a | [
"BSD-2-Clause"
] | 80 | 2016-03-27T04:26:57.000Z | 2021-12-24T08:27:55.000Z | src/kernel/proc/process.c | zhengruohuang/toddler | 0d7bde9aaf1fab8fed5f37973eeda9eaa100bd7a | [
"BSD-2-Clause"
] | 1 | 2016-12-08T18:08:20.000Z | 2018-02-23T02:51:35.000Z | src/kernel/proc/process.c | zhengruohuang/toddler | 0d7bde9aaf1fab8fed5f37973eeda9eaa100bd7a | [
"BSD-2-Clause"
] | 11 | 2017-05-09T01:42:07.000Z | 2020-02-13T13:56:36.000Z | /*
* Process manager
*/
#include "common/include/data.h"
#include "common/include/errno.h"
#include "common/include/memory.h"
#include "kernel/include/hal.h"
#include "kernel/include/mem.h"
#include "kernel/include/lib.h"
#include "kernel/include/coreimg.h"
#include "kernel/include/exec.h"
#include "kernel/include/proc.h"
static int proc_salloc_id;
static struct process_list processes;
struct process *kernel_proc;
static ulong gen_proc_id(struct process *p)
{
ulong id = (ulong)p;
return id;
}
struct process *create_process(
ulong parent_id, char *name, char *url,
enum process_type type, int priority)
{
int mon_err = EOK;
struct process *p = NULL;
// Notify process monitor
mon_err = check_process_create_before(parent_id);
assert(mon_err == EOK);
// Allocate a process struct
p = (struct process *)salloc(proc_salloc_id);
assert(p);
// Assign a proc id
p->proc_id = gen_proc_id(p);
p->parent_id = parent_id;
// Setup the process
p->name = strdup(name);
p->url = strdup(url);
p->type = type;
p->state = process_enter;
p->user_mode = type != process_kernel;
p->priority = priority;
// Thread list
create_thread_lists(p);
// Page table
if (type == process_kernel) {
p->page_dir_pfn = hal->kernel_page_dir_pfn;
} else {
p->page_dir_pfn = palloc(hal->user_page_dir_page_count);
}
assert(p->page_dir_pfn);
// Init the address space
if (type != process_kernel) {
hal->init_addr_space(p->page_dir_pfn);
}
// Init dynamic area
create_dalloc(p);
// Memory
p->memory.entry_point = 0;
p->memory.program_start = 0;
p->memory.program_end = 0;
p->memory.heap_start = 0;
p->memory.heap_end = 0;
if (type == process_kernel) {
p->memory.dynamic_top = 0;
p->memory.dynamic_bottom = 0;
} else {
p->memory.dynamic_top = p->dynamic.cur_top;
p->memory.dynamic_bottom = p->dynamic.cur_top;
}
// Msg handlers
hashtable_create(&p->msg_handlers, 0, NULL, NULL);
// ASID
if (type == process_kernel) {
p->asid = 0;
} else {
p->asid = asid_alloc();
}
// Insert the process into process list
p->prev = NULL;
p->next = processes.next;
processes.next = p;
processes.count++;
// Notify process monitor
mon_err = check_process_create_after(parent_id, p->proc_id);
assert(mon_err == EOK);
// Create cleaning thread
if (type != process_kernel) {
struct thread *t = create_thread(kernel_proc, (ulong)&kernel_tclean_thread, (ulong)p, -1, 0, 0);
run_thread(t);
}
// Done
return p;
}
int load_image(struct process *p, char *url)
{
// Load image
ulong img = (ulong)get_core_file_addr_by_name(url); // FIXME: should use namespace service
ulong entry = 0, vaddr_start = 0, vaddr_end = 0;
//int succeed = hal->load_exe(img, p->page_dir_pfn, &entry, &vaddr_start, &vaddr_end);
int succeed = load_exec(img, p->page_dir_pfn, &entry, &vaddr_start, &vaddr_end);
if (!succeed) {
return 0;
}
// Calculae rounded heap start
ulong heap_start = vaddr_end;
if (heap_start % PAGE_SIZE) {
heap_start /= PAGE_SIZE;
heap_start++;
heap_start *= PAGE_SIZE;
}
// Map the initial page for heap
ulong heap_paddr = PFN_TO_ADDR(palloc(1));
succeed = hal->map_user(
p->page_dir_pfn,
heap_start, heap_paddr, PAGE_SIZE,
0, 1, 1, 0
);
assert(succeed);
// Set memory layout
p->memory.entry_point = entry;
p->memory.program_start = vaddr_start;
p->memory.program_end = vaddr_end;
p->memory.heap_start = heap_start;
p->memory.heap_end = heap_start;
return 1;
}
void init_process()
{
kprintf("Initializing process manager\n");
// Create salloc obj
proc_salloc_id = salloc_create(sizeof(struct process), 0, 0, NULL, NULL);
// Init process list
processes.count = 0;
processes.next = NULL;
// Create the kernel process
kernel_proc = create_process(-1, "kernel", "coreimg://tdlrkrnl.bin", process_kernel, 0);
kprintf("\tSalloc ID: %d, Kernel process ID: %x\n", proc_salloc_id, kernel_proc->proc_id);
}
| 24.258242 | 104 | 0.615629 |
5e2892df1bff08376862676e840850183e78b494 | 30,326 | c | C | ports/esp32/components/driver_framebuffer/fonts/Graphik_Bold16pt7b.c | open-lv/micropython | 60413546add6ffd62609e3b629fc286b639cd4dc | [
"MIT"
] | null | null | null | ports/esp32/components/driver_framebuffer/fonts/Graphik_Bold16pt7b.c | open-lv/micropython | 60413546add6ffd62609e3b629fc286b639cd4dc | [
"MIT"
] | null | null | null | ports/esp32/components/driver_framebuffer/fonts/Graphik_Bold16pt7b.c | open-lv/micropython | 60413546add6ffd62609e3b629fc286b639cd4dc | [
"MIT"
] | null | null | null | #include "../include/driver_framebuffer.h"
const uint8_t Graphik_Bold16pt7bBitmaps[] = {
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xC0, 0x01, 0xEF, 0xFF, 0xFF, 0xF7, 0x80, 0xFD, 0xFF, 0x9F, 0xF9, 0xF7,
0x9F, 0x79, 0xF7, 0x9F, 0x79, 0xF7, 0x8F, 0x0F, 0x3C, 0x0F, 0x3C, 0x0F,
0x3C, 0x0F, 0x3C, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x1E,
0x78, 0x1E, 0x78, 0x1E, 0x78, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF,
0xFE, 0x3C, 0xF0, 0x3C, 0xF0, 0x3C, 0xF0, 0x3C, 0xE0, 0x3D, 0xE0, 0x00,
0x60, 0x00, 0x0C, 0x00, 0x01, 0x80, 0x01, 0xFE, 0x00, 0xFF, 0xF0, 0x3F,
0xFF, 0x0F, 0xFF, 0xF3, 0xFB, 0xFE, 0x7E, 0x6F, 0xCF, 0xCC, 0xFD, 0xF9,
0x80, 0x3F, 0xF0, 0x07, 0xFF, 0xC0, 0x7F, 0xFE, 0x07, 0xFF, 0xF0, 0x7F,
0xFE, 0x03, 0xFF, 0xE0, 0x0F, 0xFC, 0x01, 0x9F, 0xBF, 0x33, 0xF7, 0xE6,
0x7E, 0xFF, 0xFF, 0xCF, 0xFF, 0xF1, 0xFF, 0xFC, 0x1F, 0xFF, 0x00, 0x7F,
0x80, 0x01, 0x80, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00, 0xC0, 0x00, 0x1F,
0x80, 0x38, 0x3F, 0xC0, 0x70, 0x7F, 0xE0, 0x70, 0xF9, 0xF0, 0xE0, 0xF0,
0xF1, 0xC0, 0xF0, 0xF1, 0xC0, 0xF9, 0xF3, 0x80, 0xFF, 0xF7, 0x00, 0x7F,
0xE7, 0x00, 0x3F, 0xCE, 0x00, 0x1F, 0x9C, 0x00, 0x00, 0x1C, 0x00, 0x00,
0x38, 0xF8, 0x00, 0x71, 0xFC, 0x00, 0x73, 0xFE, 0x00, 0xE7, 0x8F, 0x01,
0xC7, 0x8F, 0x01, 0xC7, 0x8F, 0x03, 0x87, 0x8F, 0x07, 0x07, 0xFF, 0x07,
0x03, 0xFE, 0x0E, 0x01, 0xFC, 0x1C, 0x00, 0xF8, 0x01, 0xFC, 0x00, 0x0F,
0xFE, 0x00, 0x3F, 0xFE, 0x00, 0xFF, 0xFE, 0x01, 0xFC, 0xFC, 0x03, 0xF0,
0xF8, 0x07, 0xE1, 0xF0, 0x0F, 0xE7, 0xC0, 0x0F, 0xFF, 0x80, 0x1F, 0xFE,
0x00, 0x7F, 0xF0, 0x01, 0xFF, 0xE1, 0xF7, 0xFF, 0xE7, 0xCF, 0xDF, 0xEF,
0xBF, 0x3F, 0xFE, 0x7E, 0x3F, 0xFC, 0xFC, 0x3F, 0xF1, 0xF8, 0x3F, 0xE3,
0xF8, 0x7F, 0x83, 0xFF, 0xFF, 0x87, 0xFF, 0xFF, 0x83, 0xFF, 0xFF, 0x81,
0xFC, 0x7F, 0x80, 0xFF, 0xFF, 0xDE, 0x79, 0xE7, 0x9E, 0x07, 0xC1, 0xE0,
0xF8, 0x7C, 0x1F, 0x0F, 0xC3, 0xE1, 0xF8, 0x7E, 0x1F, 0x0F, 0xC3, 0xF0,
0xFC, 0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xC1, 0xF0, 0x7E, 0x1F,
0x83, 0xE0, 0xFC, 0x1F, 0x07, 0xC0, 0xF8, 0x1E, 0x07, 0xC0, 0xF8, 0x1E,
0x07, 0xC0, 0xF8, 0x3E, 0x0F, 0xC1, 0xF0, 0x7E, 0x1F, 0x83, 0xE0, 0xFC,
0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3E, 0x1F,
0x87, 0xE1, 0xF0, 0xFC, 0x3E, 0x0F, 0x87, 0xC1, 0xE0, 0xF8, 0x00, 0x0F,
0x00, 0xF0, 0x4F, 0x27, 0xEE, 0xFF, 0xEF, 0xFF, 0x1F, 0x01, 0xF8, 0x3F,
0xC7, 0x9E, 0x39, 0x80, 0x10, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07,
0xC0, 0x07, 0xC0, 0x07, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07,
0xC0, 0x10, 0x1E, 0x3F, 0x3F, 0x3E, 0x7C, 0x7C, 0x78, 0x78, 0x10, 0xFF,
0xFF, 0xFF, 0xFF, 0xF0, 0x7B, 0xFF, 0xFF, 0xFD, 0xE0, 0x00, 0x3E, 0x00,
0x78, 0x01, 0xF0, 0x03, 0xE0, 0x07, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x78,
0x01, 0xF0, 0x03, 0xE0, 0x07, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x78, 0x01,
0xF0, 0x03, 0xE0, 0x07, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x78, 0x01, 0xF0,
0x03, 0xE0, 0x07, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x78, 0x01, 0xF0, 0x03,
0xE0, 0x07, 0x80, 0x1F, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x7F, 0xF0, 0x1F,
0xFF, 0x83, 0xFF, 0xFC, 0x3F, 0xFF, 0xE7, 0xF0, 0xFE, 0x7E, 0x07, 0xEF,
0xE0, 0x7F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F,
0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0x7E, 0x07,
0xE7, 0xF0, 0xFE, 0x7F, 0xFF, 0xC3, 0xFF, 0xFC, 0x1F, 0xFF, 0x80, 0xFF,
0xF0, 0x03, 0xF8, 0x00, 0x07, 0xE1, 0xFC, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x3F, 0xC7, 0xE0, 0xFC, 0x1F, 0x83, 0xF0, 0x7E, 0x0F, 0xC1,
0xF8, 0x3F, 0x07, 0xE0, 0xFC, 0x1F, 0x83, 0xF0, 0x7E, 0x0F, 0xC1, 0xF8,
0x03, 0xF8, 0x03, 0xFF, 0x81, 0xFF, 0xF0, 0xFF, 0xFE, 0x7F, 0xFF, 0xDF,
0xC7, 0xF7, 0xE0, 0xFD, 0xF8, 0x3F, 0x7E, 0x0F, 0xC0, 0x07, 0xF0, 0x01,
0xF8, 0x00, 0xFE, 0x00, 0x7F, 0x00, 0x3F, 0x80, 0x1F, 0xC0, 0x0F, 0xE0,
0x07, 0xF0, 0x03, 0xF8, 0x01, 0xFF, 0xFC, 0xFF, 0xFF, 0x7F, 0xFF, 0xDF,
0xFF, 0xFF, 0xFF, 0xFC, 0x03, 0xF8, 0x07, 0xFF, 0xC3, 0xFF, 0xF9, 0xFF,
0xFE, 0x7F, 0x1F, 0xDF, 0x83, 0xF7, 0xC0, 0xFC, 0x00, 0x3F, 0x00, 0x1F,
0x80, 0x7F, 0xC0, 0x1F, 0xE0, 0x07, 0xFC, 0x01, 0xFF, 0x80, 0x07, 0xF0,
0x00, 0xFF, 0xF0, 0x3F, 0xFC, 0x0F, 0xFF, 0x03, 0xFF, 0xE1, 0xFD, 0xFF,
0xFE, 0x3F, 0xFF, 0x07, 0xFF, 0x80, 0x7F, 0x80, 0x00, 0x7F, 0x80, 0x07,
0xF8, 0x00, 0xFF, 0x80, 0x1F, 0xF8, 0x01, 0xFF, 0x80, 0x3F, 0xF8, 0x03,
0xDF, 0x80, 0x7D, 0xF8, 0x0F, 0x9F, 0x80, 0xF9, 0xF8, 0x1F, 0x1F, 0x81,
0xE1, 0xF8, 0x3E, 0x1F, 0x87, 0xC1, 0xF8, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x1F, 0x80, 0x01, 0xF8, 0x00, 0x1F,
0x80, 0x01, 0xF8, 0x00, 0x1F, 0x80, 0x7F, 0xFF, 0x9F, 0xFF, 0xE7, 0xFF,
0xF9, 0xFF, 0xFE, 0x7F, 0xFF, 0x9F, 0x00, 0x07, 0xC0, 0x01, 0xF0, 0x00,
0x7C, 0xFC, 0x1F, 0x7F, 0xC7, 0xFF, 0xF9, 0xFF, 0xFE, 0x7C, 0x1F, 0xDE,
0x03, 0xF0, 0x00, 0xFC, 0x00, 0x3F, 0xFC, 0x0F, 0xFF, 0x87, 0xF7, 0xFF,
0xF9, 0xFF, 0xFE, 0x3F, 0xFF, 0x07, 0xFF, 0x80, 0x7F, 0x80, 0x01, 0xFC,
0x00, 0xFF, 0xE0, 0x7F, 0xFE, 0x1F, 0xFF, 0xE3, 0xFF, 0xFC, 0xFE, 0x1F,
0x9F, 0x81, 0xFF, 0xF0, 0x00, 0xFC, 0x7C, 0x1F, 0xBF, 0xE3, 0xFF, 0xFE,
0x7F, 0xFF, 0xEF, 0xF0, 0xFF, 0xFC, 0x1F, 0xFF, 0x01, 0xFF, 0xE0, 0x3F,
0x7C, 0x07, 0xEF, 0xC1, 0xFD, 0xFC, 0x7F, 0x1F, 0xFF, 0xE1, 0xFF, 0xF8,
0x1F, 0xFE, 0x00, 0xFE, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF,
0xFF, 0xEF, 0xFF, 0xF0, 0x03, 0xF0, 0x03, 0xF8, 0x01, 0xFC, 0x00, 0xFC,
0x00, 0xFE, 0x00, 0x7F, 0x00, 0x3F, 0x00, 0x3F, 0x80, 0x1F, 0xC0, 0x0F,
0xC0, 0x0F, 0xE0, 0x07, 0xF0, 0x03, 0xF0, 0x03, 0xF8, 0x01, 0xF8, 0x00,
0xFC, 0x00, 0xFE, 0x00, 0x7E, 0x00, 0x03, 0xF8, 0x01, 0xFF, 0xC0, 0xFF,
0xFE, 0x1F, 0xFF, 0xC7, 0xF1, 0xFC, 0xFC, 0x1F, 0x9F, 0x83, 0xF3, 0xF0,
0x7E, 0x7F, 0x1F, 0x87, 0xFF, 0xF0, 0x7F, 0xFC, 0x0F, 0xFF, 0xC7, 0xFF,
0xFC, 0xFC, 0x1F, 0xBF, 0x01, 0xFF, 0xE0, 0x3F, 0xFC, 0x07, 0xFF, 0x80,
0xFF, 0xF8, 0x3F, 0xBF, 0xFF, 0xE3, 0xFF, 0xF8, 0x3F, 0xFE, 0x01, 0xFF,
0x00, 0x03, 0xF8, 0x03, 0xFF, 0xC0, 0xFF, 0xFC, 0x3F, 0xFF, 0xC7, 0xE1,
0xFD, 0xFC, 0x1F, 0xBF, 0x03, 0xF7, 0xE0, 0x3F, 0xFC, 0x0F, 0xFF, 0x81,
0xFF, 0xF8, 0x7F, 0xBF, 0xFF, 0xF3, 0xFF, 0xFE, 0x3F, 0xEF, 0xC1, 0xF1,
0xF8, 0x00, 0x3F, 0xFC, 0x0F, 0xDF, 0xC3, 0xF9, 0xFF, 0xFF, 0x3F, 0xFF,
0xC3, 0xFF, 0xF0, 0x3F, 0xFC, 0x01, 0xFE, 0x00, 0x7B, 0xFF, 0xFF, 0xFD,
0xE0, 0x00, 0x01, 0xEF, 0xFF, 0xFF, 0xF7, 0x80, 0x1E, 0x3F, 0x3F, 0x3F,
0x3F, 0x1E, 0x00, 0x00, 0x00, 0x30, 0x3E, 0x3E, 0x3E, 0x7C, 0x78, 0x78,
0xF0, 0x70, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0E, 0x01, 0xF0, 0x3F, 0x83,
0xFC, 0x7F, 0x8F, 0xF8, 0xFF, 0x07, 0xF8, 0x0F, 0xF0, 0x1F, 0xE0, 0x7F,
0x80, 0xFC, 0x01, 0xE0, 0x07, 0x00, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFC, 0x00, 0x06, 0x00, 0x38, 0x01, 0xF0, 0x0F, 0xE0, 0x7F, 0x80,
0xFF, 0x01, 0xFE, 0x07, 0xF8, 0x3F, 0xC7, 0xF8, 0xFF, 0x0F, 0xF0, 0x7E,
0x03, 0xC0, 0x1C, 0x00, 0x80, 0x00, 0x07, 0xF0, 0x1F, 0xFC, 0x3F, 0xFE,
0x7F, 0xFF, 0xFE, 0x7F, 0xFC, 0x3F, 0xFC, 0x3F, 0x00, 0x7F, 0x00, 0x7E,
0x00, 0xFE, 0x01, 0xFC, 0x03, 0xF8, 0x07, 0xF0, 0x07, 0xE0, 0x07, 0xC0,
0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x0F, 0xC0, 0x0F, 0xC0,
0x0F, 0xC0, 0x07, 0x80, 0x00, 0x3F, 0xC0, 0x00, 0x1F, 0xFF, 0x00, 0x0F,
0x81, 0xF8, 0x03, 0x80, 0x07, 0x80, 0xE0, 0x00, 0x78, 0x38, 0x00, 0x07,
0x0E, 0x00, 0x00, 0x71, 0xC1, 0xE7, 0x8E, 0x70, 0xFE, 0xF0, 0xEE, 0x3F,
0xFE, 0x1F, 0x87, 0xFF, 0xC3, 0xF1, 0xF8, 0xF8, 0x7E, 0x3E, 0x1F, 0x0F,
0xC7, 0xC3, 0xE1, 0xF8, 0xF8, 0x7C, 0x3F, 0x1F, 0x9F, 0x0E, 0xE3, 0xFF,
0xE1, 0xDC, 0x3F, 0xFE, 0x71, 0xC7, 0xFB, 0xFC, 0x38, 0x3C, 0x3F, 0x03,
0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x07, 0x00, 0x01, 0xC0, 0x78, 0x00,
0xF0, 0x07, 0xC0, 0x7C, 0x00, 0x7F, 0xFE, 0x00, 0x01, 0xFE, 0x00, 0x00,
0x01, 0xFF, 0x00, 0x03, 0xFE, 0x00, 0x07, 0xFE, 0x00, 0x1F, 0xFC, 0x00,
0x3F, 0xF8, 0x00, 0x7F, 0xF8, 0x00, 0xFF, 0xF0, 0x03, 0xF7, 0xE0, 0x07,
0xEF, 0xE0, 0x0F, 0x9F, 0xC0, 0x3F, 0x3F, 0x80, 0x7E, 0x3F, 0x00, 0xFC,
0x7F, 0x03, 0xF0, 0xFE, 0x07, 0xE0, 0xFC, 0x0F, 0xFF, 0xFC, 0x3F, 0xFF,
0xF8, 0x7F, 0xFF, 0xF0, 0xFF, 0xFF, 0xF3, 0xF0, 0x0F, 0xE7, 0xE0, 0x1F,
0xCF, 0xC0, 0x1F, 0xDF, 0x80, 0x3F, 0x80, 0xFF, 0xFC, 0x3F, 0xFF, 0xCF,
0xFF, 0xFB, 0xFF, 0xFF, 0xFC, 0x1F, 0xFF, 0x03, 0xFF, 0xC0, 0xFF, 0xF0,
0x3F, 0xFC, 0x1F, 0xBF, 0xFF, 0xEF, 0xFF, 0xE3, 0xFF, 0xFC, 0xFF, 0xFF,
0xBF, 0x07, 0xEF, 0xC0, 0xFF, 0xF0, 0x3F, 0xFC, 0x0F, 0xFF, 0x03, 0xFF,
0xC1, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xBF, 0xFF, 0xCF, 0xFF, 0xC0, 0x00,
0xFF, 0x00, 0x1F, 0xFF, 0x00, 0xFF, 0xFE, 0x07, 0xFF, 0xFC, 0x3F, 0xFF,
0xF9, 0xFF, 0x0F, 0xE7, 0xF0, 0x1F, 0xDF, 0xC0, 0x7F, 0xFE, 0x01, 0xFF,
0xF8, 0x00, 0x0F, 0xE0, 0x00, 0x3F, 0x80, 0x00, 0xFE, 0x00, 0x03, 0xF8,
0x00, 0x0F, 0xE0, 0x0F, 0xFF, 0xC0, 0x3F, 0x7F, 0x01, 0xFD, 0xFF, 0x0F,
0xF3, 0xFF, 0xFF, 0x87, 0xFF, 0xFC, 0x0F, 0xFF, 0xE0, 0x1F, 0xFF, 0x00,
0x1F, 0xF0, 0x00, 0xFF, 0xF0, 0x0F, 0xFF, 0xE0, 0xFF, 0xFF, 0x8F, 0xFF,
0xFC, 0xFF, 0xFF, 0xCF, 0xC1, 0xFE, 0xFC, 0x0F, 0xEF, 0xC0, 0x7F, 0xFC,
0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF,
0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x7E, 0xFC, 0x0F, 0xEF, 0xC1, 0xFE,
0xFF, 0xFF, 0xCF, 0xFF, 0xF8, 0xFF, 0xFF, 0x0F, 0xFF, 0xE0, 0xFF, 0xF0,
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC,
0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFF, 0xFC, 0xFF,
0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC,
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x3F, 0x00,
0x7E, 0x00, 0xFC, 0x01, 0xF8, 0x03, 0xFF, 0xF7, 0xFF, 0xEF, 0xFF, 0xDF,
0xFF, 0xBF, 0xFF, 0x7E, 0x00, 0xFC, 0x01, 0xF8, 0x03, 0xF0, 0x07, 0xE0,
0x0F, 0xC0, 0x1F, 0x80, 0x3F, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x07, 0xFF,
0x80, 0x3F, 0xFF, 0xC0, 0xFF, 0xFF, 0xC3, 0xFF, 0xFF, 0xCF, 0xF0, 0x3F,
0x9F, 0xC0, 0x3F, 0x3F, 0x00, 0x7E, 0xFC, 0x00, 0x01, 0xF8, 0x00, 0x03,
0xF0, 0x3F, 0xFF, 0xE0, 0x7F, 0xFF, 0xC0, 0xFF, 0xFF, 0x81, 0xFF, 0xFF,
0x00, 0x1F, 0xBF, 0x00, 0x3F, 0x7F, 0x00, 0xFC, 0xFF, 0x03, 0xF8, 0xFF,
0xFF, 0xF0, 0xFF, 0xFF, 0xC0, 0xFF, 0xFF, 0x00, 0xFF, 0xF8, 0x00, 0x3F,
0xC0, 0x00, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F,
0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC,
0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xF0,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x03, 0xF0, 0x3F, 0x03, 0xF0, 0x3F,
0x03, 0xF0, 0x3F, 0x03, 0xF0, 0x3F, 0x03, 0xF0, 0x3F, 0x03, 0xF0, 0x3F,
0x03, 0xF0, 0x3F, 0x03, 0xF0, 0x3F, 0x03, 0xF0, 0x7F, 0xFF, 0xEF, 0xFE,
0xFF, 0xCF, 0xF8, 0x7F, 0x00, 0xFC, 0x0F, 0xEF, 0xC0, 0xFC, 0xFC, 0x1F,
0xCF, 0xC3, 0xF8, 0xFC, 0x7F, 0x0F, 0xC7, 0xE0, 0xFC, 0xFC, 0x0F, 0xDF,
0xC0, 0xFF, 0xF8, 0x0F, 0xFF, 0x00, 0xFF, 0xE0, 0x0F, 0xFF, 0x00, 0xFF,
0xF8, 0x0F, 0xFF, 0x80, 0xFD, 0xFC, 0x0F, 0xDF, 0xE0, 0xFC, 0xFE, 0x0F,
0xC7, 0xF0, 0xFC, 0x7F, 0x8F, 0xC3, 0xF8, 0xFC, 0x1F, 0xCF, 0xC1, 0xFE,
0xFC, 0x0F, 0xF0, 0xFC, 0x01, 0xF8, 0x03, 0xF0, 0x07, 0xE0, 0x0F, 0xC0,
0x1F, 0x80, 0x3F, 0x00, 0x7E, 0x00, 0xFC, 0x01, 0xF8, 0x03, 0xF0, 0x07,
0xE0, 0x0F, 0xC0, 0x1F, 0x80, 0x3F, 0x00, 0x7E, 0x00, 0xFC, 0x01, 0xF8,
0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xFF,
0x80, 0x7F, 0xFF, 0xC0, 0x3F, 0xFF, 0xF0, 0x3F, 0xFF, 0xF8, 0x1F, 0xFF,
0xFC, 0x0F, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0x87, 0xFF, 0xFF, 0xC3, 0xFF,
0xFF, 0xF3, 0xFF, 0xFF, 0xF9, 0xFF, 0xFF, 0x7C, 0xF7, 0xFF, 0xBF, 0xFB,
0xFF, 0xDF, 0xFD, 0xFF, 0xE7, 0xFC, 0xFF, 0xF3, 0xFE, 0x7F, 0xF8, 0xFE,
0x3F, 0xFC, 0x7F, 0x1F, 0xFE, 0x3F, 0x8F, 0xFF, 0x0F, 0x87, 0xFF, 0x87,
0xC3, 0xFF, 0xC3, 0xE1, 0xFF, 0xE0, 0xE0, 0xFF, 0xF0, 0x70, 0x7E, 0xFF,
0x03, 0xFF, 0xF0, 0x3F, 0xFF, 0x83, 0xFF, 0xF8, 0x3F, 0xFF, 0xC3, 0xFF,
0xFC, 0x3F, 0xFF, 0xE3, 0xFF, 0xFE, 0x3F, 0xFF, 0xF3, 0xFF, 0xFF, 0x3F,
0xFD, 0xFB, 0xFF, 0xCF, 0xBF, 0xFC, 0xFF, 0xFF, 0xC7, 0xFF, 0xFC, 0x7F,
0xFF, 0xC3, 0xFF, 0xFC, 0x3F, 0xFF, 0xC1, 0xFF, 0xFC, 0x1F, 0xFF, 0xC0,
0xFF, 0xFC, 0x0F, 0xFF, 0xC0, 0x7F, 0xFC, 0x07, 0xF0, 0x00, 0xFE, 0x00,
0x0F, 0xFF, 0x80, 0x3F, 0xFF, 0x80, 0xFF, 0xFF, 0x83, 0xFF, 0xFF, 0x8F,
0xF0, 0x7F, 0x9F, 0xC0, 0x7F, 0x3F, 0x00, 0x7E, 0xFC, 0x00, 0x7F, 0xF8,
0x00, 0xFF, 0xF0, 0x01, 0xFF, 0xE0, 0x03, 0xFF, 0xC0, 0x07, 0xFF, 0x80,
0x0F, 0xFF, 0x00, 0x1F, 0xBF, 0x00, 0x7E, 0x7F, 0x01, 0xFC, 0xFF, 0x07,
0xF8, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0x80, 0xFF, 0xFE, 0x00, 0xFF, 0xF8,
0x00, 0x3F, 0x80, 0x00, 0xFF, 0xF0, 0x7F, 0xFE, 0x3F, 0xFF, 0x9F, 0xFF,
0xEF, 0xFF, 0xFF, 0xE1, 0xFF, 0xF0, 0x7F, 0xF8, 0x3F, 0xFC, 0x1F, 0xFE,
0x0F, 0xFF, 0x0F, 0xFF, 0xFF, 0xEF, 0xFF, 0xE7, 0xFF, 0xE3, 0xFF, 0xC1,
0xF8, 0x00, 0xFC, 0x00, 0x7E, 0x00, 0x3F, 0x00, 0x1F, 0x80, 0x0F, 0xC0,
0x07, 0xE0, 0x03, 0xF0, 0x00, 0x00, 0xFE, 0x00, 0x0F, 0xFF, 0x80, 0x3F,
0xFF, 0x80, 0xFF, 0xFF, 0x83, 0xFF, 0xFF, 0x8F, 0xF0, 0x7F, 0x9F, 0xC0,
0x7F, 0x3F, 0x00, 0x7E, 0xFC, 0x00, 0x7F, 0xF8, 0x00, 0xFF, 0xF0, 0x01,
0xFF, 0xE0, 0x03, 0xFF, 0xC0, 0x07, 0xFF, 0x80, 0x0F, 0xFF, 0x00, 0x1F,
0xBF, 0x06, 0x7E, 0x7E, 0x1F, 0xFC, 0xFF, 0x7F, 0xF8, 0xFF, 0xFF, 0xE0,
0xFF, 0xFF, 0x80, 0xFF, 0xFE, 0x00, 0xFF, 0xFE, 0x00, 0x3F, 0xFE, 0x00,
0x00, 0xFC, 0x00, 0x00, 0xF0, 0x00, 0x00, 0xC0, 0xFF, 0xF8, 0x1F, 0xFF,
0xC3, 0xFF, 0xFC, 0x7F, 0xFF, 0xCF, 0xFF, 0xFD, 0xF8, 0x3F, 0xBF, 0x03,
0xF7, 0xE0, 0x7E, 0xFC, 0x0F, 0xDF, 0x81, 0xFB, 0xF0, 0x7E, 0x7F, 0xFF,
0xCF, 0xFF, 0xF1, 0xFF, 0xFC, 0x3F, 0xFF, 0x87, 0xE7, 0xF0, 0xFC, 0x7F,
0x1F, 0x8F, 0xE3, 0xF0, 0xFE, 0x7E, 0x0F, 0xCF, 0xC1, 0xFD, 0xF8, 0x1F,
0xBF, 0x03, 0xF8, 0x03, 0xFC, 0x01, 0xFF, 0xE0, 0x7F, 0xFE, 0x1F, 0xFF,
0xC7, 0xF1, 0xFC, 0xFC, 0x1F, 0x9F, 0x81, 0xF3, 0xF8, 0x00, 0x7F, 0xF0,
0x0F, 0xFF, 0xE0, 0xFF, 0xFE, 0x1F, 0xFF, 0xE1, 0xFF, 0xFE, 0x0F, 0xFF,
0xC0, 0x1F, 0xF8, 0x00, 0x3F, 0x7E, 0x07, 0xEF, 0xC0, 0xFD, 0xFC, 0x3F,
0x3F, 0xFF, 0xE3, 0xFF, 0xF8, 0x3F, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xFC, 0x00,
0x3F, 0x00, 0x0F, 0xC0, 0x03, 0xF0, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x0F,
0xC0, 0x03, 0xF0, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x0F, 0xC0, 0x03, 0xF0,
0x00, 0xFC, 0x00, 0x3F, 0x00, 0x0F, 0xC0, 0x03, 0xF0, 0x00, 0xFC, 0x00,
0x3F, 0x00, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F,
0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03,
0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFC, 0x03, 0xFF, 0xC0,
0x3F, 0xFC, 0x03, 0xFF, 0xC0, 0x3F, 0xFE, 0x07, 0xF7, 0xF0, 0xFE, 0x7F,
0xFF, 0xE3, 0xFF, 0xFC, 0x3F, 0xFF, 0x80, 0xFF, 0xF0, 0x03, 0xFC, 0x00,
0x7E, 0x00, 0xFD, 0xFC, 0x03, 0xF7, 0xF0, 0x0F, 0xDF, 0xC0, 0x7E, 0x3F,
0x81, 0xF8, 0xFE, 0x07, 0xE3, 0xF8, 0x1F, 0x07, 0xE0, 0xFC, 0x1F, 0xC3,
0xF0, 0x7F, 0x0F, 0x80, 0xFC, 0x7E, 0x03, 0xF9, 0xF8, 0x0F, 0xE7, 0xC0,
0x1F, 0x9F, 0x00, 0x7E, 0xFC, 0x01, 0xFF, 0xF0, 0x03, 0xFF, 0x80, 0x0F,
0xFE, 0x00, 0x3F, 0xF8, 0x00, 0x7F, 0xC0, 0x01, 0xFF, 0x00, 0x07, 0xFC,
0x00, 0x0F, 0xE0, 0x00, 0x7E, 0x07, 0xE0, 0x7E, 0xFC, 0x1F, 0xC1, 0xF9,
0xF8, 0x3F, 0x83, 0xF3, 0xF8, 0x7F, 0x07, 0xE7, 0xF0, 0xFF, 0x0F, 0xC7,
0xE1, 0xFE, 0x1F, 0x8F, 0xC7, 0xFC, 0x7E, 0x1F, 0x8F, 0xF8, 0xFC, 0x3F,
0x9F, 0xF1, 0xF8, 0x3F, 0x3D, 0xF3, 0xF0, 0x7E, 0x7B, 0xE7, 0xC0, 0xFD,
0xF7, 0xDF, 0x81, 0xFB, 0xCF, 0xBF, 0x03, 0xFF, 0x8F, 0xFE, 0x03, 0xFF,
0x1F, 0xF8, 0x07, 0xFE, 0x3F, 0xF0, 0x0F, 0xF8, 0x7F, 0xE0, 0x1F, 0xF0,
0x7F, 0xC0, 0x1F, 0xE0, 0xFF, 0x80, 0x3F, 0xC1, 0xFE, 0x00, 0x7F, 0x83,
0xFC, 0x00, 0xFE, 0x07, 0xF8, 0x00, 0xFC, 0x07, 0xF0, 0x00, 0xFF, 0x03,
0xF9, 0xFC, 0x0F, 0xC3, 0xF8, 0x7F, 0x0F, 0xE1, 0xF8, 0x1F, 0xCF, 0xE0,
0x7F, 0x3F, 0x00, 0xFF, 0xF8, 0x01, 0xFF, 0xE0, 0x07, 0xFF, 0x00, 0x0F,
0xFC, 0x00, 0x3F, 0xE0, 0x00, 0xFF, 0x80, 0x03, 0xFF, 0x00, 0x1F, 0xFE,
0x00, 0x7F, 0xF8, 0x03, 0xF7, 0xF0, 0x1F, 0xDF, 0xC0, 0x7E, 0x3F, 0x83,
0xF8, 0xFE, 0x0F, 0xC1, 0xFC, 0x7F, 0x07, 0xF9, 0xF8, 0x0F, 0xEF, 0xE0,
0x3F, 0xC0, 0xFE, 0x03, 0xF7, 0xE0, 0x7E, 0x7F, 0x07, 0xE3, 0xF0, 0xFC,
0x3F, 0x8F, 0xC1, 0xF9, 0xF8, 0x1F, 0xDF, 0x80, 0xFF, 0xF0, 0x0F, 0xFE,
0x00, 0x7F, 0xE0, 0x03, 0xFC, 0x00, 0x3F, 0xC0, 0x01, 0xF8, 0x00, 0x1F,
0x80, 0x01, 0xF8, 0x00, 0x1F, 0x80, 0x01, 0xF8, 0x00, 0x1F, 0x80, 0x01,
0xF8, 0x00, 0x1F, 0x80, 0x01, 0xF8, 0x00, 0x1F, 0x80, 0x01, 0xF8, 0x00,
0x7F, 0xFF, 0xDF, 0xFF, 0xF7, 0xFF, 0xF9, 0xFF, 0xFE, 0x7F, 0xFF, 0x00,
0x1F, 0xC0, 0x0F, 0xE0, 0x03, 0xF8, 0x01, 0xFC, 0x00, 0x7E, 0x00, 0x3F,
0x80, 0x0F, 0xC0, 0x07, 0xF0, 0x01, 0xF8, 0x00, 0xFE, 0x00, 0x3F, 0x00,
0x1F, 0xC0, 0x07, 0xE0, 0x03, 0xFF, 0xFD, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x3F, 0x0F,
0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xC3, 0xF0,
0xFC, 0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F,
0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xF0, 0x03, 0xE0, 0x07, 0x80, 0x1E, 0x00,
0x7C, 0x00, 0xF0, 0x03, 0xC0, 0x0F, 0x80, 0x1E, 0x00, 0x78, 0x01, 0xF0,
0x03, 0xC0, 0x0F, 0x00, 0x3E, 0x00, 0x78, 0x01, 0xE0, 0x07, 0xC0, 0x0F,
0x00, 0x3C, 0x00, 0xF8, 0x01, 0xE0, 0x07, 0x80, 0x1F, 0x00, 0x3C, 0x00,
0xF0, 0x03, 0xE0, 0x07, 0x80, 0x1F, 0x00, 0x7C, 0x00, 0xF0, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xC3, 0xF0, 0xFC,
0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xC3, 0xF0, 0xFC, 0x3F, 0x0F,
0xC3, 0xF0, 0xFC, 0x3F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x07,
0xC0, 0x1F, 0xC0, 0x3F, 0x80, 0xFF, 0x81, 0xFF, 0x07, 0xDF, 0x1F, 0x3E,
0x3E, 0x3E, 0xF8, 0x7D, 0xF0, 0x7C, 0xFF, 0xFF, 0xFF, 0xF0, 0x7C, 0xF8,
0xF9, 0xF1, 0xE0, 0x07, 0xF0, 0x1F, 0xFC, 0x3F, 0xFE, 0x7F, 0xFF, 0x7E,
0x7F, 0x7C, 0x3F, 0x00, 0x3F, 0x0F, 0xFF, 0x3F, 0xFF, 0x7F, 0xFF, 0xFE,
0x3F, 0xFC, 0x3F, 0xFC, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xBF, 0x1F,
0x3F, 0xFC, 0x00, 0x3F, 0x00, 0x0F, 0xC0, 0x03, 0xF0, 0x00, 0xFC, 0x00,
0x3F, 0x00, 0x0F, 0xC0, 0x03, 0xF1, 0xF0, 0xFD, 0xFE, 0x3F, 0xFF, 0xCF,
0xFF, 0xFB, 0xF8, 0x7E, 0xFE, 0x1F, 0xFF, 0x03, 0xFF, 0xC0, 0xFF, 0xF0,
0x3F, 0xFC, 0x0F, 0xFF, 0x03, 0xFF, 0xE1, 0xFF, 0xF8, 0x7E, 0xFF, 0xFF,
0xBF, 0xFF, 0xCF, 0xDF, 0xE3, 0xF3, 0xF0, 0x07, 0xF0, 0x0F, 0xFE, 0x0F,
0xFF, 0x8F, 0xFF, 0xE7, 0xE1, 0xF7, 0xF0, 0xFB, 0xF0, 0x01, 0xF8, 0x00,
0xFC, 0x00, 0x7E, 0x00, 0x3F, 0x03, 0xFF, 0xC3, 0xE7, 0xE1, 0xF3, 0xFF,
0xF8, 0xFF, 0xF8, 0x3F, 0xF8, 0x07, 0xF0, 0x00, 0x00, 0x0F, 0xC0, 0x03,
0xF0, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x0F, 0xC0, 0x03, 0xF0, 0x00, 0xFC,
0x3F, 0x3F, 0x1F, 0xEF, 0xCF, 0xFF, 0xF7, 0xFF, 0xFD, 0xF8, 0x7F, 0xFE,
0x1F, 0xFF, 0x03, 0xFF, 0xC0, 0xFF, 0xF0, 0x3F, 0xFC, 0x0F, 0xFF, 0x03,
0xFF, 0xE1, 0xFD, 0xF8, 0x7F, 0x7F, 0xFF, 0xCF, 0xFF, 0xF1, 0xFE, 0xFC,
0x3F, 0x3F, 0x03, 0xF8, 0x03, 0xFF, 0x81, 0xFF, 0xF0, 0xFF, 0xFE, 0x7F,
0x1F, 0x9F, 0x83, 0xF7, 0xC0, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF,
0xF7, 0xC0, 0x01, 0xF8, 0x3F, 0x7E, 0x1F, 0xCF, 0xFF, 0xE1, 0xFF, 0xF8,
0x3F, 0xFC, 0x03, 0xF8, 0x00, 0x07, 0xE1, 0xFC, 0x7F, 0x9F, 0xF3, 0xF0,
0x7E, 0x0F, 0xC7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x9F, 0x83, 0xF0, 0x7E,
0x0F, 0xC1, 0xF8, 0x3F, 0x07, 0xE0, 0xFC, 0x1F, 0x83, 0xF0, 0x7E, 0x0F,
0xC1, 0xF8, 0x0F, 0xCF, 0xC7, 0xFB, 0xF3, 0xFF, 0xFD, 0xFF, 0xFF, 0x7E,
0x1F, 0xFF, 0x87, 0xFF, 0xC0, 0xFF, 0xF0, 0x3F, 0xFC, 0x0F, 0xFF, 0x03,
0xFF, 0xE1, 0xFD, 0xF8, 0x7F, 0x7F, 0xFF, 0xCF, 0xFF, 0xF1, 0xFE, 0xFC,
0x3E, 0x3F, 0x00, 0x0F, 0xFF, 0x03, 0xFF, 0xE1, 0xF9, 0xFF, 0xFE, 0x7F,
0xFF, 0x07, 0xFF, 0x80, 0x7F, 0x80, 0xFC, 0x00, 0x7E, 0x00, 0x3F, 0x00,
0x1F, 0x80, 0x0F, 0xC0, 0x07, 0xE0, 0x03, 0xF0, 0x01, 0xF8, 0xF8, 0xFD,
0xFE, 0x7F, 0xFF, 0xBF, 0xFF, 0xFF, 0xC7, 0xFF, 0xC1, 0xFF, 0xE0, 0xFF,
0xF0, 0x7F, 0xF8, 0x3F, 0xFC, 0x1F, 0xFE, 0x0F, 0xFF, 0x07, 0xFF, 0x83,
0xFF, 0xC1, 0xFF, 0xE0, 0xFF, 0xF0, 0x7F, 0xF8, 0x3F, 0x7B, 0xFF, 0xFF,
0xFD, 0xE0, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x1E, 0x3F, 0x3F, 0x3F, 0x3F, 0x1E, 0x00, 0x3F, 0x3F,
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFE, 0xFC, 0xF0, 0xFC, 0x00, 0x7E,
0x00, 0x3F, 0x00, 0x1F, 0x80, 0x0F, 0xC0, 0x07, 0xE0, 0x03, 0xF0, 0x01,
0xF8, 0x7E, 0xFC, 0x7E, 0x7E, 0x3F, 0x3F, 0x3F, 0x1F, 0xBF, 0x0F, 0xDF,
0x07, 0xFF, 0x83, 0xFF, 0x81, 0xFF, 0xC0, 0xFF, 0xF0, 0x7E, 0xFC, 0x3F,
0x7E, 0x1F, 0x9F, 0x8F, 0xCF, 0xE7, 0xE3, 0xF3, 0xF0, 0xFD, 0xF8, 0x7E,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0x3E, 0x3F, 0x7F, 0xBF,
0xCF, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0xFE, 0x7F, 0x9F, 0xFF, 0x0F,
0xC3, 0xFF, 0xC3, 0xF0, 0xFF, 0xF0, 0xFC, 0x3F, 0xFC, 0x3F, 0x0F, 0xFF,
0x0F, 0xC3, 0xFF, 0xC3, 0xF0, 0xFF, 0xF0, 0xFC, 0x3F, 0xFC, 0x3F, 0x0F,
0xFF, 0x0F, 0xC3, 0xFF, 0xC3, 0xF0, 0xFF, 0xF0, 0xFC, 0x3F, 0xFC, 0x3F,
0x0F, 0xC0, 0xFC, 0x7C, 0x7E, 0xFF, 0x3F, 0xFF, 0xDF, 0xFF, 0xFF, 0xE3,
0xFF, 0xE0, 0xFF, 0xF0, 0x7F, 0xF8, 0x3F, 0xFC, 0x1F, 0xFE, 0x0F, 0xFF,
0x07, 0xFF, 0x83, 0xFF, 0xC1, 0xFF, 0xE0, 0xFF, 0xF0, 0x7F, 0xF8, 0x3F,
0xFC, 0x1F, 0x80, 0x03, 0xF0, 0x03, 0xFF, 0x03, 0xFF, 0xF1, 0xFF, 0xFE,
0x7E, 0x1F, 0xBF, 0x87, 0xFF, 0xC0, 0xFF, 0xF0, 0x3F, 0xFC, 0x0F, 0xFF,
0x03, 0xFF, 0xC0, 0xFF, 0xF8, 0x7F, 0x7E, 0x1F, 0x9F, 0xFF, 0xE3, 0xFF,
0xF0, 0x7F, 0xF8, 0x03, 0xF0, 0x00, 0xFC, 0xFC, 0x3F, 0x7F, 0x8F, 0xFF,
0xF3, 0xFF, 0xFE, 0xFE, 0x1F, 0xBF, 0x87, 0xFF, 0xC0, 0xFF, 0xF0, 0x3F,
0xFC, 0x0F, 0xFF, 0x03, 0xFF, 0xC0, 0xFF, 0xF8, 0x7F, 0xFE, 0x1F, 0xBF,
0xFF, 0xEF, 0xFF, 0xF3, 0xF7, 0xF8, 0xFC, 0xFC, 0x3F, 0x00, 0x0F, 0xC0,
0x03, 0xF0, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x0F, 0xC0, 0x00, 0x0F, 0xCF,
0xC7, 0xFB, 0xF3, 0xFF, 0xFD, 0xFF, 0xFF, 0x7E, 0x1F, 0xFF, 0x87, 0xFF,
0xC0, 0xFF, 0xF0, 0x3F, 0xFC, 0x0F, 0xFF, 0x03, 0xFF, 0xC0, 0xFF, 0xF8,
0x7F, 0x7E, 0x1F, 0xDF, 0xFF, 0xF3, 0xFF, 0xFC, 0x7F, 0xBF, 0x0F, 0x8F,
0xC0, 0x03, 0xF0, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x0F, 0xC0, 0x03, 0xF0,
0x00, 0xFC, 0xFC, 0x7F, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x3F, 0x87,
0xE0, 0xFC, 0x1F, 0x83, 0xF0, 0x7E, 0x0F, 0xC1, 0xF8, 0x3F, 0x07, 0xE0,
0xFC, 0x00, 0x0F, 0xE0, 0x7F, 0xF1, 0xFF, 0xE7, 0xFF, 0xEF, 0xC7, 0xDF,
0x8F, 0xBF, 0xC0, 0x7F, 0xFC, 0x7F, 0xFC, 0x3F, 0xFC, 0x07, 0xFF, 0xE3,
0xFF, 0xC7, 0xFF, 0xFF, 0xDF, 0xFF, 0x1F, 0xFC, 0x0F, 0xE0, 0x3F, 0x07,
0xE0, 0xFC, 0x1F, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0xE0,
0xFC, 0x1F, 0x83, 0xF0, 0x7E, 0x0F, 0xC1, 0xF8, 0x3F, 0x07, 0xFC, 0x7F,
0x8F, 0xF0, 0x7E, 0xFC, 0x1F, 0xFE, 0x0F, 0xFF, 0x07, 0xFF, 0x83, 0xFF,
0xC1, 0xFF, 0xE0, 0xFF, 0xF0, 0x7F, 0xF8, 0x3F, 0xFC, 0x1F, 0xFE, 0x0F,
0xFF, 0x07, 0xFF, 0x83, 0xFF, 0xE3, 0xFF, 0xFF, 0xFD, 0xFF, 0xFE, 0x7F,
0xBF, 0x1F, 0x1F, 0x80, 0xFC, 0x07, 0xDF, 0x81, 0xF7, 0xE0, 0xF9, 0xF8,
0x3E, 0x3F, 0x0F, 0x8F, 0xC7, 0xC1, 0xF1, 0xF0, 0x7E, 0x7C, 0x1F, 0xBE,
0x03, 0xEF, 0x80, 0xFF, 0xE0, 0x3F, 0xF0, 0x07, 0xFC, 0x01, 0xFF, 0x00,
0x7F, 0x80, 0x0F, 0xE0, 0x03, 0xF8, 0x00, 0xFC, 0x1F, 0x07, 0xDF, 0x07,
0xC3, 0xF7, 0xE1, 0xF0, 0xF9, 0xF8, 0xFE, 0x3E, 0x3E, 0x3F, 0x8F, 0x8F,
0x8F, 0xE7, 0xE3, 0xF3, 0xF9, 0xF0, 0xFD, 0xFF, 0x7C, 0x1F, 0x7F, 0xDF,
0x07, 0xDE, 0xFF, 0x81, 0xFF, 0x3F, 0xE0, 0x3F, 0xCF, 0xF8, 0x0F, 0xF1,
0xFC, 0x03, 0xFC, 0x7F, 0x00, 0x7E, 0x1F, 0xC0, 0x1F, 0x87, 0xE0, 0x07,
0xE0, 0xF8, 0x00, 0x7E, 0x0F, 0xCF, 0xC7, 0xE3, 0xF9, 0xF0, 0x7E, 0xFC,
0x1F, 0xFE, 0x03, 0xFF, 0x00, 0x7F, 0xC0, 0x1F, 0xE0, 0x03, 0xF8, 0x01,
0xFF, 0x00, 0xFF, 0xC0, 0x3F, 0xF8, 0x1F, 0xFF, 0x07, 0xCF, 0xC3, 0xF1,
0xF9, 0xF8, 0x7E, 0x7C, 0x0F, 0xC0, 0xFE, 0x07, 0xDF, 0x83, 0xF7, 0xE0,
0xF8, 0xFC, 0x3E, 0x3F, 0x1F, 0x87, 0xC7, 0xC1, 0xF9, 0xF0, 0x7E, 0xF8,
0x0F, 0xBE, 0x03, 0xFF, 0x80, 0x7F, 0xC0, 0x1F, 0xF0, 0x03, 0xF8, 0x00,
0xFE, 0x00, 0x3F, 0x80, 0x07, 0xC0, 0x03, 0xF0, 0x00, 0xFC, 0x00, 0x3E,
0x00, 0x1F, 0x80, 0x07, 0xC0, 0x01, 0xF0, 0x00, 0xFC, 0x00, 0x7F, 0xFE,
0xFF, 0xF9, 0xFF, 0xF3, 0xFF, 0xC0, 0x1F, 0x80, 0x7E, 0x00, 0xFC, 0x03,
0xF0, 0x07, 0xE0, 0x1F, 0x80, 0x3E, 0x00, 0xFC, 0x03, 0xF0, 0x07, 0xFF,
0xDF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFE, 0x03, 0xE1, 0xFC, 0x7F, 0x8F, 0xF3,
0xF8, 0x7E, 0x07, 0xC0, 0xF8, 0x1F, 0x03, 0xF0, 0x7E, 0x1F, 0x8F, 0xF1,
0xFC, 0x3F, 0x87, 0xF8, 0x3F, 0x03, 0xF0, 0x7E, 0x0F, 0x81, 0xF0, 0x3E,
0x0F, 0xC1, 0xF8, 0x1F, 0x83, 0xFC, 0x7F, 0x87, 0xF0, 0x1E, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xF0, 0xF8, 0x1F, 0xC3, 0xFC, 0x7F, 0x83, 0xF8, 0x3F, 0x07, 0xC0, 0xF8,
0x1F, 0x07, 0xE0, 0xFC, 0x0F, 0xC1, 0xFE, 0x1F, 0xC3, 0xF8, 0xFF, 0x1F,
0x87, 0xE0, 0xFC, 0x0F, 0x81, 0xF0, 0x3E, 0x07, 0xE0, 0xFC, 0x3F, 0x1F,
0xE3, 0xFC, 0x7F, 0x0F, 0x00, 0x1E, 0x1C, 0xFF, 0xF9, 0xFF, 0xF7, 0xFF,
0xEF, 0xFF, 0x9E, 0x3E, 0x00 };
const GFXglyph Graphik_Bold16pt7bGlyphs[] = {
{ 0, 1, 1, 6, 0, 0 }, // 0x20 ' '
{ 1, 6, 23, 10, 2, -22 }, // 0x21 '!'
{ 19, 12, 8, 14, 1, -22 }, // 0x22 '"'
{ 31, 16, 20, 18, 1, -22 }, // 0x23 '#'
{ 71, 19, 30, 20, 0, -25 }, // 0x24 '$'
{ 143, 24, 23, 26, 1, -22 }, // 0x25 '%'
{ 212, 23, 23, 24, 1, -22 }, // 0x26 '&'
{ 279, 6, 8, 8, 1, -22 }, // 0x27 '''
{ 285, 10, 29, 12, 1, -23 }, // 0x28 '('
{ 322, 10, 29, 12, 1, -23 }, // 0x29 ')'
{ 359, 12, 12, 14, 1, -23 }, // 0x2A '*'
{ 377, 16, 16, 18, 1, -18 }, // 0x2B '+'
{ 409, 8, 10, 10, 0, -5 }, // 0x2C ','
{ 419, 9, 4, 13, 2, -10 }, // 0x2D '-'
{ 424, 6, 6, 8, 1, -5 }, // 0x2E '.'
{ 429, 15, 30, 14, -1, -24 }, // 0x2F '/'
{ 486, 20, 23, 22, 1, -22 }, // 0x30 '0'
{ 544, 11, 23, 13, 0, -22 }, // 0x31 '1'
{ 576, 18, 23, 20, 1, -22 }, // 0x32 '2'
{ 628, 18, 23, 20, 1, -22 }, // 0x33 '3'
{ 680, 20, 23, 22, 1, -22 }, // 0x34 '4'
{ 738, 18, 23, 20, 1, -22 }, // 0x35 '5'
{ 790, 19, 23, 21, 1, -22 }, // 0x36 '6'
{ 845, 17, 23, 19, 1, -22 }, // 0x37 '7'
{ 894, 19, 23, 21, 1, -22 }, // 0x38 '8'
{ 949, 19, 23, 21, 1, -22 }, // 0x39 '9'
{ 1004, 6, 15, 10, 2, -14 }, // 0x3A ':'
{ 1016, 8, 19, 9, 0, -14 }, // 0x3B ';'
{ 1035, 13, 17, 16, 1, -18 }, // 0x3C '<'
{ 1063, 15, 10, 17, 1, -14 }, // 0x3D '='
{ 1082, 13, 17, 16, 2, -18 }, // 0x3E '>'
{ 1110, 16, 23, 18, 1, -22 }, // 0x3F '?'
{ 1156, 27, 27, 29, 1, -21 }, // 0x40 '@'
{ 1248, 23, 23, 23, 0, -22 }, // 0x41 'A'
{ 1315, 18, 23, 21, 2, -22 }, // 0x42 'B'
{ 1367, 22, 23, 24, 1, -22 }, // 0x43 'C'
{ 1431, 20, 23, 23, 2, -22 }, // 0x44 'D'
{ 1489, 16, 23, 19, 2, -22 }, // 0x45 'E'
{ 1535, 15, 23, 18, 2, -22 }, // 0x46 'F'
{ 1579, 23, 23, 25, 1, -22 }, // 0x47 'G'
{ 1646, 20, 23, 24, 2, -22 }, // 0x48 'H'
{ 1704, 6, 23, 10, 2, -22 }, // 0x49 'I'
{ 1722, 12, 23, 15, 1, -22 }, // 0x4A 'J'
{ 1757, 20, 23, 22, 2, -22 }, // 0x4B 'K'
{ 1815, 15, 23, 18, 2, -22 }, // 0x4C 'L'
{ 1859, 25, 23, 29, 2, -22 }, // 0x4D 'M'
{ 1931, 20, 23, 24, 2, -22 }, // 0x4E 'N'
{ 1989, 23, 23, 25, 1, -22 }, // 0x4F 'O'
{ 2056, 17, 23, 20, 2, -22 }, // 0x50 'P'
{ 2105, 23, 26, 25, 1, -22 }, // 0x51 'Q'
{ 2180, 19, 23, 22, 2, -22 }, // 0x52 'R'
{ 2235, 19, 23, 20, 0, -22 }, // 0x53 'S'
{ 2290, 18, 23, 20, 1, -22 }, // 0x54 'T'
{ 2342, 20, 23, 24, 2, -22 }, // 0x55 'U'
{ 2400, 22, 23, 23, 0, -22 }, // 0x56 'V'
{ 2464, 31, 23, 31, 0, -22 }, // 0x57 'W'
{ 2554, 22, 23, 24, 1, -22 }, // 0x58 'X'
{ 2618, 20, 23, 21, 1, -22 }, // 0x59 'Y'
{ 2676, 18, 23, 20, 1, -22 }, // 0x5A 'Z'
{ 2728, 10, 29, 13, 2, -23 }, // 0x5B '['
{ 2765, 14, 30, 14, 0, -24 }, // 0x5C '\'
{ 2818, 10, 29, 13, 1, -23 }, // 0x5D ']'
{ 2855, 15, 10, 17, 1, -21 }, // 0x5E '^'
{ 2874, 14, 2, 14, 0, 4 }, // 0x5F '_'
{ 2878, 7, 5, 13, 1, -22 }, // 0x60 '`'
{ 2883, 16, 17, 19, 1, -16 }, // 0x61 'a'
{ 2917, 18, 24, 21, 2, -23 }, // 0x62 'b'
{ 2971, 17, 17, 18, 1, -16 }, // 0x63 'c'
{ 3008, 18, 24, 21, 1, -23 }, // 0x64 'd'
{ 3062, 18, 17, 19, 0, -16 }, // 0x65 'e'
{ 3101, 11, 24, 13, 1, -23 }, // 0x66 'f'
{ 3134, 18, 23, 21, 1, -16 }, // 0x67 'g'
{ 3186, 17, 24, 21, 2, -23 }, // 0x68 'h'
{ 3237, 6, 24, 10, 2, -23 }, // 0x69 'i'
{ 3255, 8, 30, 9, -1, -23 }, // 0x6A 'j'
{ 3285, 17, 24, 19, 2, -23 }, // 0x6B 'k'
{ 3336, 6, 24, 10, 2, -23 }, // 0x6C 'l'
{ 3354, 26, 17, 30, 2, -16 }, // 0x6D 'm'
{ 3410, 17, 17, 21, 2, -16 }, // 0x6E 'n'
{ 3447, 18, 17, 20, 1, -16 }, // 0x6F 'o'
{ 3486, 18, 23, 21, 2, -16 }, // 0x70 'p'
{ 3538, 18, 23, 21, 1, -16 }, // 0x71 'q'
{ 3590, 11, 17, 14, 2, -16 }, // 0x72 'r'
{ 3614, 15, 17, 17, 1, -16 }, // 0x73 's'
{ 3646, 11, 21, 13, 1, -20 }, // 0x74 't'
{ 3675, 17, 17, 21, 2, -16 }, // 0x75 'u'
{ 3712, 18, 17, 19, 0, -16 }, // 0x76 'v'
{ 3751, 26, 17, 26, 0, -16 }, // 0x77 'w'
{ 3807, 18, 17, 19, 0, -16 }, // 0x78 'x'
{ 3846, 18, 23, 18, 0, -16 }, // 0x79 'y'
{ 3898, 15, 17, 17, 1, -16 }, // 0x7A 'z'
{ 3930, 11, 29, 13, 1, -23 }, // 0x7B '{'
{ 3970, 4, 29, 8, 2, -23 }, // 0x7C '|'
{ 3985, 11, 29, 13, 1, -23 }, // 0x7D '}'
{ 4025, 15, 6, 16, 1, -12 } }; // 0x7E '~'
const GFXfont Graphik_Bold16pt7b = {
(uint8_t *)Graphik_Bold16pt7bBitmaps,
(GFXglyph *)Graphik_Bold16pt7bGlyphs,
0x20, 0x7E, 34 };
// Approx. 4709 bytes
| 68.301802 | 73 | 0.593121 |
5e5ed781e1600335904c15dc79bda5b44d08b6ac | 1,776 | h | C | include/efi/defs.h | mxre/zloader | 57e55b6a5e4033fd429d5d863ac9830fc61d7d13 | [
"BSD-2-Clause"
] | 1 | 2022-03-28T09:49:15.000Z | 2022-03-28T09:49:15.000Z | include/efi/defs.h | mxre/zloader | 57e55b6a5e4033fd429d5d863ac9830fc61d7d13 | [
"BSD-2-Clause"
] | 1 | 2021-11-12T19:57:09.000Z | 2021-11-13T05:20:04.000Z | include/efi/defs.h | mxre/zloader | 57e55b6a5e4033fd429d5d863ac9830fc61d7d13 | [
"BSD-2-Clause"
] | 1 | 2021-11-12T18:37:36.000Z | 2021-11-12T18:37:36.000Z | #pragma once
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdalign.h>
#include "compiler.h"
typedef size_t efi_status_t;
typedef size_t efi_size_t;
typedef void* efi_handle_t;
typedef char char8_t;
typedef uint16_t char16_t;
struct __packed efi_guid {
union {
struct {
uint32_t ms1;
uint16_t ms2;
uint16_t ms3;
uint8_t ms4[8];
};
uint8_t u8[16];
uint16_t u16[8];
uint32_t u32[4];
uint64_t u64[2];
};
};
typedef struct efi_guid* efi_guid_t;
struct efi_table_header {
uint64_t signature;
uint32_t revision;
uint32_t header_size;
uint32_t crc32;
uint32_t reserved;
};
#if __x86_64__
# define efi_api __attribute__((ms_abi))
#elif __i386__ || __i686__
# define efi_api __attribute__((cdecl))
#else
# define efi_api
#endif
/* well known UEFI Machine Abbreviations */
#if __x86_64__
# define EFI_ARCH "x64"
#elif __i386__ || __i686__
# define EFI_ARCH "ia32"
#elif __aarch64__
# define EFI_ARCH "aa64"
#elif __arm__
# define EFI_ARCH "arm"
#elif __riscv && __riscv_xlen == 64
# define EFI_ARCH "riscv64"
#elif __riscv && __riscv_xlen == 32
# define EFI_ARCH "riscv32"
#else
# error "Unsupported UEFI System"
#endif
#define LOAD_OPTION_ACTIVE UINT32_C(0x00000001)
#define LOAD_OPTION_FORCE_RECONNECT UINT32_C(0x00000002)
#define LOAD_OPTION_HIDDEN UINT32_C(0x00000008)
#define LOAD_OPTION_CATEGORY UINT32_C(0x00001F00)
#define LOAD_OPTION_CATEGORY_BOOT UINT32_C(0x00000000)
#define LOAD_OPTION_CATEGORY_APP UINT32_C(0x00000100)
struct __packed efi_load_option {
uint32_t attributes;
uint16_t file_path_list_length;
uint16_t description[];
// efi_filepath_t file_path_list[];
// uint8_t optional_data[]
};
typedef struct efi_load_option* efi_load_option_t;
| 21.39759 | 56 | 0.745495 |
5e7cee34f75ceaeb16dbf4f607d262fb1aa91142 | 1,099 | h | C | modules/mapred/map_pipe_task.h | spiralgenetics/biograph | 33c78278ce673e885f38435384f9578bfbf9cdb8 | [
"BSD-2-Clause"
] | 16 | 2021-07-14T23:32:31.000Z | 2022-03-24T16:25:15.000Z | modules/mapred/map_pipe_task.h | spiralgenetics/biograph | 33c78278ce673e885f38435384f9578bfbf9cdb8 | [
"BSD-2-Clause"
] | 9 | 2021-07-20T20:39:47.000Z | 2021-09-16T20:57:59.000Z | modules/mapred/map_pipe_task.h | spiralgenetics/biograph | 33c78278ce673e885f38435384f9578bfbf9cdb8 | [
"BSD-2-Clause"
] | 9 | 2021-07-15T19:38:35.000Z | 2022-01-31T19:24:56.000Z | #pragma once
#include "modules/mapred/map_task.h"
#include "modules/io/log.h"
struct pipe_params;
struct temp_file_spec;
class map_pipe_task : public task_impl<map_pipe_task>
{
public:
static std::string s_type() { return "map_pipe"; }
TRANSFER_OBJECT
{
VERSION(0);
FIELD(input_stream, TF_STRICT);
FIELD(output_stream, TF_STRICT);
FIELD(map, TF_STRICT);
FIELD(map_param, TF_STRICT);
FIELD(update_freq, TF_STRICT);
};
void run();
input_stream_params input_stream;
output_stream_params output_stream;
std::string map;
std::string map_param;
size_t update_freq;
void processed_a_record();
void keep_alive() const;
private:
std::unique_ptr<kv_source> m_input;
std::unique_ptr<kv_sink> m_output;
unsigned int m_records_processed;
// Creates temp files from the mainfests in the pipe params and sets up the command line arguments.
std::vector<std::string> create_temp_files(pipe_params& the_pipe_params) const;
std::string create_temp_file(const temp_file_spec& the_temp_file_spec) const;
};
| 23.891304 | 100 | 0.717925 |
395b32592f2eb86783e0f7e4143dda7a7e5c362d | 6,391 | h | C | legacy/Euler3/include/lattice.h | carterbox/cold | 2738e6e9ccfd13007ac4fd987bf1a75656d358bd | [
"BSD-3-Clause"
] | null | null | null | legacy/Euler3/include/lattice.h | carterbox/cold | 2738e6e9ccfd13007ac4fd987bf1a75656d358bd | [
"BSD-3-Clause"
] | 6 | 2022-01-21T17:14:55.000Z | 2022-03-31T10:34:20.000Z | legacy/Euler3/include/lattice.h | carterbox/cold | 2738e6e9ccfd13007ac4fd987bf1a75656d358bd | [
"BSD-3-Clause"
] | 1 | 2022-01-21T17:48:28.000Z | 2022-01-21T17:48:28.000Z | #ifndef LATTICE_H
#define LATTICE_H
#ifndef CHECK_FREE
#define CHECK_FREE(A) { if(A) free(A); (A)=NULL;}
#endif
#ifndef STD_TEMP_DEF_
#define STD_TEMP_DEF_
#define STD_TEMP 22.5 /* standard temperature (C) */
#endif
#ifndef ROOM_TEMP_DEF_
#define ROOM_TEMP_DEF_
#define ROOM_TEMP STD_TEMP /* room temperature (C) */
#endif
#define STRUCTURE_ATOMS_MAX 2000 /* max number of atom types in a material structure (for Si only need 1) */
// #ifndef hc_KEV_A
// #define hc_KEV_A 12.3984187 /* ( h*c (keV-Å), from 2006 CODATA, http://physics.nist.gov/cuu/Constants/index.html */
// #endif
//
// #ifndef N_Avagadro
// #define N_Avagadro 6.02214179e23 /* Avagadro's number, from 2006 CODATA, http://physics.nist.gov/cuu/Constants/index.html */
// #endif
/*
* struct latticeParameters { // defines a lattice 3 lengths & 3 angles OLD
* double a,b,c; // lattice constants (Angstroms)
* double alpha,beta,gamma; // lattice angles (radian)
* int structure; // structure number from International Tables, allowed values are [1-230]
* double recip[3][3]; // reciprocal lattice from constants, has the 2PI in it
* };
*/
struct atomTypeStructure { /* defines one type of atom (each atom may be in multiple positions) */
char name[60]; /* label for this atom, usually starts with atomic symbol */
int Zatom; /* Z of the atom */
double x; /* fractional coord along x lattice vector */
double y;
double z;
double occ; /* occupancy */
double Debye; /* Debye-Waller factor */
};
struct atomStructure { /* defines single atome position, one atom type can produce multiple atom positions */
size_t type; /* index into associated atomTypeStructure for this atom */
int Zatom; /* Z of the atom */
double x; /* fractional coord along x lattice vector */
double y;
double z;
double occ; /* occupancy */
double Debye; /* Debye-Waller factor */
};
struct equivOpsStructure { /* holds all of the information about the symmetry operations */
int SpaceGroup; /* Space Group number [1,230] */
int N; /* number of symmetry ops, [1,192] */
double ***equivXYZM; /* the matricies */
double **equivXYZB; /* and the vectors */
};
struct crystalStructure { /* defines a lattice 3 lengths & 3 angles */
char desc[256]; /* name or decription of this crystal */
double a,b,c; /* lattice constants (Angstroms) */
double alpha,beta,gamma; /* lattice angles (radian) */
double lengthUnits; /* units for a,b,c conversion from meters, Angstrom->1e10, nm->1e9, micron->1e6, ... */
int SpaceGroup; /* Space Group number from International Tables, allowed values are [1-230] */
double direct[3][3]; /* direct lattice from constants, units agree with lengthUnits, column vecs, not C vecs */
double recip[3][3]; /* reciprocal lattice from constants, has the 2PI in it, column vectors not C vecs */
double Vc; /* Volume of unit cell */
double density; /* calculated density (g/cm^3) */
double alphaT; /* coef of thermal expansion, a = ao*(1+alphaT*(TempC-22.5)) */
size_t Ntype; /* number of atom types described here, this needs to be provided by the user */
struct atomTypeStructure *atomType; /* the atom positions, space must be allocated for this */
size_t N; /* number of real atom (not just types), computed from atomType */
struct atomStructure *atom; /* the atom positions, space must be allocated for this */
struct equivOpsStructure equiv; /* the equivalent atom position operations for thie Space Group, computed internally from Space Group */
int useUnconventional; /* flag, true means use Unconventional[3][3], provided by user, usually 0 */
double Unconventional[3][3]; /* transform matrix for an unconventional unit cel, for conventional, this will be identity matrix */
};
#define TRICLINIC 0
#define MONOCLINIC 1
#define ORTHORHOMBIC 2
#define TETRAGONAL 3
#define TRIGONAL 4
#define HEXAGONAL 5
#define CUBIC 6
#define P_CENTER 0
#define F_CENTER 1
#define B_CENTER 2
#define RHOMBOHEDRAL 3
#define C_CENTER 4
#define A_CENTER 5
#define FCC 225 /* generic structure numbers */
#define BCC 229
#define DIA 227
#define SIMPLE_CUBIC 221
#define SAPPHIRE 167
#define ALLOW_FC(H,K,L) (!(((H)+(K))%2) && !(((K)+(L))%2)) /* H,K,L all even or all odd face-centered */
#define ALLOW_BC(H,K,L) (!(((H)+(K)+(L))%2)) /* !mod(round(h+k+l),2) body-centered */
#define ALLOW_CC(H,K,L) (!(((H)+(K))%2)) /* !mod(round(h+k),2) C-centered */
#define ALLOW_AC(H,K,L) (!(((K)+(L))%2)) /* !mod(round(k+l),2) A-centered */
#define ALLOW_RHOM_HEX(H,K,L) (((-(H)+(K)+(L))%3)==0 || (((H)-(K)+(L))%3)==0) /* allowed are -H+K+L=3n or H-K+L=3n */
/* #define ALLOW_HEXAGONAL(H,K,L) ((((H)+2*(K))%3) || !((L)%2))// forbidden are: H+2K=3N with L odd */
size_t Fstruct(struct crystalStructure *xtal, long h, long k, long l, double *Freal, double *Fimag);
int ForceLatticeToStructure(struct crystalStructure *xtal);
int UpdateInternalsOfCrystalStructure(struct crystalStructure *xtal);
long allowedHKL(struct crystalStructure *xtal, long h, long k, long l);
int latticeSystem(int structNum);
int setAtomXYZs(struct crystalStructure *xtal);
/* char *getSymString(int structNum, char *str); */
char *symmetryString(int SG, char *sym);
int setDirectRecip(struct crystalStructure *xtal);
double dSpacing(struct crystalStructure *xtal, double h, double k, double l, double T);
double densityOfCrystalStructure(struct crystalStructure *xtal);
void lowestOrderHKL(long hkl[3]);
void lowestAllowedHKL(long hkl[3], struct crystalStructure *xtal);
void copyCrystalStructure(struct crystalStructure *destLat, struct crystalStructure *sourceLat);
void InitCleanCrystalStructure(struct crystalStructure *lat);
void freeCrystalStructure(struct crystalStructure *lat);
int SetSymOpsForSpaceGroup(int SpaceGroup, struct equivOpsStructure *sym);
void print_crystalStructure(FILE *f, struct crystalStructure *xtal);
long multiplicityOfAtomType(size_t type, struct crystalStructure *xtal);
int atomicNumber(char *ele);
/* void printMat33(double m[3][3]); */
/* void printVec3(double v[3]); */
/* void printEquivOpsStructure(struct equivOpsStructure *sym); */
/* char *latticeNames[]={"Triclinic","Monoclinic","Orthorhombic","Tetragonal","Trigonal","Hexagonal","Cubic"}; */
#endif
| 40.967949 | 138 | 0.69238 |
c2217ff9d91646ee75dcdab06c301c0610f3222f | 306 | h | C | trie.h | michelchevalier/hackysack | 332e4afdff52f43d9f5d71bd39232bd627045e86 | [
"Unlicense"
] | null | null | null | trie.h | michelchevalier/hackysack | 332e4afdff52f43d9f5d71bd39232bd627045e86 | [
"Unlicense"
] | null | null | null | trie.h | michelchevalier/hackysack | 332e4afdff52f43d9f5d71bd39232bd627045e86 | [
"Unlicense"
] | null | null | null | /*
* An ASCII trie
*/
#ifndef TRIE_H
#define TRIE_H
typedef struct _trienode {
struct _trienode *leaves[128];
void *data;
} trienode;
extern size_t trienodesize;
size_t trie_add_string(trienode *t, const char *str, void *data);
void *trie_match_string(trienode *t, const char *str);
#endif
| 15.3 | 65 | 0.712418 |
5ea5b26339e943ed229e9187dc6b1f2e4e78c182 | 1,901 | h | C | video.h | rogerboesch/x16-emulator | e86431245705e09eafde174c3c93aef2dd5d2a10 | [
"BSD-2-Clause"
] | 1 | 2021-04-22T09:19:52.000Z | 2021-04-22T09:19:52.000Z | video.h | rogerboesch/x16-emulator | e86431245705e09eafde174c3c93aef2dd5d2a10 | [
"BSD-2-Clause"
] | null | null | null | video.h | rogerboesch/x16-emulator | e86431245705e09eafde174c3c93aef2dd5d2a10 | [
"BSD-2-Clause"
] | null | null | null | // Commander X16 Emulator
// Copyright (c) 2019 Michael Steil
// All rights reserved. License: 2-clause BSD
#ifndef _VIDEO_H_
#define _VIDEO_H_
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "glue.h"
#include "platform_ios.h"
#define ADDR_VRAM_START 0x00000
#define ADDR_VRAM_END 0x20000
#define ADDR_PSG_START 0x1F9C0
#define ADDR_PSG_END 0x1FA00
#define ADDR_PALETTE_START 0x1FA00
#define ADDR_PALETTE_END 0x1FC00
#define ADDR_SPRDATA_START 0x1FC00
#define ADDR_SPRDATA_END 0x20000
#define NUM_SPRITES 128
// both VGA and NTSC
#define SCAN_WIDTH 800
#define SCAN_HEIGHT 525
// VGA
#define VGA_FRONT_PORCH_X 16
#define VGA_FRONT_PORCH_Y 10
#define VGA_PIXEL_FREQ 25.175
// NTSC: 262.5 lines per frame, lower field first
#define NTSC_FRONT_PORCH_X 80
#define NTSC_FRONT_PORCH_Y 22
#define NTSC_PIXEL_FREQ (15.750 * 800 / 1000)
#define TITLE_SAFE_X 0.067
#define TITLE_SAFE_Y 0.05
// visible area we're drawing
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_RAM_OFFSET 0x00000
// When rendering a layer line, we can amortize some of the cost by calculating multiple pixels at a time.
#define LAYER_PIXELS_PER_ITERATION 8
bool video_init(int window_scale, char *quality);
void video_reset(void);
bool video_step(float mhz);
bool video_update(void);
void video_end(void);
bool video_get_irq_out(void);
void video_save(SDL_RWops *f);
uint8_t video_read(uint8_t reg, bool debugOn);
void video_write(uint8_t reg, uint8_t value);
void video_update_title(const char* window_title);
uint8_t via1_read(uint8_t reg);
void via1_write(uint8_t reg, uint8_t value);
// For debugging purposes only:
uint8_t video_space_read(uint32_t address);
void video_space_write(uint32_t address, uint8_t value);
bool video_is_tilemap_address(int addr);
bool video_is_tiledata_address(int addr);
bool video_is_special_address(int addr);
#endif
| 26.041096 | 106 | 0.791163 |
c3c4b53cdd402ac2f7e7f93923eb3a70cd2a774a | 79 | h | C | MandelbrotVS/MandelbrotShared/image.h | tupieurods/mandelbrot-dyn | 4c29b966b200857f94e91c81031f8495a3da6d99 | [
"MIT"
] | null | null | null | MandelbrotVS/MandelbrotShared/image.h | tupieurods/mandelbrot-dyn | 4c29b966b200857f94e91c81031f8495a3da6d99 | [
"MIT"
] | null | null | null | MandelbrotVS/MandelbrotShared/image.h | tupieurods/mandelbrot-dyn | 4c29b966b200857f94e91c81031f8495a3da6d99 | [
"MIT"
] | null | null | null | #pragma once
void save_image(const char* filename, int* dwells, int w, int h); | 26.333333 | 65 | 0.734177 |
57f682f7a0de16150b4edec660d934d488b02a41 | 261 | c | C | Validation/pyFrame3DD-master/gcc-master/gcc/testsuite/c-c++-common/goacc/parallel-dims-1.c | djamal2727/Main-Bearing-Analytical-Model | 2f00c2219c71be0175c6f4f8f1d4cca231d97096 | [
"Apache-2.0"
] | null | null | null | Validation/pyFrame3DD-master/gcc-master/gcc/testsuite/c-c++-common/goacc/parallel-dims-1.c | djamal2727/Main-Bearing-Analytical-Model | 2f00c2219c71be0175c6f4f8f1d4cca231d97096 | [
"Apache-2.0"
] | null | null | null | Validation/pyFrame3DD-master/gcc-master/gcc/testsuite/c-c++-common/goacc/parallel-dims-1.c | djamal2727/Main-Bearing-Analytical-Model | 2f00c2219c71be0175c6f4f8f1d4cca231d97096 | [
"Apache-2.0"
] | null | null | null | /* Valid use of OpenACC parallelism dimensions clauses: num_gangs, num_workers,
vector_length. */
void f(int i)
{
#pragma acc kernels num_gangs(i) num_workers(i) vector_length(i)
;
#pragma acc parallel num_gangs(i) num_workers(i) vector_length(i)
;
}
| 21.75 | 79 | 0.735632 |
411f735aa102dddb42a53005362e88322942d194 | 149 | h | C | src/macro.h | 1BADragon/raytrace | 0a3f943e11858c82186436e9d6b0af50df25923f | [
"MIT"
] | null | null | null | src/macro.h | 1BADragon/raytrace | 0a3f943e11858c82186436e9d6b0af50df25923f | [
"MIT"
] | null | null | null | src/macro.h | 1BADragon/raytrace | 0a3f943e11858c82186436e9d6b0af50df25923f | [
"MIT"
] | null | null | null | #ifndef MACRO_H
#define MACRO_H
#define STRINGIZE(a) _STRINGIZE(a)
#define _STRINGIZE(a) __STRINGIZE(a)
#define __STRINGIZE(a) #a
#endif //MACRO_H
| 16.555556 | 36 | 0.758389 |
41d67bcf5e7beddfd26efefd391fdbf6f5a033bc | 2,734 | c | C | 2D arrays/main.c | violet-sunn/Programming-Languages | 14026f85bc6196fbc1d2cd9d8c8d9c738c7a23ac | [
"MIT"
] | null | null | null | 2D arrays/main.c | violet-sunn/Programming-Languages | 14026f85bc6196fbc1d2cd9d8c8d9c738c7a23ac | [
"MIT"
] | null | null | null | 2D arrays/main.c | violet-sunn/Programming-Languages | 14026f85bc6196fbc1d2cd9d8c8d9c738c7a23ac | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
//TASK 1
int main()
{
int n, m, count, max = 0, max_i = 0, sum = 0;
scanf("%d %d", &n, &m);
int **x, *y;
x = (int **)calloc(n, sizeof(int *));
for (int i = 0; i < n; i++)
x[i] = (int *)calloc(m, sizeof(int));
for (int i = 0; i < n; i++) {
count = 0;
for (int j = 0; j < m; j++) {
scanf("%d", &x[i][j]);
if (x[i][j] % 2 == 0){
count++;
}
}
if (count > max){
max = count;
max_i = i;
}
}
if (max_i == 0){
for (int j = 0; j < m; j++)
sum += x[0][j];
}
else {
for (int j = 0; j < m; j++) {
if (x[max_i][j] % 2 == 1) {
sum += x[max_i][j];
}
}
}
for (int i = 0; i < n; i++) {
printf("\n");
for (int j = 0; j < m; j++) {
printf("%d ", x[i][j]);
}
}
printf("\n");
printf("%d %d", max_i + 1, sum);
return 0;
}
//TASK 2
int main()
{
int n, m, max;
scanf("%d %d", &n, &m);
int **x, *y;
y = (int *)calloc(n, sizeof(int));
x = (int **)calloc(n, sizeof(int *));
for (int i = 0; i < n; i++)
x[i] = (int *)calloc(m, sizeof(int));
for (int i = 0; i < n; i++) {
max = 0;
for (int j = 0; j < m; j++) {
scanf("%d", &x[i][j]);
if (x[i][j] > max || max == 0){
max = x[i][j];
}
}
y[i] = max - x[i][m-1];
}
for (int i = 0; i < n; i++) {
printf("\n");
for (int j = 0; j < m; j++)
printf("%d ", x[i][j]);
}
printf("\n");
for (int i = 0; i < n; i++) {
printf("\n");
printf("%d ", y[i]);
}
return 0;
}
//TASK 3
int main()
{
int n, m, prod;
scanf("%d %d", &n, &m);
int **x, *y;
y = (int *)calloc(m, sizeof(int));
x = (int **)calloc(n, sizeof(int *));
for (int i = 0; i < n; i++)
x[i] = (int *)calloc(m, sizeof(int));
for (int i = 0; i < n; i++) {
prod = 0;
for (int j = 0; j < m; j++) {
scanf("%d", &x[i][j]);
}
}
for (int j = 0; j < m; j++) {
prod = 0;
for (int i = 0; i < n; i++) {
if (abs(x[i][j]) % 2 == 1) {
if (prod == 0) {
prod = 1;
}
prod *= x[i][j];
}
}
y[j] = prod;
}
for (int i = 0; i < n; i++) {
printf("\n");
for (int j = 0; j < m; j++)
printf("%d ", x[i][j]);
}
printf("\n\n");
for (int i = 0; i < m; i++) {
printf("%d ", y[i]);
}
return 0;
}
| 21.872 | 49 | 0.314557 |
579c82e78b9789d60bc62855bf785108efbae4c7 | 100 | h | C | Chapitre 8 - Avec Assimp/PetitMoteur3D/CollisionTypes.h | KeikakuB/grand-turtle-racing | b9a19ac1d9056ff582a63e2a5e4782b6fdc4d53b | [
"Apache-2.0"
] | null | null | null | Chapitre 8 - Avec Assimp/PetitMoteur3D/CollisionTypes.h | KeikakuB/grand-turtle-racing | b9a19ac1d9056ff582a63e2a5e4782b6fdc4d53b | [
"Apache-2.0"
] | null | null | null | Chapitre 8 - Avec Assimp/PetitMoteur3D/CollisionTypes.h | KeikakuB/grand-turtle-racing | b9a19ac1d9056ff582a63e2a5e4782b6fdc4d53b | [
"Apache-2.0"
] | null | null | null | #pragma once
enum CollisionTypes
{
kPlayer = 1 << 0,
kTerrain = 1 << 1,
kObstacle = 1 << 2
};
| 12.5 | 20 | 0.58 |
7e477c8f1cba96c5bde7d85c9b2290be3431ccd8 | 240 | h | C | server/src/deterministic.h | utnapischtim/polygon | 4c926553f436199d643f43a0129610d8d67d72da | [
"MIT"
] | null | null | null | server/src/deterministic.h | utnapischtim/polygon | 4c926553f436199d643f43a0129610d8d67d72da | [
"MIT"
] | null | null | null | server/src/deterministic.h | utnapischtim/polygon | 4c926553f436199d643f43a0129610d8d67d72da | [
"MIT"
] | null | null | null | #ifndef DETERMINISTIC_H_
#define DETERMINISTIC_H_
#include "CommonSetting.h"
#include "Filter.h"
#include "Point.h"
namespace pl::det {
PointList deterministic(CommonSettingList common_settings, FilterList /*local_filters*/);
}
#endif
| 16 | 89 | 0.783333 |
dfed7703095387fafb223e043b7b6a6db444ada4 | 1,199 | c | C | src/MaterialValidator.c | St-Alin/a3-4-alin | e5573c83f70b9b3712440cc28a33eee2e66dda39 | [
"Xnet",
"X11"
] | null | null | null | src/MaterialValidator.c | St-Alin/a3-4-alin | e5573c83f70b9b3712440cc28a33eee2e66dda39 | [
"Xnet",
"X11"
] | null | null | null | src/MaterialValidator.c | St-Alin/a3-4-alin | e5573c83f70b9b3712440cc28a33eee2e66dda39 | [
"Xnet",
"X11"
] | null | null | null | #include "MaterialValidator.h"
#include <string.h>
#include <math.h>
const char* VALID_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 `~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?";
int matValid_validate(const Material* mat)
{
if (mat == NULL)
return 0;
// Id.
if (material_id(mat) < 0)
return 0;
// Name.
const char* name = material_name(mat);
if (name == NULL || strlen(name) < 1 || strlen(name) > 100)
return 0;
for (size_t i = 0; name[i] != '\0'; ++i) {
if (!strchr(VALID_CHARS, name[i]))
return 0;
}
// Supplier.
const char* supplier = material_supplier(mat);
if (supplier == NULL || strlen(supplier) < 1 || strlen(supplier) > 100)
return 0;
for (size_t i = 0; supplier[i] != '\0'; ++i) {
if (!strchr(VALID_CHARS, supplier[i]))
return 0;
}
// Quantity.
float quantity = material_quantity(mat);
if (isnan(quantity) || quantity <= 0.0f || isinf(quantity))
return 0;
// Expiration date.
Date exp_date = material_expDate(mat);
int year = exp_date.year, month = exp_date.month, day = exp_date.day;
if (year < 1 || month < 1 || month > 12 || day < 1 || day > 31)
return 0;
return 1;
}
| 24.469388 | 127 | 0.597164 |
623eda82c57624317f74ffcf39f6474c94cdfc9d | 48 | h | C | riscv/insns/vsh.h | qmn/riscv-isa-sim | 917b74c2fe8bcef5c12acda72f5f84cc4e13173e | [
"BSD-3-Clause"
] | 1 | 2015-07-19T07:34:32.000Z | 2015-07-19T07:34:32.000Z | riscv/insns/vsh.h | qmn/riscv-isa-sim | 917b74c2fe8bcef5c12acda72f5f84cc4e13173e | [
"BSD-3-Clause"
] | null | null | null | riscv/insns/vsh.h | qmn/riscv-isa-sim | 917b74c2fe8bcef5c12acda72f5f84cc4e13173e | [
"BSD-3-Clause"
] | 1 | 2022-01-17T19:58:49.000Z | 2022-01-17T19:58:49.000Z | require_vector;
VEC_STORE(RD, store_uint16, 2);
| 16 | 31 | 0.791667 |
2b7c084923c6e07daf350d02bda4ddd448a4ed8c | 1,872 | h | C | scripts/bananapi/rootfs/usr/src/linux-headers-4.9.241-BPI-M5/include/linux/amlogic/media/registers/register_map.h | Dangku/openEuler-bananapi | 058184debb766ce9bb9ea7ebe340fa861ecdd58b | [
"MulanPSL-1.0"
] | null | null | null | scripts/bananapi/rootfs/usr/src/linux-headers-4.9.241-BPI-M5/include/linux/amlogic/media/registers/register_map.h | Dangku/openEuler-bananapi | 058184debb766ce9bb9ea7ebe340fa861ecdd58b | [
"MulanPSL-1.0"
] | null | null | null | scripts/bananapi/rootfs/usr/src/linux-headers-4.9.241-BPI-M5/include/linux/amlogic/media/registers/register_map.h | Dangku/openEuler-bananapi | 058184debb766ce9bb9ea7ebe340fa861ecdd58b | [
"MulanPSL-1.0"
] | null | null | null | /*
* include/linux/amlogic/media/registers/register_map.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef CODECIO_REGISTER_MAP_H
#define CODECIO_REGISTER_MAP_H
int codecio_read_cbus(unsigned int reg);
void codecio_write_cbus(unsigned int reg, unsigned int val);
int codecio_read_dosbus(unsigned int reg);
void codecio_write_dosbus(unsigned int reg, unsigned int val);
int codecio_read_hiubus(unsigned int reg);
void codecio_write_hiubus(unsigned int reg, unsigned int val);
int codecio_read_aobus(unsigned int reg);
void codecio_write_aobus(unsigned int reg, unsigned int val);
int codecio_read_vcbus(unsigned int reg);
void codecio_write_vcbus(unsigned int reg, unsigned int val);
int codecio_read_dmcbus(unsigned int reg);
void codecio_write_dmcbus(unsigned int reg, unsigned int val);
int codecio_read_parsbus(unsigned int reg);
void codecio_write_parsbus(unsigned int reg, unsigned int val);
int codecio_read_aiubus(unsigned int reg);
void codecio_write_aiubus(unsigned int reg, unsigned int val);
int codecio_read_demuxbus(unsigned int reg);
void codecio_write_demuxbus(unsigned int reg, unsigned int val);
int codecio_read_resetbus(unsigned int reg);
void codecio_write_resetbus(unsigned int reg, unsigned int val);
int codecio_read_efusebus(unsigned int reg);
void codecio_write_efusebus(unsigned int reg, unsigned int val);
#endif
| 43.534884 | 78 | 0.803953 |
44f1e1dca0919f0cfd887bc04babf2fab53b879c | 10,065 | c | C | src/mod_uploadprogress.c | LeSpocky/lighttpd1.4 | 55d787cd5520376074326cdb22be4274c3c886ca | [
"BSD-3-Clause"
] | 458 | 2015-01-24T04:01:23.000Z | 2022-03-27T07:58:12.000Z | src/mod_uploadprogress.c | LeSpocky/lighttpd1.4 | 55d787cd5520376074326cdb22be4274c3c886ca | [
"BSD-3-Clause"
] | 95 | 2015-02-07T11:50:07.000Z | 2021-11-05T11:00:35.000Z | src/mod_uploadprogress.c | LeSpocky/lighttpd1.4 | 55d787cd5520376074326cdb22be4274c3c886ca | [
"BSD-3-Clause"
] | 265 | 2015-03-10T16:01:26.000Z | 2022-03-15T01:57:39.000Z | #include "first.h"
#include "algo_splaytree.h"
#include "log.h"
#include "buffer.h"
#include "request.h"
#include "http_header.h"
#include "plugin.h"
#include <stdlib.h>
#include <string.h>
/**
* this is a uploadprogress for a lighttpd plugin
*
*/
typedef struct {
buffer r_id;
request_st *r;
int ndx;
} request_map_entry;
typedef struct {
const buffer *progress_url;
} plugin_config;
typedef struct {
PLUGIN_DATA;
plugin_config defaults;
plugin_config conf;
splay_tree *request_map;
} plugin_data;
/**
*
* request maps
*
*/
static request_map_entry *
request_map_entry_init (request_st * const r, const char *r_id, size_t idlen)
{
request_map_entry * const rme = calloc(1, sizeof(request_map_entry));
force_assert(rme);
rme->r = r;
rme->ndx = splaytree_djbhash(r_id, idlen);
buffer_copy_string_len(&rme->r_id, r_id, idlen);
return rme;
}
static void
request_map_entry_free (request_map_entry *rme)
{
free(rme->r_id.ptr);
free(rme);
}
static void
request_map_remove (plugin_data * const p, request_map_entry * const rme)
{
splay_tree ** const sptree = &p->request_map;
*sptree = splaytree_splay(*sptree, rme->ndx);
if (NULL != *sptree && (*sptree)->key == rme->ndx) {
request_map_entry_free((*sptree)->data);
*sptree = splaytree_delete(*sptree, (*sptree)->key);
}
}
static request_map_entry *
request_map_insert (plugin_data * const p, request_map_entry * const rme)
{
splay_tree ** const sptree = &p->request_map;
*sptree = splaytree_splay(*sptree, rme->ndx);
if (NULL == *sptree || (*sptree)->key != rme->ndx) {
*sptree = splaytree_insert(*sptree, rme->ndx, rme);
return rme;
}
else { /* collision (not expected); leave old entry and forget new */
/*(old entry is referenced elsewhere, so new entry is freed here)*/
request_map_entry_free(rme);
return NULL;
}
}
__attribute_pure__
static request_st *
request_map_get_request (plugin_data * const p, const char * const r_id, const size_t idlen)
{
splay_tree ** const sptree = &p->request_map;
int ndx = splaytree_djbhash(r_id, idlen);
*sptree = splaytree_splay(*sptree, ndx);
if (NULL != *sptree && (*sptree)->key == ndx) {
request_map_entry * const rme = (*sptree)->data;
if (buffer_eq_slen(&rme->r_id, r_id, idlen))
return rme->r;
}
return NULL;
}
static void
request_map_free (plugin_data * const p)
{
splay_tree *sptree = p->request_map;
p->request_map = NULL;
while (sptree) {
request_map_entry_free(sptree->data);
sptree = splaytree_delete(sptree, sptree->key);
}
}
INIT_FUNC(mod_uploadprogress_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_uploadprogress_free) {
request_map_free((plugin_data *)p_d);
}
static void mod_uploadprogress_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* upload-progress.progress-url */
pconf->progress_url = cpv->v.b;
break;
default:/* should not happen */
return;
}
}
static void mod_uploadprogress_merge_config(plugin_config * const pconf, const config_plugin_value_t *cpv) {
do {
mod_uploadprogress_merge_config_cpv(pconf, cpv);
} while ((++cpv)->k_id != -1);
}
static void mod_uploadprogress_patch_config(request_st * const r, plugin_data * const p) {
p->conf = p->defaults; /* copy small struct instead of memcpy() */
/*memcpy(&p->conf, &p->defaults, sizeof(plugin_config));*/
for (int i = 1, used = p->nconfig; i < used; ++i) {
if (config_check_cond(r, (uint32_t)p->cvlist[i].k_id))
mod_uploadprogress_merge_config(&p->conf,
p->cvlist + p->cvlist[i].v.u2[0]);
}
}
SETDEFAULTS_FUNC(mod_uploadprogress_set_defaults) {
static const config_plugin_keys_t cpk[] = {
{ CONST_STR_LEN("upload-progress.progress-url"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_CONNECTION }
,{ NULL, 0,
T_CONFIG_UNSET,
T_CONFIG_SCOPE_UNSET }
};
plugin_data * const p = p_d;
if (!config_plugin_values_init(srv, p, cpk, "mod_uploadprogress"))
return HANDLER_ERROR;
/* process and validate config directives
* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) {
config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0];
for (; -1 != cpv->k_id; ++cpv) {
switch (cpv->k_id) {
case 0: /* upload-progress.progress-url */
if (buffer_is_blank(cpv->v.b))
cpv->v.b = NULL;
break;
default:/* should not happen */
break;
}
}
}
/* initialize p->defaults from global config context */
if (p->nconfig > 0 && p->cvlist->v.u2[1]) {
const config_plugin_value_t *cpv = p->cvlist + p->cvlist->v.u2[0];
if (-1 != cpv->k_id)
mod_uploadprogress_merge_config(&p->defaults, cpv);
}
return HANDLER_GO_ON;
}
#define REQID_LEN 32
static const char * mod_uploadprogress_get_reqid (request_st * const r) {
const char *idstr;
uint32_t len;
int pathinfo = 0;
const buffer *h = http_header_request_get(r, HTTP_HEADER_OTHER,
CONST_STR_LEN("X-Progress-ID"));
if (NULL != h)
idstr = h->ptr;
else if (!buffer_is_blank(&r->uri.query)
&& (idstr = strstr(r->uri.query.ptr, "X-Progress-ID=")))
idstr += sizeof("X-Progress-ID=")-1;
else { /*(path-info is not known at this point in request)*/
idstr = r->uri.path.ptr;
len = buffer_clen(&r->uri.path);
if (len > REQID_LEN && idstr[len-REQID_LEN-1] == '/') {
pathinfo = 1;
idstr += len - REQID_LEN;
}
else
return NULL;
}
/* request must contain ID of REQID_LEN bytes */
for (len = 0; light_isxdigit(idstr[len]); ++len) ;
if (len != REQID_LEN) {
if (!pathinfo) { /*(reduce false positive noise in error log)*/
log_error(r->conf.errh, __FILE__, __LINE__,
"invalid progress-id; non-xdigit or len != %d: %s",
REQID_LEN, idstr);
}
return NULL;
}
return idstr;
}
/**
*
* the idea:
*
* for the first request we check if it is a post-request
*
* if no, move out, don't care about them
*
* if yes, take the connection structure and register it locally
* in the progress-struct together with an session-id (md5 ... )
*
* if the connections closes, cleanup the entry in the progress-struct
*
* a second request can now get the info about the size of the upload,
* the received bytes
*
*/
URIHANDLER_FUNC(mod_uploadprogress_uri_handler) {
plugin_data *p = p_d;
switch(r->http_method) {
case HTTP_METHOD_GET:
case HTTP_METHOD_POST: break;
default: return HANDLER_GO_ON;
}
mod_uploadprogress_patch_config(r, p);
if (!p->conf.progress_url) return HANDLER_GO_ON;
if (r->http_method == HTTP_METHOD_GET
&& !buffer_is_equal(&r->uri.path, p->conf.progress_url))
return HANDLER_GO_ON;
const char * const idstr = mod_uploadprogress_get_reqid(r);
if (NULL == idstr) return HANDLER_GO_ON;
if (r->http_method == HTTP_METHOD_POST) {
r->plugin_ctx[p->id] =
request_map_insert(p, request_map_entry_init(r, idstr, REQID_LEN));
return HANDLER_GO_ON;
} /* else r->http_method == HTTP_METHOD_GET */
r->resp_body_started = 1;
r->resp_body_finished = 1;
r->http_status = 200;
r->handler_module = NULL;
/* get the connection */
request_st * const post_r = request_map_get_request(p,idstr,REQID_LEN);
if (NULL == post_r) {
log_error(r->conf.errh, __FILE__, __LINE__, "ID not known: %.*s", REQID_LEN, idstr);
/* XXX: why is this not an XML response, too?
* (At least Content-Type is not set to text/xml) */
chunkqueue_append_mem(&r->write_queue, CONST_STR_LEN("not in progress"));
return HANDLER_FINISHED;
}
http_header_response_set(r, HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/xml"));
/* just an attempt the force the IE/proxies to NOT cache the request ... doesn't help :( */
http_header_response_set(r, HTTP_HEADER_PRAGMA, CONST_STR_LEN("Pragma"), CONST_STR_LEN("no-cache"));
http_header_response_set(r, HTTP_HEADER_EXPIRES, CONST_STR_LEN("Expires"), CONST_STR_LEN("Thu, 19 Nov 1981 08:52:00 GMT"));
http_header_response_set(r, HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control"), CONST_STR_LEN("no-store, no-cache, must-revalidate, post-check=0, pre-check=0"));
/* prepare XML */
buffer * const b = chunkqueue_append_buffer_open(&r->write_queue);
buffer_copy_string_len(b, CONST_STR_LEN(
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
"<upload>"
"<size>"));
buffer_append_int(b, post_r->reqbody_length);
buffer_append_string_len(b, CONST_STR_LEN(
"</size>"
"<received>"));
buffer_append_int(b, post_r->reqbody_queue.bytes_in);
buffer_append_string_len(b, CONST_STR_LEN(
"</received>"
"</upload>"));
chunkqueue_append_buffer_commit(&r->write_queue);
return HANDLER_FINISHED;
}
REQUESTDONE_FUNC(mod_uploadprogress_request_done) {
plugin_data *p = p_d;
request_map_entry * const rme = r->plugin_ctx[p->id];
if (rme) {
r->plugin_ctx[p->id] = NULL;
request_map_remove(p, rme);
}
return HANDLER_GO_ON;
}
int mod_uploadprogress_plugin_init(plugin *p);
int mod_uploadprogress_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = "uploadprogress";
p->init = mod_uploadprogress_init;
p->handle_uri_clean = mod_uploadprogress_uri_handler;
p->handle_request_reset = mod_uploadprogress_request_done;
p->set_defaults = mod_uploadprogress_set_defaults;
p->cleanup = mod_uploadprogress_free;
return 0;
}
| 30.044776 | 170 | 0.649478 |
6d1130a203fbd197a25e789a9f259e7e928aa390 | 330 | h | C | gameSource.h | abhaymitra/dirt-bike-racing | 75fc6fed1ffea1c70f531b8370a8b3e976d653e4 | [
"MIT"
] | 1 | 2019-03-10T14:58:27.000Z | 2019-03-10T14:58:27.000Z | gameSource.h | abhaymitra/dirt-bike-racing | 75fc6fed1ffea1c70f531b8370a8b3e976d653e4 | [
"MIT"
] | null | null | null | gameSource.h | abhaymitra/dirt-bike-racing | 75fc6fed1ffea1c70f531b8370a8b3e976d653e4 | [
"MIT"
] | null | null | null | /**
@file gameSource.h
Defines the publicly available functions of the gameSource file.
These includes bilinear Interpolation and calculate Tangent required by the Physics Engine.
*/
float vecDifference(float, float, float,float,float, float);
float bilinearInterpolation(float, float);
float calculatePhi(float,float,float);
| 27.5 | 91 | 0.80303 |
4315d55d2fce85a9301a8d3f3285651c7dd7c831 | 137 | c | C | 4388/4388.c | isac322/BOJ | 35959dd1a63d75ebca9ed606051f7a649d5c0c7b | [
"MIT"
] | 14 | 2017-05-02T02:00:42.000Z | 2021-11-16T07:25:29.000Z | 4388/4388.c | isac322/BOJ | 35959dd1a63d75ebca9ed606051f7a649d5c0c7b | [
"MIT"
] | 1 | 2017-12-25T14:18:14.000Z | 2018-02-07T06:49:44.000Z | 4388/4388.c | isac322/BOJ | 35959dd1a63d75ebca9ed606051f7a649d5c0c7b | [
"MIT"
] | 9 | 2016-03-03T22:06:52.000Z | 2020-04-30T22:06:24.000Z | main(a,b,r,i){for(;scanf("%d %d",&a,&b),a+b;){r=0;for(i=10;(a/i!=0)||(b/i!=0);i*=10)a%i+b%i>=i?r++:0;a%i+b%i>=i?r++:0;printf("%d\n",r);}} | 137 | 137 | 0.452555 |
d8b14f14c669c80131c4e2ef4309029e5098b8a0 | 8,187 | c | C | src/lib/hrt/hrt-thread-pool.c | havocp/hwf | a99e9a0461983226717b278513cfd9f1e53ba0f1 | [
"MIT"
] | 1 | 2015-04-19T10:49:48.000Z | 2015-04-19T10:49:48.000Z | src/lib/hrt/hrt-thread-pool.c | havocp/hwf | a99e9a0461983226717b278513cfd9f1e53ba0f1 | [
"MIT"
] | null | null | null | src/lib/hrt/hrt-thread-pool.c | havocp/hwf | a99e9a0461983226717b278513cfd9f1e53ba0f1 | [
"MIT"
] | null | null | null | /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/*
* Copyright (c) 2010 Havoc Pennington
*
* 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 THREAD 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 <config.h>
#include <hrt/hrt-thread-pool.h>
#include <hrt/hrt-log.h>
#include <hrt/hrt-builtins.h>
#include <hrt/hrt-marshalers.h>
struct HrtThreadPool {
GObject parent_instance;
const HrtThreadPoolVTable *vtable;
void *vfunc_data;
GDestroyNotify vfunc_data_dnotify;
GAsyncQueue *queue;
GThread **threads;
gsize n_threads;
gboolean shutting_down;
};
struct HrtThreadPoolClass {
GObjectClass parent_class;
};
G_DEFINE_TYPE(HrtThreadPool, hrt_thread_pool, G_TYPE_OBJECT);
enum {
PROP_0
};
enum {
LAST_SIGNAL
};
/* static guint signals[LAST_SIGNAL]; */
static void
hrt_thread_pool_dispose(GObject *object)
{
HrtThreadPool *pool;
pool = HRT_THREAD_POOL(object);
hrt_thread_pool_shutdown(pool);
if (pool->vfunc_data_dnotify != NULL) {
(* pool->vfunc_data_dnotify) (pool->vfunc_data);
}
pool->vtable = NULL;
pool->vfunc_data = NULL;
pool->vfunc_data_dnotify = NULL;
G_OBJECT_CLASS(hrt_thread_pool_parent_class)->dispose(object);
}
static void
hrt_thread_pool_finalize(GObject *object)
{
HrtThreadPool *pool;
pool = HRT_THREAD_POOL(object);
g_assert(pool->threads == NULL);
g_assert(pool->n_threads == 0);
g_assert(pool->vtable == NULL);
g_async_queue_unref(pool->queue);
G_OBJECT_CLASS(hrt_thread_pool_parent_class)->finalize(object);
}
static void
hrt_thread_pool_init(HrtThreadPool *pool)
{
pool->queue = g_async_queue_new();
}
static void
hrt_thread_pool_class_init(HrtThreadPoolClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS(klass);
object_class->dispose = hrt_thread_pool_dispose;
object_class->finalize = hrt_thread_pool_finalize;
}
/* just an arbitrary unique valid pointer */
static void* shutting_down_item = (void*) &hrt_thread_pool_class_init;
static void*
hrt_thread_pool_thread(void *data)
{
HrtThreadPool *pool;
void *thread_data;
pool = HRT_THREAD_POOL(data);
thread_data = (* pool->vtable->thread_data_new) (pool->vfunc_data);
while (TRUE) {
void *item;
item = g_async_queue_pop(pool->queue);
g_assert(item != NULL);
if (item == shutting_down_item) {
/* time to quit */
break;
} else {
(* pool->vtable->handle_item) (thread_data,
item,
pool->vfunc_data);
}
}
(* pool->vtable->thread_data_free) (thread_data, pool->vfunc_data);
g_object_unref(pool);
return NULL;
}
static void
create_threads(HrtThreadPool *pool)
{
gsize i;
/* on my 2-core system 3 or 4 threads seems to be optimal, with
* two or five clearly worse. We might end up wanting to look at
* number of cores and decide.
*/
pool->n_threads = 4;
pool->threads = g_new0(GThread*, pool->n_threads);
for (i = 0; i < pool->n_threads; ++i) {
GError *error = NULL;
pool->threads[i] =
g_thread_create(hrt_thread_pool_thread,
g_object_ref(pool),
TRUE, /* joinable */
&error);
if (error != NULL) {
g_error("Failed to create thread: %s", error->message);
}
}
}
HrtThreadPool*
hrt_thread_pool_new(const HrtThreadPoolVTable *vtable,
void *vfunc_data,
GDestroyNotify vfunc_data_dnotify)
{
HrtThreadPool *pool;
pool = g_object_new(HRT_TYPE_THREAD_POOL,
NULL);
pool->vtable = vtable;
pool->vfunc_data = vfunc_data;
pool->vfunc_data_dnotify = vfunc_data_dnotify;
create_threads(pool);
return pool;
}
typedef struct {
GFunc handler;
void *handler_data;
GDestroyNotify handler_data_dnotify;
} Handler;
static void
handler_free(void *data)
{
Handler *handler = data;
if (handler->handler_data_dnotify) {
(* handler->handler_data_dnotify) (handler->handler_data);
}
g_slice_free(Handler, handler);
}
static Handler*
handler_new(GFunc handler_func,
void *handler_data,
GDestroyNotify handler_data_dnotify)
{
Handler *handler;
handler = g_slice_new(Handler);
handler->handler = handler_func;
handler->handler_data = handler_data;
handler->handler_data_dnotify = handler_data_dnotify;
return handler;
}
static void*
handler_thread_data_new(void *vfunc_data)
{
return NULL;
}
static void
handler_handle_item (void *thread_data,
void *item,
void *vfunc_data)
{
Handler *handler;
handler = vfunc_data;
(* handler->handler) (item, handler->handler_data);
}
static void
handler_thread_data_free(void *thread_data,
void *vfunc_data)
{
/* nothing */
}
static const HrtThreadPoolVTable handler_vtable = {
handler_thread_data_new,
handler_handle_item,
handler_thread_data_free
};
HrtThreadPool*
hrt_thread_pool_new_func (GFunc handler_func,
void *handler_data,
GDestroyNotify handler_data_dnotify)
{
Handler *handler;
handler = handler_new(handler_func, handler_data,
handler_data_dnotify);
return hrt_thread_pool_new(&handler_vtable,
handler,
handler_free);
}
void
hrt_thread_pool_shutdown(HrtThreadPool *pool)
{
gsize i;
g_return_if_fail(HRT_IS_THREAD_POOL(pool));
if (pool->n_threads == 0)
return;
/* Mark that threads should exit when nothing left in queue */
pool->shutting_down = TRUE;
/* push a special item to tell threads to exit. Threads will not
* pop anything else once they get this special item, so each
* thread should pop just one of the special items and then quit.
* These are the last items in the queue, so all real items have
* to get processed before threads will quit.
*/
for (i = 0; i < pool->n_threads; ++i) {
g_async_queue_push(pool->queue, shutting_down_item);
}
/* now close down */
for (i = 0; i < pool->n_threads; ++i) {
g_thread_join(pool->threads[i]);
}
g_free(pool->threads);
pool->threads = NULL;
pool->n_threads = 0;
}
/* "item" must be a valid pointer... we rely on being able to use
* magic valid pointers that won't conflict with application's
* pointers.
*/
void
hrt_thread_pool_push(HrtThreadPool *pool,
void *item)
{
g_return_if_fail(HRT_IS_THREAD_POOL(pool));
g_return_if_fail(item != NULL);
g_return_if_fail(!pool->shutting_down);
g_return_if_fail(pool->n_threads > 0);
g_async_queue_push(pool->queue, item);
}
| 25.584375 | 79 | 0.639184 |
94d2d4479968b032ec3826a8c10d4871b1b7896f | 23,642 | c | C | alice4/software/ideas/draw_lamp.c | lkesteloot/alice | 44b85caf744e5830536b5e813e761cc0ce3f695e | [
"Apache-2.0"
] | 63 | 2015-08-14T23:27:39.000Z | 2022-03-09T22:46:11.000Z | alice4/software/ideas/draw_lamp.c | lkesteloot/alice | 44b85caf744e5830536b5e813e761cc0ce3f695e | [
"Apache-2.0"
] | 64 | 2015-09-11T23:13:03.000Z | 2018-10-29T09:38:06.000Z | alice4/software/ideas/draw_lamp.c | lkesteloot/alice | 44b85caf744e5830536b5e813e761cc0ce3f695e | [
"Apache-2.0"
] | 9 | 2016-01-06T00:06:33.000Z | 2021-12-07T10:38:15.000Z | #include <gl.h>
#include "objects.h"
float hp[6][13][3] = {
{
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
},
{
{0.438371, 0.000000, 0.898794},
{0.379641, 0.219186, 0.898794},
{0.219186, 0.379641, 0.898794},
{0.000000, 0.438371, 0.898794},
{-0.219186, 0.379641, 0.898794},
{-0.379641, 0.219186, 0.898794},
{-0.438371, 0.000000, 0.898794},
{-0.379641, -0.219186, 0.898794},
{-0.219186, -0.379641, 0.898794},
{0.000000, -0.438371, 0.898794},
{0.219186, -0.379641, 0.898794},
{0.379641, -0.219186, 0.898794},
{0.438371, 0.000000, 0.898794},
},
{
{0.788011, 0.000000, 0.615662},
{0.682437, 0.394005, 0.615662},
{0.394005, 0.682437, 0.615662},
{0.000000, 0.788011, 0.615662},
{-0.394005, 0.682437, 0.615662},
{-0.682437, 0.394005, 0.615662},
{-0.788011, 0.000000, 0.615662},
{-0.682437, -0.394005, 0.615662},
{-0.394005, -0.682437, 0.615662},
{0.000000, -0.788011, 0.615662},
{0.394005, -0.682437, 0.615662},
{0.682437, -0.394005, 0.615662},
{0.788011, 0.000000, 0.615662},
},
{
{0.978148, 0.000000, 0.207912},
{0.847101, 0.489074, 0.207912},
{0.489074, 0.847101, 0.207912},
{0.000000, 0.978148, 0.207912},
{-0.489074, 0.847101, 0.207912},
{-0.847101, 0.489074, 0.207912},
{-0.978148, 0.000000, 0.207912},
{-0.847101, -0.489074, 0.207912},
{-0.489074, -0.847101, 0.207912},
{0.000000, -0.978148, 0.207912},
{0.489074, -0.847101, 0.207912},
{0.847101, -0.489074, 0.207912},
{0.978148, 0.000000, 0.207912},
},
{
{0.970296, 0.000000, -0.241922},
{0.840301, 0.485148, -0.241922},
{0.485148, 0.840301, -0.241922},
{0.000000, 0.970296, -0.241922},
{-0.485148, 0.840301, -0.241922},
{-0.840301, 0.485148, -0.241922},
{-0.970296, 0.000000, -0.241922},
{-0.840301, -0.485148, -0.241922},
{-0.485148, -0.840301, -0.241922},
{0.000000, -0.970296, -0.241922},
{0.485148, -0.840301, -0.241922},
{0.840301, -0.485148, -0.241922},
{0.970296, 0.000000, -0.241922},
},
{
{0.766044, 0.000000, -0.642788},
{0.663414, 0.383022, -0.642788},
{0.383022, 0.663414, -0.642788},
{0.000000, 0.766044, -0.642788},
{-0.383022, 0.663414, -0.642788},
{-0.663414, 0.383022, -0.642788},
{-0.766044, 0.000000, -0.642788},
{-0.663414, -0.383022, -0.642788},
{-0.383022, -0.663414, -0.642788},
{0.000000, -0.766044, -0.642788},
{0.383022, -0.663414, -0.642788},
{0.663414, -0.383022, -0.642788},
{0.766044, 0.000000, -0.642788},
},
};
float ltp[9][25][3] = {
{
{10.000000, 0.000000, 1.000000},
{9.659258, -2.588191, 1.000000},
{8.660254, -5.000000, 1.000000},
{7.071068, -7.071068, 1.000000},
{5.000000, -8.660254, 1.000000},
{2.588191, -9.659258, 1.000000},
{0.000000, -10.000000, 1.000000},
{-2.588191, -9.659258, 1.000000},
{-5.000000, -8.660254, 1.000000},
{-7.071068, -7.071068, 1.000000},
{-8.660254, -5.000000, 1.000000},
{-9.659258, -2.588191, 1.000000},
{-10.000000, 0.000000, 1.000000},
{-9.659258, 2.588191, 1.000000},
{-8.660254, 5.000000, 1.000000},
{-7.071068, 7.071068, 1.000000},
{-5.000000, 8.660254, 1.000000},
{-2.588191, 9.659258, 1.000000},
{0.000000, 10.000000, 1.000000},
{2.588191, 9.659258, 1.000000},
{5.000000, 8.660254, 1.000000},
{7.071068, 7.071068, 1.000000},
{8.660254, 5.000000, 1.000000},
{9.659258, 2.588191, 1.000000},
{10.000000, 0.000000, 1.000000},
},
{
{10.707107, 0.000000, 0.707107},
{10.342271, -2.771203, 0.707107},
{9.272627, -5.353553, 0.707107},
{7.571068, -7.571068, 0.707107},
{5.353553, -9.272627, 0.707107},
{2.771203, -10.342271, 0.707107},
{0.000000, -10.707107, 0.707107},
{-2.771203, -10.342271, 0.707107},
{-5.353553, -9.272627, 0.707107},
{-7.571068, -7.571068, 0.707107},
{-9.272627, -5.353553, 0.707107},
{-10.342271, -2.771203, 0.707107},
{-10.707107, 0.000000, 0.707107},
{-10.342271, 2.771203, 0.707107},
{-9.272627, 5.353553, 0.707107},
{-7.571068, 7.571068, 0.707107},
{-5.353553, 9.272627, 0.707107},
{-2.771203, 10.342271, 0.707107},
{0.000000, 10.707107, 0.707107},
{2.771203, 10.342271, 0.707107},
{5.353553, 9.272627, 0.707107},
{7.571068, 7.571068, 0.707107},
{9.272627, 5.353553, 0.707107},
{10.342271, 2.771203, 0.707107},
{10.707107, 0.000000, 0.707107},
},
{
{11.000000, 0.000000, 0.000000},
{10.625184, -2.847009, 0.000000},
{9.526279, -5.500000, 0.000000},
{7.778174, -7.778174, 0.000000},
{5.500000, -9.526279, 0.000000},
{2.847009, -10.625184, 0.000000},
{0.000000, -11.000000, 0.000000},
{-2.847009, -10.625184, 0.000000},
{-5.500000, -9.526279, 0.000000},
{-7.778174, -7.778174, 0.000000},
{-9.526279, -5.500000, 0.000000},
{-10.625184, -2.847009, 0.000000},
{-11.000000, 0.000000, 0.000000},
{-10.625184, 2.847009, 0.000000},
{-9.526279, 5.500000, 0.000000},
{-7.778174, 7.778174, 0.000000},
{-5.500000, 9.526279, 0.000000},
{-2.847009, 10.625184, 0.000000},
{0.000000, 11.000000, 0.000000},
{2.847009, 10.625184, 0.000000},
{5.500000, 9.526279, 0.000000},
{7.778174, 7.778174, 0.000000},
{9.526279, 5.500000, 0.000000},
{10.625184, 2.847009, 0.000000},
{11.000000, 0.000000, 0.000000},
},
{
{10.707107, 0.000000, -0.707107},
{10.342271, -2.771203, -0.707107},
{9.272627, -5.353553, -0.707107},
{7.571068, -7.571068, -0.707107},
{5.353553, -9.272627, -0.707107},
{2.771203, -10.342271, -0.707107},
{0.000000, -10.707107, -0.707107},
{-2.771203, -10.342271, -0.707107},
{-5.353553, -9.272627, -0.707107},
{-7.571068, -7.571068, -0.707107},
{-9.272627, -5.353553, -0.707107},
{-10.342271, -2.771203, -0.707107},
{-10.707107, 0.000000, -0.707107},
{-10.342271, 2.771203, -0.707107},
{-9.272627, 5.353553, -0.707107},
{-7.571068, 7.571068, -0.707107},
{-5.353553, 9.272627, -0.707107},
{-2.771203, 10.342271, -0.707107},
{0.000000, 10.707107, -0.707107},
{2.771203, 10.342271, -0.707107},
{5.353553, 9.272627, -0.707107},
{7.571068, 7.571068, -0.707107},
{9.272627, 5.353553, -0.707107},
{10.342271, 2.771203, -0.707107},
{10.707107, 0.000000, -0.707107},
},
{
{10.000000, 0.000000, -1.000000},
{9.659258, -2.588191, -1.000000},
{8.660254, -5.000000, -1.000000},
{7.071068, -7.071068, -1.000000},
{5.000000, -8.660254, -1.000000},
{2.588191, -9.659258, -1.000000},
{0.000000, -10.000000, -1.000000},
{-2.588191, -9.659258, -1.000000},
{-5.000000, -8.660254, -1.000000},
{-7.071068, -7.071068, -1.000000},
{-8.660254, -5.000000, -1.000000},
{-9.659258, -2.588191, -1.000000},
{-10.000000, 0.000000, -1.000000},
{-9.659258, 2.588191, -1.000000},
{-8.660254, 5.000000, -1.000000},
{-7.071068, 7.071068, -1.000000},
{-5.000000, 8.660254, -1.000000},
{-2.588191, 9.659258, -1.000000},
{0.000000, 10.000000, -1.000000},
{2.588191, 9.659258, -1.000000},
{5.000000, 8.660254, -1.000000},
{7.071068, 7.071068, -1.000000},
{8.660254, 5.000000, -1.000000},
{9.659258, 2.588191, -1.000000},
{10.000000, 0.000000, -1.000000},
},
{
{9.292893, 0.000000, -0.707107},
{8.976246, -2.405178, -0.707107},
{8.047881, -4.646447, -0.707107},
{6.571068, -6.571068, -0.707107},
{4.646447, -8.047881, -0.707107},
{2.405178, -8.976246, -0.707107},
{0.000000, -9.292893, -0.707107},
{-2.405178, -8.976246, -0.707107},
{-4.646447, -8.047881, -0.707107},
{-6.571068, -6.571068, -0.707107},
{-8.047881, -4.646447, -0.707107},
{-8.976246, -2.405178, -0.707107},
{-9.292893, 0.000000, -0.707107},
{-8.976246, 2.405178, -0.707107},
{-8.047881, 4.646447, -0.707107},
{-6.571068, 6.571068, -0.707107},
{-4.646447, 8.047881, -0.707107},
{-2.405178, 8.976246, -0.707107},
{0.000000, 9.292893, -0.707107},
{2.405178, 8.976246, -0.707107},
{4.646447, 8.047881, -0.707107},
{6.571068, 6.571068, -0.707107},
{8.047881, 4.646447, -0.707107},
{8.976246, 2.405178, -0.707107},
{9.292893, 0.000000, -0.707107},
},
{
{9.000000, 0.000000, 0.000000},
{8.693333, -2.329371, 0.000000},
{7.794229, -4.500000, 0.000000},
{6.363961, -6.363961, 0.000000},
{4.500000, -7.794229, 0.000000},
{2.329371, -8.693333, 0.000000},
{0.000000, -9.000000, 0.000000},
{-2.329371, -8.693333, 0.000000},
{-4.500000, -7.794229, 0.000000},
{-6.363961, -6.363961, 0.000000},
{-7.794229, -4.500000, 0.000000},
{-8.693333, -2.329371, 0.000000},
{-9.000000, 0.000000, 0.000000},
{-8.693333, 2.329371, 0.000000},
{-7.794229, 4.500000, 0.000000},
{-6.363961, 6.363961, 0.000000},
{-4.500000, 7.794229, 0.000000},
{-2.329371, 8.693333, 0.000000},
{0.000000, 9.000000, 0.000000},
{2.329371, 8.693333, 0.000000},
{4.500000, 7.794229, 0.000000},
{6.363961, 6.363961, 0.000000},
{7.794229, 4.500000, 0.000000},
{8.693333, 2.329371, 0.000000},
{9.000000, 0.000000, 0.000000},
},
{
{9.292893, 0.000000, 0.707107},
{8.976246, -2.405178, 0.707107},
{8.047881, -4.646447, 0.707107},
{6.571068, -6.571068, 0.707107},
{4.646447, -8.047881, 0.707107},
{2.405178, -8.976246, 0.707107},
{0.000000, -9.292893, 0.707107},
{-2.405178, -8.976246, 0.707107},
{-4.646447, -8.047881, 0.707107},
{-6.571068, -6.571068, 0.707107},
{-8.047881, -4.646447, 0.707107},
{-8.976246, -2.405178, 0.707107},
{-9.292893, 0.000000, 0.707107},
{-8.976246, 2.405178, 0.707107},
{-8.047881, 4.646447, 0.707107},
{-6.571068, 6.571068, 0.707107},
{-4.646447, 8.047881, 0.707107},
{-2.405178, 8.976246, 0.707107},
{0.000000, 9.292893, 0.707107},
{2.405178, 8.976246, 0.707107},
{4.646447, 8.047881, 0.707107},
{6.571068, 6.571068, 0.707107},
{8.047881, 4.646447, 0.707107},
{8.976246, 2.405178, 0.707107},
{9.292893, 0.000000, 0.707107},
},
{
{10.000000, 0.000000, 1.000000},
{9.659258, -2.588191, 1.000000},
{8.660254, -5.000000, 1.000000},
{7.071068, -7.071068, 1.000000},
{5.000000, -8.660254, 1.000000},
{2.588191, -9.659258, 1.000000},
{0.000000, -10.000000, 1.000000},
{-2.588191, -9.659258, 1.000000},
{-5.000000, -8.660254, 1.000000},
{-7.071068, -7.071068, 1.000000},
{-8.660254, -5.000000, 1.000000},
{-9.659258, -2.588191, 1.000000},
{-10.000000, 0.000000, 1.000000},
{-9.659258, 2.588191, 1.000000},
{-8.660254, 5.000000, 1.000000},
{-7.071068, 7.071068, 1.000000},
{-5.000000, 8.660254, 1.000000},
{-2.588191, 9.659258, 1.000000},
{0.000000, 10.000000, 1.000000},
{2.588191, 9.659258, 1.000000},
{5.000000, 8.660254, 1.000000},
{7.071068, 7.071068, 1.000000},
{8.660254, 5.000000, 1.000000},
{9.659258, 2.588191, 1.000000},
{10.000000, 0.000000, 1.000000},
},
};
float ltn[9][25][3] = {
{
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
},
{
{0.707107, 0.000000, 0.707107},
{0.683013, -0.183013, 0.707107},
{0.612372, -0.353553, 0.707107},
{0.500000, -0.500000, 0.707107},
{0.353553, -0.612372, 0.707107},
{0.183013, -0.683013, 0.707107},
{0.000000, -0.707107, 0.707107},
{-0.183013, -0.683013, 0.707107},
{-0.353553, -0.612372, 0.707107},
{-0.500000, -0.500000, 0.707107},
{-0.612372, -0.353553, 0.707107},
{-0.683013, -0.183013, 0.707107},
{-0.707107, 0.000000, 0.707107},
{-0.683013, 0.183013, 0.707107},
{-0.612372, 0.353553, 0.707107},
{-0.500000, 0.500000, 0.707107},
{-0.353553, 0.612372, 0.707107},
{-0.183013, 0.683013, 0.707107},
{0.000000, 0.707107, 0.707107},
{0.183013, 0.683013, 0.707107},
{0.353553, 0.612372, 0.707107},
{0.500000, 0.500000, 0.707107},
{0.612372, 0.353553, 0.707107},
{0.683013, 0.183013, 0.707107},
{0.707107, 0.000000, 0.707107},
},
{
{1.000000, 0.000000, 0.000000},
{0.965926, -0.258819, 0.000000},
{0.866025, -0.500000, 0.000000},
{0.707107, -0.707107, 0.000000},
{0.500000, -0.866025, 0.000000},
{0.258819, -0.965926, 0.000000},
{0.000000, -1.000000, 0.000000},
{-0.258819, -0.965926, 0.000000},
{-0.500000, -0.866025, 0.000000},
{-0.707107, -0.707107, 0.000000},
{-0.866025, -0.500000, 0.000000},
{-0.965926, -0.258819, 0.000000},
{-1.000000, 0.000000, 0.000000},
{-0.965926, 0.258819, 0.000000},
{-0.866025, 0.500000, 0.000000},
{-0.707107, 0.707107, 0.000000},
{-0.500000, 0.866025, 0.000000},
{-0.258819, 0.965926, 0.000000},
{0.000000, 1.000000, 0.000000},
{0.258819, 0.965926, 0.000000},
{0.500000, 0.866025, 0.000000},
{0.707107, 0.707107, 0.000000},
{0.866025, 0.500000, 0.000000},
{0.965926, 0.258819, 0.000000},
{1.000000, 0.000000, 0.000000},
},
{
{0.707107, 0.000000, -0.707107},
{0.683013, -0.183013, -0.707107},
{0.612372, -0.353553, -0.707107},
{0.500000, -0.500000, -0.707107},
{0.353553, -0.612372, -0.707107},
{0.183013, -0.683013, -0.707107},
{0.000000, -0.707107, -0.707107},
{-0.183013, -0.683013, -0.707107},
{-0.353553, -0.612372, -0.707107},
{-0.500000, -0.500000, -0.707107},
{-0.612372, -0.353553, -0.707107},
{-0.683013, -0.183013, -0.707107},
{-0.707107, 0.000000, -0.707107},
{-0.683013, 0.183013, -0.707107},
{-0.612372, 0.353553, -0.707107},
{-0.500000, 0.500000, -0.707107},
{-0.353553, 0.612372, -0.707107},
{-0.183013, 0.683013, -0.707107},
{0.000000, 0.707107, -0.707107},
{0.183013, 0.683013, -0.707107},
{0.353553, 0.612372, -0.707107},
{0.500000, 0.500000, -0.707107},
{0.612372, 0.353553, -0.707107},
{0.683013, 0.183013, -0.707107},
{0.707107, 0.000000, -0.707107},
},
{
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
{0.000000, 0.000000, -1.000000},
},
{
{-0.707107, 0.000000, -0.707107},
{-0.683013, 0.183013, -0.707107},
{-0.612372, 0.353553, -0.707107},
{-0.500000, 0.500000, -0.707107},
{-0.353553, 0.612372, -0.707107},
{-0.183013, 0.683013, -0.707107},
{0.000000, 0.707107, -0.707107},
{0.183013, 0.683013, -0.707107},
{0.353553, 0.612372, -0.707107},
{0.500000, 0.500000, -0.707107},
{0.612372, 0.353553, -0.707107},
{0.683013, 0.183013, -0.707107},
{0.707107, 0.000000, -0.707107},
{0.683013, -0.183013, -0.707107},
{0.612372, -0.353553, -0.707107},
{0.500000, -0.500000, -0.707107},
{0.353553, -0.612372, -0.707107},
{0.183013, -0.683013, -0.707107},
{0.000000, -0.707107, -0.707107},
{-0.183013, -0.683013, -0.707107},
{-0.353553, -0.612372, -0.707107},
{-0.500000, -0.500000, -0.707107},
{-0.612372, -0.353553, -0.707107},
{-0.683013, -0.183013, -0.707107},
{-0.707107, 0.000000, -0.707107},
},
{
{-1.000000, 0.000000, 0.000000},
{-0.965926, 0.258819, 0.000000},
{-0.866025, 0.500000, 0.000000},
{-0.707107, 0.707107, 0.000000},
{-0.500000, 0.866025, 0.000000},
{-0.258819, 0.965926, 0.000000},
{0.000000, 1.000000, 0.000000},
{0.258819, 0.965926, 0.000000},
{0.500000, 0.866025, 0.000000},
{0.707107, 0.707107, 0.000000},
{0.866025, 0.500000, 0.000000},
{0.965926, 0.258819, 0.000000},
{1.000000, 0.000000, 0.000000},
{0.965926, -0.258819, 0.000000},
{0.866025, -0.500000, 0.000000},
{0.707107, -0.707107, 0.000000},
{0.500000, -0.866025, 0.000000},
{0.258819, -0.965926, 0.000000},
{0.000000, -1.000000, 0.000000},
{-0.258819, -0.965926, 0.000000},
{-0.500000, -0.866025, 0.000000},
{-0.707107, -0.707107, 0.000000},
{-0.866025, -0.500000, 0.000000},
{-0.965926, -0.258819, 0.000000},
{-1.000000, 0.000000, 0.000000},
},
{
{-0.707107, 0.000000, 0.707107},
{-0.683013, 0.183013, 0.707107},
{-0.612372, 0.353553, 0.707107},
{-0.500000, 0.500000, 0.707107},
{-0.353553, 0.612372, 0.707107},
{-0.183013, 0.683013, 0.707107},
{0.000000, 0.707107, 0.707107},
{0.183013, 0.683013, 0.707107},
{0.353553, 0.612372, 0.707107},
{0.500000, 0.500000, 0.707107},
{0.612372, 0.353553, 0.707107},
{0.683013, 0.183013, 0.707107},
{0.707107, 0.000000, 0.707107},
{0.683013, -0.183013, 0.707107},
{0.612372, -0.353553, 0.707107},
{0.500000, -0.500000, 0.707107},
{0.353553, -0.612372, 0.707107},
{0.183013, -0.683013, 0.707107},
{0.000000, -0.707107, 0.707107},
{-0.183013, -0.683013, 0.707107},
{-0.353553, -0.612372, 0.707107},
{-0.500000, -0.500000, 0.707107},
{-0.612372, -0.353553, 0.707107},
{-0.683013, -0.183013, 0.707107},
{-0.707107, 0.000000, 0.707107},
},
{
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
{0.000000, 0.000000, 1.000000},
},
};
draw_hemisphere() {
lmbind(MATERIAL, MAT_HEMISPHERE);
lmbind(LMODEL, 1);
bgntmesh();
n3f(hp[0][0]); v3f(hp[0][0]);
n3f(hp[1][0]); v3f(hp[1][0]);
n3f(hp[0][1]); v3f(hp[0][1]);
n3f(hp[1][1]); v3f(hp[1][1]);
n3f(hp[0][2]); v3f(hp[0][2]);
n3f(hp[1][2]); v3f(hp[1][2]);
n3f(hp[0][3]); v3f(hp[0][3]);
n3f(hp[1][3]); v3f(hp[1][3]);
n3f(hp[0][4]); v3f(hp[0][4]);
n3f(hp[1][4]); v3f(hp[1][4]);
n3f(hp[0][5]); v3f(hp[0][5]);
n3f(hp[1][5]); v3f(hp[1][5]);
n3f(hp[0][6]); v3f(hp[0][6]);
n3f(hp[1][6]); v3f(hp[1][6]);
n3f(hp[0][7]); v3f(hp[0][7]);
n3f(hp[1][7]); v3f(hp[1][7]);
n3f(hp[0][8]); v3f(hp[0][8]);
n3f(hp[1][8]); v3f(hp[1][8]);
n3f(hp[0][9]); v3f(hp[0][9]);
n3f(hp[1][9]); v3f(hp[1][9]);
n3f(hp[0][10]); v3f(hp[0][10]);
n3f(hp[1][10]); v3f(hp[1][10]);
n3f(hp[0][11]); v3f(hp[0][11]);
n3f(hp[1][11]); v3f(hp[1][11]);
n3f(hp[0][12]); v3f(hp[0][12]);
n3f(hp[1][12]); v3f(hp[1][12]);
endtmesh();
bgntmesh();
n3f(hp[1][0]); v3f(hp[1][0]);
n3f(hp[2][0]); v3f(hp[2][0]);
n3f(hp[1][1]); v3f(hp[1][1]);
n3f(hp[2][1]); v3f(hp[2][1]);
n3f(hp[1][2]); v3f(hp[1][2]);
n3f(hp[2][2]); v3f(hp[2][2]);
n3f(hp[1][3]); v3f(hp[1][3]);
n3f(hp[2][3]); v3f(hp[2][3]);
n3f(hp[1][4]); v3f(hp[1][4]);
n3f(hp[2][4]); v3f(hp[2][4]);
n3f(hp[1][5]); v3f(hp[1][5]);
n3f(hp[2][5]); v3f(hp[2][5]);
n3f(hp[1][6]); v3f(hp[1][6]);
n3f(hp[2][6]); v3f(hp[2][6]);
n3f(hp[1][7]); v3f(hp[1][7]);
n3f(hp[2][7]); v3f(hp[2][7]);
n3f(hp[1][8]); v3f(hp[1][8]);
n3f(hp[2][8]); v3f(hp[2][8]);
n3f(hp[1][9]); v3f(hp[1][9]);
n3f(hp[2][9]); v3f(hp[2][9]);
n3f(hp[1][10]); v3f(hp[1][10]);
n3f(hp[2][10]); v3f(hp[2][10]);
n3f(hp[1][11]); v3f(hp[1][11]);
n3f(hp[2][11]); v3f(hp[2][11]);
n3f(hp[1][12]); v3f(hp[1][12]);
n3f(hp[2][12]); v3f(hp[2][12]);
endtmesh();
bgntmesh();
n3f(hp[2][0]); v3f(hp[2][0]);
n3f(hp[3][0]); v3f(hp[3][0]);
n3f(hp[2][1]); v3f(hp[2][1]);
n3f(hp[3][1]); v3f(hp[3][1]);
n3f(hp[2][2]); v3f(hp[2][2]);
n3f(hp[3][2]); v3f(hp[3][2]);
n3f(hp[2][3]); v3f(hp[2][3]);
n3f(hp[3][3]); v3f(hp[3][3]);
n3f(hp[2][4]); v3f(hp[2][4]);
n3f(hp[3][4]); v3f(hp[3][4]);
n3f(hp[2][5]); v3f(hp[2][5]);
n3f(hp[3][5]); v3f(hp[3][5]);
n3f(hp[2][6]); v3f(hp[2][6]);
n3f(hp[3][6]); v3f(hp[3][6]);
n3f(hp[2][7]); v3f(hp[2][7]);
n3f(hp[3][7]); v3f(hp[3][7]);
n3f(hp[2][8]); v3f(hp[2][8]);
n3f(hp[3][8]); v3f(hp[3][8]);
n3f(hp[2][9]); v3f(hp[2][9]);
n3f(hp[3][9]); v3f(hp[3][9]);
n3f(hp[2][10]); v3f(hp[2][10]);
n3f(hp[3][10]); v3f(hp[3][10]);
n3f(hp[2][11]); v3f(hp[2][11]);
n3f(hp[3][11]); v3f(hp[3][11]);
n3f(hp[2][12]); v3f(hp[2][12]);
n3f(hp[3][12]); v3f(hp[3][12]);
endtmesh();
bgntmesh();
n3f(hp[3][0]); v3f(hp[3][0]);
n3f(hp[4][0]); v3f(hp[4][0]);
n3f(hp[3][1]); v3f(hp[3][1]);
n3f(hp[4][1]); v3f(hp[4][1]);
n3f(hp[3][2]); v3f(hp[3][2]);
n3f(hp[4][2]); v3f(hp[4][2]);
n3f(hp[3][3]); v3f(hp[3][3]);
n3f(hp[4][3]); v3f(hp[4][3]);
n3f(hp[3][4]); v3f(hp[3][4]);
n3f(hp[4][4]); v3f(hp[4][4]);
n3f(hp[3][5]); v3f(hp[3][5]);
n3f(hp[4][5]); v3f(hp[4][5]);
n3f(hp[3][6]); v3f(hp[3][6]);
n3f(hp[4][6]); v3f(hp[4][6]);
n3f(hp[3][7]); v3f(hp[3][7]);
n3f(hp[4][7]); v3f(hp[4][7]);
n3f(hp[3][8]); v3f(hp[3][8]);
n3f(hp[4][8]); v3f(hp[4][8]);
n3f(hp[3][9]); v3f(hp[3][9]);
n3f(hp[4][9]); v3f(hp[4][9]);
n3f(hp[3][10]); v3f(hp[3][10]);
n3f(hp[4][10]); v3f(hp[4][10]);
n3f(hp[3][11]); v3f(hp[3][11]);
n3f(hp[4][11]); v3f(hp[4][11]);
n3f(hp[3][12]); v3f(hp[3][12]);
n3f(hp[4][12]); v3f(hp[4][12]);
endtmesh();
bgntmesh();
n3f(hp[4][0]); v3f(hp[4][0]);
n3f(hp[5][0]); v3f(hp[5][0]);
n3f(hp[4][1]); v3f(hp[4][1]);
n3f(hp[5][1]); v3f(hp[5][1]);
n3f(hp[4][2]); v3f(hp[4][2]);
n3f(hp[5][2]); v3f(hp[5][2]);
n3f(hp[4][3]); v3f(hp[4][3]);
n3f(hp[5][3]); v3f(hp[5][3]);
n3f(hp[4][4]); v3f(hp[4][4]);
n3f(hp[5][4]); v3f(hp[5][4]);
n3f(hp[4][5]); v3f(hp[4][5]);
n3f(hp[5][5]); v3f(hp[5][5]);
n3f(hp[4][6]); v3f(hp[4][6]);
n3f(hp[5][6]); v3f(hp[5][6]);
n3f(hp[4][7]); v3f(hp[4][7]);
n3f(hp[5][7]); v3f(hp[5][7]);
n3f(hp[4][8]); v3f(hp[4][8]);
n3f(hp[5][8]); v3f(hp[5][8]);
n3f(hp[4][9]); v3f(hp[4][9]);
n3f(hp[5][9]); v3f(hp[5][9]);
n3f(hp[4][10]); v3f(hp[4][10]);
n3f(hp[5][10]); v3f(hp[5][10]);
n3f(hp[4][11]); v3f(hp[4][11]);
n3f(hp[5][11]); v3f(hp[5][11]);
n3f(hp[4][12]); v3f(hp[4][12]);
n3f(hp[5][12]); v3f(hp[5][12]);
endtmesh();
lmbind(LMODEL, 0);
RGBcolor(255, 255, 255);
bgnpolygon();
v3f(hp[5][0]);
v3f(hp[5][1]);
v3f(hp[5][2]);
v3f(hp[5][3]);
v3f(hp[5][4]);
v3f(hp[5][5]);
v3f(hp[5][6]);
v3f(hp[5][7]);
v3f(hp[5][8]);
v3f(hp[5][9]);
v3f(hp[5][10]);
v3f(hp[5][11]);
endpolygon();
}
| 30.427284 | 36 | 0.564842 |
ff431b97720f3999d81a49092f65dc004d8b36d6 | 5,168 | h | C | Interfaz Grafica/Debug_old.h | ORParga/Interfaz_Grafica | d27ae9aa4e7d2639c3515bd428f60ca8bfbf3378 | [
"MIT"
] | null | null | null | Interfaz Grafica/Debug_old.h | ORParga/Interfaz_Grafica | d27ae9aa4e7d2639c3515bd428f60ca8bfbf3378 | [
"MIT"
] | null | null | null | Interfaz Grafica/Debug_old.h | ORParga/Interfaz_Grafica | d27ae9aa4e7d2639c3515bd428f60ca8bfbf3378 | [
"MIT"
] | null | null | null | #pragma once
#include <Windows.h>
class _DEBUGGER
{
//********************************** VARIAS
static const int COMODIN_LENGHT = 1024;
//comodin reservado para this->Debug()
wchar_t comodin[COMODIN_LENGHT];
//****************************** OUTPUT *****************************************************
enum class OUTPUT_t { DEBUG, LISTBOX, LISTBOX_ONLY };
OUTPUT_t OUTPUT = OUTPUT_t::DEBUG;
HWND ListBox_forOutput = NULL;
public:wchar_t* Debug(const wchar_t* message) {
int pos;
switch (OUTPUT)
{
case OUTPUT_t::LISTBOX_ONLY:
pos = (int)SendMessage(ListBox_forOutput, LB_ADDSTRING, 0,
(LPARAM)message);
break;
case OUTPUT_t::LISTBOX:
pos = (int)SendMessage(ListBox_forOutput, LB_ADDSTRING, 0,
(LPARAM)message);
lstrcpyW(comodin, message);
lstrcatW(comodin, L"\n");
OutputDebugString(comodin);
break;
case OUTPUT_t::DEBUG:
default:
lstrcpyW(comodin, message);
lstrcatW(comodin, L"\n");
OutputDebugString(comodin);
break;
}
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, wchar_t* message2) {
lstrcpyW(comodin, message);
lstrcatW(comodin, message2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(wchar_t* message, char* message2) {
wchar_t comodin2[1024];
size_t length = 0;
int size = strlen(message2);
mbstowcs_s(&length, comodin2, message2, size + 1);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, const char* message2) {
wchar_t comodin2[1024];
size_t length = 0;
int size = strlen(message2);
mbstowcs_s(&length, comodin2, message2, size + 1);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, const wchar_t* message2, int number2) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message2);
_itow_s(number2, comodin2, 10);
lstrcatW(comodin, comodin2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, const wchar_t* message2, int number2, const wchar_t* message3) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message2);
_itow_s(number2, comodin2, 10);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message3);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, const wchar_t* message2, int number2, const wchar_t* message3, int number3) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message2);
_itow_s(number2, comodin2, 10);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message3);
_itow_s(number3, comodin2, 10);
lstrcatW(comodin, comodin2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, const wchar_t* message2, int number2, const wchar_t* message3, int number3, const wchar_t* message4) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message2);
_itow_s(number2, comodin2, 10);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message3);
_itow_s(number3, comodin2, 10);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message4);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, const wchar_t* message2) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, const wchar_t* message2, const wchar_t* message3) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message2);
lstrcatW(comodin, message3);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, const wchar_t* message2, const char* message3) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
lstrcatW(comodin, message2);
size_t length = 0;
int size = strlen(message3);
mbstowcs_s(&length, comodin2, message3, size + 1);
lstrcatW(comodin, comodin2);
Debug(comodin);
return comodin;
}
public:wchar_t* Debug(const wchar_t* message, int number, int number2) {
wchar_t comodin2[1024];
_itow_s(number, comodin2, 10);
lstrcpyW(comodin, message);
lstrcatW(comodin, comodin2);
_itow_s(number2, comodin2, 10);
lstrcatW(comodin, comodin2);
Debug(comodin);
return comodin;
}
};
| 30.046512 | 161 | 0.699884 |
9e3fc1b41739809064f9f727fdb15a5e2034e4e2 | 5,903 | h | C | jni/enet/include/protocol.h | Astroyaxx/Automic-fixed-source | 0d36ee371619dfd9155ea0d26d4eb5f4fc8f2cf9 | [
"MIT"
] | 11 | 2021-07-27T08:52:26.000Z | 2022-03-27T08:34:55.000Z | jni/enet/include/protocol.h | Astroyaxx/Automic-fixed-source | 0d36ee371619dfd9155ea0d26d4eb5f4fc8f2cf9 | [
"MIT"
] | 3 | 2021-09-07T19:58:56.000Z | 2022-02-15T13:15:08.000Z | jni/enet/include/protocol.h | Astroyaxx/Automic-fixed-source | 0d36ee371619dfd9155ea0d26d4eb5f4fc8f2cf9 | [
"MIT"
] | 5 | 2021-07-07T09:07:25.000Z | 2021-12-08T02:44:28.000Z | /**
@file protocol.h
@brief ENet protocol
*/
#ifndef __ENET_PROTOCOL_H__
#define __ENET_PROTOCOL_H__
#include "../include/types.h"
enum
{
ENET_PROTOCOL_MINIMUM_MTU = 576,
ENET_PROTOCOL_MAXIMUM_MTU = 4096,
ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32,
ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096,
ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536,
ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1,
ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255,
ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF,
ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024
};
typedef enum _ENetProtocolCommand
{
ENET_PROTOCOL_COMMAND_NONE = 0,
ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1,
ENET_PROTOCOL_COMMAND_CONNECT = 2,
ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3,
ENET_PROTOCOL_COMMAND_DISCONNECT = 4,
ENET_PROTOCOL_COMMAND_PING = 5,
ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6,
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7,
ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8,
ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9,
ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10,
ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,
ENET_PROTOCOL_COMMAND_COUNT = 13,
ENET_PROTOCOL_COMMAND_MASK = 0x0F
} ENetProtocolCommand;
typedef enum _ENetProtocolFlag
{
ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7),
ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6),
ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14),
ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15),
ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME,
ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12),
ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12
} ENetProtocolFlag;
#ifdef _MSC_VER
#pragma pack(push, 1)
#define ENET_PACKED
#elif defined(__GNUC__) || defined(__clang__)
#define ENET_PACKED __attribute__ ((packed))
#else
#define ENET_PACKED
#endif
typedef struct _ENetProtocolHeader
{
enet_uint16 peerID;
enet_uint16 sentTime;
} ENET_PACKED ENetProtocolHeader;
typedef struct _ENetProtocolHeader2 {
enet_uint16 a, b, c;
enet_uint16 peerID;
enet_uint16 sentTime;
} ENET_PACKED ENetProtocolHeader2;
typedef struct _ENetProtocolCommandHeader
{
enet_uint8 command;
enet_uint8 channelID;
enet_uint16 reliableSequenceNumber;
} ENET_PACKED ENetProtocolCommandHeader;
typedef struct _ENetProtocolAcknowledge
{
ENetProtocolCommandHeader header;
enet_uint16 receivedReliableSequenceNumber;
enet_uint16 receivedSentTime;
} ENET_PACKED ENetProtocolAcknowledge;
typedef struct _ENetProtocolConnect
{
ENetProtocolCommandHeader header;
enet_uint16 outgoingPeerID;
enet_uint8 incomingSessionID;
enet_uint8 outgoingSessionID;
enet_uint32 mtu;
enet_uint32 windowSize;
enet_uint32 channelCount;
enet_uint32 incomingBandwidth;
enet_uint32 outgoingBandwidth;
enet_uint32 packetThrottleInterval;
enet_uint32 packetThrottleAcceleration;
enet_uint32 packetThrottleDeceleration;
enet_uint32 connectID;
enet_uint32 data;
} ENET_PACKED ENetProtocolConnect;
typedef struct _ENetProtocolVerifyConnect
{
ENetProtocolCommandHeader header;
enet_uint16 outgoingPeerID;
enet_uint8 incomingSessionID;
enet_uint8 outgoingSessionID;
enet_uint32 mtu;
enet_uint32 windowSize;
enet_uint32 channelCount;
enet_uint32 incomingBandwidth;
enet_uint32 outgoingBandwidth;
enet_uint32 packetThrottleInterval;
enet_uint32 packetThrottleAcceleration;
enet_uint32 packetThrottleDeceleration;
enet_uint32 connectID;
} ENET_PACKED ENetProtocolVerifyConnect;
typedef struct _ENetProtocolBandwidthLimit
{
ENetProtocolCommandHeader header;
enet_uint32 incomingBandwidth;
enet_uint32 outgoingBandwidth;
} ENET_PACKED ENetProtocolBandwidthLimit;
typedef struct _ENetProtocolThrottleConfigure
{
ENetProtocolCommandHeader header;
enet_uint32 packetThrottleInterval;
enet_uint32 packetThrottleAcceleration;
enet_uint32 packetThrottleDeceleration;
} ENET_PACKED ENetProtocolThrottleConfigure;
typedef struct _ENetProtocolDisconnect
{
ENetProtocolCommandHeader header;
enet_uint32 data;
} ENET_PACKED ENetProtocolDisconnect;
typedef struct _ENetProtocolPing
{
ENetProtocolCommandHeader header;
} ENET_PACKED ENetProtocolPing;
typedef struct _ENetProtocolSendReliable
{
ENetProtocolCommandHeader header;
enet_uint16 dataLength;
} ENET_PACKED ENetProtocolSendReliable;
typedef struct _ENetProtocolSendUnreliable
{
ENetProtocolCommandHeader header;
enet_uint16 unreliableSequenceNumber;
enet_uint16 dataLength;
} ENET_PACKED ENetProtocolSendUnreliable;
typedef struct _ENetProtocolSendUnsequenced
{
ENetProtocolCommandHeader header;
enet_uint16 unsequencedGroup;
enet_uint16 dataLength;
} ENET_PACKED ENetProtocolSendUnsequenced;
typedef struct _ENetProtocolSendFragment
{
ENetProtocolCommandHeader header;
enet_uint16 startSequenceNumber;
enet_uint16 dataLength;
enet_uint32 fragmentCount;
enet_uint32 fragmentNumber;
enet_uint32 totalLength;
enet_uint32 fragmentOffset;
} ENET_PACKED ENetProtocolSendFragment;
typedef union _ENetProtocol
{
ENetProtocolCommandHeader header;
ENetProtocolAcknowledge acknowledge;
ENetProtocolConnect connect;
ENetProtocolVerifyConnect verifyConnect;
ENetProtocolDisconnect disconnect;
ENetProtocolPing ping;
ENetProtocolSendReliable sendReliable;
ENetProtocolSendUnreliable sendUnreliable;
ENetProtocolSendUnsequenced sendUnsequenced;
ENetProtocolSendFragment sendFragment;
ENetProtocolBandwidthLimit bandwidthLimit;
ENetProtocolThrottleConfigure throttleConfigure;
} ENET_PACKED ENetProtocol;
#ifdef _MSC_VER
#pragma pack(pop)
#endif
#endif /* __ENET_PROTOCOL_H__ */
| 28.795122 | 117 | 0.797391 |
9e45be42dc39189490d9a5419111db414b116cf1 | 1,544 | h | C | Sourcecode/mx/core/elements/StaffLines.h | diskzero/MusicXML-Class-Library | bd4d1357b8ab2d4df8f1c6077883bbf169f6f0db | [
"MIT"
] | null | null | null | Sourcecode/mx/core/elements/StaffLines.h | diskzero/MusicXML-Class-Library | bd4d1357b8ab2d4df8f1c6077883bbf169f6f0db | [
"MIT"
] | null | null | null | Sourcecode/mx/core/elements/StaffLines.h | diskzero/MusicXML-Class-Library | bd4d1357b8ab2d4df8f1c6077883bbf169f6f0db | [
"MIT"
] | null | null | null | // MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License
#pragma once
#include "mx/core/ForwardDeclare.h"
#include "mx/core/ElementInterface.h"
#include "mx/core/Integers.h"
#include <iosfwd>
#include <memory>
#include <vector>
namespace mx
{
namespace core
{
MX_FORWARD_DECLARE_ELEMENT( StaffLines )
inline StaffLinesPtr makeStaffLines() { return std::make_shared<StaffLines>(); }
inline StaffLinesPtr makeStaffLines( const NonNegativeInteger& value ) { return std::make_shared<StaffLines>( value ); }
inline StaffLinesPtr makeStaffLines( NonNegativeInteger&& value ) { return std::make_shared<StaffLines>( std::move( value ) ); }
class StaffLines : public ElementInterface
{
public:
StaffLines();
StaffLines( const NonNegativeInteger& value );
virtual bool hasAttributes() const;
virtual bool hasContents() const;
virtual std::ostream& streamAttributes( std::ostream& os ) const;
virtual std::ostream& streamName( std::ostream& os ) const;
virtual std::ostream& streamContents( std::ostream& os, const int indentLevel, bool& isOneLineOnly ) const;
NonNegativeInteger getValue() const;
void setValue( const NonNegativeInteger& value );
private:
virtual bool fromXElementImpl( std::ostream& message, xml::XElement& xelement );
private:
NonNegativeInteger myValue;
};
}
}
| 32.166667 | 130 | 0.662565 |
d221d3fe958cc9d1d76b955f4c78aa9b78391eeb | 3,771 | c | C | struct.c | DaerkZeus/Huffman-Compression | f95199a0460d29726533fd37e0371563d2cb75ea | [
"MIT"
] | null | null | null | struct.c | DaerkZeus/Huffman-Compression | f95199a0460d29726533fd37e0371563d2cb75ea | [
"MIT"
] | null | null | null | struct.c | DaerkZeus/Huffman-Compression | f95199a0460d29726533fd37e0371563d2cb75ea | [
"MIT"
] | null | null | null | #include "struct.h"
TreeNode * createTreeNode(char val, long frequency)
{
TreeNode *newNode = malloc(sizeof(TreeNode));
newNode -> frequency = frequency;
newNode -> val = val;
newNode -> left = NULL;
newNode -> right = NULL;
return newNode;
}
// Merge two nodes together with left child being the first argument
TreeNode * mergeTree(TreeNode * node1, TreeNode *node2)
{
TreeNode * root = malloc(sizeof(TreeNode));
root -> left = node1;
root -> right = node2;
root -> val = node1 -> val; //Does not matter
root -> frequency = (node1 -> frequency) + (node2 -> frequency);
return root;
}
void printList(ListNode * head, FILE * fptr)
{
if (head == NULL)
{
return;
}
printTree(head -> ptr, fptr);
printList(head -> next, fptr);
}
void printTree(TreeNode * root, FILE * fptr)
{
printTreeHelper(root, fptr);
}
void printTreeHelper(TreeNode * root, FILE * fptr)
{
if (root == NULL)
{
return;
}
if (root->frequency > 0)
{
fprintf(fptr, "%c:%ld\n", root->val, root->frequency);
printTreeHelper(root->left, fptr);
printTreeHelper(root->right, fptr);
}
}
void freeTreeNode(TreeNode * t) {
free(t);
}
void freeTree(TreeNode * t) {
if (t == NULL) return;
freeTree(t->left);
freeTree(t->right);
freeTreeNode(t);
}
ListNode * createListNode(TreeNode * treePtr)
{
ListNode * newNode = malloc(sizeof(ListNode));
newNode -> ptr = treePtr;
newNode -> next = NULL;
return newNode;
}
ListNode * insertNode(ListNode * head, ListNode * toInsert)
{
if (head == NULL)
{
return toInsert; // No head, toInsert is new head
}
if (toInsert == NULL)
{
printf("Error. ListNode to insert is NULL.\n");
exit(1);
}
if ((toInsert -> next) != NULL)
{
printf("toInsert-> next must be NULL.\n");
exit(1);
}
if (compareFreq(head, toInsert) == 1) // character frequency of the newNode is smaller than the head's
{
toInsert -> next = head;
return toInsert; // Return the head
}
head -> next = insertNode(head -> next, toInsert);
return head;
}
int compareFreq(ListNode * head, ListNode * toInsert) //Return 1 if the new node needs to be inserted before
{
long freq1 = (toInsert -> ptr) -> frequency;
long freq2 = (head -> ptr) -> frequency;
if (freq1 < freq2) // character frequency of the newNode is smaller than the head's
{
return 1;
}
else if (freq2 < freq1)
{
return 0;
}
else if (freq1 == freq2)
{
if ((toInsert->ptr->val < head->ptr->val) && (toInsert->ptr->left == NULL) && (toInsert->ptr->right == NULL) ) //Compare both ASCII values
{
return 1;
}
}
return 0;
}
//Remake this function if error
ListNode * buildList(long * frequencies)
{
int index = 0;
while (frequencies[index] == 0)
{
index++;
}
if (index == ASCII_SIZE) //Amount of letters
{
return NULL; //No input
}
ListNode * head = NULL;
while (index < ASCII_SIZE)
{
if (frequencies[index] > 0 && index != 13)
{
char character = index;
TreeNode * tn = createTreeNode(character, frequencies[index]);
ListNode * ln = createListNode(tn);
head = insertNode(head, ln);
}
index++;
}
return head;
}
void freeList(ListNode * head)
{
while (head != NULL)
{
ListNode *p = head -> next;
freeTree(head->ptr);
free(head);
head = p;
}
} | 24.173077 | 147 | 0.546539 |
cfc4d8069777df74bc069c0cfd82e81b4e953332 | 3,914 | h | C | third_party/virtualbox/src/VBox/Additions/x11/x11include/xorg-server-1.18.0/loaderProcs.h | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | 521 | 2019-03-29T15:44:08.000Z | 2022-03-22T09:46:19.000Z | third_party/virtualbox/src/VBox/Additions/x11/x11include/xorg-server-1.18.0/loaderProcs.h | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | 30 | 2019-06-04T17:00:49.000Z | 2021-09-08T20:44:19.000Z | third_party/virtualbox/src/VBox/Additions/x11/x11include/xorg-server-1.18.0/loaderProcs.h | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | 99 | 2019-03-29T16:04:13.000Z | 2022-03-28T16:59:34.000Z | /*
* Copyright 1995-1998 by Metro Link, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Metro Link, Inc. not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Metro Link, Inc. makes no
* representations about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
* METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, 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.
*/
/*
* Copyright (c) 1997-2002 by The XFree86 Project, Inc.
*
* 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
*
* Except as contained in this notice, the name of the copyright holder(s)
* and author(s) shall not be used in advertising or otherwise to promote
* the sale, use or other dealings in this Software without prior written
* authorization from the copyright holder(s) and author(s).
*/
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#ifndef _LOADERPROCS_H
#define _LOADERPROCS_H
#include "xf86Module.h"
typedef struct module_desc {
struct module_desc *child;
struct module_desc *sib;
struct module_desc *parent;
char *name;
char *path;
void *handle;
ModuleSetupProc SetupProc;
ModuleTearDownProc TearDownProc;
void *TearDownData; /* returned from SetupProc */
const XF86ModuleVersionInfo *VersionInfo;
} ModuleDesc, *ModuleDescPtr;
/* External API for the loader */
void LoaderInit(void);
ModuleDescPtr LoadDriver(const char *, const char *, int, void *, int *,
int *);
ModuleDescPtr LoadModule(const char *, const char *, const char **,
const char **, void *, const XF86ModReqInfo *,
int *, int *);
ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent);
void UnloadDriver(ModuleDescPtr);
void LoaderSetPath(const char *path);
void LoaderUnload(const char *, void *);
unsigned long LoaderGetModuleVersion(ModuleDescPtr mod);
void LoaderResetOptions(void);
void LoaderSetOptions(unsigned long);
/* Options for LoaderSetOptions */
#define LDR_OPT_ABI_MISMATCH_NONFATAL 0x0001
#endif /* _LOADERPROCS_H */
| 41.638298 | 78 | 0.738631 |
82a725e68293a2b0608a3e82d94beb1457be7022 | 387 | h | C | tfacc_i8/firm/rvmon/include/uartdrv.h | shin-yamashita/5th-AI-Edge-Contest | b71de5e845b237e5beba5f317eb3fc8531aa5eda | [
"Apache-2.0"
] | 3 | 2021-02-23T23:42:36.000Z | 2021-09-14T08:52:59.000Z | src/tfacc_u8/firm/include/uartdrv.h | shin-yamashita/4th-AI-Edge-Contest | 0642d383c56256e6c0957142e93c0a1e1ec7d4cc | [
"Apache-2.0"
] | null | null | null | src/tfacc_u8/firm/include/uartdrv.h | shin-yamashita/4th-AI-Edge-Contest | 0642d383c56256e6c0957142e93c0a1e1ec7d4cc | [
"Apache-2.0"
] | null | null | null |
#ifndef _UARTDRV_H
#define _UARTDRV_H
#include "types.h"
//void select_uart(int bt);
void uart_tx(unsigned char data);
int uart_rx_ready(void);
void uart_set_baud(int brreg);
void txirq_handl();
void uart_putc(char c);
unsigned char uart_rx(void);
ssize_t uart_read(int fd, char *buf, size_t count);
ssize_t uart_write(int fd, const char *buf, size_t count);
#endif // _UARTDRV_H
| 18.428571 | 58 | 0.754522 |
324776111f3bcda316775b54a5fcd7a56362766d | 1,343 | h | C | Dev/asd_cpp/core/Graphics/3D/Resource/asd.MassModel.h | GCLemon/Altseed | b525740d64001aaed673552eb4ba3e98a321fcdf | [
"FTL"
] | 37 | 2015-07-12T14:21:03.000Z | 2020-10-17T03:08:17.000Z | Dev/asd_cpp/core/Graphics/3D/Resource/asd.MassModel.h | GCLemon/Altseed | b525740d64001aaed673552eb4ba3e98a321fcdf | [
"FTL"
] | 91 | 2015-06-14T10:47:22.000Z | 2020-06-29T18:05:21.000Z | Dev/asd_cpp/core/Graphics/3D/Resource/asd.MassModel.h | GCLemon/Altseed | b525740d64001aaed673552eb4ba3e98a321fcdf | [
"FTL"
] | 14 | 2015-07-13T04:15:20.000Z | 2021-09-30T01:34:51.000Z |
#pragma once
#include <asd.common.Base.h>
#include "../../../asd.Core.Base.h"
#include "../../../asd.ReferenceObject.h"
namespace asd
{
/**
@brief 大量描画が可能な3Dモデルクラス
*/
class MassModel
: public IReference
{
private:
protected:
MassModel(){}
virtual ~MassModel(){}
public:
/**
@brief モデルが持つアニメーションの個数を取得する。
@return アニメーションの個数
*/
virtual int32_t GetAnimationCount() const = 0;
/**
@brief モデルが持つアニメーションの名称を取得する。
@param index アニメーションのインデックス
@return アニメーションの名称
*/
virtual const achar* GetAnimationName(int32_t index) const = 0;
/**
@brief モデルが持つアニメーションの長さ(60フレーム単位)を取得する。
@param name アニメーション名
@return アニメーションの長さ
*/
virtual float GetAnimationLength(const achar* name) const = 0;
/**
@brief アニメーションがループするかを取得する。
@param name アニメーション名
@return ループするか?
*/
virtual bool GetIsAnimationLoopingMode(const achar* name) const = 0;
/**
@brief アニメーションがループするかを設定する。
@param name アニメーション名
@return isLoopingMode ループするか?
*/
virtual void SetIsAnimationLoopingMode(const achar* name, bool isLoopingMode) = 0;
/**
@brief 材質を設定する。
@param material 材質
*/
virtual void SetMaterial(Material3D* material) = 0;
#if !SWIG
/**
@brief 材質を設定する。
@param material 材質
*/
void SetMaterial(std::shared_ptr<Material3D> material)
{
SetMaterial(material.get());
}
#endif
};
} | 17.441558 | 84 | 0.682055 |
c5c01cc4e7a099a792232d3235770b9b8be1b6de | 826 | c | C | Engine Hacks/PopupRework/Src/PopRCore.c | sme23/Christmas2 | f3f3daeda1afe2b78bfed38cbf60d8bc17ca9f79 | [
"CC0-1.0"
] | 3 | 2020-06-15T14:22:38.000Z | 2020-06-28T19:44:52.000Z | Wizardry/Necessary/PopupRework/Src/PopRCore.c | sme23/WhatHeck | 746a2be83358aaa4e855182176b47c4808f2587a | [
"CC0-1.0"
] | null | null | null | Wizardry/Necessary/PopupRework/Src/PopRCore.c | sme23/WhatHeck | 746a2be83358aaa4e855182176b47c4808f2587a | [
"CC0-1.0"
] | null | null | null | #include "PopupRework.h"
unsigned PopR_GetLength(struct PopupReworkProc* proc) {
const u32* defintion = proc->pop.pDefinition;
unsigned result = 0;
if (defintion) {
while (defintion[0] && gPopupComponentTypes[defintion[0]]) {
const struct PopupComponentType* type = gPopupComponentTypes[defintion[0]];
if (type->getLength)
result += type->getLength(proc, defintion[1]);
defintion += 2;
}
}
return result;
}
void PopR_DisplayComponents(struct PopupReworkProc* proc, struct TextHandle* text) {
const u32* defintion = proc->pop.pDefinition;
if (defintion) {
while (defintion[0] && gPopupComponentTypes[defintion[0]]) {
const struct PopupComponentType* type = gPopupComponentTypes[defintion[0]];
if (type->display)
type->display(proc, text, defintion[1]);
defintion += 2;
}
}
}
| 22.944444 | 84 | 0.7046 |
3074148b7e0d3e7acf912d2c7ca30e576b0a68a9 | 85,132 | c | C | linux-4.14.90-dev/linux-4.14.90/mm/percpu.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 3 | 2022-01-20T04:23:25.000Z | 2022-03-27T13:18:30.000Z | linux-4.14.90-dev/linux-4.14.90/mm/percpu.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | null | null | null | linux-4.14.90-dev/linux-4.14.90/mm/percpu.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 20 | 2021-10-22T02:21:23.000Z | 2022-03-31T04:55:35.000Z | /*
* mm/percpu.c - percpu memory allocator
*
* Copyright (C) 2009 SUSE Linux Products GmbH
* Copyright (C) 2009 Tejun Heo <tj@kernel.org>
*
* Copyright (C) 2017 Facebook Inc.
* Copyright (C) 2017 Dennis Zhou <dennisszhou@gmail.com>
*
* This file is released under the GPLv2 license.
*
* The percpu allocator handles both static and dynamic areas. Percpu
* areas are allocated in chunks which are divided into units. There is
* a 1-to-1 mapping for units to possible cpus. These units are grouped
* based on NUMA properties of the machine.
*
* c0 c1 c2
* ------------------- ------------------- ------------
* | u0 | u1 | u2 | u3 | | u0 | u1 | u2 | u3 | | u0 | u1 | u
* ------------------- ...... ------------------- .... ------------
*
* Allocation is done by offsets into a unit's address space. Ie., an
* area of 512 bytes at 6k in c1 occupies 512 bytes at 6k in c1:u0,
* c1:u1, c1:u2, etc. On NUMA machines, the mapping may be non-linear
* and even sparse. Access is handled by configuring percpu base
* registers according to the cpu to unit mappings and offsetting the
* base address using pcpu_unit_size.
*
* There is special consideration for the first chunk which must handle
* the static percpu variables in the kernel image as allocation services
* are not online yet. In short, the first chunk is structured like so:
*
* <Static | [Reserved] | Dynamic>
*
* The static data is copied from the original section managed by the
* linker. The reserved section, if non-zero, primarily manages static
* percpu variables from kernel modules. Finally, the dynamic section
* takes care of normal allocations.
*
* The allocator organizes chunks into lists according to free size and
* tries to allocate from the fullest chunk first. Each chunk is managed
* by a bitmap with metadata blocks. The allocation map is updated on
* every allocation and free to reflect the current state while the boundary
* map is only updated on allocation. Each metadata block contains
* information to help mitigate the need to iterate over large portions
* of the bitmap. The reverse mapping from page to chunk is stored in
* the page's index. Lastly, units are lazily backed and grow in unison.
*
* There is a unique conversion that goes on here between bytes and bits.
* Each bit represents a fragment of size PCPU_MIN_ALLOC_SIZE. The chunk
* tracks the number of pages it is responsible for in nr_pages. Helper
* functions are used to convert from between the bytes, bits, and blocks.
* All hints are managed in bits unless explicitly stated.
*
* To use this allocator, arch code should do the following:
*
* - define __addr_to_pcpu_ptr() and __pcpu_ptr_to_addr() to translate
* regular address to percpu pointer and back if they need to be
* different from the default
*
* - use pcpu_setup_first_chunk() during percpu area initialization to
* setup the first chunk containing the kernel static percpu area
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitmap.h>
#include <linux/bootmem.h>
#include <linux/err.h>
#include <linux/lcm.h>
#include <linux/list.h>
#include <linux/log2.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/percpu.h>
#include <linux/pfn.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
#include <linux/workqueue.h>
#include <linux/kmemleak.h>
#include <linux/sched.h>
#include <asm/cacheflush.h>
#include <asm/sections.h>
#include <asm/tlbflush.h>
#include <asm/io.h>
#define CREATE_TRACE_POINTS
#include <trace/events/percpu.h>
#include "percpu-internal.h"
/* the slots are sorted by free bytes left, 1-31 bytes share the same slot */
#define PCPU_SLOT_BASE_SHIFT 5
#define PCPU_EMPTY_POP_PAGES_LOW 2
#define PCPU_EMPTY_POP_PAGES_HIGH 4
#ifdef CONFIG_SMP
/* default addr <-> pcpu_ptr mapping, override in asm/percpu.h if necessary */
#ifndef __addr_to_pcpu_ptr
#define __addr_to_pcpu_ptr(addr) \
(void __percpu *)((unsigned long)(addr) - \
(unsigned long)pcpu_base_addr + \
(unsigned long)__per_cpu_start)
#endif
#ifndef __pcpu_ptr_to_addr
#define __pcpu_ptr_to_addr(ptr) \
(void __force *)((unsigned long)(ptr) + \
(unsigned long)pcpu_base_addr - \
(unsigned long)__per_cpu_start)
#endif
#else /* CONFIG_SMP */
/* on UP, it's always identity mapped */
#define __addr_to_pcpu_ptr(addr) (void __percpu *)(addr)
#define __pcpu_ptr_to_addr(ptr) (void __force *)(ptr)
#endif /* CONFIG_SMP */
static int pcpu_unit_pages __ro_after_init;
static int pcpu_unit_size __ro_after_init;
static int pcpu_nr_units __ro_after_init;
static int pcpu_atom_size __ro_after_init;
int pcpu_nr_slots __ro_after_init;
static size_t pcpu_chunk_struct_size __ro_after_init;
/* cpus with the lowest and highest unit addresses */
static unsigned int pcpu_low_unit_cpu __ro_after_init;
static unsigned int pcpu_high_unit_cpu __ro_after_init;
/* the address of the first chunk which starts with the kernel static area */
void *pcpu_base_addr __ro_after_init;
EXPORT_SYMBOL_GPL(pcpu_base_addr);
static const int *pcpu_unit_map __ro_after_init; /* cpu -> unit */
const unsigned long *pcpu_unit_offsets __ro_after_init; /* cpu -> unit offset */
/* group information, used for vm allocation */
static int pcpu_nr_groups __ro_after_init;
static const unsigned long *pcpu_group_offsets __ro_after_init;
static const size_t *pcpu_group_sizes __ro_after_init;
/*
* The first chunk which always exists. Note that unlike other
* chunks, this one can be allocated and mapped in several different
* ways and thus often doesn't live in the vmalloc area.
*/
struct pcpu_chunk *pcpu_first_chunk __ro_after_init;
/*
* Optional reserved chunk. This chunk reserves part of the first
* chunk and serves it for reserved allocations. When the reserved
* region doesn't exist, the following variable is NULL.
*/
struct pcpu_chunk *pcpu_reserved_chunk __ro_after_init;
DEFINE_SPINLOCK(pcpu_lock); /* all internal data structures */
static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop, map ext */
struct list_head *pcpu_slot __ro_after_init; /* chunk list slots */
/* chunks which need their map areas extended, protected by pcpu_lock */
static LIST_HEAD(pcpu_map_extend_chunks);
/*
* The number of empty populated pages, protected by pcpu_lock. The
* reserved chunk doesn't contribute to the count.
*/
int pcpu_nr_empty_pop_pages;
/*
* Balance work is used to populate or destroy chunks asynchronously. We
* try to keep the number of populated free pages between
* PCPU_EMPTY_POP_PAGES_LOW and HIGH for atomic allocations and at most one
* empty chunk.
*/
static void pcpu_balance_workfn(struct work_struct *work);
static DECLARE_WORK(pcpu_balance_work, pcpu_balance_workfn);
static bool pcpu_async_enabled __read_mostly;
static bool pcpu_atomic_alloc_failed;
static void pcpu_schedule_balance_work(void)
{
if (pcpu_async_enabled)
schedule_work(&pcpu_balance_work);
}
/**
* pcpu_addr_in_chunk - check if the address is served from this chunk
* @chunk: chunk of interest
* @addr: percpu address
*
* RETURNS:
* True if the address is served from this chunk.
*/
static bool pcpu_addr_in_chunk(struct pcpu_chunk *chunk, void *addr)
{
void *start_addr, *end_addr;
if (!chunk)
return false;
start_addr = chunk->base_addr + chunk->start_offset;
end_addr = chunk->base_addr + chunk->nr_pages * PAGE_SIZE -
chunk->end_offset;
return addr >= start_addr && addr < end_addr;
}
static int __pcpu_size_to_slot(int size)
{
int highbit = fls(size); /* size is in bytes */
return max(highbit - PCPU_SLOT_BASE_SHIFT + 2, 1);
}
static int pcpu_size_to_slot(int size)
{
if (size == pcpu_unit_size)
return pcpu_nr_slots - 1;
return __pcpu_size_to_slot(size);
}
static int pcpu_chunk_slot(const struct pcpu_chunk *chunk)
{
if (chunk->free_bytes < PCPU_MIN_ALLOC_SIZE || chunk->contig_bits == 0)
return 0;
return pcpu_size_to_slot(chunk->free_bytes);
}
/* set the pointer to a chunk in a page struct */
static void pcpu_set_page_chunk(struct page *page, struct pcpu_chunk *pcpu)
{
page->index = (unsigned long)pcpu;
}
/* obtain pointer to a chunk from a page struct */
static struct pcpu_chunk *pcpu_get_page_chunk(struct page *page)
{
return (struct pcpu_chunk *)page->index;
}
static int __maybe_unused pcpu_page_idx(unsigned int cpu, int page_idx)
{
return pcpu_unit_map[cpu] * pcpu_unit_pages + page_idx;
}
static unsigned long pcpu_unit_page_offset(unsigned int cpu, int page_idx)
{
return pcpu_unit_offsets[cpu] + (page_idx << PAGE_SHIFT);
}
static unsigned long pcpu_chunk_addr(struct pcpu_chunk *chunk,
unsigned int cpu, int page_idx)
{
return (unsigned long)chunk->base_addr +
pcpu_unit_page_offset(cpu, page_idx);
}
static void pcpu_next_unpop(unsigned long *bitmap, int *rs, int *re, int end)
{
*rs = find_next_zero_bit(bitmap, end, *rs);
*re = find_next_bit(bitmap, end, *rs + 1);
}
static void pcpu_next_pop(unsigned long *bitmap, int *rs, int *re, int end)
{
*rs = find_next_bit(bitmap, end, *rs);
*re = find_next_zero_bit(bitmap, end, *rs + 1);
}
/*
* Bitmap region iterators. Iterates over the bitmap between
* [@start, @end) in @chunk. @rs and @re should be integer variables
* and will be set to start and end index of the current free region.
*/
#define pcpu_for_each_unpop_region(bitmap, rs, re, start, end) \
for ((rs) = (start), pcpu_next_unpop((bitmap), &(rs), &(re), (end)); \
(rs) < (re); \
(rs) = (re) + 1, pcpu_next_unpop((bitmap), &(rs), &(re), (end)))
#define pcpu_for_each_pop_region(bitmap, rs, re, start, end) \
for ((rs) = (start), pcpu_next_pop((bitmap), &(rs), &(re), (end)); \
(rs) < (re); \
(rs) = (re) + 1, pcpu_next_pop((bitmap), &(rs), &(re), (end)))
/*
* The following are helper functions to help access bitmaps and convert
* between bitmap offsets to address offsets.
*/
static unsigned long *pcpu_index_alloc_map(struct pcpu_chunk *chunk, int index)
{
return chunk->alloc_map +
(index * PCPU_BITMAP_BLOCK_BITS / BITS_PER_LONG);
}
static unsigned long pcpu_off_to_block_index(int off)
{
return off / PCPU_BITMAP_BLOCK_BITS;
}
static unsigned long pcpu_off_to_block_off(int off)
{
return off & (PCPU_BITMAP_BLOCK_BITS - 1);
}
static unsigned long pcpu_block_off_to_off(int index, int off)
{
return index * PCPU_BITMAP_BLOCK_BITS + off;
}
/**
* pcpu_next_md_free_region - finds the next hint free area
* @chunk: chunk of interest
* @bit_off: chunk offset
* @bits: size of free area
*
* Helper function for pcpu_for_each_md_free_region. It checks
* block->contig_hint and performs aggregation across blocks to find the
* next hint. It modifies bit_off and bits in-place to be consumed in the
* loop.
*/
static void pcpu_next_md_free_region(struct pcpu_chunk *chunk, int *bit_off,
int *bits)
{
int i = pcpu_off_to_block_index(*bit_off);
int block_off = pcpu_off_to_block_off(*bit_off);
struct pcpu_block_md *block;
*bits = 0;
for (block = chunk->md_blocks + i; i < pcpu_chunk_nr_blocks(chunk);
block++, i++) {
/* handles contig area across blocks */
if (*bits) {
*bits += block->left_free;
if (block->left_free == PCPU_BITMAP_BLOCK_BITS)
continue;
return;
}
/*
* This checks three things. First is there a contig_hint to
* check. Second, have we checked this hint before by
* comparing the block_off. Third, is this the same as the
* right contig hint. In the last case, it spills over into
* the next block and should be handled by the contig area
* across blocks code.
*/
*bits = block->contig_hint;
if (*bits && block->contig_hint_start >= block_off &&
*bits + block->contig_hint_start < PCPU_BITMAP_BLOCK_BITS) {
*bit_off = pcpu_block_off_to_off(i,
block->contig_hint_start);
return;
}
/* reset to satisfy the second predicate above */
block_off = 0;
*bits = block->right_free;
*bit_off = (i + 1) * PCPU_BITMAP_BLOCK_BITS - block->right_free;
}
}
/**
* pcpu_next_fit_region - finds fit areas for a given allocation request
* @chunk: chunk of interest
* @alloc_bits: size of allocation
* @align: alignment of area (max PAGE_SIZE)
* @bit_off: chunk offset
* @bits: size of free area
*
* Finds the next free region that is viable for use with a given size and
* alignment. This only returns if there is a valid area to be used for this
* allocation. block->first_free is returned if the allocation request fits
* within the block to see if the request can be fulfilled prior to the contig
* hint.
*/
static void pcpu_next_fit_region(struct pcpu_chunk *chunk, int alloc_bits,
int align, int *bit_off, int *bits)
{
int i = pcpu_off_to_block_index(*bit_off);
int block_off = pcpu_off_to_block_off(*bit_off);
struct pcpu_block_md *block;
*bits = 0;
for (block = chunk->md_blocks + i; i < pcpu_chunk_nr_blocks(chunk);
block++, i++) {
/* handles contig area across blocks */
if (*bits) {
*bits += block->left_free;
if (*bits >= alloc_bits)
return;
if (block->left_free == PCPU_BITMAP_BLOCK_BITS)
continue;
}
/* check block->contig_hint */
*bits = ALIGN(block->contig_hint_start, align) -
block->contig_hint_start;
/*
* This uses the block offset to determine if this has been
* checked in the prior iteration.
*/
if (block->contig_hint &&
block->contig_hint_start >= block_off &&
block->contig_hint >= *bits + alloc_bits) {
*bits += alloc_bits + block->contig_hint_start -
block->first_free;
*bit_off = pcpu_block_off_to_off(i, block->first_free);
return;
}
/* reset to satisfy the second predicate above */
block_off = 0;
*bit_off = ALIGN(PCPU_BITMAP_BLOCK_BITS - block->right_free,
align);
*bits = PCPU_BITMAP_BLOCK_BITS - *bit_off;
*bit_off = pcpu_block_off_to_off(i, *bit_off);
if (*bits >= alloc_bits)
return;
}
/* no valid offsets were found - fail condition */
*bit_off = pcpu_chunk_map_bits(chunk);
}
/*
* Metadata free area iterators. These perform aggregation of free areas
* based on the metadata blocks and return the offset @bit_off and size in
* bits of the free area @bits. pcpu_for_each_fit_region only returns when
* a fit is found for the allocation request.
*/
#define pcpu_for_each_md_free_region(chunk, bit_off, bits) \
for (pcpu_next_md_free_region((chunk), &(bit_off), &(bits)); \
(bit_off) < pcpu_chunk_map_bits((chunk)); \
(bit_off) += (bits) + 1, \
pcpu_next_md_free_region((chunk), &(bit_off), &(bits)))
#define pcpu_for_each_fit_region(chunk, alloc_bits, align, bit_off, bits) \
for (pcpu_next_fit_region((chunk), (alloc_bits), (align), &(bit_off), \
&(bits)); \
(bit_off) < pcpu_chunk_map_bits((chunk)); \
(bit_off) += (bits), \
pcpu_next_fit_region((chunk), (alloc_bits), (align), &(bit_off), \
&(bits)))
/**
* pcpu_mem_zalloc - allocate memory
* @size: bytes to allocate
* @gfp: allocation flags
*
* Allocate @size bytes. If @size is smaller than PAGE_SIZE,
* kzalloc() is used; otherwise, the equivalent of vzalloc() is used.
* This is to facilitate passing through whitelisted flags. The
* returned memory is always zeroed.
*
* CONTEXT:
* Does GFP_KERNEL allocation.
*
* RETURNS:
* Pointer to the allocated area on success, NULL on failure.
*/
static void *pcpu_mem_zalloc(size_t size, gfp_t gfp)
{
if (WARN_ON_ONCE(!slab_is_available()))
return NULL;
if (size <= PAGE_SIZE)
return kzalloc(size, gfp | GFP_KERNEL);
else
return __vmalloc(size, gfp | GFP_KERNEL | __GFP_ZERO,
PAGE_KERNEL);
}
/**
* pcpu_mem_free - free memory
* @ptr: memory to free
*
* Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc().
*/
static void pcpu_mem_free(void *ptr)
{
kvfree(ptr);
}
/**
* pcpu_chunk_relocate - put chunk in the appropriate chunk slot
* @chunk: chunk of interest
* @oslot: the previous slot it was on
*
* This function is called after an allocation or free changed @chunk.
* New slot according to the changed state is determined and @chunk is
* moved to the slot. Note that the reserved chunk is never put on
* chunk slots.
*
* CONTEXT:
* pcpu_lock.
*/
static void pcpu_chunk_relocate(struct pcpu_chunk *chunk, int oslot)
{
int nslot = pcpu_chunk_slot(chunk);
if (chunk != pcpu_reserved_chunk && oslot != nslot) {
if (oslot < nslot)
list_move(&chunk->list, &pcpu_slot[nslot]);
else
list_move_tail(&chunk->list, &pcpu_slot[nslot]);
}
}
/**
* pcpu_cnt_pop_pages- counts populated backing pages in range
* @chunk: chunk of interest
* @bit_off: start offset
* @bits: size of area to check
*
* Calculates the number of populated pages in the region
* [page_start, page_end). This keeps track of how many empty populated
* pages are available and decide if async work should be scheduled.
*
* RETURNS:
* The nr of populated pages.
*/
static inline int pcpu_cnt_pop_pages(struct pcpu_chunk *chunk, int bit_off,
int bits)
{
int page_start = PFN_UP(bit_off * PCPU_MIN_ALLOC_SIZE);
int page_end = PFN_DOWN((bit_off + bits) * PCPU_MIN_ALLOC_SIZE);
if (page_start >= page_end)
return 0;
/*
* bitmap_weight counts the number of bits set in a bitmap up to
* the specified number of bits. This is counting the populated
* pages up to page_end and then subtracting the populated pages
* up to page_start to count the populated pages in
* [page_start, page_end).
*/
return bitmap_weight(chunk->populated, page_end) -
bitmap_weight(chunk->populated, page_start);
}
/**
* pcpu_chunk_update - updates the chunk metadata given a free area
* @chunk: chunk of interest
* @bit_off: chunk offset
* @bits: size of free area
*
* This updates the chunk's contig hint and starting offset given a free area.
* Choose the best starting offset if the contig hint is equal.
*/
static void pcpu_chunk_update(struct pcpu_chunk *chunk, int bit_off, int bits)
{
if (bits > chunk->contig_bits) {
chunk->contig_bits_start = bit_off;
chunk->contig_bits = bits;
} else if (bits == chunk->contig_bits && chunk->contig_bits_start &&
(!bit_off ||
__ffs(bit_off) > __ffs(chunk->contig_bits_start))) {
/* use the start with the best alignment */
chunk->contig_bits_start = bit_off;
}
}
/**
* pcpu_chunk_refresh_hint - updates metadata about a chunk
* @chunk: chunk of interest
*
* Iterates over the metadata blocks to find the largest contig area.
* It also counts the populated pages and uses the delta to update the
* global count.
*
* Updates:
* chunk->contig_bits
* chunk->contig_bits_start
* nr_empty_pop_pages (chunk and global)
*/
static void pcpu_chunk_refresh_hint(struct pcpu_chunk *chunk)
{
int bit_off, bits, nr_empty_pop_pages;
/* clear metadata */
chunk->contig_bits = 0;
bit_off = chunk->first_bit;
bits = nr_empty_pop_pages = 0;
pcpu_for_each_md_free_region(chunk, bit_off, bits) {
pcpu_chunk_update(chunk, bit_off, bits);
nr_empty_pop_pages += pcpu_cnt_pop_pages(chunk, bit_off, bits);
}
/*
* Keep track of nr_empty_pop_pages.
*
* The chunk maintains the previous number of free pages it held,
* so the delta is used to update the global counter. The reserved
* chunk is not part of the free page count as they are populated
* at init and are special to serving reserved allocations.
*/
if (chunk != pcpu_reserved_chunk)
pcpu_nr_empty_pop_pages +=
(nr_empty_pop_pages - chunk->nr_empty_pop_pages);
chunk->nr_empty_pop_pages = nr_empty_pop_pages;
}
/**
* pcpu_block_update - updates a block given a free area
* @block: block of interest
* @start: start offset in block
* @end: end offset in block
*
* Updates a block given a known free area. The region [start, end) is
* expected to be the entirety of the free area within a block. Chooses
* the best starting offset if the contig hints are equal.
*/
static void pcpu_block_update(struct pcpu_block_md *block, int start, int end)
{
int contig = end - start;
block->first_free = min(block->first_free, start);
if (start == 0)
block->left_free = contig;
if (end == PCPU_BITMAP_BLOCK_BITS)
block->right_free = contig;
if (contig > block->contig_hint) {
block->contig_hint_start = start;
block->contig_hint = contig;
} else if (block->contig_hint_start && contig == block->contig_hint &&
(!start || __ffs(start) > __ffs(block->contig_hint_start))) {
/* use the start with the best alignment */
block->contig_hint_start = start;
}
}
/**
* pcpu_block_refresh_hint
* @chunk: chunk of interest
* @index: index of the metadata block
*
* Scans over the block beginning at first_free and updates the block
* metadata accordingly.
*/
static void pcpu_block_refresh_hint(struct pcpu_chunk *chunk, int index)
{
struct pcpu_block_md *block = chunk->md_blocks + index;
unsigned long *alloc_map = pcpu_index_alloc_map(chunk, index);
int rs, re; /* region start, region end */
/* clear hints */
block->contig_hint = 0;
block->left_free = block->right_free = 0;
/* iterate over free areas and update the contig hints */
pcpu_for_each_unpop_region(alloc_map, rs, re, block->first_free,
PCPU_BITMAP_BLOCK_BITS) {
pcpu_block_update(block, rs, re);
}
}
/**
* pcpu_block_update_hint_alloc - update hint on allocation path
* @chunk: chunk of interest
* @bit_off: chunk offset
* @bits: size of request
*
* Updates metadata for the allocation path. The metadata only has to be
* refreshed by a full scan iff the chunk's contig hint is broken. Block level
* scans are required if the block's contig hint is broken.
*/
static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off,
int bits)
{
struct pcpu_block_md *s_block, *e_block, *block;
int s_index, e_index; /* block indexes of the freed allocation */
int s_off, e_off; /* block offsets of the freed allocation */
/*
* Calculate per block offsets.
* The calculation uses an inclusive range, but the resulting offsets
* are [start, end). e_index always points to the last block in the
* range.
*/
s_index = pcpu_off_to_block_index(bit_off);
e_index = pcpu_off_to_block_index(bit_off + bits - 1);
s_off = pcpu_off_to_block_off(bit_off);
e_off = pcpu_off_to_block_off(bit_off + bits - 1) + 1;
s_block = chunk->md_blocks + s_index;
e_block = chunk->md_blocks + e_index;
/*
* Update s_block.
* block->first_free must be updated if the allocation takes its place.
* If the allocation breaks the contig_hint, a scan is required to
* restore this hint.
*/
if (s_off == s_block->first_free)
s_block->first_free = find_next_zero_bit(
pcpu_index_alloc_map(chunk, s_index),
PCPU_BITMAP_BLOCK_BITS,
s_off + bits);
if (s_off >= s_block->contig_hint_start &&
s_off < s_block->contig_hint_start + s_block->contig_hint) {
/* block contig hint is broken - scan to fix it */
pcpu_block_refresh_hint(chunk, s_index);
} else {
/* update left and right contig manually */
s_block->left_free = min(s_block->left_free, s_off);
if (s_index == e_index)
s_block->right_free = min_t(int, s_block->right_free,
PCPU_BITMAP_BLOCK_BITS - e_off);
else
s_block->right_free = 0;
}
/*
* Update e_block.
*/
if (s_index != e_index) {
/*
* When the allocation is across blocks, the end is along
* the left part of the e_block.
*/
e_block->first_free = find_next_zero_bit(
pcpu_index_alloc_map(chunk, e_index),
PCPU_BITMAP_BLOCK_BITS, e_off);
if (e_off == PCPU_BITMAP_BLOCK_BITS) {
/* reset the block */
e_block++;
} else {
if (e_off > e_block->contig_hint_start) {
/* contig hint is broken - scan to fix it */
pcpu_block_refresh_hint(chunk, e_index);
} else {
e_block->left_free = 0;
e_block->right_free =
min_t(int, e_block->right_free,
PCPU_BITMAP_BLOCK_BITS - e_off);
}
}
/* update in-between md_blocks */
for (block = s_block + 1; block < e_block; block++) {
block->contig_hint = 0;
block->left_free = 0;
block->right_free = 0;
}
}
/*
* The only time a full chunk scan is required is if the chunk
* contig hint is broken. Otherwise, it means a smaller space
* was used and therefore the chunk contig hint is still correct.
*/
if (bit_off >= chunk->contig_bits_start &&
bit_off < chunk->contig_bits_start + chunk->contig_bits)
pcpu_chunk_refresh_hint(chunk);
}
/**
* pcpu_block_update_hint_free - updates the block hints on the free path
* @chunk: chunk of interest
* @bit_off: chunk offset
* @bits: size of request
*
* Updates metadata for the allocation path. This avoids a blind block
* refresh by making use of the block contig hints. If this fails, it scans
* forward and backward to determine the extent of the free area. This is
* capped at the boundary of blocks.
*
* A chunk update is triggered if a page becomes free, a block becomes free,
* or the free spans across blocks. This tradeoff is to minimize iterating
* over the block metadata to update chunk->contig_bits. chunk->contig_bits
* may be off by up to a page, but it will never be more than the available
* space. If the contig hint is contained in one block, it will be accurate.
*/
static void pcpu_block_update_hint_free(struct pcpu_chunk *chunk, int bit_off,
int bits)
{
struct pcpu_block_md *s_block, *e_block, *block;
int s_index, e_index; /* block indexes of the freed allocation */
int s_off, e_off; /* block offsets of the freed allocation */
int start, end; /* start and end of the whole free area */
/*
* Calculate per block offsets.
* The calculation uses an inclusive range, but the resulting offsets
* are [start, end). e_index always points to the last block in the
* range.
*/
s_index = pcpu_off_to_block_index(bit_off);
e_index = pcpu_off_to_block_index(bit_off + bits - 1);
s_off = pcpu_off_to_block_off(bit_off);
e_off = pcpu_off_to_block_off(bit_off + bits - 1) + 1;
s_block = chunk->md_blocks + s_index;
e_block = chunk->md_blocks + e_index;
/*
* Check if the freed area aligns with the block->contig_hint.
* If it does, then the scan to find the beginning/end of the
* larger free area can be avoided.
*
* start and end refer to beginning and end of the free area
* within each their respective blocks. This is not necessarily
* the entire free area as it may span blocks past the beginning
* or end of the block.
*/
start = s_off;
if (s_off == s_block->contig_hint + s_block->contig_hint_start) {
start = s_block->contig_hint_start;
} else {
/*
* Scan backwards to find the extent of the free area.
* find_last_bit returns the starting bit, so if the start bit
* is returned, that means there was no last bit and the
* remainder of the chunk is free.
*/
int l_bit = find_last_bit(pcpu_index_alloc_map(chunk, s_index),
start);
start = (start == l_bit) ? 0 : l_bit + 1;
}
end = e_off;
if (e_off == e_block->contig_hint_start)
end = e_block->contig_hint_start + e_block->contig_hint;
else
end = find_next_bit(pcpu_index_alloc_map(chunk, e_index),
PCPU_BITMAP_BLOCK_BITS, end);
/* update s_block */
e_off = (s_index == e_index) ? end : PCPU_BITMAP_BLOCK_BITS;
pcpu_block_update(s_block, start, e_off);
/* freeing in the same block */
if (s_index != e_index) {
/* update e_block */
pcpu_block_update(e_block, 0, end);
/* reset md_blocks in the middle */
for (block = s_block + 1; block < e_block; block++) {
block->first_free = 0;
block->contig_hint_start = 0;
block->contig_hint = PCPU_BITMAP_BLOCK_BITS;
block->left_free = PCPU_BITMAP_BLOCK_BITS;
block->right_free = PCPU_BITMAP_BLOCK_BITS;
}
}
/*
* Refresh chunk metadata when the free makes a page free, a block
* free, or spans across blocks. The contig hint may be off by up to
* a page, but if the hint is contained in a block, it will be accurate
* with the else condition below.
*/
if ((ALIGN_DOWN(end, min(PCPU_BITS_PER_PAGE, PCPU_BITMAP_BLOCK_BITS)) >
ALIGN(start, min(PCPU_BITS_PER_PAGE, PCPU_BITMAP_BLOCK_BITS))) ||
s_index != e_index)
pcpu_chunk_refresh_hint(chunk);
else
pcpu_chunk_update(chunk, pcpu_block_off_to_off(s_index, start),
s_block->contig_hint);
}
/**
* pcpu_is_populated - determines if the region is populated
* @chunk: chunk of interest
* @bit_off: chunk offset
* @bits: size of area
* @next_off: return value for the next offset to start searching
*
* For atomic allocations, check if the backing pages are populated.
*
* RETURNS:
* Bool if the backing pages are populated.
* next_index is to skip over unpopulated blocks in pcpu_find_block_fit.
*/
static bool pcpu_is_populated(struct pcpu_chunk *chunk, int bit_off, int bits,
int *next_off)
{
int page_start, page_end, rs, re;
page_start = PFN_DOWN(bit_off * PCPU_MIN_ALLOC_SIZE);
page_end = PFN_UP((bit_off + bits) * PCPU_MIN_ALLOC_SIZE);
rs = page_start;
pcpu_next_unpop(chunk->populated, &rs, &re, page_end);
if (rs >= page_end)
return true;
*next_off = re * PAGE_SIZE / PCPU_MIN_ALLOC_SIZE;
return false;
}
/**
* pcpu_find_block_fit - finds the block index to start searching
* @chunk: chunk of interest
* @alloc_bits: size of request in allocation units
* @align: alignment of area (max PAGE_SIZE bytes)
* @pop_only: use populated regions only
*
* Given a chunk and an allocation spec, find the offset to begin searching
* for a free region. This iterates over the bitmap metadata blocks to
* find an offset that will be guaranteed to fit the requirements. It is
* not quite first fit as if the allocation does not fit in the contig hint
* of a block or chunk, it is skipped. This errs on the side of caution
* to prevent excess iteration. Poor alignment can cause the allocator to
* skip over blocks and chunks that have valid free areas.
*
* RETURNS:
* The offset in the bitmap to begin searching.
* -1 if no offset is found.
*/
static int pcpu_find_block_fit(struct pcpu_chunk *chunk, int alloc_bits,
size_t align, bool pop_only)
{
int bit_off, bits, next_off;
/*
* Check to see if the allocation can fit in the chunk's contig hint.
* This is an optimization to prevent scanning by assuming if it
* cannot fit in the global hint, there is memory pressure and creating
* a new chunk would happen soon.
*/
bit_off = ALIGN(chunk->contig_bits_start, align) -
chunk->contig_bits_start;
if (bit_off + alloc_bits > chunk->contig_bits)
return -1;
bit_off = chunk->first_bit;
bits = 0;
pcpu_for_each_fit_region(chunk, alloc_bits, align, bit_off, bits) {
if (!pop_only || pcpu_is_populated(chunk, bit_off, bits,
&next_off))
break;
bit_off = next_off;
bits = 0;
}
if (bit_off == pcpu_chunk_map_bits(chunk))
return -1;
return bit_off;
}
/**
* pcpu_alloc_area - allocates an area from a pcpu_chunk
* @chunk: chunk of interest
* @alloc_bits: size of request in allocation units
* @align: alignment of area (max PAGE_SIZE)
* @start: bit_off to start searching
*
* This function takes in a @start offset to begin searching to fit an
* allocation of @alloc_bits with alignment @align. It needs to scan
* the allocation map because if it fits within the block's contig hint,
* @start will be block->first_free. This is an attempt to fill the
* allocation prior to breaking the contig hint. The allocation and
* boundary maps are updated accordingly if it confirms a valid
* free area.
*
* RETURNS:
* Allocated addr offset in @chunk on success.
* -1 if no matching area is found.
*/
static int pcpu_alloc_area(struct pcpu_chunk *chunk, int alloc_bits,
size_t align, int start)
{
size_t align_mask = (align) ? (align - 1) : 0;
int bit_off, end, oslot;
lockdep_assert_held(&pcpu_lock);
oslot = pcpu_chunk_slot(chunk);
/*
* Search to find a fit.
*/
end = start + alloc_bits + PCPU_BITMAP_BLOCK_BITS;
bit_off = bitmap_find_next_zero_area(chunk->alloc_map, end, start,
alloc_bits, align_mask);
if (bit_off >= end)
return -1;
/* update alloc map */
bitmap_set(chunk->alloc_map, bit_off, alloc_bits);
/* update boundary map */
set_bit(bit_off, chunk->bound_map);
bitmap_clear(chunk->bound_map, bit_off + 1, alloc_bits - 1);
set_bit(bit_off + alloc_bits, chunk->bound_map);
chunk->free_bytes -= alloc_bits * PCPU_MIN_ALLOC_SIZE;
/* update first free bit */
if (bit_off == chunk->first_bit)
chunk->first_bit = find_next_zero_bit(
chunk->alloc_map,
pcpu_chunk_map_bits(chunk),
bit_off + alloc_bits);
pcpu_block_update_hint_alloc(chunk, bit_off, alloc_bits);
pcpu_chunk_relocate(chunk, oslot);
return bit_off * PCPU_MIN_ALLOC_SIZE;
}
/**
* pcpu_free_area - frees the corresponding offset
* @chunk: chunk of interest
* @off: addr offset into chunk
*
* This function determines the size of an allocation to free using
* the boundary bitmap and clears the allocation map.
*/
static void pcpu_free_area(struct pcpu_chunk *chunk, int off)
{
int bit_off, bits, end, oslot;
lockdep_assert_held(&pcpu_lock);
pcpu_stats_area_dealloc(chunk);
oslot = pcpu_chunk_slot(chunk);
bit_off = off / PCPU_MIN_ALLOC_SIZE;
/* find end index */
end = find_next_bit(chunk->bound_map, pcpu_chunk_map_bits(chunk),
bit_off + 1);
bits = end - bit_off;
bitmap_clear(chunk->alloc_map, bit_off, bits);
/* update metadata */
chunk->free_bytes += bits * PCPU_MIN_ALLOC_SIZE;
/* update first free bit */
chunk->first_bit = min(chunk->first_bit, bit_off);
pcpu_block_update_hint_free(chunk, bit_off, bits);
pcpu_chunk_relocate(chunk, oslot);
}
static void pcpu_init_md_blocks(struct pcpu_chunk *chunk)
{
struct pcpu_block_md *md_block;
for (md_block = chunk->md_blocks;
md_block != chunk->md_blocks + pcpu_chunk_nr_blocks(chunk);
md_block++) {
md_block->contig_hint = PCPU_BITMAP_BLOCK_BITS;
md_block->left_free = PCPU_BITMAP_BLOCK_BITS;
md_block->right_free = PCPU_BITMAP_BLOCK_BITS;
}
}
/**
* pcpu_alloc_first_chunk - creates chunks that serve the first chunk
* @tmp_addr: the start of the region served
* @map_size: size of the region served
*
* This is responsible for creating the chunks that serve the first chunk. The
* base_addr is page aligned down of @tmp_addr while the region end is page
* aligned up. Offsets are kept track of to determine the region served. All
* this is done to appease the bitmap allocator in avoiding partial blocks.
*
* RETURNS:
* Chunk serving the region at @tmp_addr of @map_size.
*/
static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr,
int map_size)
{
struct pcpu_chunk *chunk;
unsigned long aligned_addr, lcm_align;
int start_offset, offset_bits, region_size, region_bits;
/* region calculations */
aligned_addr = tmp_addr & PAGE_MASK;
start_offset = tmp_addr - aligned_addr;
/*
* Align the end of the region with the LCM of PAGE_SIZE and
* PCPU_BITMAP_BLOCK_SIZE. One of these constants is a multiple of
* the other.
*/
lcm_align = lcm(PAGE_SIZE, PCPU_BITMAP_BLOCK_SIZE);
region_size = ALIGN(start_offset + map_size, lcm_align);
/* allocate chunk */
chunk = memblock_virt_alloc(sizeof(struct pcpu_chunk) +
BITS_TO_LONGS(region_size >> PAGE_SHIFT),
0);
INIT_LIST_HEAD(&chunk->list);
chunk->base_addr = (void *)aligned_addr;
chunk->start_offset = start_offset;
chunk->end_offset = region_size - chunk->start_offset - map_size;
chunk->nr_pages = region_size >> PAGE_SHIFT;
region_bits = pcpu_chunk_map_bits(chunk);
chunk->alloc_map = memblock_virt_alloc(BITS_TO_LONGS(region_bits) *
sizeof(chunk->alloc_map[0]), 0);
chunk->bound_map = memblock_virt_alloc(BITS_TO_LONGS(region_bits + 1) *
sizeof(chunk->bound_map[0]), 0);
chunk->md_blocks = memblock_virt_alloc(pcpu_chunk_nr_blocks(chunk) *
sizeof(chunk->md_blocks[0]), 0);
pcpu_init_md_blocks(chunk);
/* manage populated page bitmap */
chunk->immutable = true;
bitmap_fill(chunk->populated, chunk->nr_pages);
chunk->nr_populated = chunk->nr_pages;
chunk->nr_empty_pop_pages =
pcpu_cnt_pop_pages(chunk, start_offset / PCPU_MIN_ALLOC_SIZE,
map_size / PCPU_MIN_ALLOC_SIZE);
chunk->contig_bits = map_size / PCPU_MIN_ALLOC_SIZE;
chunk->free_bytes = map_size;
if (chunk->start_offset) {
/* hide the beginning of the bitmap */
offset_bits = chunk->start_offset / PCPU_MIN_ALLOC_SIZE;
bitmap_set(chunk->alloc_map, 0, offset_bits);
set_bit(0, chunk->bound_map);
set_bit(offset_bits, chunk->bound_map);
chunk->first_bit = offset_bits;
pcpu_block_update_hint_alloc(chunk, 0, offset_bits);
}
if (chunk->end_offset) {
/* hide the end of the bitmap */
offset_bits = chunk->end_offset / PCPU_MIN_ALLOC_SIZE;
bitmap_set(chunk->alloc_map,
pcpu_chunk_map_bits(chunk) - offset_bits,
offset_bits);
set_bit((start_offset + map_size) / PCPU_MIN_ALLOC_SIZE,
chunk->bound_map);
set_bit(region_bits, chunk->bound_map);
pcpu_block_update_hint_alloc(chunk, pcpu_chunk_map_bits(chunk)
- offset_bits, offset_bits);
}
return chunk;
}
static struct pcpu_chunk *pcpu_alloc_chunk(gfp_t gfp)
{
struct pcpu_chunk *chunk;
int region_bits;
chunk = pcpu_mem_zalloc(pcpu_chunk_struct_size, gfp);
if (!chunk)
return NULL;
INIT_LIST_HEAD(&chunk->list);
chunk->nr_pages = pcpu_unit_pages;
region_bits = pcpu_chunk_map_bits(chunk);
chunk->alloc_map = pcpu_mem_zalloc(BITS_TO_LONGS(region_bits) *
sizeof(chunk->alloc_map[0]), gfp);
if (!chunk->alloc_map)
goto alloc_map_fail;
chunk->bound_map = pcpu_mem_zalloc(BITS_TO_LONGS(region_bits + 1) *
sizeof(chunk->bound_map[0]), gfp);
if (!chunk->bound_map)
goto bound_map_fail;
chunk->md_blocks = pcpu_mem_zalloc(pcpu_chunk_nr_blocks(chunk) *
sizeof(chunk->md_blocks[0]), gfp);
if (!chunk->md_blocks)
goto md_blocks_fail;
pcpu_init_md_blocks(chunk);
/* init metadata */
chunk->contig_bits = region_bits;
chunk->free_bytes = chunk->nr_pages * PAGE_SIZE;
return chunk;
md_blocks_fail:
pcpu_mem_free(chunk->bound_map);
bound_map_fail:
pcpu_mem_free(chunk->alloc_map);
alloc_map_fail:
pcpu_mem_free(chunk);
return NULL;
}
static void pcpu_free_chunk(struct pcpu_chunk *chunk)
{
if (!chunk)
return;
pcpu_mem_free(chunk->md_blocks);
pcpu_mem_free(chunk->bound_map);
pcpu_mem_free(chunk->alloc_map);
pcpu_mem_free(chunk);
}
/**
* pcpu_chunk_populated - post-population bookkeeping
* @chunk: pcpu_chunk which got populated
* @page_start: the start page
* @page_end: the end page
* @for_alloc: if this is to populate for allocation
*
* Pages in [@page_start,@page_end) have been populated to @chunk. Update
* the bookkeeping information accordingly. Must be called after each
* successful population.
*
* If this is @for_alloc, do not increment pcpu_nr_empty_pop_pages because it
* is to serve an allocation in that area.
*/
static void pcpu_chunk_populated(struct pcpu_chunk *chunk, int page_start,
int page_end, bool for_alloc)
{
int nr = page_end - page_start;
lockdep_assert_held(&pcpu_lock);
bitmap_set(chunk->populated, page_start, nr);
chunk->nr_populated += nr;
if (!for_alloc) {
chunk->nr_empty_pop_pages += nr;
pcpu_nr_empty_pop_pages += nr;
}
}
/**
* pcpu_chunk_depopulated - post-depopulation bookkeeping
* @chunk: pcpu_chunk which got depopulated
* @page_start: the start page
* @page_end: the end page
*
* Pages in [@page_start,@page_end) have been depopulated from @chunk.
* Update the bookkeeping information accordingly. Must be called after
* each successful depopulation.
*/
static void pcpu_chunk_depopulated(struct pcpu_chunk *chunk,
int page_start, int page_end)
{
int nr = page_end - page_start;
lockdep_assert_held(&pcpu_lock);
bitmap_clear(chunk->populated, page_start, nr);
chunk->nr_populated -= nr;
chunk->nr_empty_pop_pages -= nr;
pcpu_nr_empty_pop_pages -= nr;
}
/*
* Chunk management implementation.
*
* To allow different implementations, chunk alloc/free and
* [de]population are implemented in a separate file which is pulled
* into this file and compiled together. The following functions
* should be implemented.
*
* pcpu_populate_chunk - populate the specified range of a chunk
* pcpu_depopulate_chunk - depopulate the specified range of a chunk
* pcpu_create_chunk - create a new chunk
* pcpu_destroy_chunk - destroy a chunk, always preceded by full depop
* pcpu_addr_to_page - translate address to physical address
* pcpu_verify_alloc_info - check alloc_info is acceptable during init
*/
static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size,
gfp_t gfp);
static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size);
static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp);
static void pcpu_destroy_chunk(struct pcpu_chunk *chunk);
static struct page *pcpu_addr_to_page(void *addr);
static int __init pcpu_verify_alloc_info(const struct pcpu_alloc_info *ai);
#ifdef CONFIG_NEED_PER_CPU_KM
#include "percpu-km.c"
#else
#include "percpu-vm.c"
#endif
/**
* pcpu_chunk_addr_search - determine chunk containing specified address
* @addr: address for which the chunk needs to be determined.
*
* This is an internal function that handles all but static allocations.
* Static percpu address values should never be passed into the allocator.
*
* RETURNS:
* The address of the found chunk.
*/
static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
{
/* is it in the dynamic region (first chunk)? */
if (pcpu_addr_in_chunk(pcpu_first_chunk, addr))
return pcpu_first_chunk;
/* is it in the reserved region? */
if (pcpu_addr_in_chunk(pcpu_reserved_chunk, addr))
return pcpu_reserved_chunk;
/*
* The address is relative to unit0 which might be unused and
* thus unmapped. Offset the address to the unit space of the
* current processor before looking it up in the vmalloc
* space. Note that any possible cpu id can be used here, so
* there's no need to worry about preemption or cpu hotplug.
*/
addr += pcpu_unit_offsets[raw_smp_processor_id()];
return pcpu_get_page_chunk(pcpu_addr_to_page(addr));
}
/**
* pcpu_alloc - the percpu allocator
* @size: size of area to allocate in bytes
* @align: alignment of area (max PAGE_SIZE)
* @reserved: allocate from the reserved chunk if available
* @gfp: allocation flags
*
* Allocate percpu area of @size bytes aligned at @align. If @gfp doesn't
* contain %GFP_KERNEL, the allocation is atomic. If @gfp has __GFP_NOWARN
* then no warning will be triggered on invalid or failed allocation
* requests.
*
* RETURNS:
* Percpu pointer to the allocated area on success, NULL on failure.
*/
static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
gfp_t gfp)
{
bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
bool do_warn = !(gfp & __GFP_NOWARN);
static int warn_limit = 10;
struct pcpu_chunk *chunk;
const char *err;
int slot, off, cpu, ret;
unsigned long flags;
void __percpu *ptr;
size_t bits, bit_align;
/*
* There is now a minimum allocation size of PCPU_MIN_ALLOC_SIZE,
* therefore alignment must be a minimum of that many bytes.
* An allocation may have internal fragmentation from rounding up
* of up to PCPU_MIN_ALLOC_SIZE - 1 bytes.
*/
if (unlikely(align < PCPU_MIN_ALLOC_SIZE))
align = PCPU_MIN_ALLOC_SIZE;
size = ALIGN(size, PCPU_MIN_ALLOC_SIZE);
bits = size >> PCPU_MIN_ALLOC_SHIFT;
bit_align = align >> PCPU_MIN_ALLOC_SHIFT;
if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE ||
!is_power_of_2(align))) {
WARN(do_warn, "illegal size (%zu) or align (%zu) for percpu allocation\n",
size, align);
return NULL;
}
if (!is_atomic)
mutex_lock(&pcpu_alloc_mutex);
spin_lock_irqsave(&pcpu_lock, flags);
/* serve reserved allocations from the reserved chunk if available */
if (reserved && pcpu_reserved_chunk) {
chunk = pcpu_reserved_chunk;
off = pcpu_find_block_fit(chunk, bits, bit_align, is_atomic);
if (off < 0) {
err = "alloc from reserved chunk failed";
goto fail_unlock;
}
off = pcpu_alloc_area(chunk, bits, bit_align, off);
if (off >= 0)
goto area_found;
err = "alloc from reserved chunk failed";
goto fail_unlock;
}
restart:
/* search through normal chunks */
for (slot = pcpu_size_to_slot(size); slot < pcpu_nr_slots; slot++) {
list_for_each_entry(chunk, &pcpu_slot[slot], list) {
off = pcpu_find_block_fit(chunk, bits, bit_align,
is_atomic);
if (off < 0)
continue;
off = pcpu_alloc_area(chunk, bits, bit_align, off);
if (off >= 0)
goto area_found;
}
}
spin_unlock_irqrestore(&pcpu_lock, flags);
/*
* No space left. Create a new chunk. We don't want multiple
* tasks to create chunks simultaneously. Serialize and create iff
* there's still no empty chunk after grabbing the mutex.
*/
if (is_atomic) {
err = "atomic alloc failed, no space left";
goto fail;
}
if (list_empty(&pcpu_slot[pcpu_nr_slots - 1])) {
chunk = pcpu_create_chunk(0);
if (!chunk) {
err = "failed to allocate new chunk";
goto fail;
}
spin_lock_irqsave(&pcpu_lock, flags);
pcpu_chunk_relocate(chunk, -1);
} else {
spin_lock_irqsave(&pcpu_lock, flags);
}
goto restart;
area_found:
pcpu_stats_area_alloc(chunk, size);
spin_unlock_irqrestore(&pcpu_lock, flags);
/* populate if not all pages are already there */
if (!is_atomic) {
int page_start, page_end, rs, re;
page_start = PFN_DOWN(off);
page_end = PFN_UP(off + size);
pcpu_for_each_unpop_region(chunk->populated, rs, re,
page_start, page_end) {
WARN_ON(chunk->immutable);
ret = pcpu_populate_chunk(chunk, rs, re, 0);
spin_lock_irqsave(&pcpu_lock, flags);
if (ret) {
pcpu_free_area(chunk, off);
err = "failed to populate";
goto fail_unlock;
}
pcpu_chunk_populated(chunk, rs, re, true);
spin_unlock_irqrestore(&pcpu_lock, flags);
}
mutex_unlock(&pcpu_alloc_mutex);
}
if (pcpu_nr_empty_pop_pages < PCPU_EMPTY_POP_PAGES_LOW)
pcpu_schedule_balance_work();
/* clear the areas and return address relative to base address */
for_each_possible_cpu(cpu)
memset((void *)pcpu_chunk_addr(chunk, cpu, 0) + off, 0, size);
ptr = __addr_to_pcpu_ptr(chunk->base_addr + off);
kmemleak_alloc_percpu(ptr, size, gfp);
trace_percpu_alloc_percpu(reserved, is_atomic, size, align,
chunk->base_addr, off, ptr);
return ptr;
fail_unlock:
spin_unlock_irqrestore(&pcpu_lock, flags);
fail:
trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
if (!is_atomic && do_warn && warn_limit) {
pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
size, align, is_atomic, err);
dump_stack();
if (!--warn_limit)
pr_info("limit reached, disable warning\n");
}
if (is_atomic) {
/* see the flag handling in pcpu_blance_workfn() */
pcpu_atomic_alloc_failed = true;
pcpu_schedule_balance_work();
} else {
mutex_unlock(&pcpu_alloc_mutex);
}
return NULL;
}
/**
* __alloc_percpu_gfp - allocate dynamic percpu area
* @size: size of area to allocate in bytes
* @align: alignment of area (max PAGE_SIZE)
* @gfp: allocation flags
*
* Allocate zero-filled percpu area of @size bytes aligned at @align. If
* @gfp doesn't contain %GFP_KERNEL, the allocation doesn't block and can
* be called from any context but is a lot more likely to fail. If @gfp
* has __GFP_NOWARN then no warning will be triggered on invalid or failed
* allocation requests.
*
* RETURNS:
* Percpu pointer to the allocated area on success, NULL on failure.
*/
void __percpu *__alloc_percpu_gfp(size_t size, size_t align, gfp_t gfp)
{
return pcpu_alloc(size, align, false, gfp);
}
EXPORT_SYMBOL_GPL(__alloc_percpu_gfp);
/**
* __alloc_percpu - allocate dynamic percpu area
* @size: size of area to allocate in bytes
* @align: alignment of area (max PAGE_SIZE)
*
* Equivalent to __alloc_percpu_gfp(size, align, %GFP_KERNEL).
*/
void __percpu *__alloc_percpu(size_t size, size_t align)
{
return pcpu_alloc(size, align, false, GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(__alloc_percpu);
/**
* __alloc_reserved_percpu - allocate reserved percpu area
* @size: size of area to allocate in bytes
* @align: alignment of area (max PAGE_SIZE)
*
* Allocate zero-filled percpu area of @size bytes aligned at @align
* from reserved percpu area if arch has set it up; otherwise,
* allocation is served from the same dynamic area. Might sleep.
* Might trigger writeouts.
*
* CONTEXT:
* Does GFP_KERNEL allocation.
*
* RETURNS:
* Percpu pointer to the allocated area on success, NULL on failure.
*/
void __percpu *__alloc_reserved_percpu(size_t size, size_t align)
{
return pcpu_alloc(size, align, true, GFP_KERNEL);
}
/**
* pcpu_balance_workfn - manage the amount of free chunks and populated pages
* @work: unused
*
* Reclaim all fully free chunks except for the first one. This is also
* responsible for maintaining the pool of empty populated pages. However,
* it is possible that this is called when physical memory is scarce causing
* OOM killer to be triggered. We should avoid doing so until an actual
* allocation causes the failure as it is possible that requests can be
* serviced from already backed regions.
*/
static void pcpu_balance_workfn(struct work_struct *work)
{
/* gfp flags passed to underlying allocators */
const gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN;
LIST_HEAD(to_free);
struct list_head *free_head = &pcpu_slot[pcpu_nr_slots - 1];
struct pcpu_chunk *chunk, *next;
int slot, nr_to_pop, ret;
/*
* There's no reason to keep around multiple unused chunks and VM
* areas can be scarce. Destroy all free chunks except for one.
*/
mutex_lock(&pcpu_alloc_mutex);
spin_lock_irq(&pcpu_lock);
list_for_each_entry_safe(chunk, next, free_head, list) {
WARN_ON(chunk->immutable);
/* spare the first one */
if (chunk == list_first_entry(free_head, struct pcpu_chunk, list))
continue;
list_move(&chunk->list, &to_free);
}
spin_unlock_irq(&pcpu_lock);
list_for_each_entry_safe(chunk, next, &to_free, list) {
int rs, re;
pcpu_for_each_pop_region(chunk->populated, rs, re, 0,
chunk->nr_pages) {
pcpu_depopulate_chunk(chunk, rs, re);
spin_lock_irq(&pcpu_lock);
pcpu_chunk_depopulated(chunk, rs, re);
spin_unlock_irq(&pcpu_lock);
}
pcpu_destroy_chunk(chunk);
}
/*
* Ensure there are certain number of free populated pages for
* atomic allocs. Fill up from the most packed so that atomic
* allocs don't increase fragmentation. If atomic allocation
* failed previously, always populate the maximum amount. This
* should prevent atomic allocs larger than PAGE_SIZE from keeping
* failing indefinitely; however, large atomic allocs are not
* something we support properly and can be highly unreliable and
* inefficient.
*/
retry_pop:
if (pcpu_atomic_alloc_failed) {
nr_to_pop = PCPU_EMPTY_POP_PAGES_HIGH;
/* best effort anyway, don't worry about synchronization */
pcpu_atomic_alloc_failed = false;
} else {
nr_to_pop = clamp(PCPU_EMPTY_POP_PAGES_HIGH -
pcpu_nr_empty_pop_pages,
0, PCPU_EMPTY_POP_PAGES_HIGH);
}
for (slot = pcpu_size_to_slot(PAGE_SIZE); slot < pcpu_nr_slots; slot++) {
int nr_unpop = 0, rs, re;
if (!nr_to_pop)
break;
spin_lock_irq(&pcpu_lock);
list_for_each_entry(chunk, &pcpu_slot[slot], list) {
nr_unpop = chunk->nr_pages - chunk->nr_populated;
if (nr_unpop)
break;
}
spin_unlock_irq(&pcpu_lock);
if (!nr_unpop)
continue;
/* @chunk can't go away while pcpu_alloc_mutex is held */
pcpu_for_each_unpop_region(chunk->populated, rs, re, 0,
chunk->nr_pages) {
int nr = min(re - rs, nr_to_pop);
ret = pcpu_populate_chunk(chunk, rs, rs + nr, gfp);
if (!ret) {
nr_to_pop -= nr;
spin_lock_irq(&pcpu_lock);
pcpu_chunk_populated(chunk, rs, rs + nr, false);
spin_unlock_irq(&pcpu_lock);
} else {
nr_to_pop = 0;
}
if (!nr_to_pop)
break;
}
}
if (nr_to_pop) {
/* ran out of chunks to populate, create a new one and retry */
chunk = pcpu_create_chunk(gfp);
if (chunk) {
spin_lock_irq(&pcpu_lock);
pcpu_chunk_relocate(chunk, -1);
spin_unlock_irq(&pcpu_lock);
goto retry_pop;
}
}
mutex_unlock(&pcpu_alloc_mutex);
}
/**
* free_percpu - free percpu area
* @ptr: pointer to area to free
*
* Free percpu area @ptr.
*
* CONTEXT:
* Can be called from atomic context.
*/
void free_percpu(void __percpu *ptr)
{
void *addr;
struct pcpu_chunk *chunk;
unsigned long flags;
int off;
if (!ptr)
return;
kmemleak_free_percpu(ptr);
addr = __pcpu_ptr_to_addr(ptr);
spin_lock_irqsave(&pcpu_lock, flags);
chunk = pcpu_chunk_addr_search(addr);
off = addr - chunk->base_addr;
pcpu_free_area(chunk, off);
/* if there are more than one fully free chunks, wake up grim reaper */
if (chunk->free_bytes == pcpu_unit_size) {
struct pcpu_chunk *pos;
list_for_each_entry(pos, &pcpu_slot[pcpu_nr_slots - 1], list)
if (pos != chunk) {
pcpu_schedule_balance_work();
break;
}
}
trace_percpu_free_percpu(chunk->base_addr, off, ptr);
spin_unlock_irqrestore(&pcpu_lock, flags);
}
EXPORT_SYMBOL_GPL(free_percpu);
bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr)
{
#ifdef CONFIG_SMP
const size_t static_size = __per_cpu_end - __per_cpu_start;
void __percpu *base = __addr_to_pcpu_ptr(pcpu_base_addr);
unsigned int cpu;
for_each_possible_cpu(cpu) {
void *start = per_cpu_ptr(base, cpu);
void *va = (void *)addr;
if (va >= start && va < start + static_size) {
if (can_addr) {
*can_addr = (unsigned long) (va - start);
*can_addr += (unsigned long)
per_cpu_ptr(base, get_boot_cpu_id());
}
return true;
}
}
#endif
/* on UP, can't distinguish from other static vars, always false */
return false;
}
/**
* is_kernel_percpu_address - test whether address is from static percpu area
* @addr: address to test
*
* Test whether @addr belongs to in-kernel static percpu area. Module
* static percpu areas are not considered. For those, use
* is_module_percpu_address().
*
* RETURNS:
* %true if @addr is from in-kernel static percpu area, %false otherwise.
*/
bool is_kernel_percpu_address(unsigned long addr)
{
return __is_kernel_percpu_address(addr, NULL);
}
/**
* per_cpu_ptr_to_phys - convert translated percpu address to physical address
* @addr: the address to be converted to physical address
*
* Given @addr which is dereferenceable address obtained via one of
* percpu access macros, this function translates it into its physical
* address. The caller is responsible for ensuring @addr stays valid
* until this function finishes.
*
* percpu allocator has special setup for the first chunk, which currently
* supports either embedding in linear address space or vmalloc mapping,
* and, from the second one, the backing allocator (currently either vm or
* km) provides translation.
*
* The addr can be translated simply without checking if it falls into the
* first chunk. But the current code reflects better how percpu allocator
* actually works, and the verification can discover both bugs in percpu
* allocator itself and per_cpu_ptr_to_phys() callers. So we keep current
* code.
*
* RETURNS:
* The physical address for @addr.
*/
phys_addr_t per_cpu_ptr_to_phys(void *addr)
{
void __percpu *base = __addr_to_pcpu_ptr(pcpu_base_addr);
bool in_first_chunk = false;
unsigned long first_low, first_high;
unsigned int cpu;
/*
* The following test on unit_low/high isn't strictly
* necessary but will speed up lookups of addresses which
* aren't in the first chunk.
*
* The address check is against full chunk sizes. pcpu_base_addr
* points to the beginning of the first chunk including the
* static region. Assumes good intent as the first chunk may
* not be full (ie. < pcpu_unit_pages in size).
*/
first_low = (unsigned long)pcpu_base_addr +
pcpu_unit_page_offset(pcpu_low_unit_cpu, 0);
first_high = (unsigned long)pcpu_base_addr +
pcpu_unit_page_offset(pcpu_high_unit_cpu, pcpu_unit_pages);
if ((unsigned long)addr >= first_low &&
(unsigned long)addr < first_high) {
for_each_possible_cpu(cpu) {
void *start = per_cpu_ptr(base, cpu);
if (addr >= start && addr < start + pcpu_unit_size) {
in_first_chunk = true;
break;
}
}
}
if (in_first_chunk) {
if (!is_vmalloc_addr(addr))
return __pa(addr);
else
return page_to_phys(vmalloc_to_page(addr)) +
offset_in_page(addr);
} else
return page_to_phys(pcpu_addr_to_page(addr)) +
offset_in_page(addr);
}
/**
* pcpu_alloc_alloc_info - allocate percpu allocation info
* @nr_groups: the number of groups
* @nr_units: the number of units
*
* Allocate ai which is large enough for @nr_groups groups containing
* @nr_units units. The returned ai's groups[0].cpu_map points to the
* cpu_map array which is long enough for @nr_units and filled with
* NR_CPUS. It's the caller's responsibility to initialize cpu_map
* pointer of other groups.
*
* RETURNS:
* Pointer to the allocated pcpu_alloc_info on success, NULL on
* failure.
*/
struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
int nr_units)
{
struct pcpu_alloc_info *ai;
size_t base_size, ai_size;
void *ptr;
int unit;
base_size = ALIGN(sizeof(*ai) + nr_groups * sizeof(ai->groups[0]),
__alignof__(ai->groups[0].cpu_map[0]));
ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]);
ptr = memblock_virt_alloc_nopanic(PFN_ALIGN(ai_size), 0);
if (!ptr)
return NULL;
ai = ptr;
ptr += base_size;
ai->groups[0].cpu_map = ptr;
for (unit = 0; unit < nr_units; unit++)
ai->groups[0].cpu_map[unit] = NR_CPUS;
ai->nr_groups = nr_groups;
ai->__ai_size = PFN_ALIGN(ai_size);
return ai;
}
/**
* pcpu_free_alloc_info - free percpu allocation info
* @ai: pcpu_alloc_info to free
*
* Free @ai which was allocated by pcpu_alloc_alloc_info().
*/
void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai)
{
memblock_free_early(__pa(ai), ai->__ai_size);
}
/**
* pcpu_dump_alloc_info - print out information about pcpu_alloc_info
* @lvl: loglevel
* @ai: allocation info to dump
*
* Print out information about @ai using loglevel @lvl.
*/
static void pcpu_dump_alloc_info(const char *lvl,
const struct pcpu_alloc_info *ai)
{
int group_width = 1, cpu_width = 1, width;
char empty_str[] = "--------";
int alloc = 0, alloc_end = 0;
int group, v;
int upa, apl; /* units per alloc, allocs per line */
v = ai->nr_groups;
while (v /= 10)
group_width++;
v = num_possible_cpus();
while (v /= 10)
cpu_width++;
empty_str[min_t(int, cpu_width, sizeof(empty_str) - 1)] = '\0';
upa = ai->alloc_size / ai->unit_size;
width = upa * (cpu_width + 1) + group_width + 3;
apl = rounddown_pow_of_two(max(60 / width, 1));
printk("%spcpu-alloc: s%zu r%zu d%zu u%zu alloc=%zu*%zu",
lvl, ai->static_size, ai->reserved_size, ai->dyn_size,
ai->unit_size, ai->alloc_size / ai->atom_size, ai->atom_size);
for (group = 0; group < ai->nr_groups; group++) {
const struct pcpu_group_info *gi = &ai->groups[group];
int unit = 0, unit_end = 0;
BUG_ON(gi->nr_units % upa);
for (alloc_end += gi->nr_units / upa;
alloc < alloc_end; alloc++) {
if (!(alloc % apl)) {
pr_cont("\n");
printk("%spcpu-alloc: ", lvl);
}
pr_cont("[%0*d] ", group_width, group);
for (unit_end += upa; unit < unit_end; unit++)
if (gi->cpu_map[unit] != NR_CPUS)
pr_cont("%0*d ",
cpu_width, gi->cpu_map[unit]);
else
pr_cont("%s ", empty_str);
}
}
pr_cont("\n");
}
/**
* pcpu_setup_first_chunk - initialize the first percpu chunk
* @ai: pcpu_alloc_info describing how to percpu area is shaped
* @base_addr: mapped address
*
* Initialize the first percpu chunk which contains the kernel static
* perpcu area. This function is to be called from arch percpu area
* setup path.
*
* @ai contains all information necessary to initialize the first
* chunk and prime the dynamic percpu allocator.
*
* @ai->static_size is the size of static percpu area.
*
* @ai->reserved_size, if non-zero, specifies the amount of bytes to
* reserve after the static area in the first chunk. This reserves
* the first chunk such that it's available only through reserved
* percpu allocation. This is primarily used to serve module percpu
* static areas on architectures where the addressing model has
* limited offset range for symbol relocations to guarantee module
* percpu symbols fall inside the relocatable range.
*
* @ai->dyn_size determines the number of bytes available for dynamic
* allocation in the first chunk. The area between @ai->static_size +
* @ai->reserved_size + @ai->dyn_size and @ai->unit_size is unused.
*
* @ai->unit_size specifies unit size and must be aligned to PAGE_SIZE
* and equal to or larger than @ai->static_size + @ai->reserved_size +
* @ai->dyn_size.
*
* @ai->atom_size is the allocation atom size and used as alignment
* for vm areas.
*
* @ai->alloc_size is the allocation size and always multiple of
* @ai->atom_size. This is larger than @ai->atom_size if
* @ai->unit_size is larger than @ai->atom_size.
*
* @ai->nr_groups and @ai->groups describe virtual memory layout of
* percpu areas. Units which should be colocated are put into the
* same group. Dynamic VM areas will be allocated according to these
* groupings. If @ai->nr_groups is zero, a single group containing
* all units is assumed.
*
* The caller should have mapped the first chunk at @base_addr and
* copied static data to each unit.
*
* The first chunk will always contain a static and a dynamic region.
* However, the static region is not managed by any chunk. If the first
* chunk also contains a reserved region, it is served by two chunks -
* one for the reserved region and one for the dynamic region. They
* share the same vm, but use offset regions in the area allocation map.
* The chunk serving the dynamic region is circulated in the chunk slots
* and available for dynamic allocation like any other chunk.
*
* RETURNS:
* 0 on success, -errno on failure.
*/
int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
void *base_addr)
{
size_t size_sum = ai->static_size + ai->reserved_size + ai->dyn_size;
size_t static_size, dyn_size;
struct pcpu_chunk *chunk;
unsigned long *group_offsets;
size_t *group_sizes;
unsigned long *unit_off;
unsigned int cpu;
int *unit_map;
int group, unit, i;
int map_size;
unsigned long tmp_addr;
#define PCPU_SETUP_BUG_ON(cond) do { \
if (unlikely(cond)) { \
pr_emerg("failed to initialize, %s\n", #cond); \
pr_emerg("cpu_possible_mask=%*pb\n", \
cpumask_pr_args(cpu_possible_mask)); \
pcpu_dump_alloc_info(KERN_EMERG, ai); \
BUG(); \
} \
} while (0)
/* sanity checks */
PCPU_SETUP_BUG_ON(ai->nr_groups <= 0);
#ifdef CONFIG_SMP
PCPU_SETUP_BUG_ON(!ai->static_size);
PCPU_SETUP_BUG_ON(offset_in_page(__per_cpu_start));
#endif
PCPU_SETUP_BUG_ON(!base_addr);
PCPU_SETUP_BUG_ON(offset_in_page(base_addr));
PCPU_SETUP_BUG_ON(ai->unit_size < size_sum);
PCPU_SETUP_BUG_ON(offset_in_page(ai->unit_size));
PCPU_SETUP_BUG_ON(ai->unit_size < PCPU_MIN_UNIT_SIZE);
PCPU_SETUP_BUG_ON(!IS_ALIGNED(ai->unit_size, PCPU_BITMAP_BLOCK_SIZE));
PCPU_SETUP_BUG_ON(ai->dyn_size < PERCPU_DYNAMIC_EARLY_SIZE);
PCPU_SETUP_BUG_ON(!ai->dyn_size);
PCPU_SETUP_BUG_ON(!IS_ALIGNED(ai->reserved_size, PCPU_MIN_ALLOC_SIZE));
PCPU_SETUP_BUG_ON(!(IS_ALIGNED(PCPU_BITMAP_BLOCK_SIZE, PAGE_SIZE) ||
IS_ALIGNED(PAGE_SIZE, PCPU_BITMAP_BLOCK_SIZE)));
PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0);
/* process group information and build config tables accordingly */
group_offsets = memblock_virt_alloc(ai->nr_groups *
sizeof(group_offsets[0]), 0);
group_sizes = memblock_virt_alloc(ai->nr_groups *
sizeof(group_sizes[0]), 0);
unit_map = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_map[0]), 0);
unit_off = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_off[0]), 0);
for (cpu = 0; cpu < nr_cpu_ids; cpu++)
unit_map[cpu] = UINT_MAX;
pcpu_low_unit_cpu = NR_CPUS;
pcpu_high_unit_cpu = NR_CPUS;
for (group = 0, unit = 0; group < ai->nr_groups; group++, unit += i) {
const struct pcpu_group_info *gi = &ai->groups[group];
group_offsets[group] = gi->base_offset;
group_sizes[group] = gi->nr_units * ai->unit_size;
for (i = 0; i < gi->nr_units; i++) {
cpu = gi->cpu_map[i];
if (cpu == NR_CPUS)
continue;
PCPU_SETUP_BUG_ON(cpu >= nr_cpu_ids);
PCPU_SETUP_BUG_ON(!cpu_possible(cpu));
PCPU_SETUP_BUG_ON(unit_map[cpu] != UINT_MAX);
unit_map[cpu] = unit + i;
unit_off[cpu] = gi->base_offset + i * ai->unit_size;
/* determine low/high unit_cpu */
if (pcpu_low_unit_cpu == NR_CPUS ||
unit_off[cpu] < unit_off[pcpu_low_unit_cpu])
pcpu_low_unit_cpu = cpu;
if (pcpu_high_unit_cpu == NR_CPUS ||
unit_off[cpu] > unit_off[pcpu_high_unit_cpu])
pcpu_high_unit_cpu = cpu;
}
}
pcpu_nr_units = unit;
for_each_possible_cpu(cpu)
PCPU_SETUP_BUG_ON(unit_map[cpu] == UINT_MAX);
/* we're done parsing the input, undefine BUG macro and dump config */
#undef PCPU_SETUP_BUG_ON
pcpu_dump_alloc_info(KERN_DEBUG, ai);
pcpu_nr_groups = ai->nr_groups;
pcpu_group_offsets = group_offsets;
pcpu_group_sizes = group_sizes;
pcpu_unit_map = unit_map;
pcpu_unit_offsets = unit_off;
/* determine basic parameters */
pcpu_unit_pages = ai->unit_size >> PAGE_SHIFT;
pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT;
pcpu_atom_size = ai->atom_size;
pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) +
BITS_TO_LONGS(pcpu_unit_pages) * sizeof(unsigned long);
pcpu_stats_save_ai(ai);
/*
* Allocate chunk slots. The additional last slot is for
* empty chunks.
*/
pcpu_nr_slots = __pcpu_size_to_slot(pcpu_unit_size) + 2;
pcpu_slot = memblock_virt_alloc(
pcpu_nr_slots * sizeof(pcpu_slot[0]), 0);
for (i = 0; i < pcpu_nr_slots; i++)
INIT_LIST_HEAD(&pcpu_slot[i]);
/*
* The end of the static region needs to be aligned with the
* minimum allocation size as this offsets the reserved and
* dynamic region. The first chunk ends page aligned by
* expanding the dynamic region, therefore the dynamic region
* can be shrunk to compensate while still staying above the
* configured sizes.
*/
static_size = ALIGN(ai->static_size, PCPU_MIN_ALLOC_SIZE);
dyn_size = ai->dyn_size - (static_size - ai->static_size);
/*
* Initialize first chunk.
* If the reserved_size is non-zero, this initializes the reserved
* chunk. If the reserved_size is zero, the reserved chunk is NULL
* and the dynamic region is initialized here. The first chunk,
* pcpu_first_chunk, will always point to the chunk that serves
* the dynamic region.
*/
tmp_addr = (unsigned long)base_addr + static_size;
map_size = ai->reserved_size ?: dyn_size;
chunk = pcpu_alloc_first_chunk(tmp_addr, map_size);
/* init dynamic chunk if necessary */
if (ai->reserved_size) {
pcpu_reserved_chunk = chunk;
tmp_addr = (unsigned long)base_addr + static_size +
ai->reserved_size;
map_size = dyn_size;
chunk = pcpu_alloc_first_chunk(tmp_addr, map_size);
}
/* link the first chunk in */
pcpu_first_chunk = chunk;
pcpu_nr_empty_pop_pages = pcpu_first_chunk->nr_empty_pop_pages;
pcpu_chunk_relocate(pcpu_first_chunk, -1);
pcpu_stats_chunk_alloc();
trace_percpu_create_chunk(base_addr);
/* we're done */
pcpu_base_addr = base_addr;
return 0;
}
#ifdef CONFIG_SMP
const char * const pcpu_fc_names[PCPU_FC_NR] __initconst = {
[PCPU_FC_AUTO] = "auto",
[PCPU_FC_EMBED] = "embed",
[PCPU_FC_PAGE] = "page",
};
enum pcpu_fc pcpu_chosen_fc __initdata = PCPU_FC_AUTO;
static int __init percpu_alloc_setup(char *str)
{
if (!str)
return -EINVAL;
if (0)
/* nada */;
#ifdef CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK
else if (!strcmp(str, "embed"))
pcpu_chosen_fc = PCPU_FC_EMBED;
#endif
#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
else if (!strcmp(str, "page"))
pcpu_chosen_fc = PCPU_FC_PAGE;
#endif
else
pr_warn("unknown allocator %s specified\n", str);
return 0;
}
early_param("percpu_alloc", percpu_alloc_setup);
/*
* pcpu_embed_first_chunk() is used by the generic percpu setup.
* Build it if needed by the arch config or the generic setup is going
* to be used.
*/
#if defined(CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK) || \
!defined(CONFIG_HAVE_SETUP_PER_CPU_AREA)
#define BUILD_EMBED_FIRST_CHUNK
#endif
/* build pcpu_page_first_chunk() iff needed by the arch config */
#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
#define BUILD_PAGE_FIRST_CHUNK
#endif
/* pcpu_build_alloc_info() is used by both embed and page first chunk */
#if defined(BUILD_EMBED_FIRST_CHUNK) || defined(BUILD_PAGE_FIRST_CHUNK)
/**
* pcpu_build_alloc_info - build alloc_info considering distances between CPUs
* @reserved_size: the size of reserved percpu area in bytes
* @dyn_size: minimum free size for dynamic allocation in bytes
* @atom_size: allocation atom size
* @cpu_distance_fn: callback to determine distance between cpus, optional
*
* This function determines grouping of units, their mappings to cpus
* and other parameters considering needed percpu size, allocation
* atom size and distances between CPUs.
*
* Groups are always multiples of atom size and CPUs which are of
* LOCAL_DISTANCE both ways are grouped together and share space for
* units in the same group. The returned configuration is guaranteed
* to have CPUs on different nodes on different groups and >=75% usage
* of allocated virtual address space.
*
* RETURNS:
* On success, pointer to the new allocation_info is returned. On
* failure, ERR_PTR value is returned.
*/
static struct pcpu_alloc_info * __init pcpu_build_alloc_info(
size_t reserved_size, size_t dyn_size,
size_t atom_size,
pcpu_fc_cpu_distance_fn_t cpu_distance_fn)
{
static int group_map[NR_CPUS] __initdata;
static int group_cnt[NR_CPUS] __initdata;
const size_t static_size = __per_cpu_end - __per_cpu_start;
int nr_groups = 1, nr_units = 0;
size_t size_sum, min_unit_size, alloc_size;
int upa, max_upa, uninitialized_var(best_upa); /* units_per_alloc */
int last_allocs, group, unit;
unsigned int cpu, tcpu;
struct pcpu_alloc_info *ai;
unsigned int *cpu_map;
/* this function may be called multiple times */
memset(group_map, 0, sizeof(group_map));
memset(group_cnt, 0, sizeof(group_cnt));
/* calculate size_sum and ensure dyn_size is enough for early alloc */
size_sum = PFN_ALIGN(static_size + reserved_size +
max_t(size_t, dyn_size, PERCPU_DYNAMIC_EARLY_SIZE));
dyn_size = size_sum - static_size - reserved_size;
/*
* Determine min_unit_size, alloc_size and max_upa such that
* alloc_size is multiple of atom_size and is the smallest
* which can accommodate 4k aligned segments which are equal to
* or larger than min_unit_size.
*/
min_unit_size = max_t(size_t, size_sum, PCPU_MIN_UNIT_SIZE);
/* determine the maximum # of units that can fit in an allocation */
alloc_size = roundup(min_unit_size, atom_size);
upa = alloc_size / min_unit_size;
while (alloc_size % upa || (offset_in_page(alloc_size / upa)))
upa--;
max_upa = upa;
/* group cpus according to their proximity */
for_each_possible_cpu(cpu) {
group = 0;
next_group:
for_each_possible_cpu(tcpu) {
if (cpu == tcpu)
break;
if (group_map[tcpu] == group && cpu_distance_fn &&
(cpu_distance_fn(cpu, tcpu) > LOCAL_DISTANCE ||
cpu_distance_fn(tcpu, cpu) > LOCAL_DISTANCE)) {
group++;
nr_groups = max(nr_groups, group + 1);
goto next_group;
}
}
group_map[cpu] = group;
group_cnt[group]++;
}
/*
* Wasted space is caused by a ratio imbalance of upa to group_cnt.
* Expand the unit_size until we use >= 75% of the units allocated.
* Related to atom_size, which could be much larger than the unit_size.
*/
last_allocs = INT_MAX;
for (upa = max_upa; upa; upa--) {
int allocs = 0, wasted = 0;
if (alloc_size % upa || (offset_in_page(alloc_size / upa)))
continue;
for (group = 0; group < nr_groups; group++) {
int this_allocs = DIV_ROUND_UP(group_cnt[group], upa);
allocs += this_allocs;
wasted += this_allocs * upa - group_cnt[group];
}
/*
* Don't accept if wastage is over 1/3. The
* greater-than comparison ensures upa==1 always
* passes the following check.
*/
if (wasted > num_possible_cpus() / 3)
continue;
/* and then don't consume more memory */
if (allocs > last_allocs)
break;
last_allocs = allocs;
best_upa = upa;
}
upa = best_upa;
/* allocate and fill alloc_info */
for (group = 0; group < nr_groups; group++)
nr_units += roundup(group_cnt[group], upa);
ai = pcpu_alloc_alloc_info(nr_groups, nr_units);
if (!ai)
return ERR_PTR(-ENOMEM);
cpu_map = ai->groups[0].cpu_map;
for (group = 0; group < nr_groups; group++) {
ai->groups[group].cpu_map = cpu_map;
cpu_map += roundup(group_cnt[group], upa);
}
ai->static_size = static_size;
ai->reserved_size = reserved_size;
ai->dyn_size = dyn_size;
ai->unit_size = alloc_size / upa;
ai->atom_size = atom_size;
ai->alloc_size = alloc_size;
for (group = 0, unit = 0; group_cnt[group]; group++) {
struct pcpu_group_info *gi = &ai->groups[group];
/*
* Initialize base_offset as if all groups are located
* back-to-back. The caller should update this to
* reflect actual allocation.
*/
gi->base_offset = unit * ai->unit_size;
for_each_possible_cpu(cpu)
if (group_map[cpu] == group)
gi->cpu_map[gi->nr_units++] = cpu;
gi->nr_units = roundup(gi->nr_units, upa);
unit += gi->nr_units;
}
BUG_ON(unit != nr_units);
return ai;
}
#endif /* BUILD_EMBED_FIRST_CHUNK || BUILD_PAGE_FIRST_CHUNK */
#if defined(BUILD_EMBED_FIRST_CHUNK)
/**
* pcpu_embed_first_chunk - embed the first percpu chunk into bootmem
* @reserved_size: the size of reserved percpu area in bytes
* @dyn_size: minimum free size for dynamic allocation in bytes
* @atom_size: allocation atom size
* @cpu_distance_fn: callback to determine distance between cpus, optional
* @alloc_fn: function to allocate percpu page
* @free_fn: function to free percpu page
*
* This is a helper to ease setting up embedded first percpu chunk and
* can be called where pcpu_setup_first_chunk() is expected.
*
* If this function is used to setup the first chunk, it is allocated
* by calling @alloc_fn and used as-is without being mapped into
* vmalloc area. Allocations are always whole multiples of @atom_size
* aligned to @atom_size.
*
* This enables the first chunk to piggy back on the linear physical
* mapping which often uses larger page size. Please note that this
* can result in very sparse cpu->unit mapping on NUMA machines thus
* requiring large vmalloc address space. Don't use this allocator if
* vmalloc space is not orders of magnitude larger than distances
* between node memory addresses (ie. 32bit NUMA machines).
*
* @dyn_size specifies the minimum dynamic area size.
*
* If the needed size is smaller than the minimum or specified unit
* size, the leftover is returned using @free_fn.
*
* RETURNS:
* 0 on success, -errno on failure.
*/
int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
size_t atom_size,
pcpu_fc_cpu_distance_fn_t cpu_distance_fn,
pcpu_fc_alloc_fn_t alloc_fn,
pcpu_fc_free_fn_t free_fn)
{
void *base = (void *)ULONG_MAX;
void **areas = NULL;
struct pcpu_alloc_info *ai;
size_t size_sum, areas_size;
unsigned long max_distance;
int group, i, highest_group, rc;
ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size,
cpu_distance_fn);
if (IS_ERR(ai))
return PTR_ERR(ai);
size_sum = ai->static_size + ai->reserved_size + ai->dyn_size;
areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *));
areas = memblock_virt_alloc_nopanic(areas_size, 0);
if (!areas) {
rc = -ENOMEM;
goto out_free;
}
/* allocate, copy and determine base address & max_distance */
highest_group = 0;
for (group = 0; group < ai->nr_groups; group++) {
struct pcpu_group_info *gi = &ai->groups[group];
unsigned int cpu = NR_CPUS;
void *ptr;
for (i = 0; i < gi->nr_units && cpu == NR_CPUS; i++)
cpu = gi->cpu_map[i];
BUG_ON(cpu == NR_CPUS);
/* allocate space for the whole group */
ptr = alloc_fn(cpu, gi->nr_units * ai->unit_size, atom_size);
if (!ptr) {
rc = -ENOMEM;
goto out_free_areas;
}
/* kmemleak tracks the percpu allocations separately */
kmemleak_free(ptr);
areas[group] = ptr;
base = min(ptr, base);
if (ptr > areas[highest_group])
highest_group = group;
}
max_distance = areas[highest_group] - base;
max_distance += ai->unit_size * ai->groups[highest_group].nr_units;
/* warn if maximum distance is further than 75% of vmalloc space */
if (max_distance > VMALLOC_TOTAL * 3 / 4) {
pr_warn("max_distance=0x%lx too large for vmalloc space 0x%lx\n",
max_distance, VMALLOC_TOTAL);
#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
/* and fail if we have fallback */
rc = -EINVAL;
goto out_free_areas;
#endif
}
/*
* Copy data and free unused parts. This should happen after all
* allocations are complete; otherwise, we may end up with
* overlapping groups.
*/
for (group = 0; group < ai->nr_groups; group++) {
struct pcpu_group_info *gi = &ai->groups[group];
void *ptr = areas[group];
for (i = 0; i < gi->nr_units; i++, ptr += ai->unit_size) {
if (gi->cpu_map[i] == NR_CPUS) {
/* unused unit, free whole */
free_fn(ptr, ai->unit_size);
continue;
}
/* copy and return the unused part */
memcpy(ptr, __per_cpu_load, ai->static_size);
free_fn(ptr + size_sum, ai->unit_size - size_sum);
}
}
/* base address is now known, determine group base offsets */
for (group = 0; group < ai->nr_groups; group++) {
ai->groups[group].base_offset = areas[group] - base;
}
pr_info("Embedded %zu pages/cpu @%p s%zu r%zu d%zu u%zu\n",
PFN_DOWN(size_sum), base, ai->static_size, ai->reserved_size,
ai->dyn_size, ai->unit_size);
rc = pcpu_setup_first_chunk(ai, base);
goto out_free;
out_free_areas:
for (group = 0; group < ai->nr_groups; group++)
if (areas[group])
free_fn(areas[group],
ai->groups[group].nr_units * ai->unit_size);
out_free:
pcpu_free_alloc_info(ai);
if (areas)
memblock_free_early(__pa(areas), areas_size);
return rc;
}
#endif /* BUILD_EMBED_FIRST_CHUNK */
#ifdef BUILD_PAGE_FIRST_CHUNK
/**
* pcpu_page_first_chunk - map the first chunk using PAGE_SIZE pages
* @reserved_size: the size of reserved percpu area in bytes
* @alloc_fn: function to allocate percpu page, always called with PAGE_SIZE
* @free_fn: function to free percpu page, always called with PAGE_SIZE
* @populate_pte_fn: function to populate pte
*
* This is a helper to ease setting up page-remapped first percpu
* chunk and can be called where pcpu_setup_first_chunk() is expected.
*
* This is the basic allocator. Static percpu area is allocated
* page-by-page into vmalloc area.
*
* RETURNS:
* 0 on success, -errno on failure.
*/
int __init pcpu_page_first_chunk(size_t reserved_size,
pcpu_fc_alloc_fn_t alloc_fn,
pcpu_fc_free_fn_t free_fn,
pcpu_fc_populate_pte_fn_t populate_pte_fn)
{
static struct vm_struct vm;
struct pcpu_alloc_info *ai;
char psize_str[16];
int unit_pages;
size_t pages_size;
struct page **pages;
int unit, i, j, rc;
int upa;
int nr_g0_units;
snprintf(psize_str, sizeof(psize_str), "%luK", PAGE_SIZE >> 10);
ai = pcpu_build_alloc_info(reserved_size, 0, PAGE_SIZE, NULL);
if (IS_ERR(ai))
return PTR_ERR(ai);
BUG_ON(ai->nr_groups != 1);
upa = ai->alloc_size/ai->unit_size;
nr_g0_units = roundup(num_possible_cpus(), upa);
if (unlikely(WARN_ON(ai->groups[0].nr_units != nr_g0_units))) {
pcpu_free_alloc_info(ai);
return -EINVAL;
}
unit_pages = ai->unit_size >> PAGE_SHIFT;
/* unaligned allocations can't be freed, round up to page size */
pages_size = PFN_ALIGN(unit_pages * num_possible_cpus() *
sizeof(pages[0]));
pages = memblock_virt_alloc(pages_size, 0);
/* allocate pages */
j = 0;
for (unit = 0; unit < num_possible_cpus(); unit++) {
unsigned int cpu = ai->groups[0].cpu_map[unit];
for (i = 0; i < unit_pages; i++) {
void *ptr;
ptr = alloc_fn(cpu, PAGE_SIZE, PAGE_SIZE);
if (!ptr) {
pr_warn("failed to allocate %s page for cpu%u\n",
psize_str, cpu);
goto enomem;
}
/* kmemleak tracks the percpu allocations separately */
kmemleak_free(ptr);
pages[j++] = virt_to_page(ptr);
}
}
/* allocate vm area, map the pages and copy static data */
vm.flags = VM_ALLOC;
vm.size = num_possible_cpus() * ai->unit_size;
vm_area_register_early(&vm, PAGE_SIZE);
for (unit = 0; unit < num_possible_cpus(); unit++) {
unsigned long unit_addr =
(unsigned long)vm.addr + unit * ai->unit_size;
for (i = 0; i < unit_pages; i++)
populate_pte_fn(unit_addr + (i << PAGE_SHIFT));
/* pte already populated, the following shouldn't fail */
rc = __pcpu_map_pages(unit_addr, &pages[unit * unit_pages],
unit_pages);
if (rc < 0)
panic("failed to map percpu area, err=%d\n", rc);
/*
* FIXME: Archs with virtual cache should flush local
* cache for the linear mapping here - something
* equivalent to flush_cache_vmap() on the local cpu.
* flush_cache_vmap() can't be used as most supporting
* data structures are not set up yet.
*/
/* copy static data */
memcpy((void *)unit_addr, __per_cpu_load, ai->static_size);
}
/* we're ready, commit */
pr_info("%d %s pages/cpu @%p s%zu r%zu d%zu\n",
unit_pages, psize_str, vm.addr, ai->static_size,
ai->reserved_size, ai->dyn_size);
rc = pcpu_setup_first_chunk(ai, vm.addr);
goto out_free_ar;
enomem:
while (--j >= 0)
free_fn(page_address(pages[j]), PAGE_SIZE);
rc = -ENOMEM;
out_free_ar:
memblock_free_early(__pa(pages), pages_size);
pcpu_free_alloc_info(ai);
return rc;
}
#endif /* BUILD_PAGE_FIRST_CHUNK */
#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
/*
* Generic SMP percpu area setup.
*
* The embedding helper is used because its behavior closely resembles
* the original non-dynamic generic percpu area setup. This is
* important because many archs have addressing restrictions and might
* fail if the percpu area is located far away from the previous
* location. As an added bonus, in non-NUMA cases, embedding is
* generally a good idea TLB-wise because percpu area can piggy back
* on the physical linear memory mapping which uses large page
* mappings on applicable archs.
*/
unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
EXPORT_SYMBOL(__per_cpu_offset);
static void * __init pcpu_dfl_fc_alloc(unsigned int cpu, size_t size,
size_t align)
{
return memblock_virt_alloc_from_nopanic(
size, align, __pa(MAX_DMA_ADDRESS));
}
static void __init pcpu_dfl_fc_free(void *ptr, size_t size)
{
memblock_free_early(__pa(ptr), size);
}
void __init setup_per_cpu_areas(void)
{
unsigned long delta;
unsigned int cpu;
int rc;
/*
* Always reserve area for module percpu variables. That's
* what the legacy allocator did.
*/
rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
PERCPU_DYNAMIC_RESERVE, PAGE_SIZE, NULL,
pcpu_dfl_fc_alloc, pcpu_dfl_fc_free);
if (rc < 0)
panic("Failed to initialize percpu areas.");
delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
for_each_possible_cpu(cpu)
__per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu];
}
#endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */
#else /* CONFIG_SMP */
/*
* UP percpu area setup.
*
* UP always uses km-based percpu allocator with identity mapping.
* Static percpu variables are indistinguishable from the usual static
* variables and don't require any special preparation.
*/
void __init setup_per_cpu_areas(void)
{
const size_t unit_size =
roundup_pow_of_two(max_t(size_t, PCPU_MIN_UNIT_SIZE,
PERCPU_DYNAMIC_RESERVE));
struct pcpu_alloc_info *ai;
void *fc;
ai = pcpu_alloc_alloc_info(1, 1);
fc = memblock_virt_alloc_from_nopanic(unit_size,
PAGE_SIZE,
__pa(MAX_DMA_ADDRESS));
if (!ai || !fc)
panic("Failed to allocate memory for percpu areas.");
/* kmemleak tracks the percpu allocations separately */
kmemleak_free(fc);
ai->dyn_size = unit_size;
ai->unit_size = unit_size;
ai->atom_size = unit_size;
ai->alloc_size = unit_size;
ai->groups[0].nr_units = 1;
ai->groups[0].cpu_map[0] = 0;
if (pcpu_setup_first_chunk(ai, fc) < 0)
panic("Failed to initialize percpu areas.");
}
#endif /* CONFIG_SMP */
/*
* Percpu allocator is initialized early during boot when neither slab or
* workqueue is available. Plug async management until everything is up
* and running.
*/
static int __init percpu_enable_async(void)
{
pcpu_async_enabled = true;
return 0;
}
subsys_initcall(percpu_enable_async);
| 30.957091 | 83 | 0.717251 |
d057a419df8f16a69e34776a6c0fac1f79b1f47d | 585 | h | C | JieBanApp/src/Chat/Chat/Chat/Views/RXChatMemberView.h | splsylp/RXDemo | 3f9bb3c1a8f1380e96cf46d93900ecb6e7b2a34a | [
"MIT"
] | null | null | null | JieBanApp/src/Chat/Chat/Chat/Views/RXChatMemberView.h | splsylp/RXDemo | 3f9bb3c1a8f1380e96cf46d93900ecb6e7b2a34a | [
"MIT"
] | null | null | null | JieBanApp/src/Chat/Chat/Chat/Views/RXChatMemberView.h | splsylp/RXDemo | 3f9bb3c1a8f1380e96cf46d93900ecb6e7b2a34a | [
"MIT"
] | 1 | 2020-12-04T13:15:10.000Z | 2020-12-04T13:15:10.000Z | //
// RXChatMemberView.h
// ECSDKDemo_OC
//
// Created by ronglianmac1 on 15/10/27.
// Copyright © 2015年 ronglian. All rights reserved.
//
#import <UIKit/UIKit.h>
@class RXChatMemberView;
@protocol RXChatMemberViewDelegate <NSObject>
- (void)RXChatMemberView:(RXChatMemberView*)memberView index:(NSInteger)index;
@end
@interface RXChatMemberView : UIView
@property (weak,nonatomic) id<RXChatMemberViewDelegate>delegate;
@property(nonatomic,strong)UIImageView *headerIconView;
@property(nonatomic,strong)UILabel *nameLabel;
@property(nonatomic,strong)UIButton *deleteBtn;
@end
| 24.375 | 78 | 0.784615 |
a9610c2d2ea921d8fba027887693d1d987200036 | 6,462 | h | C | pcie_cdev_dbg.h | cocktail828/pcie_balong5000 | 878c8c9e22f9e63ca9eea5d9beeab06d93fd6a1c | [
"MIT"
] | null | null | null | pcie_cdev_dbg.h | cocktail828/pcie_balong5000 | 878c8c9e22f9e63ca9eea5d9beeab06d93fd6a1c | [
"MIT"
] | null | null | null | pcie_cdev_dbg.h | cocktail828/pcie_balong5000 | 878c8c9e22f9e63ca9eea5d9beeab06d93fd6a1c | [
"MIT"
] | 1 | 2021-09-23T07:06:48.000Z | 2021-09-23T07:06:48.000Z | /*
* Copyright (C) Huawei Technologies Co., Ltd. 2012-2015. All rights reserved.
* foss@huawei.com
*
* If distributed as part of the Linux kernel, the following license terms
* apply:
*
* * This program is free software; you can redistribute it and/or modify
* * it under the terms of the GNU General Public License version 2 and
* * only 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
*
* Otherwise, the following license terms apply:
*
* * 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 Huawei nor the names of its contributors may
* * be used to endorse or promote products derived from this software
* * without specific prior written permission.
*
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __PCIE_CDEV_DBG_H__
#define __PCIE_CDEV_DBG_H__
#include <linux/kernel.h>
#include "bsp_print.h"
#include "bsp_slice.h"
#include "pcie_cdev.h"
#include "osl_types.h"
#define THIS_MODU mod_pcdev
extern struct pcdev_ctx g_pcdev_ctx;
/* pcdev msg level */
#define PCDEV_LEVEL_ERR BIT(0)
#define PCDEV_LEVEL_WARN BIT(1)
#define PCDEV_LEVEL_TRACE BIT(2)
#define PCDEV_LEVEL_INFO BIT(3)
#define PCDEV_LEVEL_DBG BIT(4)
#define PCDEV_SHOW(level, fmt, ...) \
do \
{ \
if (g_pcdev_ctx.msg_level & PCDEV_LEVEL_ERR) \
printk(KERN_ERR "[%d] %s: " fmt, __LINE__, __func__, ##__VA_ARGS__); \
else if (g_pcdev_ctx.msg_level & PCDEV_LEVEL_WARN) \
printk(KERN_WARNING "[%d] %s: " fmt, __LINE__, __func__, ##__VA_ARGS__); \
else if (g_pcdev_ctx.msg_level & PCDEV_LEVEL_TRACE) \
printk(KERN_NOTICE "[%d] %s: " fmt, __LINE__, __func__, ##__VA_ARGS__); \
else if (g_pcdev_ctx.msg_level & PCDEV_LEVEL_INFO) \
printk(KERN_INFO "[%d] %s: " fmt, __LINE__, __func__, ##__VA_ARGS__); \
else if (g_pcdev_ctx.msg_level & PCDEV_LEVEL_DBG) \
printk(KERN_DEBUG "[%d] %s: " fmt, __LINE__, __func__, ##__VA_ARGS__); \
} while (0)
#define PCDEV_ERR(fmt, ...) PCDEV_SHOW(PCDEV_LEVEL_ERR, fmt, ##__VA_ARGS__)
#define PCDEV_WARN(fmt, ...) PCDEV_SHOW(PCDEV_LEVEL_WARN, fmt, ##__VA_ARGS__)
#define PCDEV_TRACE(fmt, ...) PCDEV_SHOW(PCDEV_LEVEL_TRACE, fmt, ##__VA_ARGS__)
#define PCDEV_INFO(fmt, ...) PCDEV_SHOW(PCDEV_LEVEL_INFO, fmt, ##__VA_ARGS__)
#define PCDEV_LINE PCDEV_TRACE("PCDEV_LINE\n")
#define print_pkt(_pnum, _buf, _len) \
do \
{ \
int j, count; \
static char buf[512]; \
count = _len > 64 ? 64 : _len; \
snprintf(buf, sizeof(buf), "buf addr: 0x%lx, len: %d, port %d\n", (uintptr_t)_buf, (int)_len, _pnum); \
\
for (j = 0; j < count; j += 16) \
snprintf(buf + strlen(buf), sizeof(buf), "%03x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", \
j, _buf[j], _buf[j + 1], _buf[j + 2], _buf[j + 3], _buf[j + 4], _buf[j + 5], _buf[j + 6], \
_buf[j + 7], _buf[j + 8], _buf[j + 9], _buf[j + 0xa], _buf[j + 0xb], _buf[j + 0xc], \
_buf[j + 0xd], _buf[j + 0xe], _buf[j + 0xf]); \
PCDEV_TRACE("%s", buf); \
} while (0)
#endif
| 60.392523 | 145 | 0.508976 |
6547b85341f8db1b76b0095c25af8a2c568b9f5b | 429 | h | C | YTTitleBarDemo/Content/View/YTHealthHeadListCell.h | JHB-Client/YTTitleBarDemo | aef76787457ff9d2129286481ac0efd440ce4685 | [
"Apache-2.0"
] | null | null | null | YTTitleBarDemo/Content/View/YTHealthHeadListCell.h | JHB-Client/YTTitleBarDemo | aef76787457ff9d2129286481ac0efd440ce4685 | [
"Apache-2.0"
] | null | null | null | YTTitleBarDemo/Content/View/YTHealthHeadListCell.h | JHB-Client/YTTitleBarDemo | aef76787457ff9d2129286481ac0efd440ce4685 | [
"Apache-2.0"
] | null | null | null | //
// YTHealthHeadListCell.h
// YTTitleBarDemo
//
// Created by admin on 2019/10/28.
// Copyright © 2019 admin. All rights reserved.
//
#import <UIKit/UIKit.h>
@class YTHealthHead;
NS_ASSUME_NONNULL_BEGIN
@interface YTHealthHeadListCell : UITableViewCell
@property (nonatomic, strong) YTHealthHead *healthHead;
+ (instancetype)cellWithTableView:(UITableView *)tableView;
- (void)setShadeShadow;
@end
NS_ASSUME_NONNULL_END
| 21.45 | 59 | 0.771562 |
45e847e51faacf8681b4c2db1cb5c774c32239d5 | 1,457 | h | C | System/Library/PrivateFrameworks/Celestial.framework/BWFigCameraSourceNode.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | 4 | 2017-03-23T00:01:54.000Z | 2018-08-04T20:16:32.000Z | System/Library/PrivateFrameworks/Celestial.framework/BWFigCameraSourceNode.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/Celestial.framework/BWFigCameraSourceNode.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | 4 | 2017-05-14T16:23:26.000Z | 2019-12-21T15:07:59.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Wednesday, March 22, 2017 at 9:02:57 AM Mountain Standard Time
* Operating System: Version 10.1 (Build 14U593)
* Image Source: /System/Library/PrivateFrameworks/Celestial.framework/Celestial
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@class BWFigVideoCaptureDevice, BWFigVideoCaptureStream, BWNodeOutput, NSDictionary;
@protocol BWFigCameraSourceNode <NSObject>
@property (readonly) BWFigVideoCaptureDevice * captureDevice;
@property (readonly) BWFigVideoCaptureStream * captureStream;
@property (readonly) BWNodeOutput * videoCaptureOutput;
@property (readonly) BWNodeOutput * stillImageOutput;
@property (readonly) BWNodeOutput * detectedFacesOutput;
@property (nonatomic,copy) NSDictionary * videoCaptureOutputColorInfoOverride;
@property (assign,nonatomic) BOOL videoCaptureOutputPixelBufferAttachmentModificationAllowed;
@required
-(BWNodeOutput *)videoCaptureOutput;
-(BWNodeOutput *)stillImageOutput;
-(BWFigVideoCaptureStream *)captureStream;
-(void)willStop;
-(BWNodeOutput *)detectedFacesOutput;
-(id)colorInfoForOutput:(id)arg1;
-(void)setVideoCaptureOutputPixelBufferAttachmentModificationAllowed:(BOOL)arg1;
-(void)setVideoCaptureOutputColorInfoOverride:(id)arg1;
-(NSDictionary *)videoCaptureOutputColorInfoOverride;
-(BOOL)videoCaptureOutputPixelBufferAttachmentModificationAllowed;
-(BWFigVideoCaptureDevice *)captureDevice;
@end
| 41.628571 | 94 | 0.825669 |
e70f5dd00672b81352fc3bc0c8cdc76796edf0ca | 1,589 | c | C | Python/getcwd.c | Northfear/Python-2.7.3-vita | 51c43989936bb0202cd1eab0a42afa2cd6bb4566 | [
"PSF-2.0"
] | 1 | 2020-10-30T09:20:56.000Z | 2020-10-30T09:20:56.000Z | Python/getcwd.c | Northfear/Python-2.7.3-vita | 51c43989936bb0202cd1eab0a42afa2cd6bb4566 | [
"PSF-2.0"
] | 1 | 2020-11-04T21:09:47.000Z | 2020-11-06T13:25:54.000Z | Python/getcwd.c | Northfear/Python-2.7.3-vita | 51c43989936bb0202cd1eab0a42afa2cd6bb4566 | [
"PSF-2.0"
] | null | null | null |
/* Two PD getcwd() implementations.
Author: Guido van Rossum, CWI Amsterdam, Jan 1991, <guido@cwi.nl>. */
#include <stdio.h>
#include <errno.h>
#ifdef HAVE_GETWD
/* Version for BSD systems -- use getwd() */
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifndef MAXPATHLEN
#if defined(PATH_MAX) && PATH_MAX > 1024
#define MAXPATHLEN PATH_MAX
#else
#define MAXPATHLEN 1024
#endif
#endif
extern char *getwd(char *);
char *
getcwd(char *buf, int size)
{
char localbuf[MAXPATHLEN+1];
char *ret;
if (size <= 0) {
errno = EINVAL;
return NULL;
}
ret = getwd(localbuf);
if (ret != NULL && strlen(localbuf) >= (size_t)size) {
errno = ERANGE;
return NULL;
}
if (ret == NULL) {
errno = EACCES; /* Most likely error */
return NULL;
}
strncpy(buf, localbuf, size);
return buf;
}
#else /* !HAVE_GETWD */
/* Version for really old UNIX systems -- use pipe from pwd */
#ifndef PWD_CMD
#define PWD_CMD "/bin/pwd"
#endif
char *
getcwd(char *buf, int size)
{
#if defined(VITA)
return NULL;
#else
FILE *fp;
char *p;
if (size <= 0) {
errno = EINVAL;
return NULL;
}
if ((fp = popen(PWD_CMD, "r")) == NULL)
return NULL;
if (fgets(buf, size, fp) == NULL || pclose(fp) != 0) {
errno = EACCES; /* Most likely error */
return NULL;
}
for (p = buf; *p != '\n'; p++) {
if (*p == '\0') {
errno = ERANGE;
return NULL;
}
}
*p = '\0';
return buf;
#endif
}
#endif /* !HAVE_GETWD */
| 18.264368 | 72 | 0.555695 |
3145428846ab3833023b9225baa96f7cda1c4a27 | 17,649 | h | C | Sources/Elastos/LibCore/inc/elastosx/security/auth/CSubject.h | suchto/ElastosRT | 8a542a1d70aebee3dbc31341b7e36d8526258849 | [
"Apache-2.0"
] | 4 | 2017-03-17T07:22:01.000Z | 2021-07-22T13:23:41.000Z | Sources/Elastos/LibCore/inc/elastosx/security/auth/CSubject.h | suchto/ElastosRT | 8a542a1d70aebee3dbc31341b7e36d8526258849 | [
"Apache-2.0"
] | null | null | null | Sources/Elastos/LibCore/inc/elastosx/security/auth/CSubject.h | suchto/ElastosRT | 8a542a1d70aebee3dbc31341b7e36d8526258849 | [
"Apache-2.0"
] | 2 | 2018-03-16T09:20:04.000Z | 2021-07-22T13:23:45.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.
//=========================================================================
#ifndef __ELASTOSX_SECURITY_AUTH_CSUBJECT_H__
#define __ELASTOSX_SECURITY_AUTH_CSUBJECT_H__
#include "Elastos.CoreLibrary.Security.h"
#include "_Elastosx_Security_Auth_CSubject.h"
#include "AbstractSet.h"
#if 0 // TODO: Waiting for AccessControlContext
#include "CAccessControlContext.h"
#endif
using Elastos::IO::IObjectInputStream;
using Elastos::IO::IObjectOutputStream;
using Elastos::Security::EIID_IPrivilegedAction;
using Elastos::Security::IAccessControlContext;
using Elastos::Security::IDomainCombiner;
using Elastos::Security::IPermission;
using Elastos::Security::IPrivilegedAction;
using Elastos::Security::IPrivilegedExceptionAction;
#if 0 // TODO: Waiting for AccessControlContext
using Elastos::Security::CAccessControlContext;
#endif
using Elastos::Utility::ICollection;
using Elastos::Utility::IIterator;
using Elastos::Utility::ILinkedList;
using Elastos::Utility::ISet;
using Elastos::Utility::AbstractSet;
using Elastosx::Security::Auth::ISubjectDomainCombiner;
using Elastos::Core::Object;
namespace Elastosx {
namespace Security {
namespace Auth {
CarClass(CSubject)
, public Object
, public ISubject
{
public:
CAR_OBJECT_DECL()
CAR_INTERFACE_DECL()
/**
* Runs the code defined by {@code action} using the permissions granted to
* the {@code Subject} itself and to the code as well.
*
* @param subject
* the distinguished {@code Subject}.
* @param action
* the code to be run.
* @return the {@code Object} returned when running the {@code action}.
*/
// @SuppressWarnings("unchecked")
static CARAPI DoAs(
/* [in] */ ISubject *subject,
/* [in] */ IPrivilegedAction *action,
/* [out] */ IInterface **obj);
/**
* Run the code defined by {@code action} using the permissions granted to
* the {@code Subject} and to the code itself, additionally providing a more
* specific context.
*
* @param subject
* the distinguished {@code Subject}.
* @param action
* the code to be run.
* @param context
* the specific context in which the {@code action} is invoked.
* if {@code null} a new {@link AccessControlContext} is
* instantiated.
* @return the {@code Object} returned when running the {@code action}.
*/
// @SuppressWarnings("unchecked")
static CARAPI DoAsPrivileged(
/* [in] */ ISubject *subject,
/* [in] */ IPrivilegedAction *action,
/* [in] */ IAccessControlContext *context,
/* [out] */ IInterface **obj);
/**
* Runs the code defined by {@code action} using the permissions granted to
* the subject and to the code itself.
*
* @param subject
* the distinguished {@code Subject}.
* @param action
* the code to be run.
* @return the {@code Object} returned when running the {@code action}.
* @throws PrivilegedActionException
* if running the {@code action} throws an exception.
*/
// @SuppressWarnings("unchecked")
static CARAPI DoAs(
/* [in] */ ISubject *subject,
/* [in] */ IPrivilegedExceptionAction *action,
/* [out] */ IInterface **obj);
/**
* Runs the code defined by {@code action} using the permissions granted to
* the subject and to the code itself, additionally providing a more
* specific context.
*
* @param subject
* the distinguished {@code Subject}.
* @param action
* the code to be run.
* @param context
* the specific context in which the {@code action} is invoked.
* if {@code null} a new {@link AccessControlContext} is
* instantiated.
* @return the {@code Object} returned when running the {@code action}.
* @throws PrivilegedActionException
* if running the {@code action} throws an exception.
*/
// @SuppressWarnings("unchecked")
static CARAPI DoAsPrivileged(
/* [in] */ ISubject *subject,
/* [in] */ IPrivilegedExceptionAction *action,
/* [in] */ IAccessControlContext *context,
/* [out] */ IInterface **obj);
/**
* Returns the {@code Subject} that was last associated with the {@code
* context} provided as argument.
*
* @param context
* the {@code context} that was associated with the
* {@code Subject}.
* @return the {@code Subject} that was last associated with the {@code
* context} provided as argument.
*/
static CARAPI GetSubject(
/* [in] */ IAccessControlContext *context,
/* [out] */ ISubject **subject);
/**
* Checks two Subjects for equality. More specifically if the principals,
* public and private credentials are equal, equality for two {@code
* Subjects} is implied.
*
* @param obj
* the {@code Object} checked for equality with this {@code
* Subject}.
* @return {@code true} if the specified {@code Subject} is equal to this
* one.
*/
// @Override
CARAPI Equals(
/* [in] */ IInterface *obj,
/* [out] */ Boolean *isEqual);
/**
* Returns this {@code Subject}'s {@link Principal}.
*
* @return this {@code Subject}'s {@link Principal}.
*/
CARAPI GetPrincipals(
/* [out] */ ISet **principals);
/**
* Returns this {@code Subject}'s {@link Principal} which is a subclass of
* the {@code Class} provided.
*
* @param c
* the {@code Class} as a criteria which the {@code Principal}
* returned must satisfy.
* @return this {@code Subject}'s {@link Principal}. Modifications to the
* returned set of {@code Principal}s do not affect this {@code
* Subject}'s set.
*/
CARAPI GetPrincipals(
/* [in] */ IInterface *pC,
/* [out] */ ISet **principals);
/**
* Returns the private credentials associated with this {@code Subject}.
*
* @return the private credentials associated with this {@code Subject}.
*/
CARAPI GetPrivateCredentials(
/* [out] */ ISet **credentials);
/**
* Returns this {@code Subject}'s private credentials which are a subclass
* of the {@code Class} provided.
*
* @param c
* the {@code Class} as a criteria which the private credentials
* returned must satisfy.
* @return this {@code Subject}'s private credentials. Modifications to the
* returned set of credentials do not affect this {@code Subject}'s
* credentials.
*/
CARAPI GetPrivateCredentials(
/* [in] */ const ClassID& id,
/* [out] */ ISet **credentials);
/**
* Returns the public credentials associated with this {@code Subject}.
*
* @return the public credentials associated with this {@code Subject}.
*/
CARAPI GetPublicCredentials(
/* [out] */ ISet **credentials);
/**
* Returns this {@code Subject}'s public credentials which are a subclass of
* the {@code Class} provided.
*
* @param c
* the {@code Class} as a criteria which the public credentials
* returned must satisfy.
* @return this {@code Subject}'s public credentials. Modifications to the
* returned set of credentials do not affect this {@code Subject}'s
* credentials.
*/
CARAPI GetPublicCredentials(
/* [in] */ const ClassID& id,
/* [out] */ ISet **credentials);
/**
* Returns a hash code of this {@code Subject}.
*
* @return a hash code of this {@code Subject}.
*/
// @Override
CARAPI GetHashCode(
/* [out] */ Int32 *hashCode);
/**
* Prevents from modifications being done to the credentials and {@link
* Principal} sets. After setting it to read-only this {@code Subject} can
* not be made writable again. The destroy method on the credentials still
* works though.
*/
CARAPI SetReadOnly();
/**
* Returns whether this {@code Subject} is read-only or not.
*
* @return whether this {@code Subject} is read-only or not.
*/
CARAPI IsReadOnly(
/* [out] */ Boolean *isReadOnly);
/**
* Returns a {@code String} representation of this {@code Subject}.
*
* @return a {@code String} representation of this {@code Subject}.
*/
// @Override
CARAPI ToString(
/* [out] */ String *str);
/**
* The default constructor initializing the sets of public and private
* credentials and principals with the empty set.
*/
CARAPI constructor();
/**
* The constructor for the subject, setting its public and private
* credentials and principals according to the arguments.
*
* @param readOnly
* {@code true} if this {@code Subject} is read-only, thus
* preventing any modifications to be done.
* @param subjPrincipals
* the set of Principals that are attributed to this {@code
* Subject}.
* @param pubCredentials
* the set of public credentials that distinguish this {@code
* Subject}.
* @param privCredentials
* the set of private credentials that distinguish this {@code
* Subject}.
*/
CARAPI constructor(
/* [in] */ Boolean readOnly,
/* [in] */ ISet *subjPrincipals,
/* [in] */ ISet *pubCredentials,
/* [in] */ ISet *privCredentials);
private:
class SecureSet
: public AbstractSet
{
public:
/*
* verifies specified element, checks set state, and security permission
* to modify set before adding new element
*/
// @Override
CARAPI Add(
/* [in] */ IInterface *o,
/* [out] */ Boolean *ret);
// returns an instance of SecureIterator
// @Override
CARAPI GetIterator(
/* [out] */ IIterator **it);
// @Override
CARAPI RetainAll(
/* [in] */ ICollection *c,
/* [out] */ Boolean *ret);
/**
* return set with elements that are instances or subclasses of the
* specified class
*/
/*
protected final <E> Set<E> get(final Class<E> c)
*/
SecureSet(
/* [in] */ IPermission *perm,
/* [in] */ Handle32 host);
SecureSet(
/* [in] */ IPermission *perm,
/* [in] */ ICollection *s,
/* [in] */ Handle32 host);
/**
* return set with elements that are instances or subclasses of the
* specified class
*/
CARAPI Get(
/* [in] */ const ClassID& id,
/* [out] */ ISet **obj);
CARAPI GetSize(
/* [out] */ Int32* size);
/**
* Represents iterator for subject's secure set
*/
class SecureIterator
: public Object
, public IIterator
{
public:
CAR_INTERFACE_DECL()
CARAPI HasNext(
/* [out] */ Boolean *hasNext);
CARAPI GetNext(
/* [out] */ IInterface **next);
/**
* checks set state, and security permission to modify set before
* removing current element
*/
Remove();
SecureIterator(
/* [in] */ IIterator *iterator,
/* [in] */ Handle32 host);
protected:
AutoPtr<IIterator> mIterator;
Handle32 mHost;
};
// verifies new set element
CARAPI VerifyElement(
/* [in] */ IInterface *o);
protected:
CARAPI_(String) GetClassName() { return String("CSubject::SecureSet"); }
private:
/**
* Compatibility issue: see comments for setType variable
*/
static const Int64 serialVersionUID;// = 7911754171111800359L;
AutoPtr<ILinkedList> mElements;
/*
* Is used to define a set type for serialization.
*
* A type can be principal, priv. or pub. credential set. The spec.
* doesn't clearly says that priv. and pub. credential sets can be
* serialized and what classes they are. It is only possible to figure
* out from writeObject method comments that priv. credential set is
* serializable and it is an instance of SecureSet class. So pub.
* credential was implemented by analogy
*
* Compatibility issue: the class follows its specified serial form.
* Also according to the serialization spec. adding new field is a
* compatible change. So is ok for principal set (because the default
* value for integer is zero). But priv. or pub. credential set it is
* not compatible because most probably other implementations resolve
* this issue in other way
*/
Int32 mSetType;
// Defines principal set for serialization.
static const Int32 SET_Principal = 0;
// Defines private credential set for serialization.
static const Int32 SET_PrivCred = 1;
// Defines public credential set for serialization.
static const Int32 SET_PubCred = 2;
// permission required to modify set
// transient
AutoPtr<IPermission> mPermission;
Handle32 mHost;
};
class PrivilegedAction
: public IPrivilegedAction
, public Object
{
public:
PrivilegedAction(
/* [in] */ IAccessControlContext *context)
: mAcc(context)
{}
PInterface Probe(
/* [in] */ REIID riid)
{
if (riid == EIID_IInterface) {
return (IInterface*)(IPrivilegedAction*)this;
}
else if (riid == EIID_IPrivilegedAction) {
return (IPrivilegedAction*)this;
}
return NULL;
}
UInt32 AddRef()
{
return ElRefBase::AddRef();
}
UInt32 Release()
{
return ElRefBase::Release();
}
ECode GetInterfaceID(
/* [in] */ IInterface* object,
/* [out] */ InterfaceID* iid)
{
VALIDATE_NOT_NULL(iid)
if (object == (IInterface*)(IPrivilegedAction*)this) {
*iid = EIID_IPrivilegedAction;
}
else {
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
return NOERROR;
}
ECode Run(
/* [out] */ IInterface **dc)
{
AutoPtr<IDomainCombiner> tmpdc;
ECode ec = mAcc->GetDomainCombiner((IDomainCombiner**)&tmpdc);
*dc = tmpdc.Get();
REFCOUNT_ADD(*dc)
return ec;
}
protected:
AutoPtr<IAccessControlContext> mAcc;
};
// instantiates a new context and passes it to AccessController
// @SuppressWarnings("unchecked")
static CARAPI DoAs_PrivilegedAction(
/* [in] */ ISubject *subject,
/* [in] */ IPrivilegedAction *action,
/* [in] */ IAccessControlContext * const context,
/* [out] */ IInterface **ret);
// instantiates a new context and passes it to AccessController
// @SuppressWarnings("unchecked")
static CARAPI DoAs_PrivilegedExceptionAction(
/* [in] */ ISubject *subject,
/* [in] */ IPrivilegedExceptionAction *action,
/* [in] */ IAccessControlContext * const context,
/* [out] */ IInterface **ret);
CARAPI ReadObject(
/* [in] */ IObjectInputStream *is);
CARAPI WriteObject(
/* [in] */ IObjectOutputStream *os);
CARAPI CheckState();
private:
static const Int64 serialVersionUID;
static const AutoPtr<IPermission> _AS;
static const AutoPtr<IPermission> _AS_PRIVILEGED;
static const AutoPtr<IPermission> _SUBJECT;
static const AutoPtr<IPermission> _PRINCIPALS;
static const AutoPtr<IPermission> _PRIVATE_CREDENTIALS;
static const AutoPtr<IPermission> _PUBLIC_CREDENTIALS;
static const AutoPtr<IPermission> _READ_ONLY;
AutoPtr<ISet> mPrincipals;
Boolean mReadOnly;
// set of private credentials
// transient
AutoPtr<SecureSet> mPrivateCredentials;
// set of public credentials
// transient
AutoPtr<SecureSet> mPublicCredentials;
};
} // namespace Auth
} // namespace Security
} // namespace Elastosx
#endif // __ELASTOSX_SECURITY_AUTH_CSUBJECT_H__
| 32.030853 | 80 | 0.581449 |
316fbad6c2f7493e6f94bc3df859e3baebd7a68b | 1,641 | c | C | src/examples/2chan.c | megoldsby/microcsp | b896f568bb78b9e1574ec41ca448c9ee2f62aa03 | [
"Apache-2.0"
] | null | null | null | src/examples/2chan.c | megoldsby/microcsp | b896f568bb78b9e1574ec41ca448c9ee2f62aa03 | [
"Apache-2.0"
] | null | null | null | src/examples/2chan.c | megoldsby/microcsp | b896f568bb78b9e1574ec41ca448c9ee2f62aa03 | [
"Apache-2.0"
] | null | null | null |
/**
* Two processes, one sending interrupts, one receiving them.
*/
#include "microcsp.h"
#include <stdio.h>
#define ONE_SEC 1000000000ULL
Channel chan[2];
PROCESS(Proc1)
Guard guards[2];
ENDPROC
void Proc1_rtc(void *local)
{
enum { CH0=0, CH1 };
Proc1 *proc1 = (Proc1 *)local;
if (initial()) {
init_alt(&proc1->guards[0], 2);
activate(&proc1->guards[0]);
activate(&proc1->guards[1]);
init_chanin_guard(&proc1->guards[0], in(&chan[0]), NULL, 0);
init_chanin_guard(&proc1->guards[1], in(&chan[1]), NULL, 0);
} else {
printf("boing!\n");
switch(selected()) {
case CH0:
printf("Proc1 receives signal on CH0\n");
break;
case CH1:
printf("Proc1 receives signal on CH1\n");
break;
}
}
}
PROCESS(Proc2)
Guard guards[2];
uint8_t which;
ENDPROC
void Proc2_rtc(void *local)
{
Proc2 *proc2 = (Proc2 *)local;
if (initial()) {
init_alt(&proc2->guards[0], 2);
init_chanout_guard(&proc2->guards[0], out(&chan[0]), NULL);
activate(&proc2->guards[0]);
init_chanout_guard(&proc2->guards[1], out(&chan[1]), NULL);
deactivate(&proc2->guards[1]);
proc2->which = 0;
} else {
deactivate(&proc2->guards[proc2->which]);
proc2->which = (proc2->which + 1) % 2;
activate(&proc2->guards[proc2->which]);
}
}
int main(int argc, char **argv)
{
initialize(32768);
Proc1 local1;
START(Proc1, &local1, 1);
Proc2 local2;
START(Proc2, &local2, 2);
run();
}
| 22.479452 | 68 | 0.549055 |
2ee1c35b17bb3c327986da9d779208ebc1d85f51 | 619 | h | C | gui-unit-testing-with-qt-test-advanced/GuiUnitTestingAdv/WidgetsLib/PanelConcat.h | emediato/BitsOfBytes | 1c9e9c5a5eff09021e990da8e776c7e9c975d901 | [
"Unlicense"
] | 115 | 2016-11-10T11:58:46.000Z | 2022-03-25T18:04:38.000Z | gui-unit-testing-with-qt-test-advanced/GuiUnitTestingAdv/WidgetsLib/PanelConcat.h | emediato/BitsOfBytes | 1c9e9c5a5eff09021e990da8e776c7e9c975d901 | [
"Unlicense"
] | 5 | 2016-11-25T12:16:19.000Z | 2020-11-15T22:15:14.000Z | gui-unit-testing-with-qt-test-advanced/GuiUnitTestingAdv/WidgetsLib/PanelConcat.h | emediato/BitsOfBytes | 1c9e9c5a5eff09021e990da8e776c7e9c975d901 | [
"Unlicense"
] | 121 | 2016-11-14T17:45:31.000Z | 2022-03-24T12:03:26.000Z | #pragma once
#include "WidgetsLibGlobal.h"
#include <QWidget>
class QLabel;
class QLineEdit;
class QPushButton;
class WIDGETSLIBSHARED_EXPORT PanelConcat : public QWidget
{
Q_OBJECT
MAKE_TESTABLE(PanelConcat);
public:
explicit PanelConcat(QWidget * parent = nullptr);
signals:
void DataAvailable(const QString & data);
void DataCleared();
public slots:
void ConcatData();
void CancelData();
private:
static const int MIN_W = 480;
static const int MIN_H = 240;
private:
QLineEdit * mInputA;
QLineEdit * mInputB;
QPushButton * mButtonConcat;
QPushButton * mButtonCancel;
QLabel * mLabelRes;
};
| 14.738095 | 58 | 0.751212 |
2c5664d5068f4737366223921b8a49f00322227d | 17,409 | h | C | pascal.h | yugyfoog/pascal | b5307907c984b18ea0402dfb23eb98b52a44300f | [
"MIT"
] | null | null | null | pascal.h | yugyfoog/pascal | b5307907c984b18ea0402dfb23eb98b52a44300f | [
"MIT"
] | null | null | null | pascal.h | yugyfoog/pascal | b5307907c984b18ea0402dfb23eb98b52a44300f | [
"MIT"
] | null | null | null | #define internal_error() x_internal_error(__FILE__,__LINE__,__FUNCTION__)
#define new(T) (T *)malloc(sizeof(T))
typedef enum {false, true} bool;
typedef enum {TO, DOWNTO} For_Mode;
typedef struct Identifier_List {
char *id;
struct Identifier_List *next;
} Identifier_List;
typedef enum {
AND_TOKEN, ARRAY_TOKEN, BEGIN_TOKEN, CASE_TOKEN, CONST_TOKEN, DIV_TOKEN,
DO_TOKEN, DOWNTO_TOKEN, ELSE_TOKEN, END_TOKEN, FILE_TOKEN, FOR_TOKEN,
FUNCTION_TOKEN, GOTO_TOKEN, IF_TOKEN, IN_TOKEN, LABEL_TOKEN, MOD_TOKEN,
NIL_TOKEN, NOT_TOKEN, OF_TOKEN, OR_TOKEN, PACKED_TOKEN,
PROCEDURE_TOKEN, PROGRAM_TOKEN, RECORD_TOKEN, REPEAT_TOKEN, SET_TOKEN,
THEN_TOKEN, TO_TOKEN, TYPE_TOKEN, UNTIL_TOKEN, VAR_TOKEN, WHILE_TOKEN,
WITH_TOKEN,
PLUS_TOKEN, MINUS_TOKEN, MULTIPLY_TOKEN, DIVIDE_TOKEN,
EQ_TOKEN, NE_TOKEN, LT_TOKEN, LE_TOKEN, GT_TOKEN, GE_TOKEN,
PERIOD_TOKEN, COMMA_TOKEN, COLON_TOKEN, SEMICOLON_TOKEN,
LPAREN_TOKEN, RPAREN_TOKEN, LBRACK_TOKEN, RBRACK_TOKEN,
ASSIGN_TOKEN, ARROW_TOKEN, ELLIPSIS_TOKEN,
IDENTIFIER_TOKEN, INTEGER_TOKEN, REAL_TOKEN, STRING_TOKEN,
END_OF_FILE_TOKEN
} Token_Type;
typedef struct Ordinal_Type {
struct Type *base;
Ordinal low;
Ordinal high;
} Ordinal_Type;
typedef struct Array_Type {
bool packed;
struct Type *component_type;
struct Type *index_type;
} Array_Type;
typedef struct File_Type {
bool packed;
struct Type *base;
} File_Type;
typedef struct Set_Type {
bool packed;
struct Type *base;
} Set_Type;
typedef struct Variant_List {
struct Constant_List *cnsts;
struct Type *fields;
struct Variant_List *next;
} Variant_List;
typedef struct Variant_Part {
struct Symbol *selector;
Variant_List *variants;
} Variant_Part;
typedef struct Record_Type {
bool packed;
struct Symbol_List *fields;
Variant_Part *variant;
} Record_Type;
typedef enum {
ORDINAL_TYPE, REAL_TYPE, NIL_TYPE, ARRAY_TYPE,
RECORD_TYPE, SET_TYPE, FILE_TYPE, POINTER_TYPE
} Type_Class;
typedef struct Type {
Type_Class class;
int size;
union {
Ordinal_Type ordinal;
Array_Type array;
File_Type file;
Set_Type set;
Record_Type record;
struct Type *pointer;
};
} Type;
typedef struct Constant {
struct Type *type;
union {
Ordinal ordinal;
Real real;
char *string;
};
} Constant;
typedef struct Constant_List {
Constant *cnst;
struct Constant_List *next;
} Constant_List;
typedef enum {
REWRITE_PROCEDURE, RESET_PROCEDURE, PUT_PROCEDURE, GET_PROCEDURE,
READ_PROCEDURE, WRITE_PROCEDURE, READLN_PROCEDURE, WRITELN_PROCEDURE,
PAGE_PROCEDURE, NEW_PROCEDURE, DISPOSE_PROCEDURE,
PACK_PROCEDURE, UNPACK_PROCEDURE,
ARGV_PROCEDURE, FLUSH_PROCEDURE, CLOSE_PROCEDURE,
EXIT_PROCEDURE
} Standard_Procedure;
typedef enum {
ABS_FUNCTION, SQR_FUNCTION, SIN_FUNCTION, COS_FUNCTION, ARCTAN_FUNCTION,
EXP_FUNCTION, LN_FUNCTION, SQRT_FUNCTION, TRUNC_FUNCTION, ROUND_FUNCTION,
ORD_FUNCTION, CHR_FUNCTION, SUCC_FUNCTION, PRED_FUNCTION, ODD_FUNCTION,
EOF_FUNCTION, EOLN_FUNCTION,
ARGC_FUNCTION,
} Standard_Function;
typedef struct Variable_Symbol {
Type *type;
int offset;
Type *parent; /* used for field symbols to
connect to the record that contains this field */
} Variable_Symbol;
typedef enum {UNKNOWN, DEFINED, EXTERNAL, FORWARD} Directive;
typedef struct Algorithm_Symbol {
char *gname;
int local_size;
int parameter_size;
Directive declared;
struct Symbol_List *parameters;
struct Symbol_List *algorithms;
struct Statement *statement;
Type *type;
struct Symbol *return_value;
} Algorithm_Symbol;
typedef struct Label_Symbol {
struct Symbol *algorithm; /* this is the program/procedure/function that the label is defined in */
int internal_label;
} Label_Symbol;
typedef enum {
PROGRAM_SYMBOL, PROCEDURE_SYMBOL, FUNCTION_SYMBOL,
CONSTANT_SYMBOL, TYPE_SYMBOL, VARIABLE_SYMBOL,
VALUE_PARAMETER, VARIABLE_PARAMETER,
FIELD_SYMBOL,
PROCEDURE_PARAMETER, FUNCTION_PARAMETER,
STANDARD_PROCEDURE, STANDARD_FUNCTION,
LABEL_SYMBOL,
} Symbol_Class;
typedef struct Symbol {
Symbol_Class class;
char *name;
int block_level;
union {
struct Constant *constant; /* CONSTANT_SYMBOL */
Type *type; /* TYPE_SYMBOL */
Variable_Symbol variable; /* VARIABLE_SYMBOL, FIELD_SYMBOL, VARIABLE_PARAMETER, VALUE_PARAMETER */
Algorithm_Symbol algorithm; /* PROGRAM_SYMBOL, PROCEDURE_SYMBOL, FUNCTION_SYMBOL */
Standard_Procedure stdproc; /* STANDARD_PROCEDURE */
Standard_Function stdfunc; /* STANDARD_FUNCTION */
Label_Symbol label; /* LABEL_SYMBOL */
};
} Symbol;
typedef struct Call_Expression { /* used in Expression and Statement */
Symbol *sym;
struct Expression_List *params;
} Call_Expression;
typedef struct Field_Expression {
struct Expression *base;
Symbol *field;
} Field_Expression;
typedef enum {
VARIABLE_EXPRESSION, CONSTANT_EXPRESSION,
ORDINAL_EQ_EXPRESSION, REAL_EQ_EXPRESSION,
STRING_EQ_EXPRESSION, SET_EQ_EXPRESSION,
POINTER_EQ_EXPRESSION,
ORDINAL_NE_EXPRESSION, REAL_NE_EXPRESSION,
STRING_NE_EXPRESSION, SET_NE_EXPRESSION,
POINTER_NE_EXPRESSION,
ORDINAL_LT_EXPRESSION, REAL_LT_EXPRESSION,
STRING_LT_EXPRESSION,
ORDINAL_LE_EXPRESSION, REAL_LE_EXPRESSION,
STRING_LE_EXPRESSION, SET_LE_EXPRESSION,
ORDINAL_GT_EXPRESSION, REAL_GT_EXPRESSION,
STRING_GT_EXPRESSION,
ORDINAL_GE_EXPRESSION, REAL_GE_EXPRESSION,
STRING_GE_EXPRESSION, SET_GE_EXPRESSION,
INTEGER_PLUS_EXPRESSION, REAL_PLUS_EXPRESSION,
INTEGER_MINUS_EXPRESSION, REAL_MINUS_EXPRESSION,
INTEGER_TO_REAL_EXPRESSION,
INTEGER_ADD_EXPRESSION, REAL_ADD_EXPRESSION,
INTEGER_SUBTRACT_EXPRESSION, REAL_SUBTRACT_EXPRESSION,
INTEGER_MULTIPLY_EXPRESSION, REAL_MULTIPLY_EXPRESSION,
INTEGER_DIVIDE_EXPRESSION, INTEGER_MODULUS_EXPRESSION,
REAL_DIVIDE_EXPRESSION,
OR_EXPRESSION, AND_EXPRESSION, NOT_EXPRESSION,
INDEX_EXPRESSION, IN_EXPRESSION,
SET_CONSTRUCTOR, SET_EXPRESSION, SET_RANGE_EXPRESSION,
SET_UNION_EXPRESSION, SET_INTERSECTION_EXPRESSION,
SET_DIFFERENCE_EXPRESSION, EMPTY_SET_EXPRESSION,
FIELD_EXPRESSION, INDIRECT_EXPRESSION, FILE_ACCESS,
INTEGER_ABS_EXPRESSION, REAL_ABS_EXPRESSION,
INTEGER_SQR_EXPRESSION, REAL_SQR_EXPRESSION,
SQRT_EXPRESSION, EXP_EXPRESSION, LN_EXPRESSION,
SIN_EXPRESSION, COS_EXPRESSION, ARCTAN_EXPRESSION,
TRUNC_EXPRESSION, ROUND_EXPRESSION,
FUNCTION_CALL, ODD_EXPRESSION, ORD_EXPRESSION, CHR_EXPRESSION,
SUCC_EXPRESSION, PRED_EXPRESSION,
EOF_EXPRESSION, EOLN_EXPRESSION,
ARGC_EXPRESSION,
PROCEDURAL_PARAMETER_EXPRESSION,
FUNCTIONAL_PARAMETER_EXPRESSION,
} Expression_Class;
typedef struct Expression {
Expression_Class class;
Type *type;
union {
Constant *constant; /* CONSTANT_EXPRESSION */
Symbol *variable; /* VARIABLE_EXPRESSION, FUNCTION_PARAMETER_EXPRESSION */
struct Expression *val; /* unary operators */
struct {
struct Expression *lval; /* binary operators */
struct Expression *rval;
};
Call_Expression call;
struct Expression_List *set;
Field_Expression field;
};
} Expression;
typedef struct Expression_List {
Expression *expr;
struct Expression_List *next;
} Expression_List;
typedef struct Symbol_List {
struct Symbol_List *next;
Symbol *symbol;
int level;
} Symbol_List;
typedef struct Assignment_Statement {
Expression *lval;
Expression *rval;
} Assignment_Statement;
typedef struct If_Statement {
Expression *test;
struct Statement *tstmt;
struct Statement *fstmt;
} If_Statement;
typedef struct Case_Statement {
Expression *index;
struct Case_Element_List *elements;
} Case_Statement;
typedef struct Case_Element_List {
int label;
Constant_List *constants;
struct Statement *statement;
struct Case_Element_List *next;
} Case_Element_List;
typedef struct While_Statement {
Expression *test;
struct Statement *body;
} While_Statement;
typedef struct Repeat_Statement {
struct Statement_Sequence *body;
Expression *test;
} Repeat_Statement;
typedef struct For_Statement {
Symbol *temp1;
Symbol *temp2;
Symbol *control_variable;
Expression *initial_value;
Expression *final_value;
struct Statement *body;
For_Mode mode;
} For_Statement;
typedef struct With_Statement {
Expression *record;
Symbol *variable;
struct Statement *body;
} With_Statement;
typedef struct Pack_Statement {
Expression *a;
Expression *i;
Expression *z;
} Pack_Statement;
typedef struct Read_Statement {
Symbol *file;
Expression *expression;
} Read_Statement;
typedef struct Write_Statement {
Symbol *file;
Expression *expression;
Expression *field_width;
Expression *fractional_digits;
} Write_Statement;
typedef struct Reset_Rewrite_Statement {
Expression *name;
Expression *file;
} Reset_Rewrite_Statement;
typedef struct Argv_Statement {
Expression *index;
Expression *arg;
} Argv_Statement;
typedef enum {
EMPTY_STATEMENT, COMPOUND_STATEMENT,
ASSIGNMENT_STATEMENT, GOTO_STATEMENT,
IF_STATEMENT, CASE_STATEMENT,
WHILE_STATEMENT, REPEAT_STATEMENT,
FOR_STATEMENT, WITH_STATEMENT, PROCEDURE_CALL,
RESET_STATEMENT, REWRITE_STATEMENT,
GET_STATEMENT, PUT_STATEMENT,
READ_STATEMENT, READ_TEXT_STATEMENT, READLN_STATEMENT,
WRITE_STATEMENT, WRITE_TEXT_STATEMENT, WRITELN_STATEMENT,
NEW_STATEMENT, DISPOSE_STATEMENT,
PAGE_STATEMENT,
PACK_STATEMENT, UNPACK_STATEMENT,
ARGV_STATEMENT, FLUSH_STATEMENT, CLOSE_STATEMENT, EXIT_STATEMENT
} Statement_Class;
typedef struct Statement {
Statement_Class class;
Symbol *label;
union {
struct Statement_Sequence *compound_statement;
Assignment_Statement assignment;
Symbol *gotostmt;
If_Statement ifstmt;
Case_Statement casestmt;
While_Statement whilestmt;
Repeat_Statement repeatstmt;
For_Statement forstmt;
With_Statement with;
Reset_Rewrite_Statement reset_rewrite;
Read_Statement read;
Write_Statement write;
Symbol *writeln;
Symbol *readln;
Call_Expression call;
Argv_Statement argv;
Pack_Statement pack; /* pack and unpack procedures */
Expression *parameter; /* used for single parameter standard procedures */
};
} Statement;
typedef struct Statement_Sequence {
Statement *statement;
struct Statement_Sequence *next;
} Statement_Sequence;
typedef struct Undefined_Pointer_List {
char *id;
Type *type;
struct Undefined_Pointer_List *next;
} Undefined_Pointer_List;
/* pascal.c */
extern char *input_name;
extern FILE *input;
extern FILE *output;
/* symbols.c */
extern Type *boolean_type;
extern Type *char_type;
extern Type *integer_type;
extern Type *real_type;
extern Type *text_type;
extern Type *empty_set_type;
extern Type *nil_type;
extern Constant *nil_constant;
void initialize_symbols(void);
void push_symbol_table(void);
void pop_symbol_table(void);
Symbol *new_symbol(char *, Symbol_Class);
Symbol *new_program_symbol(char *, Symbol_List *);
Symbol *new_procedure_symbol(char *, Symbol_List *);
Symbol *new_function_symbol(char *, Symbol_List *, Type *);
Symbol *new_parameter_symbol(char *, Symbol_Class);
Symbol *new_procedure_parameter_symbol(char *, Symbol_List *);
Symbol *new_function_parameter_symbol(char *, Symbol_List *, Type *);
Symbol *new_constant_symbol(char *, Constant *);
Symbol *new_type_symbol(char *, Type *);
Symbol *new_field_symbol(char *);
void insert_symbols(Symbol_List *);
void insert_symbol(Symbol *);
void insert_variable_symbols(Identifier_List *, Type *);
void insert_record_fields(Type *);
Symbol *lookup_symbol(char *);
Symbol *lookup_symbol_local(char *);
void install_variable_symbols(Identifier_List *, Type *);
/* source.c */
extern int line_number;
extern char *token;
extern Token_Type token_type;
bool check(Token_Type);
void need(Token_Type);
bool match(Token_Type);
void next_token(void);
/* constants.c */
Constant *constant(void);
Constant *unsigned_constant(void);
Constant_List *constant_list(void);
Constant *new_ordinal_constant(Type *, Ordinal);
Constant *new_real_constant(double);
Constant *new_string_constant(char *);
char *fix_string(char *);
/* types.c */
extern Undefined_Pointer_List *undefined_pointer_list;
Type *type_identifier(void);
Type *result_type(void);
Type *type_denoter(void);
void define_undefined_pointer(char *, Type *);
Type *new_type(Type_Class);
Type *new_ordinal_type(Type *, Ordinal, Ordinal);
Type *new_real_type(void);
Type *new_file_type(bool, Type *);
Type *new_pointer_type(Type *);
Type *new_undefined_pointer_type(char *);
Type *new_set_type(bool, Type *);
Type *new_record_type(Symbol_List *, Variant_Part *);
/* parse.c */
Symbol *parse(void);
char *identifier(void);
Identifier_List *identifier_list(void);
char *label(void);
/* statements.c */
Statement *compound_statement(Symbol *);
/* expressions.c */
Expression *expression(void);
Expression *variable_access(void);
Expression_List *actual_parameter_list(Symbol_List *);
/* semantics.c */
extern int block_level;
extern long variable_offset;
extern long parameter_offset;
extern Symbol_List *with_symbol_stack;
bool is_integer(Type *);
bool is_char(Type *);
bool is_boolean(Type *);
bool is_real(Type *);
bool is_set(Type *);
bool is_file(Type *);
bool is_string(Type *);
Symbol *new_symbol(char *, Symbol_Class);
Symbol *new_variable_symbol(char *, Type *);
Symbol *new_label_symbol(char *, Symbol *);
Type *new_subrange_type(Constant *, Constant *);
Symbol *find_with_variable(Type *);
Statement *new_statement(Statement_Class, Symbol *);
Statement *new_assignment_statement(Expression *, Expression *, Symbol *, bool);
Statement *new_procedure_call(Symbol *, Expression_List *, Symbol *);
Statement *new_reset_statement(Expression *, Expression *, Symbol *);
Statement *new_rewrite_statement(Expression *, Expression *, Symbol *);
Statement *new_get_statement(Expression *, Symbol *);
Statement *new_put_statement(Expression *, Symbol *);
Statement *new_read_statement(Symbol *, Expression *);
Statement *new_read_text_statement(Symbol *, Expression *);
Statement *new_readln_statement(Symbol *);
Statement *new_write_statement(Symbol *, Expression *);
Statement *new_write_text_statement(Symbol *, Expression *, Expression *, Expression *);
Statement *new_writeln_statement(Symbol *);
Statement *new_argv_statement(Expression *, Expression *, Symbol *);
Expression *new_expression(Expression_Class, Type *);
Expression *new_constant_expression(Constant *);
Expression *new_variable_expression(Symbol *);
Expression *new_eq_expression(Expression *, Expression *);
Expression *new_ne_expression(Expression *, Expression *);
Expression *new_lt_expression(Expression *, Expression *);
Expression *new_le_expression(Expression *, Expression *);
Expression *new_gt_expression(Expression *, Expression *);
Expression *new_ge_expression(Expression *, Expression *);
Expression *new_in_expression(Expression *, Expression *);
Expression *new_plus_expression(Expression *);
Expression *new_minus_expression(Expression *);
Expression *new_add_expression(Expression *, Expression *);
Expression *new_subtract_expression(Expression *, Expression *);
Expression *new_or_expression(Expression *, Expression *);
Expression *new_multiply_expression(Expression *, Expression *);
Expression *new_divide_expression(Expression *, Expression *);
Expression *new_div_expression(Expression *, Expression *);
Expression *new_mod_expression(Expression *, Expression *);
Expression *new_and_expression(Expression *, Expression *);
Expression *new_not_expression(Expression *);
Expression *new_index_expression(Expression *, Expression *);
Expression *new_field_designator_expression(Expression *, Symbol *);
Symbol *find_field(Type *, char *);
Expression *new_indirect_expression(Expression *);
Expression *new_abs_function(Expression *);
Expression *new_sqr_function(Expression *);
Expression *new_sqrt_function(Expression *);
Expression *new_sin_function(Expression *);
Expression *new_cos_function(Expression *);
Expression *new_arctan_function(Expression *);
Expression *new_exp_function(Expression *);
Expression *new_ln_function(Expression *);
Expression *new_trunc_function(Expression *);
Expression *new_round_function(Expression *);
Expression *new_odd_function(Expression *);
Expression *new_ord_function(Expression *);
Expression *new_succ_function(Expression *);
Expression *new_pred_function(Expression *);
Expression *new_chr_function(Expression *);
Expression *new_eof_function(Expression *);
Expression *new_eoln_function(Expression *);
Expression *new_argc_function(void);
Expression *new_function_call(Symbol *, Expression_List *);
Expression *new_empty_set(void);
Expression *new_set_constructor(Expression_List *);
Expression *new_set_expression(Expression *);
Expression *new_set_range_expression(Expression *, Expression *);
Expression *new_procedural_parameter_expression(Symbol *, Symbol *);
Expression *new_functional_parameter_expression(Symbol *, Symbol *);
Symbol *create_tempory_file_variable(void);
Symbol *create_tempory_with_variable(Type *);
void push_for_variable_stack(void);
void pop_for_variable_stack(void);
Symbol *create_for_variable(int);
long align_up(long, long);
long align_down(long, long);
/* error.c */
extern int error_count;
void syntax_error(int);
void warning(char *, ...);
void error(char *, ...);
void fatal_error(char *, ...);
void x_internal_error(char *, int, char const *);
void x_undefined(char *, int, char const *);
| 29.556876 | 111 | 0.778046 |
c8639d638e66c70e81ffb9272f22b5b3c669e3ec | 2,046 | h | C | include/tudat/astro/basic_astro/sphericalBodyShapeModel.h | kimonito98/tudat | c28f2a3e78b8492e2e054ad5e0d1f9ad785cd092 | [
"BSD-3-Clause"
] | null | null | null | include/tudat/astro/basic_astro/sphericalBodyShapeModel.h | kimonito98/tudat | c28f2a3e78b8492e2e054ad5e0d1f9ad785cd092 | [
"BSD-3-Clause"
] | null | null | null | include/tudat/astro/basic_astro/sphericalBodyShapeModel.h | kimonito98/tudat | c28f2a3e78b8492e2e054ad5e0d1f9ad785cd092 | [
"BSD-3-Clause"
] | null | null | null | #ifndef TUDAT_SPHERICALBODYSHAPEMODEL_H
#define TUDAT_SPHERICALBODYSHAPEMODEL_H
/* Copyright (c) 2010-2019, Delft University of Technology
* All rigths reserved
*
* This file is part of the Tudat. Redistribution and use in source and
* binary forms, with or without modification, are permitted exclusively
* under the terms of the Modified BSD license. You should have received
* a copy of the license with this file. If not, please or visit:
* http://tudat.tudelft.nl/LICENSE.
*
* References
* Montebruck O, Gill E. Satellite Orbits, Springer, 2000.
*
*/
#include "tudat/astro/basic_astro/bodyShapeModel.h"
namespace tudat
{
namespace basic_astrodynamics
{
//! Body shape model defined as a sphere
/*!
* Body shape model defined as a sphere, defined by only its radius.
*/
class SphericalBodyShapeModel: public BodyShapeModel
{
public:
//! Constructor.
/*!
* Constructor, defines body shape.
* \param radius Radius of sphere
*/
SphericalBodyShapeModel ( const double radius ):
radius_( radius ){ }
//! Destructor
~SphericalBodyShapeModel( ){ }
//! Calculates the altitude above the sphere
/*!
* Function to calculate the altitude above the sphere from a body fixed position.
* \param bodyFixedPosition Cartesian, body-fixed position of the point at which the altitude
* is to be determined.
* \return Altitude above the sphere.
*/
double getAltitude( const Eigen::Vector3d& bodyFixedPosition )
{
return bodyFixedPosition.norm( ) - radius_;
}
//! Function to return the mean radius of the shape model
/*!
* Function to return the mean radius of the sphere, equal to its radius.
* \return Average radius of shape model (equal to radius).
*/
double getAverageRadius( )
{
return radius_;
}
private:
//! Radius of sphere
double radius_;
};
} // namespace basic_astrodynamics
} // namespace tudat
#endif // TUDAT_SPHERICALBODYSHAPEMODEL_H
| 26.571429 | 98 | 0.684262 |
4d119269e947ad83f38aefad6ebd4dc0ae611bec | 19,633 | h | C | codecparsers/jpegparser.h | zhongcong/libyami | 0118c0c78cd5a0208da67024cb9c26b61af67851 | [
"Intel"
] | null | null | null | codecparsers/jpegparser.h | zhongcong/libyami | 0118c0c78cd5a0208da67024cb9c26b61af67851 | [
"Intel"
] | null | null | null | codecparsers/jpegparser.h | zhongcong/libyami | 0118c0c78cd5a0208da67024cb9c26b61af67851 | [
"Intel"
] | null | null | null | /*
* jpegparser.h - JPEG parser
*
* Copyright (C) 2011-2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef __JPEG_PARSER_H
#define __JPEG_PARSER_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <stdint.h>
#include "common/common_def.h"
/**
* JPEG_MAX_FRAME_COMPONENTS:
*
* Maximum number of image components in a frame (Nf).
*/
#define JPEG_MAX_FRAME_COMPONENTS 256
/**
* JPEG_MAX_SCAN_COMPONENTS:
*
* Maximum number of image components in a scan (Ns).
*/
#define JPEG_MAX_SCAN_COMPONENTS 4
/**
* JPEG_MAX_QUANT_ELEMENTS:
*
* Number of elements in the quantization table.
*/
#define JPEG_MAX_QUANT_ELEMENTS 64
typedef struct _JpegQuantTable JpegQuantTable;
typedef struct _JpegQuantTables JpegQuantTables;
typedef struct _JpegHuffmanTable JpegHuffmanTable;
typedef struct _JpegHuffmanTables JpegHuffmanTables;
typedef struct _JpegScanComponent JpegScanComponent;
typedef struct _JpegScanHdr JpegScanHdr;
typedef struct _JpegFrameComponent JpegFrameComponent;
typedef struct _JpegFrameHdr JpegFrameHdr;
typedef struct _JpegMarkerSegment JpegMarkerSegment;
/**
* JpegMarkerCode:
* @JPEG_MARKER_SOF_MIN: Start of frame min marker code
* @JPEG_MARKER_SOF_MAX: Start of frame max marker code
* @JPEG_MARKER_DHT: Huffman tabler marker code
* @JPEG_MARKER_DAC: Arithmetic coding marker code
* @JPEG_MARKER_RST_MIN: Restart interval min marker code
* @JPEG_MARKER_RST_MAX: Restart interval max marker code
* @JPEG_MARKER_SOI: Start of image marker code
* @JPEG_MARKER_EOI: End of image marker code
* @JPEG_MARKER_SOS: Start of scan marker code
* @JPEG_MARKER_DQT: Define quantization table marker code
* @JPEG_MARKER_DNL: Define number of lines marker code
* @JPEG_MARKER_DRI: Define restart interval marker code
* @JPEG_MARKER_APP_MIN: Application segment min marker code
* @JPEG_MARKER_APP_MAX: Application segment max marker code
* @JPEG_MARKER_COM: Comment marker code
*
* Indicates the type of JPEG segment.
*/
typedef enum {
JPEG_MARKER_SOF_MIN = 0xC0,
JPEG_MARKER_SOF_MAX = 0xCF,
JPEG_MARKER_DHT = 0xC4,
JPEG_MARKER_DAC = 0xCC,
JPEG_MARKER_RST_MIN = 0xD0,
JPEG_MARKER_RST_MAX = 0xD7,
JPEG_MARKER_SOI = 0xD8,
JPEG_MARKER_EOI = 0xD9,
JPEG_MARKER_SOS = 0xDA,
JPEG_MARKER_DQT = 0xDB,
JPEG_MARKER_DNL = 0xDC,
JPEG_MARKER_DRI = 0xDD,
JPEG_MARKER_APP_MIN = 0xE0,
JPEG_MARKER_APP_MAX = 0xEF,
JPEG_MARKER_COM = 0xFE,
} JpegMarkerCode;
/**
* JpegProfile:
* @JPEG_PROFILE_BASELINE: Baseline DCT
* @JPEG_PROFILE_EXTENDED: Extended sequential DCT
* @JPEG_PROFILE_PROGRESSIVE: Progressive DCT
* @JPEG_PROFILE_LOSSLESS: Lossless (sequential)
*
* JPEG encoding processes.
*/
typedef enum {
JPEG_PROFILE_BASELINE = 0x00,
JPEG_PROFILE_EXTENDED = 0x01,
JPEG_PROFILE_PROGRESSIVE = 0x02,
JPEG_PROFILE_LOSSLESS = 0x03,
} JpegProfile;
/**
* JpegEntropyCodingMode:
* @JPEG_ENTROPY_CODING_HUFFMAN: Huffman coding
* @JPEG_ENTROPY_CODING_ARITHMETIC: arithmetic coding
*
* JPEG entropy coding mode.
*/
typedef enum {
JPEG_ENTROPY_CODING_HUFFMAN = 0x00,
JPEG_ENTROPY_CODING_ARITHMETIC = 0x08
} JpegEntropyCodingMode;
/**
* JpegQuantTable:
* @quant_precision: Quantization table element precision (Pq)
* @quant_table: Quantization table elements (Qk)
* @valid: If the quantization table is valid, which means it has
* already been parsed
*
* Quantization table.
*/
struct _JpegQuantTable
{
uint8_t quant_precision;
uint16_t quant_table[JPEG_MAX_QUANT_ELEMENTS];
BOOL valid;
};
/**
* JpegQuantTables:
* @quant_tables: All quantization tables
*
* Helper data structure that holds all quantization tables used to
* decode an image.
*/
struct _JpegQuantTables
{
JpegQuantTable quant_tables[JPEG_MAX_SCAN_COMPONENTS];
};
/**
* JpegHuffmanTable:
* @huf_bits: Number of Huffman codes of length i + 1 (Li)
* @huf_vales: Value associated with each Huffman code (Vij)
* @valid: If the Huffman table is valid, which means it has already
* been parsed
*
* Huffman table.
*/
struct _JpegHuffmanTable
{
uint8_t huf_bits[16];
uint8_t huf_values[256];
BOOL valid;
};
/**
* JpegHuffmanTables:
* @dc_tables: DC Huffman tables
* @ac_tables: AC Huffman tables
*
* Helper data structure that holds all AC/DC Huffman tables used to
* decode an image.
*/
struct _JpegHuffmanTables
{
JpegHuffmanTable dc_tables[JPEG_MAX_SCAN_COMPONENTS];
JpegHuffmanTable ac_tables[JPEG_MAX_SCAN_COMPONENTS];
};
/**
* JpegScanComponent:
* @component_selector: Scan component selector (Csj)
* @dc_selector: DC entropy coding table destination selector (Tdj)
* @ac_selector: AC entropy coding table destination selector (Taj)
* Component-specification parameters.
*/
struct _JpegScanComponent
{
uint8_t component_selector; /* 0 .. 255 */
uint8_t dc_selector; /* 0 .. 3 */
uint8_t ac_selector; /* 0 .. 3 */
};
/**
* JpegScanHdr:
* @num_components: Number of image components in scan (Ns)
* @components: Image components
*
* Scan header.
*/
struct _JpegScanHdr
{
uint8_t num_components; /* 1 .. 4 */
JpegScanComponent components[JPEG_MAX_SCAN_COMPONENTS];
};
/**
* JpegFrameComponent:
* @identifier: Component identifier (Ci)
* @horizontal_factor: Horizontal sampling factor (Hi)
* @vertical_factor: Vertical sampling factor (Vi)
* @quant_table_selector: Quantization table destination selector (Tqi)
*
* Component-specification parameters.
*/
struct _JpegFrameComponent
{
uint8_t identifier; /* 0 .. 255 */
uint8_t horizontal_factor; /* 1 .. 4 */
uint8_t vertical_factor; /* 1 .. 4 */
uint8_t quant_table_selector; /* 0 .. 3 */
};
/**
* JpegFrameHdr:
* @sample_precision: Sample precision (P)
* @height: Number of lines (Y)
* @width: Number of samples per line (X)
* @num_components: Number of image components in frame (Nf)
* @components: Image components
* @restart_interval: Number of MCU in the restart interval (Ri)
*
* Frame header.
*/
struct _JpegFrameHdr
{
uint8_t sample_precision; /* 2 .. 16 */
uint16_t width; /* 1 .. 65535 */
uint16_t height; /* 0 .. 65535 */
uint8_t num_components; /* 1 .. 255 */
JpegFrameComponent components[JPEG_MAX_FRAME_COMPONENTS];
};
/**
* JpegMarkerSegment:
* @type: The type of the segment that starts at @offset
* @offset: The offset to the segment start in bytes. This is the
* exact start of the segment, no marker code included
* @size: The size in bytes of the segment, or -1 if the end was not
* found. It is the exact size of the segment, no marker code included
*
* A structure that contains the type of a segment, its offset and its size.
*/
struct _JpegMarkerSegment
{
uint8_t marker;
uint32_t offset;
int32_t size;
};
/* Table used to address an 8x8 matrix in zig-zag order */
/* *INDENT-OFF* */
static const uint8_t zigzag_index[64] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36,
29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46,
53, 60, 61, 54, 47, 55, 62, 63
};
/* *INDENT-ON* */
/* Table K.1 - Luminance quantization table */
/* *INDENT-OFF* */
static const uint8_t default_luminance_quant_table[64] = {
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
};
/* *INDENT-ON* */
/* Table K.2 - Chrominance quantization table */
/* *INDENT-OFF* */
static const uint8_t default_chrominance_quant_table[64] = {
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
/* *INDENT-ON* */
typedef struct _JpegHuffmanTableEntry JpegHuffmanTableEntry;
struct _JpegHuffmanTableEntry
{
uint8_t value; /* category */
uint8_t length; /* code length in bits */
};
/* Table K.3 - Table for luminance DC coefficient differences */
static const JpegHuffmanTableEntry default_luminance_dc_table[] = {
{0x00, 2}, {0x01, 3}, {0x02, 3}, {0x03, 3}, {0x04, 3}, {0x05, 3},
{0x06, 4}, {0x07, 5}, {0x08, 6}, {0x09, 7}, {0x0a, 8}, {0x0b, 9}
};
/* Table K.4 - Table for chrominance DC coefficient differences */
static const JpegHuffmanTableEntry default_chrominance_dc_table[] = {
{0x00, 2}, {0x01, 2}, {0x02, 2}, {0x03, 3}, {0x04, 4}, {0x05, 5},
{0x06, 6}, {0x07, 7}, {0x08, 8}, {0x09, 9}, {0x0a, 10}, {0x0b, 11}
};
/* Table K.5 - Table for luminance AC coefficients */
/* *INDENT-OFF* */
static const JpegHuffmanTableEntry default_luminance_ac_table[] = {
{0x00, 4}, {0x01, 2}, {0x02, 2}, {0x03, 3}, {0x04, 4}, {0x05, 5},
{0x06, 7}, {0x07, 8}, {0x08, 10}, {0x09, 16}, {0x0a, 16}, {0x11, 4},
{0x12, 5}, {0x13, 7}, {0x14, 9}, {0x15, 11}, {0x16, 16}, {0x17, 16},
{0x18, 16}, {0x19, 16}, {0x1a, 16}, {0x21, 5}, {0x22, 8}, {0x23, 10},
{0x24, 12}, {0x25, 16}, {0x26, 16}, {0x27, 16}, {0x28, 16}, {0x29, 16},
{0x2a, 16}, {0x31, 6}, {0x32, 9}, {0x33, 12}, {0x34, 16}, {0x35, 16},
{0x36, 16}, {0x37, 16}, {0x38, 16}, {0x39, 16}, {0x3a, 16}, {0x41, 6},
{0x42, 10}, {0x43, 16}, {0x44, 16}, {0x45, 16}, {0x46, 16}, {0x47, 16},
{0x48, 16}, {0x49, 16}, {0x4a, 16}, {0x51, 7}, {0x52, 11}, {0x53, 16},
{0x54, 16}, {0x55, 16}, {0x56, 16}, {0x57, 16}, {0x58, 16}, {0x59, 16},
{0x5a, 16}, {0x61, 7}, {0x62, 12}, {0x63, 16}, {0x64, 16}, {0x65, 16},
{0x66, 16}, {0x67, 16}, {0x68, 16}, {0x69, 16}, {0x6a, 16}, {0x71, 8},
{0x72, 12}, {0x73, 16}, {0x74, 16}, {0x75, 16}, {0x76, 16}, {0x77, 16},
{0x78, 16}, {0x79, 16}, {0x7a, 16}, {0x81, 9}, {0x82, 15}, {0x83, 16},
{0x84, 16}, {0x85, 16}, {0x86, 16}, {0x87, 16}, {0x88, 16}, {0x89, 16},
{0x8a, 16}, {0x91, 9}, {0x92, 16}, {0x93, 16}, {0x94, 16}, {0x95, 16},
{0x96, 16}, {0x97, 16}, {0x98, 16}, {0x99, 16}, {0x9a, 16}, {0xa1, 9},
{0xa2, 16}, {0xa3, 16}, {0xa4, 16}, {0xa5, 16}, {0xa6, 16}, {0xa7, 16},
{0xa8, 16}, {0xa9, 16}, {0xaa, 16}, {0xb1, 10}, {0xb2, 16}, {0xb3, 16},
{0xb4, 16}, {0xb5, 16}, {0xb6, 16}, {0xb7, 16}, {0xb8, 16}, {0xb9, 16},
{0xba, 16}, {0xc1, 10}, {0xc2, 16}, {0xc3, 16}, {0xc4, 16}, {0xc5, 16},
{0xc6, 16}, {0xc7, 16}, {0xc8, 16}, {0xc9, 16}, {0xca, 16}, {0xd1, 11},
{0xd2, 16}, {0xd3, 16}, {0xd4, 16}, {0xd5, 16}, {0xd6, 16}, {0xd7, 16},
{0xd8, 16}, {0xd9, 16}, {0xda, 16}, {0xe1, 16}, {0xe2, 16}, {0xe3, 16},
{0xe4, 16}, {0xe5, 16}, {0xe6, 16}, {0xe7, 16}, {0xe8, 16}, {0xe9, 16},
{0xea, 16}, {0xf0, 11}, {0xf1, 16}, {0xf2, 16}, {0xf3, 16}, {0xf4, 16},
{0xf5, 16}, {0xf6, 16}, {0xf7, 16}, {0xf8, 16}, {0xf9, 16}, {0xfa, 16}
};
/* *INDENT-ON* */
/* Table K.6 - Table for chrominance AC coefficients */
/* *INDENT-OFF* */
static const JpegHuffmanTableEntry default_chrominance_ac_table[] = {
{0x00, 2}, {0x01, 2}, {0x02, 3}, {0x03, 4}, {0x04, 5}, {0x05, 5},
{0x06, 6}, {0x07, 7}, {0x08, 9}, {0x09, 10}, {0x0a, 12}, {0x11, 4},
{0x12, 6}, {0x13, 8}, {0x14, 9}, {0x15, 11}, {0x16, 12}, {0x17, 16},
{0x18, 16}, {0x19, 16}, {0x1a, 16}, {0x21, 5}, {0x22, 8}, {0x23, 10},
{0x24, 12}, {0x25, 15}, {0x26, 16}, {0x27, 16}, {0x28, 16}, {0x29, 16},
{0x2a, 16}, {0x31, 5}, {0x32, 8}, {0x33, 10}, {0x34, 12}, {0x35, 16},
{0x36, 16}, {0x37, 16}, {0x38, 16}, {0x39, 16}, {0x3a, 16}, {0x41, 6},
{0x42, 9}, {0x43, 16}, {0x44, 16}, {0x45, 16}, {0x46, 16}, {0x47, 16},
{0x48, 16}, {0x49, 16}, {0x4a, 16}, {0x51, 6}, {0x52, 10}, {0x53, 16},
{0x54, 16}, {0x55, 16}, {0x56, 16}, {0x57, 16}, {0x58, 16}, {0x59, 16},
{0x5a, 16}, {0x61, 7}, {0x62, 11}, {0x63, 16}, {0x64, 16}, {0x65, 16},
{0x66, 16}, {0x67, 16}, {0x68, 16}, {0x69, 16}, {0x6a, 16}, {0x71, 7},
{0x72, 11}, {0x73, 16}, {0x74, 16}, {0x75, 16}, {0x76, 16}, {0x77, 16},
{0x78, 16}, {0x79, 16}, {0x7a, 16}, {0x81, 8}, {0x82, 16}, {0x83, 16},
{0x84, 16}, {0x85, 16}, {0x86, 16}, {0x87, 16}, {0x88, 16}, {0x89, 16},
{0x8a, 16}, {0x91, 9}, {0x92, 16}, {0x93, 16}, {0x94, 16}, {0x95, 16},
{0x96, 16}, {0x97, 16}, {0x98, 16}, {0x99, 16}, {0x9a, 16}, {0xa1, 9},
{0xa2, 16}, {0xa3, 16}, {0xa4, 16}, {0xa5, 16}, {0xa6, 16}, {0xa7, 16},
{0xa8, 16}, {0xa9, 16}, {0xaa, 16}, {0xb1, 9}, {0xb2, 16}, {0xb3, 16},
{0xb4, 16}, {0xb5, 16}, {0xb6, 16}, {0xb7, 16}, {0xb8, 16}, {0xb9, 16},
{0xba, 16}, {0xc1, 9}, {0xc2, 16}, {0xc3, 16}, {0xc4, 16}, {0xc5, 16},
{0xc6, 16}, {0xc7, 16}, {0xc8, 16}, {0xc9, 16}, {0xca, 16}, {0xd1, 11},
{0xd2, 16}, {0xd3, 16}, {0xd4, 16}, {0xd5, 16}, {0xd6, 16}, {0xd7, 16},
{0xd8, 16}, {0xd9, 16}, {0xda, 16}, {0xe1, 14}, {0xe2, 16}, {0xe3, 16},
{0xe4, 16}, {0xe5, 16}, {0xe6, 16}, {0xe7, 16}, {0xe8, 16}, {0xe9, 16},
{0xea, 16}, {0xf0, 10}, {0xf1, 15}, {0xf2, 16}, {0xf3, 16}, {0xf4, 16},
{0xf5, 16}, {0xf6, 16}, {0xf7, 16}, {0xf8, 16}, {0xf9, 16}, {0xfa, 16}
};
/* *INDENT-ON* */
/**
* jpeg_scan_for_marker_code:
* @data: The data to parse
* @size: The size of @data
* @offset: The offset from which to start parsing
*
* Scans the JPEG bitstream contained in @data for the next marker
* code. If found, the function returns an offset to the marker code,
* including the 0xff prefix code but excluding any extra fill bytes.
*
* Returns: offset to the marker code if found, or -1 if not found.
*/
int32_t jpeg_scan_for_marker_code (const uint8_t * data,
size_t size,
uint32_t offset);
/**
* jpeg_parse:
* @data: The data to parse
* @size: The size of @data
* @offset: The offset from which to start parsing
*
* Parses the JPEG bitstream contained in @data, and returns the
* detected segment as a #JpegMarkerSegment.
*
* Returns: TRUE if a packet start code was found.
*/
BOOL jpeg_parse (JpegMarkerSegment * seg,
const uint8_t * data,
size_t size,
uint32_t offset);
/**
* jpeg_parse_frame_hdr:
* @hdr: (out): The #JpegFrameHdr structure to fill in
* @data: The data from which to parse the frame header
* @size: The size of @data
* @offset: The offset in bytes from which to start parsing @data
*
* Parses the @hdr JPEG frame header structure members from @data.
*
* Returns: TRUE if the frame header was correctly parsed.
*/
BOOL jpeg_parse_frame_hdr (JpegFrameHdr * hdr,
const uint8_t * data,
size_t size,
uint32_t offset);
/**
* jpeg_parse_scan_hdr:
* @hdr: (out): The #JpegScanHdr structure to fill in
* @data: The data from which to parse the scan header
* @size: The size of @data
* @offset: The offset in bytes from which to start parsing @data
*
* Parses the @hdr JPEG scan header structure members from @data.
*
* Returns: TRUE if the scan header was correctly parsed
*/
BOOL jpeg_parse_scan_hdr (JpegScanHdr * hdr,
const uint8_t * data,
size_t size,
uint32_t offset);
/**
* jpeg_parse_quantization_table:
* @quant_tables: (out): The #JpegQuantizationTable structure to fill in
* @num_quant_tables: The number of allocated quantization tables in @quant_tables
* @data: The data from which to parse the quantization table
* @size: The size of @data
* @offset: The offset in bytes from which to start parsing @data
*
* Parses the JPEG quantization table structure members from @data.
*
* Note: @quant_tables represents the complete set of possible
* quantization tables. However, the parser will only write to the
* quantization table specified by the table destination identifier
* (Tq). While doing so, the @valid flag of the specified quantization
* table will also be set to %TRUE.
*
* Returns: TRUE if the quantization table was correctly parsed.
*/
BOOL jpeg_parse_quant_table (JpegQuantTables *quant_tables,
const uint8_t * data,
size_t size,
uint32_t offset);
/**
* jpeg_parse_huffman_table:
* @huf_tables: (out): The #JpegHuffmanTable structure to fill in
* @data: The data from which to parse the Huffman table
* @size: The size of @data
* @offset: The offset in bytes from which to start parsing @data
*
* Parses the JPEG Huffman table structure members from @data.
*
* Note: @huf_tables represents the complete set of possible Huffman
* tables. However, the parser will only write to the Huffman table
* specified by the table destination identifier (Th). While doing so,
* the @valid flag of the specified Huffman table will also be set to
* %TRUE;
*
* Returns: TRUE if the Huffman table was correctly parsed.
*/
BOOL jpeg_parse_huffman_table (JpegHuffmanTables *huf_tables,
const uint8_t * data,
size_t size,
uint32_t offset);
/**
* jpeg_parse_restart_interval:
* @interval: (out): The parsed restart interval value
* @data: The data from which to parse the restart interval specification
* @size: The size of @data
* @offset: The offset in bytes from which to start parsing @data
*
* Returns: TRUE if the restart interval value was correctly parsed.
*/
BOOL jpeg_parse_restart_interval (uint32_t * interval,
const uint8_t * data,
size_t size,
uint32_t offset);
/**
* jpeg_get_default_huffman_tables:
* @huf_tables: (out): The default DC/AC Huffman tables to fill in
*
* Fills in @huf_tables with the default AC/DC Huffman tables, as
* specified by the JPEG standard.
*/
void jpeg_get_default_huffman_tables (JpegHuffmanTables *huf_tables);
/**
* jpeg_get_default_quantization_table:
* @quant_tables: (out): The default luma/chroma quant-tables in zigzag mode
*
* Fills in @quant_tables with the default quantization tables, as
* specified by the JPEG standard.
*/
void jpeg_get_default_quantization_tables (JpegQuantTables *quant_tables);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* JPEG_PARSER_H */
| 36.156538 | 82 | 0.623236 |
232028ba9c291584d0fa6f6fba35fa85482188a0 | 213 | h | C | RenderHardwareInterface/Math/MathUtilities.h | xRiveria/Crescent-Engine | b6512b6a8dab2d27cf542c562ccc28f21bf2345d | [
"Apache-2.0"
] | 2 | 2020-12-18T03:43:07.000Z | 2020-12-23T12:20:00.000Z | RenderHardwareInterface/Math/MathUtilities.h | xRiveria/Crescent-Engine | b6512b6a8dab2d27cf542c562ccc28f21bf2345d | [
"Apache-2.0"
] | null | null | null | RenderHardwareInterface/Math/MathUtilities.h | xRiveria/Crescent-Engine | b6512b6a8dab2d27cf542c562ccc28f21bf2345d | [
"Apache-2.0"
] | null | null | null | #pragma once
namespace Math::Utilities
{
template <typename T>
T Min(T comparison1, T comparison2)
{
if (comparison1 > comparison2) { return comparison2; } else { return comparison1; }
}
} | 21.3 | 91 | 0.652582 |
d94caa5ad615a55495392d443577296017183605 | 1,387 | h | C | usr/libexec/progressd/CLSBlob-PDSyncableItem.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 2 | 2021-11-02T09:23:27.000Z | 2022-03-28T08:21:57.000Z | usr/libexec/progressd/CLSBlob-PDSyncableItem.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | null | null | null | usr/libexec/progressd/CLSBlob-PDSyncableItem.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 1 | 2022-03-28T08:21:59.000Z | 2022-03-28T08:21:59.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 <ClassKit/CLSBlob.h>
#import "PDDatabaseEntity-Protocol.h"
#import "PDSyncableItem-Protocol.h"
@class NSObject, NSString;
@protocol PDDatabaseValue;
@interface CLSBlob (PDSyncableItem) <PDSyncableItem, PDDatabaseEntity>
+ (id)parentReferenceName; // IMP=0x000000010005b94c
+ (long long)syncableItemType; // IMP=0x000000010005b944
+ (id)recordType; // IMP=0x000000010005b690
+ (_Bool)migrateFromVersion:(unsigned long long)arg1 finalVersion:(out unsigned long long *)arg2 inDatabase:(id)arg3; // IMP=0x0000000100123420
+ (id)entityName; // IMP=0x0000000100123114
- (long long)syncOrder; // IMP=0x000000010005b93c
- (void)populate:(id)arg1; // IMP=0x000000010005b820
- (id)initWithCKRecord:(id)arg1; // IMP=0x000000010005b69c
- (void)bindTo:(id)arg1; // IMP=0x000000010012325c
- (id)initWithDatabaseRow:(id)arg1; // IMP=0x0000000100123120
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, nonatomic, getter=isDeleteTracked) _Bool deleteTracked;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly, nonatomic) NSObject<PDDatabaseValue> *identityValue;
@property(readonly) Class superclass;
@end
| 38.527778 | 143 | 0.774333 |
eaaa2edd7ea184e6621993c407c3878a288e5d79 | 1,571 | h | C | Frameworks/AssetsLibrary.framework/ALAssetRepresentationPrivate.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | Frameworks/AssetsLibrary.framework/ALAssetRepresentationPrivate.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | Frameworks/AssetsLibrary.framework/ALAssetRepresentationPrivate.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/Frameworks/AssetsLibrary.framework/AssetsLibrary
*/
@interface ALAssetRepresentationPrivate : NSObject <ALAssetsLibraryAsset> {
NSString * _extension;
bool _isValid;
ALAssetsLibrary * _library;
PLManagedAsset * _photo;
PLPhotoLibrary * _photoLibrary;
PLSidecarFile * _sidecar;
}
@property (nonatomic, retain) PLPhotoLibrary *_photoLibrary;
@property (readonly, copy) NSString *debugDescription;
@property (readonly, copy) NSString *description;
@property (nonatomic, copy) NSString *extension;
@property (readonly) unsigned long long hash;
@property (nonatomic) bool isValid;
@property (nonatomic) ALAssetsLibrary *library;
@property (nonatomic, retain) PLManagedAsset *photo;
@property (nonatomic, retain) PLSidecarFile *sidecar;
@property (readonly) Class superclass;
+ (void)_clearFileDescriptorQueue;
+ (int)_fileDescriptorForPersistentURL:(id)arg1;
+ (void)_setupFileDescriptorQueue;
+ (int)_updateFileDescriptor:(int)arg1 forPersistentURL:(id)arg2;
- (void).cxx_destruct;
- (bool)_isImage;
- (bool)_isVideo;
- (void)_performBlockAndWait:(id /* block */)arg1;
- (id)_photoLibrary;
- (void)dealloc;
- (id)extension;
- (id)initWithManagedAsset:(id)arg1 sidecar:(id)arg2 extension:(id)arg3 library:(id)arg4;
- (bool)isValid;
- (id)library;
- (void)libraryDidChange;
- (id)photo;
- (void)setExtension:(id)arg1;
- (void)setIsValid:(bool)arg1;
- (void)setLibrary:(id)arg1;
- (void)setPhoto:(id)arg1;
- (void)setSidecar:(id)arg1;
- (void)set_photoLibrary:(id)arg1;
- (id)sidecar;
@end
| 30.803922 | 89 | 0.753024 |
d85a149f17d145469ab5dafde8832c82a5fd6c90 | 1,367 | h | C | Tangram/Source/Layouts/TangramWaterFlowLayout.h | MiaoShichang/Tangram-iOS | 2f36bb18746a3d7e2957dd049ca121f8f1a63785 | [
"MIT"
] | null | null | null | Tangram/Source/Layouts/TangramWaterFlowLayout.h | MiaoShichang/Tangram-iOS | 2f36bb18746a3d7e2957dd049ca121f8f1a63785 | [
"MIT"
] | null | null | null | Tangram/Source/Layouts/TangramWaterFlowLayout.h | MiaoShichang/Tangram-iOS | 2f36bb18746a3d7e2957dd049ca121f8f1a63785 | [
"MIT"
] | 1 | 2020-04-22T03:13:17.000Z | 2020-04-22T03:13:17.000Z | //
// TangramWaterFlowLayout.h
// Pods
//
// Created by xiaoxia on 15/12/12.
//
//
#import <UIKit/UIKit.h>
#import "TangramLayoutProtocol.h"
@interface TangramWaterFlowLayout : UIView<TangramLayoutProtocol>
// Models Array , as protocol request.
@property (nonatomic, strong) NSArray *itemModels;
// Number of columns.
@property (nonatomic, assign) NSUInteger numberOfColumns;
// Percentage number of every cols
@property (nonatomic, strong) NSArray *cols;
// Aspect ratio of every row
@property (nonatomic, strong) NSString *aspectRatio;
// Margin , the sequence of top, right, bottom, left, the class type in array can be NSNumber or NSString
@property (nonatomic, strong) NSArray *margin;
// padding top, right, bottom, left的顺序, 接收NSString
@property (nonatomic, strong) NSArray *padding;
// Gap in horizontal direction
@property (nonatomic, assign) CGFloat hGap;
// Gap in vertical direction
@property (nonatomic, assign) CGFloat vGap;
// Element width
@property (nonatomic, assign, readonly) CGFloat cellWidth;
@property (nonatomic, weak) TangramBus *tangramBus;
@property (nonatomic, assign) TangramLayoutLoadType loadType;
@property (nonatomic, strong) NSString *layoutLoadAPI;
@property (nonatomic, assign) CGFloat zIndex;
@end
| 32.547619 | 105 | 0.693489 |
affcbaa0d1578577ce5efb87986dc96736118eca | 1,842 | h | C | garnet/lib/vulkan/src/swapchain/image_pipe_surface_async.h | zhangpf/fuchsia-rs | 903568f28ddf45f09157ead36d61b50322c9cf49 | [
"BSD-3-Clause"
] | 1 | 2019-10-09T10:50:57.000Z | 2019-10-09T10:50:57.000Z | garnet/lib/vulkan/src/swapchain/image_pipe_surface_async.h | zhangpf/fuchsia-rs | 903568f28ddf45f09157ead36d61b50322c9cf49 | [
"BSD-3-Clause"
] | 5 | 2020-09-06T09:02:06.000Z | 2022-03-02T04:44:22.000Z | garnet/lib/vulkan/src/swapchain/image_pipe_surface_async.h | ZVNexus/fuchsia | c5610ad15208208c98693618a79c705af935270c | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2017 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 GARNET_LIB_VULKAN_SRC_SWAPCHAIN_IMAGE_PIPE_SURFACE_ASYNC_H_
#define GARNET_LIB_VULKAN_SRC_SWAPCHAIN_IMAGE_PIPE_SURFACE_ASYNC_H_
#include "image_pipe_surface.h"
#include <lib/async-loop/cpp/loop.h>
#include <mutex>
#include <thread>
namespace image_pipe_swapchain {
// An implementation of ImagePipeSurface based on an async fidl ImagePipe.
class ImagePipeSurfaceAsync : public ImagePipeSurface {
public:
ImagePipeSurfaceAsync(zx_handle_t image_pipe_handle)
: loop_(&kAsyncLoopConfigNoAttachToThread) {
image_pipe_.Bind(zx::channel(image_pipe_handle), loop_.dispatcher());
loop_.StartThread();
}
bool CreateImage(VkDevice device, VkLayerDispatchTable* pDisp,
VkFormat format, VkImageUsageFlags usage,
VkSwapchainCreateFlagsKHR swapchain_flags,
fuchsia::images::ImageInfo image_info, uint32_t image_count,
const VkAllocationCallbacks* pAllocator,
std::vector<ImageInfo>* image_info_out) override;
void RemoveImage(uint32_t image_id) override;
void PresentImage(uint32_t image_id, std::vector<zx::event> acquire_fences,
std::vector<zx::event> release_fences) override;
private:
void PresentNextImageLocked();
async::Loop loop_;
std::mutex mutex_;
fuchsia::images::ImagePipePtr image_pipe_;
struct PendingPresent {
uint32_t image_id;
std::vector<zx::event> acquire_fences;
std::vector<zx::event> release_fences;
};
std::vector<PendingPresent> queue_;
bool present_pending_ = false;
};
} // namespace image_pipe_swapchain
#endif // GARNET_LIB_VULKAN_SRC_SWAPCHAIN_IMAGE_PIPE_SURFACE_ASYNC_H_
| 33.490909 | 79 | 0.743757 |
88a1da8f0663f1c53eea758ea66a8d1e7dec39c3 | 3,234 | h | C | master/core/third/tntnet/framework/common/tnt/data.h | importlib/klib | a59837857689d0e60d3df6d2ebd12c3160efa794 | [
"MIT"
] | 4 | 2017-12-04T08:22:48.000Z | 2019-10-26T21:44:59.000Z | master/core/third/tntnet/framework/common/tnt/data.h | isuhao/klib | a59837857689d0e60d3df6d2ebd12c3160efa794 | [
"MIT"
] | null | null | null | master/core/third/tntnet/framework/common/tnt/data.h | isuhao/klib | a59837857689d0e60d3df6d2ebd12c3160efa794 | [
"MIT"
] | 4 | 2017-12-04T08:22:49.000Z | 2018-12-27T03:20:31.000Z | /*
* Copyright (C) 2003 Tommi Maekitalo
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* As a special exception, you may use this file as part of a free
* software library without restriction. Specifically, if other files
* instantiate templates or use macros or inline functions from this
* file, or you compile this file and link it with other files to
* produce an executable, this file does not by itself cause the
* resulting executable to be covered by the GNU General Public
* License. This exception does not however invalidate any other
* reasons why the executable file might be covered by the GNU Library
* General Public License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TNT_DATA_H
#define TNT_DATA_H
#include <iostream>
namespace tnt
{
class DataChunk
{
const char* data;
unsigned len;
public:
DataChunk(const char* data_, const char* end_)
: data(data_),
len(end_ - data_)
{ }
DataChunk(const char* data_, unsigned len_)
: data(data_),
len(len_)
{ }
const char* getData() const { return data; }
unsigned getLength() const { return len; }
};
//////////////////////////////////////////////////////////////////////
// interpretes raw data as a data-structure with chunks
// unsigned: number of chunks
// count X unsigned: offsets
// data
//
class DataChunks
{
const char* dataObject;
const unsigned* udata() const
{
const char* d = dataObject;
return reinterpret_cast<const unsigned*>(d);
}
public:
DataChunks(const char* d = 0)
: dataObject(d)
{ }
const char* data() const
{ return dataObject; }
void setData(const char* d)
{ dataObject = d; }
// number of chunks
unsigned size() const
{ return (udata()[0] / sizeof(unsigned)) - 1; }
// offset of n-th chunk from start
unsigned offset(unsigned n) const
{ return udata()[n] - udata()[0]; }
// size of nth chunk in bytes
unsigned size(unsigned n) const
{ return udata()[n + 1] - udata()[n]; }
// pointer to n-th chunk
const char* ptr(unsigned n) const
{
const char* d = dataObject;
return d + udata()[n];
}
DataChunk operator[] (unsigned n) const
{ return DataChunk(ptr(n), size(n)); }
};
inline std::ostream& operator << (std::ostream& out, const DataChunk& c)
{
out.write(c.getData(), c.getLength());
return out;
}
}
#endif // TNT_DATA_H
| 27.87931 | 81 | 0.630489 |
88c292ce79baa1eb4fba50f21271671b0ea41ada | 825 | h | C | classpath-0.98/native/jni/qt-peer/slotcallbacks.h | nmldiegues/jvm-stm | d422d78ba8efc99409ecb49efdb4edf4884658df | [
"Apache-2.0"
] | 2 | 2015-09-08T15:40:04.000Z | 2017-02-09T15:19:33.000Z | llvm-gcc-4.2-2.9/libjava/classpath/native/jni/qt-peer/slotcallbacks.h | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | null | null | null | llvm-gcc-4.2-2.9/libjava/classpath/native/jni/qt-peer/slotcallbacks.h | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | null | null | null | #ifndef SLOTCALLBACKS_H
#define SLOTCALLBACKS_H
#include <QAbstractButton>
#include <QAbstractSlider>
#include <QAction>
#include <QComboBox>
#include <QListWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QScrollBar>
#include <QTextEdit>
#include <jni.h>
void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj);
void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj);
void connectAction(QAction *action, JNIEnv *env, jobject obj);
void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj);
void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj);
void connectList(QListWidget *list, JNIEnv *env, jobject choiceobj);
void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj);
void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj);
#endif
| 33 | 72 | 0.789091 |
156745f08eb9c8523dc3ec93934aff87a57e3b94 | 1,578 | c | C | EXP4_Synchronization_Primitives_IPC/src/test_sanguo/process3.c | ucasFL/OperatingSystemEXP | d60310f0fb5d73e64ca6d473b0c1ee1114ea0c0a | [
"MIT"
] | null | null | null | EXP4_Synchronization_Primitives_IPC/src/test_sanguo/process3.c | ucasFL/OperatingSystemEXP | d60310f0fb5d73e64ca6d473b0c1ee1114ea0c0a | [
"MIT"
] | null | null | null | EXP4_Synchronization_Primitives_IPC/src/test_sanguo/process3.c | ucasFL/OperatingSystemEXP | d60310f0fb5d73e64ca6d473b0c1ee1114ea0c0a | [
"MIT"
] | null | null | null | #include "common.h"
#include "syslib.h"
#include "util.h"
#include "printf.h"
void CaoCao(void)
{
// uint32_t myRand = 1234;
uint32_t myRand = timer();
pid_t myPid = getpid();
mbox_t subSunQuan = mbox_open("SunQuan-Publish-PID");
mbox_t subLiuBei = mbox_open("LiuBei-Publish-PID");
pid_t sunquan, liubei;
mbox_recv(subSunQuan, &sunquan, sizeof(pid_t));
mbox_recv(subLiuBei, &liubei, sizeof(pid_t));
for(;;)
{
printf(7,1, "CaoCao(%d): I am working... muahaha ", myPid);
sleep(5000);
printf(7,1, "CaoCao(%d): I have my decision! ", myPid);
myRand = rand_step(myRand);
switch( myRand % 2 )
{
case 0:
printf(8, 1, "CaoCao(%d): I will kill SunQuan (%d)! ", myPid, sunquan);
sleep(1000);
printf(1,1, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ");
kill( sunquan );
mbox_recv(subSunQuan, &sunquan, sizeof(pid_t));
printf(8, 1, "CaoCao(%d): Oops! SunQuan(%d) lives! ", myPid, sunquan);
break;
case 1:
printf(9, 1, "CaoCao(%d): I will kill LiuBei(%d)! ", myPid, liubei);
sleep(1000);
printf(2,1, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ");
kill( liubei );
mbox_recv(subLiuBei, &liubei, sizeof(pid_t));
printf(10, 1, "CaoCao(%d): Oops! LiuBei(%d) is alive again! ", myPid, liubei);
break;
}
sleep(2000);
printf(11, 1, " ");
printf(12, 1, " ");
}
}
| 26.3 | 94 | 0.532953 |
15a6afadfb41dff4e5e4a088686cd4c0ff4a9cd1 | 3,625 | h | C | src/CoviMAC/Operateurs/Op_Grad_CoviMAC_Face.h | cea-trust-platform/trust-code | c4f42d8f8602a8cc5e0ead0e29dbf0be8ac52f72 | [
"BSD-3-Clause"
] | 12 | 2021-06-30T18:50:38.000Z | 2022-03-23T09:03:16.000Z | src/CoviMAC/Operateurs/Op_Grad_CoviMAC_Face.h | cea-trust-platform/trust-code | c4f42d8f8602a8cc5e0ead0e29dbf0be8ac52f72 | [
"BSD-3-Clause"
] | null | null | null | src/CoviMAC/Operateurs/Op_Grad_CoviMAC_Face.h | cea-trust-platform/trust-code | c4f42d8f8602a8cc5e0ead0e29dbf0be8ac52f72 | [
"BSD-3-Clause"
] | 2 | 2021-10-04T09:19:39.000Z | 2021-12-15T14:21:04.000Z | /****************************************************************************
* Copyright (c) 2021, CEA
* 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.
*
*****************************************************************************/
//////////////////////////////////////////////////////////////////////////////
//
// File: Op_Grad_CoviMAC_Face.h
// Directory: $TRUST_ROOT/src/CoviMAC/Operateurs
// Version: /main/12
//
//////////////////////////////////////////////////////////////////////////////
#ifndef Op_Grad_CoviMAC_Face_included
#define Op_Grad_CoviMAC_Face_included
#include <Operateur_Grad.h>
#include <Ref_Zone_CoviMAC.h>
#include <Zone_CoviMAC.h>
#include <Ref_Zone_Cl_CoviMAC.h>
#include <Ref_Champ_Face_CoviMAC.h>
//
// .DESCRIPTION class Op_Grad_CoviMAC_Face
//
// Cette classe represente l'operateur de gradient
// La discretisation est CoviMAC
// On calcule le gradient d'un champ_P0_CoviMAC (la pression)
//
// .SECTION voir aussi
// Operateur_Grad_base
//
class Op_Grad_CoviMAC_Face : public Operateur_Grad_base
{
Declare_instanciable(Op_Grad_CoviMAC_Face);
public:
void associer(const Zone_dis& , const Zone_Cl_dis& , const Champ_Inc& );
void completer();
/* interface {dimensionner,ajouter}_blocs -> cf Equation_base.h */
int has_interface_blocs() const
{
return 1;
};
virtual void dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl = {}) const;
virtual void ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl = {}) const;
int impr(Sortie& os) const;
/* poids de l'amont/aval dans les equations a chaque face : l'appel provoque le calcul du gradient */
const DoubleTab& mu_f(int full_stencil = 0) const;
/* public pour utilisation par Assembleur_P_CoviMAC : [grad p]_f */
mutable IntTab fgrad_d, fgrad_e;
mutable DoubleTab fgrad_c;
void check_multiphase_compatibility() const { }; //ok
private:
mutable double last_gradp_; //dernier temps utilise pour interpoler grad p (mis a DBL_MAX si grad p non reinterpole)
mutable DoubleTab mu_f_; //il faut appeller mu_f() pour forcer la mise a jour du gradient
REF(Zone_CoviMAC) ref_zone;
REF(Zone_Cl_CoviMAC) ref_zcl;
};
#endif
| 43.674699 | 260 | 0.707034 |
63b9e9f4a5d1923d8b43aec28b23458adfbea5ed | 20,053 | h | C | roo_material_icons/round/24/maps.h | dejwk/roo_material_icons | f559ce25b6ee2fdf67ed4f8b0bedfce2aaefb885 | [
"MIT"
] | null | null | null | roo_material_icons/round/24/maps.h | dejwk/roo_material_icons | f559ce25b6ee2fdf67ed4f8b0bedfce2aaefb885 | [
"MIT"
] | null | null | null | roo_material_icons/round/24/maps.h | dejwk/roo_material_icons | f559ce25b6ee2fdf67ed4f8b0bedfce2aaefb885 | [
"MIT"
] | null | null | null | #include "roo_display/image/image.h"
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_360();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_add_business();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_add_location_alt();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_add_location();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_add_road();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_agriculture();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_alt_route();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_atm();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_attractions();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_badge();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_bakery_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_beenhere();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_bike_scooter();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_breakfast_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_brunch_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_bus_alert();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_car_rental();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_car_repair();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_category();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_celebration();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_cleaning_services();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_compass_calibration();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_delivery_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_departure_board();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_design_services();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_dinner_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_bike();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_boat_filled();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_boat();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_bus_filled();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_bus();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_car_filled();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_car();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_railway_filled();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_railway();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_run();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_subway_filled();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_subway();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_transit_filled();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_transit();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_directions_walk();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_dry_cleaning();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_edit_attributes();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_edit_location_alt();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_edit_location();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_edit_road();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_electrical_services();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_electric_bike();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_electric_car();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_electric_moped();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_electric_rickshaw();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_electric_scooter();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_emergency();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_ev_station();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_fastfood();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_festival();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_flight();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_hail();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_handyman();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_hardware();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_home_repair_service();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_hotel();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_hvac();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_icecream();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_layers_clear();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_layers();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_liquor();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_activity();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_airport();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_atm();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_bar();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_cafe();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_car_wash();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_convenience_store();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_drink();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_fire_department();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_florist();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_gas_station();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_grocery_store();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_hospital();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_hotel();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_laundry_service();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_library();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_mall();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_movies();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_offer();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_parking();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_pharmacy();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_phone();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_pizza();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_play();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_police();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_post_office();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_printshop();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_see();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_shipping();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_local_taxi();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_lunch_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_map();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_maps_ugc();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_medical_services();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_menu_book();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_miscellaneous_services();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_money();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_moped();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_moving();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_multiple_stop();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_museum();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_my_location();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_navigation();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_near_me_disabled();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_near_me();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_nightlife();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_no_meals();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_not_listed_location();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_no_transfer();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_park();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_pedal_bike();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_person_pin_circle();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_person_pin();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_pest_control();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_pest_control_rodent();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_pin_drop();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_place();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_plumbing();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_railway_alert();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_ramen_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_rate_review();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_restaurant_menu();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_restaurant();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_run_circle();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_sailing();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_satellite();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_set_meal();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_snowmobile();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_store_mall_directory();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_streetview();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_subway();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_takeout_dining();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_taxi_alert();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_terrain();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_theater_comedy();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_traffic();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_train();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_tram();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_transfer_within_a_station();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_transit_enterexit();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_trip_origin();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_two_wheeler();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_volunteer_activism();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_wine_bar();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_wrong_location();
const ::roo_display::RleImage4bppxBiased<::roo_display::Alpha4, ::roo_display::PrgMemResource>& ic_round_24_maps_zoom_out_map();
| 126.917722 | 141 | 0.821772 |
635e2e5926a1f96161fa83524db98f391496c2d7 | 2,954 | h | C | data/playback_data_source_interface.h | BrnSlr/CuteBoard | 00beb783e234c9a08f9a53baa0fe10744452f755 | [
"Apache-2.0"
] | 47 | 2019-10-23T17:55:13.000Z | 2022-03-22T07:49:04.000Z | data/playback_data_source_interface.h | BrnSlr/CuteBoard | 00beb783e234c9a08f9a53baa0fe10744452f755 | [
"Apache-2.0"
] | 1 | 2021-12-20T18:48:26.000Z | 2021-12-20T18:48:26.000Z | data/playback_data_source_interface.h | BrnSlr/CuteBoard | 00beb783e234c9a08f9a53baa0fe10744452f755 | [
"Apache-2.0"
] | 18 | 2020-01-31T06:45:06.000Z | 2022-03-29T16:56:31.000Z | #ifndef PLAYBACK_DATA_SOURCE_INTERFACE_H
#define PLAYBACK_DATA_SOURCE_INTERFACE_H
#include <QDate>
#include "data_source.h"
#include "data_global.h"
#include "log4qt/logger.h"
class DATASHARED_EXPORT PlaybackDataSourceInterface : public DataSource
{
Q_OBJECT
LOG4QT_DECLARE_QCLASS_LOGGER
public:
PlaybackDataSourceInterface(QString name) :
DataSource(name)
{
}
virtual ~PlaybackDataSourceInterface() override {}
virtual bool activatePlayback() = 0;
virtual void setPlaybackDateTime(double secsSinceStartOfTheDay, QDate date = QDate()) = 0;
virtual void loadPlaybackData(QVector<QSharedPointer<TimeSeries>> boardParameters,
QMap<quint32, QVector<double>> ×tamps,
QMap<quint32, QVector<DataValue>> &values) = 0;
virtual bool parametersUpdated() = 0;
void clearParameters() override
{
if(mDataManager) {
foreach(auto param, mListParam)
mDataManager->unregisterPlaybackParameter(param);
mListParam.clear();
}
}
void unregisterParameter(const QString& label) override
{
if(mDataManager) {
QSharedPointer<TimeSeries> param;
param = mDataManager->playbackParameter(label);
mDataManager->unregisterPlaybackParameter(label);
if(param)
mListParam.removeAll(param);
}
}
void unregisterParameter(quint32 parameterId) override
{
if(mDataManager) {
QSharedPointer<TimeSeries> param;
param = mDataManager->playbackParameter(parameterId);
mDataManager->unregisterPlaybackParameter(parameterId);
if(param)
mListParam.removeAll(param);
}
}
virtual bool registerParameter(const QSharedPointer<TimeSeries>& param) override
{
bool st = false;
if(mDataManager) {
if(param->valid()) {
st = mDataManager->registerPlaybackParameter(param);
if(st)
mListParam.append(param);
} else {
logger()->debug() << Q_FUNC_INFO << "Param is not valid - failed to allocate memory" << param->name() << param->capacity();
}
}
return st;
}
signals:
void playbackStartTime(int);
void playbackEndTime(int);
protected:
virtual void dataManagerInitialized() override
{
connect(this, &PlaybackDataSourceInterface::playbackStartTime,
mDataManager, &DataManager::newPlaybackStartTime);
connect(this, &PlaybackDataSourceInterface::playbackEndTime,
mDataManager, &DataManager::newPlaybackEndTime);
}
};
#define PlaybackDataSourceInterface_iid "CuteBoard.PlaybackDataSources"
Q_DECLARE_INTERFACE(PlaybackDataSourceInterface, PlaybackDataSourceInterface_iid)
#endif // PLAYBACK_DATA_SOURCE_INTERFACE_H
| 30.770833 | 139 | 0.646581 |
6362c20bf91acc6d470332170537b41b572f9a07 | 410 | h | C | RWRider.xcframework/ios-x86_64-simulator/RWRider.framework/Headers/SplitFareTableViewCell.h | RahulGera/RWRider | b0094f91d1e8bcaadf442ebaaf8e104e9b422342 | [
"MIT"
] | 5 | 2019-05-07T12:45:50.000Z | 2020-12-03T05:14:26.000Z | RWRider.xcframework/ios-x86_64-simulator/RWRider.framework/Headers/SplitFareTableViewCell.h | RahulGera/RWRider | b0094f91d1e8bcaadf442ebaaf8e104e9b422342 | [
"MIT"
] | null | null | null | RWRider.xcframework/ios-x86_64-simulator/RWRider.framework/Headers/SplitFareTableViewCell.h | RahulGera/RWRider | b0094f91d1e8bcaadf442ebaaf8e104e9b422342 | [
"MIT"
] | 7 | 2020-06-16T20:45:23.000Z | 2021-06-06T18:07:08.000Z | //
// SplitFareTableViewCell.h
// Ride
//
// Created by Roberto Abreu on 1/17/18.
// Copyright © 2018 RideAustin.com. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SplitFareTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *imgUserProfile;
@property (weak, nonatomic) IBOutlet UILabel *lblName;
@property (weak, nonatomic) IBOutlet UIButton *btnCancel;
@end
| 22.777778 | 65 | 0.74878 |
c0e6b97bb84e8def0f54d2c32afe17abefdb9ec1 | 90,066 | c | C | usr.sbin/moused/moused.c | lambdaxymox/DragonFlyBSD | 6379cf2998a4a073c65b12d99e62988a375b4598 | [
"BSD-3-Clause"
] | 432 | 2015-01-03T20:05:29.000Z | 2022-03-24T16:39:09.000Z | usr.sbin/moused/moused.c | lambdaxymox/DragonFlyBSD | 6379cf2998a4a073c65b12d99e62988a375b4598 | [
"BSD-3-Clause"
] | 8 | 2015-12-03T15:45:38.000Z | 2020-12-25T15:42:08.000Z | usr.sbin/moused/moused.c | lambdaxymox/DragonFlyBSD | 6379cf2998a4a073c65b12d99e62988a375b4598 | [
"BSD-3-Clause"
] | 114 | 2015-01-07T16:23:00.000Z | 2022-03-23T18:26:01.000Z | /**
** Copyright (c) 1995 Michael Smith, 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 as
** the first lines of this file unmodified.
** 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 Michael Smith.
** 4. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY Michael Smith ``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 Michael Smith 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.
**
**/
/**
** MOUSED.C
**
** Mouse daemon : listens to a serial port, the bus mouse interface, or
** the PS/2 mouse port for mouse data stream, interprets data and passes
** ioctls off to the console driver.
**
** The mouse interface functions are derived closely from the mouse
** handler in the XFree86 X server. Many thanks to the XFree86 people
** for their great work!
**
**/
/*
* $FreeBSD: src/usr.sbin/moused/moused.c,v 1.69 2005/01/06 08:38:29 philip Exp $
*/
#include <machine/console.h>
#include <sys/mouse.h>
#include <sys/param.h>
#include <sys/consio.h>
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/un.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <termios.h>
#include <unistd.h>
#define MAX_CLICKTHRESHOLD 2000 /* 2 seconds */
#define MAX_BUTTON2TIMEOUT 2000 /* 2 seconds */
#define DFLT_CLICKTHRESHOLD 500 /* 0.5 second */
#define DFLT_BUTTON2TIMEOUT 100 /* 0.1 second */
#define DFLT_SCROLLTHRESHOLD 3 /* 3 pixels */
/* Abort 3-button emulation delay after this many movement events. */
#define BUTTON2_MAXMOVE 3
#define TRUE 1
#define FALSE 0
#define MOUSE_XAXIS (-1)
#define MOUSE_YAXIS (-2)
/* Logitech PS2++ protocol */
#define MOUSE_PS2PLUS_CHECKBITS(b) \
((((b[2] & 0x03) << 2) | 0x02) == (b[1] & 0x0f))
#define MOUSE_PS2PLUS_PACKET_TYPE(b) \
(((b[0] & 0x30) >> 2) | ((b[1] & 0x30) >> 4))
#define ChordMiddle 0x0001
#define Emulate3Button 0x0002
#define ClearDTR 0x0004
#define ClearRTS 0x0008
#define NoPnP 0x0010
#define VirtualScroll 0x0020
#define ID_NONE 0
#define ID_PORT 1
#define ID_IF 2
#define ID_TYPE 4
#define ID_MODEL 8
#define ID_ALL (ID_PORT | ID_IF | ID_TYPE | ID_MODEL)
#define debug(fmt, args...) do { \
if (debug && nodaemon) \
warnx(fmt, ##args); \
} while (0)
#define logerr(e, fmt, args...) do { \
log_or_warn(LOG_DAEMON | LOG_ERR, errno, fmt, ##args); \
exit(e); \
} while (0)
#define logerrx(e, fmt, args...) do { \
log_or_warn(LOG_DAEMON | LOG_ERR, 0, fmt, ##args); \
exit(e); \
} while (0)
#define logwarn(fmt, args...) \
log_or_warn(LOG_DAEMON | LOG_WARNING, errno, fmt, ##args)
#define logwarnx(fmt, args...) \
log_or_warn(LOG_DAEMON | LOG_WARNING, 0, fmt, ##args)
/* structures */
/* symbol table entry */
typedef struct {
char *name;
int val;
int val2;
} symtab_t;
/* serial PnP ID string */
typedef struct {
int revision; /* PnP revision, 100 for 1.00 */
char *eisaid; /* EISA ID including mfr ID and product ID */
char *serial; /* serial No, optional */
char *class; /* device class, optional */
char *compat; /* list of compatible drivers, optional */
char *description; /* product description, optional */
int neisaid; /* length of the above fields... */
int nserial;
int nclass;
int ncompat;
int ndescription;
} pnpid_t;
/* global variables */
int debug = 0;
int nodaemon = FALSE;
int background = FALSE;
int identify = ID_NONE;
int extioctl = FALSE;
char *pidfile = "/var/run/moused.pid";
#define SCROLL_NOTSCROLLING 0
#define SCROLL_PREPARE 1
#define SCROLL_SCROLLING 2
static int scroll_state;
static int scroll_movement;
/* local variables */
/* interface (the table must be ordered by MOUSE_IF_XXX in mouse.h) */
static symtab_t rifs[] = {
{ "serial", MOUSE_IF_SERIAL },
{ "bus", MOUSE_IF_BUS },
{ "inport", MOUSE_IF_INPORT },
{ "ps/2", MOUSE_IF_PS2 },
{ "sysmouse", MOUSE_IF_SYSMOUSE },
{ "usb", MOUSE_IF_USB },
{ NULL, MOUSE_IF_UNKNOWN },
};
/* types (the table must be ordered by MOUSE_PROTO_XXX in mouse.h) */
static char *rnames[] = {
"microsoft",
"mousesystems",
"logitech",
"mmseries",
"mouseman",
"busmouse",
"inportmouse",
"ps/2",
"mmhitab",
"glidepoint",
"intellimouse",
"thinkingmouse",
"sysmouse",
"x10mouseremote",
"kidspad",
"versapad",
"jogdial",
#if 0 /* not yet */
"mariqua",
#endif
NULL
};
/* models */
static symtab_t rmodels[] = {
{ "NetScroll", MOUSE_MODEL_NETSCROLL },
{ "NetMouse/NetScroll Optical", MOUSE_MODEL_NET },
{ "GlidePoint", MOUSE_MODEL_GLIDEPOINT },
{ "ThinkingMouse", MOUSE_MODEL_THINK },
{ "IntelliMouse", MOUSE_MODEL_INTELLI },
{ "EasyScroll/SmartScroll", MOUSE_MODEL_EASYSCROLL },
{ "MouseMan+", MOUSE_MODEL_MOUSEMANPLUS },
{ "Kidspad", MOUSE_MODEL_KIDSPAD },
{ "VersaPad", MOUSE_MODEL_VERSAPAD },
{ "IntelliMouse Explorer", MOUSE_MODEL_EXPLORER },
{ "4D Mouse", MOUSE_MODEL_4D },
{ "4D+ Mouse", MOUSE_MODEL_4DPLUS },
{ "Synaptics Touchpad", MOUSE_MODEL_SYNAPTICS },
{ "generic", MOUSE_MODEL_GENERIC },
{ NULL, MOUSE_MODEL_UNKNOWN },
};
/* PnP EISA/product IDs */
static symtab_t pnpprod[] = {
/* Kensignton ThinkingMouse */
{ "KML0001", MOUSE_PROTO_THINK, MOUSE_MODEL_THINK },
/* MS IntelliMouse */
{ "MSH0001", MOUSE_PROTO_INTELLI, MOUSE_MODEL_INTELLI },
/* MS IntelliMouse TrackBall */
{ "MSH0004", MOUSE_PROTO_INTELLI, MOUSE_MODEL_INTELLI },
/* Tremon Wheel Mouse MUSD */
{ "HTK0001", MOUSE_PROTO_INTELLI, MOUSE_MODEL_INTELLI },
/* Genius PnP Mouse */
{ "KYE0001", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
/* MouseSystems SmartScroll Mouse (OEM from Genius?) */
{ "KYE0002", MOUSE_PROTO_MS, MOUSE_MODEL_EASYSCROLL },
/* Genius NetMouse */
{ "KYE0003", MOUSE_PROTO_INTELLI, MOUSE_MODEL_NET },
/* Genius Kidspad, Easypad and other tablets */
{ "KYE0005", MOUSE_PROTO_KIDSPAD, MOUSE_MODEL_KIDSPAD },
/* Genius EZScroll */
{ "KYEEZ00", MOUSE_PROTO_MS, MOUSE_MODEL_EASYSCROLL },
/* Logitech Cordless MouseMan Wheel */
{ "LGI8033", MOUSE_PROTO_INTELLI, MOUSE_MODEL_MOUSEMANPLUS },
/* Logitech MouseMan (new 4 button model) */
{ "LGI800C", MOUSE_PROTO_INTELLI, MOUSE_MODEL_MOUSEMANPLUS },
/* Logitech MouseMan+ */
{ "LGI8050", MOUSE_PROTO_INTELLI, MOUSE_MODEL_MOUSEMANPLUS },
/* Logitech FirstMouse+ */
{ "LGI8051", MOUSE_PROTO_INTELLI, MOUSE_MODEL_MOUSEMANPLUS },
/* Logitech serial */
{ "LGI8001", MOUSE_PROTO_LOGIMOUSEMAN, MOUSE_MODEL_GENERIC },
/* A4 Tech 4D/4D+ Mouse */
{ "A4W0005", MOUSE_PROTO_INTELLI, MOUSE_MODEL_4D },
/* 8D Scroll Mouse */
{ "PEC9802", MOUSE_PROTO_INTELLI, MOUSE_MODEL_INTELLI },
/* Mitsumi Wireless Scroll Mouse */
{ "MTM6401", MOUSE_PROTO_INTELLI, MOUSE_MODEL_INTELLI },
/* MS bus */
{ "PNP0F00", MOUSE_PROTO_BUS, MOUSE_MODEL_GENERIC },
/* MS serial */
{ "PNP0F01", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
/* MS InPort */
{ "PNP0F02", MOUSE_PROTO_INPORT, MOUSE_MODEL_GENERIC },
/* MS PS/2 */
{ "PNP0F03", MOUSE_PROTO_PS2, MOUSE_MODEL_GENERIC },
/*
* EzScroll returns PNP0F04 in the compatible device field; but it
* doesn't look compatible... XXX
*/
/* MouseSystems */
{ "PNP0F04", MOUSE_PROTO_MSC, MOUSE_MODEL_GENERIC },
/* MouseSystems */
{ "PNP0F05", MOUSE_PROTO_MSC, MOUSE_MODEL_GENERIC },
#if 0 /* not yet */
/* Genius Mouse */
{ "PNP0F06", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
/* Genius Mouse */
{ "PNP0F07", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
#endif
/* Logitech serial */
{ "PNP0F08", MOUSE_PROTO_LOGIMOUSEMAN, MOUSE_MODEL_GENERIC },
/* MS BallPoint serial */
{ "PNP0F09", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
/* MS PnP serial */
{ "PNP0F0A", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
/* MS PnP BallPoint serial */
{ "PNP0F0B", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
/* MS serial comatible */
{ "PNP0F0C", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
/* MS InPort comatible */
{ "PNP0F0D", MOUSE_PROTO_INPORT, MOUSE_MODEL_GENERIC },
/* MS PS/2 comatible */
{ "PNP0F0E", MOUSE_PROTO_PS2, MOUSE_MODEL_GENERIC },
/* MS BallPoint comatible */
{ "PNP0F0F", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
#if 0 /* not yet */
/* TI QuickPort */
{ "PNP0F10", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
#endif
/* MS bus comatible */
{ "PNP0F11", MOUSE_PROTO_BUS, MOUSE_MODEL_GENERIC },
/* Logitech PS/2 */
{ "PNP0F12", MOUSE_PROTO_PS2, MOUSE_MODEL_GENERIC },
/* PS/2 */
{ "PNP0F13", MOUSE_PROTO_PS2, MOUSE_MODEL_GENERIC },
#if 0 /* not yet */
/* MS Kids Mouse */
{ "PNP0F14", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
#endif
/* Logitech bus */
{ "PNP0F15", MOUSE_PROTO_BUS, MOUSE_MODEL_GENERIC },
#if 0 /* not yet */
/* Logitech SWIFT */
{ "PNP0F16", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
#endif
/* Logitech serial compat */
{ "PNP0F17", MOUSE_PROTO_LOGIMOUSEMAN, MOUSE_MODEL_GENERIC },
/* Logitech bus compatible */
{ "PNP0F18", MOUSE_PROTO_BUS, MOUSE_MODEL_GENERIC },
/* Logitech PS/2 compatible */
{ "PNP0F19", MOUSE_PROTO_PS2, MOUSE_MODEL_GENERIC },
#if 0 /* not yet */
/* Logitech SWIFT compatible */
{ "PNP0F1A", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
/* HP Omnibook */
{ "PNP0F1B", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
/* Compaq LTE TrackBall PS/2 */
{ "PNP0F1C", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
/* Compaq LTE TrackBall serial */
{ "PNP0F1D", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
/* MS Kidts Trackball */
{ "PNP0F1E", MOUSE_PROTO_XXX, MOUSE_MODEL_GENERIC },
#endif
/* Interlink VersaPad */
{ "LNK0001", MOUSE_PROTO_VERSAPAD, MOUSE_MODEL_VERSAPAD },
{ NULL, MOUSE_PROTO_UNKNOWN, MOUSE_MODEL_GENERIC },
};
/* the table must be ordered by MOUSE_PROTO_XXX in mouse.h */
static unsigned short rodentcflags[] =
{
(CS7 | CREAD | CLOCAL | HUPCL), /* MicroSoft */
(CS8 | CSTOPB | CREAD | CLOCAL | HUPCL), /* MouseSystems */
(CS8 | CSTOPB | CREAD | CLOCAL | HUPCL), /* Logitech */
(CS8 | PARENB | PARODD | CREAD | CLOCAL | HUPCL), /* MMSeries */
(CS7 | CREAD | CLOCAL | HUPCL), /* MouseMan */
0, /* Bus */
0, /* InPort */
0, /* PS/2 */
(CS8 | CREAD | CLOCAL | HUPCL), /* MM HitTablet */
(CS7 | CREAD | CLOCAL | HUPCL), /* GlidePoint */
(CS7 | CREAD | CLOCAL | HUPCL), /* IntelliMouse */
(CS7 | CREAD | CLOCAL | HUPCL), /* Thinking Mouse */
(CS8 | CSTOPB | CREAD | CLOCAL | HUPCL), /* sysmouse */
(CS7 | CREAD | CLOCAL | HUPCL), /* X10 MouseRemote */
(CS8 | PARENB | PARODD | CREAD | CLOCAL | HUPCL), /* kidspad etc. */
(CS8 | CREAD | CLOCAL | HUPCL), /* VersaPad */
0, /* JogDial */
#if 0 /* not yet */
(CS8 | CSTOPB | CREAD | CLOCAL | HUPCL), /* Mariqua */
#endif
};
static struct rodentparam {
int flags;
char *portname; /* /dev/XXX */
int rtype; /* MOUSE_PROTO_XXX */
int level; /* operation level: 0 or greater */
int baudrate;
int rate; /* report rate */
int resolution; /* MOUSE_RES_XXX or a positive number */
int zmap[4]; /* MOUSE_{X|Y}AXIS or a button number */
int wmode; /* wheel mode button number */
int mfd; /* mouse file descriptor */
int cfd; /* /dev/consolectl file descriptor */
int mremsfd; /* mouse remote server file descriptor */
int mremcfd; /* mouse remote client file descriptor */
long clickthreshold; /* double click speed in msec */
long button2timeout; /* 3 button emulation timeout */
mousehw_t hw; /* mouse device hardware information */
mousemode_t mode; /* protocol information */
float accelx; /* Acceleration in the X axis */
float accely; /* Acceleration in the Y axis */
int scrollthreshold; /* Movement distance before virtual scrolling */
} rodent = {
.flags = 0,
.portname = NULL,
.rtype = MOUSE_PROTO_UNKNOWN,
.level = -1,
.baudrate = 1200,
.rate = 0,
.resolution = MOUSE_RES_UNKNOWN,
.zmap = { 0, 0, 0, 0 },
.wmode = 0,
.mfd = -1,
.cfd = -1,
.mremsfd = -1,
.mremcfd = -1,
.clickthreshold = DFLT_CLICKTHRESHOLD,
.button2timeout = DFLT_BUTTON2TIMEOUT,
.accelx = 1.0,
.accely = 1.0,
.scrollthreshold = DFLT_SCROLLTHRESHOLD,
};
/* button status */
struct button_state {
int count; /* 0: up, 1: single click, 2: double click,... */
struct timeval tv; /* timestamp on the last button event */
};
static struct button_state bstate[MOUSE_MAXBUTTON]; /* button state */
static struct button_state *mstate[MOUSE_MAXBUTTON];/* mapped button st.*/
static struct button_state zstate[4]; /* Z/W axis state */
/* state machine for 3 button emulation */
#define S0 0 /* start */
#define S1 1 /* button 1 delayed down */
#define S2 2 /* button 3 delayed down */
#define S3 3 /* both buttons down -> button 2 down */
#define S4 4 /* button 1 delayed up */
#define S5 5 /* button 1 down */
#define S6 6 /* button 3 down */
#define S7 7 /* both buttons down */
#define S8 8 /* button 3 delayed up */
#define S9 9 /* button 1 or 3 up after S3 */
#define A(b1, b3) (((b1) ? 2 : 0) | ((b3) ? 1 : 0))
#define A_TIMEOUT 4
#define S_DELAYED(st) (states[st].s[A_TIMEOUT] != (st))
static struct {
int s[A_TIMEOUT + 1];
int buttons;
int mask;
int timeout;
} states[10] = {
/* S0 */
{ { S0, S2, S1, S3, S0 }, 0, ~(MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN), FALSE },
/* S1 */
{ { S4, S2, S1, S3, S5 }, 0, ~MOUSE_BUTTON1DOWN, FALSE },
/* S2 */
{ { S8, S2, S1, S3, S6 }, 0, ~MOUSE_BUTTON3DOWN, FALSE },
/* S3 */
{ { S0, S9, S9, S3, S3 }, MOUSE_BUTTON2DOWN, ~0, FALSE },
/* S4 */
{ { S0, S2, S1, S3, S0 }, MOUSE_BUTTON1DOWN, ~0, TRUE },
/* S5 */
{ { S0, S2, S5, S7, S5 }, MOUSE_BUTTON1DOWN, ~0, FALSE },
/* S6 */
{ { S0, S6, S1, S7, S6 }, MOUSE_BUTTON3DOWN, ~0, FALSE },
/* S7 */
{ { S0, S6, S5, S7, S7 }, MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN, ~0, FALSE },
/* S8 */
{ { S0, S2, S1, S3, S0 }, MOUSE_BUTTON3DOWN, ~0, TRUE },
/* S9 */
{ { S0, S9, S9, S3, S9 }, 0, ~(MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN), FALSE },
};
static int mouse_button_state;
static struct timeval mouse_button_state_tv;
static int mouse_move_delayed;
static jmp_buf env;
/* function prototypes */
static void moused(void);
static void hup(int sig);
static void cleanup(int sig);
static void usage(void);
static void log_or_warn(int log_pri, int errnum, const char *fmt, ...)
__printflike(3, 4);
static int r_identify(void);
static char *r_if(int type);
static char *r_name(int type);
static char *r_model(int model);
static void r_init(void);
static int r_protocol(u_char b, mousestatus_t *act);
static int r_statetrans(mousestatus_t *a1, mousestatus_t *a2, int trans);
static int r_installmap(char *arg);
static void r_map(mousestatus_t *act1, mousestatus_t *act2);
static void r_timestamp(mousestatus_t *act);
static int r_timeout(void);
static void r_click(mousestatus_t *act);
static void setmousespeed(int old, int new, unsigned cflag);
static int pnpwakeup1(void);
static int pnpwakeup2(void);
static int pnpgets(char *buf);
static int pnpparse(pnpid_t *id, char *buf, int len);
static symtab_t *pnpproto(pnpid_t *id);
static symtab_t *gettoken(symtab_t *tab, char *s, int len);
static char *gettokenname(symtab_t *tab, int val);
static void mremote_serversetup();
static void mremote_clientchg(int add);
static int kidspad(u_char rxc, mousestatus_t *act);
static int usbmodule(void);
int
main(int argc, char *argv[])
{
int c;
int i;
int j;
int retry;
for (i = 0; i < MOUSE_MAXBUTTON; ++i)
mstate[i] = &bstate[i];
while ((c = getopt(argc, argv, "3C:DE:F:I:PRS:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
switch(c) {
case '3':
rodent.flags |= Emulate3Button;
break;
case 'E':
rodent.button2timeout = atoi(optarg);
if ((rodent.button2timeout < 0) ||
(rodent.button2timeout > MAX_BUTTON2TIMEOUT)) {
warnx("invalid argument `%s'", optarg);
usage();
}
break;
case 'a':
i = sscanf(optarg, "%f,%f", &rodent.accelx, &rodent.accely);
if (i == 0) {
warnx("invalid acceleration argument '%s'", optarg);
usage();
}
if (i == 1)
rodent.accely = rodent.accelx;
break;
case 'c':
rodent.flags |= ChordMiddle;
break;
case 'd':
++debug;
break;
case 'f':
nodaemon = TRUE;
break;
case 'i':
if (strcmp(optarg, "all") == 0)
identify = ID_ALL;
else if (strcmp(optarg, "port") == 0)
identify = ID_PORT;
else if (strcmp(optarg, "if") == 0)
identify = ID_IF;
else if (strcmp(optarg, "type") == 0)
identify = ID_TYPE;
else if (strcmp(optarg, "model") == 0)
identify = ID_MODEL;
else {
warnx("invalid argument `%s'", optarg);
usage();
}
nodaemon = TRUE;
break;
case 'l':
rodent.level = atoi(optarg);
if ((rodent.level < 0) || (rodent.level > 4)) {
warnx("invalid argument `%s'", optarg);
usage();
}
break;
case 'm':
if (!r_installmap(optarg)) {
warnx("invalid argument `%s'", optarg);
usage();
}
break;
case 'p':
rodent.portname = optarg;
break;
case 'r':
if (strcmp(optarg, "high") == 0)
rodent.resolution = MOUSE_RES_HIGH;
else if (strcmp(optarg, "medium-high") == 0)
rodent.resolution = MOUSE_RES_HIGH;
else if (strcmp(optarg, "medium-low") == 0)
rodent.resolution = MOUSE_RES_MEDIUMLOW;
else if (strcmp(optarg, "low") == 0)
rodent.resolution = MOUSE_RES_LOW;
else if (strcmp(optarg, "default") == 0)
rodent.resolution = MOUSE_RES_DEFAULT;
else {
rodent.resolution = atoi(optarg);
if (rodent.resolution <= 0) {
warnx("invalid argument `%s'", optarg);
usage();
}
}
break;
case 's':
rodent.baudrate = 9600;
break;
case 'w':
i = atoi(optarg);
if ((i <= 0) || (i > MOUSE_MAXBUTTON)) {
warnx("invalid argument `%s'", optarg);
usage();
}
rodent.wmode = 1 << (i - 1);
break;
case 'z':
if (strcmp(optarg, "x") == 0)
rodent.zmap[0] = MOUSE_XAXIS;
else if (strcmp(optarg, "y") == 0)
rodent.zmap[0] = MOUSE_YAXIS;
else {
i = atoi(optarg);
/*
* Use button i for negative Z axis movement and
* button (i + 1) for positive Z axis movement.
*/
if ((i <= 0) || (i > MOUSE_MAXBUTTON - 1)) {
warnx("invalid argument `%s'", optarg);
usage();
}
rodent.zmap[0] = i;
rodent.zmap[1] = i + 1;
debug("optind: %d, optarg: '%s'", optind, optarg);
for (j = 1; j < 4; ++j) {
if ((optind >= argc) || !isdigit(*argv[optind]))
break;
i = atoi(argv[optind]);
if ((i <= 0) || (i > MOUSE_MAXBUTTON - 1)) {
warnx("invalid argument `%s'", argv[optind]);
usage();
}
rodent.zmap[j] = i;
++optind;
}
if ((rodent.zmap[2] != 0) && (rodent.zmap[3] == 0))
rodent.zmap[3] = rodent.zmap[2] + 1;
}
break;
case 'C':
rodent.clickthreshold = atoi(optarg);
if ((rodent.clickthreshold < 0) ||
(rodent.clickthreshold > MAX_CLICKTHRESHOLD)) {
warnx("invalid argument `%s'", optarg);
usage();
}
break;
case 'D':
rodent.flags |= ClearDTR;
break;
case 'F':
rodent.rate = atoi(optarg);
if (rodent.rate <= 0) {
warnx("invalid argument `%s'", optarg);
usage();
}
break;
case 'I':
pidfile = optarg;
break;
case 'P':
rodent.flags |= NoPnP;
break;
case 'R':
rodent.flags |= ClearRTS;
break;
case 'S':
rodent.baudrate = atoi(optarg);
if (rodent.baudrate <= 0) {
warnx("invalid argument `%s'", optarg);
usage();
}
debug("rodent baudrate %d", rodent.baudrate);
break;
case 't':
if (strcmp(optarg, "auto") == 0) {
rodent.rtype = MOUSE_PROTO_UNKNOWN;
rodent.flags &= ~NoPnP;
rodent.level = -1;
break;
}
for (i = 0; rnames[i]; i++)
if (strcmp(optarg, rnames[i]) == 0) {
rodent.rtype = i;
rodent.flags |= NoPnP;
rodent.level = (i == MOUSE_PROTO_SYSMOUSE) ? 1 : 0;
break;
}
if (rnames[i])
break;
warnx("no such mouse type `%s'", optarg);
usage();
case 'V':
rodent.flags |= VirtualScroll;
break;
case 'U':
rodent.scrollthreshold = atoi(optarg);
if (rodent.scrollthreshold < 0) {
warnx("invalid argument `%s'", optarg);
usage();
}
break;
case 'h':
case '?':
default:
usage();
}
/* fix Z axis mapping */
for (i = 0; i < 4; ++i) {
if (rodent.zmap[i] > 0) {
for (j = 0; j < MOUSE_MAXBUTTON; ++j) {
if (mstate[j] == &bstate[rodent.zmap[i] - 1])
mstate[j] = &zstate[i];
}
rodent.zmap[i] = 1 << (rodent.zmap[i] - 1);
}
}
/* the default port name */
switch(rodent.rtype) {
case MOUSE_PROTO_PS2:
if (!rodent.portname)
rodent.portname = "/dev/psm0";
break;
default:
if (rodent.portname)
break;
warnx("no port name specified");
usage();
}
retry = 1;
if (strncmp(rodent.portname, "/dev/ums", 8) == 0) {
if (usbmodule() != 0)
retry = 5;
}
for (;;) {
if (setjmp(env) == 0) {
signal(SIGHUP, hup);
signal(SIGINT , cleanup);
signal(SIGQUIT, cleanup);
signal(SIGTERM, cleanup);
for (i = 0; i < retry; ++i) {
if (i > 0)
sleep(2);
rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
if (rodent.mfd != -1 || errno != ENOENT)
break;
}
if (rodent.mfd == -1)
logerr(1, "unable to open %s", rodent.portname);
if (r_identify() == MOUSE_PROTO_UNKNOWN) {
logwarnx("cannot determine mouse type on %s", rodent.portname);
close(rodent.mfd);
rodent.mfd = -1;
}
/* print some information */
if (identify != ID_NONE) {
if (identify == ID_ALL)
printf("%s %s %s %s\n",
rodent.portname, r_if(rodent.hw.iftype),
r_name(rodent.rtype), r_model(rodent.hw.model));
else if (identify & ID_PORT)
printf("%s\n", rodent.portname);
else if (identify & ID_IF)
printf("%s\n", r_if(rodent.hw.iftype));
else if (identify & ID_TYPE)
printf("%s\n", r_name(rodent.rtype));
else if (identify & ID_MODEL)
printf("%s\n", r_model(rodent.hw.model));
exit(0);
} else {
debug("port: %s interface: %s type: %s model: %s",
rodent.portname, r_if(rodent.hw.iftype),
r_name(rodent.rtype), r_model(rodent.hw.model));
}
if (rodent.mfd == -1) {
/*
* We cannot continue because of error. Exit if the
* program has not become a daemon. Otherwise, block
* until the the user corrects the problem and issues SIGHUP.
*/
if (!background)
exit(1);
sigpause(0);
}
r_init(); /* call init function */
moused();
}
if (rodent.mfd != -1)
close(rodent.mfd);
if (rodent.cfd != -1)
close(rodent.cfd);
rodent.mfd = rodent.cfd = -1;
}
/* NOT REACHED */
exit(0);
}
static int
usbmodule(void)
{
struct kld_file_stat fstat;
struct module_stat mstat;
int fileid, modid;
int loaded;
for (loaded = 0, fileid = kldnext(0); !loaded && fileid > 0;
fileid = kldnext(fileid)) {
fstat.version = sizeof(fstat);
if (kldstat(fileid, &fstat) < 0)
continue;
if (strncmp(fstat.name, "uhub/ums", 8) == 0) {
loaded = 1;
break;
}
for (modid = kldfirstmod(fileid); modid > 0;
modid = modfnext(modid)) {
mstat.version = sizeof(mstat);
if (modstat(modid, &mstat) < 0)
continue;
if (strncmp(mstat.name, "uhub/ums", 8) == 0) {
loaded = 1;
break;
}
}
}
if (!loaded) {
if (kldload("ums") != -1)
return 1;
if (errno != EEXIST)
logerr(1, "unable to load USB mouse driver");
}
return 0;
}
static void
moused(void)
{
struct mouse_info mouse;
mousestatus_t action0; /* original mouse action */
mousestatus_t action; /* interrim buffer */
mousestatus_t action2; /* mapped action */
struct timeval timeout;
fd_set fds;
u_char buf[16];
FILE *fp;
int fill = 0;
int pos = 0;
int flags;
int c;
int i;
if ((rodent.cfd = open("/dev/consolectl", O_RDWR, 0)) == -1)
logerr(1, "cannot open /dev/consolectl");
if (!nodaemon && !background) {
if (daemon(0, 0)) {
logerr(1, "failed to become a daemon");
} else {
background = TRUE;
fp = fopen(pidfile, "w");
if (fp != NULL) {
fprintf(fp, "%d\n", getpid());
fclose(fp);
}
}
}
/* clear mouse data */
bzero(&action0, sizeof(action0));
bzero(&action, sizeof(action));
bzero(&action2, sizeof(action2));
bzero(&mouse, sizeof(mouse));
mouse_button_state = S0;
gettimeofday(&mouse_button_state_tv, NULL);
mouse_move_delayed = 0;
for (i = 0; i < MOUSE_MAXBUTTON; ++i) {
bstate[i].count = 0;
bstate[i].tv = mouse_button_state_tv;
}
for (i = 0; i < NELEM(zstate); ++i) {
zstate[i].count = 0;
zstate[i].tv = mouse_button_state_tv;
}
/* choose which ioctl command to use */
mouse.operation = MOUSE_MOTION_EVENT;
extioctl = (ioctl(rodent.cfd, CONS_MOUSECTL, &mouse) == 0);
/* process mouse data */
timeout.tv_sec = 0;
timeout.tv_usec = 20000; /* 20 msec */
for (;;) {
if (fill > pos)
goto more;
fill = 0;
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
if (rodent.mremsfd >= 0)
FD_SET(rodent.mremsfd, &fds);
if (rodent.mremcfd >= 0)
FD_SET(rodent.mremcfd, &fds);
c = select(FD_SETSIZE, &fds, NULL, NULL,
(rodent.flags & Emulate3Button) ? &timeout : NULL);
if (c < 0) { /* error */
logwarn("failed to read from mouse");
continue;
} else if (c == 0) { /* timeout */
/* assert(rodent.flags & Emulate3Button) */
action0.button = action0.obutton;
action0.dx = action0.dy = action0.dz = 0;
action0.flags = flags = 0;
if (r_timeout() && r_statetrans(&action0, &action, A_TIMEOUT)) {
if (debug > 2)
debug("flags:%08x buttons:%08x obuttons:%08x",
action.flags, action.button, action.obutton);
} else {
action0.obutton = action0.button;
continue;
}
} else {
/* MouseRemote client connect/disconnect */
if ((rodent.mremsfd >= 0) && FD_ISSET(rodent.mremsfd, &fds)) {
mremote_clientchg(TRUE);
continue;
}
if ((rodent.mremcfd >= 0) && FD_ISSET(rodent.mremcfd, &fds)) {
mremote_clientchg(FALSE);
continue;
}
/* mouse movement */
if ((fill = read(rodent.mfd, buf, sizeof(buf))) == -1) {
if (errno == EWOULDBLOCK)
continue;
else
return;
}
pos = 0;
more:
if ((flags = r_protocol(buf[pos++], &action0)) == 0)
continue;
if (rodent.flags & VirtualScroll) {
/* Allow middle button drags to scroll up and down */
if (action0.button == MOUSE_BUTTON2DOWN) {
if (scroll_state == SCROLL_NOTSCROLLING) {
scroll_state = SCROLL_PREPARE;
debug("PREPARING TO SCROLL");
}
debug("[BUTTON2] flags:%08x buttons:%08x obuttons:%08x",
action.flags, action.button, action.obutton);
} else {
debug("[NOTBUTTON2] flags:%08x buttons:%08x obuttons:%08x",
action.flags, action.button, action.obutton);
/* This isn't a middle button down... move along... */
if (scroll_state == SCROLL_SCROLLING) {
/*
* We were scrolling, someone let go of button 2.
* Now turn autoscroll off.
*/
scroll_state = SCROLL_NOTSCROLLING;
debug("DONE WITH SCROLLING / %d", scroll_state);
} else if (scroll_state == SCROLL_PREPARE) {
mousestatus_t newaction = action0;
/* We were preparing to scroll, but we never moved... */
r_timestamp(&action0);
r_statetrans(&action0, &newaction,
A(newaction.button & MOUSE_BUTTON1DOWN,
action0.button & MOUSE_BUTTON3DOWN));
/* Send middle down */
newaction.button = MOUSE_BUTTON2DOWN;
r_click(&newaction);
/* Send middle up */
r_timestamp(&newaction);
newaction.obutton = newaction.button;
newaction.button = action0.button;
r_click(&newaction);
}
}
}
r_timestamp(&action0);
r_statetrans(&action0, &action,
A(action0.button & MOUSE_BUTTON1DOWN,
action0.button & MOUSE_BUTTON3DOWN));
debug("flags:%08x buttons:%08x obuttons:%08x", action.flags,
action.button, action.obutton);
}
action0.obutton = action0.button;
flags &= MOUSE_POSCHANGED;
flags |= action.obutton ^ action.button;
action.flags = flags;
if (flags) { /* handler detected action */
r_map(&action, &action2);
debug("activity : buttons 0x%08x dx %d dy %d dz %d",
action2.button, action2.dx, action2.dy, action2.dz);
if (rodent.flags & VirtualScroll) {
/*
* If *only* the middle button is pressed AND we are moving
* the stick/trackpoint/nipple, scroll!
*/
if (scroll_state == SCROLL_PREPARE) {
/* Ok, Set we're really scrolling now.... */
if (action2.dy || action2.dx)
scroll_state = SCROLL_SCROLLING;
}
if (scroll_state == SCROLL_SCROLLING) {
scroll_movement += action2.dy;
debug("SCROLL: %d", scroll_movement);
if (scroll_movement < -rodent.scrollthreshold) {
/* Scroll down */
action2.dz = -1;
scroll_movement = 0;
}
else if (scroll_movement > rodent.scrollthreshold) {
/* Scroll up */
action2.dz = 1;
scroll_movement = 0;
}
/* Don't move while scrolling */
action2.dx = action2.dy = 0;
}
}
if (extioctl) {
/* Defer clicks until we aren't VirtualScroll'ing. */
if (scroll_state == SCROLL_NOTSCROLLING)
r_click(&action2);
if (action2.flags & MOUSE_POSCHANGED) {
mouse.operation = MOUSE_MOTION_EVENT;
mouse.u.data.buttons = action2.button;
mouse.u.data.x = action2.dx * rodent.accelx;
mouse.u.data.y = action2.dy * rodent.accely;
mouse.u.data.z = action2.dz;
if (debug < 2)
ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
}
} else {
mouse.operation = MOUSE_ACTION;
mouse.u.data.buttons = action2.button;
mouse.u.data.x = action2.dx * rodent.accelx;
mouse.u.data.y = action2.dy * rodent.accely;
mouse.u.data.z = action2.dz;
if (debug < 2)
ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
}
/*
* If the Z axis movement is mapped to an imaginary physical
* button, we need to cook up a corresponding button `up' event
* after sending a button `down' event.
*/
if ((rodent.zmap[0] > 0) && (action.dz != 0)) {
action.obutton = action.button;
action.dx = action.dy = action.dz = 0;
r_map(&action, &action2);
debug("activity : buttons 0x%08x dx %d dy %d dz %d",
action2.button, action2.dx, action2.dy, action2.dz);
if (extioctl) {
r_click(&action2);
} else {
mouse.operation = MOUSE_ACTION;
mouse.u.data.buttons = action2.button;
mouse.u.data.x = mouse.u.data.y = mouse.u.data.z = 0;
if (debug < 2)
ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
}
}
}
}
/* NOT REACHED */
}
static void
hup(int sig)
{
longjmp(env, 1);
}
static void
cleanup(int sig)
{
if (rodent.rtype == MOUSE_PROTO_X10MOUSEREM)
unlink(_PATH_MOUSEREMOTE);
exit(0);
}
/**
** usage
**
** Complain, and free the CPU for more worthy tasks
**/
static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
" [-V [-U threshold]] [-a X [,Y]] [-C threshold] [-m N=M] [-w N]",
" [-z N] [-t <mousetype>] [-l level] [-3 [-E timeout]] -p <port>",
" moused [-d] -i <port|if|type|model|all> -p <port>");
exit(1);
}
/*
* Output an error message to syslog or stderr as appropriate. If
* `errnum' is non-zero, append its string form to the message.
*/
static void
log_or_warn(int log_pri, int errnum, const char *fmt, ...)
{
va_list ap;
char buf[256];
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (errnum) {
strlcat(buf, ": ", sizeof(buf));
strlcat(buf, strerror(errnum), sizeof(buf));
}
if (background)
syslog(log_pri, "%s", buf);
else
warnx("%s", buf);
}
/**
** Mouse interface code, courtesy of XFree86 3.1.2.
**
** Note: Various bits have been trimmed, and in my shortsighted enthusiasm
** to clean, reformat and rationalise naming, it's quite possible that
** some things in here have been broken.
**
** I hope not 8)
**
** The following code is derived from a module marked :
**/
/* $XConsortium: xf86_Mouse.c,v 1.2 94/10/12 20:33:21 kaleb Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86_Mouse.c,v 3.2 1995/01/28
17:03:40 dawes Exp $ */
/*
*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
* Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Thomas Roell and David Dawes not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. Thomas Roell
* and David Dawes makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY
* SPECIAL, 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.
*
*/
/**
** GlidePoint support from XFree86 3.2.
** Derived from the module:
**/
/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86_Mouse.c,v 3.19 1996/10/16 14:40:51 dawes Exp $ */
/* $XConsortium: xf86_Mouse.c /main/10 1996/01/30 15:16:12 kaleb $ */
/* the following table must be ordered by MOUSE_PROTO_XXX in mouse.h */
static unsigned char proto[][7] = {
/* hd_mask hd_id dp_mask dp_id bytes b4_mask b4_id */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x23, 0x00 }, /* MicroSoft */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* MouseSystems */
{ 0xe0, 0x80, 0x80, 0x00, 3, 0x00, 0xff }, /* Logitech */
{ 0xe0, 0x80, 0x80, 0x00, 3, 0x00, 0xff }, /* MMSeries */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x33, 0x00 }, /* MouseMan */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* Bus */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* InPort */
{ 0xc0, 0x00, 0x00, 0x00, 3, 0x00, 0xff }, /* PS/2 mouse */
{ 0xe0, 0x80, 0x80, 0x00, 3, 0x00, 0xff }, /* MM HitTablet */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x33, 0x00 }, /* GlidePoint */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x3f, 0x00 }, /* IntelliMouse */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x33, 0x00 }, /* ThinkingMouse */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* sysmouse */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x23, 0x00 }, /* X10 MouseRem */
{ 0x80, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* KIDSPAD */
{ 0xc3, 0xc0, 0x00, 0x00, 6, 0x00, 0xff }, /* VersaPad */
{ 0x00, 0x00, 0x00, 0x00, 1, 0x00, 0xff }, /* JogDial */
#if 0 /* not yet */
{ 0xf8, 0x80, 0x00, 0x00, 5, ~0x2f, 0x10 }, /* Mariqua */
#endif
};
static unsigned char cur_proto[7];
static int
r_identify(void)
{
char pnpbuf[256]; /* PnP identifier string may be up to 256 bytes long */
pnpid_t pnpid;
symtab_t *t;
int level;
int len;
/* set the driver operation level, if applicable */
if (rodent.level < 0)
rodent.level = 1;
ioctl(rodent.mfd, MOUSE_SETLEVEL, &rodent.level);
rodent.level = (ioctl(rodent.mfd, MOUSE_GETLEVEL, &level) == 0) ? level : 0;
/*
* Interrogate the driver and get some intelligence on the device...
* The following ioctl functions are not always supported by device
* drivers. When the driver doesn't support them, we just trust the
* user to supply valid information.
*/
rodent.hw.iftype = MOUSE_IF_UNKNOWN;
rodent.hw.model = MOUSE_MODEL_GENERIC;
ioctl(rodent.mfd, MOUSE_GETHWINFO, &rodent.hw);
if (rodent.rtype != MOUSE_PROTO_UNKNOWN)
bcopy(proto[rodent.rtype], cur_proto, sizeof(cur_proto));
rodent.mode.protocol = MOUSE_PROTO_UNKNOWN;
rodent.mode.rate = -1;
rodent.mode.resolution = MOUSE_RES_UNKNOWN;
rodent.mode.accelfactor = 0;
rodent.mode.level = 0;
if (ioctl(rodent.mfd, MOUSE_GETMODE, &rodent.mode) == 0) {
if ((rodent.mode.protocol == MOUSE_PROTO_UNKNOWN)
|| (rodent.mode.protocol >= NELEM(proto))) {
logwarnx("unknown mouse protocol (%d)", rodent.mode.protocol);
return MOUSE_PROTO_UNKNOWN;
} else {
/* INPORT and BUS are the same... */
if (rodent.mode.protocol == MOUSE_PROTO_INPORT)
rodent.mode.protocol = MOUSE_PROTO_BUS;
if (rodent.mode.protocol != rodent.rtype) {
/* Hmm, the driver doesn't agree with the user... */
if (rodent.rtype != MOUSE_PROTO_UNKNOWN)
logwarnx("mouse type mismatch (%s != %s), %s is assumed",
r_name(rodent.mode.protocol), r_name(rodent.rtype),
r_name(rodent.mode.protocol));
rodent.rtype = rodent.mode.protocol;
bcopy(proto[rodent.rtype], cur_proto, sizeof(cur_proto));
}
}
cur_proto[4] = rodent.mode.packetsize;
cur_proto[0] = rodent.mode.syncmask[0]; /* header byte bit mask */
cur_proto[1] = rodent.mode.syncmask[1]; /* header bit pattern */
}
/* maybe this is a PnP mouse... */
if (rodent.mode.protocol == MOUSE_PROTO_UNKNOWN) {
if (rodent.flags & NoPnP)
return rodent.rtype;
if (((len = pnpgets(pnpbuf)) <= 0) || !pnpparse(&pnpid, pnpbuf, len))
return rodent.rtype;
debug("PnP serial mouse: '%*.*s' '%*.*s' '%*.*s'",
pnpid.neisaid, pnpid.neisaid, pnpid.eisaid,
pnpid.ncompat, pnpid.ncompat, pnpid.compat,
pnpid.ndescription, pnpid.ndescription, pnpid.description);
/* we have a valid PnP serial device ID */
rodent.hw.iftype = MOUSE_IF_SERIAL;
t = pnpproto(&pnpid);
if (t != NULL) {
rodent.mode.protocol = t->val;
rodent.hw.model = t->val2;
} else {
rodent.mode.protocol = MOUSE_PROTO_UNKNOWN;
}
if (rodent.mode.protocol == MOUSE_PROTO_INPORT)
rodent.mode.protocol = MOUSE_PROTO_BUS;
/* make final adjustment */
if (rodent.mode.protocol != MOUSE_PROTO_UNKNOWN) {
if (rodent.mode.protocol != rodent.rtype) {
/* Hmm, the device doesn't agree with the user... */
if (rodent.rtype != MOUSE_PROTO_UNKNOWN)
logwarnx("mouse type mismatch (%s != %s), %s is assumed",
r_name(rodent.mode.protocol), r_name(rodent.rtype),
r_name(rodent.mode.protocol));
rodent.rtype = rodent.mode.protocol;
bcopy(proto[rodent.rtype], cur_proto, sizeof(cur_proto));
}
}
}
debug("proto params: %02x %02x %02x %02x %d %02x %02x",
cur_proto[0], cur_proto[1], cur_proto[2], cur_proto[3],
cur_proto[4], cur_proto[5], cur_proto[6]);
return rodent.rtype;
}
static char *
r_if(int iftype)
{
char *s;
s = gettokenname(rifs, iftype);
return (s == NULL) ? "unknown" : s;
}
static char *
r_name(int type)
{
return ((type == MOUSE_PROTO_UNKNOWN)
|| (type > NELEM(rnames) - 1))
? "unknown" : rnames[type];
}
static char *
r_model(int model)
{
char *s;
s = gettokenname(rmodels, model);
return (s == NULL) ? "unknown" : s;
}
static void
r_init(void)
{
unsigned char buf[16]; /* scrach buffer */
fd_set fds;
char *s;
char c;
int i;
/**
** This comment is a little out of context here, but it contains
** some useful information...
********************************************************************
**
** The following lines take care of the Logitech MouseMan protocols.
**
** NOTE: There are different versions of both MouseMan and TrackMan!
** Hence I add another protocol P_LOGIMAN, which the user can
** specify as MouseMan in his XF86Config file. This entry was
** formerly handled as a special case of P_MS. However, people
** who don't have the middle button problem, can still specify
** Microsoft and use P_MS.
**
** By default, these mice should use a 3 byte Microsoft protocol
** plus a 4th byte for the middle button. However, the mouse might
** have switched to a different protocol before we use it, so I send
** the proper sequence just in case.
**
** NOTE: - all commands to (at least the European) MouseMan have to
** be sent at 1200 Baud.
** - each command starts with a '*'.
** - whenever the MouseMan receives a '*', it will switch back
** to 1200 Baud. Hence I have to select the desired protocol
** first, then select the baud rate.
**
** The protocols supported by the (European) MouseMan are:
** - 5 byte packed binary protocol, as with the Mouse Systems
** mouse. Selected by sequence "*U".
** - 2 button 3 byte MicroSoft compatible protocol. Selected
** by sequence "*V".
** - 3 button 3+1 byte MicroSoft compatible protocol (default).
** Selected by sequence "*X".
**
** The following baud rates are supported:
** - 1200 Baud (default). Selected by sequence "*n".
** - 9600 Baud. Selected by sequence "*q".
**
** Selecting a sample rate is no longer supported with the MouseMan!
** Some additional lines in xf86Config.c take care of ill configured
** baud rates and sample rates. (The user will get an error.)
*/
switch (rodent.rtype) {
case MOUSE_PROTO_LOGI:
/*
* The baud rate selection command must be sent at the current
* baud rate; try all likely settings
*/
setmousespeed(9600, rodent.baudrate, rodentcflags[rodent.rtype]);
setmousespeed(4800, rodent.baudrate, rodentcflags[rodent.rtype]);
setmousespeed(2400, rodent.baudrate, rodentcflags[rodent.rtype]);
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
/* select MM series data format */
write(rodent.mfd, "S", 1);
setmousespeed(rodent.baudrate, rodent.baudrate,
rodentcflags[MOUSE_PROTO_MM]);
/* select report rate/frequency */
if (rodent.rate <= 0) write(rodent.mfd, "O", 1);
else if (rodent.rate <= 15) write(rodent.mfd, "J", 1);
else if (rodent.rate <= 27) write(rodent.mfd, "K", 1);
else if (rodent.rate <= 42) write(rodent.mfd, "L", 1);
else if (rodent.rate <= 60) write(rodent.mfd, "R", 1);
else if (rodent.rate <= 85) write(rodent.mfd, "M", 1);
else if (rodent.rate <= 125) write(rodent.mfd, "Q", 1);
else write(rodent.mfd, "N", 1);
break;
case MOUSE_PROTO_LOGIMOUSEMAN:
/* The command must always be sent at 1200 baud */
setmousespeed(1200, 1200, rodentcflags[rodent.rtype]);
write(rodent.mfd, "*X", 2);
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
break;
case MOUSE_PROTO_HITTAB:
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
/*
* Initialize Hitachi PUMA Plus - Model 1212E to desired settings.
* The tablet must be configured to be in MM mode, NO parity,
* Binary Format. xf86Info.sampleRate controls the sensativity
* of the tablet. We only use this tablet for it's 4-button puck
* so we don't run in "Absolute Mode"
*/
write(rodent.mfd, "z8", 2); /* Set Parity = "NONE" */
usleep(50000);
write(rodent.mfd, "zb", 2); /* Set Format = "Binary" */
usleep(50000);
write(rodent.mfd, "@", 1); /* Set Report Mode = "Stream" */
usleep(50000);
write(rodent.mfd, "R", 1); /* Set Output Rate = "45 rps" */
usleep(50000);
write(rodent.mfd, "I\x20", 2); /* Set Incrememtal Mode "20" */
usleep(50000);
write(rodent.mfd, "E", 1); /* Set Data Type = "Relative */
usleep(50000);
/* Resolution is in 'lines per inch' on the Hitachi tablet */
if (rodent.resolution == MOUSE_RES_LOW) c = 'g';
else if (rodent.resolution == MOUSE_RES_MEDIUMLOW) c = 'e';
else if (rodent.resolution == MOUSE_RES_MEDIUMHIGH) c = 'h';
else if (rodent.resolution == MOUSE_RES_HIGH) c = 'd';
else if (rodent.resolution <= 40) c = 'g';
else if (rodent.resolution <= 100) c = 'd';
else if (rodent.resolution <= 200) c = 'e';
else if (rodent.resolution <= 500) c = 'h';
else if (rodent.resolution <= 1000) c = 'j';
else c = 'd';
write(rodent.mfd, &c, 1);
usleep(50000);
write(rodent.mfd, "\021", 1); /* Resume DATA output */
break;
case MOUSE_PROTO_THINK:
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
/* the PnP ID string may be sent again, discard it */
usleep(200000);
i = FREAD;
ioctl(rodent.mfd, TIOCFLUSH, &i);
/* send the command to initialize the beast */
for (s = "E5E5"; *s; ++s) {
write(rodent.mfd, s, 1);
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
if (select(FD_SETSIZE, &fds, NULL, NULL, NULL) <= 0)
break;
read(rodent.mfd, &c, 1);
debug("%c", c);
if (c != *s)
break;
}
break;
case MOUSE_PROTO_JOGDIAL:
break;
case MOUSE_PROTO_MSC:
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
if (rodent.flags & ClearDTR) {
i = TIOCM_DTR;
ioctl(rodent.mfd, TIOCMBIC, &i);
}
if (rodent.flags & ClearRTS) {
i = TIOCM_RTS;
ioctl(rodent.mfd, TIOCMBIC, &i);
}
break;
case MOUSE_PROTO_SYSMOUSE:
if (rodent.hw.iftype == MOUSE_IF_SYSMOUSE)
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
/* FALLTHROUGH */
case MOUSE_PROTO_BUS:
case MOUSE_PROTO_INPORT:
case MOUSE_PROTO_PS2:
if (rodent.rate >= 0)
rodent.mode.rate = rodent.rate;
if (rodent.resolution != MOUSE_RES_UNKNOWN)
rodent.mode.resolution = rodent.resolution;
ioctl(rodent.mfd, MOUSE_SETMODE, &rodent.mode);
break;
case MOUSE_PROTO_X10MOUSEREM:
mremote_serversetup();
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
break;
case MOUSE_PROTO_VERSAPAD:
tcsendbreak(rodent.mfd, 0); /* send break for 400 msec */
i = FREAD;
ioctl(rodent.mfd, TIOCFLUSH, &i);
for (i = 0; i < 7; ++i) {
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
if (select(FD_SETSIZE, &fds, NULL, NULL, NULL) <= 0)
break;
read(rodent.mfd, &c, 1);
buf[i] = c;
}
debug("%s\n", buf);
if ((buf[0] != 'V') || (buf[1] != 'P')|| (buf[7] != '\r'))
break;
setmousespeed(9600, rodent.baudrate, rodentcflags[rodent.rtype]);
tcsendbreak(rodent.mfd, 0); /* send break for 400 msec again */
for (i = 0; i < 7; ++i) {
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
if (select(FD_SETSIZE, &fds, NULL, NULL, NULL) <= 0)
break;
read(rodent.mfd, &c, 1);
debug("%c", c);
if (c != buf[i])
break;
}
i = FREAD;
ioctl(rodent.mfd, TIOCFLUSH, &i);
break;
default:
setmousespeed(1200, rodent.baudrate, rodentcflags[rodent.rtype]);
break;
}
}
static int
r_protocol(u_char rBuf, mousestatus_t *act)
{
/* MOUSE_MSS_BUTTON?DOWN -> MOUSE_BUTTON?DOWN */
static int butmapmss[4] = { /* Microsoft, MouseMan, GlidePoint,
IntelliMouse, Thinking Mouse */
0,
MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
};
static int butmapmss2[4] = { /* Microsoft, MouseMan, GlidePoint,
Thinking Mouse */
0,
MOUSE_BUTTON4DOWN,
MOUSE_BUTTON2DOWN,
MOUSE_BUTTON2DOWN | MOUSE_BUTTON4DOWN,
};
/* MOUSE_INTELLI_BUTTON?DOWN -> MOUSE_BUTTON?DOWN */
static int butmapintelli[4] = { /* IntelliMouse, NetMouse, Mie Mouse,
MouseMan+ */
0,
MOUSE_BUTTON2DOWN,
MOUSE_BUTTON4DOWN,
MOUSE_BUTTON2DOWN | MOUSE_BUTTON4DOWN,
};
/* MOUSE_MSC_BUTTON?UP -> MOUSE_BUTTON?DOWN */
static int butmapmsc[8] = { /* MouseSystems, MMSeries, Logitech,
Bus, sysmouse */
0,
MOUSE_BUTTON3DOWN,
MOUSE_BUTTON2DOWN,
MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN
};
/* MOUSE_PS2_BUTTON?DOWN -> MOUSE_BUTTON?DOWN */
static int butmapps2[8] = { /* PS/2 */
0,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
MOUSE_BUTTON2DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN,
MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN
};
/* for Hitachi tablet */
static int butmaphit[8] = { /* MM HitTablet */
0,
MOUSE_BUTTON3DOWN,
MOUSE_BUTTON2DOWN,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON4DOWN,
MOUSE_BUTTON5DOWN,
MOUSE_BUTTON6DOWN,
MOUSE_BUTTON7DOWN,
};
/* for serial VersaPad */
static int butmapversa[8] = { /* VersaPad */
0,
0,
MOUSE_BUTTON3DOWN,
MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
};
/* for PS/2 VersaPad */
static int butmapversaps2[8] = { /* VersaPad */
0,
MOUSE_BUTTON3DOWN,
0,
MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
MOUSE_BUTTON1DOWN,
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
};
static int pBufP = 0;
static unsigned char pBuf[8];
static int prev_x, prev_y;
static int on = FALSE;
int x, y;
debug("received char 0x%x",(int)rBuf);
if (rodent.rtype == MOUSE_PROTO_KIDSPAD)
return kidspad(rBuf, act) ;
/*
* Hack for resyncing: We check here for a package that is:
* a) illegal (detected by wrong data-package header)
* b) invalid (0x80 == -128 and that might be wrong for MouseSystems)
* c) bad header-package
*
* NOTE: b) is a voilation of the MouseSystems-Protocol, since values of
* -128 are allowed, but since they are very seldom we can easily
* use them as package-header with no button pressed.
* NOTE/2: On a PS/2 mouse any byte is valid as a data byte. Furthermore,
* 0x80 is not valid as a header byte. For a PS/2 mouse we skip
* checking data bytes.
* For resyncing a PS/2 mouse we require the two most significant
* bits in the header byte to be 0. These are the overflow bits,
* and in case of an overflow we actually lose sync. Overflows
* are very rare, however, and we quickly gain sync again after
* an overflow condition. This is the best we can do. (Actually,
* we could use bit 0x08 in the header byte for resyncing, since
* that bit is supposed to be always on, but nobody told
* Microsoft...)
*/
if (pBufP != 0 && rodent.rtype != MOUSE_PROTO_PS2 &&
((rBuf & cur_proto[2]) != cur_proto[3] || rBuf == 0x80))
{
pBufP = 0; /* skip package */
}
if (pBufP == 0 && (rBuf & cur_proto[0]) != cur_proto[1])
return 0;
/* is there an extra data byte? */
if (pBufP >= cur_proto[4] && (rBuf & cur_proto[0]) != cur_proto[1])
{
/*
* Hack for Logitech MouseMan Mouse - Middle button
*
* Unfortunately this mouse has variable length packets: the standard
* Microsoft 3 byte packet plus an optional 4th byte whenever the
* middle button status changes.
*
* We have already processed the standard packet with the movement
* and button info. Now post an event message with the old status
* of the left and right buttons and the updated middle button.
*/
/*
* Even worse, different MouseMen and TrackMen differ in the 4th
* byte: some will send 0x00/0x20, others 0x01/0x21, or even
* 0x02/0x22, so I have to strip off the lower bits.
*
* [JCH-96/01/21]
* HACK for ALPS "fourth button". (It's bit 0x10 of the "fourth byte"
* and it is activated by tapping the glidepad with the finger! 8^)
* We map it to bit bit3, and the reverse map in xf86Events just has
* to be extended so that it is identified as Button 4. The lower
* half of the reverse-map may remain unchanged.
*/
/*
* [KY-97/08/03]
* Receive the fourth byte only when preceding three bytes have
* been detected (pBufP >= cur_proto[4]). In the previous
* versions, the test was pBufP == 0; thus, we may have mistakingly
* received a byte even if we didn't see anything preceding
* the byte.
*/
if ((rBuf & cur_proto[5]) != cur_proto[6]) {
pBufP = 0;
return 0;
}
switch (rodent.rtype) {
#if 0 /* not yet */
case MOUSE_PROTO_MARIQUA:
/*
* This mouse has 16! buttons in addition to the standard
* three of them. They return 0x10 though 0x1f in the
* so-called `ten key' mode and 0x30 though 0x3f in the
* `function key' mode. As there are only 31 bits for
* button state (including the standard three), we ignore
* the bit 0x20 and don't distinguish the two modes.
*/
act->dx = act->dy = act->dz = 0;
act->obutton = act->button;
rBuf &= 0x1f;
act->button = (1 << (rBuf - 13))
| (act->obutton & (MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN));
/*
* FIXME: this is a button "down" event. There needs to be
* a corresponding button "up" event... XXX
*/
break;
#endif /* notyet */
case MOUSE_PROTO_JOGDIAL:
break;
/*
* IntelliMouse, NetMouse (including NetMouse Pro) and Mie Mouse
* always send the fourth byte, whereas the fourth byte is
* optional for GlidePoint and ThinkingMouse. The fourth byte
* is also optional for MouseMan+ and FirstMouse+ in their
* native mode. It is always sent if they are in the IntelliMouse
* compatible mode.
*/
case MOUSE_PROTO_INTELLI: /* IntelliMouse, NetMouse, Mie Mouse,
MouseMan+ */
act->dx = act->dy = 0;
act->dz = (rBuf & 0x08) ? (rBuf & 0x0f) - 16 : (rBuf & 0x0f);
if ((act->dz >= 7) || (act->dz <= -7))
act->dz = 0;
act->obutton = act->button;
act->button = butmapintelli[(rBuf & MOUSE_MSS_BUTTONS) >> 4]
| (act->obutton & (MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN));
break;
default:
act->dx = act->dy = act->dz = 0;
act->obutton = act->button;
act->button = butmapmss2[(rBuf & MOUSE_MSS_BUTTONS) >> 4]
| (act->obutton & (MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN));
break;
}
act->flags = ((act->dx || act->dy || act->dz) ? MOUSE_POSCHANGED : 0)
| (act->obutton ^ act->button);
pBufP = 0;
return act->flags;
}
if (pBufP >= cur_proto[4])
pBufP = 0;
pBuf[pBufP++] = rBuf;
if (pBufP != cur_proto[4])
return 0;
/*
* assembly full package
*/
debug("assembled full packet (len %d) %x,%x,%x,%x,%x,%x,%x,%x",
cur_proto[4],
pBuf[0], pBuf[1], pBuf[2], pBuf[3],
pBuf[4], pBuf[5], pBuf[6], pBuf[7]);
act->dz = 0;
act->obutton = act->button;
switch (rodent.rtype)
{
case MOUSE_PROTO_MS: /* Microsoft */
case MOUSE_PROTO_LOGIMOUSEMAN: /* MouseMan/TrackMan */
case MOUSE_PROTO_X10MOUSEREM: /* X10 MouseRemote */
act->button = act->obutton & MOUSE_BUTTON4DOWN;
if (rodent.flags & ChordMiddle)
act->button |= ((pBuf[0] & MOUSE_MSS_BUTTONS) == MOUSE_MSS_BUTTONS)
? MOUSE_BUTTON2DOWN
: butmapmss[(pBuf[0] & MOUSE_MSS_BUTTONS) >> 4];
else
act->button |= (act->obutton & MOUSE_BUTTON2DOWN)
| butmapmss[(pBuf[0] & MOUSE_MSS_BUTTONS) >> 4];
/* Send X10 btn events to remote client (ensure -128-+127 range) */
if ((rodent.rtype == MOUSE_PROTO_X10MOUSEREM) &&
((pBuf[0] & 0xFC) == 0x44) && (pBuf[2] == 0x3F)) {
if (rodent.mremcfd >= 0) {
unsigned char key = (signed char)(((pBuf[0] & 0x03) << 6) |
(pBuf[1] & 0x3F));
write(rodent.mremcfd, &key, 1);
}
return 0;
}
act->dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
act->dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
break;
case MOUSE_PROTO_GLIDEPOINT: /* GlidePoint */
case MOUSE_PROTO_THINK: /* ThinkingMouse */
case MOUSE_PROTO_INTELLI: /* IntelliMouse, NetMouse, Mie Mouse,
MouseMan+ */
act->button = (act->obutton & (MOUSE_BUTTON2DOWN | MOUSE_BUTTON4DOWN))
| butmapmss[(pBuf[0] & MOUSE_MSS_BUTTONS) >> 4];
act->dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
act->dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
break;
case MOUSE_PROTO_MSC: /* MouseSystems Corp */
#if 0 /* not yet */
case MOUSE_PROTO_MARIQUA: /* Mariqua */
#endif
act->button = butmapmsc[(~pBuf[0]) & MOUSE_MSC_BUTTONS];
act->dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]);
act->dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4]));
break;
case MOUSE_PROTO_JOGDIAL: /* JogDial */
if (rBuf == 0x6c)
act->dz = -1;
if (rBuf == 0x72)
act->dz = 1;
if (rBuf == 0x64)
act->button = MOUSE_BUTTON1DOWN;
if (rBuf == 0x75)
act->button = 0;
break;
case MOUSE_PROTO_HITTAB: /* MM HitTablet */
act->button = butmaphit[pBuf[0] & 0x07];
act->dx = (pBuf[0] & MOUSE_MM_XPOSITIVE) ? pBuf[1] : - pBuf[1];
act->dy = (pBuf[0] & MOUSE_MM_YPOSITIVE) ? - pBuf[2] : pBuf[2];
break;
case MOUSE_PROTO_MM: /* MM Series */
case MOUSE_PROTO_LOGI: /* Logitech Mice */
act->button = butmapmsc[pBuf[0] & MOUSE_MSC_BUTTONS];
act->dx = (pBuf[0] & MOUSE_MM_XPOSITIVE) ? pBuf[1] : - pBuf[1];
act->dy = (pBuf[0] & MOUSE_MM_YPOSITIVE) ? - pBuf[2] : pBuf[2];
break;
case MOUSE_PROTO_VERSAPAD: /* VersaPad */
act->button = butmapversa[(pBuf[0] & MOUSE_VERSA_BUTTONS) >> 3];
act->button |= (pBuf[0] & MOUSE_VERSA_TAP) ? MOUSE_BUTTON4DOWN : 0;
act->dx = act->dy = 0;
if (!(pBuf[0] & MOUSE_VERSA_IN_USE)) {
on = FALSE;
break;
}
x = (pBuf[2] << 6) | pBuf[1];
if (x & 0x800)
x -= 0x1000;
y = (pBuf[4] << 6) | pBuf[3];
if (y & 0x800)
y -= 0x1000;
if (on) {
act->dx = prev_x - x;
act->dy = prev_y - y;
} else {
on = TRUE;
}
prev_x = x;
prev_y = y;
break;
case MOUSE_PROTO_BUS: /* Bus */
case MOUSE_PROTO_INPORT: /* InPort */
act->button = butmapmsc[(~pBuf[0]) & MOUSE_MSC_BUTTONS];
act->dx = (signed char)pBuf[1];
act->dy = - (signed char)pBuf[2];
break;
case MOUSE_PROTO_PS2: /* PS/2 */
act->button = butmapps2[pBuf[0] & MOUSE_PS2_BUTTONS];
act->dx = (pBuf[0] & MOUSE_PS2_XNEG) ? pBuf[1] - 256 : pBuf[1];
act->dy = (pBuf[0] & MOUSE_PS2_YNEG) ? -(pBuf[2] - 256) : -pBuf[2];
/*
* Moused usually operates the psm driver at the operation level 1
* which sends mouse data in MOUSE_PROTO_SYSMOUSE protocol.
* The following code takes effect only when the user explicitly
* requets the level 2 at which wheel movement and additional button
* actions are encoded in model-dependent formats. At the level 0
* the following code is no-op because the psm driver says the model
* is MOUSE_MODEL_GENERIC.
*/
switch (rodent.hw.model) {
case MOUSE_MODEL_EXPLORER:
/* wheel and additional button data is in the fourth byte */
act->dz = (pBuf[3] & MOUSE_EXPLORER_ZNEG)
? (pBuf[3] & 0x0f) - 16 : (pBuf[3] & 0x0f);
act->button |= (pBuf[3] & MOUSE_EXPLORER_BUTTON4DOWN)
? MOUSE_BUTTON4DOWN : 0;
act->button |= (pBuf[3] & MOUSE_EXPLORER_BUTTON5DOWN)
? MOUSE_BUTTON5DOWN : 0;
break;
case MOUSE_MODEL_INTELLI:
case MOUSE_MODEL_NET:
/* wheel data is in the fourth byte */
act->dz = (signed char)pBuf[3];
if ((act->dz >= 7) || (act->dz <= -7))
act->dz = 0;
/* some compatible mice may have additional buttons */
act->button |= (pBuf[0] & MOUSE_PS2INTELLI_BUTTON4DOWN)
? MOUSE_BUTTON4DOWN : 0;
act->button |= (pBuf[0] & MOUSE_PS2INTELLI_BUTTON5DOWN)
? MOUSE_BUTTON5DOWN : 0;
break;
case MOUSE_MODEL_MOUSEMANPLUS:
if (((pBuf[0] & MOUSE_PS2PLUS_SYNCMASK) == MOUSE_PS2PLUS_SYNC)
&& (abs(act->dx) > 191)
&& MOUSE_PS2PLUS_CHECKBITS(pBuf)) {
/* the extended data packet encodes button and wheel events */
switch (MOUSE_PS2PLUS_PACKET_TYPE(pBuf)) {
case 1:
/* wheel data packet */
act->dx = act->dy = 0;
if (pBuf[2] & 0x80) {
/* horizontal roller count - ignore it XXX*/
} else {
/* vertical roller count */
act->dz = (pBuf[2] & MOUSE_PS2PLUS_ZNEG)
? (pBuf[2] & 0x0f) - 16 : (pBuf[2] & 0x0f);
}
act->button |= (pBuf[2] & MOUSE_PS2PLUS_BUTTON4DOWN)
? MOUSE_BUTTON4DOWN : 0;
act->button |= (pBuf[2] & MOUSE_PS2PLUS_BUTTON5DOWN)
? MOUSE_BUTTON5DOWN : 0;
break;
case 2:
/* this packet type is reserved by Logitech */
/*
* IBM ScrollPoint Mouse uses this packet type to
* encode both vertical and horizontal scroll movement.
*/
act->dx = act->dy = 0;
/* horizontal roller count */
if (pBuf[2] & 0x0f)
act->dz = (pBuf[2] & MOUSE_SPOINT_WNEG) ? -2 : 2;
/* vertical roller count */
if (pBuf[2] & 0xf0)
act->dz = (pBuf[2] & MOUSE_SPOINT_ZNEG) ? -1 : 1;
#if 0
/* vertical roller count */
act->dz = (pBuf[2] & MOUSE_SPOINT_ZNEG)
? ((pBuf[2] >> 4) & 0x0f) - 16
: ((pBuf[2] >> 4) & 0x0f);
/* horizontal roller count */
act->dw = (pBuf[2] & MOUSE_SPOINT_WNEG)
? (pBuf[2] & 0x0f) - 16 : (pBuf[2] & 0x0f);
#endif
break;
case 0:
/* device type packet - shouldn't happen */
/* FALLTHROUGH */
default:
act->dx = act->dy = 0;
act->button = act->obutton;
debug("unknown PS2++ packet type %d: 0x%02x 0x%02x 0x%02x\n",
MOUSE_PS2PLUS_PACKET_TYPE(pBuf),
pBuf[0], pBuf[1], pBuf[2]);
break;
}
} else {
/* preserve button states */
act->button |= act->obutton & MOUSE_EXTBUTTONS;
}
break;
case MOUSE_MODEL_GLIDEPOINT:
/* `tapping' action */
act->button |= ((pBuf[0] & MOUSE_PS2_TAP)) ? 0 : MOUSE_BUTTON4DOWN;
break;
case MOUSE_MODEL_NETSCROLL:
/* three addtional bytes encode buttons and wheel events */
act->button |= (pBuf[3] & MOUSE_PS2_BUTTON3DOWN)
? MOUSE_BUTTON4DOWN : 0;
act->button |= (pBuf[3] & MOUSE_PS2_BUTTON1DOWN)
? MOUSE_BUTTON5DOWN : 0;
act->dz = (pBuf[3] & MOUSE_PS2_XNEG) ? pBuf[4] - 256 : pBuf[4];
break;
case MOUSE_MODEL_THINK:
/* the fourth button state in the first byte */
act->button |= (pBuf[0] & MOUSE_PS2_TAP) ? MOUSE_BUTTON4DOWN : 0;
break;
case MOUSE_MODEL_VERSAPAD:
act->button = butmapversaps2[pBuf[0] & MOUSE_PS2VERSA_BUTTONS];
act->button |=
(pBuf[0] & MOUSE_PS2VERSA_TAP) ? MOUSE_BUTTON4DOWN : 0;
act->dx = act->dy = 0;
if (!(pBuf[0] & MOUSE_PS2VERSA_IN_USE)) {
on = FALSE;
break;
}
x = ((pBuf[4] << 8) & 0xf00) | pBuf[1];
if (x & 0x800)
x -= 0x1000;
y = ((pBuf[4] << 4) & 0xf00) | pBuf[2];
if (y & 0x800)
y -= 0x1000;
if (on) {
act->dx = prev_x - x;
act->dy = prev_y - y;
} else {
on = TRUE;
}
prev_x = x;
prev_y = y;
break;
case MOUSE_MODEL_4D:
act->dx = (pBuf[1] & 0x80) ? pBuf[1] - 256 : pBuf[1];
act->dy = (pBuf[2] & 0x80) ? -(pBuf[2] - 256) : -pBuf[2];
switch (pBuf[0] & MOUSE_4D_WHEELBITS) {
case 0x10:
act->dz = 1;
break;
case 0x30:
act->dz = -1;
break;
case 0x40: /* 2nd wheel rolling right XXX */
act->dz = 2;
break;
case 0xc0: /* 2nd wheel rolling left XXX */
act->dz = -2;
break;
}
break;
case MOUSE_MODEL_4DPLUS:
if ((act->dx < 16 - 256) && (act->dy > 256 - 16)) {
act->dx = act->dy = 0;
if (pBuf[2] & MOUSE_4DPLUS_BUTTON4DOWN)
act->button |= MOUSE_BUTTON4DOWN;
act->dz = (pBuf[2] & MOUSE_4DPLUS_ZNEG)
? ((pBuf[2] & 0x07) - 8) : (pBuf[2] & 0x07);
} else {
/* preserve previous button states */
act->button |= act->obutton & MOUSE_EXTBUTTONS;
}
break;
case MOUSE_MODEL_GENERIC:
default:
break;
}
break;
case MOUSE_PROTO_SYSMOUSE: /* sysmouse */
act->button = butmapmsc[(~pBuf[0]) & MOUSE_SYS_STDBUTTONS];
act->dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]);
act->dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4]));
if (rodent.level == 1) {
act->dz = ((signed char)(pBuf[5] << 1) + (signed char)(pBuf[6] << 1)) >> 1;
act->button |= ((~pBuf[7] & MOUSE_SYS_EXTBUTTONS) << 3);
}
break;
default:
return 0;
}
/*
* We don't reset pBufP here yet, as there may be an additional data
* byte in some protocols. See above.
*/
/* has something changed? */
act->flags = ((act->dx || act->dy || act->dz) ? MOUSE_POSCHANGED : 0)
| (act->obutton ^ act->button);
return act->flags;
}
static int
r_statetrans(mousestatus_t *a1, mousestatus_t *a2, int trans)
{
int changed;
int flags;
a2->dx = a1->dx;
a2->dy = a1->dy;
a2->dz = a1->dz;
a2->obutton = a2->button;
a2->button = a1->button;
a2->flags = a1->flags;
changed = FALSE;
if (rodent.flags & Emulate3Button) {
if (debug > 2)
debug("state:%d, trans:%d -> state:%d",
mouse_button_state, trans,
states[mouse_button_state].s[trans]);
/*
* Avoid re-ordering button and movement events. While a button
* event is deferred, throw away up to BUTTON2_MAXMOVE movement
* events to allow for mouse jitter. If more movement events
* occur, then complete the deferred button events immediately.
*/
if ((a2->dx != 0 || a2->dy != 0) &&
S_DELAYED(states[mouse_button_state].s[trans])) {
if (++mouse_move_delayed > BUTTON2_MAXMOVE) {
mouse_move_delayed = 0;
mouse_button_state =
states[mouse_button_state].s[A_TIMEOUT];
changed = TRUE;
} else
a2->dx = a2->dy = 0;
} else
mouse_move_delayed = 0;
if (mouse_button_state != states[mouse_button_state].s[trans])
changed = TRUE;
if (changed)
gettimeofday(&mouse_button_state_tv, NULL);
mouse_button_state = states[mouse_button_state].s[trans];
a2->button &=
~(MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN);
a2->button &= states[mouse_button_state].mask;
a2->button |= states[mouse_button_state].buttons;
flags = a2->flags & MOUSE_POSCHANGED;
flags |= a2->obutton ^ a2->button;
if (flags & MOUSE_BUTTON2DOWN) {
a2->flags = flags & MOUSE_BUTTON2DOWN;
r_timestamp(a2);
}
a2->flags = flags;
}
return changed;
}
/* phisical to logical button mapping */
static int p2l[MOUSE_MAXBUTTON] = {
MOUSE_BUTTON1DOWN, MOUSE_BUTTON2DOWN, MOUSE_BUTTON3DOWN, MOUSE_BUTTON4DOWN,
MOUSE_BUTTON5DOWN, MOUSE_BUTTON6DOWN, MOUSE_BUTTON7DOWN, MOUSE_BUTTON8DOWN,
0x00000100, 0x00000200, 0x00000400, 0x00000800,
0x00001000, 0x00002000, 0x00004000, 0x00008000,
0x00010000, 0x00020000, 0x00040000, 0x00080000,
0x00100000, 0x00200000, 0x00400000, 0x00800000,
0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000,
};
static char *
skipspace(char *s)
{
while(isspace(*s))
++s;
return s;
}
static int
r_installmap(char *arg)
{
int pbutton;
int lbutton;
char *s;
while (*arg) {
arg = skipspace(arg);
s = arg;
while (isdigit(*arg))
++arg;
arg = skipspace(arg);
if ((arg <= s) || (*arg != '='))
return FALSE;
lbutton = atoi(s);
arg = skipspace(++arg);
s = arg;
while (isdigit(*arg))
++arg;
if ((arg <= s) || (!isspace(*arg) && (*arg != '\0')))
return FALSE;
pbutton = atoi(s);
if ((lbutton <= 0) || (lbutton > MOUSE_MAXBUTTON))
return FALSE;
if ((pbutton <= 0) || (pbutton > MOUSE_MAXBUTTON))
return FALSE;
p2l[pbutton - 1] = 1 << (lbutton - 1);
mstate[lbutton - 1] = &bstate[pbutton - 1];
}
return TRUE;
}
static void
r_map(mousestatus_t *act1, mousestatus_t *act2)
{
register int pb;
register int pbuttons;
int lbuttons;
pbuttons = act1->button;
lbuttons = 0;
act2->obutton = act2->button;
if (pbuttons & rodent.wmode) {
pbuttons &= ~rodent.wmode;
act1->dz = act1->dy;
act1->dx = 0;
act1->dy = 0;
}
act2->dx = act1->dx;
act2->dy = act1->dy;
act2->dz = act1->dz;
switch (rodent.zmap[0]) {
case 0: /* do nothing */
break;
case MOUSE_XAXIS:
if (act1->dz != 0) {
act2->dx = act1->dz;
act2->dz = 0;
}
break;
case MOUSE_YAXIS:
if (act1->dz != 0) {
act2->dy = act1->dz;
act2->dz = 0;
}
break;
default: /* buttons */
pbuttons &= ~(rodent.zmap[0] | rodent.zmap[1]
| rodent.zmap[2] | rodent.zmap[3]);
if ((act1->dz < -1) && rodent.zmap[2]) {
pbuttons |= rodent.zmap[2];
zstate[2].count = 1;
} else if (act1->dz < 0) {
pbuttons |= rodent.zmap[0];
zstate[0].count = 1;
} else if ((act1->dz > 1) && rodent.zmap[3]) {
pbuttons |= rodent.zmap[3];
zstate[3].count = 1;
} else if (act1->dz > 0) {
pbuttons |= rodent.zmap[1];
zstate[1].count = 1;
}
act2->dz = 0;
break;
}
for (pb = 0; (pb < MOUSE_MAXBUTTON) && (pbuttons != 0); ++pb) {
lbuttons |= (pbuttons & 1) ? p2l[pb] : 0;
pbuttons >>= 1;
}
act2->button = lbuttons;
act2->flags = ((act2->dx || act2->dy || act2->dz) ? MOUSE_POSCHANGED : 0)
| (act2->obutton ^ act2->button);
}
static void
r_timestamp(mousestatus_t *act)
{
struct timeval tv;
struct timeval tv1;
struct timeval tv2;
struct timeval tv3;
int button;
int mask;
int i;
mask = act->flags & MOUSE_BUTTONS;
if (mask == 0)
return;
gettimeofday(&tv1, NULL);
/* double click threshold */
tv2.tv_sec = rodent.clickthreshold/1000;
tv2.tv_usec = (rodent.clickthreshold%1000)*1000;
timersub(&tv1, &tv2, &tv);
debug("tv: %ld %ld", tv.tv_sec, tv.tv_usec);
/* 3 button emulation timeout */
tv2.tv_sec = rodent.button2timeout/1000;
tv2.tv_usec = (rodent.button2timeout%1000)*1000;
timersub(&tv1, &tv2, &tv3);
button = MOUSE_BUTTON1DOWN;
for (i = 0; (i < MOUSE_MAXBUTTON) && (mask != 0); ++i) {
if (mask & 1) {
if (act->button & button) {
/* the button is down */
debug(" : %ld %ld",
bstate[i].tv.tv_sec, bstate[i].tv.tv_usec);
if (timercmp(&tv, &bstate[i].tv, >)) {
bstate[i].count = 1;
} else {
++bstate[i].count;
}
bstate[i].tv = tv1;
} else {
/* the button is up */
bstate[i].tv = tv1;
}
} else {
if (act->button & button) {
/* the button has been down */
if (timercmp(&tv3, &bstate[i].tv, >)) {
bstate[i].count = 1;
bstate[i].tv = tv1;
act->flags |= button;
debug("button %d timeout", i + 1);
}
} else {
/* the button has been up */
}
}
button <<= 1;
mask >>= 1;
}
}
static int
r_timeout(void)
{
struct timeval tv;
struct timeval tv1;
struct timeval tv2;
if (states[mouse_button_state].timeout)
return TRUE;
gettimeofday(&tv1, NULL);
tv2.tv_sec = rodent.button2timeout/1000;
tv2.tv_usec = (rodent.button2timeout%1000)*1000;
timersub(&tv1, &tv2, &tv);
return timercmp(&tv, &mouse_button_state_tv, >);
}
static void
r_click(mousestatus_t *act)
{
struct mouse_info mouse;
int button;
int mask;
int i;
mask = act->flags & MOUSE_BUTTONS;
if (mask == 0)
return;
button = MOUSE_BUTTON1DOWN;
for (i = 0; (i < MOUSE_MAXBUTTON) && (mask != 0); ++i) {
if (mask & 1) {
debug("mstate[%d]->count:%d", i, mstate[i]->count);
if (act->button & button) {
/* the button is down */
mouse.u.event.value = mstate[i]->count;
} else {
/* the button is up */
mouse.u.event.value = 0;
}
mouse.operation = MOUSE_BUTTON_EVENT;
mouse.u.event.id = button;
if (debug < 2)
ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
debug("button %d count %d", i + 1, mouse.u.event.value);
}
button <<= 1;
mask >>= 1;
}
}
/* $XConsortium: posix_tty.c,v 1.3 95/01/05 20:42:55 kaleb Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.4 1995/01/28 17:05:03 dawes Exp $ */
/*
* Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of David Dawes
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission.
* David Dawes makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL DAVID DAWES BE LIABLE FOR
* ANY SPECIAL, 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.
*
*/
static void
setmousespeed(int old, int new, unsigned cflag)
{
struct termios tty;
char *c;
if (tcgetattr(rodent.mfd, &tty) < 0)
{
logwarn("unable to get status of mouse fd");
return;
}
tty.c_iflag = IGNBRK | IGNPAR;
tty.c_oflag = 0;
tty.c_lflag = 0;
tty.c_cflag = (tcflag_t)cflag;
tty.c_cc[VTIME] = 0;
tty.c_cc[VMIN] = 1;
switch (old)
{
case 9600:
cfsetispeed(&tty, B9600);
cfsetospeed(&tty, B9600);
break;
case 4800:
cfsetispeed(&tty, B4800);
cfsetospeed(&tty, B4800);
break;
case 2400:
cfsetispeed(&tty, B2400);
cfsetospeed(&tty, B2400);
break;
case 1200:
default:
cfsetispeed(&tty, B1200);
cfsetospeed(&tty, B1200);
}
if (tcsetattr(rodent.mfd, TCSADRAIN, &tty) < 0)
{
logwarn("unable to set status of mouse fd");
return;
}
switch (new)
{
case 9600:
c = "*q";
cfsetispeed(&tty, B9600);
cfsetospeed(&tty, B9600);
break;
case 4800:
c = "*p";
cfsetispeed(&tty, B4800);
cfsetospeed(&tty, B4800);
break;
case 2400:
c = "*o";
cfsetispeed(&tty, B2400);
cfsetospeed(&tty, B2400);
break;
case 1200:
default:
c = "*n";
cfsetispeed(&tty, B1200);
cfsetospeed(&tty, B1200);
}
if (rodent.rtype == MOUSE_PROTO_LOGIMOUSEMAN
|| rodent.rtype == MOUSE_PROTO_LOGI)
{
if (write(rodent.mfd, c, 2) != 2)
{
logwarn("unable to write to mouse fd");
return;
}
}
usleep(100000);
if (tcsetattr(rodent.mfd, TCSADRAIN, &tty) < 0)
logwarn("unable to set status of mouse fd");
}
/*
* PnP COM device support
*
* It's a simplistic implementation, but it works :-)
* KY, 31/7/97.
*/
/*
* Try to elicit a PnP ID as described in
* Microsoft, Hayes: "Plug and Play External COM Device Specification,
* rev 1.00", 1995.
*
* The routine does not fully implement the COM Enumerator as par Section
* 2.1 of the document. In particular, we don't have idle state in which
* the driver software monitors the com port for dynamic connection or
* removal of a device at the port, because `moused' simply quits if no
* device is found.
*
* In addition, as PnP COM device enumeration procedure slightly has
* changed since its first publication, devices which follow earlier
* revisions of the above spec. may fail to respond if the rev 1.0
* procedure is used. XXX
*/
static int
pnpwakeup1(void)
{
struct timeval timeout;
fd_set fds;
int i;
/*
* This is the procedure described in rev 1.0 of PnP COM device spec.
* Unfortunately, some devices which comform to earlier revisions of
* the spec gets confused and do not return the ID string...
*/
debug("PnP COM device rev 1.0 probe...");
/* port initialization (2.1.2) */
ioctl(rodent.mfd, TIOCMGET, &i);
i |= TIOCM_DTR; /* DTR = 1 */
i &= ~TIOCM_RTS; /* RTS = 0 */
ioctl(rodent.mfd, TIOCMSET, &i);
usleep(240000);
/*
* The PnP COM device spec. dictates that the mouse must set DSR
* in response to DTR (by hardware or by software) and that if DSR is
* not asserted, the host computer should think that there is no device
* at this serial port. But some mice just don't do that...
*/
ioctl(rodent.mfd, TIOCMGET, &i);
debug("modem status 0%o", i);
if ((i & TIOCM_DSR) == 0)
return FALSE;
/* port setup, 1st phase (2.1.3) */
setmousespeed(1200, 1200, (CS7 | CREAD | CLOCAL | HUPCL));
i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
ioctl(rodent.mfd, TIOCMBIC, &i);
usleep(240000);
i = TIOCM_DTR; /* DTR = 1, RTS = 0 */
ioctl(rodent.mfd, TIOCMBIS, &i);
usleep(240000);
/* wait for response, 1st phase (2.1.4) */
i = FREAD;
ioctl(rodent.mfd, TIOCFLUSH, &i);
i = TIOCM_RTS; /* DTR = 1, RTS = 1 */
ioctl(rodent.mfd, TIOCMBIS, &i);
/* try to read something */
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 240000;
if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
debug("pnpwakeup1(): valid response in first phase.");
return TRUE;
}
/* port setup, 2nd phase (2.1.5) */
i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
ioctl(rodent.mfd, TIOCMBIC, &i);
usleep(240000);
/* wait for respose, 2nd phase (2.1.6) */
i = FREAD;
ioctl(rodent.mfd, TIOCFLUSH, &i);
i = TIOCM_DTR | TIOCM_RTS; /* DTR = 1, RTS = 1 */
ioctl(rodent.mfd, TIOCMBIS, &i);
/* try to read something */
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 240000;
if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
debug("pnpwakeup1(): valid response in second phase.");
return TRUE;
}
return FALSE;
}
static int
pnpwakeup2(void)
{
struct timeval timeout;
fd_set fds;
int i;
/*
* This is a simplified procedure; it simply toggles RTS.
*/
debug("alternate probe...");
ioctl(rodent.mfd, TIOCMGET, &i);
i |= TIOCM_DTR; /* DTR = 1 */
i &= ~TIOCM_RTS; /* RTS = 0 */
ioctl(rodent.mfd, TIOCMSET, &i);
usleep(240000);
setmousespeed(1200, 1200, (CS7 | CREAD | CLOCAL | HUPCL));
/* wait for respose */
i = FREAD;
ioctl(rodent.mfd, TIOCFLUSH, &i);
i = TIOCM_DTR | TIOCM_RTS; /* DTR = 1, RTS = 1 */
ioctl(rodent.mfd, TIOCMBIS, &i);
/* try to read something */
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 240000;
if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
debug("pnpwakeup2(): valid response.");
return TRUE;
}
return FALSE;
}
static int
pnpgets(char *buf)
{
struct timeval timeout;
fd_set fds;
int begin;
int i;
char c;
if (!pnpwakeup1() && !pnpwakeup2()) {
/*
* According to PnP spec, we should set DTR = 1 and RTS = 0 while
* in idle state. But, `moused' shall set DTR = RTS = 1 and proceed,
* assuming there is something at the port even if it didn't
* respond to the PnP enumeration procedure.
*/
i = TIOCM_DTR | TIOCM_RTS; /* DTR = 1, RTS = 1 */
ioctl(rodent.mfd, TIOCMBIS, &i);
return 0;
}
/* collect PnP COM device ID (2.1.7) */
begin = -1;
i = 0;
usleep(240000); /* the mouse must send `Begin ID' within 200msec */
while (read(rodent.mfd, &c, 1) == 1) {
/* we may see "M", or "M3..." before `Begin ID' */
buf[i++] = c;
if ((c == 0x08) || (c == 0x28)) { /* Begin ID */
debug("begin-id %02x", c);
begin = i - 1;
break;
}
debug("%c %02x", c, c);
if (i >= 256)
break;
}
if (begin < 0) {
/* we haven't seen `Begin ID' in time... */
goto connect_idle;
}
++c; /* make it `End ID' */
for (;;) {
FD_ZERO(&fds);
FD_SET(rodent.mfd, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 240000;
if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) <= 0)
break;
read(rodent.mfd, &buf[i], 1);
if (buf[i++] == c) /* End ID */
break;
if (i >= 256)
break;
}
if (begin > 0) {
i -= begin;
bcopy(&buf[begin], &buf[0], i);
}
/* string may not be human readable... */
debug("len:%d, '%-*.*s'", i, i, i, buf);
if (buf[i - 1] == c)
return i; /* a valid PnP string */
/*
* According to PnP spec, we should set DTR = 1 and RTS = 0 while
* in idle state. But, `moused' shall leave the modem control lines
* as they are. See above.
*/
connect_idle:
/* we may still have something in the buffer */
return ((i > 0) ? i : 0);
}
static int
pnpparse(pnpid_t *id, char *buf, int len)
{
char s[3];
int offset;
int sum = 0;
int i, j;
id->revision = 0;
id->eisaid = NULL;
id->serial = NULL;
id->class = NULL;
id->compat = NULL;
id->description = NULL;
id->neisaid = 0;
id->nserial = 0;
id->nclass = 0;
id->ncompat = 0;
id->ndescription = 0;
if ((buf[0] != 0x28) && (buf[0] != 0x08)) {
/* non-PnP mice */
switch(buf[0]) {
default:
return FALSE;
case 'M': /* Microsoft */
id->eisaid = "PNP0F01";
break;
case 'H': /* MouseSystems */
id->eisaid = "PNP0F04";
break;
}
id->neisaid = strlen(id->eisaid);
id->class = "MOUSE";
id->nclass = strlen(id->class);
debug("non-PnP mouse '%c'", buf[0]);
return TRUE;
}
/* PnP mice */
offset = 0x28 - buf[0];
/* calculate checksum */
for (i = 0; i < len - 3; ++i) {
sum += buf[i];
buf[i] += offset;
}
sum += buf[len - 1];
for (; i < len; ++i)
buf[i] += offset;
debug("PnP ID string: '%*.*s'", len, len, buf);
/* revision */
buf[1] -= offset;
buf[2] -= offset;
id->revision = ((buf[1] & 0x3f) << 6) | (buf[2] & 0x3f);
debug("PnP rev %d.%02d", id->revision / 100, id->revision % 100);
/* EISA vender and product ID */
id->eisaid = &buf[3];
id->neisaid = 7;
/* option strings */
i = 10;
if (buf[i] == '\\') {
/* device serial # */
for (j = ++i; i < len; ++i) {
if (buf[i] == '\\')
break;
}
if (i >= len)
i -= 3;
if (i - j == 8) {
id->serial = &buf[j];
id->nserial = 8;
}
}
if (buf[i] == '\\') {
/* PnP class */
for (j = ++i; i < len; ++i) {
if (buf[i] == '\\')
break;
}
if (i >= len)
i -= 3;
if (i > j + 1) {
id->class = &buf[j];
id->nclass = i - j;
}
}
if (buf[i] == '\\') {
/* compatible driver */
for (j = ++i; i < len; ++i) {
if (buf[i] == '\\')
break;
}
/*
* PnP COM spec prior to v0.96 allowed '*' in this field,
* it's not allowed now; just igore it.
*/
if (buf[j] == '*')
++j;
if (i >= len)
i -= 3;
if (i > j + 1) {
id->compat = &buf[j];
id->ncompat = i - j;
}
}
if (buf[i] == '\\') {
/* product description */
for (j = ++i; i < len; ++i) {
if (buf[i] == ';')
break;
}
if (i >= len)
i -= 3;
if (i > j + 1) {
id->description = &buf[j];
id->ndescription = i - j;
}
}
/* checksum exists if there are any optional fields */
if ((id->nserial > 0) || (id->nclass > 0)
|| (id->ncompat > 0) || (id->ndescription > 0)) {
debug("PnP checksum: 0x%X", sum);
sprintf(s, "%02X", sum & 0x0ff);
if (strncmp(s, &buf[len - 3], 2) != 0) {
#if 0
/*
* I found some mice do not comply with the PnP COM device
* spec regarding checksum... XXX
*/
logwarnx("PnP checksum error", 0);
return FALSE;
#endif
}
}
return TRUE;
}
static symtab_t *
pnpproto(pnpid_t *id)
{
symtab_t *t;
int i, j;
if (id->nclass > 0)
if (strncmp(id->class, "MOUSE", id->nclass) != 0 &&
strncmp(id->class, "TABLET", id->nclass) != 0)
/* this is not a mouse! */
return NULL;
if (id->neisaid > 0) {
t = gettoken(pnpprod, id->eisaid, id->neisaid);
if (t->val != MOUSE_PROTO_UNKNOWN)
return t;
}
/*
* The 'Compatible drivers' field may contain more than one
* ID separated by ','.
*/
if (id->ncompat <= 0)
return NULL;
for (i = 0; i < id->ncompat; ++i) {
for (j = i; id->compat[i] != ','; ++i)
if (i >= id->ncompat)
break;
if (i > j) {
t = gettoken(pnpprod, id->compat + j, i - j);
if (t->val != MOUSE_PROTO_UNKNOWN)
return t;
}
}
return NULL;
}
/* name/val mapping */
static symtab_t *
gettoken(symtab_t *tab, char *s, int len)
{
int i;
for (i = 0; tab[i].name != NULL; ++i) {
if (strncmp(tab[i].name, s, len) == 0)
break;
}
return &tab[i];
}
static char *
gettokenname(symtab_t *tab, int val)
{
int i;
for (i = 0; tab[i].name != NULL; ++i) {
if (tab[i].val == val)
return tab[i].name;
}
return NULL;
}
/*
* code to read from the Genius Kidspad tablet.
The tablet responds to the COM PnP protocol 1.0 with EISA-ID KYE0005,
and to pre-pnp probes (RTS toggle) with 'T' (tablet ?)
9600, 8 bit, parity odd.
The tablet puts out 5 bytes. b0 (mask 0xb8, value 0xb8) contains
the proximity, tip and button info:
(byte0 & 0x1) true = tip pressed
(byte0 & 0x2) true = button pressed
(byte0 & 0x40) false = pen in proximity of tablet.
The next 4 bytes are used for coordinates xl, xh, yl, yh (7 bits valid).
Only absolute coordinates are returned, so we use the following approach:
we store the last coordinates sent when the pen went out of the tablet,
*
*/
typedef enum {
S_IDLE, S_PROXY, S_FIRST, S_DOWN, S_UP
} k_status ;
static int
kidspad(u_char rxc, mousestatus_t *act)
{
static int buf[5];
static int buflen = 0, b_prev = 0 , x_prev = -1, y_prev = -1 ;
static k_status status = S_IDLE ;
static struct timeval now ;
int x, y ;
if (buflen > 0 && (rxc & 0x80)) {
fprintf(stderr, "invalid code %d 0x%x\n", buflen, rxc);
buflen = 0 ;
}
if (buflen == 0 && (rxc & 0xb8) != 0xb8) {
fprintf(stderr, "invalid code 0 0x%x\n", rxc);
return 0 ; /* invalid code, no action */
}
buf[buflen++] = rxc ;
if (buflen < 5)
return 0 ;
buflen = 0 ; /* for next time... */
x = buf[1]+128*(buf[2] - 7) ;
if (x < 0) x = 0 ;
y = 28*128 - (buf[3] + 128* (buf[4] - 7)) ;
if (y < 0) y = 0 ;
x /= 8 ;
y /= 8 ;
act->flags = 0 ;
act->obutton = act->button ;
act->dx = act->dy = act->dz = 0 ;
gettimeofday(&now, NULL);
if (buf[0] & 0x40) /* pen went out of reach */
status = S_IDLE ;
else if (status == S_IDLE) { /* pen is newly near the tablet */
act->flags |= MOUSE_POSCHANGED ; /* force update */
status = S_PROXY ;
x_prev = x ;
y_prev = y ;
}
act->dx = x - x_prev ;
act->dy = y - y_prev ;
if (act->dx || act->dy)
act->flags |= MOUSE_POSCHANGED ;
x_prev = x ;
y_prev = y ;
if (b_prev != 0 && b_prev != buf[0]) { /* possibly record button change */
act->button = 0 ;
if (buf[0] & 0x01) /* tip pressed */
act->button |= MOUSE_BUTTON1DOWN ;
if (buf[0] & 0x02) /* button pressed */
act->button |= MOUSE_BUTTON2DOWN ;
act->flags |= MOUSE_BUTTONSCHANGED ;
}
b_prev = buf[0] ;
return act->flags ;
}
static void
mremote_serversetup(void)
{
struct sockaddr_un ad;
/* Open a UNIX domain stream socket to listen for mouse remote clients */
unlink(_PATH_MOUSEREMOTE);
if ((rodent.mremsfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
logerrx(1, "unable to create unix domain socket %s",_PATH_MOUSEREMOTE);
umask(0111);
bzero(&ad, sizeof(ad));
ad.sun_family = AF_UNIX;
strcpy(ad.sun_path, _PATH_MOUSEREMOTE);
#ifndef SUN_LEN
#define SUN_LEN(unp) (((char *)(unp)->sun_path - (char *)(unp)) + \
strlen((unp)->path))
#endif
if (bind(rodent.mremsfd, (struct sockaddr *) &ad, SUN_LEN(&ad)) < 0)
logerrx(1, "unable to bind unix domain socket %s", _PATH_MOUSEREMOTE);
listen(rodent.mremsfd, 1);
}
static void
mremote_clientchg(int add)
{
struct sockaddr_un ad;
int ad_len, fd;
if (rodent.rtype != MOUSE_PROTO_X10MOUSEREM)
return;
if (add) {
/* Accept client connection, if we don't already have one */
ad_len = sizeof(ad);
fd = accept(rodent.mremsfd, (struct sockaddr *) &ad, &ad_len);
if (fd < 0)
logwarnx("failed accept on mouse remote socket");
if (rodent.mremcfd < 0) {
rodent.mremcfd = fd;
debug("remote client connect...accepted");
}
else {
close(fd);
debug("another remote client connect...disconnected");
}
}
else {
/* Client disconnected */
debug("remote client disconnected");
close(rodent.mremcfd);
rodent.mremcfd = -1;
}
}
| 28.830346 | 114 | 0.613728 |
8d8015c28170b0aadf87283c6445e8ec6d4d7c05 | 2,912 | h | C | net/tapi/skywalker/rend/rndreg.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | net/tapi/skywalker/rend/rndreg.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | net/tapi/skywalker/rend/rndreg.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*++
Copyright (c) 1997-2000 Microsoft Corporation
Module Name:
rndreg.h
Abstract:
Definitions for registry operation classes.
--*/
#ifndef __RENDEZVOUS_REGISTRY__
#define __RENDEZVOUS_REGISTRY__
#pragma once
#include "rndcommc.h"
const DWORD MAX_REG_WSTR_SIZE = 100;
const DWORD MAX_BLOB_TEMPLATE_SIZE = 2000;
const WCHAR REG_SERVER_NAME[] = L"ServerName";
typedef struct
{
OBJECT_ATTRIBUTE Attribute;
WCHAR * wstrValue;
} REG_INFO;
extern REG_INFO g_ConfInstInfoArray[];
extern DWORD g_ContInstInfoArraySize;
class KEY_WRAP
{
public:
KEY_WRAP(IN HKEY Key) : m_Key(Key) {}
~KEY_WRAP() { if (m_Key) RegCloseKey(m_Key); m_Key = NULL; }
protected:
HKEY m_Key;
};
class CRegistry
{
public:
static WCHAR ms_ServerName[MAX_REG_WSTR_SIZE];
static WCHAR ms_ProtocolId[MAX_REG_WSTR_SIZE];
static WCHAR ms_SubType[MAX_REG_WSTR_SIZE];
static WCHAR ms_AdvertisingScope[MAX_REG_WSTR_SIZE];
static WCHAR ms_IsEncrypted[MAX_REG_WSTR_SIZE];
static DWORD ms_StartTimeOffset;
static DWORD ms_StopTimeOffset;
CRegistry();
~CRegistry() { if (m_RendezvousKey) RegCloseKey(m_RendezvousKey); }
// inline CCriticalSection &GetCriticalSection();
// inline CEvent &GetEvent();
BOOL NotifyServerNameChange();
static BOOL IsValid() { return (ERROR_SUCCESS == ms_ErrorCode); }
static DWORD GetErrorCode() { return ms_ErrorCode; }
static WCHAR * GetServerName() { return ms_ServerName; }
static WCHAR * GetProtocolId() { return ms_ProtocolId; }
static WCHAR * GetSubType() { return ms_SubType; }
static WCHAR * GetAdvertizingScope() { return ms_AdvertisingScope; }
static WCHAR * GetIsEncrypted() { return ms_IsEncrypted; }
protected:
static DWORD ms_ErrorCode;
// the key is open throughout the lifetime of the CRegistry instance,
// so that any modifications to values under the key may be monitored
HKEY m_RendezvousKey;
// the critical section and the event (in particular) have been declared
// as instance members (rather than static) because the order of
// initialization of static variables is undefined and the event is used
// in the CRegistry constructor
// CCriticalSection m_CriticalSection;
// CEvent m_Event;
static BOOL ReadConfInstValues(
IN HKEY ConfInstKey
);
static BOOL ReadRegValue(
IN HKEY Key,
IN const WCHAR * pName,
IN WCHAR * pValue
);
};
/*
inline CCriticalSection &
CRegistry::GetCriticalSection(
)
{
return m_CriticalSection;
}
inline CEvent &
CRegistry::GetEvent(
)
{
return m_Event;
}
*/
#endif // __RENDEZVOUS_REGISTRY__
| 23.111111 | 80 | 0.654876 |
022f89bdc43569d47a1f9eeb7a762ea8fbdced2e | 863 | c | C | src/stack.c | suransea/libcoll | bc9e459dad6f63b30e9cbc98de3c74685f21311f | [
"Apache-2.0"
] | 1 | 2022-03-04T11:16:02.000Z | 2022-03-04T11:16:02.000Z | src/stack.c | suransea/libcoll | bc9e459dad6f63b30e9cbc98de3c74685f21311f | [
"Apache-2.0"
] | null | null | null | src/stack.c | suransea/libcoll | bc9e459dad6f63b30e9cbc98de3c74685f21311f | [
"Apache-2.0"
] | null | null | null | //
// Created by sea on 2019/11/28.
//
#include "coll/stack.h"
void coll_stack_init(coll_stack_t *stack, size_t cap) {
coll_vector_init(stack, cap);
}
void coll_stack_push(coll_stack_t *stack, void *data) {
coll_vector_append(stack, data);
}
void *coll_stack_pop(coll_stack_t *stack) {
return coll_vector_remove_last(stack);
}
void *coll_stack_peek(coll_stack_t *stack) {
return coll_vector_last(stack);
}
size_t coll_stack_size(coll_stack_t *stack) {
return coll_vector_size(stack);
}
bool coll_stack_empty(coll_stack_t *stack) {
return coll_vector_empty(stack);
}
void coll_stack_foreach(coll_stack_t *stack, void (*visit)(void *)) {
coll_vector_foreach(stack, visit);
}
void coll_stack_clear(coll_stack_t *stack) {
coll_vector_clear(stack);
}
void coll_stack_free(coll_stack_t *stack) {
coll_vector_free(stack);
}
| 20.547619 | 69 | 0.739282 |
e28a34ce02c89bc6b0699afd01fb2b1590f20876 | 705 | h | C | System/Library/CoreServices/SpringBoard/PrivateHeaders/SBIconImageAppLowQualityCrossfadeView.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 12 | 2019-06-02T02:42:41.000Z | 2021-04-13T07:22:20.000Z | System/Library/CoreServices/SpringBoard/PrivateHeaders/SBIconImageAppLowQualityCrossfadeView.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | null | null | null | System/Library/CoreServices/SpringBoard/PrivateHeaders/SBIconImageAppLowQualityCrossfadeView.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 3 | 2019-06-11T02:46:10.000Z | 2019-12-21T14:58:16.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "SBIconImageAppCrossfadeView.h"
@class SBAnimatableCorneredView;
@interface SBIconImageAppLowQualityCrossfadeView : SBIconImageAppCrossfadeView
{
SBAnimatableCorneredView *_imageViewCornerView; // 8 = 0x8
SBAnimatableCorneredView *_crossfadeViewCornerView; // 16 = 0x10
}
- (void).cxx_destruct; // IMP=0x00000001000de32c
- (void)cleanup; // IMP=0x00000001000de2d0
- (void)applyCornerRadius:(double)arg1; // IMP=0x00000001000de2b8
- (id)crossfadeViewParentView; // IMP=0x00000001000de258
- (id)imageViewParentView; // IMP=0x00000001000de1f8
@end
| 28.2 | 83 | 0.758865 |
9932a2a7cda72fe88dc2e6a10b3aeda4a8daa979 | 1,177 | h | C | src/prefs/GUIPrefs.h | Evropa1/audacity | 3be57fce49d293bd64cb0904b3883c885503ab2e | [
"CC-BY-3.0"
] | 21 | 2015-08-02T20:43:37.000Z | 2022-02-06T04:19:16.000Z | src/prefs/GUIPrefs.h | Evropa1/audacity | 3be57fce49d293bd64cb0904b3883c885503ab2e | [
"CC-BY-3.0"
] | null | null | null | src/prefs/GUIPrefs.h | Evropa1/audacity | 3be57fce49d293bd64cb0904b3883c885503ab2e | [
"CC-BY-3.0"
] | 3 | 2016-05-15T05:35:57.000Z | 2018-09-21T20:50:11.000Z | /**********************************************************************
Audacity: A Digital Audio Editor
GUIPrefs.h
Brian Gunlogson
Joshua Haberman
James Crook
**********************************************************************/
#ifndef __AUDACITY_GUI_PREFS__
#define __AUDACITY_GUI_PREFS__
#include <wx/defs.h>
#include <wx/arrstr.h>
#include <wx/window.h>
#include "PrefsPanel.h"
class ShuttleGui;
class GUIPrefs final : public PrefsPanel
{
public:
GUIPrefs(wxWindow * parent, wxWindowID winid);
~GUIPrefs();
bool Commit() override;
wxString HelpPageName() override;
void PopulateOrExchange(ShuttleGui & S) override;
static void GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes);
private:
void Populate();
wxArrayString mLangCodes;
wxArrayString mLangNames;
wxArrayString mHtmlHelpCodes;
wxArrayString mHtmlHelpChoices;
wxArrayString mThemeCodes;
wxArrayString mThemeChoices;
wxArrayString mRangeCodes;
wxArrayString mRangeChoices;
};
class GUIPrefsFactory final : public PrefsPanelFactory
{
public:
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
};
#endif
| 20.293103 | 79 | 0.663551 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.